metaheuristic_designer.parameter_schedules.random_schedule module#

Schedule that picks a random value at each evaluation.

class RandomSchedule(init_value, final_value, rng=None)[source]#

Bases: SchedulableParameter

Schedule that returns a uniform random value between init_value and final_value at every call, ignoring progress.

Parameters:
init_valuefloat

Lower bound of the random interval.

final_valuefloat

Upper bound of the random interval.

rngRNGLike, optional

Random number generator.

Parameters:
  • init_value (float)

  • final_value (float)

  • rng (int | Generator | None)

Methods

__call__(progress)

Shorthand for evaluate().

evaluate(progress)

Return the parameter value at the given progress.

evaluate(progress)[source]#

Return the parameter value at the given progress.

Return type:

float

Parameters:
progressfloat

Current progress, a number between 0 (start) and 1 (end).

Returns:
Any

The parameter value at this stage of the optimization.

Parameters:

progress (float)

Notes

The return value is not restricted to numbers. You can return: * a float (e.g., a linearly decaying mutation strength), * an int (e.g., a discrete number of mutated components), * a bool (e.g., switching on/off a feature after a threshold), * a string (e.g., switching between strategies), or * any other object that the consuming component expects.

This makes schedules suitable for changing discrete algorithm choices as well as continuous numerical parameters.