Model context schema
This guide provides a reference on the model context schema.
For a complete model context file example, please see Model context example.
Properties
Below are detailed descriptions of the context object's properties. To find a specific property, use the navigation menu on the right.
version
Specifies the platform version.
- Type:
string - Nullable:
false
variables
An object that describes the model variables that comprise the archived run state. In each key-value pair, the key is the variable name and the value is a VariableOptions object describing the processing options for the variable.
- Keys: The name of the variable
- Values:
VariableOptionsobject - Nullable:
true
VariableOptions object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
resetDecision | boolean | Yes | Only used for Simlang. If true, decisions are reset to the calculated value after each step. If false, decisions keep the user-entered value. |
dialect | string | Yes | The way we describe the variable. For possible values, see dialect values below. |
save | boolean | Yes | If true, the value should be saved to database. This property only applies to Excel and systems dynamics languages like SimLang, Vensim, STELLA, and Powersim. In programming languages, like Python, you must call Epicenter.record() to save a variable value. |
reportPer | number | Yes | A floating-point number of time steps. Defines the frequency with which the value should be saved to the database. Used with modelling languages like Vensim, STELLA, and Powersim. There can be thousands of time steps in a model. You might not want to save the variable values for every step lest the history become too large. To define the optimal number of time steps between variable saves, set this value. |
sensitivity | boolean | Yes | Particular to Vensim. Marks a variable as one that will be output during a sensitivity run. |
reportOffset | integer | Yes | The time step when the first variable save should occur. |
dialect values
POINT_IN_TIMEFor languages like Simlang that can return a history of a variable's value. This dialect returns only the head of that history, which is the current value.XY: Returns an array of objects with two values: the timestep value and the variable value.COLLAPSED_ARRAY: Vensim, STELLA, and Powersim give you subscripted variables. This dialect leaves out the subscripts. Returns an array of values in the correct subscript order.
"variables": {
"variable-1": {
"dialect": "point_in_time",
"resetDecision": true,
"save": true,
"sensitivity": false,
"reportPer": 2,
"reportOffset": 0
},
"sensitivity-variable-1": {
"resetDecision": false,
"save": false,
"sensitivity": true,
"reportPer": 1,
"reportOffset": 0
},
...
},
...
externalFunctions
An object that describes external functions mapped in the model. Each key-value pair consists of a function name as the key and a WireExternalFunction object as the value.
- Keys: The internal name mapped to the external function (string)
- Values:
WireExternalFunctionobject - Nullable:
true
WireExternalFunction object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
route | Route object | No | Defines the route to the external function. |
arguments | string | Yes | Arguments for the external function. |
Route object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
service | string | Yes | The name of the external service that provides the function. |
version | integer | Yes | The external service version. |
"externalFunctions": {
"key": {
"wire": {
"route": {
"function": {
"name": "create"
},
"service": "user",
"version": 2
},
"arguments": "[\"name\",\"email\"]"
}
}
},
...
modelVersion
Allows you to version your models.
If you would like to version your models, please contact Forio support, as this may require a custom implementation.
- Type:
integer - Format:
int32 - Minimum:
0 - Nullable:
true
"modelVersion": 3
mappedFiles
Use this property to provide a list of mapped context files.
An object containing string key-value pairs.
- Keys: Names for the mapped files (
string) - Values: The mapped file paths (
string) - Nullable:
true
"mappedFiles": {
"region_1": "path/to/file/for/region_1",
...
},
...
control
Provide specific settings for each modelling language in this property.
- Type: One of the following objects:
- Nullable:
false
ExcelModelControl object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
autoRecalculate | boolean | Yes | If true, automatically recalculate all values after each state-changing operation. Alternatively, Epicenter provides a recalculate() function that can be called by the model when making a step. |
JavaModelControl object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
executable | string | Yes | The name of the executable you want from the model JAR. |
PowersimModelControl object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
minimizeMemoryFootprint | boolean | Yes | Determines whether to minimize memory usage during model execution. |
VensimModelControl object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
sensitivityControl | SensitivityControl object | No | Configuration object for controlling sensitivity analysis in Vensim. |
extensionModule | string | Yes | The name of an optional Vensim extension module to load. |
SensitivityControl object properties
| Property | Type | Nullable | Required | Description |
|---|---|---|---|---|
noiseSeed | integer (int32) | Yes | Yes | The random seed used for introducing noise during sensitivity analysis. |
reportPer | number (double) | Yes | No | The frequency (in time steps) at which results are reported. |
numberOfSimulations | integer (int32) | Yes | Yes | The total number of simulations to run for the sensitivity analysis. |
parameters | string array | Yes | No | A list of parameter names to vary in the sensitivity analysis. |
reportOffset | integer (int32) | Yes | No | The time step at which reporting should start. |
algorithm | string | Yes | Yes | The algorithm to use for the sensitivity analysis. |
"control": {
"vensim": {
"sensitivityControl": {
"algorithm": "M",
"parameters": [
"Constant=RANDOM_UNIFORM(2,4)"
],
"numberOfSimulations": 1,
"noiseSeed": 1234
}
}
},
...
language
Epicenter defaults to the earliest version of a modelling language. If you are using a later version, set this property.
- Type:
string - Nullable:
true
protections
A model is a global namespace. To protect against unwanted variable value changes, you can introduce guards based on specific user attributes, for example, role.
- Type:
object - Nullable:
false
Properties
| Property | Type | Nullable | Description |
|---|---|---|---|
guards | array | No | An array of objects that define validation rules. Must not be empty. Each item is one of the following: InputGuard, OverwriteGuard, PrivilegeGuard, RelativeGuard, or RoleGuard. |
InputGuard object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
regex | string | No | A regular expression pattern to validate input. Must not be blank. |
operand | string | No | The operand used in the validation logic. |
operator | string | No | The operator applied for comparison or matching during validation. |
OverwriteGuard object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
regex | string | No | A regular expression pattern to validate input. Must not be blank. |
dialect | string | Yes | Specifies the dialect used for interpreting the validation logic. |
initial | string | No | The initial value to apply during the overwrite operation. |
PrivilegeGuard object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
regex | string | No | A regular expression pattern to validate privilege rules. Must not be blank. |
read | string | No | Specifies the read permissions for the privilege guard. |
domain | string | No | The domain to which the privilege rules apply. |
grant | string | No | The grant type that defines the level of access. |
write | string | No | Specifies the write permissions for the privilege guard. |
execute | string | No | Specifies the execute permissions for the privilege guard. |
RelativeGuard object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
regex | string | No | A regular expression pattern to validate relative rules. Must not be blank. |
dialect | string | Yes | Specifies the dialect used for interpreting the validation logic. |
value | string | No | The value used for comparison in the relative guard condition. |
operator | string | No | The operator applied in the relative validation logic (e.g., ==, !=, <, >). |
key | string | No | The key or field name that the guard applies to. Must not be blank. |
RoleGuard object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
regex | string | No | A regular expression pattern to validate role rules. Must not be blank. |
role | string | No | The name of the role required for validation. Must not be blank. |
domain | string | No | The domain to which the role validation applies. |
grant | string | No | The grant type that defines the level of access. |
"protections": {
"guards": [
{
"role": {
"regex": "state.players.doctor.*",
"grant": "ALLOW",
"domain": "variable",
"role": "doctor"
}
},
{
"overwrite": {
"regex": "state.internal.precondition",
"initial": "-1"
}
},
{
"relative": {
"operator": "eq",
"value": "42",
"key": "state.internal.other"
}
},
{
"input": {
"regex": "state.internal.precondition",
"operator": "lt",
"operand": "0"
}
},
{
"privilege": {
"regex": "*",
"grant": "DISALLOW",
"read": "PARTICIPANT",
"write": "PARTICIPANT",
"execute": "PARTICIPANT"
}
}
]
},
...
restorations
This object configures two key behaviors for your model runs:
- Run restart. To restart an existing run, call the run adapter's
restore()function. - Run rewind. To rewind a run one or more steps, call the run adapter's
rewind()function. Pass the number of steps to rewind in thestepsparameter.
If both snapshot and rewind are enabled, we restore from the snapshot, but still store the history for rewinds.
Properties
| Property | Type | Nullable | Description |
|---|---|---|---|
rewind | RewindMarker object | Yes | Settings for a model run rewind. |
assembly | array of ReplayRestoration or SnapshotRestoration | Yes | Defines how we store the history and how we restore the run. |
log | string | Yes | Defines how we store the history if you have replay operations or rewind. For possible values, see log values below. |
log values
- Possible values:
FULL: Store all state-changing operations in order they are executed.TEMPORAL: Only the latest in a series of similar operations is saved for each step. (For model languages that implement a non-real-time step function). Deprecated and replaced byTEMPORAL_2.TEMPORAL_2: Only the latest in a series of similar operations is saved for each step. This setting is more efficient thanTEMPORAL.
- The default value depends on the model language:
- In Python, we save all state-changing operations.
- In languages that have steps like Vensim, we only store the last operation on a particular variable for each step.
If you do not define a rewind or any restore commands, Epicenter doesn't store history for your model runs.
RewindMarker object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
name | string | Yes | The name of the function that implements a time step. |
arguments | object | Yes | An object describing the arguments that are part of the step function signature. |
destructible | boolean | Yes | If true, remove the step you are rewinding from history. In this case, the step will not be included in the restore. |
ReplayRestoration object properties
This object contains a set of commands for a full history restore.
| Property | Type | Nullable | Description |
|---|---|---|---|
operations | array of ReplayOperation objects | Yes | The restore commands. |
ReplayOperation object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
operationType | string | No | The type of restore command. Possible values: operationType values. |
targetType | string | No | Specifies the action you are taking on the target. Possible values: targetType values. |
targetKey | string | No | The name of the function to call or the variable to set. |
operationType values
"stop_before": Stop the restore before the specified operation."stop_after": Stop the restore after the specified operation."include": Include the specified operation in the restore."exclude": Exclude the specified operation from the restore.
targetType values
"execute": indicates a function call"set": setting a variable value
To provide several stop_before or stop_after operations would be redundant. The restore will stop at the first stop operation. You could have more than one exclude or include operations.
SnapshotRestoration object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
variables | array | Yes | An array of variable names (strings) included in the snapshot restoration. |
"restorations": {
"rewind": {
"arguments": [
1,
"hello"
],
"name": "step_operation",
"destructible": false
},
"assembly": [
{
"snapshot": {
"variables": [
"variableOne",
"variableTwo"
]
}
},
{
"replay": {
"operations": [
{
"operationType": "stop_before",
"targetType": "execute", // this is a function call
"targetKey": "operation" // the name of the function
},
{
"operationType": "stop_after",
"targetType": "set", // setting a variable
"targetKey": "variable" // the variable name
},
{
"operationType": "include",
"targetType": "execute",
"targetKey": "operation"
},
{
"operationType": "exclude",
"targetType": "set",
"targetKey": "variable"
}
]
}
}
],
"log": "full"
},
...
workerImage
Change the Docker worker image with this setting.
- Type:
string - Nullable:
true
Epicenter has default Docker images for all supported languages. If you are producing a custom worker image, substitute the default image name here.
Please talk to Forio support before changing this value.
dependencies
Use this setting to provide a list of dependencies for a custom Docker image.
- Type:
array - Items: One of the following object types:
- Nullable:
true
AptExternalDependency object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
package | string | Yes | The name of the APT package to install. |
repository | string | Yes | The repository from which to fetch the package. |
version | string | Yes | The version of the package to install. |
CranExternalDependency object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
package | string | Yes | The name of the CRAN package to install. |
version | string | Yes | The version of the package to install. |
GitExternalDependency object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
url | string | Yes | The URL of the Git repository to clone. |
script | string | Yes | A script to run after cloning the repository. |
JuliaExternalDependency object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
package | string | Yes | The name of the Julia package to install. |
version | string | Yes | The version of the package to install. |
NpmExternalDependency object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
package | string | Yes | The name of the npm package to install. |
version | string | Yes | The version of the package to install. |
PypiExternalDependency object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
package | string | Yes | The name of the PyPI package to install. |
version | string | Yes | The version of the package to install. |
ShellExternalDependency object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
script | string | Yes | The shell script content or path to execute. |
"dependencies": [
{
"pypi": {
"package": "package",
"version": "1.0.0"
}
},
{
"apt": {
"package": "package",
"version": "1.0.0",
"repository": "repository"
}
}
],
...
operations
An object that lists the functions in the model.
- Keys: The function names (string)
- Values:
OperationOptionsobject that contains metadata for the operation. - Nullable:
true
OperationOptions object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
timeoutSeconds | integer | Yes | How long we wait for a response before it's a timeout (64-bit integer). |
inert | boolean | Yes | If true, the operation is non-state-changing. For example, a complex operation on several variables that doesn't change any variable values. |
Set inert to true for operations that don't change the state. That helps avoid unnecessary operations in the history and speeds up run restore and rewind.
"operations": {
"operation": {
"timeoutSeconds": 20,
"inert": false
}
},
...
enableStateCache
For efficiency, Epicenter can cache the return values of non-state-changing operations and flash the cache when state is updated.
- Type:
boolean - Nullable:
true
Please reach out to Forio support if you would like to use this feature.
redirectStandardOut
Channels your standard output to the log file.
- Type:
boolean - Nullable:
true
startDebugger
Indicates whether the debugger should start with the model (for languages that have a debugger).
- Type:
boolean - Nullable:
true
inceptionGracePeriodSeconds
How long we should wait for the model to start. The default is 180 seconds (3 minutes).
- Type:
integer - Format:
int32 - Minimum:
1 - Nullable:
true
minimumLogLevel
Set this value to have Epicenter create a log for your model.
- Type:
string - Nullable:
true
Logging can be helpful in a development environment. However, it is suggested to leave logging off unless you need it.
Possible values:
INFODEBUG
A debug-level log is much more detailed and requires significantly more storage space.
There is no logging unless this value is set.
events
Override defaults for event handlers. The keys are the event names, and the values are objects containing override values.
- Key: The event name (
string) - Value:
EventOptionsobject - Nullable:
true
EventOptions object properties
| Property | Type | Nullable | Description |
|---|---|---|---|
timeoutSeconds | integer | Yes | Enter a custom timeout value for the event handler in seconds. |
defaults
Specifies the default context settings for the model.
The defaults property is implemented for backward compatibility. It is a best practice to set explicit values for the properties, rather than to define the defaults.
- Type:
ModelContextDefaultsobject - Nullable:
false
ModelContextDefaults object properties
variables(VariableOptionsobject, Nullable): Defaults for variables.operations(OperationOptionsobject, Nullable): Defaults for operations.events(EventOptionsobject, Nullable): Defaults for events.