hive.utils.schedule module

class hive.utils.schedule.Schedule[source]

Bases: ABC, Registrable

abstract get_value()[source]

Returns the current value of the variable we are tracking

abstract update()[source]

Update the value of the variable we are tracking and return the updated value. The first call to update will return the initial value of the schedule.

classmethod type_name()[source]

This should represent a string that denotes the which type of class you are creating. For example, “logger”, “agent”, or “env”.

class hive.utils.schedule.LinearSchedule(init_value, end_value, steps)[source]

Bases: Schedule

Defines a linear schedule between two values over some number of steps.

If updated more than the defined number of steps, the schedule stays at the end value.

Parameters
  • init_value (int | float) – Starting value for schedule.

  • end_value (int | float) – End value for schedule.

  • steps (int) – Number of steps for schedule. Should be positive.

get_value()[source]

Returns the current value of the variable we are tracking

update()[source]

Update the value of the variable we are tracking and return the updated value. The first call to update will return the initial value of the schedule.

class hive.utils.schedule.ConstantSchedule(value)[source]

Bases: Schedule

Returns a constant value over the course of the schedule

Parameters

value – The value to be returned.

get_value()[source]

Returns the current value of the variable we are tracking

update()[source]

Update the value of the variable we are tracking and return the updated value. The first call to update will return the initial value of the schedule.

class hive.utils.schedule.SwitchSchedule(off_value, on_value, steps)[source]

Bases: Schedule

Returns one value for the first part of the schedule. After the defined number of steps is reached, switches to returning a second value.

Parameters
  • off_value – The value to be returned in the first part of the schedule.

  • on_value – The value to be returned in the second part of the schedule.

  • steps (int) – The number of steps after which to switch from the off value to the on value.

get_value()[source]

Returns the current value of the variable we are tracking

update()[source]

Update the value of the variable we are tracking and return the updated value. The first call to update will return the initial value of the schedule.

class hive.utils.schedule.DoublePeriodicSchedule(off_value, on_value, off_period, on_period)[source]

Bases: Schedule

Returns off value for off period, then switches to returning on value for on period. Alternates between the two.

Parameters
  • on_value – The value to be returned for the on period.

  • off_value – The value to be returned for the off period.

  • on_period (int) – the number of steps in the on period.

  • off_period (int) – the number of steps in the off period.

get_value()[source]

Returns the current value of the variable we are tracking

update()[source]

Update the value of the variable we are tracking and return the updated value. The first call to update will return the initial value of the schedule.

class hive.utils.schedule.PeriodicSchedule(off_value, on_value, period)[source]

Bases: DoublePeriodicSchedule

Returns one value on the first step of each period of a predefined number of steps. Returns another value otherwise.

Parameters
  • on_value – The value to be returned on the first step of each period.

  • off_value – The value to be returned for every other step in the period.

  • period (int) – The number of steps in the period.