forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
osqp_solver.h
64 lines (56 loc) · 1.95 KB
/
osqp_solver.h
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
#pragma once
#include "drake/common/drake_copyable.h"
#include "drake/solvers/solver_base.h"
namespace drake {
namespace solvers {
/**
* The OSQP solver details after calling Solve() function. The user can call
* MathematicalProgramResult::get_solver_details<OsqpSolver>() to obtain the
* details.
*/
struct OsqpSolverDetails {
/// Number of iterations taken.
int iter{};
/// Status of the solver at termination. Please refer to
/// https://github.com/oxfordcontrol/osqp/blob/master/include/constants.h
int status_val{};
/// Norm of primal residue.
double primal_res{};
/// Norm of dual residue.
double dual_res{};
/// Time taken for setup phase (seconds).
double setup_time{};
/// Time taken for solve phase (seconds).
double solve_time{};
/// Time taken for polish phase (seconds).
double polish_time{};
/// Total OSQP time (seconds).
double run_time{};
/// y contains the solution for the Lagrangian multiplier associated with
/// l <= Ax <= u. The Lagrangian multiplier is set only when OSQP solves
/// the problem. Notice that the order of the linear constraints are linear
/// inequality first, and then linear equality constraints.
Eigen::VectorXd y{};
};
class OsqpSolver final : public SolverBase {
public:
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(OsqpSolver)
/// Type of details stored in MathematicalProgramResult.
using Details = OsqpSolverDetails;
OsqpSolver();
~OsqpSolver() final;
/// @name Static versions of the instance methods with similar names.
//@{
static SolverId id();
static bool is_available();
static bool is_enabled();
static bool ProgramAttributesSatisfied(const MathematicalProgram&);
//@}
// A using-declaration adds these methods into our class's Doxygen.
using SolverBase::Solve;
private:
void DoSolve(const MathematicalProgram&, const Eigen::VectorXd&,
const SolverOptions&, MathematicalProgramResult*) const final;
};
} // namespace solvers
} // namespace drake