Annotations

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

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

  • end - The 'end' of the simulation, by virtue of calling the finish function. This will also affect the lastStep function within step for usage by the modeller. Default value is 60

  • kickoff - The 'kickoff' for the simulation - the function for this is represented by kickOff which can be called in the tick function. Usage for this is primarily to set aside actions to activate or call agents/procesess to begin while allowing a 'warmup' phase where some actions can occur. Default value is 1.

    ModelSettings.Java

public class MyModel extends AgentBasedModel<GlobalState> {
@ModelSettings(kickoff = 10, end = 100, 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).

![](/src/images/constant_2_1.png)
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 Outputting Data

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.