Skip to content

Commit

Permalink
SolCheck: 'Idealistic check is an indicator only' #200
Browse files Browse the repository at this point in the history
Expanation message for idealistic violations
  • Loading branch information
glebbelov committed Sep 7, 2023
1 parent 030d5ec commit d847a95
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions include/mp/flat/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ class FlatConverter :
CheckCons(chk);
if (chk.check_mode() & 16)
CheckObjs(chk);
GenerateViolationsReport(chk);
GenerateViolationsReport(chk, if_recomp_vals);
// Should messages for realistic and idealistic
// modes be coordinated?
// I.e., when no expressions.
Expand Down Expand Up @@ -781,12 +781,13 @@ class FlatConverter :
}
}

void GenerateViolationsReport(SolCheck& chk) {
void GenerateViolationsReport(
SolCheck& chk, bool f_idealistic) {
fmt::MemoryWriter wrt;
if (chk.HasAnyViols())
wrt.write(
" [ sol:chk:feastol={}, :feastolrel={}, :inttol={},\n"
" solution_round='{}', solution_precision='{}' ]\n",
" solution_round='{}', solution_precision='{}' ]\n",
options_.solfeastol_, options_.solfeastolrel_,
options_.solinttol_,
chk.x_ext().solution_round(),
Expand All @@ -808,6 +809,9 @@ class FlatConverter :
Gen1Viol(chk.ObjViols(), wrt, true,
" - {} objective value(s) violated");
}
if (f_idealistic && chk.HasAnyViols())
wrt.write(
"Idealistic check is an indicator only, see documentation.");
chk.SetReport( wrt.str() );
}

Expand Down Expand Up @@ -836,14 +840,16 @@ class FlatConverter :
std::string Gen1ViolMax(
bool f_max, double viol, const char* nm, bool relVsAbs) {
fmt::MemoryWriter wrt;
if (f_max)
wrt.write("up to {:.0E} ({}",
viol, relVsAbs ? "rel" : "abs");
if (nm && *nm != '\0') {
wrt.write(f_max ? ", " : "(");
wrt.write("item '{}'", nm);
} else if (f_max)
wrt.write(")");
if (viol>0.0) {
if (f_max)
wrt.write("up to {:.0E} ({}",
viol, relVsAbs ? "rel" : "abs");
if (nm && *nm != '\0') {
wrt.write(f_max ? ", " : "(");
wrt.write("item '{}')", nm);
} else if (f_max)
wrt.write(")");
}
return wrt.str();
}

Expand Down

0 comments on commit d847a95

Please sign in to comment.