DART
6.10.1
|
DefaultSolver is a Solver extension which is native to DART (rather than relying on third-party libraries). More...
#include <GradientDescentSolver.hpp>
Classes | |
struct | Properties |
struct | UniqueProperties |
Public Member Functions | |
GradientDescentSolver (const Properties &_properties=Properties()) | |
Default constructor. More... | |
GradientDescentSolver (std::shared_ptr< Problem > _problem) | |
Alternative constructor. More... | |
virtual | ~GradientDescentSolver () |
Destructor. More... | |
bool | solve () override |
Solve optimization problem. More... | |
Eigen::VectorXd | getLastConfiguration () const |
Get the last configuration that was used by the Solver. More... | |
std::string | getType () const override |
Get the type (implementation) of this Solver. More... | |
std::shared_ptr< Solver > | clone () const override |
Create an identical clone of this Solver. More... | |
void | setProperties (const Properties &_properties) |
Set the Properties of this GradientDescentSolver. More... | |
void | setProperties (const UniqueProperties &_properties) |
Set the Properties of this GradientDescentSolver. More... | |
Properties | getGradientDescentProperties () const |
Get the Properties of this GradientDescentSolver. More... | |
void | copy (const GradientDescentSolver &_other) |
Copy the Properties of another GradientDescentSolver. More... | |
GradientDescentSolver & | operator= (const GradientDescentSolver &_other) |
Copy the Properties of another GradientDescentSolver. More... | |
void | setStepSize (double _newMultiplier) |
Set the multiplier for the step size. More... | |
double | getStepSize () const |
Get the multiplier for the step size. More... | |
void | setMaxAttempts (std::size_t _maxAttempts) |
Set the maximum number of solving attempts before quitting. More... | |
std::size_t | getMaxAttempts () const |
Get the maximum number of solving attempts. More... | |
void | setPerturbationStep (std::size_t _step) |
Set the number of steps that will be taken before applying a randomized perturbation. More... | |
std::size_t | getPerturbationStep () const |
Get UniqueProperties::mPerturbationStep. More... | |
void | setMaxPerturbationFactor (double _factor) |
Set UniqueProperties::mPerturbationFactor. More... | |
double | getMaxPerturbationFactor () const |
Get UniqueProperties::mPerturbationFactor. More... | |
void | setDefaultConstraintWeight (double _newDefault) |
Set UniqueProperties::mDefaultConstraintWeight. More... | |
double | getDefaultConstraintWeight () const |
Get UniqueProperties::mDefaultConstraintWeight. More... | |
Eigen::VectorXd & | getEqConstraintWeights () |
Set UniqueProperties::mEqConstraintWeights. More... | |
const Eigen::VectorXd & | getEqConstraintWeights () const |
Get UniqueProperties::mEqConstraintWeights. More... | |
Eigen::VectorXd & | getIneqConstraintWeights () |
Set UniqueProperties::mIneqConstraintWeights. More... | |
const Eigen::VectorXd & | getIneqConstraintWeights () const |
Get UniqueProperties::mIneqConstraintWeights. More... | |
void | randomizeConfiguration (Eigen::VectorXd &_x) |
Randomize the configuration based on this Solver's settings. More... | |
void | clampToBoundary (Eigen::VectorXd &_x) |
Clamp the configuration to the limits of the Problem. More... | |
std::size_t | getLastNumIterations () const |
Get the number of iterations used in the last attempt to solve the problem. More... | |
void | setProperties (const Properties &_properties) |
Set the generic Properties of this Solver. More... | |
const Properties & | getSolverProperties () const |
Get the generic Properties of this Solver. More... | |
void | copy (const Solver &_otherSolver) |
Copy the generic Properties of another Solver. More... | |
virtual void | setProblem (std::shared_ptr< Problem > _newProblem) |
Set the nonlinear optimization problem. More... | |
std::shared_ptr< Problem > | getProblem () const |
Get nonlinear optimization problem. More... | |
virtual void | setTolerance (double _newTolerance) |
Set the maximum step size allowed for the Problem to be considered converged. More... | |
double | getTolerance () const |
Get the maximum step size allowed for the Problem to be considered converged. More... | |
virtual void | setNumMaxIterations (std::size_t _newMax) |
Set the maximum number of iterations that the Solver should use. More... | |
std::size_t | getNumMaxIterations () const |
Get the maximum number of iterations that the Solver should use. More... | |
virtual void | setIterationsPerPrint (std::size_t _newRatio) |
Set the number of iterations that should pass between printing progress to the terminal. More... | |
std::size_t | getIterationsPerPrint () const |
Get the number of iterations that should pass between printing progress to the terminal. More... | |
virtual void | setOutStream (std::ostream *_os) |
Set the output stream that prints the Solver's progress. More... | |
std::ostream * | getOutStream () const |
Get the output stream that prints the Solver's progress. More... | |
virtual void | setPrintFinalResult (bool _print) |
Set to true if the final result should be printed to the terminal. More... | |
bool | getPrintFinalResult () const |
Returns true if the final result should be printed to the terminal. More... | |
virtual void | setResultFileName (const std::string &_resultFile) |
Set the name of the file that results should be printed to. More... | |
const std::string & | getResultFileName () const |
Get the name of the file that results should be printed to. More... | |
Static Public Attributes | |
static const std::string | Type = "GradientDescentSolver" |
Protected Attributes | |
UniqueProperties | mGradientP |
GradientDescentSolver properties. More... | |
std::size_t | mLastNumIterations |
The last number of iterations performed by this Solver. More... | |
std::random_device | mRD |
Randomization device. More... | |
std::mt19937 | mMT |
Mersenne twister method. More... | |
std::uniform_real_distribution< double > | mDistribution |
Distribution. More... | |
Eigen::VectorXd | mEqConstraintCostCache |
Cache to track the costs of equality constraints. More... | |
Eigen::VectorXd | mIneqConstraintCostCache |
Cache to track the costs of inequality constraints. More... | |
Eigen::VectorXd | mLastConfig |
The last config reached by this Solver. More... | |
Properties | mProperties |
DefaultSolver is a Solver extension which is native to DART (rather than relying on third-party libraries).
It uses randomized gradient descent and softened constraints (i.e. constraint functions are added into the objective function and assigned weights) to solve nonlinear problems. Note that this is not a good option for Problems with difficult constraint functions that need to be solved exactly.
|
explicit |
Default constructor.
|
explicit |
Alternative constructor.
|
virtual |
Destructor.
void dart::optimizer::GradientDescentSolver::clampToBoundary | ( | Eigen::VectorXd & | _x | ) |
Clamp the configuration to the limits of the Problem.
|
overridevirtual |
Create an identical clone of this Solver.
Implements dart::optimizer::Solver.
void dart::optimizer::GradientDescentSolver::copy | ( | const GradientDescentSolver & | _other | ) |
Copy the Properties of another GradientDescentSolver.
|
inherited |
Copy the generic Properties of another Solver.
double dart::optimizer::GradientDescentSolver::getDefaultConstraintWeight | ( | ) | const |
Eigen::VectorXd & dart::optimizer::GradientDescentSolver::getEqConstraintWeights | ( | ) |
const Eigen::VectorXd & dart::optimizer::GradientDescentSolver::getEqConstraintWeights | ( | ) | const |
GradientDescentSolver::Properties dart::optimizer::GradientDescentSolver::getGradientDescentProperties | ( | ) | const |
Get the Properties of this GradientDescentSolver.
Eigen::VectorXd & dart::optimizer::GradientDescentSolver::getIneqConstraintWeights | ( | ) |
const Eigen::VectorXd & dart::optimizer::GradientDescentSolver::getIneqConstraintWeights | ( | ) | const |
|
inherited |
Get the number of iterations that should pass between printing progress to the terminal.
A value of 0 means there will be no printing.
Eigen::VectorXd dart::optimizer::GradientDescentSolver::getLastConfiguration | ( | ) | const |
Get the last configuration that was used by the Solver.
std::size_t dart::optimizer::GradientDescentSolver::getLastNumIterations | ( | ) | const |
Get the number of iterations used in the last attempt to solve the problem.
std::size_t dart::optimizer::GradientDescentSolver::getMaxAttempts | ( | ) | const |
Get the maximum number of solving attempts.
double dart::optimizer::GradientDescentSolver::getMaxPerturbationFactor | ( | ) | const |
Get UniqueProperties::mPerturbationFactor.
|
inherited |
Get the maximum number of iterations that the Solver should use.
|
inherited |
Get the output stream that prints the Solver's progress.
std::size_t dart::optimizer::GradientDescentSolver::getPerturbationStep | ( | ) | const |
|
inherited |
Returns true if the final result should be printed to the terminal.
|
inherited |
Get nonlinear optimization problem.
|
inherited |
Get the name of the file that results should be printed to.
An empty string indicates that results should not be printed to a file.
|
inherited |
Get the generic Properties of this Solver.
double dart::optimizer::GradientDescentSolver::getStepSize | ( | ) | const |
Get the multiplier for the step size.
|
inherited |
Get the maximum step size allowed for the Problem to be considered converged.
|
overridevirtual |
Get the type (implementation) of this Solver.
Implements dart::optimizer::Solver.
GradientDescentSolver & dart::optimizer::GradientDescentSolver::operator= | ( | const GradientDescentSolver & | _other | ) |
Copy the Properties of another GradientDescentSolver.
void dart::optimizer::GradientDescentSolver::randomizeConfiguration | ( | Eigen::VectorXd & | _x | ) |
Randomize the configuration based on this Solver's settings.
void dart::optimizer::GradientDescentSolver::setDefaultConstraintWeight | ( | double | _newDefault | ) |
|
virtualinherited |
Set the number of iterations that should pass between printing progress to the terminal.
Use 0 for no printing.
void dart::optimizer::GradientDescentSolver::setMaxAttempts | ( | std::size_t | _maxAttempts | ) |
Set the maximum number of solving attempts before quitting.
Each attempt will use getNumMaxIterations() steps. When a new attempt is started, it will use the next seed in the list of seeds. If we've reached the end of the list of seeds, the attempt will start from a randomized configuration.
void dart::optimizer::GradientDescentSolver::setMaxPerturbationFactor | ( | double | _factor | ) |
Set UniqueProperties::mPerturbationFactor.
|
virtualinherited |
Set the maximum number of iterations that the Solver should use.
|
virtualinherited |
Set the output stream that prints the Solver's progress.
void dart::optimizer::GradientDescentSolver::setPerturbationStep | ( | std::size_t | _step | ) |
Set the number of steps that will be taken before applying a randomized perturbation.
|
virtualinherited |
Set to true if the final result should be printed to the terminal.
|
virtualinherited |
Set the nonlinear optimization problem.
void dart::optimizer::GradientDescentSolver::setProperties | ( | const Properties & | _properties | ) |
Set the Properties of this GradientDescentSolver.
|
inherited |
Set the generic Properties of this Solver.
void dart::optimizer::GradientDescentSolver::setProperties | ( | const UniqueProperties & | _properties | ) |
Set the Properties of this GradientDescentSolver.
|
virtualinherited |
Set the name of the file that results should be printed to.
Use an empty string to indicate that results should not be printed to a file.
void dart::optimizer::GradientDescentSolver::setStepSize | ( | double | _newMultiplier | ) |
Set the multiplier for the step size.
|
virtualinherited |
Set the maximum step size allowed for the Problem to be considered converged.
|
overridevirtual |
Solve optimization problem.
Implements dart::optimizer::Solver.
|
protected |
Distribution.
|
protected |
Cache to track the costs of equality constraints.
|
protected |
GradientDescentSolver properties.
|
protected |
Cache to track the costs of inequality constraints.
|
protected |
The last config reached by this Solver.
|
protected |
The last number of iterations performed by this Solver.
|
protected |
Mersenne twister method.
|
protectedinherited |
|
protected |
Randomization device.
|
static |