33 #ifndef DART_OPTIMIZER_SOLVER_HPP_
34 #define DART_OPTIMIZER_SOLVER_HPP_
39 #include <Eigen/Dense>
88 Properties(std::shared_ptr<Problem> _problem =
nullptr,
89 double _tolerance = 1e-9,
90 std::size_t _numMaxIterations = 500,
91 std::size_t _iterationsPerPrint = 0,
92 std::ostream* _ostream = &std::cout,
93 bool _printFinalResult =
false,
94 const std::string& _resultFile =
"");
101 explicit Solver(std::shared_ptr<Problem> _problem);
113 virtual std::shared_ptr<Solver>
clone()
const = 0;
128 virtual void setProblem(std::shared_ptr<Problem> _newProblem);
Abstract class that provides a common interface for different Solvers.
Definition: Solver.hpp:53
virtual void setPrintFinalResult(bool _print)
Set to true if the final result should be printed to the terminal.
Definition: Solver.cpp:167
std::shared_ptr< Problem > getProblem() const
Get nonlinear optimization problem.
Definition: Solver.cpp:113
virtual void setOutStream(std::ostream *_os)
Set the output stream that prints the Solver's progress.
Definition: Solver.cpp:149
virtual void setProblem(std::shared_ptr< Problem > _newProblem)
Set the nonlinear optimization problem.
Definition: Solver.cpp:107
std::size_t getIterationsPerPrint() const
Get the number of iterations that should pass between printing progress to the terminal.
Definition: Solver.cpp:161
const std::string & getResultFileName() const
Get the name of the file that results should be printed to.
Definition: Solver.cpp:185
std::size_t getNumMaxIterations() const
Get the maximum number of iterations that the Solver should use.
Definition: Solver.cpp:137
void copy(const Solver &_otherSolver)
Copy the generic Properties of another Solver.
Definition: Solver.cpp:91
Solver & operator=(const Solver &_otherSolver)
Copy the generic Properties of another Solver.
Definition: Solver.cpp:100
std::ostream * getOutStream() const
Get the output stream that prints the Solver's progress.
Definition: Solver.cpp:155
Properties mProperties
Definition: Solver.hpp:177
bool getPrintFinalResult() const
Returns true if the final result should be printed to the terminal.
Definition: Solver.cpp:173
virtual ~Solver()=default
Destructor.
double getTolerance() const
Get the maximum step size allowed for the Problem to be considered converged.
Definition: Solver.cpp:125
virtual void setIterationsPerPrint(std::size_t _newRatio)
Set the number of iterations that should pass between printing progress to the terminal.
Definition: Solver.cpp:143
virtual bool solve()=0
Solve optimization problem.
virtual void setNumMaxIterations(std::size_t _newMax)
Set the maximum number of iterations that the Solver should use.
Definition: Solver.cpp:131
virtual void setTolerance(double _newTolerance)
Set the maximum step size allowed for the Problem to be considered converged.
Definition: Solver.cpp:119
void setProperties(const Properties &_properties)
Set the generic Properties of this Solver.
Definition: Solver.cpp:74
virtual void setResultFileName(const std::string &_resultFile)
Set the name of the file that results should be printed to.
Definition: Solver.cpp:179
const Properties & getSolverProperties() const
Get the generic Properties of this Solver.
Definition: Solver.cpp:85
Solver(const Properties &_properties=Properties())
Default Constructor.
Definition: Solver.cpp:60
virtual std::string getType() const =0
Get the type (implementation) of this Solver.
virtual std::shared_ptr< Solver > clone() const =0
Create an identical clone of this Solver.
Definition: BulletCollisionDetector.cpp:63
The Solver::Properties class contains Solver parameters that are common to all Solver types.
Definition: Solver.hpp:61
std::ostream * mOutStream
Stream for printing the Solver's progress. Default is std::cout.
Definition: Solver.hpp:79
std::string mResultFile
Publish the results of the optimization to a file.
Definition: Solver.hpp:86
std::size_t mIterationsPerPrint
How many iterations between printing the Solver's progress to the terminal.
Definition: Solver.hpp:76
Properties(std::shared_ptr< Problem > _problem=nullptr, double _tolerance=1e-9, std::size_t _numMaxIterations=500, std::size_t _iterationsPerPrint=0, std::ostream *_ostream=&std::cout, bool _printFinalResult=false, const std::string &_resultFile="")
Definition: Solver.cpp:40
bool mPrintFinalResult
Set to true if the final result should be printed to the terminal.
Definition: Solver.hpp:82
std::size_t mNumMaxIterations
The maximum number of iterations that the solver should use.
Definition: Solver.hpp:72
double mTolerance
The relative tolerance on the optimization parameters.
Definition: Solver.hpp:68
std::shared_ptr< Problem > mProblem
Nonlinear optimization Problem to be solved.
Definition: Solver.hpp:63