Class RandomScheduler

Inheritance Relationships

Base Types

Class Documentation

class RandomScheduler : public kami::SequentialScheduler, private std::enable_shared_from_this<RandomScheduler>

Will execute all agent steps in a random order.

A random scheduler will iterate over the agents assigned to the scheduler and call their step() function in a random order. That order should be different for each subsequent call to step(), but is not guaranteed not to repeat.

Public Functions

RandomScheduler() = default

Constructor.

explicit RandomScheduler(std::shared_ptr<std::mt19937> rng)

Constructor.

Parameters

rng – [in] A uniform random number generator of type std::mt19937, used as the source of randomness.

virtual std::unique_ptr<std::vector<AgentID>> step(std::shared_ptr<Model> model, std::unique_ptr<std::vector<AgentID>> agent_list) override

Execute a single time step.

This method will randomize the list of Agents provided then execute the Agent::step() method for every Agent listed.

Parameters
  • model – a reference copy of the model

  • agent_list – list of agents to execute the step

Returns

returns vector of agents successfully stepped

virtual std::unique_ptr<std::vector<AgentID>> step(std::shared_ptr<ReporterModel> model, std::unique_ptr<std::vector<AgentID>> agent_list) override

Execute a single time step for a ReporterModel

This method will randomize the list of Agents provided then execute the Agent::step() method for every Agent listed.

Parameters
  • model – a reference copy of the ReporterModel

  • agent_list – list of agents to execute the step

Returns

returns vector of agents successfully stepped

std::shared_ptr<std::mt19937> set_rng(std::shared_ptr<std::mt19937> rng)

Set the RNG.

Set the random number generator used to randomize the order of agent stepping.

Parameters

rng – [in] A uniform random number generator of type std::mt19937, used as the source of randomness.

Returns

a shared pointer to the random number generator

std::shared_ptr<std::mt19937> get_rng()

Get the RNG.

Get a reference to the random number generator used to randomize the order of agent stepping.