Configuration
A mission model configuration enables mission modelers to set initial mission model values when running a simulation. Configurations are tied to a plan, therefore each plan is able to define its own set of configuration parameters
Declaration
To use a mission model configuration the @WithConfiguration
annotation must be used within the mission model's package-info.java to register the configuration with Aerie.
For example, the Aerie mission model template package-info.java makes use of this annotation:
@MissionModel(model = Mission.class)
@WithConfiguration(Configuration.class)
package missionmodel;
import gov.nasa.jpl.aerie.merlin.framework.annotations.MissionModel;
import gov.nasa.jpl.aerie.merlin.framework.annotations.MissionModel.WithConfiguration;
In this example Configuration
is the class class containing all mission model configuration data. When the @WithConfiguration
annotation is used, the model – defined within the @MissionModel
annotation – must accept the configuration as the last constructor parameter. See Mission.java:
public Mission(final Registrar registrar, final Configuration config) {
// Initialize Mission with 'registrar' and 'config' here.
}
If the second argument is an Instant
denoting plan start time the configuration parameter must still be provided as the last argument. For example:
public Mission(final Registrar registrar, final Instant planStart, final Configuration config) {
// Initialize Mission with 'registrar', 'planStart', and 'config' here.
}
Parameters
A configuration class should be defined with the same parameter annotations as activities. See Parameters for a thorough explanation of all possible styles of @Export
parameter declarations.
Similarly to activities, the annotation processor will take care of all serialization/deserialization of the configuration object. The annotation processor will generate a configuration mapper for the configuration defined within @WithConfiguration()
.
Examples
A Configuration
can be a simple data class. For example:
package missionmodel;
import gov.nasa.jpl.aerie.merlin.framework.annotations.Export;
import java.nio.file.Path;
import static gov.nasa.jpl.aerie.merlin.framework.annotations.Export.Template;
public record Configuration(Path initialDataPath) {
public static final Path DEFAULT_DATA_PATH = Path.of("/etc/os-release");
public static @Template Configuration defaultConfiguration() {
return new Configuration(DEFAULT_DATA_PATH);
}
}
See the Aerie mission model examples directory for a demonstration of each possible style of configuration definitions:
- foo-missionmodel - Uses standard
@Parameter
configuration annotations - banananation - Uses the
@Template
annotation to define a default Configuration object (shown above) - config-with-defaults - Uses
@WithDefaults
to define a default for each parameter - config-without-defaults - Defined with no default arguments, requires all arguments to be supplied by the planner
The mission model may use a configuration to set initial values of resources, for example:
this.sink = new Accumulator(0.0, config.sinkRate);