Skip to content

Commit

Permalink
Expression interface: fix acc:_all=0 #237
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbelov committed Aug 26, 2024
1 parent 6839e5b commit e38ae6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions include/mp/flat/constr_2_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,9 @@ class Constraints2Expr {

bool HasExpressionArgs(const LinTerms& lt) const {
for (auto v: lt.vars())
if (!MPCD( IsProperVar(v) ))
if (!MPCD( IsProperVar(v) )) {
return true;
}
return false;
}

Expand Down Expand Up @@ -415,9 +416,9 @@ class Constraints2Expr {
result.reserve(ltin.size() - nvars);
int v=0;
for (size_t i=0; i<ltin.size(); ++i) {
if (MPCD( IsProperVar(v = ltin.var(i)) ))
if (MPCD( IsProperVar(v = ltin.var(i)) )) {
lt_out_vars.add_term(ltin.coef(i), v);
else
} else
result.add_term(ltin.coef(i), v);
}
return result;
Expand Down
7 changes: 5 additions & 2 deletions include/mp/flat/constr_keeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,10 @@ class ConstraintKeeper final
}

void DoCvtWithExprs() {
auto cal = GetChosenAcceptanceLevel();
// For acc:_all=0 to work, we have to accept non-convertible con types
auto cal = IfConverterConverts(GetConverter())
? GetChosenAcceptanceLevel()
: ConstraintAcceptanceLevel::Recommended;
auto eal = GetChosenAcceptanceLevelEXPR();
ForEachActive(
[this, cal, eal](const auto& con, int i) {
Expand All @@ -390,7 +393,7 @@ class ConstraintKeeper final
/// Call Converter's RunConversion() and mark as "bridged".
///
/// @param cnt the constraint container -
/// actually redundant, as \a i is enough to find it. But for speed.
/// actually redundant, as \a i is enough to find it. But for speed.
/// @param i constraint index, needed for bridging
void ConvertConstraint(Container& cnt, int i) {
assert(!cnt.IsBridged());
Expand Down

0 comments on commit e38ae6f

Please sign in to comment.