Skip to content

Commit

Permalink
tnlp.hxx: treat user-requested stops as warnings.
Browse files Browse the repository at this point in the history
The user may be relying on a custom stop criterion, so this case
should not be treated as an error.
  • Loading branch information
Benjamin Chrétien committed Nov 25, 2014
1 parent a1c0b83 commit bca3914
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/tnlp.hxx
Expand Up @@ -560,11 +560,18 @@ namespace roboptim
} \
break

#define SWITCH_FATAL(NAME) \
case NAME: \
assert (0); \
#define SWITCH_WARNING(NAME, WARNING) \
case NAME: \
{ \
ResultWithWarnings res (n, 1); \
FILL_RESULT (); \
res.warnings.push_back (SolverWarning (WARNING)); \
solver_.result_ = res; \
break; \
} \
break


#define MAP_IPOPT_ERRORS(MACRO) \
MACRO(MAXITER_EXCEEDED, "Max iteration exceeded"); \
MACRO(STOP_AT_TINY_STEP, \
Expand All @@ -582,11 +589,12 @@ namespace roboptim
MACRO(TOO_FEW_DEGREES_OF_FREEDOM, "Two few degrees of freedom"); \
MACRO(INVALID_OPTION, "Invalid option"); \
MACRO(OUT_OF_MEMORY, "Out of memory"); \
MACRO(CPUTIME_EXCEEDED, "Cpu time exceeded")
MACRO(CPUTIME_EXCEEDED, "CPU time exceeded")


#define MAP_IPOPT_FATALS(MACRO) \
MACRO(USER_REQUESTED_STOP)
#define MAP_IPOPT_WARNINGS(MACRO) \
MACRO(USER_REQUESTED_STOP, "User-requested stop"); \
MACRO(STOP_AT_ACCEPTABLE_POINT, "Acceptable point")


template <typename T>
Expand All @@ -612,17 +620,9 @@ namespace roboptim
solver_.result_ = res;
break;
}
case STOP_AT_ACCEPTABLE_POINT:
{
ResultWithWarnings res (n, 1);
FILL_RESULT ();
res.warnings.push_back (SolverWarning ("Acceptable point"));
solver_.result_ = res;
break;
}

MAP_IPOPT_ERRORS(SWITCH_ERROR);
MAP_IPOPT_FATALS(SWITCH_FATAL);
MAP_IPOPT_WARNINGS(SWITCH_WARNING);

case UNASSIGNED:
assert (0 && "should never happen");
Expand All @@ -632,9 +632,9 @@ namespace roboptim

#undef FILL_RESULT
#undef SWITCH_ERROR
#undef SWITCH_FATAL
#undef SWITCH_WARNING
#undef MAP_IPOPT_ERRORS
#undef MAP_IPOPT_FATALS
#undef MAP_IPOPT_WARNINGS

template <typename T>
bool
Expand Down

0 comments on commit bca3914

Please sign in to comment.