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

Detailed Description

A wrapper to call DAQP using Drake's MathematicalProgram.

DAQP is a dual active-set solver for convex quadratic programs. It works on dense matrices, so it is well suited to small and medium sized QPs (e.g., up to a few hundred variables), such as those in differential inverse kinematics and model predictive control, where it is typically much faster and more accurate than first-order methods. It does not exploit sparsity, so for large sparse QPs prefer a sparse solver such as ClarabelSolver or OsqpSolver.

DaqpSolver accepts quadratic and linear costs, linear constraints, linear equality constraints, and bounding box constraints. A quadratic cost is required, and it must be convex; positive semidefinite Hessians are supported. The solver performs a fresh setup on every call to Solve(); the initial guess is ignored, and variable scaling is ignored (with a warning).

Solver options

DAQP's options may be set with SolverOptions using the field names of DAQPSettings:

  • primal_tol (double)
  • dual_tol (double)
  • zero_tol (double)
  • pivot_tol (double)
  • progress_tol (double)
  • sing_tol (double)
  • refactor_tol (double)
  • cycle_tol (int)
  • iter_limit (int)
  • time_limit (double, seconds)
  • fval_bound (double)
  • eps_prox (double)
  • eta_prox (double)
  • eq_reduction (int)

Refer to https://darnstrom.github.io/daqp/parameters/ for their meanings and default values. An unrecognized option name throws an exception. DaqpSolver does not print to the console, so CommonSolverOption::kPrintToConsole and CommonSolverOption::kPrintFileName have no effect; DAQP is single-threaded, so CommonSolverOption::kMaxThreads has no effect.

Solution result

When DAQP reaches its iteration limit (iter_limit) or time limit (time_limit), the result is SolutionResult::kIterationLimit. Note that when the Hessian is only positive semidefinite, DAQP does not detect an unbounded problem; it reports SolutionResult::kIterationLimit after iter_limit proximal-point iterations instead of SolutionResult::kUnbounded.

#include <drake/solvers/daqp_solver.h>

Public Types

using Details = DaqpSolverDetails
 Type of details stored in MathematicalProgramResult.

Public Member Functions

 DaqpSolver ()
 ~DaqpSolver () final
Does not allow copy, move, or assignment
 DaqpSolver (const DaqpSolver &)=delete
DaqpSolver & operator= (const DaqpSolver &)=delete
 DaqpSolver (DaqpSolver &&)=delete
DaqpSolver & operator= (DaqpSolver &&)=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 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 ()
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 ()

Member Typedef Documentation

◆ Details

Type of details stored in MathematicalProgramResult.

Constructor & Destructor Documentation

◆ DaqpSolver() [1/3]

DaqpSolver ( const DaqpSolver & )
delete

◆ DaqpSolver() [2/3]

DaqpSolver ( DaqpSolver && )
delete

◆ DaqpSolver() [3/3]

DaqpSolver ( )

◆ ~DaqpSolver()

~DaqpSolver ( )
final

Member Function Documentation

◆ id()

SolverId id ( )
static

◆ is_available()

bool is_available ( )
static

◆ is_enabled()

bool is_enabled ( )
static

◆ operator=() [1/2]

DaqpSolver & operator= ( const DaqpSolver & )
delete

◆ operator=() [2/2]

DaqpSolver & operator= ( DaqpSolver && )
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.

◆ UnsatisfiedProgramAttributes()

std::string UnsatisfiedProgramAttributes ( const MathematicalProgram & )
static

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