-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarking.html
More file actions
380 lines (342 loc) · 20.2 KB
/
marking.html
File metadata and controls
380 lines (342 loc) · 20.2 KB
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Marking Reference — Semi-Markov 1.0 documentation</title>
<link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '1.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="top" title="Semi-Markov 1.0 documentation" href="index.html" />
<link rel="up" title="Semi-Markov Library Reference" href="reference.html" />
<link rel="next" title="Continuous Distributions Reference" href="distributions.html" />
<link rel="prev" title="Semi-Markov Library Reference" href="reference.html" />
</head>
<body>
<div class="related">
<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="distributions.html" title="Continuous Distributions Reference"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="reference.html" title="Semi-Markov Library Reference"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Semi-Markov 1.0 documentation</a> »</li>
<li><a href="reference.html" accesskey="U">Semi-Markov Library Reference</a> »</li>
</ul>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Marking Reference</a><ul>
<li><a class="reference internal" href="#local-marking">Local Marking</a><ul>
<li><a class="reference internal" href="#helper-classes">Helper Classes</a></li>
<li><a class="reference internal" href="#localmarking-class">LocalMarking Class</a></li>
</ul>
</li>
<li><a class="reference internal" href="#marking-class">Marking Class</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="reference.html"
title="previous chapter">Semi-Markov Library Reference</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="distributions.html"
title="next chapter">Continuous Distributions Reference</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/marking.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="marking-reference">
<h1>Marking Reference<a class="headerlink" href="#marking-reference" title="Permalink to this headline">¶</a></h1>
<div class="section" id="local-marking">
<h2>Local Marking<a class="headerlink" href="#local-marking" title="Permalink to this headline">¶</a></h2>
<p>The local marking is the set of ways a transition can examine
or modify the marking of its input and output tokens.
It is also responsible for keeping track of changes made to the
marking, so the system can make update affected transitions.
For this, it collaborates with the complete Marking.</p>
<div class="section" id="helper-classes">
<h3>Helper Classes<a class="headerlink" href="#helper-classes" title="Permalink to this headline">¶</a></h3>
<p>The marking can represent colored tokens in two ways.
If a place may contain only one type of token, then it is possible
to create a place in the marking which accepts only one C++ class
type. We call each of these classes a <em>token layer</em>.
The more common definition of color is that tokens at
a marking may be partitioned by a finite set of colors. This is
called a <em>colored token</em> container.</p>
<p>Two classes define storage for tokens at a place in a marking.</p>
<dl class="class">
<dt id="afidd::smv::Uncolored:TokenType:">
<em class="property">class </em><tt class="descclassname">afidd::smv::</tt><tt class="descname">Uncolored<TokenType></tt><a class="headerlink" href="#afidd::smv::Uncolored:TokenType:" title="Permalink to this definition">¶</a></dt>
<dd><p>This is a storage container for tokens of the same type and
without color.</p>
</dd></dl>
<dl class="class">
<dt id="afidd::smv::color_type:TokenType:">
<em class="property">class </em><tt class="descclassname">afidd::smv::</tt><tt class="descname">color_type<TokenType></tt><a class="headerlink" href="#afidd::smv::color_type:TokenType:" title="Permalink to this definition">¶</a></dt>
<dd><p>Given an arbitrary token, this decares the type of its color.</p>
</dd></dl>
</div>
<div class="section" id="localmarking-class">
<h3>LocalMarking Class<a class="headerlink" href="#localmarking-class" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="afidd::smv::LocalMarking:typename-TokenContainers:">
<em class="property">class </em><tt class="descclassname">afidd::smv::</tt><tt class="descname">LocalMarking<typename TokenContainers></tt><a class="headerlink" href="#afidd::smv::LocalMarking:typename-TokenContainers:" title="Permalink to this definition">¶</a></dt>
<dd><p>This class is responsible for reading and changing the subset
of the marking associated with the input places and output
places of a transition. The Marking for the whole system
puts values into this class and checks it to see what changes
have been made.</p>
<p>The template argument is a list of token containers. For example:</p>
<div class="highlight-python"><pre>typedef LocalMarking<Uncolored<CowToken>,Uncolored<BatToken>> MyLocal;</pre>
</div>
<p>With
this definition, the <cite>CowToken</cite> is layer 0 and the <cite>BatToken</cite>
is layer 1.</p>
<p>All methods in this class refer to token containers with an
ordinal <cite>size_t</cite>. This is exactly the order used when defining
the transition in <cite>BuildGraph</cite>.</p>
</dd></dl>
<dl class="function">
<dt id="LocalMarking">
<tt class="descname">LocalMarking</tt><big>(</big><big>)</big><a class="headerlink" href="#LocalMarking" title="Permalink to this definition">¶</a></dt>
<dd><p>There is a default constructor.</p>
</dd></dl>
<dl class="function">
<dt id="Add:I:__s.TokenType:I:CR">
void <tt class="descname">Add<I></tt><big>(</big>size_t <em>place_idx</em>, const TokenType<I>& <em>token</em><big>)</big><a class="headerlink" href="#Add:I:__s.TokenType:I:CR" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a token to a place. The template argument is a size_t which
specifies the token layer.</p>
</dd></dl>
<dl class="function">
<dt id="Remove:I.RNG:__s.s.RNGR">
void <tt class="descname">Remove<I, RNG></tt><big>(</big>size_t <em>place_idx</em>, size_t <em>count</em>, RNG& <em>random_generator</em><big>)</big><a class="headerlink" href="#Remove:I.RNG:__s.s.RNGR" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove <cite>count</cite> tokens from a place. This version chooses the tokens
randomly using a random number generator of the kind defined in
std::random and Boost.</p>
</dd></dl>
<dl class="function">
<dt id="Length:I:__sC">
size_t <tt class="descname">Length<I></tt><big>(</big>size_t <em>place_idx</em><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#Length:I:__sC" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the number of tokens.</p>
</dd></dl>
<dl class="function">
<dt id="StochiometricCoefficient__sC">
int <tt class="descname">StochiometricCoefficient</tt><big>(</big>size_t <em>place_idx</em><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#StochiometricCoefficient__sC" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the stochiometric coefficient associated with this place, for
this transition.</p>
</dd></dl>
<dl class="function">
<dt id="Layer__sC">
int <tt class="descname">Layer</tt><big>(</big>size_t <em>place_idx</em><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#Layer__sC" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the token layer for this place.</p>
</dd></dl>
<dl class="function">
<dt id="Get:I.F:__s.FCRC">
std::tuple<F::result_type, bool> <tt class="descname">Get<I, F></tt><big>(</big>size_t <em>place_idx</em>, const F& <em>functor</em><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#Get:I.F:__s.FCRC" title="Permalink to this definition">¶</a></dt>
<dd><p>This doesn’t get a token. It operates on the container with a functor of
type <cite>F</cite> and returns the result of that functor. For instance, you might
want to know the average of the <cite>birthday</cite> property of a set of tokens
on the second input arc of a transition:</p>
<div class="highlight-python"><pre>auto average=local_marking.template get<0>(1,
[](const Uncolored<Children>& kids)->double {
double total=0.0;
for (const auto& k : kids) {
total+=k.birthday;
}
return total/kids.size();
});</pre>
</div>
<p>The <cite>get</cite> function returns a <cite>std::tuple<double,bool></cite>, where the first
type is the return type of your function and the second is whether
there were any tokens at the place.</p>
</dd></dl>
<dl class="function">
<dt id="GetToken:I.F:__s.FCRC">
void <tt class="descname">GetToken<I, F></tt><big>(</big>size_t <em>place_idx</em>, const F& <em>functor</em><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#GetToken:I.F:__s.FCRC" title="Permalink to this definition">¶</a></dt>
<dd><p>This applied <cite>functor</cite> to the token at layer I, and returns an
<cite>std::tuple<F::result_type,bool></cite> where the first member of the tuple
is the result type of the functor, <cite>F</cite>, and the second is whether there
were any tokens at the place. It runs the functor on the <em>first</em> token
in the container.</p>
</dd></dl>
<dl class="function">
<dt id="Move:I.J:__s.s.s">
void <tt class="descname">Move<I, J></tt><big>(</big>size_t <em>from</em>, size_t <em>to</em>, size_t <em>count</em><big>)</big><a class="headerlink" href="#Move:I.J:__s.s.s" title="Permalink to this definition">¶</a></dt>
<dd><p>Moves a token from one place to another. The two layers, I and J, are
usually the same, but it is possible to move a token from one layer
to another if the token types are the same for both layers. For instance,
one may be colored an one uncolored.</p>
</dd></dl>
<dl class="function">
<dt id="Move:I.J.Modifier:__s.s.s.ModifierCR">
void <tt class="descname">Move<I, J, Modifier></tt><big>(</big>size_t <em>from</em>, size_t <em>to</em>, size_t <em>count</em>, const Modifier& <em>functor</em><big>)</big><a class="headerlink" href="#Move:I.J.Modifier:__s.s.s.ModifierCR" title="Permalink to this definition">¶</a></dt>
<dd><p>This moves <cite>count</cite> number of tokens from a place in the Ith token layer
to a place in the Jth token layer (usually the same layer), and applies
the function <cite>functor</cite> to each token. For example:</p>
<div class="highlight-python"><pre>local_marking.template move<0,0>(1, 3, 1,
[](CowToken& bessie)->void {
bessie.parity+=1; // The number of times the cow gave birth.
});</pre>
</div>
</dd></dl>
<dl class="function">
<dt id="InputTokensSufficient:I:C">
void <tt class="descname">InputTokensSufficient<I></tt><big>(</big><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#InputTokensSufficient:I:C" title="Permalink to this definition">¶</a></dt>
<dd><p>Asks whether the number of tokens at each input place exceeds the
requirements of the stochiometric coefficients to that place.
This determines whether a transition is enabled.</p>
</dd></dl>
<dl class="function">
<dt id="OutputTokensEmpty:I:C">
bool <tt class="descname">OutputTokensEmpty<I></tt><big>(</big><big>)</big><tt class="descclassname"> const</tt><a class="headerlink" href="#OutputTokensEmpty:I:C" title="Permalink to this definition">¶</a></dt>
<dd><p>Asks whether all output places are empty. A transition can have a policy
that it will not enable unless output places have no tokens.</p>
</dd></dl>
<dl class="function">
<dt id="TransferByStochiometricCoefficient:I.RNG:__RNGR">
void <tt class="descname">TransferByStochiometricCoefficient<I, RNG></tt><big>(</big>RNG& <em>random_generator</em><big>)</big><a class="headerlink" href="#TransferByStochiometricCoefficient:I.RNG:__RNGR" title="Permalink to this definition">¶</a></dt>
<dd><p>This high level function looks at the stochiometric coefficient of each
input and output arc for all tokens at layer I. It then moves tokens
from inputs to outputs. If
inputs have more than one token, they are chosen randomly, and input
tokens are randomly assigned to outputs. Any extra inputs are removed
and any extra outputs are created.</p>
</dd></dl>
<dl class="function">
<dt id="TransferByStochiometricCoefficient:I.RNG.AndModify:__RNGR.AndModifyCR">
void <tt class="descname">TransferByStochiometricCoefficient<I, RNG, AndModify></tt><big>(</big>RNG& <em>random_generator</em>, const AndModify& <em>mod</em><big>)</big><a class="headerlink" href="#TransferByStochiometricCoefficient:I.RNG.AndModify:__RNGR.AndModifyCR" title="Permalink to this definition">¶</a></dt>
<dd><p>As above, this moves tokens according to the stochiometric coefficients, but
it also executes the AndModify functor on each token.</p>
</dd></dl>
</div>
</div>
<div class="section" id="marking-class">
<h2>Marking Class<a class="headerlink" href="#marking-class" title="Permalink to this headline">¶</a></h2>
<p>The Marking class is much like the LocalMarking, but it specifies
places using a PlaceKey.</p>
<dl class="class">
<dt id="afidd::smv::Marking:PlaceKey.typename-TokenContainers:">
<em class="property">class </em><tt class="descclassname">afidd::smv::</tt><tt class="descname">Marking<PlaceKey, typename TokenContainers></tt><a class="headerlink" href="#afidd::smv::Marking:PlaceKey.typename-TokenContainers:" title="Permalink to this definition">¶</a></dt>
<dd><p>This class holds the marking for the whole system. Each place
can contain one type of token container, specified by the
list of TokenContainers.</p>
</dd></dl>
<dl class="function">
<dt id="Marking">
<tt class="descname">Marking</tt><big>(</big><big>)</big><a class="headerlink" href="#Marking" title="Permalink to this definition">¶</a></dt>
<dd><p>The constructor takes no arguments.</p>
</dd></dl>
<dl class="function">
<dt id="Modified">
<tt class="descname">Modified</tt><big>(</big><big>)</big><a class="headerlink" href="#Modified" title="Permalink to this definition">¶</a></dt>
<dd><p>This returns the set of PlaceKeys of places whose tokens
were modified in any way.</p>
</dd></dl>
<p><strong>Free Functions</strong></p>
<dl class="function">
<dt id="Add:I.Marking:__MarkingR.PlaceKey.TokenType:I:CR">
void <tt class="descname">Add<I, Marking></tt><big>(</big>Marking& <em>m</em>, PlaceKey <em>place</em>, const TokenType<I>& <em>token</em><big>)</big><a class="headerlink" href="#Add:I.Marking:__MarkingR.PlaceKey.TokenType:I:CR" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a token to the container at a place. The size_t constant <cite>I</cite> specifies
the layer. This is a free function.</p>
</dd></dl>
<dl class="function">
<dt id="Remove:I.Marking.RNG:__MarkingR.PlaceKey.s.RNGR">
void <tt class="descname">Remove<I, Marking, RNG></tt><big>(</big>Marking& <em>m</em>, PlaceKey <em>place</em>, size_t <em>cnt</em>, RNG& <em>rng</em><big>)</big><a class="headerlink" href="#Remove:I.Marking.RNG:__MarkingR.PlaceKey.s.RNGR" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove <cite>cnt</cite> number of tokens from the marking at <cite>place</cite> in layer <cite>I.</cite>
If there are more than <cite>cnt</cite> tokens at the place, then this uses the random
number generator, <cite>rng,</cite> to select tokens.</p>
</dd></dl>
<dl class="function">
<dt id="Length:I.Marking:__MarkingR.PlaceKey">
size_t <tt class="descname">Length<I, Marking></tt><big>(</big>Marking& <em>m</em>, PlaceKey <em>place</em><big>)</big><a class="headerlink" href="#Length:I.Marking:__MarkingR.PlaceKey" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the number of tokens at a place.</p>
</dd></dl>
<dl class="function">
<dt id="Get:I.Marking.F:__MarkingCR.PlaceKey.FCR">
std::tuple<F::result_type, bool> <tt class="descname">Get<I, Marking, F></tt><big>(</big>const Marking& <em>m</em>, PlaceKey <em>place</em>, const F& <em>functor</em><big>)</big><a class="headerlink" href="#Get:I.Marking.F:__MarkingCR.PlaceKey.FCR" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply a functor to the first token at <cite>place.</cite> Return a tuple with
a) whether there was any token at the place and b) the result of the functor
if there was.</p>
</dd></dl>
<dl class="function">
<dt id="Move:I.J.Marking:__MarkingCR.PlaceKey.PlaceKey.s">
void <tt class="descname">Move<I, J, Marking></tt><big>(</big>const Marking& <em>m</em>, PlaceKey <em>place_from</em>, PlaceKey <em>place_to</em>, size_t <em>count</em><big>)</big><a class="headerlink" href="#Move:I.J.Marking:__MarkingCR.PlaceKey.PlaceKey.s" title="Permalink to this definition">¶</a></dt>
<dd><p>Move <cite>count</cite> number of tokens from <cite>place_from</cite> in layer
<cite>I</cite> to <cite>place_to</cite> in layer <cite>J</cite>.</p>
</dd></dl>
<dl class="function">
<dt id="Move:I.J.Marking.Modifier:__MarkingCR.PlaceKey.PlaceKey.s.ModifierCR">
void <tt class="descname">Move<I, J, Marking, Modifier></tt><big>(</big>const Marking& <em>m</em>, PlaceKey <em>place_from</em>, PlaceKey <em>place_to</em>, size_t <em>count</em>, const Modifier& <em>modify</em><big>)</big><a class="headerlink" href="#Move:I.J.Marking.Modifier:__MarkingCR.PlaceKey.PlaceKey.s.ModifierCR" title="Permalink to this definition">¶</a></dt>
<dd><p>Move <cite>count</cite> number of tokens from <cite>place_from</cite> in layer
<cite>I</cite> to <cite>place_to</cite> in layer <cite>J</cite>. Additionally apply the functor <cite>modify</cite>
to each moved token.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<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="distributions.html" title="Continuous Distributions Reference"
>next</a> |</li>
<li class="right" >
<a href="reference.html" title="Semi-Markov Library Reference"
>previous</a> |</li>
<li><a href="index.html">Semi-Markov 1.0 documentation</a> »</li>
<li><a href="reference.html" >Semi-Markov Library Reference</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2014, Andrew Dolgert, David Schneider.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>