mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
add LP parser option to front-end and opt context
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
20fe08d80c
commit
43441d0fd5
8 changed files with 459 additions and 176 deletions
|
@ -38,7 +38,7 @@ Revision History:
|
|||
#include "util/env_params.h"
|
||||
#include "shell/lp_frontend.h"
|
||||
|
||||
typedef enum { IN_UNSPECIFIED, IN_SMTLIB, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_Z3_LOG, IN_MPS } input_kind;
|
||||
typedef enum { IN_UNSPECIFIED, IN_SMTLIB, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_LP, IN_Z3_LOG, IN_MPS } input_kind;
|
||||
|
||||
std::string g_aux_input_file;
|
||||
char const * g_input_file = 0;
|
||||
|
@ -71,10 +71,12 @@ void display_usage() {
|
|||
std::cout << "]. (C) Copyright 2006-2016 Microsoft Corp.\n";
|
||||
std::cout << "Usage: z3 [options] [-file:]file\n";
|
||||
std::cout << "\nInput format:\n";
|
||||
std::cout << " -smt use parser for SMT input format.\n";
|
||||
std::cout << " -smt2 use parser for SMT 2 input format.\n";
|
||||
std::cout << " -dl use parser for Datalog input format.\n";
|
||||
std::cout << " -dimacs use parser for DIMACS input format.\n";
|
||||
std::cout << " -wcnf use parser for Weighted CNF DIMACS input format.\n";
|
||||
std::cout << " -opb use parser for PB optimization input format.\n";
|
||||
std::cout << " -lp use parser for a modest subset of CPLEX LP input format.\n";
|
||||
std::cout << " -log use parser for Z3 log input format.\n";
|
||||
std::cout << " -in read formula from standard input.\n";
|
||||
std::cout << "\nMiscellaneous:\n";
|
||||
|
@ -188,9 +190,12 @@ void parse_cmd_line_args(int argc, char ** argv) {
|
|||
else if (strcmp(opt_name, "wcnf") == 0) {
|
||||
g_input_kind = IN_WCNF;
|
||||
}
|
||||
else if (strcmp(opt_name, "bpo") == 0) {
|
||||
else if (strcmp(opt_name, "pbo") == 0) {
|
||||
g_input_kind = IN_OPB;
|
||||
}
|
||||
else if (strcmp(opt_name, "lp") == 0) {
|
||||
g_input_kind = IN_LP;
|
||||
}
|
||||
else if (strcmp(opt_name, "log") == 0) {
|
||||
g_input_kind = IN_Z3_LOG;
|
||||
}
|
||||
|
@ -322,6 +327,9 @@ int STD_CALL main(int argc, char ** argv) {
|
|||
else if (strcmp(ext, "opb") == 0) {
|
||||
g_input_kind = IN_OPB;
|
||||
}
|
||||
else if (strcmp(ext, "lp") == 0) {
|
||||
g_input_kind = IN_LP;
|
||||
}
|
||||
else if (strcmp(ext, "log") == 0) {
|
||||
g_input_kind = IN_Z3_LOG;
|
||||
}
|
||||
|
@ -349,10 +357,13 @@ int STD_CALL main(int argc, char ** argv) {
|
|||
return_value = read_dimacs(g_input_file);
|
||||
break;
|
||||
case IN_WCNF:
|
||||
return_value = parse_opt(g_input_file, true);
|
||||
return_value = parse_opt(g_input_file, wcnf_t);
|
||||
break;
|
||||
case IN_OPB:
|
||||
return_value = parse_opt(g_input_file, false);
|
||||
return_value = parse_opt(g_input_file, opb_t);
|
||||
break;
|
||||
case IN_LP:
|
||||
return_value = parse_opt(g_input_file, lp_t);
|
||||
break;
|
||||
case IN_DATALOG:
|
||||
read_datalog(g_input_file);
|
||||
|
|
|
@ -14,6 +14,7 @@ Copyright (c) 2015 Microsoft Corporation
|
|||
#include "util/timeout.h"
|
||||
#include "ast/reg_decl_plugins.h"
|
||||
#include "opt/opt_parse.h"
|
||||
#include "shell/opt_frontend.h"
|
||||
|
||||
extern bool g_display_statistics;
|
||||
static bool g_first_interrupt = true;
|
||||
|
@ -73,18 +74,23 @@ static void on_timeout() {
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned parse_opt(std::istream& in, bool is_wcnf) {
|
||||
static unsigned parse_opt(std::istream& in, opt_format f) {
|
||||
ast_manager m;
|
||||
reg_decl_plugins(m);
|
||||
opt::context opt(m);
|
||||
g_opt = &opt;
|
||||
params_ref p = gparams::get_module("opt");
|
||||
opt.updt_params(p);
|
||||
if (is_wcnf) {
|
||||
switch (f) {
|
||||
case wcnf_t:
|
||||
parse_wcnf(opt, in, g_handles);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
case opb_t:
|
||||
parse_opb(opt, in, g_handles);
|
||||
break;
|
||||
case lp_t:
|
||||
parse_lp(opt, in, g_handles);
|
||||
break;
|
||||
}
|
||||
try {
|
||||
lbool r = opt.optimize();
|
||||
|
@ -121,7 +127,7 @@ static unsigned parse_opt(std::istream& in, bool is_wcnf) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
unsigned parse_opt(char const* file_name, bool is_wcnf) {
|
||||
unsigned parse_opt(char const* file_name, opt_format f) {
|
||||
g_first_interrupt = true;
|
||||
g_start_time = static_cast<double>(clock());
|
||||
register_on_timeout_proc(on_timeout);
|
||||
|
@ -132,10 +138,10 @@ unsigned parse_opt(char const* file_name, bool is_wcnf) {
|
|||
std::cerr << "(error \"failed to open file '" << file_name << "'\")" << std::endl;
|
||||
exit(ERR_OPEN_FILE);
|
||||
}
|
||||
return parse_opt(in, is_wcnf);
|
||||
return parse_opt(in, f);
|
||||
}
|
||||
else {
|
||||
return parse_opt(std::cin, is_wcnf);
|
||||
return parse_opt(std::cin, f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,9 @@ Author:
|
|||
#ifndef OPT_FRONTEND_H_
|
||||
#define OPT_FRONTEND_H_
|
||||
|
||||
unsigned parse_opt(char const* file_name, bool is_wcnf);
|
||||
enum opt_format { opb_t, wcnf_t, lp_t };
|
||||
|
||||
unsigned parse_opt(char const* file_name, opt_format f);
|
||||
|
||||
#endif /* OPT_FRONTEND_H_ */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue