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

NonlinearObjectiveFunction.h
1
11#pragma once
12
13#include <MachineLearning/IObjectiveFunction.h>
14
15 namespace NeuralEngine
16{
17 namespace MachineLearning
18 {
19 template<typename Scalar>
20 class NE_IMPEXP NonlinearObjectiveFunction : virtual public IObjectiveFunction<Scalar>
21 {
22 public:
23
31 NonlinearObjectiveFunction(int numberOfVariables);
32
43 NonlinearObjectiveFunction(int numberOfVariables, std::function<Scalar(const af::array&, af::array&)> function);
44
59 //NonlinearObjectiveFunction(int numberOfVariables,
60 // std::function<Scalar(const af::array&)> function, std::function<af::array(const af::array&)> gradient);
61
67 ~NonlinearObjectiveFunction();
68
76 std::function<Scalar(const af::array&, af::array&)> GetFunction();
77
85 void SetFunction(std::function<Scalar(const af::array&, af::array&)> func);
86
96 Scalar Value(const af::array& x);
97
107 af::array Gradient(const af::array& x);
108
116 int GetNumberOfVariables();
117
125 void CheckGradient(const af::array& probe);
126
137 af::array FiniteGradient(const af::array& x, int accuracy = 0);
138
146 af::array& LowerBound();
147
155 af::array& UpperBound();
156
157 protected:
158
166 NonlinearObjectiveFunction();
167
168 int _numVariables;
169 std::function<Scalar(const af::array&, af::array&)> _function;
170 //std::function<af::array(const af::array&)> _gradient;
171 af::array _gradient;
172
173 af::array afLowerBound;
174 af::array afUpperBound;
175
176 private:
177 af::dtype _dtype;
178 };
179 }
180}
NeuralEngine::MachineLearning::IObjectiveFunction
Definition: IObjectiveFunction.h:26
NeuralEngine::MachineLearning::NonlinearObjectiveFunction
Definition: NonlinearObjectiveFunction.h:21
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::FiniteGradient
af::array FiniteGradient(const af::array &x, int accuracy=0)
Finite gradient computation.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::GetFunction
std::function< Scalar(const af::array &, af::array &)> GetFunction()
Gets the objective function.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::SetFunction
void SetFunction(std::function< Scalar(const af::array &, af::array &)> func)
Gets the objective function.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::Value
Scalar Value(const af::array &x)
Computes function value of given x.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::NonlinearObjectiveFunction
NonlinearObjectiveFunction()
Initializes a new instance of the NonlinearObjectiveFunction class.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::CheckGradient
void CheckGradient(const af::array &probe)
Checks the gradient.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::GetNumberOfVariables
int GetNumberOfVariables()
Gets the number of input variables for the function.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::LowerBound
af::array & LowerBound()
Lower bound.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::UpperBound
af::array & UpperBound()
Upper bound.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::~NonlinearObjectiveFunction
~NonlinearObjectiveFunction()
Destructor.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::Gradient
af::array Gradient(const af::array &x)
Gradient of given x.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::NonlinearObjectiveFunction
NonlinearObjectiveFunction(int numberOfVariables)
Constructor.
NeuralEngine::MachineLearning::NonlinearObjectiveFunction::NonlinearObjectiveFunction
NonlinearObjectiveFunction(int numberOfVariables, std::function< Scalar(const af::array &, af::array &)> function)
Creates a new objective function specified through a string.
Scalar
NeuralEngine
Definition: NeArray2.h:18