# SimulationConfig

This file describes the high level parameters of a simulation invocation (i.e. an experiment). It contains the basic experiment settings like number of runs and random seed, the environment definition, the parametrization of the output (more precisely the observation modules) and the definition of the spawners. The path to the SimulationConfig is given as command line argument (or defaulted) and all other configs are directly or indirectly refered to in the SimulationConfig. Several parameters depend on probabilities. Each invocation then rolls for said probabilities. All probabilities need to add up to 1.0.

The simulationConfig.xml consists of the following sections:

- ProfilesCatalog

- Experiment

- Scenario

- Environment

- Observations

- Spawners

## ProfilesCatalog

Specifies the ProfilesCatalog for the experiment.

      <ProfilesCatalog>ProfilesCatalog.xml</ProfilesCatalog>

## Experiment

Specifies the general experiment setup, not specific to a single invocation.

Tag | Description | Mandatory
--- | --- | ---
ExperimentId | Id of the experiment | yes
NumberOfInvocations | Number of invocation in the experiment. For each invocation probabilities are rerolled. | yes
RandomSeed | Random seed for the entire experiment. Must be within the bounds of an unsigned integer. | yes
Libraries | Name of the core module Libraries to use. If not specified the default name is assumed. | yes

      <Experiment>
        <ExperimentID>123</ExperimentID>
        <NumberOfInvocations>1</NumberOfInvocations>
        <RandomSeed>532725206</RandomSeed>
        <Libraries>
          <WorldLibrary>World_OSI</WorldLibrary>
        </Libraries>
      </Experiment>

## Scenario

This section contains information about the scenario setup for the experiment. This information does not change between invocations.

Tag | Description | Mandatory
--- | --- | ---
OpenScenarioFile | Name of the scenario file | yes

Example

This experiment uses the “HighwayScenario.xosc” scenario file.

      <Scenario>
        <OpenScenarioFile>Scenario.xosc</OpenScenarioFile>
      </Scenario>

## Environment

This section contains information about the world and the general environment inside the simulation. Every invocation re-rolls the environment probabilities. All probabilities need to add up to 1.0.

Tag | Description | Mandatory
--- | --- | ---
TimeOfDay | Currently unused. Time of day ranging from 1-24 [h]. | 1+ entry
VisibilityDistance | Defines how far a human driver can see [m]. | 1+ entry
Friction | Friction on the road. Used by DynamicsRegularDriving and LimiterAccelerationVehicleComponents. | 1+ entry
Weather | Currently unused. Weather as string | 1+ entry
TrafficRules | Defines which set of TrafficRules to use from the ProfilesCatalog | yes
TurningRates | Defines the turning rates for random route generation | no

Example

Every invocation has the time set to 15:00. In 70% of all invocation drivers can see 125 meter and for the other 30% of invocations the drivers can see 250 meter. Every invocation has a friction of 0.3. Every invocation has sunny weather.

      <Environment>
        <TimeOfDays>
          <TimeOfDay Probability="0.4" Value="15"/>
          <TimeOfDay Probability="0.6" Value="18"/>
        </TimeOfDays>
        <VisibilityDistances>
          <VisibilityDistance Probability="0.7" Value="300"/>
          <VisibilityDistance Probability="0.3" Value="400"/>
        </VisibilityDistances>
        <Frictions>
          <Friction Probability="1.0" Value="1.0"/>
        </Frictions>
        <Weathers>
          <Weather Probability="0.5" Value="Rainy"/>
          <Weather Probability="0.5" Value="Snowy"/>
        </Weathers>
        <TrafficRules>DE</TrafficRules>
      </Environment>

TurningRates

If routes are not defined in the Scenario, they are randomly generated. Starting at the current agent position at each junction a random connector is chosen based on the weights given in the TurningRates element, until the route terminates at a road without successors or a maximum depth is reached. If for a pair of incoming road / connector no weight is given, it is defaulted to 1. At the below example an agent coming from road “R1” has a 1/3 chance of selecting “R1-2” and a 2/3 chance of selecting “R1-3”.

Attribute | Description
--- | ---
Incoming | Id of the incoming road
Outgoing | Id of the connector
Weight | Weight for this pair

        <TurningRates>
          <TurningRate Incoming="R1" Outgoing="R1-2" Weight="1.0"/>
          <TurningRate Incoming="R1" Outgoing="R1-3" Weight="2.0"/>
          <TurningRate Incoming="R2" Outgoing="R2-1" Weight="1.0"/>
          <TurningRate Incoming="R2" Outgoing="R2-3" Weight="1.0"/>
          <TurningRate Incoming="R3" Outgoing="R3-1" Weight="2.0"/>
          <TurningRate Incoming="R3" Outgoing="R3-2" Weight="1.0"/>
        </TurningRates>

## Observations

In this section all observation libraries are defined with their parameters. A specific library is loaded by adding an entry to the Observations tag:

    <Observations>
      <!-- first observer -->
      <Observation>
        <Library>THE_OBSERVATION_LIBRARY</Library>
        <!-- observer specific parameter -->
        <Parameters>
          <String Key="THE_KEY" Value="THE_VALUE"/>
          <Bool Key="ANOTHER_KEY" Value="false"/>
          ...
        </Parameters>
      </Observation>
      <!-- second observer -->
      <Observation>
         ...
      </Observation>
    </Observations>

