metaheuristic_designer.parametrizable_mixin module#

Module providing the ParametrizableMixin for managing schedulable parameters.

class ParametrizableMixin[source]#

Bases: object

Mixin that turns raw keyword arguments into dynamic, schedulable parameters.

Any argument passed to store_kwargs() or update_kwargs() can be a plain value or a callable that receives the current progress (a float between 0 and 1) and returns the value to use. The current values are accessible via get_params() or the params property.

Attributes:
params

Access parameter values by attribute-style lookup.

Methods

get_params()

Return a copy of the current parameter dictionary.

store_kwargs([progress])

Store keyword arguments and evaluate them at the given progress.

update(progress)

Re-evaluate all stored parameters at the current progress.

update_kwargs([progress])

Add or replace parameters and immediately evaluate them.

store_kwargs(progress=0, **kwargs)[source]#

Store keyword arguments and evaluate them at the given progress.

Parameters:
progressfloat, optional

Progress value forwarded to any callable parameters.

**kwargs

Parameter names and values (constants or callables).

Parameters:

progress (float)

update(progress)[source]#

Re-evaluate all stored parameters at the current progress.

Parameters:
progressfloat

Current progress (0-1) used to evaluate callable parameters.

Parameters:

progress (float)

update_kwargs(progress=0, **kwargs)[source]#

Add or replace parameters and immediately evaluate them.

Parameters:
progressfloat, optional

Progress value forwarded to any callable parameters.

**kwargs

Parameter names and new values.

Parameters:

progress (float)

get_params()[source]#

Return a copy of the current parameter dictionary.

Return type:

dict

Returns:
dict

The evaluated (non-callable) parameter values.