33 #ifndef DART_OPTIMIZATION_SOLVER_HPP_ 34 #define DART_OPTIMIZATION_SOLVER_HPP_ 39 #include <Eigen/Dense> 42 namespace optimization {
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);
107 virtual bool solve() = 0;
110 virtual std::string
getType()
const = 0;
113 virtual std::shared_ptr<Solver>
clone()
const = 0;
128 virtual void setProblem(std::shared_ptr<Problem> _newProblem);
182 #endif // DART_OPTIMIZATION_SOLVER_HPP_ bool getPrintFinalResult() const
Returns true if the final result should be printed to the terminal.
Definition: Solver.cpp:171
std::size_t getNumMaxIterations() const
Get the maximum number of iterations that the Solver should use.
Definition: Solver.cpp:135
double getTolerance() const
Get the maximum step size allowed for the Problem to be considered converged.
Definition: Solver.cpp:123
virtual ~Solver()=default
Destructor.
std::size_t getIterationsPerPrint() const
Get the number of iterations that should pass between printing progress to the terminal.
Definition: Solver.cpp:159
std::size_t mNumMaxIterations
The maximum number of iterations that the solver should use.
Definition: Solver.hpp:71
bool mPrintFinalResult
Set to true if the final result should be printed to the terminal.
Definition: Solver.hpp:81
std::ostream * getOutStream() const
Get the output stream that prints the Solver's progress.
Definition: Solver.cpp:153
const std::string & getResultFileName() const
Get the name of the file that results should be printed to.
Definition: Solver.cpp:183
virtual bool solve()=0
Solve optimization problem.
std::shared_ptr< Problem > getProblem() const
Get nonlinear optimization problem.
Definition: Solver.cpp:111
Solver & operator=(const Solver &_otherSolver)
Copy the generic Properties of another Solver.
Definition: Solver.cpp:98
void copy(const Solver &_otherSolver)
Copy the generic Properties of another Solver.
Definition: Solver.cpp:89
virtual std::shared_ptr< Solver > clone() const =0
Create an identical clone of this Solver.
std::ostream * mOutStream
Stream for printing the Solver's progress. Default is std::cout.
Definition: Solver.hpp:78
Definition: Aspect.cpp:40
virtual void setNumMaxIterations(std::size_t _newMax)
Set the maximum number of iterations that the Solver should use.
Definition: Solver.cpp:129
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 void setPrintFinalResult(bool _print)
Set to true if the final result should be printed to the terminal.
Definition: Solver.cpp:165
std::size_t mIterationsPerPrint
How many iterations between printing the Solver's progress to the terminal.
Definition: Solver.hpp:75
const Properties & getSolverProperties() const
Get the generic Properties of this Solver.
Definition: Solver.cpp:83
virtual void setOutStream(std::ostream *_os)
Set the output stream that prints the Solver's progress.
Definition: Solver.cpp:147
virtual std::string getType() const =0
Get the type (implementation) of this Solver.
double mTolerance
The relative tolerance on the optimization parameters.
Definition: Solver.hpp:67
void setProperties(const Properties &_properties)
Set the generic Properties of this Solver.
Definition: Solver.cpp:72
Abstract class that provides a common interface for different Solvers.
Definition: Solver.hpp:52
virtual void setProblem(std::shared_ptr< Problem > _newProblem)
Set the nonlinear optimization problem.
Definition: Solver.cpp:105
Solver(const Properties &_properties=Properties())
Default Constructor.
Definition: Solver.cpp:60
std::shared_ptr< Problem > mProblem
Nonlinear optimization Problem to be solved.
Definition: Solver.hpp:62
virtual void setTolerance(double _newTolerance)
Set the maximum step size allowed for the Problem to be considered converged.
Definition: Solver.cpp:117
std::string mResultFile
Publish the results of the optimization to a file.
Definition: Solver.hpp:85
The Solver::Properties class contains Solver parameters that are common to all Solver types...
Definition: Solver.hpp:59
virtual void setResultFileName(const std::string &_resultFile)
Set the name of the file that results should be printed to.
Definition: Solver.cpp:177