Simulation parameter Annotation usage
The @SimParam annotation can be used to specify the simulation model parameters
that will be received at runtime. The MiniReal system will pick up the list of
simulation parameters and show them on the UI. The values inserted by the User on
the UI will be fed to the simulation on runtime.
This annotation should be defined for arguments placed in the constructor of the
Model class.
The @SimParam annotation takes one argument for its self, which is the default value
for the parameter it is bound to. If no value is provided to the simulation model at
runtime, this default value is used to initialize the model parameter.
- The key for this argument is named
valueand it takes aStringobject. - Later on the
Stringvalue is casted to the correct type with respect to the simulation parameter.
Model.java
import org.simreal.annotation.*;
import sim.engine.SimState;
@SimModel
public class Model extends SimState {
// rest of code
private int population;
// class constructor
public Model(
@SimParam(value = "500") int population,
@SimParam(value = "100") int wealth
) {
super(System.currentTimeMillis());
this.population = population;
createAgents(wealth);
}
// rest of code
}