Last updated on 16th July 2024
Annotations are used to mark fields in the model. This is important to identify the model as a specific type so that the Simudyne SDK has knowledge of these fields when running the model.
ModelSettings
is an optional annotation that allows you to set a number of configuration parameters, such as the default time settings.
Optional ModelSettings
parameters:
new_model
2018-01-01T00:00:00Z
. If set, the string must represent a valid date-time that will be parsed using DateTimeFormatter1
MONTHS
60
macroStep
. Default value is 10
. Macro steps will appear on the console as an option that users can click to step forward x amount of ticks/steps.MacroStep of 10 - used to step forward 10 steps/ticks.
ModelSettings.Java
public class MyModel extends AgentBasedModel<GlobalState> {
@ModelSettings(macroStep = 10, timeUnit = "MONTHS")
public class CreditCard implements Model {
...
}
Fields can be marked as Constant
to highlight that this field is available for configuration before setup()
has been called on the model. Constant
is useful for configurable parameters that will be used during the model setup such as the number of agents.
name
can be passed as an optional parameter to the constant annotation to set a human-friendly name for the input field in the console. If not set, the name of the field will be used.
Constant.Java
public class CreditCard implements Model {
@Constant(name = "Initial Balance")
public long initialBalance = 400;
public void setup() {
// set balance to value of initialBalance
}
}
Console view of constant before setup (value can be changed).
Fields can be marked as Input
to show that this field is available for configuration in the model at all times. Input
fields are used to highlight where particular parameters in the model may be involved in ongoing decisions.
As with @Constant, name
can be used as an optional parameter to set a human-friendly title for the input field in the console. If this is not set, the name of the field will be used.
Input.Java
public class CreditCard implements Model {
@Input(name = "Spending")
public float spending = 250f;
public void step() {
// use value of spending
}
}
Fields marked as Variable
are serialised as part of the model output after setup has been run.
(This means that it is safe to depend upon state that is initialised as part of setup from a @Variable method (such as an AgentSystem)).
For more information on Variable
see Reporting
Currently Outputs
and Variables
are considered the same thing, and can be used in the same way.
Fields marked as custom are objects which have fields of their own with annotations.