MeLOn
Loading...
Searching...
No Matches
melon::GaussianProcess< T > Class Template Reference

This class represents a Gaussian process, to be used in the MAiNGO solver. More...

#include <gp.h>

Inheritance diagram for melon::GaussianProcess< T >:
melon::MelonModel< T >

Public Member Functions

 GaussianProcess ()
 Default Constructor.
 
 GaussianProcess (std::string modelName)
 Constructor.
 
 GaussianProcess (std::string modelPath, std::string modelName)
 Constructor.
 
 GaussianProcess (std::shared_ptr< const GPData > modelData)
 Constructor.
 
calculate_prediction_reduced_space (std::vector< T > input) const
 Calculates the prediction of the Gaussian process at a given point in reduced space mode (only network inputs are given)
 
calculate_variance_reduced_space (std::vector< T > input) const
 Calculates the variance of the Gaussian process at a given point in reduced space mode (only network inputs are given)
 
calculate_prediction_full_space (std::vector< T > input, std::vector< T > internalVariables, std::vector< T > &constraints) const
 Calculates the prediction of the Gaussian process at a given point in full space mode (values for all internal variables are given and a set of constraints is returned)
 
calculate_variance_full_space (std::vector< T > input, std::vector< T > internalVariables, std::vector< T > &constraints) const
 Calculates the variance of the Gaussian process at a given point in full space mode (values for all internal variables are given and a set of constraints is returned)
 
std::pair< T, T > calculate_prediction_and_variance_full_space (std::vector< T > input, std::vector< T > internalVariables, std::vector< T > &constraints) const
 Calculates the prediction and the variance of the Gaussian process at a given point in full space mode (values for all internal variables are given and a set of constraints is returned)
 
int get_input_dimension () const
 Get the dimesnion of the input.
 
int get_number_of_training_data_points () const
 Get the number of training data points.
 
double get_minimum_of_training_data_outputs () const
 Get the minimum value of the training data outputs.
 
double get_maximum_of_training_data_outputs () const
 Get the maximum value of the training data outputs.
 
unsigned int get_number_of_full_space_variables_prediction () const
 Get the number of internal variables used in the calculation of the prediction.
 
void get_full_space_variables_prediction (unsigned int &variableNumber, std::vector< std::string > &variableNames, std::vector< std::pair< double, double > > &variableBounds) const
 Get the properties of internal variables used in the calculation of the prediction.
 
unsigned int get_number_of_full_space_variables_variance () const
 Get the number of internal variables used in the calculation of the variance.
 
void get_full_space_variables_variance (unsigned int &variableNumber, std::vector< std::string > &variableNames, std::vector< std::pair< double, double > > &variableBounds) const
 Get the properties of internal variables used in the calculation of the variance.
 
unsigned int get_number_of_full_space_variables_prediction_and_variance () const
 Get the number of internal variables used in the calculation of prediction and variance.
 
void get_full_space_variables_prediction_and_variance (unsigned int &variableNumber, std::vector< std::string > &variableNames, std::vector< std::pair< double, double > > &variableBounds) const
 Get the properties of internal variables used in the calculation of prediction and variance.
 
std::vector< double > get_observations () const
 Get the observations based on which the Gaussian process was trained and is evaluated.
 
std::vector< double > get_normalized_observations () const
 Returns the the normalized values of the observations based on which the Gaussian process was trained and is evaluated.
 
const GPDatadata () const
 Getter for member variable _data.
 
const kernel::StationaryKernel< double, T > & kernel () const
 Getter for member variable _kernel.
 
const Scaler< T > & inputScaler () const
 Getter for member variable _inputScaler.
 
const Scaler< T > & predictionScaler () const
 Getter for member variable _predictionScaler.
 
const Scaler< T > & parameterScaler () const
 Getter for member variable _parameterScaler.
 
- Public Member Functions inherited from melon::MelonModel< T >
virtual ~MelonModel ()=default
 Default destructor.
 
void load_model (std::string modelName, MODEL_FILE_TYPE fileType)
 Loads new model from file.
 
void load_model (std::string modelPath, std::string modelName, MODEL_FILE_TYPE fileType)
 Loads new model from file.
 
void load_model (std::shared_ptr< const ModelData > modelData)
 Loads new model from file.
 

Private Member Functions

void _set_data_object (std::shared_ptr< const ModelData > modelData) override
 Sets data object containing model parameters.
 
void _set_kernel (std::shared_ptr< const GPData > data)
 Function for setting the kernel of the Gaussian process.
 
template<typename RandomAccessIterator >
std::vector< T > _calculate_covariance_vector (std::vector< T > input, RandomAccessIterator &internalVariables, const bool fullSpace, std::vector< T > &constraints) const
 Calculates the covariance vector of the Gaussian process for a given point.
 
template<typename RandomAccessIterator >
_calculate_prediction (std::vector< T > covarianceVector, RandomAccessIterator &internalVariables, const bool fullSpace, std::vector< T > &constraints) const
 Calculates the prediction of the Gaussian process for a given point.
 
template<typename RandomAccessIterator >
_calculate_variance (std::vector< T > covarianceVector, RandomAccessIterator &internalVariables, const bool fullSpace, std::vector< T > &constraints) const
 Calculates the variance of the Gaussian process for a given point.
 

Private Attributes

std::shared_ptr< const GPData_data
 
std::unique_ptr< kernel::StationaryKernel< double, T > > _kernel
 
std::unique_ptr< Scaler< T > > _inputScaler
 
std::unique_ptr< Scaler< T > > _predictionScaler
 
std::unique_ptr< Scaler< double > > _parameterScaler
 

Additional Inherited Members

- Protected Member Functions inherited from melon::MelonModel< T >
 MelonModel (std::shared_ptr< ModelParserFactory > parserFactory)
 Constructor.
 
template<typename RandomAccessIterator >
void _set_constraints (std::vector< T > &constraints, std::vector< T > &constraintEvaluation, RandomAccessIterator &constraintValue) const
 Sets constraints required for fullspace opimization.
 
template<typename RandomAccessIterator >
void _set_constraints (std::vector< T > &constraints, T &constraintEvaluation, RandomAccessIterator &constraintValue) const
 Sets constraints required for fullspace opimization.
 
- Protected Attributes inherited from melon::MelonModel< T >
bool _modelLoaded { false }
 
std::shared_ptr< ModelParserFactory_parserFactory
 

Detailed Description

template<typename T>
class melon::GaussianProcess< T >

This class represents a Gaussian process, to be used in the MAiNGO solver.

This class is used to enable the solution of optimization problems in MAiNGO containing Gaussian processes. The trained GPs can be loaded from json files created in matlab.

Constructor & Destructor Documentation

◆ GaussianProcess() [1/4]

template<typename T >
melon::GaussianProcess< T >::GaussianProcess ( )
inline

Default Constructor.

◆ GaussianProcess() [2/4]

template<typename T >
melon::GaussianProcess< T >::GaussianProcess ( std::string modelName)
inline

Constructor.

Parameters
[in]modelNameis the name of the Gaussian process

◆ GaussianProcess() [3/4]

template<typename T >
melon::GaussianProcess< T >::GaussianProcess ( std::string modelPath,
std::string modelName )
inline

Constructor.

Parameters
[in]modelPathis the path to the directory in which the Gaussian process file is located
[in]modelNameis the name of the Gaussian process

◆ GaussianProcess() [4/4]

template<typename T >
melon::GaussianProcess< T >::GaussianProcess ( std::shared_ptr< const GPData > modelData)
inline

Constructor.

Parameters
[in]modelDatais a GPData object containing the data which defines the Gaussian process

Member Function Documentation

◆ _calculate_covariance_vector()

template<typename T >
template<typename RandomAccessIterator >
std::vector< T > melon::GaussianProcess< T >::_calculate_covariance_vector ( std::vector< T > input,
RandomAccessIterator & internalVariables,
const bool fullSpace,
std::vector< T > & constraints ) const
private

Calculates the covariance vector of the Gaussian process for a given point.

Parameters
[in]inputis a vector containing input point for which the covariance vector is calculated
[in]internalVariablesis a iterator pointing to the beginning of the internal variables used in calculation of the covariance vector
[in]fullSpaceindicates wether the Gaussian process should be evaluated in fullspace mode (all internal variables are pre-set and given in variables and a vector of constraints is returned)
[out]constraintsis a vector of constraints which are the difference of the given (in the vector variables) and calulated internal Gaussian process variables.
Returns
returns the covariance vector

◆ _calculate_prediction()

template<typename T >
template<typename RandomAccessIterator >
T melon::GaussianProcess< T >::_calculate_prediction ( std::vector< T > covarianceVector,
RandomAccessIterator & internalVariables,
const bool fullSpace,
std::vector< T > & constraints ) const
private

Calculates the prediction of the Gaussian process for a given point.

Parameters
[in]covarianceVectoris a vector based on which the prediction is calculated
[in]internalVariablesis a iterator pointing to the beginning of the internal variables used in calculation of the prediction
[in]fullSpaceindicates wether the Gaussian process should be evaluated in fullspace mode (all internal variables are pre-set and given in variables and a vector of constraints is returned)
[out]constraintsis a vector of constraints which are the difference of the given (in the vector variables) and calulated internal Gaussian process variables.
Returns
returns the prediction

◆ _calculate_variance()

template<typename T >
template<typename RandomAccessIterator >
T melon::GaussianProcess< T >::_calculate_variance ( std::vector< T > covarianceVector,
RandomAccessIterator & internalVariables,
const bool fullSpace,
std::vector< T > & constraints ) const
private

Calculates the variance of the Gaussian process for a given point.

Parameters
[in]covarianceVectoris a vector based on which the variance is calculated
[in]internalVariablesis a iterator pointing to the beginning of the internal variables used in calculation of the variance
[in]fullSpaceindicates wether the Gaussian process should be evaluated in fullspace mode (all internal variables are pre-set and given in variables and a vector of constraints is returned)
[out]constraintsis a vector of constraints which are the difference of the given (in the vector variables) and calulated internal Gaussian process variables.
Returns
returns the variance

◆ _set_data_object()

template<typename T >
void melon::GaussianProcess< T >::_set_data_object ( std::shared_ptr< const ModelData > modelData)
overrideprivatevirtual

Sets data object containing model parameters.

Parameters
[in]modelDatais a ModelData object containing the data which defines the model

Implements melon::MelonModel< T >.

◆ _set_kernel()

template<typename T >
void melon::GaussianProcess< T >::_set_kernel ( std::shared_ptr< const GPData > data)
private

Function for setting the kernel of the Gaussian process.

Parameters
[in]datais a pointer to a GPData object containing information about the kernel that should be set

◆ calculate_prediction_and_variance_full_space()

template<typename T >
std::pair< T, T > melon::GaussianProcess< T >::calculate_prediction_and_variance_full_space ( std::vector< T > input,
std::vector< T > internalVariables,
std::vector< T > & constraints ) const

Calculates the prediction and the variance of the Gaussian process at a given point in full space mode (values for all internal variables are given and a set of constraints is returned)

Parameters
[in]inputis a vector containing input point for which prediction and variance of the Gaussian process are calculated
[in]internalVariablesis a vector containing values for the internal variables of the Gaussian process predcition and variance calculation
[out]constraintsis vector containing the evaluation of the fullspace constraints regarding the internal variables
Returns
returns a pair contianing the prediction and variance value

◆ calculate_prediction_full_space()

template<typename T >
T melon::GaussianProcess< T >::calculate_prediction_full_space ( std::vector< T > input,
std::vector< T > internalVariables,
std::vector< T > & constraints ) const

Calculates the prediction of the Gaussian process at a given point in full space mode (values for all internal variables are given and a set of constraints is returned)

Parameters
[in]inputis a vector containing input point for which the prediction of the Gaussian process is calculated
[in]internalVariablesis a vector containing values for the internal variables of the Gaussian process prediction calculation
[out]constraintsis vector containing the evaluation of the fullspace constraints regarding the internal variables
Returns
returns the prediction of the gaussian process

◆ calculate_prediction_reduced_space()

template<typename T >
T melon::GaussianProcess< T >::calculate_prediction_reduced_space ( std::vector< T > input) const

Calculates the prediction of the Gaussian process at a given point in reduced space mode (only network inputs are given)

Parameters
[in]inputis a vector containing input point for which the prediction of the Gaussian process is calculated
Returns
returns the prediction of the gaussian process

◆ calculate_variance_full_space()

template<typename T >
T melon::GaussianProcess< T >::calculate_variance_full_space ( std::vector< T > input,
std::vector< T > internalVariables,
std::vector< T > & constraints ) const

Calculates the variance of the Gaussian process at a given point in full space mode (values for all internal variables are given and a set of constraints is returned)

Parameters
[in]inputis a vector containing input point for which the variance of the Gaussian process is calculated
[in]internalVariablesis a vector containing values for the internal variables of the Gaussian process variance calculation
[out]constraintsis vector containing the evaluation of the fullspace constraints regarding the internal variables
Returns
returns the variance of the gaussian process

◆ calculate_variance_reduced_space()

template<typename T >
T melon::GaussianProcess< T >::calculate_variance_reduced_space ( std::vector< T > input) const

Calculates the variance of the Gaussian process at a given point in reduced space mode (only network inputs are given)

Parameters
[in]inputis a vector containing input point for which the variance of the Gaussian process is calculated
Returns
returns the variance of the gaussian process

◆ data()

template<typename T >
const GPData & melon::GaussianProcess< T >::data ( ) const
inline

Getter for member variable _data.

◆ get_full_space_variables_prediction()

template<typename T >
void melon::GaussianProcess< T >::get_full_space_variables_prediction ( unsigned int & variableNumber,
std::vector< std::string > & variableNames,
std::vector< std::pair< double, double > > & variableBounds ) const

Get the properties of internal variables used in the calculation of the prediction.

Parameters
[out]variableNumberis the number of internal variables
[out]variableNamesis a vector containing the names of the internal variables
[out]variableBoundsis a vector of pairs containing the bounds of the internal variables
Returns
returns number of internal variables

◆ get_full_space_variables_prediction_and_variance()

