Last updated on 16th July 2024
The Context of a model is the wrapper holding information about it.
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 you have the ability to get a variety of information such as:
getPRNG()
method will return the SeededRandom
object associated with your model.getTick()
method will return the tick number your simulation is on when you call it.getKickOff()
method will return the tick number specified by usage of the kickoff annotation in @ModelSettingsgetEnd()
method will return the tick number specified by usage of the end annotation in @ModelSettingsgetSessionID()
method will return the UUID of the simulation which may be useful for outputting to other processess.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
}
}