fitter

Abstraction usefull for the calibration of the closures.

This module contains the classes FittableParameter and FittableParametersSet which are used to make a link between the optimization part and the closures structures. These class can be obtained by the prefix tunax.fitter. or directly by tunax..

class FittableParameter[source]

Calibration configuration for one parameter.

An instance of this class must be created for every parameter of the closure that will be calibrated and for every not default values during calibration. The constructor takes all the attributes as parameters.

do_fit

The parameter will be calibrated.

Type:

bool

val

If do_fit : the initial value for calibration (at the first step of the calibration) ; if do_fit is false : the constant value to take for this parameter if it’s not the default one in the closure.

Type:

float, default=0.

class FittableParametersSet[source]

Complete closure calibration parameters.

This class is the set of all the configurations on the closure parameters for the calibration. It makes the link between the array on which the optimizer works and the closure parameters class.

Parameters:
  • coef_fit_dict (Dict[str, FittableParameter]) – cf. coef_fit_dict.

  • closure_name (str) – Name of the chosen closure, must be a key of CLOSURES_REGISTRY, see its documentation for the available closures.

coef_fit_dico

The set of all the configurations of all the parameters that will be calibrated and the one constants but not with the default value of the closure.

Type:

Dict[str, FittableParameter]

closure

The abstraction that represent the used closure.

Type:

Closure

property n_calib: int

Number of variables that are calibrated.

Returns:

nc – Number of variables that are calibrated.

Return type:

int

fit_to_closure(x)[source]

Transforms an fitted array in a set of closure parameters.

This method copy the fixed non-default values of coef_fit_dict and copy the calibrated values from x. Which is simply the parameters values in the order that is indicated by coef_fit_dict.

Parameters:

x (float Array of shape (nc)) – The array on which the optimize works to find the best values. It is the array of the parameters that are calibrated.

Returns:

clo_params – The instance of the closure parameters class (child class of ClosureParametersAbstract) with the modifications of the calibration step.

Return type:

ClosureParametersAbstract

gen_init_val()[source]

Produce the fitted array for the first calibration step.

This method simply copy the initial values of the calibrated coefficients in an array x which will be used as the first calibration step for the optimizer.

Returns:

x – The initial vector for the optimizer at the first step of calibration.

Return type:

float Array of shape (nc)