piglot.parameter.DualParameterSet

class DualParameterSet[source]

Bases: ParameterSet

Container class for a set of parameters with distinct internal and output parameters.

This type should be used if the internal optimised parameters and the output parameters are not equal. Output names are used for output name resolution. All output fields must have a mapping function to internal parameters.

Methods

add

Add a parameter to this set.

add_output

Adds an output parameter to the set.

clip

Clamp the parameter set to the [lbound,ubound] interval.

clone_output

Creates an output parameter identical to a given internal parameter.

hash

Build the hash for the current parameter values.

to_dict

Build a dict with name-value pairs for output parameters given a list of values.

to_output

Compute the output parameters' values given an array of internal inputs.

add(name: str, inital_value: float, lbound: float, ubound: float) None

Add a parameter to this set.

Parameters

namestr

Parameter name.

inital_valuefloat

Initial value for the parameter.

lboundfloat

Lower bound of the parameter.

uboundfloat

Upper bound of the parameter.

Raises

RuntimeError

If a repeated parameter is given.

add_output(name: str, mapping: Callable[[Dict[str, float]], float]) None[source]

Adds an output parameter to the set.

Parameters

namestr

Parameter name

mappingCallable[[Dict[str, float]], float]

Mapping function from internal parameters to this output parameter’s value. Internal parameters are passed as arguments for this function as an expanded dict.

Raises

RuntimeError

If an output parameter is repeated.

clip(values: ndarray) ndarray

Clamp the parameter set to the [lbound,ubound] interval.

Parameters

valuesnp.ndarray

Values to clip. Their order is used for parameter resolution.

Returns

np.ndarray

Clamped parameters.

clone_output(name: str) None[source]

Creates an output parameter identical to a given internal parameter.

Parameters

namestr

Name of the internal parameter to clone.

static hash(values) str

Build the hash for the current parameter values.

Parameters

valuesarray

Parameters to hash.

Returns

str

Hex digest of the hash.

to_dict(values: ndarray) Dict[str, float][source]

Build a dict with name-value pairs for output parameters given a list of values.

Parameters

valuesnp.ndarray

Values to pack. Their order is used for parameter resolution.

Returns

Dict[str, float]

Name-value pair for each output parameter.

to_output(values: ndarray) ndarray[source]

Compute the output parameters’ values given an array of internal inputs.

Parameters

valuesnp.ndarray

Values to pack. Their order is used for parameter resolution.

Returns

np.ndarray

Values of the output parameters.