rsr.rsr.minimise_lower_states_random

rsr.rsr.minimise_lower_states_random(comps_st, sfun, sys_lower_st, max_state, *, fval=None, step=1, seed=None, exclude_keys=('sys',))[source]

Random greedy reduction of component states.

Algorithm (given a random permutation of components):
  • Try increasing each component by step (e.g., 1).

  • Call sfun(modified_state). Expect sfun to return a tuple where the 2nd element is an int representing a system state.

  • If status <= sys_lower_st: keep the increased value and continue cycling. If the component reaches max_state, remove it (can’t increase further).

  • If status > sys_lower_st: revert the change and remove that component (no further attempts).

Stops when all components have been removed from the candidate pool.

Returns:

  • final_state: dict of the minimised states.

  • info: dict with keys permutation, removed_on_lower, hit_min_state, attempts, final_state.

Return type:

Tuple (final_state, info)