33 #ifndef DART_OPTIMIZER_SOLVER_HPP_
34 #define DART_OPTIMIZER_SOLVER_HPP_
39 #include <Eigen/Dense>
88 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:165
std::shared_ptr< Problem > getProblem() const
Get nonlinear optimization problem.
Definition: Solver.cpp:111
virtual void setOutStream(std::ostream *_os)
Set the output stream that prints the Solver's progress.
Definition: Solver.cpp:147
virtual void setProblem(std::shared_ptr< Problem > _newProblem)
Set the nonlinear optimization problem.
Definition: Solver.cpp:105
std::size_t getIterationsPerPrint() const
Get the number of iterations that should pass between printing progress to the terminal.
Definition: Solver.cpp:159
const std::string & getResultFileName() const
Get the name of the file that results should be printed to.
Definition: Solver.cpp:183
std::size_t getNumMaxIterations() const
Get the maximum number of iterations that the Solver should use.
Definition: Solver.cpp:135
void copy(const Solver &_otherSolver)
Copy the generic Properties of another Solver.
Definition: Solver.cpp:89
Solver & operator=(const Solver &_otherSolver)
Copy the generic Properties of another Solver.
Definition: Solver.cpp:98
std::ostream * getOutStream() const
Get the output stream that prints the Solver's progress.
Definition: Solver.cpp:153
Properties mProperties
Definition: Solver.hpp:176
bool getPrintFinalResult() const
Returns true if the final result should be printed to the terminal.
Definition: Solver.cpp:171
virtual ~Solver()=default
Destructor.
double getTolerance() const
Get the maximum step size allowed for the Problem to be considered converged.
Definition: Solver.cpp:123
virtual void setIterationsPerPrint(std::size_t _newRatio)
Set the number of iterations that should pass between printing progress to the terminal.
Definition: Solver.cpp:141
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:129
virtual void setTolerance(double _newTolerance)
Set the maximum step size allowed for the Problem to be considered converged.
Definition: Solver.cpp:117
void setProperties(const Properties &_properties)
Set the generic Properties of this Solver.
Definition: Solver.cpp:72
virtual void setResultFileName(const std::string &_resultFile)
Set the name of the file that results should be printed to.
Definition: Solver.cpp:177
const Properties & getSolverProperties() const
Get the generic Properties of this Solver.
Definition: Solver.cpp:83
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:65
The Solver::Properties class contains Solver parameters that are common to all Solver types.
Definition: Solver.hpp:60
std::ostream * mOutStream
Stream for printing the Solver's progress. Default is std::cout.
Definition: Solver.hpp:78
std::string mResultFile
Publish the results of the optimization to a file.
Definition: Solver.hpp:85
std::size_t mIterationsPerPrint
How many iterations between printing the Solver's progress to the terminal.
Definition: Solver.hpp:75
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:81
std::size_t mNumMaxIterations
The maximum number of iterations that the solver should use.
Definition: Solver.hpp:71
double mTolerance
The relative tolerance on the optimization parameters.
Definition: Solver.hpp:67
std::shared_ptr< Problem > mProblem
Nonlinear optimization Problem to be solved.
Definition: Solver.hpp:62