Model Context

Last updated on 16th July 2024

The Context of a model is the wrapper holding information about it.

Accessing the Context of a model

In the Context, you can find the seed of the model (its pseudo random number generator), the tick of the simulation and its configuration. More on Model Config

To get the Context, you can use the getContext() method. This method can be called on any AgentBasedModel, SystemDynamicsModel and AgentSystem.

public class Housing implements AgentBasedModel<GlobalState> {

  public int function(){
     return getContext().getTick(); 
  }  
}

Once you have the Context, the getPRNG() method will return the SeededRandom object associated with your model. The getTick() method will return the tick number your simulation is on when you call it. Finally, you can also get the Configuration from the Context by calling getConfig().

public class Housing implements AgentBasedModel<GlobalState> {

  public void function(){
     getContext().getTick(); // getting the current Tick of the Simulation
     getContext().getPRNG(); // getting the prng of the model
     getContext().getConfig(); // accessing the configuration of the Model
  }  
}