Line data Source code
1 : #pragma once 2 : 3 : #include "elsaDefines.h" 4 : #include "DataContainer.h" 5 : #include "Cloneable.h" 6 : 7 : namespace elsa 8 : { 9 : /** 10 : * @brief Base class representing a solver for an optimization problem. 11 : * 12 : * @author Matthias Wieczorek - initial code 13 : * @author Maximilian Hornung - modularization 14 : * @author Tobias Lasser - rewrite, modernization 15 : * 16 : * @tparam data_t data type for the domain and range of the problem, defaulting to real_t 17 : * 18 : * This class represents abstract (typically iterative) solvers acting on optimization problems. 19 : */ 20 : template <typename data_t = real_t> 21 : class Solver : public Cloneable<Solver<data_t>> 22 : { 23 : public: 24 : /// Scalar alias 25 : using Scalar = data_t; 26 : 27 141 : Solver() = default; 28 : 29 : /// default destructor 30 141 : ~Solver() override = default; 31 : 32 : /** 33 : * @brief Solve the optimization problem (most likely iteratively) 34 : * 35 : * @param[in] iterations number of iterations to execute (optional argument, the default 0 36 : * value lets the solve choose how many iterations to execute) 37 : * 38 : * @returns a reference to the current solution (after solving) 39 : * 40 : * Please note: this method calls solveImpl, which has to be overridden in derived classes. 41 : */ 42 : DataContainer<data_t>& solve(index_t iterations = 0); 43 : 44 : protected: 45 : /// the solve method to be overridden in derived classes 46 : virtual DataContainer<data_t>& solveImpl(index_t iterations) = 0; 47 : 48 : /// implement the polymorphic comparison operation 49 : // bool isEqual(const Solver<data_t>& other) const override; 50 : }; 51 : } // namespace elsa