NS-Gym Scheduler Module

class ns_gym.schedulers.RandomScheduler(probability=0.5, start=0, end=inf, seed=None)[source]

Bases: Scheduler

Random event scheduler: Events occur randomly with a given probability at each time step.

Parameters:
  • probability (float) – The probability of an event occurring at each time step.

  • start (int, optional) – The start time for the scheduler. Defaults to 0.

  • end (int, optional) – The end time for the scheduler. Defaults to infinity.

  • seed (int, optional) – Random generator seed. Defaults to None.

class ns_gym.schedulers.CustomScheduler(event_function, start=0, end=inf)[source]

Bases: Scheduler

Custom event scheduler: Allows for custom event logic based on a user-defined function.

class ns_gym.schedulers.ContinuousScheduler(start=0, end=inf)[source]

Bases: Scheduler

Continuous Event Scheduler : At every time step return true

class ns_gym.schedulers.DiscreteScheduler(event_list, start=0, end=inf)[source]

Bases: Scheduler

A discrete event scheduler returns a bool indicating where the system should transition at this time step

Parameters:

event_list (set) – List of time steps to make a transition

class ns_gym.schedulers.PeriodicScheduler(period, start=0, end=inf)[source]

Bases: Scheduler

Periodic event scheduler: At periodic steps return true.

Parameters:

period (int) – Period of event transition times.

class ns_gym.schedulers.MemorylessScheduler(p, start=0, end=inf, seed=None)[source]

Bases: Scheduler

Memoryless Scheduler: Events happen at intervals according to a Geometric distribution

This scheduler models the number of trials that must be run before a success. The scheduler samples from a geometric distribution then records the new time an event will occur. After a transition we resample from the geometric distribution.

Parameters:
  • p (float) – The probability of success of an individual trial.

  • seed (int, optional) – Random generator seed. Defaults to None.

class ns_gym.schedulers.BurstScheduler(on_duration, off_duration, start=0, end=inf)[source]

Bases: Scheduler

Burst event scheduler: fires for a window of consecutive steps, then stays silent, repeating cyclically.

The cycle length is on_duration + off_duration. Within each cycle the scheduler fires for the first on_duration steps and is silent for the remaining off_duration steps.

Parameters:
  • on_duration (int) – Number of consecutive steps to fire each cycle.

  • off_duration (int) – Number of consecutive silent steps each cycle.

  • start (int, optional) – Start time. Defaults to 0.

  • end (int, optional) – End time. Defaults to infinity.

class ns_gym.schedulers.DecayingProbabilityScheduler(initial_probability, decay_rate, start=0, end=inf, seed=None)[source]

Bases: Scheduler

Decaying probability scheduler: fires randomly with exponentially decaying probability.

At each time step the probability of firing is:

\[p(t) = p_0 \, e^{-\lambda t}\]

where \(p_0\) is the initial probability and \(\lambda\) is the decay rate. This models environments that stabilise over time.

Parameters:
  • initial_probability (float) – Probability of firing at t = 0.

  • decay_rate (float) – Exponential decay rate (>= 0).

  • start (int, optional) – Start time. Defaults to 0.

  • end (int, optional) – End time. Defaults to infinity.

  • seed (int, optional) – Random generator seed. Defaults to None.

class ns_gym.schedulers.WindowScheduler(windows, start=0, end=inf)[source]

Bases: Scheduler

Window-based event scheduler: fires only within specified time windows.

Each window is an inclusive (start, end) tuple. The scheduler fires at time t if t falls inside any window (and inside the global [start, end] range).

Parameters:
  • windows (list) – List of (start, end) time windows.

  • start (int, optional) – Global start time. Defaults to 0.

  • end (int, optional) – Global end time. Defaults to infinity.