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