NeuralEngine
A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes.
NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar > Class Template Referenceabstract

Base class for optimization methods. More...

#include <BaseOptimizationMethod.h>

Inheritance diagram for NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >:
Collaboration diagram for NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >:

Public Member Functions

virtual int GetNumberOfVariables ()
 Gets the number of variables (free parameters) in the optimization problem. More...
 
virtual af::array GetSolution ()
 Gets the current solution found, the values of the parameters which optimizes the function. More...
 
virtual void SetSolution (af::array &x)
 Sets the current solution found, the values of the parameters which optimizes the function. More...
 
virtual Scalar GetValue ()
 Gets the output of the function at the current Solution. More...
 
virtual bool Maximize (af::array &values, int *cycle=nullptr)
 Finds the maximum value of a function. The solution vector will be made available at the Solution property. More...
 
virtual bool Minimize (af::array &values, int *cycle=nullptr)
 Finds the minimum value of a function. The solution vector will be made available at the Solution property. More...
 
virtual bool Maximize (int *cycle=nullptr)
 Finds the maximum value of a function. The solution vector will be made available at the Solution property. More...
 
virtual bool Minimize (int *cycle=nullptr)
 Finds the minimum value of a function. The solution vector will be made available at the Solution property. More...
 
void Display (bool display)
 Set to display optimization information. More...
 
virtual int GetNumberOfVariables ()=0
 Gets the number of variables (free parameters) in the optimization problem. More...
 
virtual af::array GetSolution ()=0
 Gets the current solution found, the values of the parameters which optimizes the function. More...
 
virtual void SetSolution (af::array &x)=0
 Gets a solution. More...
 
virtual Scalar GetValue ()=0
 Gets the output of the function at the current Solution. More...
 
virtual bool Minimize (int *cycle=nullptr)=0
 Finds the minimum value of a function. The solution vector will be made available at the Solution property. More...
 
virtual bool Maximize (int *cycle=nullptr)=0
 Finds the maximum value of a function. The solution vector will be made available at the Solution property. More...
 

Protected Member Functions

void SetValue (Scalar v)
 Sets the output of the function at the current Solution. More...
 
void SetNumberOfVariables (int n)
 Sets the number of variables (free parameters) in the optimization problem. More...
 
 BaseOptimizationMethod (int numberOfVariables)
 Initializes a new instance of the BaseOptimizationMethod class. More...
 
 BaseOptimizationMethod (int numberOfVariables, std::function< Scalar(const af::array &, af::array &)> function)
 Initializes a new instance of the BaseOptimizationMethod class. More...
 
 BaseOptimizationMethod (NonlinearObjectiveFunction< Scalar > *function)
 Initializes a new instance of the BaseOptimizationMethod class. More...
 
virtual bool Optimize (int *cycle=nullptr)=0
 Implements the actual optimization algorithm. This method should try to minimize the objective function. More...
 

Protected Attributes

NonlinearObjectiveFunction< Scalar > * _function
 
af::array _x
 
bool _display
 
af::dtype m_dtype
 

Private Member Functions

void init (int numberOfVariables)
 

Private Attributes

Scalar _value
 
int _numVariables
 

Detailed Description

template<typename Scalar>
class NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >

Base class for optimization methods.

Admin, 3/21/2017.

Definition at line 30 of file BaseOptimizationMethod.h.

Constructor & Destructor Documentation

◆ BaseOptimizationMethod() [1/3]

template<typename Scalar >
NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::BaseOptimizationMethod ( int  numberOfVariables)
protected

Initializes a new instance of the BaseOptimizationMethod class.

Hmetal T, 17.03.2017.

Parameters
numberOfVariablesThe number of free parameters in the optimization problem.

◆ BaseOptimizationMethod() [2/3]

template<typename Scalar >
NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::BaseOptimizationMethod ( int  numberOfVariables,
std::function< Scalar(const af::array &, af::array &)>  function 
)
protected

Initializes a new instance of the BaseOptimizationMethod class.

Hmetal T, 17.03.2017.

Parameters
numberOfVariablesThe number of free parameters in the optimization problem.
functionThe objective function whose optimum values should be found.

◆ BaseOptimizationMethod() [3/3]

template<typename Scalar >
NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::BaseOptimizationMethod ( NonlinearObjectiveFunction< Scalar > *  function)
protected

Initializes a new instance of the BaseOptimizationMethod class.

Hmetal T, 17.03.2017.

Parameters
functionThe objective function whose optimum values should be found.

