schedulers#

Classes#

ExponentialScheduler

Exponential scheduler updates a parameter from a maximum value to a minimum value with a given exponential decay.

LinearScheduler

Linear schedule updates a parameter from a maximum value to a minimum value over a given number of episodes.

ParameterScheduler

Abstract class for parameter scheduling.

class prt_rl.common.schedulers.ExponentialScheduler(obj: object, parameter_name: str, start_value: float, end_value: float, decay_rate: float)[source]#

Exponential scheduler updates a parameter from a maximum value to a minimum value with a given exponential decay.

Parameters:
  • parameter_name (str) – Name of the parameter to schedule

  • start_value (float) – Maximum value for the parameter

  • end_value (float) – Minimum value for the parameter

  • decay_rate (float) – Exponential decay rate for the parameter

get_value() float#

Get current value from either a direct field or a dotted path.

update(current_step: int) None[source]#

Returns the updated parameter value based on the current step number.

Parameters:

current_step (int) – Current step number

class prt_rl.common.schedulers.LinearScheduler(obj: object, parameter_name: str, start_value: float, end_value: float | List[float], interval: int | Tuple[int, int] | List[Tuple[int, int]])[source]#

Linear schedule updates a parameter from a maximum value to a minimum value over a given number of episodes.

Parameters:
  • obj (object) – Object to which the parameter belongs

  • parameter_name (str) – Name of the parameter to schedule

  • start_value (float) – Maximum value for the parameter

  • end_value (Union[float, List[float]]) – Minimum value for the parameter

  • interval (Union[int , Tuple[int, int], List[Tuple[int, int]]]) – Interval to schedule the parameter over. Can be a single integer, a tuple of integers, or a list of tuples. If a single integer is provided, the parameter will be scheduled over that many episodes. If a tuple is provided, the parameter will be scheduled over that range of episodes. If a list of tuples is provided, the parameter will be scheduled over each interval in the list.

Raises:

ValueError – If the interval is not greater than 0 or if the length of end_value and interval are not the same

Example

check_intervals(intervals: list[tuple[int, int]]) None[source]#

Check if the intervals are overlapping.

Parameters:

intervals (list[tuple[int, int]]) – List of intervals to check

Raises:

ValueError – If any of the intervals overlap

get_value() float#

Get current value from either a direct field or a dotted path.

update(current_step: int) None[source]#

Returns the linearly scheduled parameter value based on the current step number.

Parameters:

current_step (int) – Current step number

class prt_rl.common.schedulers.ParameterScheduler(obj: object, parameter_name: str)[source]#

Abstract class for parameter scheduling.

Parameters:
  • obj (object) – Object to which the parameter belongs

  • parameter_name (str) – Name of the parameter to schedule

get_value() float[source]#

Get current value from either a direct field or a dotted path.

abstractmethod update(current_step: int) None[source]#

Returns the updated parameter value based on the current step number.

Parameters:

current_step (int) – Current step number