NeuralEngine
A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes.
FgLBFGSsolver.h
1
11#pragma once
12
13#include <MachineLearning/BaseGradientOptimizationMethod.h>
14
15namespace NeuralEngine
16{
17 namespace MachineLearning
18 {
75 template<typename Scalar, LineSearchType LSType = MoreThuente>
76 class NE_IMPEXP LBFGSSolver : public BaseGradientOptimizationMethod<Scalar, LSType>
77 {
78 public:
79
89 LBFGSSolver(int numberOfVariables);
90
102 LBFGSSolver(int numberOfVariables,
103 std::function<Scalar(const af::array&, af::array&)> function);
104
113
114 ~LBFGSSolver();
115
132 void SetNumCorrections(int corrections);
133
149 void SetDelta(Scalar inDelta);
150
163 void SetMaxLinesearch(int maxIter);
164
165 protected:
166
177 virtual bool Optimize(int* cycle = nullptr) override;
178
191 //void LineSearchBacktracking(Scalar& fx, af::array& x, af::array& grad, Scalar& step, const af::array& drt, const af::array& xp);
192
211 //void LineSearchBracketing(Scalar& fx, af::array& x, af::array& grad, Scalar& step, const af::array& drt, const af::array& xp);
212
213 private:
214 int m; // The number of corrections to approximate the inverse Hessian matrix.
215 int past; // Distance for delta-based convergence test.
216 Scalar delta; // Delta for convergence test.
217 int max_linesearch; // The maximum number of trials for the line search.
218 Scalar min_step; // The minimum step length allowed in the line search.
219 Scalar max_step; // The maximum step length allowed in the line search.
220 Scalar ftol; // A parameter to control the accuracy of the line search routine.
221 Scalar wolfe; // Wolfe condition
222 };
223 }
224}
Limited-memory BFGS (L-BFGS or LM-BFGS).
Definition: FgLBFGSsolver.h:77
LBFGSSolver(int numberOfVariables, std::function< Scalar(const af::array &, af::array &)> function)
Creates a new instance of the L-BFGS optimization algorithm.
virtual bool Optimize(int *cycle=nullptr) override
Implements the actual optimization algorithm. This method should try to minimize the objective functi...
LBFGSSolver(int numberOfVariables)
Creates a new instance of the L-BFGS optimization algorithm.
void SetMaxLinesearch(int maxIter)
Sets the maximum number of trials for the line search.
LBFGSSolver(NonlinearObjectiveFunction< Scalar > *function)
Creates a new instance of the L-BFGS optimization algorithm.
void SetDelta(Scalar inDelta)
Sets Delta for convergence test.
void SetNumCorrections(int corrections)
Sets number of corrections.