Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Jun 6, 2021
1 parent 71ff987 commit 7cd9010
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/math/simplex/model_based_opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace opt {
return true;
}

#define PASSERT(_e_) if (!(_e_)) { TRACE("opt1", display(tout, r); display(tout);); SASSERT(_e_); }
#define PASSERT(_e_) { CTRACE("qe", !(_e_), display(tout, r); display(tout);); SASSERT(_e_); }

bool model_based_opt::invariant(unsigned index, row const& r) {
vector<var> const& vars = r.m_vars;
Expand Down Expand Up @@ -423,6 +423,13 @@ namespace opt {
}
return val;
}

rational model_based_opt::eval(vector<var> const& coeffs) const {
rational val(0);
for (var const& v : coeffs)
val += v.m_coeff * eval(v.m_id);
return val;
}

rational model_based_opt::get_coefficient(unsigned row_id, unsigned var_id) const {
return m_rows[row_id].get_coefficient(var_id);
Expand Down Expand Up @@ -1193,7 +1200,7 @@ namespace opt {
row& r1 = m_rows[row_id1];
vector<var> coeffs;
mk_coeffs_without(coeffs, r1.m_vars, x);
rational c = r1.m_coeff;
rational c = mod(-eval(coeffs), a);
add_divides(coeffs, c, a);
}
unsigned_vector const& row_ids = m_var2row_ids[x];
Expand Down
2 changes: 2 additions & 0 deletions src/math/simplex/model_based_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ namespace opt {
rational eval(unsigned x) const;

rational eval(def const& d) const;

rational eval(vector<var> const& coeffs) const;

void resolve(unsigned row_src, rational const& a1, unsigned row_dst, unsigned x);

Expand Down

0 comments on commit 7cd9010

Please sign in to comment.