Annotations

Last updated on 22nd April 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

ModelSettings is an optional annotation that allows you to set a number of configuration parameters, such as the default time settings.

Optional ModelSettings parameters:

  • id - Setting an id for a model is useful when there are multiple models running. Default value is new_model
  • start - Start time for the model time to commence at. Default value is 2018-01-01T00:00:00Z. If set, the string must represent a valid date-time that will be parsed using DateTimeFormatter
  • timeStep - The number of timeUnits between every model step/tick. Default value is 1
  • timeUnit - The base timeUnit for the timeSteps to occur in. Default value is MONTHS
  • ticks - The default number of ticks/runs for the model to run. Default value is 60
  • macroStep - The number of steps occurring in a 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.

tick bar

ModelSettings.Java

public class MyModel extends AgentBasedModel<GlobalState> {
@ModelSettings(macroStep = 10, timeUnit = "MONTHS")
public class CreditCard implements Model {
  ...
}

@Constant

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).

constant field

Constant fields must be public, with a primitive type (int, float, boolean etc).

@Input

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
  }
}  
Input fields must be public, with a primitive type (int, float, boolean etc).

@Variable

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

Variable fields must be public, with a supported type (Read more about supported types).

@Output

Currently Outputs and Variables are considered the same thing, and can be used in the same way.

Ouput fields must be public, with a supported type (Read more about supported types).

@Custom

Fields marked as custom are objects which have fields of their own with annotations.