9#include "sleipnir/util/symbol_exports.hpp"
16enum class ExitStatus : int8_t {
20 SOLVED_TO_ACCEPTABLE_TOLERANCE = 1,
22 CALLBACK_REQUESTED_STOP = 2,
26 LOCALLY_INFEASIBLE = -2,
28 FACTORIZATION_FAILED = -3,
31 LINE_SEARCH_FAILED = -4,
33 NONFINITE_INITIAL_COST_OR_CONSTRAINTS = -5,
35 DIVERGING_ITERATES = -6,
38 MAX_ITERATIONS_EXCEEDED = -7,
49SLEIPNIR_DLLEXPORT
constexpr std::string_view ToMessage(
50 const ExitStatus& exit_status) {
51 using enum ExitStatus;
53 switch (exit_status) {
55 return "solved to desired tolerance";
56 case SOLVED_TO_ACCEPTABLE_TOLERANCE:
57 return "solved to acceptable tolerance";
58 case CALLBACK_REQUESTED_STOP:
59 return "callback requested stop";
61 return "problem has too few degrees of freedom";
62 case LOCALLY_INFEASIBLE:
63 return "problem is locally infeasible";
64 case FACTORIZATION_FAILED:
65 return "linear system factorization failed";
66 case LINE_SEARCH_FAILED:
67 return "backtracking line search failed, and the problem isn't locally "
69 case NONFINITE_INITIAL_COST_OR_CONSTRAINTS:
70 return "solver encountered nonfinite initial cost or constraints and "
72 case DIVERGING_ITERATES:
73 return "solver encountered diverging primal iterates xₖ and/or sₖ and "
75 case MAX_ITERATIONS_EXCEEDED:
76 return "solution returned after maximum iterations exceeded";
78 return "solution returned after maximum wall clock time exceeded";