mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
before rm lu
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
f7c9c9ef72
commit
ea16f6608c
25 changed files with 70 additions and 3878 deletions
|
@ -28,7 +28,6 @@ add_executable(shell
|
|||
opt_frontend.cpp
|
||||
smtlib_frontend.cpp
|
||||
z3_log_frontend.cpp
|
||||
lp_frontend.cpp
|
||||
# FIXME: shell should really link against libz3 but it can't due to requiring
|
||||
# use of some hidden symbols. Also libz3 has the ``api_dll`` component which
|
||||
# we don't want (I think).
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2016 Microsoft Corporation
|
||||
|
||||
Author:
|
||||
|
||||
Lev Nachmanson 2016-10-27
|
||||
|
||||
--*/
|
||||
|
||||
#include "math/lp/lp_settings.h"
|
||||
#include "math/lp/mps_reader.h"
|
||||
#include "util/timeout.h"
|
||||
#include "util/cancel_eh.h"
|
||||
#include "util/scoped_timer.h"
|
||||
#include "util/rlimit.h"
|
||||
#include "util/gparams.h"
|
||||
#include "util/mutex.h"
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "smt/params/smt_params_helper.hpp"
|
||||
|
||||
namespace {
|
||||
static mutex *display_stats_mux = new mutex;
|
||||
|
||||
static lp::lp_solver<double, double>* g_solver = nullptr;
|
||||
|
||||
static void display_statistics() {
|
||||
lock_guard lock(*display_stats_mux);
|
||||
if (g_solver && g_solver->settings().print_statistics) {
|
||||
// TBD display relevant information about statistics
|
||||
}
|
||||
}
|
||||
|
||||
static void STD_CALL on_ctrl_c(int) {
|
||||
signal (SIGINT, SIG_DFL);
|
||||
display_statistics();
|
||||
raise(SIGINT);
|
||||
}
|
||||
|
||||
static void on_timeout() {
|
||||
display_statistics();
|
||||
_Exit(0);
|
||||
}
|
||||
|
||||
struct front_end_resource_limit : public lp::lp_resource_limit {
|
||||
reslimit& m_reslim;
|
||||
|
||||
front_end_resource_limit(reslimit& lim):
|
||||
m_reslim(lim)
|
||||
{}
|
||||
|
||||
bool get_cancel_flag() override { return !m_reslim.inc(); }
|
||||
};
|
||||
|
||||
void run_solver(smt_params_helper & params, char const * mps_file_name) {
|
||||
|
||||
reslimit rlim;
|
||||
unsigned timeout = gparams::get_ref().get_uint("timeout", 0);
|
||||
unsigned rlimit = gparams::get_ref().get_uint("rlimit", 0);
|
||||
front_end_resource_limit lp_limit(rlim);
|
||||
|
||||
scoped_rlimit _rlimit(rlim, rlimit);
|
||||
cancel_eh<reslimit> eh(rlim);
|
||||
scoped_timer timer(timeout, &eh);
|
||||
|
||||
std::string fn(mps_file_name);
|
||||
lp::mps_reader<double, double> reader(fn);
|
||||
reader.set_message_stream(&std::cout); // can be redirected
|
||||
reader.read();
|
||||
if (!reader.is_ok()) {
|
||||
std::cerr << "cannot process " << mps_file_name << std::endl;
|
||||
return;
|
||||
}
|
||||
lp::lp_solver<double, double> * solver = reader.create_solver(false); // false - to create the primal solver
|
||||
solver->settings().set_resource_limit(lp_limit);
|
||||
g_solver = solver;
|
||||
if (params.arith_min()) {
|
||||
solver->flip_costs();
|
||||
}
|
||||
solver->settings().set_message_ostream(&std::cout);
|
||||
solver->settings().report_frequency = params.arith_rep_freq();
|
||||
solver->settings().print_statistics = params.arith_print_stats();
|
||||
solver->settings().set_simplex_strategy(lp:: simplex_strategy_enum::lu);
|
||||
|
||||
solver->find_maximal_solution();
|
||||
|
||||
*(solver->settings().get_message_ostream()) << "status is " << lp_status_to_string(solver->get_status()) << std::endl;
|
||||
if (solver->get_status() == lp::lp_status::OPTIMAL) {
|
||||
if (params.arith_min()) {
|
||||
solver->flip_costs();
|
||||
}
|
||||
solver->print_model(std::cout);
|
||||
}
|
||||
|
||||
display_statistics();
|
||||
g_solver = nullptr;
|
||||
delete solver;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned read_mps_file(char const * mps_file_name) {
|
||||
signal(SIGINT, on_ctrl_c);
|
||||
register_on_timeout_proc(on_timeout);
|
||||
smt_params_helper p;
|
||||
param_descrs r;
|
||||
p.collect_param_descrs(r);
|
||||
run_solver(p, mps_file_name);
|
||||
return 0;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
||||
|
||||
Author: Lev Nachmanson
|
||||
*/
|
||||
#pragma once
|
||||
unsigned read_mps_file(char const * mps_file_name);
|
|
@ -37,14 +37,13 @@ Revision History:
|
|||
#include "util/gparams.h"
|
||||
#include "util/env_params.h"
|
||||
#include "util/file_path.h"
|
||||
#include "shell/lp_frontend.h"
|
||||
#include "shell/drat_frontend.h"
|
||||
|
||||
#if defined( _WINDOWS ) && defined( __MINGW32__ ) && ( defined( __GNUG__ ) || defined( __clang__ ) )
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
typedef enum { IN_UNSPECIFIED, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_LP, IN_Z3_LOG, IN_MPS, IN_DRAT } input_kind;
|
||||
typedef enum { IN_UNSPECIFIED, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_LP, IN_Z3_LOG, IN_DRAT } input_kind;
|
||||
|
||||
static char const * g_input_file = nullptr;
|
||||
static char const * g_drat_input_file = nullptr;
|
||||
|
@ -377,10 +376,6 @@ int STD_CALL main(int argc, char ** argv) {
|
|||
else if (strcmp(ext, "smt2") == 0) {
|
||||
g_input_kind = IN_SMTLIB_2;
|
||||
}
|
||||
else if (strcmp(ext, "mps") == 0 || strcmp(ext, "sif") == 0 ||
|
||||
strcmp(ext, "MPS") == 0 || strcmp(ext, "SIF") == 0) {
|
||||
g_input_kind = IN_MPS;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (g_input_kind) {
|
||||
|
@ -406,9 +401,6 @@ int STD_CALL main(int argc, char ** argv) {
|
|||
case IN_Z3_LOG:
|
||||
replay_z3_log(g_input_file);
|
||||
break;
|
||||
case IN_MPS:
|
||||
return_value = read_mps_file(g_input_file);
|
||||
break;
|
||||
case IN_DRAT:
|
||||
return_value = read_drat(g_drat_input_file);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue