forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solver_type_converter.cc
76 lines (71 loc) · 2.43 KB
/
solver_type_converter.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "drake/solvers/solver_type_converter.h"
#include "drake/common/drake_assert.h"
#include "drake/solvers/dreal_solver.h"
#include "drake/solvers/equality_constrained_qp_solver.h"
#include "drake/solvers/gurobi_solver.h"
#include "drake/solvers/ipopt_solver.h"
#include "drake/solvers/linear_system_solver.h"
#include "drake/solvers/moby_lcp_solver.h"
#include "drake/solvers/mosek_solver.h"
#include "drake/solvers/nlopt_solver.h"
#include "drake/solvers/osqp_solver.h"
#include "drake/solvers/scs_solver.h"
#include "drake/solvers/snopt_solver.h"
namespace drake {
namespace solvers {
SolverId SolverTypeConverter::TypeToId(SolverType solver_type) {
switch (solver_type) {
case SolverType::kDReal:
return DrealSolver::id();
case SolverType::kEqualityConstrainedQP:
return EqualityConstrainedQPSolver::id();
case SolverType::kGurobi:
return GurobiSolver::id();
case SolverType::kIpopt:
return IpoptSolver::id();
case SolverType::kLinearSystem:
return LinearSystemSolver::id();
case SolverType::kMobyLCP:
return MobyLcpSolverId::id();
case SolverType::kMosek:
return MosekSolver::id();
case SolverType::kNlopt:
return NloptSolver::id();
case SolverType::kOsqp:
return OsqpSolver::id();
case SolverType::kSnopt:
return SnoptSolver::id();
case SolverType::kScs:
return ScsSolver::id();
}
DRAKE_ABORT();
}
optional<SolverType> SolverTypeConverter::IdToType(SolverId solver_id) {
if (solver_id == DrealSolver::id()) {
return SolverType::kDReal;
} else if (solver_id == EqualityConstrainedQPSolver::id()) {
return SolverType::kEqualityConstrainedQP;
} else if (solver_id == GurobiSolver::id()) {
return SolverType::kGurobi;
} else if (solver_id == IpoptSolver::id()) {
return SolverType::kIpopt;
} else if (solver_id == LinearSystemSolver::id()) {
return SolverType::kLinearSystem;
} else if (solver_id == MobyLcpSolverId::id()) {
return SolverType::kMobyLCP;
} else if (solver_id == MosekSolver::id()) {
return SolverType::kMosek;
} else if (solver_id == NloptSolver::id()) {
return SolverType::kNlopt;
} else if (solver_id == SnoptSolver::id()) {
return SolverType::kSnopt;
} else if (solver_id == OsqpSolver::id()) {
return SolverType::kOsqp;
} else if (solver_id == ScsSolver::id()) {
return SolverType::kScs;
} else {
return nullopt;
}
}
} // namespace solvers
} // namespace drake