Member Function Documentation

◆ GetNumberOfVariables()

template<typename Scalar >
virtual int NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::GetNumberOfVariables ( )
virtual

Gets the number of variables (free parameters) in the optimization problem.

The number of parameters.

Implements NeuralEngine::MachineLearning::IOptimizationMethod< Scalar >.

◆ GetSolution()

template<typename Scalar >
virtual af::array NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::GetSolution ( )
virtual

Gets the current solution found, the values of the parameters which optimizes the function.

Hmetal T, 17.03.2017.

Returns
The solution.

Implements NeuralEngine::MachineLearning::IOptimizationMethod< Scalar >.

◆ SetSolution()

template<typename Scalar >
virtual void NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::SetSolution ( af::array &  x)
virtual

Sets the current solution found, the values of the parameters which optimizes the function.

Hmetal T, 17.03.2017.

Returns
The solution.

Implements NeuralEngine::MachineLearning::IOptimizationMethod< Scalar >.

◆ GetValue()

template<typename Scalar >
virtual Scalar NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::GetValue ( )
virtual

Gets the output of the function at the current Solution.

Hmetal T, 17.03.2017.

Returns
The value.

Implements NeuralEngine::MachineLearning::IOptimizationMethod< Scalar >.

◆ Maximize() [1/2]

template<typename Scalar >
virtual bool NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::Maximize ( af::array &  values,
int cycle = nullptr 
)
virtual

Finds the maximum value of a function. The solution vector will be made available at the Solution property.

Hmetal T, 17.03.2017.

Parameters
valuesThe initial solution vector to start the search.
Returns
Returns true if the method converged to a Solution. In this case, the found value will also be available at the Value property.

◆ Minimize() [1/2]

template<typename Scalar >
virtual bool NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::Minimize ( af::array &  values,
int cycle = nullptr 
)
virtual

Finds the minimum value of a function. The solution vector will be made available at the Solution property.

Hmetal T, 17.03.2017.

Parameters
valuesThe initial solution vector to start the search.
Returns
Returns true if the method converged to a Solution. In this case, the found value will also be available at the Value property.

◆ Maximize() [2/2]

template<typename Scalar >
virtual bool NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::Maximize ( int cycle = nullptr)
virtual

Finds the maximum value of a function. The solution vector will be made available at the Solution property.

Hmetal T, 17.03.2017.

Returns
Returns true if the method converged to a Solution. In this case, the found value will also be available at the Value property.

Implements NeuralEngine::MachineLearning::IOptimizationMethod< Scalar >.

◆ Minimize() [2/2]

template<typename Scalar >
virtual bool NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::Minimize ( int cycle = nullptr)
virtual

Finds the minimum value of a function. The solution vector will be made available at the Solution property.

Hmetal T, 17.03.2017.

Returns
Returns true if the method converged to a Solution. In this case, the found value will also be available at the Value property.

Implements NeuralEngine::MachineLearning::IOptimizationMethod< Scalar >.

◆ Display()

template<typename Scalar >
void NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::Display ( bool  display)

Set to display optimization information.

Hmetal T, 03.05.2019.

Parameters
displaytrue to display.

◆ SetValue()

template<typename Scalar >
void NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::SetValue ( Scalar  v)
protected

Sets the output of the function at the current Solution.

Hmetal T, 17.03.2017.

Returns
The value.

◆ SetNumberOfVariables()

template<typename Scalar >
void NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::SetNumberOfVariables ( int  n)
protected

Sets the number of variables (free parameters) in the optimization problem.

The number of parameters.

◆ Optimize()

template<typename Scalar >
virtual bool NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::Optimize ( int cycle = nullptr)
protectedpure virtual

Member Data Documentation

◆ _function

◆ _x

template<typename Scalar >
af::array NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::_x
protected

Definition at line 233 of file BaseOptimizationMethod.h.

◆ _display

template<typename Scalar >
bool NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::_display
protected

Definition at line 235 of file BaseOptimizationMethod.h.

◆ m_dtype

template<typename Scalar >
af::dtype NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::m_dtype
protected

Definition at line 237 of file BaseOptimizationMethod.h.

◆ _value

Definition at line 243 of file BaseOptimizationMethod.h.

◆ _numVariables

template<typename Scalar >
int NeuralEngine::MachineLearning::BaseOptimizationMethod< Scalar >::_numVariables
private

Definition at line 244 of file BaseOptimizationMethod.h.


The documentation for this class was generated from the following file: