cratepy.optimization.optimizationfunction.OptimizationFunction

class OptimizationFunction(lower_bounds, upper_bounds, init_shot=None, weights=None)[source]

Bases: ABC

Optimization function interface.

opt_function(self, parameters)[source]

abstract: Optimization function.

get_parameters_names(self)[source]

Get optimization parameters names.

get_bounds(self, is_normalized=False)[source]

Get optimization parameters lower and upper bounds.

get_init_shot(self, is_normalized=False)[source]

Get optimization parameters initial guess.

set_norm_bounds(self, norm_min=-1.0, norm_max=1.0)[source]

Set optimization parameters normalization bounds.

get_norm_bounds(self)[source]

Get optimization parameters normalization bounds.

normalize(self, parameters)[source]

Normalize optimization parameters between min and max values.

denormalize(self, norm_parameters)[source]

Recover optimization parameters from normalized values.

norm_opt_function(self, norm_parameters)[source]

Wrapper of optimization function with normalized parameters.

opt_function_seq(self, parameters_seq)[source]

Wrapper of optimization function with sequential parameters.

norm_opt_function_seq(self, parameters_seq)[source]

Wrapper of optimization function with norm. sequential parameters.

Constructor.

Parameters:
  • lower_bounds (dict) – Optimization parameters (key, str) lower bounds (item, float).

  • upper_bounds (dict) – Optimization parameters (key, str) upper bounds (item, float).

  • init_shot (dict, default=None) – Optimization parameters (key, str) initial guess (item, float).

  • weights (tuple, default=None) – Weights attributed to each data point.

List of Public Methods

denormalize

Recover optimization parameters from normalized values.

get_bounds

Get optimization parameters lower and upper bounds.

get_init_shot

Get optimization parameters initial guess.

get_norm_bounds

Get optimization parameters normalization bounds.

get_parameters_names

Get optimization parameters names.

norm_opt_function

Wrapper of optimization function with normalized parameters.

norm_opt_function_seq

Wrapper of optimization function with norm.

normalize

Normalize optimization parameters between min and max values.

opt_function

Optimization function.

opt_function_seq

Wrapper of optimization function with sequential parameters.

set_norm_bounds

Set optimization parameters normalization bounds.

Methods

abstract __init__(lower_bounds, upper_bounds, init_shot=None, weights=None)[source]

Constructor.

Parameters:
  • lower_bounds (dict) – Optimization parameters (key, str) lower bounds (item, float).

  • upper_bounds (dict) – Optimization parameters (key, str) upper bounds (item, float).

  • init_shot (dict, default=None) – Optimization parameters (key, str) initial guess (item, float).

  • weights (tuple, default=None) – Weights attributed to each data point.

denormalize(norm_parameters)[source]

Recover optimization parameters from normalized values.

Parameters:

norm_parameters (dict) – Normalized optimization parameters names (key, str) and values (item, float).

Returns:

parameters – Optimization parameters names (key, str) and values (item, float).

Return type:

dict

get_bounds(is_normalized=False)[source]

Get optimization parameters lower and upper bounds.

Parameters:

is_normalized (bool, default=False) – Whether optimization parameters are normalized or not.

Returns:

  • lower_bounds (dict) – Optimization parameters (key, str) lower bounds (item, float).

  • upper_bounds (dict) – Optimization parameters (key, str) upper bounds (item, float).

get_init_shot(is_normalized=False)[source]

Get optimization parameters initial guess.

Parameters:

is_normalized (bool, default=False) – Whether optimization parameters are normalized or not.

Returns:

init_shot – Optimization parameters (key, str) initial guess (item, float).

Return type:

dict

get_norm_bounds()[source]

Get optimization parameters normalization bounds.

Returns:

norm_bounds – Normalization bounds (lower, upper) used to perform the normalization of the optimization parameters.

Return type:

tuple

get_parameters_names()[source]

Get optimization parameters names.

Returns:

parameters_names – Optimization parameters names (str).

Return type:

tuple[str]

norm_opt_function(norm_parameters)[source]

Wrapper of optimization function with normalized parameters.

Parameters:

norm_parameters (dict) – Normalized optimization parameters names (key, str) and values (item, float).

Returns:

value – Optimization function value.

Return type:

float

norm_opt_function_seq(parameters_seq)[source]

Wrapper of optimization function with norm. sequential parameters.

Parameters:

parameters_seq (tuple[float]) – Optimization parameters values.

Returns:

value – Optimization function value.

Return type:

float

normalize(parameters)[source]

Normalize optimization parameters between min and max values.

Parameters:
  • parameters (dict) – Optimization parameters names (key, str) and values (item, float).

  • norm_min (float, default=-1.0) – Normalized optimization parameter lower bound.

  • norm_max (float, default=1.0) – Normalized optimization parameter upper bound.

Returns:

norm_parameters – Normalized optimization parameters names (key, str) and values (item, float).

Return type:

dict

abstract opt_function(parameters)[source]

Optimization function.

Parameters:

parameters (dict) – Optimization parameters names (key, str) and values (item, float).

Returns:

value – Optimization function value.

Return type:

float

opt_function_seq(parameters_seq)[source]

Wrapper of optimization function with sequential parameters.

Parameters:

parameters_seq (tuple[float]) – Optimization parameters values.

Returns:

value – Optimization function value.

Return type:

float

set_norm_bounds(norm_min=-1.0, norm_max=1.0)[source]

Set optimization parameters normalization bounds.

Parameters:
  • norm_min (float, default=-1.0) – Normalized optimization parameter lower bound.

  • norm_max (float, default=1.0) – Normalized optimization parameter upper bound.