WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
exit_status.hpp
Go to the documentation of this file.
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#include <stdint.h>
6
7#include <string_view>
8
10
11namespace slp {
12
13/**
14 * Solver exit status. Negative values indicate failure.
15 */
16enum class ExitStatus : int8_t {
17 /// Solved the problem to the desired tolerance.
18 SUCCESS = 0,
19 /// The solver returned its solution so far after the user requested a stop.
21 /// The solver determined the problem to be overconstrained and gave up.
22 TOO_FEW_DOFS = -1,
23 /// The solver determined the problem to be locally infeasible and gave up.
25 /// The problem setup frontend determined the problem to have an empty
26 /// feasible region.
28 /// The linear system factorization failed.
30 /// The backtracking line search failed, and the problem isn't locally
31 /// infeasible.
33 /// The solver encountered nonfinite initial cost or constraints and gave up.
35 /// The solver encountered diverging primal iterates xₖ and/or sₖ and gave up.
37 /// The solver returned its solution so far after exceeding the maximum number
38 /// of iterations.
40 /// The solver returned its solution so far after exceeding the maximum
41 /// elapsed wall clock time.
42 TIMEOUT = -9,
43};
44
45/**
46 * Returns user-readable message corresponding to the solver exit status.
47 *
48 * @param exit_status Solver exit status.
49 */
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";
58 return "callback requested stop";
59 case TOO_FEW_DOFS:
60 return "too few degrees of freedom";
62 return "locally infeasible";
64 return "globally infeasible";
66 return "factorization failed";
68 return "line search failed";
70 return "nonfinite initial cost or constraints";
72 return "diverging iterates";
74 return "max iterations exceeded";
75 case TIMEOUT:
76 return "timeout";
77 default:
78 return "unknown";
79 }
80}
81
82} // namespace slp
Definition expression_graph.hpp:11
ExitStatus
Solver exit status.
Definition exit_status.hpp:16
@ TIMEOUT
The solver returned its solution so far after exceeding the maximum elapsed wall clock time.
@ CALLBACK_REQUESTED_STOP
The solver returned its solution so far after the user requested a stop.
@ GLOBALLY_INFEASIBLE
The problem setup frontend determined the problem to have an empty feasible region.
@ DIVERGING_ITERATES
The solver encountered diverging primal iterates xₖ and/or sₖ and gave up.
@ FACTORIZATION_FAILED
The linear system factorization failed.
@ LINE_SEARCH_FAILED
The backtracking line search failed, and the problem isn't locally infeasible.
@ MAX_ITERATIONS_EXCEEDED
The solver returned its solution so far after exceeding the maximum number of iterations.
@ SUCCESS
Solved the problem to the desired tolerance.
@ LOCALLY_INFEASIBLE
The solver determined the problem to be locally infeasible and gave up.
@ TOO_FEW_DOFS
The solver determined the problem to be overconstrained and gave up.
@ NONFINITE_INITIAL_COST_OR_CONSTRAINTS
The solver encountered nonfinite initial cost or constraints and gave up.
SLEIPNIR_DLLEXPORT constexpr std::string_view to_message(const ExitStatus &exit_status)
Returns user-readable message corresponding to the solver exit status.
Definition exit_status.hpp:50
#define SLEIPNIR_DLLEXPORT
Definition symbol_exports.hpp:34