From eae4fd6afd29bddcfea4e7fa05a7a87788528883 Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Tue, 19 Mar 2019 15:56:09 -0700 Subject: [PATCH] fix the build lp.cpp in test Signed-off-by: Lev Nachmanson --- src/test/lp/lp.cpp | 87 +++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/src/test/lp/lp.cpp b/src/test/lp/lp.cpp index f43aff668..0c243c9c8 100644 --- a/src/test/lp/lp.cpp +++ b/src/test/lp/lp.cpp @@ -2673,25 +2673,25 @@ void test_term() { var_index one = solver.add_var(_one, false); vector> term_one; - term_one.push_back(std::make_pair((int)1, one)); + term_one.push_back(std::make_pair(mpq(1), one)); solver.add_constraint(term_one, lconstraint_kind::EQ, mpq(0)); vector> term_ls; - term_ls.push_back(std::pair((int)1, x)); - term_ls.push_back(std::pair((int)1, y)); - term_ls.push_back(std::make_pair((int)3, one)); + term_ls.push_back(std::pair(mpq(1), x)); + term_ls.push_back(std::pair(mpq(1), y)); + term_ls.push_back(std::make_pair(mpq(3), one)); var_index z = solver.add_term(term_ls); vector> ls; - ls.push_back(std::pair((int)1, x)); - ls.push_back(std::pair((int)1, y)); - ls.push_back(std::pair((int)1, z)); + ls.push_back(std::pair(mpq(1), x)); + ls.push_back(std::pair(mpq(1), y)); + ls.push_back(std::pair(mpq(1), z)); solver.add_constraint(ls, lconstraint_kind::EQ, mpq(0)); ls.clear(); - ls.push_back(std::pair((int)1, x)); + ls.push_back(std::pair(mpq(1), x)); solver.add_constraint(ls, lconstraint_kind::LT, mpq(0)); - ls.push_back(std::pair((int)2, y)); + ls.push_back(std::pair(mpq(2), y)); solver.add_constraint(ls, lconstraint_kind::GT, mpq(0)); auto status = solver.solve(); std::cout << lp_status_to_string(status) << std::endl; @@ -2711,15 +2711,15 @@ void test_evidence_for_total_inf_simple(argument_parser & args_parser) { lar_solver solver; var_index x = solver.add_var(0, false); var_index y = solver.add_var(1, false); - solver.add_var_bound(x, LE, -mpq(1)); + solver.add_var_bound(x, LE, mpq(-1)); solver.add_var_bound(y, GE, mpq(0)); vector> ls; - ls.push_back(std::pair((int)1, x)); - ls.push_back(std::pair((int)1, y)); + ls.push_back(std::pair(mpq(1), x)); + ls.push_back(std::pair(mpq(1), y)); solver.add_constraint(ls, GE, mpq(1)); ls.pop_back(); - ls.push_back(std::pair(-(int)1, y)); + ls.push_back(std::pair(- mpq(1), y)); solver.add_constraint(ls, lconstraint_kind::GE, mpq(0)); auto status = solver.solve(); std::cout << lp_status_to_string(status) << std::endl; @@ -2748,19 +2748,20 @@ void test_bound_propagation_one_small_sample1() { unsigned b = ls.add_var(1, false); unsigned c = ls.add_var(2, false); vector> coeffs; - coeffs.push_back(std::pair(1, a)); - coeffs.push_back(std::pair(-1, c)); + coeffs.push_back(std::pair(mpq(1), a)); + coeffs.push_back(std::pair(mpq(-1), c)); + ls.add_term(coeffs); coeffs.pop_back(); - coeffs.push_back(std::pair(-1, b)); + coeffs.push_back(std::pair(mpq(-1), b)); ls.add_term(coeffs); coeffs.clear(); - coeffs.push_back(std::pair(1, a)); - coeffs.push_back(std::pair(-1, b)); + coeffs.push_back(std::pair(mpq(1), a)); + coeffs.push_back(std::pair(mpq(-1), b)); ls.add_constraint(coeffs, LE, zero_of_type()); coeffs.clear(); - coeffs.push_back(std::pair(1, b)); - coeffs.push_back(std::pair(-1, c)); + coeffs.push_back(std::pair(mpq(1), b)); + coeffs.push_back(std::pair(mpq(-1), c)); ls.add_constraint(coeffs, LE, zero_of_type()); vector ev; ls.add_var_bound(a, LE, mpq(1)); @@ -2812,8 +2813,8 @@ void test_bound_propagation_one_row() { unsigned x0 = ls.add_var(0, false); unsigned x1 = ls.add_var(1, false); vector> c; - c.push_back(std::pair(1, x0)); - c.push_back(std::pair(-1, x1)); + c.push_back(std::pair(mpq(1), x0)); + c.push_back(std::pair(mpq(-1), x1)); ls.add_constraint(c, EQ, one_of_type()); vector ev; ls.add_var_bound(x0, LE, mpq(1)); @@ -2826,8 +2827,8 @@ void test_bound_propagation_one_row_with_bounded_vars() { unsigned x0 = ls.add_var(0, false); unsigned x1 = ls.add_var(1, false); vector> c; - c.push_back(std::pair(1, x0)); - c.push_back(std::pair(-1, x1)); + c.push_back(std::pair(mpq(1), x0)); + c.push_back(std::pair(mpq(-1), x1)); ls.add_constraint(c, EQ, one_of_type()); vector ev; ls.add_var_bound(x0, GE, mpq(-3)); @@ -2842,8 +2843,8 @@ void test_bound_propagation_one_row_mixed() { unsigned x0 = ls.add_var(0, false); unsigned x1 = ls.add_var(1, false); vector> c; - c.push_back(std::pair(1, x0)); - c.push_back(std::pair(-1, x1)); + c.push_back(std::pair(mpq(1), x0)); + c.push_back(std::pair(mpq(-1), x1)); ls.add_constraint(c, EQ, one_of_type()); vector ev; ls.add_var_bound(x1, LE, mpq(1)); @@ -2858,14 +2859,14 @@ void test_bound_propagation_two_rows() { unsigned y = ls.add_var(1, false); unsigned z = ls.add_var(2, false); vector> c; - c.push_back(std::pair(1, x)); - c.push_back(std::pair(2, y)); - c.push_back(std::pair(3, z)); + c.push_back(std::pair(mpq(1), x)); + c.push_back(std::pair(mpq(2), y)); + c.push_back(std::pair(mpq(3), z)); ls.add_constraint(c, GE, one_of_type()); c.clear(); - c.push_back(std::pair(3, x)); - c.push_back(std::pair(2, y)); - c.push_back(std::pair(1, z)); + c.push_back(std::pair(mpq(3), x)); + c.push_back(std::pair(mpq(2), y)); + c.push_back(std::pair(mpq(y), z)); ls.add_constraint(c, GE, one_of_type()); ls.add_var_bound(x, LE, mpq(2)); vector ev; @@ -2882,9 +2883,9 @@ void test_total_case_u() { unsigned y = ls.add_var(1, false); unsigned z = ls.add_var(2, false); vector> c; - c.push_back(std::pair(1, x)); - c.push_back(std::pair(2, y)); - c.push_back(std::pair(3, z)); + c.push_back(std::pair(mpq(1), x)); + c.push_back(std::pair(mpq(2), y)); + c.push_back(std::pair(mpq(3), z)); ls.add_constraint(c, LE, one_of_type()); ls.add_var_bound(x, GE, zero_of_type()); ls.add_var_bound(y, GE, zero_of_type()); @@ -2908,9 +2909,9 @@ void test_total_case_l(){ unsigned y = ls.add_var(1, false); unsigned z = ls.add_var(2, false); vector> c; - c.push_back(std::pair(1, x)); - c.push_back(std::pair(2, y)); - c.push_back(std::pair(3, z)); + c.push_back(std::pair(mpq(1), x)); + c.push_back(std::pair(mpq(2), y)); + c.push_back(std::pair(mpq(3), z)); ls.add_constraint(c, GE, one_of_type()); ls.add_var_bound(x, LE, one_of_type()); ls.add_var_bound(y, LE, one_of_type()); @@ -3490,16 +3491,16 @@ void test_maximize_term() { var_index x = solver.add_var(_x, false); var_index y = solver.add_var(_y, true); vector> term_ls; - term_ls.push_back(std::pair((int)1, x)); - term_ls.push_back(std::pair((int)-1, y)); + term_ls.push_back(std::pair(mpq(1), x)); + term_ls.push_back(std::pair(mpq(-1), y)); unsigned term_x_min_y = solver.add_term(term_ls); term_ls.clear(); - term_ls.push_back(std::pair((int)2, x)); - term_ls.push_back(std::pair((int)2, y)); + term_ls.push_back(std::pair(mpq(2), x)); + term_ls.push_back(std::pair(mpq(2), y)); unsigned term_2x_pl_2y = solver.add_term(term_ls); solver.add_var_bound(term_x_min_y, LE, zero_of_type()); - solver.add_var_bound(term_2x_pl_2y, LE, mpq((int)5)); + solver.add_var_bound(term_2x_pl_2y, LE, mpq(5)); solver.find_feasible_solution(); lp_assert(solver.get_status() == lp_status::OPTIMAL); solver.print_constraints(std::cout);