Sleipnir C++ API
Loading...
Searching...
No Matches
exit_status.hpp
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#include <stdint.h>
6
7#include <string_view>
8
9#include "sleipnir/util/symbol_exports.hpp"
10
11namespace slp {
12
16enum class ExitStatus : int8_t {
18 SUCCESS = 0,
20 CALLBACK_REQUESTED_STOP = 1,
22 TOO_FEW_DOFS = -1,
24 LOCALLY_INFEASIBLE = -2,
27 GLOBALLY_INFEASIBLE = -3,
29 FACTORIZATION_FAILED = -4,
32 LINE_SEARCH_FAILED = -5,
34 NONFINITE_INITIAL_COST_OR_CONSTRAINTS = -6,
36 DIVERGING_ITERATES = -7,
39 MAX_ITERATIONS_EXCEEDED = -8,
42 TIMEOUT = -9,
43};
44
50SLEIPNIR_DLLEXPORT constexpr std::string_view to_message(
51 const ExitStatus& exit_status) {
52 using enum ExitStatus;
53
54 switch (exit_status) {
55 case SUCCESS:
56 return "success";
57 case CALLBACK_REQUESTED_STOP:
58 return "callback requested stop";
59 case TOO_FEW_DOFS:
60 return "too few degrees of freedom";
61 case LOCALLY_INFEASIBLE:
62 return "locally infeasible";
63 case GLOBALLY_INFEASIBLE:
64 return "globally infeasible";
65 case FACTORIZATION_FAILED:
66 return "factorization failed";
67 case LINE_SEARCH_FAILED:
68 return "line search failed";
69 case NONFINITE_INITIAL_COST_OR_CONSTRAINTS:
70 return "nonfinite initial cost or constraints";
71 case DIVERGING_ITERATES:
72 return "diverging iterates";
73 case MAX_ITERATIONS_EXCEEDED:
74 return "max iterations exceeded";
75 case TIMEOUT:
76 return "timeout";
77 default:
78 return "unknown";
79 }
80}
81
82} // namespace slp