mirror of
https://github.com/Z3Prover/z3
synced 2025-06-06 14:13:23 +00:00
fix opb
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
d4a5873dc8
commit
11fee1c8d0
2 changed files with 24 additions and 12 deletions
|
@ -36,7 +36,7 @@ Revision History:
|
||||||
#include"gparams.h"
|
#include"gparams.h"
|
||||||
#include"env_params.h"
|
#include"env_params.h"
|
||||||
|
|
||||||
typedef enum { IN_UNSPECIFIED, IN_SMTLIB, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_PBO, IN_Z3_LOG } input_kind;
|
typedef enum { IN_UNSPECIFIED, IN_SMTLIB, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_Z3_LOG } input_kind;
|
||||||
|
|
||||||
std::string g_aux_input_file;
|
std::string g_aux_input_file;
|
||||||
char const * g_input_file = 0;
|
char const * g_input_file = 0;
|
||||||
|
@ -173,7 +173,7 @@ void parse_cmd_line_args(int argc, char ** argv) {
|
||||||
g_input_kind = IN_WCNF;
|
g_input_kind = IN_WCNF;
|
||||||
}
|
}
|
||||||
else if (strcmp(opt_name, "bpo") == 0) {
|
else if (strcmp(opt_name, "bpo") == 0) {
|
||||||
g_input_kind = IN_PBO;
|
g_input_kind = IN_OPB;
|
||||||
}
|
}
|
||||||
else if (strcmp(opt_name, "log") == 0) {
|
else if (strcmp(opt_name, "log") == 0) {
|
||||||
g_input_kind = IN_Z3_LOG;
|
g_input_kind = IN_Z3_LOG;
|
||||||
|
@ -316,8 +316,8 @@ int main(int argc, char ** argv) {
|
||||||
else if (strcmp(ext, "wcnf") == 0) {
|
else if (strcmp(ext, "wcnf") == 0) {
|
||||||
g_input_kind = IN_WCNF;
|
g_input_kind = IN_WCNF;
|
||||||
}
|
}
|
||||||
else if (strcmp(ext, "pbo") == 0) {
|
else if (strcmp(ext, "opb") == 0) {
|
||||||
g_input_kind = IN_PBO;
|
g_input_kind = IN_OPB;
|
||||||
}
|
}
|
||||||
else if (strcmp(ext, "log") == 0) {
|
else if (strcmp(ext, "log") == 0) {
|
||||||
g_input_kind = IN_Z3_LOG;
|
g_input_kind = IN_Z3_LOG;
|
||||||
|
@ -344,7 +344,7 @@ int main(int argc, char ** argv) {
|
||||||
case IN_WCNF:
|
case IN_WCNF:
|
||||||
return_value = parse_opt(g_input_file, true);
|
return_value = parse_opt(g_input_file, true);
|
||||||
break;
|
break;
|
||||||
case IN_PBO:
|
case IN_OPB:
|
||||||
return_value = parse_opt(g_input_file, false);
|
return_value = parse_opt(g_input_file, false);
|
||||||
break;
|
break;
|
||||||
case IN_DATALOG:
|
case IN_DATALOG:
|
||||||
|
|
|
@ -8,10 +8,8 @@
|
||||||
#include"timeout.h"
|
#include"timeout.h"
|
||||||
#include"reg_decl_plugins.h"
|
#include"reg_decl_plugins.h"
|
||||||
|
|
||||||
static bool g_display_statistics = false;
|
extern bool g_display_statistics;
|
||||||
static bool g_first_interrupt = true;
|
static bool g_first_interrupt = true;
|
||||||
static int g_timeout = 0;
|
|
||||||
static bool g_display_model = false;
|
|
||||||
static opt::context* g_opt = 0;
|
static opt::context* g_opt = 0;
|
||||||
static double g_start_time = 0;
|
static double g_start_time = 0;
|
||||||
static unsigned_vector g_handles;
|
static unsigned_vector g_handles;
|
||||||
|
@ -143,7 +141,10 @@ public:
|
||||||
opt.add_hard_constraint(cls);
|
opt.add_hard_constraint(cls);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
opt.add_soft_constraint(cls, rational(weight), symbol::null);
|
unsigned id = opt.add_soft_constraint(cls, rational(weight), symbol::null);
|
||||||
|
if (g_handles.empty()) {
|
||||||
|
g_handles.push_back(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,9 +256,16 @@ static void display_statistics() {
|
||||||
g_opt->collect_statistics(stats);
|
g_opt->collect_statistics(stats);
|
||||||
stats.display(std::cout);
|
stats.display(std::cout);
|
||||||
double end_time = static_cast<double>(clock());
|
double end_time = static_cast<double>(clock());
|
||||||
std::cout << "time: " << (end_time - g_start_time)/CLOCKS_PER_SEC << " secs\n";
|
std::cout << "time: " << (end_time - g_start_time)/CLOCKS_PER_SEC << " secs\n";
|
||||||
for (unsigned i = 0; i < g_handles.size(); ++i) {
|
for (unsigned i = 0; i < g_handles.size(); ++i) {
|
||||||
std::cout << " [" << g_opt->get_lower(g_handles[i]) << ":" << g_opt->get_upper(g_handles[i]) << "]\n";
|
expr_ref lo = g_opt->get_lower(g_handles[i]);
|
||||||
|
expr_ref hi = g_opt->get_upper(g_handles[i]);
|
||||||
|
if (lo == hi) {
|
||||||
|
std::cout << " " << lo << "\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << " [" << lo << ":" << hi << "]\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,7 +310,11 @@ static unsigned parse_opt(std::istream& in, bool is_wcnf) {
|
||||||
opb.parse();
|
opb.parse();
|
||||||
}
|
}
|
||||||
lbool r = opt.optimize();
|
lbool r = opt.optimize();
|
||||||
std::cout << r << "\n";
|
switch (r) {
|
||||||
|
case l_true: std::cout << "sat\n"; break;
|
||||||
|
case l_false: std::cout << "unsat\n"; break;
|
||||||
|
case l_undef: std::cout << "unknown\n"; break;
|
||||||
|
}
|
||||||
#pragma omp critical (g_display_stats)
|
#pragma omp critical (g_display_stats)
|
||||||
{
|
{
|
||||||
display_statistics();
|
display_statistics();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue