DART  6.10.1
dart::optimizer::Solver Class Referenceabstract

Abstract class that provides a common interface for different Solvers. More...

#include <Solver.hpp>

Inheritance diagram for dart::optimizer::Solver:
dart::optimizer::GradientDescentSolver dart::optimizer::IpoptSolver dart::optimizer::NloptSolver dart::optimizer::snopt::SnoptSolver

Classes

struct  Properties
 The Solver::Properties class contains Solver parameters that are common to all Solver types. More...
 

Public Member Functions

 Solver (const Properties &_properties=Properties())
 Default Constructor. More...
 
 Solver (std::shared_ptr< Problem > _problem)
 Alternative Constructor. More...
 
virtual ~Solver ()=default
 Destructor. More...
 
virtual bool solve ()=0
 Solve optimization problem. More...
 
virtual std::string getType () const =0
 Get the type (implementation) of this Solver. More...
 
virtual std::shared_ptr< Solverclone () const =0
 Create an identical clone of this Solver. More...
 
void setProperties (const Properties &_properties)
 Set the generic Properties of this Solver. More...
 
const PropertiesgetSolverProperties () const
 Get the generic Properties of this Solver. More...
 
void copy (const Solver &_otherSolver)
 Copy the generic Properties of another Solver. More...
 
Solveroperator= (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< ProblemgetProblem () 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...
 

Protected Attributes

Properties mProperties
 

Detailed Description

Abstract class that provides a common interface for different Solvers.

The different Solver implementations each use a different nonlinear problem solving library, which could lead to differences in performance for various problem types. This base class allows the different Solver implementations to be swapped out with each other quickly and easily to help with testing, benchmarking, and experimentation.

Constructor & Destructor Documentation

◆ Solver() [1/2]

dart::optimizer::Solver::Solver ( const Properties _properties = Properties())
explicit

Default Constructor.

◆ Solver() [2/2]

dart::optimizer::Solver::Solver ( std::shared_ptr< Problem _problem)
explicit

Alternative Constructor.

◆ ~Solver()

virtual dart::optimizer::Solver::~Solver ( )
virtualdefault

Destructor.

Member Function Documentation

◆ clone()

virtual std::shared_ptr<Solver> dart::optimizer::Solver::clone ( ) const
pure virtual

◆ copy()

void dart::optimizer::Solver::copy ( const Solver _otherSolver)

Copy the generic Properties of another Solver.

◆ getIterationsPerPrint()

std::size_t dart::optimizer::Solver::getIterationsPerPrint ( ) const

Get the number of iterations that should pass between printing progress to the terminal.

A value of 0 means there will be no printing.

◆ getNumMaxIterations()

std::size_t dart::optimizer::Solver::getNumMaxIterations ( ) const

Get the maximum number of iterations that the Solver should use.

◆ getOutStream()

std::ostream * dart::optimizer::Solver::getOutStream ( ) const

Get the output stream that prints the Solver's progress.

◆ getPrintFinalResult()

bool dart::optimizer::Solver::getPrintFinalResult ( ) const

Returns true if the final result should be printed to the terminal.

◆ getProblem()

std::shared_ptr< Problem > dart::optimizer::Solver::getProblem ( ) const

Get nonlinear optimization problem.

◆ getResultFileName()

const std::string & dart::optimizer::Solver::getResultFileName ( ) const

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.

◆ getSolverProperties()

const Solver::Properties & dart::optimizer::Solver::getSolverProperties ( ) const

Get the generic Properties of this Solver.

◆ getTolerance()

double dart::optimizer::Solver::getTolerance ( ) const

Get the maximum step size allowed for the Problem to be considered converged.

◆ getType()

virtual std::string dart::optimizer::Solver::getType ( ) const
pure virtual

◆ operator=()

Solver & dart::optimizer::Solver::operator= ( const Solver _otherSolver)

Copy the generic Properties of another Solver.

◆ setIterationsPerPrint()

void dart::optimizer::Solver::setIterationsPerPrint ( std::size_t  _newRatio)
virtual

Set the number of iterations that should pass between printing progress to the terminal.

Use 0 for no printing.

◆ setNumMaxIterations()

void dart::optimizer::Solver::setNumMaxIterations ( std::size_t  _newMax)
virtual

Set the maximum number of iterations that the Solver should use.

◆ setOutStream()

void dart::optimizer::Solver::setOutStream ( std::ostream *  _os)
virtual

Set the output stream that prints the Solver's progress.

◆ setPrintFinalResult()

void dart::optimizer::Solver::setPrintFinalResult ( bool  _print)
virtual

Set to true if the final result should be printed to the terminal.

◆ setProblem()

void dart::optimizer::Solver::setProblem ( std::shared_ptr< Problem _newProblem)
virtual

Set the nonlinear optimization problem.

◆ setProperties()

void dart::optimizer::Solver::setProperties ( const Properties _properties)

Set the generic Properties of this Solver.

◆ setResultFileName()

void dart::optimizer::Solver::setResultFileName ( const std::string &  _resultFile)
virtual

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.

◆ setTolerance()

void dart::optimizer::Solver::setTolerance ( double  _newTolerance)
virtual

Set the maximum step size allowed for the Problem to be considered converged.

◆ solve()

virtual bool dart::optimizer::Solver::solve ( )
pure virtual

Member Data Documentation

◆ mProperties

Properties dart::optimizer::Solver::mProperties
protected