An implementation of SolverInterface for the commercially-licensed MOSEK (TM) solver (https://www.mosek.com/).
Drake downloads and builds MOSEK™ automatically, but to enable it you must set the location of your license file as described in the documentation at https://drake.mit.edu/bazel.html#mosek.
The MOSEKLM_LICENSE_FILE environment variable controls whether or not SolverInterface::enabled() returns true. Iff it is set to any non-empty value, then the solver is enabled; otherwise, the solver is not enabled.
MOSEK™ supports many solver parameters. You can refer to the full list of parameters in https://docs.mosek.com/11.0/capi/param-groups.html#doc-param-groups. On top of these parameters, we also provide the following additional parameters
#include <drake/solvers/mosek_solver.h>
Public Types | |
| using | Details = MosekSolverDetails |
| Type of details stored in MathematicalProgramResult. | |
Public Member Functions | |
| MosekSolver () | |
| ~MosekSolver () final | |
Does not allow copy, move, or assignment | |
| MosekSolver (const MosekSolver &)=delete | |
| MosekSolver & | operator= (const MosekSolver &)=delete |
| MosekSolver (MosekSolver &&)=delete | |
| MosekSolver & | operator= (MosekSolver &&)=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 | |
| SolverBase & | operator= (const SolverBase &)=delete |
| SolverBase (SolverBase &&)=delete | |
| SolverBase & | operator= (SolverBase &&)=delete |
| Public Member Functions inherited from SolverInterface | |
| virtual | ~SolverInterface () |
| SolverInterface (const SolverInterface &)=delete | |
| SolverInterface & | operator= (const SolverInterface &)=delete |
| SolverInterface (SolverInterface &&)=delete | |
| SolverInterface & | operator= (SolverInterface &&)=delete |
Static Public Member Functions | |
| static std::shared_ptr< License > | AcquireLicense () |
| This acquires a MOSEK™ license environment shared among all MosekSolver instances; the environment will stay valid as long as at least one shared_ptr returned by this function is alive. | |
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 MOSEKLM_LICENSE_FILE has been set to a non-empty value. | |
| static bool | ProgramAttributesSatisfied (const MathematicalProgram &) |
| static std::string | UnsatisfiedProgramAttributes (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 () | |
| using Details = MosekSolverDetails |
Type of details stored in MathematicalProgramResult.
|
delete |
|
delete |
| MosekSolver | ( | ) |
|
final |
|
static |
This acquires a MOSEK™ license environment shared among all MosekSolver instances; the environment will stay valid as long as at least one shared_ptr returned by this function is alive.
Call this ONLY if you must use different MathematicalProgram instances at different instances in time, and repeatedly acquiring the license is costly (e.g., requires contacting a license server).
| std::exception | if MOSEK™ is available but a license cannot be obtained. |
|
static |
|
static |
|
static |
Returns true iff the environment variable MOSEKLM_LICENSE_FILE has been set to a non-empty value.
|
delete |
|
delete |
|
static |
|
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.
| 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.
|
static |