Drake
Drake C++ Documentation
SolverInterface Class Referenceabstract

Detailed Description

Interface used by implementations of individual solvers.

#include <drake/solvers/solver_interface.h>

Public Member Functions

virtual ~SolverInterface ()
 
virtual bool available () const =0
 Returns true iff support for this solver has been compiled into Drake. More...
 
virtual bool enabled () const =0
 Returns true iff this solver is properly configured for use at runtime. More...
 
virtual void Solve (const MathematicalProgram &prog, const std::optional< Eigen::VectorXd > &initial_guess, const std::optional< SolverOptions > &solver_options, MathematicalProgramResult *result) const =0
 Solves an optimization program with optional initial guess and solver options. More...
 
virtual SolverId solver_id () const =0
 Returns the identifier of this solver. More...
 
virtual bool AreProgramAttributesSatisfied (const MathematicalProgram &prog) const =0
 Returns true iff the program's attributes are compatible with this solver's capabilities. More...
 
virtual std::string ExplainUnsatisfiedProgramAttributes (const MathematicalProgram &prog) const =0
 Describes the reasons (if any) why the program is incompatible with this solver's capabilities. More...
 
Does not allow copy, move, or assignment
 SolverInterface (const SolverInterface &)=delete
 
SolverInterfaceoperator= (const SolverInterface &)=delete
 
 SolverInterface (SolverInterface &&)=delete
 
SolverInterfaceoperator= (SolverInterface &&)=delete
 

Protected Member Functions

 SolverInterface ()
 

Constructor & Destructor Documentation

◆ SolverInterface() [1/3]

SolverInterface ( const SolverInterface )
delete

◆ SolverInterface() [2/3]

◆ ~SolverInterface()

virtual ~SolverInterface ( )
virtual

◆ SolverInterface() [3/3]

SolverInterface ( )
protected

Member Function Documentation

◆ AreProgramAttributesSatisfied()

virtual bool AreProgramAttributesSatisfied ( const MathematicalProgram prog) const
pure virtual

Returns true iff the program's attributes are compatible with this solver's capabilities.

Implemented in SolverBase.

◆ available()

virtual bool available ( ) const
pure virtual

Returns true iff support for this solver has been compiled into Drake.

When this method returns false, the Solve method will throw.

Most solver implementations will always return true, but certain solvers may have been excluded at compile-time due to licensing restrictions, or to narrow Drake's dependency footprint. In Drake's default build, only commercially-licensed solvers might return false.

Contrast this with enabled(), which reflects whether a solver has been configured for use at runtime (not compile-time).

For details on linking commercial solvers, refer to the solvers' class overview documentation, e.g., SnoptSolver, MosekSolver, GurobiSolver.

Implemented in SolverBase.

◆ enabled()

virtual bool enabled ( ) const
pure virtual

Returns true iff this solver is properly configured for use at runtime.

When this method returns false, the Solve method will throw.

Most solver implementation will always return true, but certain solvers require additional configuration before they may be used, e.g., setting an environment variable to specify a license file or license server. In Drake's default build, only commercially-licensed solvers might return false.

Contrast this with available(), which reflects whether a solver has been incorporated into Drake at compile-time (and has nothing to do with the runtime configuration). A solver where available() returns false may still return true for enabled() if it is properly configured.

The mechanism to configure a particular solver implementation is specific to the solver in question, but typically uses an environment variable. For details on configuring commercial solvers, refer to the solvers' class overview documentation, e.g., SnoptSolver, MosekSolver, GurobiSolver.

Implemented in SolverBase.

◆ ExplainUnsatisfiedProgramAttributes()

virtual std::string ExplainUnsatisfiedProgramAttributes ( const MathematicalProgram prog) const
pure virtual

Describes the reasons (if any) why the program is incompatible with this solver's capabilities.

If AreProgramAttributesSatisfied would return true for the program, then this function returns the empty string.

Implemented in SolverBase.

◆ operator=() [1/2]

SolverInterface& operator= ( const SolverInterface )
delete

◆ operator=() [2/2]

SolverInterface& operator= ( SolverInterface &&  )
delete

◆ Solve()

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

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 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.

Implemented in SolverBase.

◆ solver_id()

virtual SolverId solver_id ( ) const
pure virtual

Returns the identifier of this solver.

Implemented in SolverBase.


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