NeuralEngine A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes. |

FgLBFGSBsolver.h
1
11#pragma once
12
13#include <MachineLearning/BaseGradientOptimizationMethod.h>
14
15 namespace NeuralEngine
16{
17 namespace MachineLearning
18 {
75 template<typename Scalar, LineSearchType LSType = MoreThuente>
76 class NE_IMPEXP LBFGSBSolver : public BaseGradientOptimizationMethod<Scalar, LSType>
77 {
78 public:
88 LBFGSBSolver(int numberOfVariables);
89
101 LBFGSBSolver(int numberOfVariables,
102 std::function<Scalar(const af::array&, af::array&)> function);
103
111 LBFGSBSolver(NonlinearObjectiveFunction<Scalar>* function);
112
113 void SetHistorySize(const int hs);
114
115 ~LBFGSBSolver();
116
117 protected:
118
129 virtual bool Optimize(int* cycle = nullptr) override;
130
140 std::vector<int> SortIndexes(const std::vector<std::pair<int, Scalar>>& v);
141
153 void GetGeneralizedCauchyPoint(const af::array& x, const af::array& g, af::array& x_cauchy, af::array& c);
154
167 Scalar FindAlpha(af::array& x_cp, af::array& du, std::vector<int>& FreeVariables);
168
181 void SubspaceMinimization(af::array& x_cauchy, af::array& x, af::array& c, af::array& g, af::array& SubspaceMin);
182
193 Scalar GetOptimality(const af::array& x, const af::array& g);
194
195 private:
196 af::array W, M;
197 Scalar theta;
198 int m_historySize;
199 };
200 }
201}
NeuralEngine::MachineLearning::BaseGradientOptimizationMethod
Base class for gradient-based optimization methods.
Definition: BaseGradientOptimizationMethod.h:40
NeuralEngine::MachineLearning::LBFGSBSolver
Limited-memory BFGS (L-BFGS or LM-BFGS).
Definition: FgLBFGSBsolver.h:77
NeuralEngine::MachineLearning::LBFGSBSolver::GetOptimality
Scalar GetOptimality(const af::array &x, const af::array &g)
Gets an optimality.
NeuralEngine::MachineLearning::LBFGSBSolver::LBFGSBSolver
LBFGSBSolver(int numberOfVariables)
Creates a new instance of the L-BFGS optimization algorithm.
NeuralEngine::MachineLearning::LBFGSBSolver::Optimize
virtual bool Optimize(int *cycle=nullptr) override
Implements the actual optimization algorithm. This method should try to minimize the objective functi...
NeuralEngine::MachineLearning::LBFGSBSolver::GetGeneralizedCauchyPoint
void GetGeneralizedCauchyPoint(const af::array &x, const af::array &g, af::array &x_cauchy, af::array &c)
Computation of the generalized Cauchy point.
NeuralEngine::MachineLearning::LBFGSBSolver::SortIndexes
std::vector< int > SortIndexes(const std::vector< std::pair< int, Scalar > > &v)
Sorts pairs (k,v) according v ascending.
NeuralEngine::MachineLearning::LBFGSBSolver::FindAlpha
Scalar FindAlpha(af::array &x_cp, af::array &du, std::vector< int > &FreeVariables)
Finds alpha* = max{a : a <= 1 and l_i-xc_i <= a*d_i <= u_i-xc_i}.
NeuralEngine::MachineLearning::LBFGSBSolver::LBFGSBSolver
LBFGSBSolver(int numberOfVariables, std::function< Scalar(const af::array &, af::array &)> function)
Creates a new instance of the L-BFGS optimization algorithm.
NeuralEngine::MachineLearning::LBFGSBSolver::LBFGSBSolver
LBFGSBSolver(NonlinearObjectiveFunction< Scalar > *function)
Creates a new instance of the L-BFGS optimization algorithm.
NeuralEngine::MachineLearning::LBFGSBSolver::SubspaceMinimization
void SubspaceMinimization(af::array &x_cauchy, af::array &x, af::array &c, af::array &g, af::array &SubspaceMin)
Solving unbounded probelm.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction
Definition: NonlinearObjectiveFunction.h:21
Scalar
NeuralEngine
Definition: NeArray2.h:18