-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvents.html
318 lines (308 loc) · 25.6 KB
/
Events.html
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<title>Events — QHG4 4.1 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/jody.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>
<link rel="shortcut icon" href="http://aim-bigfoot.uzh.ch/~QHG/pmwiki/pub/skins/sinorca/gfx/favicon.png"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Compiling QHG" href="qhg4_compile.html" />
<link rel="prev" title="Dumping and Restoring" href="dumprestore.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="qhg4_compile.html" title="Compiling QHG"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="dumprestore.html" title="Dumping and Restoring"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">QHG4 4.1 documentation</a> »</li>
<li class="nav-item nav-item-this"><a href="">Events</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="events">
<span id="events-ref"></span><h1>Events<a class="headerlink" href="#events" title="Permalink to this heading">¶</a></h1>
<p>Events are needed to notify objects of some change of state.</p>
<p>In QHG we have two kinds of events: events from the command line and internal events.</p>
<p>The events on the commandline events are passed as values of the <a class="reference internal" href="code_doc/app/QHGMain.html#qhgmain-ref"><span class="std std-ref">–events option of QHGMain</span></a>.</p>
<section id="events-event-list">
<h2>–events=<event-list><a class="headerlink" href="#events-event-list" title="Permalink to this heading">¶</a></h2>
<p>Set event list.</p>
<div class="line-block">
<div class="line">The event-list string is a comma-separated list of events:</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-list</span>       <span class="pre">::=</span> <span class="pre">"'"</span> <span class="pre"><event></span> <span class="pre">[","</span> <span class="pre"><event>]*"'"</span></code></div>
<div class="line">The entire event list must be enclosed in quotes;</div>
<div class="line">if the event list contains environment variables, use double quotes.</div>
</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event</span>            <span class="pre">::=</span> <span class="pre"><event-type></span> <span class="pre">"|"</span> <span class="pre"><event-params></span> <span class="pre">"@"</span> <span class="pre"><event-times></span></code></div>
</div>
<section id="event-times-and-triggers">
<h3>event times and triggers<a class="headerlink" href="#event-times-and-triggers" title="Permalink to this heading">¶</a></h3>
<p><code class="docutils literal notranslate"><span class="pre"><event-times></span></code> defines at which times the event should be triggered.</p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-times</span>      <span class="pre">::=</span> <span class="pre"><full-trigger></span> <span class="pre">[</span> <span class="pre">"+"</span> <span class="pre"><full-trigger>]*</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">full-trigger</span>     <span class="pre">::=</span> <span class="pre">["S"|"T"]<full-trigger-sub></span></code></div>
</div>
<div class="line-block">
<div class="line">If “S” or nothing is prefixed, the following numbers are interpreted as steps.</div>
<div class="line">If “T” is prefixed, the following numbers are interpreted as ‘real’ times.</div>
</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">full-trigger-sub</span> <span class="pre">::=</span> <span class="pre"><normal-trigger></span> <span class="pre">|</span> <span class="pre"><point-trigger></span> <span class="pre">|</span> <span class="pre"><final-trigger></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">normal-trigger</span>   <span class="pre">::=</span> <span class="pre">[<trigger-interval>]</span> <span class="pre"><step-size></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">trigger-interval</span> <span class="pre">::=</span> <span class="pre">"["[<minval>]</span> <span class="pre">":"</span> <span class="pre">[<maxval>]</span> <span class="pre">"]"</span></code></div>
</div>
<div class="line-block">
<div class="line">This form causes events to be triggered at time <minval>+k*<step-size>, for k = 0 … (<maxval>-<minval>)/<step-size>.</div>
<div class="line-block">
<div class="line">If <minval> is omitted, it is set to fNegInf,</div>
<div class="line">if <maxval> is omitted, it is set to fPosInf.</div>
<div class="line">If <trigger-interval> is omitted, it is set to [fNegInf:fPosInf].</div>
</div>
</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">point-trigger</span>    <span class="pre">::=</span> <span class="pre">"["<time>"]"</span></code></div>
</div>
<p>This form causes a single event at the specified time.</p>
<p><code class="docutils literal notranslate"><span class="pre">final-trigger</span>    <span class="pre">::=</span> <span class="pre">"final"</span></code></p>
<div class="line-block">
<div class="line">This form causes a single event at the end of the simulation.</div>
<div class="line">Trigger Example:</div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">20+[305:]500+[250:600]10+[37]</span></code></p>
<div class="line-block">
<div class="line">fire events every 20 steps,</div>
<div class="line">and every 500 steps starting from step 305,</div>
<div class="line">and every 10 steps between steps 250 and 600,</div>
<div class="line">and a single event at step 37.</div>
</div>
</section>
<section id="event-types">
<h3>Event types<a class="headerlink" href="#event-types" title="Permalink to this heading">¶</a></h3>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-type</span>       <span class="pre">::=</span> <span class="pre"><standard_types></span> <span class="pre">|</span> <span class="pre"><tech-types></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">standard-type</span>    <span class="pre">::=</span> <span class="pre">"write"</span> <span class="pre">|</span> <span class="pre">"env"</span> <span class="pre">|</span> <span class="pre">"arr"</span> <span class="pre">|</span> <span class="pre">"pop"</span> <span class="pre">|</span> <span class="pre">"file"</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">tech-types</span>       <span class="pre">::=</span> <span class="pre">"dump"</span> <span class="pre">|</span> <span class="pre">"interpol"</span> <span class="pre">|</span> <span class="pre">"comm"</span> <span class="pre">|</span> <span class="pre">"check"</span> <span class="pre">|</span> <span class="pre">"user"</span> <span class="pre">|</span>  <span class="pre">"scramble"</span></code></div>
</div>
<div class="line-block">
<div class="line">The event parameters differ for the event types:</div>
<div class="line"><strong>for <event-type> == “write”:</strong></div>
</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>  <span class="pre">::=</span> <span class="pre"><type></span> <span class="pre">["+"</span> <span class="pre"><type>]*</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">type</span>          <span class="pre">::=</span> <span class="pre"><group-types></span> <span class="pre">|</span> <span class="pre"><special-types></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">group-types</span>   <span class="pre">::=</span> <span class="pre">"grid"</span> <span class="pre">|</span> <span class="pre">"geo"</span>    <span class="pre">|</span> <span class="pre">"climate</span> <span class="pre">"</span> <span class="pre">|</span> <span class="pre">"veg</span> <span class="pre">"</span> <span class="pre">|</span> <span class="pre">"nav"</span>  <span class="pre">|</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">special-types</span> <span class="pre">::=</span> <span class="pre">"occ"</span>  <span class="pre">|</span>  <span class="pre">"stats"</span> <span class="pre">|</span>  <span class="pre">"pop:"<speciesname>[<filter>]</span></code></div>
</div>
<div class="line-block">
<div class="line">Write the specified data sets to file.</div>
<div class="line">In case of “pop”, an optional filter character can be appended to the populaton name in order to filter the output:</div>
<div class="line-block">
<div class="line">‘#’ only write agent data</div>
<div class="line">‘%’ only write status arrays</div>
<div class="line">‘~’ only write additional data</div>
</div>
</div>
<p><strong>for <event-type> == “env”:</strong></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>   <span class="pre">::=</span> <span class="pre"><type></span> <span class="pre">["+"</span> <span class="pre"><type>]*</span> <span class="pre">":"</span> <span class="pre"><qdf-file></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">type</span>           <span class="pre">::=</span> <span class="pre">"geo"</span> <span class="pre">|</span> <span class="pre">"climate"</span> <span class="pre">|</span> <span class="pre">"veg"</span> <span class="pre">|</span> <span class="pre">"nav"</span></code></div>
</div>
<p>Read the specified data sets from the qdf file.</p>
<p><strong>for <event-type> == “arr”:</strong></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>   <span class="pre">::=</span> <span class="pre"><type></span> <span class="pre">":"</span> <span class="pre"><arrayname></span> <span class="pre">":"</span> <span class="pre"><qdf-file></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">type</span>           <span class="pre">::=</span> <span class="pre">"geo"</span> <span class="pre">|</span> <span class="pre">"climate"</span> <span class="pre">|</span> <span class="pre">"veg"</span></code></div>
</div>
<blockquote>
<div><p>Read the specified arrays from the qdf file.</p>
</div></blockquote>
<p><strong>for <event-type> == “pop”:</strong></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>   <span class="pre">::=</span> <span class="pre"><speciesname></span> <span class="pre">["+"</span> <span class="pre"><speciesname>]*</span> <span class="pre">":"</span> <span class="pre"><qdf-file></span></code></div>
</div>
<p>Read the specified populations from file.</p>
<p><strong>for <event-type> == “file”:</strong></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>   <span class="pre">::=</span> <span class="pre"><filename></span></code></div>
</div>
<p>The file must contain lines of the form</p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">line</span>           <span class="pre">::=</span> <span class="pre"><event-type></span> <span class="pre">"|"</span> <span class="pre"><event-params></span> <span class="pre">"@"</span> <span class="pre"><event-times></span></code></div>
</div>
<p>Add the events listed in the file to the event manager.</p>
<p><strong>for <event-type> == “interpol”:</strong></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>     <span class="pre">::=</span> <span class="pre"><interpol-data></span> <span class="pre">|</span> <span class="pre"><command></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">interpol-data</span>    <span class="pre">::=</span> <span class="pre">"file:"</span> <span class="pre"><interpol-file></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">command</span>          <span class="pre">::=</span> <span class="pre">"cmd:"</span> <span class="pre"><interpol-command></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">interpol-command</span> <span class="pre">::=</span> <span class="pre">"start"</span> <span class="pre">|</span> <span class="pre">"stop"</span></code></div>
</div>
<p>where</p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">"interpol-file"</span>  <span class="pre">:</span> <span class="pre">a</span> <span class="pre">QDF</span> <span class="pre">file</span> <span class="pre">containing</span> <span class="pre">interpolation</span> <span class="pre">steps.</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">"stop"</span>           <span class="pre">:</span> <span class="pre">stop</span> <span class="pre">interpolation</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">"start"</span>          <span class="pre">:</span> <span class="pre">restart</span> <span class="pre">interpolation</span></code></div>
</div>
<p><strong>for <event-type> == “dump”:</strong></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>   <span class="pre">::=</span> <span class="pre">"flat"</span> <span class="pre">|</span> <span class="pre">"smart"</span> <span class="pre">|</span> <span class="pre">"free"</span></code></div>
</div>
<div class="line-block">
<div class="line"><a class="reference internal" href="dumprestore.html#dump-restore-ref"><span class="std std-ref">Dump</span></a> the entire state of the simulation.</div>
<div class="line">The dump modes:</div>
<div class="line-block">
<div class="line">flat copy the linked lists as arrays</div>
<div class="line">smart save the linked lists by only saving the starts and ends of the active regions (not fully tested)</div>
<div class="line">free use “smart” mode if number of holes exceeds a threshold, otherwise use “flat” mode (not fully tested)</div>
</div>
</div>
<p><strong>for <event-type> == “comm”:</strong></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>   <span class="pre">::=</span> <span class="pre"><cmd-file></span>  <span class="pre">|</span> <span class="pre"><command></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">command</span>        <span class="pre">::=</span> <span class="pre"><iter_cmd></span> <span class="pre">|</span> <span class="pre"><del_action_cmd></span> <span class="pre">|</span> <span class="pre"><mod_pop_cmd></span> <span class="pre">|</span> <span class="pre"><event></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">iter_cmd</span>       <span class="pre">::=</span> <span class="pre">"SET</span> <span class="pre">ITERS:"<num_iters></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">del_action_cmd</span> <span class="pre">::=</span> <span class="pre">"REMOVE</span> <span class="pre">ACTION:"<population>:<action_name></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">mod_pop_cmd</span>    <span class="pre">::=</span> <span class="pre">"MOD</span> <span class="pre">POP:"<population>:<param_name>:<value></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">event</span>          <span class="pre">:</span> <span class="pre">any</span> <span class="pre">event</span> <span class="pre">description;</span> <span class="pre">see</span> <span class="pre">definition</span> <span class="pre">above</span></code></div>
</div>
<p>The format of <cmd-file></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">cmd-file</span>       <span class="pre">::=</span> <span class="pre"><command-line>*</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">command-line</span>   <span class="pre">::=</span> <span class="pre"><command></span> <span class="pre"><NL></span></code></div>
</div>
<div class="line-block">
<div class="line">If the <cmd-file> has changed since the last triggered time the contents will be executed:</div>
<div class="line-block">
<div class="line">iter_cmd: set new iteration limit</div>
<div class="line">del_action_cmd: remove action from prio list</div>
<div class="line">mod_pop_cmd: hange parameter of population</div>
<div class="line">event: add event to event manager’s list</div>
</div>
</div>
<p><strong>for <event-type> == “check”:</strong></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>   <span class="pre">::=</span> <span class="pre"><what></span> <span class="pre">["+"</span> <span class="pre"><what>]*</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">what</span>           <span class="pre">::=</span> <span class="pre">"lists"</span></code></div>
</div>
<p>(Debugging only) “lists”: check linked lists at specified times</p>
<p><strong>for <event-type> == “user”:</strong></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>   <span class="pre">::=</span> <span class="pre"><eventid>:<stringdata></span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">eventid</span>        <span class="pre">:</span> <span class="pre">an</span> <span class="pre">event</span> <span class="pre">id</span> <span class="pre">in</span> <span class="pre">[1000,</span> <span class="pre">9999]</span></code></div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">stringdata</span>     <span class="pre">:</span> <span class="pre">a</span> <span class="pre">string</span></code></div>
</div>
<p><strong>for <event-type> == “scramble”:</strong></p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">event-params</span>   <span class="pre">::=</span> <span class="pre">"connections"</span> <span class="pre">|</span> <span class="pre">"all"</span></code></div>
</div>
<p>Scrambles the order of connections between nodes</p>
</section>
<section id="example">
<h3>Example<a class="headerlink" href="#example" title="Permalink to this heading">¶</a></h3>
<p>Here is a full example for an eventlist:</p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">--events='env|geo+climate:map120.qdf@[120],write|pop:GrassLover|grid@5+[20:30]1,comm|REMOVE</span> <span class="pre">ACTION</span> <span class="pre">sapiens:ConfinedMove@[3000]'</span></code></div>
</div>
<dl class="simple">
<dt>This</dt><dd><ul class="simple">
<li><p>loads a QDF file containing new geography and climate data from ‘map120.qdf’ at step 120,</p></li>
<li><p>writes a QDF file containing grid data and population data for species “GrassLover” every 5 steps and additiionally every step between steps 20 and 30.</p></li>
<li><p>at step 3000 the ‘ConfinedMove’ action of species ‘sapiens’ is disabled.</p></li>
</ul>
</dd>
</dl>
</section>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div>
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Events</a><ul>
<li><a class="reference internal" href="#events-event-list">–events=<event-list></a><ul>
<li><a class="reference internal" href="#event-times-and-triggers">event times and triggers</a></li>
<li><a class="reference internal" href="#event-types">Event types</a></li>
<li><a class="reference internal" href="#example">Example</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="dumprestore.html"
title="previous chapter">Dumping and Restoring</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="qhg4_compile.html"
title="next chapter">Compiling QHG</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/Events.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="qhg4_compile.html" title="Compiling QHG"
>next</a> |</li>
<li class="right" >
<a href="dumprestore.html" title="Dumping and Restoring"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">QHG4 4.1 documentation</a> »</li>
<li class="nav-item nav-item-this"><a href="">Events</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2022, jodyxha.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.1.1.
</div>
</body>
</html>