template<typename T >
void melon::GaussianProcess< T >::get_full_space_variables_prediction_and_variance ( unsigned int & variableNumber,
std::vector< std::string > & variableNames,
std::vector< std::pair< double, double > > & variableBounds ) const

Get the properties of internal variables used in the calculation of prediction and variance.

Parameters
[out]variableNumberis the number of internal variables
[out]variableNamesis a vector containing the names of the internal variables
[out]variableBoundsis a vector of pairs containing the bounds of the internal variables
Returns
returns number of internal variables

◆ get_full_space_variables_variance()

template<typename T >
void melon::GaussianProcess< T >::get_full_space_variables_variance ( unsigned int & variableNumber,
std::vector< std::string > & variableNames,
std::vector< std::pair< double, double > > & variableBounds ) const

Get the properties of internal variables used in the calculation of the variance.

Parameters
[out]variableNumberis the number of internal variables
[out]variableNamesis a vector containing the names of the internal variables
[out]variableBoundsis a vector of pairs containing the bounds of the internal variables
Returns
returns number of internal variables

◆ get_input_dimension()

template<typename T >
int melon::GaussianProcess< T >::get_input_dimension ( ) const

Get the dimesnion of the input.

Returns
returns input dimension

◆ get_maximum_of_training_data_outputs()

template<typename T >
double melon::GaussianProcess< T >::get_maximum_of_training_data_outputs ( ) const

Get the maximum value of the training data outputs.

Returns
returns the maximum value of the training data outputs

◆ get_minimum_of_training_data_outputs()

template<typename T >
double melon::GaussianProcess< T >::get_minimum_of_training_data_outputs ( ) const

Get the minimum value of the training data outputs.

Returns
returns the minimum value of the training data outputs

◆ get_normalized_observations()

template<typename T >
std::vector< double > melon::GaussianProcess< T >::get_normalized_observations ( ) const
inline

Returns the the normalized values of the observations based on which the Gaussian process was trained and is evaluated.

Returns
returns the normalized Gaussian process' training observations

◆ get_number_of_full_space_variables_prediction()

template<typename T >
unsigned int melon::GaussianProcess< T >::get_number_of_full_space_variables_prediction ( ) const

Get the number of internal variables used in the calculation of the prediction.

Returns
returns number of internal variables

◆ get_number_of_full_space_variables_prediction_and_variance()

template<typename T >
unsigned int melon::GaussianProcess< T >::get_number_of_full_space_variables_prediction_and_variance ( ) const

Get the number of internal variables used in the calculation of prediction and variance.

Returns
returns number of internal variables

◆ get_number_of_full_space_variables_variance()

template<typename T >
unsigned int melon::GaussianProcess< T >::get_number_of_full_space_variables_variance ( ) const

Get the number of internal variables used in the calculation of the variance.

Returns
returns number of internal variables

◆ get_number_of_training_data_points()

template<typename T >
int melon::GaussianProcess< T >::get_number_of_training_data_points ( ) const

Get the number of training data points.

Returns
returns number of training data points

◆ get_observations()

template<typename T >
std::vector< double > melon::GaussianProcess< T >::get_observations ( ) const

Get the observations based on which the Gaussian process was trained and is evaluated.

Returns
returns the Gaussian process' training observations

◆ inputScaler()

template<typename T >
const Scaler< T > & melon::GaussianProcess< T >::inputScaler ( ) const
inline

Getter for member variable _inputScaler.

◆ kernel()

template<typename T >
const kernel::StationaryKernel< double, T > & melon::GaussianProcess< T >::kernel ( ) const
inline

Getter for member variable _kernel.

◆ parameterScaler()

template<typename T >
const Scaler< T > & melon::GaussianProcess< T >::parameterScaler ( ) const
inline

Getter for member variable _parameterScaler.

◆ predictionScaler()

template<typename T >
const Scaler< T > & melon::GaussianProcess< T >::predictionScaler ( ) const
inline

Getter for member variable _predictionScaler.

Member Data Documentation

◆ _data

template<typename T >
std::shared_ptr<const GPData> melon::GaussianProcess< T >::_data
private

object containing the data and parameters of the Gaussian process

◆ _inputScaler

template<typename T >
std::unique_ptr<Scaler<T> > melon::GaussianProcess< T >::_inputScaler
private

Object for scaling input data

◆ _kernel

template<typename T >
std::unique_ptr<kernel::StationaryKernel<double, T> > melon::GaussianProcess< T >::_kernel
private

kernel object

◆ _parameterScaler

template<typename T >
std::unique_ptr<Scaler<double> > melon::GaussianProcess< T >::_parameterScaler
private

Object for scaling double parameters

◆ _predictionScaler

template<typename T >
std::unique_ptr<Scaler<T> > melon::GaussianProcess< T >::_predictionScaler
private

Object for scaling output data


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