forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnopt_solver.h
74 lines (60 loc) · 2.1 KB
/
snopt_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
65
66
67
68
69
70
71
72
73
74
#pragma once
#include <string>
#include "drake/common/drake_copyable.h"
#include "drake/common/drake_deprecated.h"
#include "drake/solvers/solver_base.h"
namespace drake {
namespace solvers {
/**
* The SNOPT solver details after calling Solve() function. The user can call
* MathematicalProgramResult::get_solver_details<SnoptSolver>() to obtain the
* details.
*/
struct SnoptSolverDetails {
/**
* The exit condition of the solver. Please refer to section "EXIT conditions"
* in "User's Guide for SNOPT Version 7: Software for Large-Scale Nonlinear
* Programming" by Philip E. Gill to interprete the exit condition.
*/
int info{};
/** The final value of the dual variables for the bound constraint x_lower <=
* x <= x_upper.
*/
Eigen::VectorXd xmul;
/** The final value of the vector of problem functions F(x).
*/
Eigen::VectorXd F;
/** The final value of the dual variables (Lagrange multipliers) for the
* general constraints F_lower <= F(x) <= F_upper.
*/
Eigen::VectorXd Fmul;
};
class SnoptSolver final : public SolverBase {
public:
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(SnoptSolver)
/// Type of details stored in MathematicalProgramResult.
using Details = SnoptSolverDetails;
SnoptSolver();
~SnoptSolver() final;
/// @return true.
/// variables, hence it is not thread safe. SNOPT fortran interface is thread
/// safe.
DRAKE_DEPRECATED("2020-02-01",
"The SnoptSolver::is_thread_safe always returns true.")
static bool is_thread_safe();
/// For some reason, SNOPT 7.4 fails to detect a simple LP being unbounded.
static bool is_bounded_lp_broken();
/// @name Static versions of the instance methods with similar names.
//@{
static SolverId id();
static bool is_available();
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