Here, the `Library` tag contains the name of the library, and `Parameters` contain an optional list of key/value pairs, specific for each observer.

Please refer to the documentation of the individual observers for available parameters:

- Observation_Log
- Observation_EntityRepository

## Spawners

In this section the spawners are defined with their Profile (defined in the ProfilesCatalog). The same library can be loaded multiple times with different profiles. A spawner is either of type “PreRun”, meaning it is triggered only once at the start of the simulation, or “Runtime”, meaning it is triggered in every timestep. If different spawners are to be triggered at the same time the spawner with the highest priority is triggered first.

      <Spawners>
        <Spawner>
          <Library>SpawnerPreRunCommon</Library>
          <Type>PreRun</Type>
          <Priority>0</Priority>
          <Profile>DefaultPreRunCommon</Profile>
        </Spawner>
        <Spawner>
          <Library>SpawnerRuntimeCommon</Library>
          <Type>Runtime</Type>
          <Priority>0</Priority>
          <Profile>DefaultRuntimeCommon</Profile>
        </Spawner>
      </Spawners>

## Full Example

simulationConfig.xml

     1<?xml version='1.0' encoding='UTF-8'?>
     2<simulationConfig SchemaVersion="0.8.2">
     3  <ProfilesCatalog>ProfilesCatalog.xml</ProfilesCatalog>
     4  <Experiment>
     5    <ExperimentID>123</ExperimentID>
     6    <NumberOfInvocations>1</NumberOfInvocations>
     7    <RandomSeed>532725206</RandomSeed>
     8    <Libraries>
     9      <WorldLibrary>World_OSI</WorldLibrary>
    10    </Libraries>
    11  </Experiment>
    12  <Scenario>
    13    <OpenScenarioFile>Scenario.xosc</OpenScenarioFile>
    14  </Scenario>
    15  <Environment>
    16    <TimeOfDays>
    17      <TimeOfDay Probability="0.4" Value="15"/>
    18      <TimeOfDay Probability="0.6" Value="18"/>
    19    </TimeOfDays>
    20    <VisibilityDistances>
    21      <VisibilityDistance Probability="0.7" Value="300"/>
    22      <VisibilityDistance Probability="0.3" Value="400"/>
    23    </VisibilityDistances>
    24    <Frictions>
    25      <Friction Probability="1.0" Value="1.0"/>
    26    </Frictions>
    27    <Weathers>
    28      <Weather Probability="0.5" Value="Rainy"/>
    29      <Weather Probability="0.5" Value="Snowy"/>
    30    </Weathers>
    31    <TrafficRules>DE</TrafficRules>
    32  </Environment>
    33  <Observations>
    34    <Observation>
    35      <Library>Observation_Log</Library>
    36      <Parameters>
    37        <String Key="OutputFilename" Value="simulationOutput.xml"/>
    38        <Bool Key="LoggingCyclicsToCsv" Value="false"/>
    39        <StringVector Key="LoggingGroup_Trace" Value="XPosition,YPosition,YawAngle"/>
    40        <StringVector Key="LoggingGroup_RoadPosition" Value="AgentInFront,Lane,PositionRoute,Road,TCoordinate"/>
    41        <StringVector Key="LoggingGroup_RoadPositionExtended" Value="SecondaryLanes"/>
    42        <StringVector Key="LoggingGroup_Sensor" Value="Sensor*_DetectedAgents,Sensor*_VisibleAgents"/>
    43        <StringVector Key="LoggingGroup_Vehicle" Value="AccelerationPedalPosition,BrakePedalPosition,EngineMoment,Gear,SteeringAngle,TotalDistanceTraveled,YawRate"/>
    44        <StringVector Key="LoggingGroup_Visualization" Value="AccelerationEgo,BrakeLight,IndicatorState,LightStatus,VelocityEgo"/>
    45        <StringVector Key="LoggingGroups" Value="Trace,Visualization,RoadPosition,Sensor"/>
    46      </Parameters>
    47    </Observation>
    48    <Observation>
    49      <Library>Observation_EntityRepository</Library>
    50      <Parameters>
    51        <!-- If "FilenamePrefix" is skipped, defaults to Value="Repository" -->
    52        <String Key="FilenamePrefix" Value="Repository"/>
    53        <!-- If "WritePersistentEntities" is skipped, defaults to Value="Consolidated"
    54             Options:
    55             - Consolidated: Concatenate with {FilenamePrefix}_Run_###.csv for each run
    56             - Separate: Write to {FilenamePrefix}_Persistent.csv
    57             - Skip: No output for persistent entities
    58        -->
    59        <String Key="WritePersistentEntities" Value="Consolidated"/>
    60      </Parameters>
    61    </Observation>
    62  </Observations>
    63  <Spawners>
    64    <Spawner>
    65      <Library>SpawnerPreRunCommon</Library>
    66      <Type>PreRun</Type>
    67      <Priority>0</Priority>
    68      <Profile>DefaultPreRunCommon</Profile>
    69    </Spawner>
    70    <Spawner>
    71      <Library>SpawnerRuntimeCommon</Library>
    72      <Type>Runtime</Type>
    73      <Priority>0</Priority>
    74      <Profile>DefaultRuntimeCommon</Profile>
    75    </Spawner>
    76  </Spawners>
    77</simulationConfig>