File: isolver.h

package info (click to toggle)
cppnumericalsolvers 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 372 kB
  • sloc: cpp: 2,694; python: 236; sh: 20; makefile: 10
file content (57 lines) | stat: -rw-r--r-- 1,499 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// CppNumericalSolver
#ifndef ISOLVER_H_
#define ISOLVER_H_

#include <functional>
#include "isolver.h"
#include "../meta.h"
#include "../problem.h"

namespace cppoptlib {

template<typename ProblemType, int Ord>
class ISolver {
public:
    using Scalar    = typename ProblemType::Scalar;
    using TVector   = typename ProblemType::TVector;
    using THessian  = typename ProblemType::THessian;
    using TCriteria = typename ProblemType::TCriteria;
protected:
    const int order_ = Ord;
    TCriteria m_stop, m_current;
    Status m_status = Status::NotStarted;
    DebugLevel m_debug = DebugLevel::None;

public:
    virtual ~ISolver() = default;
    ISolver() {
        m_stop = TCriteria::defaults();
        m_current.reset();
    }

    ISolver(const TCriteria &s) {
        m_stop = s;
        m_current.reset();
    }

    void setStopCriteria(const TCriteria &s) { m_stop = s; }
    const TCriteria &criteria() { return m_current; }
    const Status &status() { return m_status; }
    void setDebug(const DebugLevel &d) { m_debug = d; }

    /**
     * @brief minimize an objective function given a gradient (and optinal a hessian)
     * @details this is just the abstract interface
     *
     * @param x0 starting point
     * @param funObjective objective function
     * @param funGradient gradient function
     * @param funcHession hessian function
     */
    virtual void minimize(ProblemType &objFunc, TVector &x0) = 0;

};

} /* namespace cppoptlib */

#endif /* ISOLVER_H_ */