-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_config.yaml
204 lines (181 loc) · 8.9 KB
/
example_config.yaml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# This is an example configuration file for Si.T.T.
# It demonstrates how to set all the existing variables to make your simulation work.
# Note that command line arguments override the values set in the configuration file. This makes it easier to change the
# behavior of your simulation without having to edit your configuration file.
# You can define some values dynamically, e.g. to keep secrets out of your config file. In order to do this, use the
# YAML tag !Env as prefix of the values.
#
# Example:
# args:
# myvalue: normal value
# mysecret: !Env "${SUPERSECRET}"
#
# Pass SUPERSECRET as environment variable to python to set this value. This also works for multiple strings like:
# "Hello ${PLANET}! How are ${ADDRESS}?"
#
# Moreover, you can define YAML variables using & and *. See &psql_port example below.
########################################################################################################################
# runtime configuration
# verbose output/logging
verbose: false
# suppress output/logging - will override quiet of set to true
quiet: false
# Skip certain steps in the simulation. Allowed values are none, simulation, output.
# Naturally, setting the value to simulation will also skip the output.
#skip_step: none
# The following shorthands can be set, too:
#skip_simulation: false
#skip_output: false
# break simulation step after this number of iterations, defaults to 100
# break_simulation_after: 100
# Simulation start and end points
simulation_start: &simulation_start START_HUB_ID
simulation_end: &simulation_end END_HUB_ID
# used as global start date (e.g. in nc files), must be ISO date YYYY-MM-DD
start_date: &start_date 1990-08-01
########################################################################################################################
# variables to use below - variables are normal YAML variables prefixed with &node anchors and aliased using *
# example:
# define using:
# psql_server: &psql_server 127.0.0.1
# later use like this:
# server: *psql_server
variables:
psql_port: &psql_port 5432
########################################################################################################################
# settings to use below
settings:
connections:
# source connections can be defined here, so you do not have to add these repeatedly below.
# Here is an example of a PostgreSQL connection setting used for PsqlReadPathsAndHubs and PsqlSavePathsAndHubs.
# It takes both environment variables (defined by YAML tags) and YAML node anchors.
# In our example the following environment variables are considered to be set:
# PSQL_SERVER=127.0.0.1
# PSQL_DB=sitt
# PSQL_PASSWORD=supersecret
# PSQL_USER=postgres
psql_default:
# Connection data for Postgres
server: !Env "${PSQL_SERVER}"
port: *psql_port
db: !Env "${PSQL_DB}"
user: !Env "${PSQL_USER}"
password: !Env "${PSQL_PASSWORD}"
# schema name - where are the tables saved in?
schema: sitt
########################################################################################################################
# preparation steps
# These steps define the classes to load in the preparation step and which parameters to set
# The classes are loaded and executed in the order of loading
preparation:
- # class name
class: Dummy
# module name - should be in PYTHONPATH
module: modules.preparation
# variables to pass to the object (not in constructor, but set directly). Constructor must not have required parameters.
args:
test: Test Argument passed from config.
# Execution conditions, see below
conditions: {}
# You can chain modules by adding them to the preparation array. Here is an example using settings from the connection
# settings defined above:
# GraphLoad will try to load a saved graph file from disk or from database. By convention, we take the .pkl extension
# for Python Pickle files (because this is what the file contains). By default, the module will try to load a pickled
# file. If it does not find one, it will get the data from the database. After this, it will save the graph to a
# pickled file, so we do not have to get data from db on the next run.
- class: GraphLoad
module: modules.preparation
args:
# connection definition set above
connection: psql_default
# filename of pickled graph
filename: 'saved_graph.pkl'
# save to pickled graph if retrieved from db
save: true
# DebugDisplayPathsAndHubs is a utility module to check if everything went smoothly during preparation. The options are:
# "draw_network": Draw or save a network graph. Dependent options are: "save_network": Save graph as file to disk.
# "show_network": Display network on stdout (depends on platform). If save_network is true, "save_network_name" and
# "save_network_type" will define the output file name and type. Possible file types are eps, jpeg, jpg, pdf, pgf, png,
# ps, raw, rgba, svg, svgz, tif, tiff.
# "display_routes": Display an example route. You need to define "start" and "end" hub ids. "show_graphs" will plot
# graphs to stdout (depends on platform). "save_graphs" defines, if graphs should be saved (multiple files are
# possible). Like above, "save_graphs_names" and "save_graphs_type" define file names and types (same possible values).
- class: DebugDisplayPathsAndHubs
module: modules.preparation
args:
draw_network: true
show_network: false
save_network: true
save_network_name: network
save_network_type: png
display_routes: false
start: *simulation_start
end: *simulation_end
show_graphs: false
save_graphs: true
save_graphs_names: possible_routes
save_graphs_type: png
# Create actual routes for simulation - this is important in order for the simulation to run. It takes two parameters:
# maximum_routes: if greater than 0, this is the maximum number of routes to retain (sorted by shortest routes)
# maximum_difference_from_shortest: if greater than 1, this is the maximum difference of a route from the shortest one
# (in factor) to be retained in the list.
- class: CreateRoutes
module: modules.preparation
args:
maximum_routes: 0
maximum_difference_from_shortest: 2.0
# The ConditionalModule is a utility module to bundle multiple modules with one condition check (so you do not have to
# repeat the conditions for every single step. In our example the check is not_data_must_exist. This will check if the
# data does *not* exist (conditions can be negated by prefixing them with "not_"). Here the class instance "context"
# will be tested for the instance variable "graph". What does this mean? Consider the first entry, GraphLoad. The
# module will load a saved graph, if a save file exists. If it exists, context.graph will have been populated by the
# time ConditionalModule is executed. Consequently, all the submodules will be skipped, if the graph was loaded. If not,
# the ConditionalModule will be run (context.graph will be empty).
########################################################################################################################
# simulation - is a bit more complicated, because there are several hooks to add modules to
# steps that are run at the start of each day
simulation_prepare_day: []
# steps that are run at each step to define the state
simulation_define_state: []
# steps run during simulation phase - these will update the state and calculate time taken, etc.
# Often, you will only need one simulation module to work out all the time and stop factors.
simulation_step:
- class: Simple
module: modules.simulation_step
args:
# kph of this agent
speed: 5.0
# time taken is modified by slope in percents multiplied by this number when ascending
ascend_slowdown_factor: 0.05
# time taken is modified by slope in percents multiplied by this number when descending
descend_slowdown_factor: 0.025
# conditions define conditions that must be true in order to execute this step
conditions:
# check type of next leg to be a road
types: ['road']
- class: DummyFixedSpeed
module: modules.simulation_step
args:
# kph of agent in this stepper
speed: 4.0
conditions:
# type must not be a road
not_types: ['road']
########################################################################################################################
# output steps
# These steps define the classes to load in the output step and which parameters to set
# The classes are loaded and executed in the order of loading
output:
- class: JSONOutput
module: modules.output
args:
# convert to string
to_string: true
# show output in log
show_output: false
# save output to file?
save_output: false
# output filename
filename: simulation_output.json
# indent output to display json in a nice way (if > 0, indent by this number of spaces)?
indent: 0