Skip to content

Commit

Permalink
Solution check fail code: 520 again #200
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbelov committed Dec 8, 2023
1 parent 1972801 commit 406c177
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
3 changes: 3 additions & 0 deletions include/mp/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ enum Status {
/** A solver error. */
FAILURE = 500,

/** Solution check failed. */
SOLUTION_CHECK = FAILURE + 20,

/** A numeric issue. */
NUMERIC = 550,

Expand Down
6 changes: 4 additions & 2 deletions include/mp/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ namespace mp {

#ifndef MP_ASSERT
/// Debug assert
#define MP_ASSERT(condition, message) assert((condition) && message)
#define MP_ASSERT(condition, message) \
assert((condition) && message)
#endif

/// Assert even for Release
Expand All @@ -46,7 +47,8 @@ namespace mp {
#define MP_RAISE(msg) throw mp::Error(msg)

/// Raise with exit code
#define MP_RAISE_WITH_CODE(exit_code, msg) throw mp::Error(msg, exit_code)
#define MP_RAISE_WITH_CODE(exit_code, msg) \
throw mp::Error(msg, exit_code)

/// Raise infeasibility
#define MP_INFEAS(msg) \
Expand Down
4 changes: 2 additions & 2 deletions include/mp/flat/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ class FlatConverter :
private:
std::string solchkfailtext_ {
"Fail on solution checking violations, with solve result "
+ std::to_string(SOL_CHECK_FAIL_CODE) + '.'
+ std::to_string(sol::SOLUTION_CHECK) + '.'
};
void InitOwnOptions() {
/// Should be called after adding all constraint keepers
Expand Down Expand Up @@ -1085,7 +1085,7 @@ class FlatConverter :

////////////////////// Solve result codes ////////////////////////
GetEnv().AddSolveResults({
{SOL_CHECK_FAIL_CODE, "Solution check failure"}
{sol::SOLUTION_CHECK, "Solution check failure"}
});
}

Expand Down
5 changes: 1 addition & 4 deletions include/mp/flat/sol_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

namespace mp {

/// Solve result when failing with sol:chk:fail.
const int SOL_CHECK_FAIL_CODE = sol::NUMERIC + 20;

/// A mix-in base class
/// for solution checking.
template <class Impl>
Expand Down Expand Up @@ -138,7 +135,7 @@ class SolutionChecker {
// For now, do this via warnings?
if (chk.HasAnyViols()) {
if (MPCD( sol_check_fail() ))
MP_RAISE_WITH_CODE(SOL_CHECK_FAIL_CODE, // numeric error
MP_RAISE_WITH_CODE(int(sol::SOLUTION_CHECK), // failure
chk.GetReport());
else
MPD( AddWarning(
Expand Down
2 changes: 1 addition & 1 deletion test/end2end/cases/categorized/fast/logical/modellist.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"ANYSOLVER_options": "cvt:cmp:eps=0 chk:fail"
},
"values": {
"solve_result_num": 570
"solve_result_num": 520
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion test/end2end/cases/categorized/fast/tech/modellist.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"sol:chk:fail sol:chk:mode=1023 sol:chk:feastol=1e-7 sol:chk:inttol=1e-4 feasrelax=1"
},
"values": {
"solve_result_num": 570
"solve_result_num": 520
}
}
]

0 comments on commit 406c177

Please sign in to comment.