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,
26 FACTORIZATION_FAILED = -3,
29 LINE_SEARCH_FAILED = -4,
31 NONFINITE_INITIAL_COST_OR_CONSTRAINTS = -5,
33 DIVERGING_ITERATES = -6,
36 MAX_ITERATIONS_EXCEEDED = -7,
39 TIMEOUT = -8
40};
41
47SLEIPNIR_DLLEXPORT constexpr std::string_view to_message(
48 const ExitStatus& exit_status) {
49 using enum ExitStatus;
50
51 switch (exit_status) {
52 case SUCCESS:
53 return "success";
54 case CALLBACK_REQUESTED_STOP:
55 return "callback requested stop";
56 case TOO_FEW_DOFS:
57 return "too few degrees of freedom";
58 case LOCALLY_INFEASIBLE:
59 return "locally infeasible";
60 case FACTORIZATION_FAILED:
61 return "factorization failed";
62 case LINE_SEARCH_FAILED:
63 return "line search failed";
64 case NONFINITE_INITIAL_COST_OR_CONSTRAINTS:
65 return "nonfinite initial cost or constraints";
66 case DIVERGING_ITERATES:
67 return "diverging iterates";
68 case MAX_ITERATIONS_EXCEEDED:
69 return "max iterations exceeded";
70 case TIMEOUT:
71 return "timeout";
72 default:
73 return "unknown";
74 }
75}
76
77} // namespace slp