mirror of
https://github.com/Z3Prover/z3
synced 2025-06-27 16:38:45 +00:00
remove lp_assert
This commit is contained in:
parent
1510b3112e
commit
8035edbe65
35 changed files with 332 additions and 329 deletions
|
@ -72,7 +72,7 @@ struct gomory_test {
|
|||
expl.add_pair(column_lower_bound_constraint(x_j), new_a);
|
||||
}
|
||||
else {
|
||||
lp_assert(at_upper(x_j));
|
||||
SASSERT(at_upper(x_j));
|
||||
if (a.is_pos()) {
|
||||
new_a = a / f_0;
|
||||
new_a.neg(); // the upper terms are inverted.
|
||||
|
@ -88,9 +88,9 @@ struct gomory_test {
|
|||
}
|
||||
|
||||
void int_case_in_gomory_cut(const mpq & a, unsigned x_j, mpq & k, lar_term & t, explanation& expl, mpq & lcm_den, const mpq& f_0, const mpq& one_minus_f_0) {
|
||||
lp_assert(is_integer(x_j));
|
||||
lp_assert(!a.is_int());
|
||||
lp_assert(f_0 > zero_of_type<mpq>() && f_0 < one_of_type<mpq>());
|
||||
SASSERT(is_integer(x_j));
|
||||
SASSERT(!a.is_int());
|
||||
SASSERT(f_0 > zero_of_type<mpq>() && f_0 < one_of_type<mpq>());
|
||||
mpq f_j = fractional_part(a);
|
||||
TRACE("gomory_cut_detail",
|
||||
tout << a << " x_j = " << x_j << ", k = " << k << "\n";
|
||||
|
@ -99,7 +99,7 @@ struct gomory_test {
|
|||
tout << "1 - f_0: " << one_minus_f_0 << "\n";
|
||||
tout << "at_low(" << x_j << ") = " << at_low(x_j) << std::endl;
|
||||
);
|
||||
lp_assert (!f_j.is_zero());
|
||||
SASSERT (!f_j.is_zero());
|
||||
mpq new_a;
|
||||
if (at_low(x_j)) {
|
||||
if (f_j <= one_minus_f_0) {
|
||||
|
@ -112,7 +112,7 @@ struct gomory_test {
|
|||
expl.add_pair(column_lower_bound_constraint(x_j), new_a);
|
||||
}
|
||||
else {
|
||||
lp_assert(at_upper(x_j));
|
||||
SASSERT(at_upper(x_j));
|
||||
if (f_j <= f_0) {
|
||||
new_a = f_j / f_0;
|
||||
}
|
||||
|
@ -134,13 +134,13 @@ struct gomory_test {
|
|||
}
|
||||
|
||||
void adjust_term_and_k_for_some_ints_case_gomory(lar_term& t, mpq& k, mpq &lcm_den) {
|
||||
lp_assert(!t.is_empty());
|
||||
SASSERT(!t.is_empty());
|
||||
auto pol = t.coeffs_as_vector();
|
||||
t.clear();
|
||||
if (pol.size() == 1) {
|
||||
TRACE("gomory_cut_detail", tout << "pol.size() is 1" << std::endl;);
|
||||
unsigned v = pol[0].second;
|
||||
lp_assert(is_integer(v));
|
||||
SASSERT(is_integer(v));
|
||||
const mpq& a = pol[0].first;
|
||||
k /= a;
|
||||
if (a.is_pos()) { // we have av >= k
|
||||
|
@ -162,7 +162,7 @@ struct gomory_test {
|
|||
tout << pol[i].first << " " << pol[i].second << "\n";
|
||||
}
|
||||
tout << "k: " << k << "\n";);
|
||||
lp_assert(lcm_den.is_pos());
|
||||
SASSERT(lcm_den.is_pos());
|
||||
if (!lcm_den.is_one()) {
|
||||
// normalize coefficients of integer parameters to be integers.
|
||||
for (auto & pi: pol) {
|
||||
|
@ -183,7 +183,7 @@ struct gomory_test {
|
|||
k.neg();
|
||||
}
|
||||
TRACE("gomory_cut_detail", tout << "k = " << k << std::endl;);
|
||||
lp_assert(k.is_int());
|
||||
SASSERT(k.is_int());
|
||||
}
|
||||
|
||||
void print_term(lar_term & t, std::ostream & out) {
|
||||
|
|
|
@ -384,7 +384,7 @@ vector<int> allocate_basis_heading(
|
|||
|
||||
void init_basic_part_of_basis_heading(vector<unsigned> &basis,
|
||||
vector<int> &basis_heading) {
|
||||
lp_assert(basis_heading.size() >= basis.size());
|
||||
SASSERT(basis_heading.size() >= basis.size());
|
||||
unsigned m = basis.size();
|
||||
for (unsigned i = 0; i < m; i++) {
|
||||
unsigned column = basis[i];
|
||||
|
@ -577,7 +577,7 @@ void test_stacked_unsigned() {
|
|||
v = 3;
|
||||
v = 4;
|
||||
v.pop();
|
||||
lp_assert(v == 2);
|
||||
SASSERT(v == 2);
|
||||
v++;
|
||||
v++;
|
||||
std::cout << "before push v=" << v << std::endl;
|
||||
|
@ -587,7 +587,7 @@ void test_stacked_unsigned() {
|
|||
v += 1;
|
||||
std::cout << "v = " << v << std::endl;
|
||||
v.pop(2);
|
||||
lp_assert(v == 4);
|
||||
SASSERT(v == 4);
|
||||
const unsigned &rr = v;
|
||||
std::cout << rr << std::endl;
|
||||
}
|
||||
|
@ -751,22 +751,23 @@ void test_numeric_pair() {
|
|||
numeric_pair<lp::mpq> c(0.1, 0.5);
|
||||
a += 2 * c;
|
||||
a -= c;
|
||||
lp_assert(a == b + c);
|
||||
SASSERT(a == b + c);
|
||||
numeric_pair<lp::mpq> d = a * 2;
|
||||
std::cout << a << std::endl;
|
||||
lp_assert(b == b);
|
||||
lp_assert(b < a);
|
||||
lp_assert(b <= a);
|
||||
lp_assert(a > b);
|
||||
lp_assert(a != b);
|
||||
lp_assert(a >= b);
|
||||
lp_assert(-a < b);
|
||||
lp_assert(a < 2 * b);
|
||||
lp_assert(b + b > a);
|
||||
lp_assert(lp::mpq(2.1) * b + b > a);
|
||||
lp_assert(-b * lp::mpq(2.1) - b < lp::mpq(0.99) * a);
|
||||
SASSERT(b == b);
|
||||
SASSERT(b < a);
|
||||
SASSERT(b <= a);
|
||||
SASSERT(a > b);
|
||||
SASSERT(a != b);
|
||||
SASSERT(a >= b);
|
||||
SASSERT(-a < b);
|
||||
SASSERT(a < 2 * b);
|
||||
SASSERT(b + b > a);
|
||||
SASSERT(lp::mpq(2.1) * b + b > a);
|
||||
SASSERT(-b * lp::mpq(2.1) - b < lp::mpq(0.99) * a);
|
||||
std::cout << -b * lp::mpq(2.1) - b << std::endl;
|
||||
lp_assert(-b * (lp::mpq(2.1) + 1) == -b * lp::mpq(2.1) - b);
|
||||
SASSERT(-b * (lp::mpq(2.1) + 1) == -b * lp::mpq(2.1) - b);
|
||||
std::cout << -b * (lp::mpq(2.1) + 1) << std::endl;
|
||||
}
|
||||
|
||||
void get_matrix_dimensions(std::ifstream &f, unsigned &m, unsigned &n) {
|
||||
|
@ -829,7 +830,7 @@ void test_term() {
|
|||
<< t.second.get_double() << ",";
|
||||
}
|
||||
|
||||
std::cout << "\ntableu after cube\n";
|
||||
std::cout << "\ntableau after cube\n";
|
||||
solver.pp(std::cout).print();
|
||||
std::cout << "Ax_is_correct = " << solver.ax_is_correct() << "\n";
|
||||
}
|
||||
|
@ -854,7 +855,7 @@ void test_evidence_for_total_inf_simple(argument_parser &args_parser) {
|
|||
auto status = solver.solve();
|
||||
std::cout << lp_status_to_string(status) << std::endl;
|
||||
std::unordered_map<lpvar, mpq> model;
|
||||
lp_assert(solver.get_status() == lp_status::INFEASIBLE);
|
||||
SASSERT(solver.get_status() == lp_status::INFEASIBLE);
|
||||
}
|
||||
void test_bound_propagation_one_small_sample1() {
|
||||
/*
|
||||
|
@ -1060,8 +1061,8 @@ void test_total_case_l() {
|
|||
// ls.solve();
|
||||
// my_bound_propagator bp(ls);
|
||||
// ls.propagate_bounds_for_touched_rows(bp);
|
||||
// lp_assert(ev.size() == 4);
|
||||
// lp_assert(contains_j_kind(x, GE, - one_of_type<mpq>(), ev));
|
||||
// SASSERT(ev.size() == 4);
|
||||
// SASSERT(contains_j_kind(x, GE, - one_of_type<mpq>(), ev));
|
||||
}
|
||||
void test_bound_propagation() {
|
||||
test_total_case_u();
|
||||
|
@ -1077,14 +1078,14 @@ void test_int_set() {
|
|||
indexed_uint_set s;
|
||||
s.insert(1);
|
||||
s.insert(2);
|
||||
lp_assert(s.contains(2));
|
||||
lp_assert(s.size() == 2);
|
||||
SASSERT(s.contains(2));
|
||||
SASSERT(s.size() == 2);
|
||||
s.remove(2);
|
||||
lp_assert(s.size() == 1);
|
||||
SASSERT(s.size() == 1);
|
||||
s.insert(3);
|
||||
s.insert(2);
|
||||
s.reset();
|
||||
lp_assert(s.size() == 0);
|
||||
SASSERT(s.size() == 0);
|
||||
std::cout << "done test_int_set\n";
|
||||
}
|
||||
|
||||
|
@ -1192,13 +1193,13 @@ void get_random_interval(bool &neg_inf, bool &pos_inf, int &x, int &y) {
|
|||
pos_inf = false;
|
||||
if (!neg_inf) {
|
||||
y = x + my_random() % (101 - x);
|
||||
lp_assert(y >= x);
|
||||
SASSERT(y >= x);
|
||||
} else {
|
||||
y = my_random() % 100;
|
||||
}
|
||||
}
|
||||
lp_assert((neg_inf || (0 <= x && x <= 100)) &&
|
||||
(pos_inf || (0 <= y && y <= 100)));
|
||||
SASSERT((neg_inf || (0 <= x && x <= 100)) &&
|
||||
(pos_inf || (0 <= y && y <= 100)));
|
||||
}
|
||||
|
||||
void test_gomory_cut_0() {
|
||||
|
@ -1628,7 +1629,7 @@ void test_maximize_term() {
|
|||
solver.add_var_bound(term_x_min_y, LE, zero_of_type<mpq>());
|
||||
solver.add_var_bound(term_2x_pl_2y, LE, mpq(5));
|
||||
solver.find_feasible_solution();
|
||||
lp_assert(solver.get_status() == lp_status::OPTIMAL);
|
||||
SASSERT(solver.get_status() == lp_status::OPTIMAL);
|
||||
std::cout << solver.constraints();
|
||||
std::unordered_map<lpvar, mpq> model;
|
||||
solver.get_model(model);
|
||||
|
@ -1671,7 +1672,8 @@ void test_dio() {
|
|||
lpvar fx_7 = solver.add_var(_fx_7, true);
|
||||
lpvar fx_17 = solver.add_var(_fx_17, true);
|
||||
vector<std::pair<mpq, lpvar>> term_ls;
|
||||
/* 3x1 + 3x2 + 14x3 − 7 */
|
||||
/* 3x1 + 3x2 +```cpp
|
||||
14x3 − 7 */
|
||||
term_ls.push_back(std::pair<mpq, lpvar>(mpq(3), x1));
|
||||
term_ls.push_back(std::pair<mpq, lpvar>(mpq(3), x2));
|
||||
term_ls.push_back(std::pair<mpq, lpvar>(mpq(14), x3));
|
||||
|
@ -1701,7 +1703,7 @@ void test_dio() {
|
|||
solver.add_var_bound(t1, LE, mpq(0));
|
||||
solver.add_var_bound(t1, GE, mpq(0));
|
||||
// solver.find_feasible_solution();
|
||||
//lp_assert(solver.get_status() == lp_status::OPTIMAL);
|
||||
//SASSERT(solver.get_status() == lp_status::OPTIMAL);
|
||||
enable_trace("dioph_eq");
|
||||
enable_trace("dioph_eq_fresh");
|
||||
#ifdef Z3DEBUG
|
||||
|
@ -1908,13 +1910,13 @@ void asserts_on_patching(const rational &x, const rational &alpha) {
|
|||
auto a2 = denominator(alpha);
|
||||
auto x1 = numerator(x);
|
||||
auto x2 = denominator(x);
|
||||
lp_assert(a1.is_pos());
|
||||
lp_assert(abs(a1) < abs(a2));
|
||||
lp_assert(coprime(a1, a2));
|
||||
lp_assert(x1.is_pos());
|
||||
lp_assert(x1 < x2);
|
||||
lp_assert(coprime(x1, x2));
|
||||
lp_assert((a2 / x2).is_int());
|
||||
SASSERT(a1.is_pos());
|
||||
SASSERT(abs(a1) < abs(a2));
|
||||
SASSERT(coprime(a1, a2));
|
||||
SASSERT(x1.is_pos());
|
||||
SASSERT(x1 < x2);
|
||||
SASSERT(coprime(x1, x2));
|
||||
SASSERT((a2 / x2).is_int());
|
||||
}
|
||||
void get_patching_deltas(const rational &x, const rational &alpha, rational &delta_0, rational &delta_1) {
|
||||
std::cout << "get_patching_deltas(" << x << ", " << alpha << ")" << std::endl;
|
||||
|
@ -1922,7 +1924,7 @@ void get_patching_deltas(const rational &x, const rational &alpha, rational &del
|
|||
auto a2 = denominator(alpha);
|
||||
auto x1 = numerator(x);
|
||||
auto x2 = denominator(x);
|
||||
lp_assert(divides(x2, a2));
|
||||
SASSERT(divides(x2, a2));
|
||||
// delta has to be integral.
|
||||
// We need to find delta such that x1/x2 + (a1/a2)*delta is integral.
|
||||
// Then a2*x1/x2 + a1*delta is integral, that means that t = a2/x2 is integral.
|
||||
|
@ -1936,17 +1938,17 @@ void get_patching_deltas(const rational &x, const rational &alpha, rational &del
|
|||
// We know that a2 and a1 are coprime, and x2 divides a2, so x2 and a1 are coprime.
|
||||
rational u, v;
|
||||
auto g = gcd(a1, x2, u, v);
|
||||
lp_assert(g.is_one() && u.is_int() && v.is_int() && g == u * a1 + v * x2);
|
||||
SASSERT(g.is_one() && u.is_int() && v.is_int() && g == u * a1 + v * x2);
|
||||
std::cout << "u = " << u << ", v = " << v << std::endl;
|
||||
std::cout << "x= " << (x1 / x2) << std::endl;
|
||||
std::cout << "x + (a1 / a2) * (-u * t) * x1 = " << x + (a1 / a2) * (-u * t) * x1 << std::endl;
|
||||
lp_assert((x + (a1 / a2) * (-u * t) * x1).is_int());
|
||||
SASSERT((x + (a1 / a2) * (-u * t) * x1).is_int());
|
||||
// 1 = (u- l*x2 ) * a1 + (v + l*a1)*x2, for every integer l.
|
||||
rational d = u * t * x1;
|
||||
delta_0 = mod(d, a2);
|
||||
lp_assert(delta_0 > 0);
|
||||
SASSERT(delta_0 > 0);
|
||||
delta_1 = delta_0 - a2;
|
||||
lp_assert(delta_1 < 0);
|
||||
SASSERT(delta_1 < 0);
|
||||
std::cout << "delta_0 = " << delta_0 << std::endl;
|
||||
std::cout << "delta_1 = " << delta_1 << std::endl;
|
||||
}
|
||||
|
@ -1974,10 +1976,10 @@ void test_patching_alpha(const rational &x, const rational &alpha) {
|
|||
rational delta_0, delta_1;
|
||||
get_patching_deltas(x, alpha, delta_0, delta_1);
|
||||
|
||||
lp_assert(delta_0 * delta_1 < 0);
|
||||
SASSERT(delta_0 * delta_1 < 0);
|
||||
|
||||
lp_assert((x - alpha * delta_0).is_int());
|
||||
lp_assert((x - alpha * delta_1).is_int());
|
||||
SASSERT((x - alpha * delta_0).is_int());
|
||||
SASSERT((x - alpha * delta_1).is_int());
|
||||
try_find_smaller_delta(x, alpha, delta_0, delta_1);
|
||||
// std::cout << "delta_minus = " << delta_minus << ", delta_1 = " << delta_1 << "\n";
|
||||
// std::cout << "x + alpha*delta_minus = " << x + alpha * delta_minus << "\n";
|
||||
|
@ -1988,7 +1990,7 @@ void find_a1_x1_x2_and_fix_a2(int &x1, int &x2, int &a1, int &a2) {
|
|||
x2 = (rand() % a2) + (int)(a2 / 3);
|
||||
auto g = gcd(rational(a2), rational(x2));
|
||||
a2 *= (x2 / numerator(g).get_int32());
|
||||
lp_assert(rational(a2, x2).is_int());
|
||||
SASSERT(rational(a2, x2).is_int());
|
||||
do {
|
||||
x1 = rand() % (unsigned)x2 + 1;
|
||||
} while (!coprime(x1, x2));
|
||||
|
@ -1998,6 +2000,7 @@ void find_a1_x1_x2_and_fix_a2(int &x1, int &x2, int &a1, int &a2) {
|
|||
} while (!coprime(a1, a2));
|
||||
}
|
||||
|
||||
|
||||
void test_patching() {
|
||||
srand(1);
|
||||
// repeat the test 100 times
|
||||
|
|
|
@ -117,13 +117,13 @@ namespace lp {
|
|||
|
||||
void fill_simple_elem(lisp_elem & lm) {
|
||||
int separator = first_separator();
|
||||
lp_assert(-1 != separator && separator != 0);
|
||||
SASSERT(-1 != separator && separator != 0);
|
||||
lm.m_head = m_line.substr(0, separator);
|
||||
m_line = m_line.substr(separator);
|
||||
}
|
||||
|
||||
void fill_nested_elem(lisp_elem & lm) {
|
||||
lp_assert(m_line[0] == '(');
|
||||
SASSERT(m_line[0] == '(');
|
||||
m_line = m_line.substr(1);
|
||||
int separator = first_separator();
|
||||
lm.m_head = m_line.substr(0, separator);
|
||||
|
@ -190,11 +190,11 @@ namespace lp {
|
|||
}
|
||||
|
||||
void adjust_right_side(formula_constraint & /* c*/, lisp_elem & /*el*/) {
|
||||
// lp_assert(el.m_head == "0"); // do nothing for the time being
|
||||
// SASSERT(el.m_head == "0"); // do nothing for the time being
|
||||
}
|
||||
|
||||
void set_constraint_coeffs(formula_constraint & c, lisp_elem & el) {
|
||||
lp_assert(el.m_elems.size() == 2);
|
||||
SASSERT(el.m_elems.size() == 2);
|
||||
set_constraint_coeffs_on_coeff_element(c, el.m_elems[0]);
|
||||
adjust_right_side(c, el.m_elems[1]);
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ namespace lp {
|
|||
add_mult_elem(c, el.m_elems);
|
||||
} else if (el.m_head == "~") {
|
||||
lisp_elem & minel = el.m_elems[0];
|
||||
lp_assert(minel.is_simple());
|
||||
SASSERT(minel.is_simple());
|
||||
c.m_right_side += mpq(str_to_int(minel.m_head));
|
||||
} else {
|
||||
std::cout << "unexpected input " << el.m_head << std::endl;
|
||||
|
@ -220,14 +220,14 @@ namespace lp {
|
|||
}
|
||||
|
||||
std::string get_name(lisp_elem & name) {
|
||||
lp_assert(name.is_simple());
|
||||
lp_assert(!is_integer(name.m_head));
|
||||
SASSERT(name.is_simple());
|
||||
SASSERT(!is_integer(name.m_head));
|
||||
return name.m_head;
|
||||
}
|
||||
|
||||
|
||||
void add_mult_elem(formula_constraint & c, std::vector<lisp_elem> & els) {
|
||||
lp_assert(els.size() == 2);
|
||||
SASSERT(els.size() == 2);
|
||||
mpq coeff = get_coeff(els[0]);
|
||||
std::string col_name = get_name(els[1]);
|
||||
c.add_pair(coeff, col_name);
|
||||
|
@ -237,16 +237,16 @@ namespace lp {
|
|||
if (le.is_simple()) {
|
||||
return mpq(str_to_int(le.m_head));
|
||||
} else {
|
||||
lp_assert(le.m_head == "~");
|
||||
lp_assert(le.size() == 1);
|
||||
SASSERT(le.m_head == "~");
|
||||
SASSERT(le.size() == 1);
|
||||
lisp_elem & el = le.m_elems[0];
|
||||
lp_assert(el.is_simple());
|
||||
SASSERT(el.is_simple());
|
||||
return -mpq(str_to_int(el.m_head));
|
||||
}
|
||||
}
|
||||
|
||||
int str_to_int(std::string & s) {
|
||||
lp_assert(is_integer(s));
|
||||
SASSERT(is_integer(s));
|
||||
return atoi(s.c_str());
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ namespace lp {
|
|||
if (el.size()) {
|
||||
add_complex_sum_elem(c, el);
|
||||
} else {
|
||||
lp_assert(is_integer(el.m_head));
|
||||
SASSERT(is_integer(el.m_head));
|
||||
int v = atoi(el.m_head.c_str());
|
||||
mpq vr(v);
|
||||
c.m_right_side -= vr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue