mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 04:03:39 +00:00
Handle correctly cancelled run (#5695)
* remove the bound on total iterations in simplex
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
* remove unncesseray checks in get_freedom_interval_for_column()
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
* fix the build of test-z3
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
* Revert "remove unncesseray checks in get_freedom_interval_for_column()"
This reverts commit 6770ed85e3
.
* optimize get_freedom_interval_for_column() for feasible case
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
* add function lar_solver::status_feasible
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
* rename status_is_feasible() to is_feasible()
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
* fix the linux build
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
0242566792
commit
7758b519bc
|
@ -324,6 +324,7 @@ static void set_upper(impq & u, bool & inf_u, impq const & v) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this function assumes that all basic columns dependend on j are feasible
|
||||||
bool int_solver::get_freedom_interval_for_column(unsigned j, bool & inf_l, impq & l, bool & inf_u, impq & u, mpq & m) {
|
bool int_solver::get_freedom_interval_for_column(unsigned j, bool & inf_l, impq & l, bool & inf_u, impq & u, mpq & m) {
|
||||||
if (lrac.m_r_heading[j] >= 0) // the basic var
|
if (lrac.m_r_heading[j] >= 0) // the basic var
|
||||||
return false;
|
return false;
|
||||||
|
@ -360,13 +361,12 @@ bool int_solver::get_freedom_interval_for_column(unsigned j, bool & inf_l, impq
|
||||||
const mpq & a = c.coeff();
|
const mpq & a = c.coeff();
|
||||||
unsigned i = lrac.m_r_basis[row_index];
|
unsigned i = lrac.m_r_basis[row_index];
|
||||||
impq const & xi = get_value(i);
|
impq const & xi = get_value(i);
|
||||||
|
lp_assert(lrac.m_r_solver.column_is_feasible(i));
|
||||||
if (column_is_int(i) && !a.is_int())
|
if (column_is_int(i) && !a.is_int())
|
||||||
m = lcm(m, denominator(a));
|
m = lcm(m, denominator(a));
|
||||||
|
|
||||||
|
|
||||||
if (!inf_l && !inf_u) {
|
if (!inf_l && !inf_u) {
|
||||||
if (l > u)
|
|
||||||
break;
|
|
||||||
if (l == u)
|
if (l == u)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,11 +179,17 @@ void lar_core_solver::solve() {
|
||||||
}
|
}
|
||||||
lp_assert(!settings().use_tableau() || r_basis_is_OK());
|
lp_assert(!settings().use_tableau() || r_basis_is_OK());
|
||||||
}
|
}
|
||||||
if (m_r_solver.get_status() == lp_status::INFEASIBLE) {
|
switch (m_r_solver.get_status())
|
||||||
|
{
|
||||||
|
case lp_status::INFEASIBLE:
|
||||||
fill_not_improvable_zero_sum();
|
fill_not_improvable_zero_sum();
|
||||||
}
|
break;
|
||||||
else if (m_r_solver.get_status() != lp_status::UNBOUNDED) {
|
case lp_status::CANCELLED:
|
||||||
|
case lp_status::UNBOUNDED: // do nothing in these cases
|
||||||
|
break;
|
||||||
|
default: // adjust the status to optimal
|
||||||
m_r_solver.set_status(lp_status::OPTIMAL);
|
m_r_solver.set_status(lp_status::OPTIMAL);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
lp_assert(r_basis_is_OK());
|
lp_assert(r_basis_is_OK());
|
||||||
lp_assert(m_r_solver.non_basic_columns_are_set_correctly());
|
lp_assert(m_r_solver.non_basic_columns_are_set_correctly());
|
||||||
|
|
|
@ -798,6 +798,18 @@ namespace lp {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// this function just looks at the status
|
||||||
|
bool lar_solver::is_feasible() const {
|
||||||
|
switch (this->get_status()) {
|
||||||
|
case lp_status::OPTIMAL:
|
||||||
|
case lp_status::FEASIBLE:
|
||||||
|
case lp_status::UNBOUNDED:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
numeric_pair<mpq> lar_solver::get_basic_var_value_from_row(unsigned i) {
|
numeric_pair<mpq> lar_solver::get_basic_var_value_from_row(unsigned i) {
|
||||||
numeric_pair<mpq> r = zero_of_type<numeric_pair<mpq>>();
|
numeric_pair<mpq> r = zero_of_type<numeric_pair<mpq>>();
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,8 @@ class lar_solver : public column_namer {
|
||||||
mutable mpq m_delta;
|
mutable mpq m_delta;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// this function just looks at the status
|
||||||
|
bool is_feasible() const;
|
||||||
const map<mpq, unsigned, obj_hash<mpq>, default_eq<mpq>>& fixed_var_table_int() const {
|
const map<mpq, unsigned, obj_hash<mpq>, default_eq<mpq>>& fixed_var_table_int() const {
|
||||||
return m_fixed_var_table_int;
|
return m_fixed_var_table_int;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,10 +100,7 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::done() {
|
||||||
if (this->get_status() == lp_status::OPTIMAL) {
|
if (this->get_status() == lp_status::OPTIMAL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this->total_iterations() > this->m_settings.max_total_number_of_iterations) { // debug !!!!
|
|
||||||
this->set_status(lp_status::ITERATIONS_EXHAUSTED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false; // todo, need to be more cases
|
return false; // todo, need to be more cases
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,6 +744,6 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::solve() { // s
|
||||||
one_iteration();
|
one_iteration();
|
||||||
} while (this->get_status() != lp_status::FLOATING_POINT_ERROR && this->get_status() != lp_status::DUAL_UNBOUNDED && this->get_status() != lp_status::OPTIMAL &&
|
} while (this->get_status() != lp_status::FLOATING_POINT_ERROR && this->get_status() != lp_status::DUAL_UNBOUNDED && this->get_status() != lp_status::OPTIMAL &&
|
||||||
this->iters_with_no_cost_growing() <= this->m_settings.max_number_of_iterations_with_no_improvements
|
this->iters_with_no_cost_growing() <= this->m_settings.max_number_of_iterations_with_no_improvements
|
||||||
&& this->total_iterations() <= this->m_settings.max_total_number_of_iterations);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,6 @@ template <typename T, typename X> void lp_dual_simplex<T, X>::decide_on_status_a
|
||||||
break;
|
break;
|
||||||
case lp_status::DUAL_UNBOUNDED:
|
case lp_status::DUAL_UNBOUNDED:
|
||||||
lp_unreachable();
|
lp_unreachable();
|
||||||
case lp_status::ITERATIONS_EXHAUSTED:
|
|
||||||
this->m_status = lp_status::ITERATIONS_EXHAUSTED;
|
|
||||||
break;
|
|
||||||
case lp_status::TIME_EXHAUSTED:
|
case lp_status::TIME_EXHAUSTED:
|
||||||
this->m_status = lp_status::TIME_EXHAUSTED;
|
this->m_status = lp_status::TIME_EXHAUSTED;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -956,8 +956,6 @@ template <typename T, typename X> unsigned lp_primal_core_solver<T, X>::solve()
|
||||||
&&
|
&&
|
||||||
this->iters_with_no_cost_growing() <= this->m_settings.max_number_of_iterations_with_no_improvements
|
this->iters_with_no_cost_growing() <= this->m_settings.max_number_of_iterations_with_no_improvements
|
||||||
&&
|
&&
|
||||||
this->total_iterations() <= this->m_settings.max_total_number_of_iterations
|
|
||||||
&&
|
|
||||||
!(this->current_x_is_feasible() && this->m_look_for_feasible_solution_only));
|
!(this->current_x_is_feasible() && this->m_look_for_feasible_solution_only));
|
||||||
|
|
||||||
lp_assert(this->get_status() == lp_status::FLOATING_POINT_ERROR
|
lp_assert(this->get_status() == lp_status::FLOATING_POINT_ERROR
|
||||||
|
@ -1097,10 +1095,8 @@ template <typename T, typename X> bool lp_primal_core_solver<T, X>::done() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this->m_iters_with_no_cost_growing >= this->m_settings.max_number_of_iterations_with_no_improvements) {
|
if (this->m_iters_with_no_cost_growing >= this->m_settings.max_number_of_iterations_with_no_improvements) {
|
||||||
this->get_status() = lp_status::ITERATIONS_EXHAUSTED; return true;
|
this->set_status(lp_status::CANCELLED);
|
||||||
}
|
return true;
|
||||||
if (this->total_iterations() >= this->m_settings.max_total_number_of_iterations) {
|
|
||||||
this->get_status() = lp_status::ITERATIONS_EXHAUSTED; return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,9 +182,7 @@ unsigned lp_primal_core_solver<T, X>::solve_with_tableau() {
|
||||||
if (this->m_settings.get_cancel_flag()
|
if (this->m_settings.get_cancel_flag()
|
||||||
||
|
||
|
||||||
this->iters_with_no_cost_growing() > this->m_settings.max_number_of_iterations_with_no_improvements
|
this->iters_with_no_cost_growing() > this->m_settings.max_number_of_iterations_with_no_improvements
|
||||||
||
|
) {
|
||||||
this->total_iterations() > this->m_settings.max_total_number_of_iterations
|
|
||||||
) {
|
|
||||||
this->set_status(lp_status::CANCELLED);
|
this->set_status(lp_status::CANCELLED);
|
||||||
break; // from the loop
|
break; // from the loop
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,6 @@ enum class lp_status {
|
||||||
FEASIBLE,
|
FEASIBLE,
|
||||||
FLOATING_POINT_ERROR,
|
FLOATING_POINT_ERROR,
|
||||||
TIME_EXHAUSTED,
|
TIME_EXHAUSTED,
|
||||||
ITERATIONS_EXHAUSTED,
|
|
||||||
EMPTY,
|
EMPTY,
|
||||||
UNSTABLE,
|
UNSTABLE,
|
||||||
CANCELLED
|
CANCELLED
|
||||||
|
@ -210,7 +209,6 @@ public:
|
||||||
double harris_feasibility_tolerance { 1e-7 }; // page 179 of Istvan Maros
|
double harris_feasibility_tolerance { 1e-7 }; // page 179 of Istvan Maros
|
||||||
double ignore_epsilon_of_harris { 10e-5 };
|
double ignore_epsilon_of_harris { 10e-5 };
|
||||||
unsigned max_number_of_iterations_with_no_improvements { 2000000 };
|
unsigned max_number_of_iterations_with_no_improvements { 2000000 };
|
||||||
unsigned max_total_number_of_iterations { 20000000 };
|
|
||||||
double time_limit; // the maximum time limit of the total run time in seconds
|
double time_limit; // the maximum time limit of the total run time in seconds
|
||||||
// dual section
|
// dual section
|
||||||
double dual_feasibility_tolerance { 1e-7 }; // page 71 of the PhD thesis of Achim Koberstein
|
double dual_feasibility_tolerance { 1e-7 }; // page 71 of the PhD thesis of Achim Koberstein
|
||||||
|
|
|
@ -45,7 +45,6 @@ const char* lp_status_to_string(lp_status status) {
|
||||||
case lp_status::FEASIBLE: return "FEASIBLE";
|
case lp_status::FEASIBLE: return "FEASIBLE";
|
||||||
case lp_status::FLOATING_POINT_ERROR: return "FLOATING_POINT_ERROR";
|
case lp_status::FLOATING_POINT_ERROR: return "FLOATING_POINT_ERROR";
|
||||||
case lp_status::TIME_EXHAUSTED: return "TIME_EXHAUSTED";
|
case lp_status::TIME_EXHAUSTED: return "TIME_EXHAUSTED";
|
||||||
case lp_status::ITERATIONS_EXHAUSTED: return "ITERATIONS_EXHAUSTED";
|
|
||||||
case lp_status::EMPTY: return "EMPTY";
|
case lp_status::EMPTY: return "EMPTY";
|
||||||
case lp_status::UNSTABLE: return "UNSTABLE";
|
case lp_status::UNSTABLE: return "UNSTABLE";
|
||||||
default:
|
default:
|
||||||
|
@ -62,7 +61,6 @@ lp_status lp_status_from_string(std::string status) {
|
||||||
if (status == "FEASIBLE") return lp_status::FEASIBLE;
|
if (status == "FEASIBLE") return lp_status::FEASIBLE;
|
||||||
if (status == "FLOATING_POINT_ERROR") return lp_status::FLOATING_POINT_ERROR;
|
if (status == "FLOATING_POINT_ERROR") return lp_status::FLOATING_POINT_ERROR;
|
||||||
if (status == "TIME_EXHAUSTED") return lp_status::TIME_EXHAUSTED;
|
if (status == "TIME_EXHAUSTED") return lp_status::TIME_EXHAUSTED;
|
||||||
if (status == "ITERATIONS_EXHAUSTED") return lp_status::ITERATIONS_EXHAUSTED;
|
|
||||||
if (status == "EMPTY") return lp_status::EMPTY;
|
if (status == "EMPTY") return lp_status::EMPTY;
|
||||||
lp_unreachable();
|
lp_unreachable();
|
||||||
return lp_status::UNKNOWN; // it is unreachable
|
return lp_status::UNKNOWN; // it is unreachable
|
||||||
|
|
|
@ -158,13 +158,7 @@ public:
|
||||||
m_settings.time_limit = time_limit_in_seconds;
|
m_settings.time_limit = time_limit_in_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_max_iterations_per_stage(unsigned max_iterations) {
|
|
||||||
m_settings.max_total_number_of_iterations = max_iterations;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned get_max_iterations_per_stage() const {
|
|
||||||
return m_settings.max_total_number_of_iterations;
|
|
||||||
}
|
|
||||||
protected:
|
protected:
|
||||||
bool problem_is_empty();
|
bool problem_is_empty();
|
||||||
|
|
||||||
|
|
|
@ -3095,7 +3095,7 @@ public:
|
||||||
default:
|
default:
|
||||||
TRACE("arith", tout << "status treated as inconclusive: " << status << "\n";);
|
TRACE("arith", tout << "status treated as inconclusive: " << status << "\n";);
|
||||||
// TENTATIVE_UNBOUNDED, UNBOUNDED, TENTATIVE_DUAL_UNBOUNDED, DUAL_UNBOUNDED,
|
// TENTATIVE_UNBOUNDED, UNBOUNDED, TENTATIVE_DUAL_UNBOUNDED, DUAL_UNBOUNDED,
|
||||||
// FLOATING_POINT_ERROR, TIME_EXAUSTED, ITERATIONS_EXHAUSTED, EMPTY, UNSTABLE
|
// FLOATING_POINT_ERROR, TIME_EXAUSTED, EMPTY, UNSTABLE
|
||||||
return l_undef;
|
return l_undef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1396,10 +1396,7 @@ void update_settings(argument_parser & args_parser, lp_settings& settings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
void setup_solver(unsigned max_iterations, unsigned time_limit, bool look_for_min, argument_parser & args_parser, lp_solver<T, X> * solver) {
|
void setup_solver(unsigned time_limit, bool look_for_min, argument_parser & args_parser, lp_solver<T, X> * solver) {
|
||||||
if (max_iterations > 0)
|
|
||||||
solver->set_max_iterations_per_stage(max_iterations);
|
|
||||||
|
|
||||||
if (time_limit > 0)
|
if (time_limit > 0)
|
||||||
solver->set_time_limit(time_limit);
|
solver->set_time_limit(time_limit);
|
||||||
|
|
||||||
|
@ -1429,7 +1426,7 @@ void compare_solutions(mps_reader<double, double> & reader, lp_solver<double, do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void solve_mps_double(std::string file_name, bool look_for_min, unsigned max_iterations, unsigned time_limit, bool dual, bool compare_with_primal, argument_parser & args_parser) {
|
void solve_mps_double(std::string file_name, bool look_for_min, unsigned time_limit, bool dual, bool compare_with_primal, argument_parser & args_parser) {
|
||||||
mps_reader<double, double> reader(file_name);
|
mps_reader<double, double> reader(file_name);
|
||||||
reader.read();
|
reader.read();
|
||||||
if (!reader.is_ok()) {
|
if (!reader.is_ok()) {
|
||||||
|
@ -1438,7 +1435,7 @@ void solve_mps_double(std::string file_name, bool look_for_min, unsigned max_ite
|
||||||
}
|
}
|
||||||
|
|
||||||
lp_solver<double, double> * solver = reader.create_solver(dual);
|
lp_solver<double, double> * solver = reader.create_solver(dual);
|
||||||
setup_solver(max_iterations, time_limit, look_for_min, args_parser, solver);
|
setup_solver(time_limit, look_for_min, args_parser, solver);
|
||||||
stopwatch sw;
|
stopwatch sw;
|
||||||
sw.start();
|
sw.start();
|
||||||
if (dual) {
|
if (dual) {
|
||||||
|
@ -1461,7 +1458,7 @@ void solve_mps_double(std::string file_name, bool look_for_min, unsigned max_ite
|
||||||
std::cout << "processed in " << span / 1000.0 << " seconds, running for " << solver->m_total_iterations << " iterations" << " one iter for " << (double)span/solver->m_total_iterations << " ms" << std::endl;
|
std::cout << "processed in " << span / 1000.0 << " seconds, running for " << solver->m_total_iterations << " iterations" << " one iter for " << (double)span/solver->m_total_iterations << " ms" << std::endl;
|
||||||
if (compare_with_primal) {
|
if (compare_with_primal) {
|
||||||
auto * primal_solver = reader.create_solver(false);
|
auto * primal_solver = reader.create_solver(false);
|
||||||
setup_solver(max_iterations, time_limit, look_for_min, args_parser, primal_solver);
|
setup_solver(time_limit, look_for_min, args_parser, primal_solver);
|
||||||
primal_solver->find_maximal_solution();
|
primal_solver->find_maximal_solution();
|
||||||
if (solver->get_status() != primal_solver->get_status()) {
|
if (solver->get_status() != primal_solver->get_status()) {
|
||||||
std::cout << "statuses are different: dual " << lp_status_to_string(solver->get_status()) << " primal = " << lp_status_to_string(primal_solver->get_status()) << std::endl;
|
std::cout << "statuses are different: dual " << lp_status_to_string(solver->get_status()) << " primal = " << lp_status_to_string(primal_solver->get_status()) << std::endl;
|
||||||
|
@ -1489,12 +1486,12 @@ void solve_mps_double(std::string file_name, bool look_for_min, unsigned max_ite
|
||||||
delete solver;
|
delete solver;
|
||||||
}
|
}
|
||||||
|
|
||||||
void solve_mps_rational(std::string file_name, bool look_for_min, unsigned max_iterations, unsigned time_limit, bool dual, argument_parser & args_parser) {
|
void solve_mps_rational(std::string file_name, bool look_for_min, unsigned time_limit, bool dual, argument_parser & args_parser) {
|
||||||
mps_reader<lp::mpq, lp::mpq> reader(file_name);
|
mps_reader<lp::mpq, lp::mpq> reader(file_name);
|
||||||
reader.read();
|
reader.read();
|
||||||
if (reader.is_ok()) {
|
if (reader.is_ok()) {
|
||||||
auto * solver = reader.create_solver(dual);
|
auto * solver = reader.create_solver(dual);
|
||||||
setup_solver(max_iterations, time_limit, look_for_min, args_parser, solver);
|
setup_solver(time_limit, look_for_min, args_parser, solver);
|
||||||
stopwatch sw;
|
stopwatch sw;
|
||||||
sw.start();
|
sw.start();
|
||||||
solver->find_maximal_solution();
|
solver->find_maximal_solution();
|
||||||
|
@ -1516,27 +1513,27 @@ void solve_mps_rational(std::string file_name, bool look_for_min, unsigned max_i
|
||||||
std::cout << "cannot process " << file_name << std::endl;
|
std::cout << "cannot process " << file_name << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void get_time_limit_and_max_iters_from_parser(argument_parser & args_parser, unsigned & time_limit, unsigned & max_iters); // forward definition
|
void get_time_limit_and_max_iters_from_parser(argument_parser & args_parser, unsigned & time_limit); // forward definition
|
||||||
|
|
||||||
void solve_mps(std::string file_name, bool look_for_min, unsigned max_iterations, unsigned time_limit, bool solve_for_rational, bool dual, bool compare_with_primal, argument_parser & args_parser) {
|
void solve_mps(std::string file_name, bool look_for_min, unsigned time_limit, bool solve_for_rational, bool dual, bool compare_with_primal, argument_parser & args_parser) {
|
||||||
if (!solve_for_rational) {
|
if (!solve_for_rational) {
|
||||||
std::cout << "solving " << file_name << std::endl;
|
std::cout << "solving " << file_name << std::endl;
|
||||||
solve_mps_double(file_name, look_for_min, max_iterations, time_limit, dual, compare_with_primal, args_parser);
|
solve_mps_double(file_name, look_for_min, time_limit, dual, compare_with_primal, args_parser);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << "solving " << file_name << " in rationals " << std::endl;
|
std::cout << "solving " << file_name << " in rationals " << std::endl;
|
||||||
solve_mps_rational(file_name, look_for_min, max_iterations, time_limit, dual, args_parser);
|
solve_mps_rational(file_name, look_for_min, time_limit, dual, args_parser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void solve_mps(std::string file_name, argument_parser & args_parser) {
|
void solve_mps(std::string file_name, argument_parser & args_parser) {
|
||||||
bool look_for_min = args_parser.option_is_used("--min");
|
bool look_for_min = args_parser.option_is_used("--min");
|
||||||
unsigned max_iterations, time_limit;
|
unsigned time_limit;
|
||||||
bool solve_for_rational = args_parser.option_is_used("--mpq");
|
bool solve_for_rational = args_parser.option_is_used("--mpq");
|
||||||
bool dual = args_parser.option_is_used("--dual");
|
bool dual = args_parser.option_is_used("--dual");
|
||||||
bool compare_with_primal = args_parser.option_is_used("--compare_with_primal");
|
bool compare_with_primal = args_parser.option_is_used("--compare_with_primal");
|
||||||
get_time_limit_and_max_iters_from_parser(args_parser, time_limit, max_iterations);
|
get_time_limit_and_max_iters_from_parser(args_parser, time_limit);
|
||||||
solve_mps(file_name, look_for_min, max_iterations, time_limit, solve_for_rational, dual, compare_with_primal, args_parser);
|
solve_mps(file_name, look_for_min, time_limit, solve_for_rational, dual, compare_with_primal, args_parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
void solve_mps_in_rational(std::string file_name, bool dual, argument_parser & /*args_parser*/) {
|
void solve_mps_in_rational(std::string file_name, bool dual, argument_parser & /*args_parser*/) {
|
||||||
|
@ -1903,7 +1900,7 @@ void process_test_file(std::string test_dir, std::string test_file_name, argumen
|
||||||
|
|
||||||
void solve_some_mps(argument_parser & args_parser) {
|
void solve_some_mps(argument_parser & args_parser) {
|
||||||
unsigned max_iters, time_limit;
|
unsigned max_iters, time_limit;
|
||||||
get_time_limit_and_max_iters_from_parser(args_parser, time_limit, max_iters);
|
get_time_limit_and_max_iters_from_parser(args_parser, time_limit);
|
||||||
unsigned successes = 0;
|
unsigned successes = 0;
|
||||||
unsigned failures = 0;
|
unsigned failures = 0;
|
||||||
unsigned inconclusives = 0;
|
unsigned inconclusives = 0;
|
||||||
|
@ -1935,7 +1932,7 @@ void solve_some_mps(argument_parser & args_parser) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!solve_for_rational) {
|
if (!solve_for_rational) {
|
||||||
solve_mps(file_names[6], false, 0, time_limit, false, dual, compare_with_primal, args_parser);
|
solve_mps(file_names[6], false, time_limit, false, dual, compare_with_primal, args_parser);
|
||||||
solve_mps_with_known_solution(file_names[3], nullptr, lp_status::INFEASIBLE, dual); // chvatal: 135(d)
|
solve_mps_with_known_solution(file_names[3], nullptr, lp_status::INFEASIBLE, dual); // chvatal: 135(d)
|
||||||
std::unordered_map<std::string, double> sol;
|
std::unordered_map<std::string, double> sol;
|
||||||
sol["X1"] = 0;
|
sol["X1"] = 0;
|
||||||
|
@ -1960,11 +1957,11 @@ void solve_some_mps(argument_parser & args_parser) {
|
||||||
solve_mps_with_known_solution(file_names[4], &sol, lp_status::OPTIMAL, dual); // chvatal: 135(e)
|
solve_mps_with_known_solution(file_names[4], &sol, lp_status::OPTIMAL, dual); // chvatal: 135(e)
|
||||||
solve_mps_with_known_solution(file_names[2], nullptr, lp_status::UNBOUNDED, dual); // chvatal: 135(c)
|
solve_mps_with_known_solution(file_names[2], nullptr, lp_status::UNBOUNDED, dual); // chvatal: 135(c)
|
||||||
solve_mps_with_known_solution(file_names[1], nullptr, lp_status::UNBOUNDED, dual); // chvatal: 135(b)
|
solve_mps_with_known_solution(file_names[1], nullptr, lp_status::UNBOUNDED, dual); // chvatal: 135(b)
|
||||||
solve_mps(file_names[8], false, 0, time_limit, false, dual, compare_with_primal, args_parser);
|
solve_mps(file_names[8], false, time_limit, false, dual, compare_with_primal, args_parser);
|
||||||
// return;
|
// return;
|
||||||
for (auto& s : file_names) {
|
for (auto& s : file_names) {
|
||||||
try {
|
try {
|
||||||
solve_mps(s, minimums.find(s) != minimums.end(), max_iters, time_limit, false, dual, compare_with_primal, args_parser);
|
solve_mps(s, minimums.find(s) != minimums.end(), time_limit, false, dual, compare_with_primal, args_parser);
|
||||||
}
|
}
|
||||||
catch(const char *s){
|
catch(const char *s){
|
||||||
std::cout<< "exception: "<< s << std::endl;
|
std::cout<< "exception: "<< s << std::endl;
|
||||||
|
@ -2315,14 +2312,7 @@ void finalize(unsigned ret) {
|
||||||
// return ret;
|
// return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_time_limit_and_max_iters_from_parser(argument_parser & args_parser, unsigned & time_limit, unsigned & max_iters) {
|
void get_time_limit_and_max_iters_from_parser(argument_parser & args_parser, unsigned & time_limit) {
|
||||||
std::string s = args_parser.get_option_value("--max_iters");
|
|
||||||
if (!s.empty()) {
|
|
||||||
max_iters = atoi(s.c_str());
|
|
||||||
} else {
|
|
||||||
max_iters = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string time_limit_string = args_parser.get_option_value("--time_limit");
|
std::string time_limit_string = args_parser.get_option_value("--time_limit");
|
||||||
if (!time_limit_string.empty()) {
|
if (!time_limit_string.empty()) {
|
||||||
time_limit = atoi(time_limit_string.c_str());
|
time_limit = atoi(time_limit_string.c_str());
|
||||||
|
@ -2504,7 +2494,7 @@ void process_test_file(std::string test_dir, std::string test_file_name, argumen
|
||||||
if (args_parser.option_is_used("--lar"))
|
if (args_parser.option_is_used("--lar"))
|
||||||
test_lar_on_file(input_file_name, args_parser);
|
test_lar_on_file(input_file_name, args_parser);
|
||||||
else
|
else
|
||||||
solve_mps(input_file_name, minimize, max_iters, time_limit, use_mpq, dual, false, args_parser);
|
solve_mps(input_file_name, minimize, time_limit, use_mpq, dual, false, args_parser);
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
std::cout << "catching the failure" << std::endl;
|
std::cout << "catching the failure" << std::endl;
|
||||||
|
@ -2624,7 +2614,7 @@ void test_files_from_directory(std::string test_file_dir, argument_parser & args
|
||||||
vector<std::pair<std::string, int>> files = get_file_list_of_dir(test_file_dir);
|
vector<std::pair<std::string, int>> files = get_file_list_of_dir(test_file_dir);
|
||||||
std::sort(files.begin(), files.end(), sort_pred());
|
std::sort(files.begin(), files.end(), sort_pred());
|
||||||
unsigned max_iters, time_limit;
|
unsigned max_iters, time_limit;
|
||||||
get_time_limit_and_max_iters_from_parser(args_parser, time_limit, max_iters);
|
get_time_limit_and_max_iters_from_parser(args_parser, time_limit);
|
||||||
unsigned successes = 0, failures = 0, inconclusives = 0;
|
unsigned successes = 0, failures = 0, inconclusives = 0;
|
||||||
for (auto & t : files) {
|
for (auto & t : files) {
|
||||||
process_test_file(test_file_dir, t.first, args_parser, out_dir, max_iters, time_limit, successes, failures, inconclusives);
|
process_test_file(test_file_dir, t.first, args_parser, out_dir, max_iters, time_limit, successes, failures, inconclusives);
|
||||||
|
@ -2651,10 +2641,6 @@ void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_read
|
||||||
solver->settings().presolve_with_double_solver_for_lar = true;
|
solver->settings().presolve_with_double_solver_for_lar = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string iter = args_parser.get_option_value("--max_iters");
|
|
||||||
if (!iter.empty()) {
|
|
||||||
solver->settings().max_total_number_of_iterations = atoi(iter.c_str());
|
|
||||||
}
|
|
||||||
if (args_parser.option_is_used("--compare_with_primal")){
|
if (args_parser.option_is_used("--compare_with_primal")){
|
||||||
if (reader == nullptr) {
|
if (reader == nullptr) {
|
||||||
std::cout << "cannot compare with primal, the reader is null " << std::endl;
|
std::cout << "cannot compare with primal, the reader is null " << std::endl;
|
||||||
|
@ -4074,14 +4060,13 @@ void test_lp_local(int argn, char**argv) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
return finalize(ret);
|
return finalize(ret);
|
||||||
}
|
}
|
||||||
unsigned max_iters;
|
|
||||||
unsigned time_limit;
|
unsigned time_limit;
|
||||||
get_time_limit_and_max_iters_from_parser(args_parser, time_limit, max_iters);
|
get_time_limit_and_max_iters_from_parser(args_parser, time_limit);
|
||||||
bool dual = args_parser.option_is_used("--dual");
|
bool dual = args_parser.option_is_used("--dual");
|
||||||
bool solve_for_rational = args_parser.option_is_used("--mpq");
|
bool solve_for_rational = args_parser.option_is_used("--mpq");
|
||||||
std::string file_name = args_parser.get_option_value("--file");
|
std::string file_name = args_parser.get_option_value("--file");
|
||||||
if (!file_name.empty()) {
|
if (!file_name.empty()) {
|
||||||
solve_mps(file_name, args_parser.option_is_used("--min"), max_iters, time_limit, solve_for_rational, dual, args_parser.option_is_used("--compare_with_primal"), args_parser);
|
solve_mps(file_name, args_parser.option_is_used("--min"), time_limit, solve_for_rational, dual, args_parser.option_is_used("--compare_with_primal"), args_parser);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
return finalize(ret);
|
return finalize(ret);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue