Drake
Drake C++ Documentation
Loading...
Searching...
No Matches
SnoptSolver Class Referencefinal

Detailed Description

An implementation of SolverInterface for the commercially-licensed SNOPT solver (https://ccom.ucsd.edu/~optimizers/solvers/snopt/).

Builds of Drake from source do not compile SNOPT by default, so therefore SolverInterface::available() will return false. You must opt-in to build SNOPT per the documentation at https://drake.mit.edu/bazel.html#snopt.

Drake's pre-compiled binary releases do incorporate SNOPT, so therefore SolverInterface::available() will return true. Thanks to Philip E. Gill and Elizabeth Wong for their kind support.

There is no license configuration required to use SNOPT, but you may set the environtment variable DRAKE_SNOPT_SOLVER_ENABLED to "0" to force-disable SNOPT, in which case SolverInterface::enabled() will return false.

#include <drake/solvers/snopt_solver.h>

Public Types

using Details = SnoptSolverDetails
 Type of details stored in MathematicalProgramResult.

Public Member Functions

 SnoptSolver ()
 ~SnoptSolver () final
Does not allow copy, move, or assignment
 SnoptSolver (const SnoptSolver &)=delete
SnoptSolveroperator= (const SnoptSolver &)=delete
 SnoptSolver (SnoptSolver &&)=delete
SnoptSolveroperator= (SnoptSolver &&)=delete
Public Member Functions inherited from SolverBase
 ~SolverBase () override
MathematicalProgramResult Solve (const MathematicalProgram &prog, const std::optional< Eigen::VectorXd > &initial_guess=std::nullopt, const std::optional< SolverOptions > &solver_options=std::nullopt) const
 Like SolverInterface::Solve(), but the result is a return value instead of an output argument.
void Solve (const MathematicalProgram &, const std::optional< Eigen::VectorXd > &, const std::optional< SolverOptions > &, MathematicalProgramResult *) const override
 Solves an optimization program with optional initial guess and solver options.
bool available () const override
 Returns true iff support for this solver has been compiled into Drake.
bool enabled () const override
 Returns true iff this solver is properly configured for use at runtime.
SolverId solver_id () const final
 Returns the identifier of this solver.
bool AreProgramAttributesSatisfied (const MathematicalProgram &) const override
 Returns true iff the program's attributes are compatible with this solver's capabilities.
std::string ExplainUnsatisfiedProgramAttributes (const MathematicalProgram &) const override
 Describes the reasons (if any) why the program is incompatible with this solver's capabilities.
 SolverBase (const SolverBase &)=delete
SolverBaseoperator= (const SolverBase &)=delete
 SolverBase (SolverBase &&)=delete
SolverBaseoperator= (SolverBase &&)=delete
Public Member Functions inherited from SolverInterface
virtual ~SolverInterface ()
 SolverInterface (const SolverInterface &)=delete
SolverInterfaceoperator= (const SolverInterface &)=delete
 SolverInterface (SolverInterface &&)=delete
SolverInterfaceoperator= (SolverInterface &&)=delete

Static Public Member Functions

static bool is_bounded_lp_broken ()
 For some reason, SNOPT 7.4 fails to detect a simple LP being unbounded.

Static versions of the instance methods with similar names.

MathematicalProgramResult Solve (const MathematicalProgram &prog, const std::optional< Eigen::VectorXd > &initial_guess=std::nullopt, const std::optional< SolverOptions > &solver_options=std::nullopt) const
 Like SolverInterface::Solve(), but the result is a return value instead of an output argument.
void Solve (const MathematicalProgram &, const std::optional< Eigen::VectorXd > &, const std::optional< SolverOptions > &, MathematicalProgramResult *) const override
 Solves an optimization program with optional initial guess and solver options.
static SolverId id ()
static bool is_available ()
static bool is_enabled ()
 Returns true iff the environment variable DRAKE_SNOPT_SOLVER_ENABLED is unset or set to anything other than "0".
static bool ProgramAttributesSatisfied (const MathematicalProgram &)

Additional Inherited Members

Protected Member Functions inherited from SolverBase
 SolverBase (const SolverId &id, std::function< bool()> available, std::function< bool()> enabled, std::function< bool(const MathematicalProgram &)> are_satisfied, std::function< std::string(const MathematicalProgram &)> explain_unsatisfied=nullptr)
 Constructs a SolverBase with the given default implementations of the solver_id(), available(), enabled(), AreProgramAttributesSatisfied(), and ExplainUnsatisfiedProgramAttributes() methods.
virtual void DoSolve (const MathematicalProgram &prog, const Eigen::VectorXd &initial_guess, const SolverOptions &merged_options, MathematicalProgramResult *result) const
 Hook for subclasses to implement Solve.
Protected Member Functions inherited from SolverInterface
 SolverInterface ()

Member Typedef Documentation

◆ Details

Type of details stored in MathematicalProgramResult.

Constructor & Destructor Documentation

◆ SnoptSolver() [1/3]

SnoptSolver ( const SnoptSolver & )
delete

◆ SnoptSolver() [2/3]

SnoptSolver ( SnoptSolver && )
delete

◆ SnoptSolver() [3/3]

◆ ~SnoptSolver()

~SnoptSolver ( )
final

Member Function Documentation

◆ id()

SolverId id ( )
static

◆ is_available()

bool is_available ( )
static

◆ is_bounded_lp_broken()

bool is_bounded_lp_broken ( )
static

For some reason, SNOPT 7.4 fails to detect a simple LP being unbounded.

◆ is_enabled()

bool is_enabled ( )
static

Returns true iff the environment variable DRAKE_SNOPT_SOLVER_ENABLED is unset or set to anything other than "0".

◆ operator=() [1/2]

SnoptSolver & operator= ( const SnoptSolver & )
delete

◆ operator=() [2/2]

SnoptSolver & operator= ( SnoptSolver && )
delete

◆ ProgramAttributesSatisfied()

bool ProgramAttributesSatisfied ( const MathematicalProgram & )
static

◆ Solve() [1/2]

void Solve ( const MathematicalProgram & prog,
const std::optional< Eigen::VectorXd > & initial_guess,
const std::optional< SolverOptions > & solver_options,
MathematicalProgramResult * result ) const
overridevirtual

Solves an optimization program with optional initial guess and solver options.

Note that these initial guess and solver options are not written to prog. If the prog has set an initial guess, and initial_guess is set, then initial_guess takes priority. If the prog has set an option for a solver, and solver_options contains a different value for the same option on the same solver, then solver_options takes priority. Derived implementations of this interface may elect to throw std::exception for badly formed programs.

Implements SolverInterface.

◆ Solve() [2/2]

MathematicalProgramResult Solve ( const MathematicalProgram & prog,
const std::optional< Eigen::VectorXd > & initial_guess = std::nullopt,
const std::optional< SolverOptions > & solver_options = std::nullopt ) const

Like SolverInterface::Solve(), but the result is a return value instead of an output argument.


The documentation for this class was generated from the following file: