y_nelson 2.3.6 → 2.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d87d07882b70f11a57acb5b1c5380353bcfd599
4
- data.tar.gz: 1812d1b077531e683a56ef47ced2df71078c481e
3
+ metadata.gz: 3d8ae630804969be734da51a5b79f46d4ecca69b
4
+ data.tar.gz: 56a6b0a5c3271882bfd872c4c99de8046703c105
5
5
  SHA512:
6
- metadata.gz: b4157b917e486f2ad9c14ed9a5f08e76d554270586d49cd4b71e993c010ccc5a704ed9df694e69d44ddbf0f4989e393618488987fd1be714a2df4132901e4a27
7
- data.tar.gz: 0d36ee17ed8aca298ff2355968644ff8116bdad4b3d37e0745b34bed1d07adaa78bb14de843858cdacf351a8bbae3c910304926639034613127bcec195c71073
6
+ metadata.gz: f8db0f66ffda5c2e43dd179b5f7d2360a67c4662f578ed165a29eadacee87ac07d72f5052229e884f070872402aeb791a4e5d69cfd6af83432ef79521b56181a
7
+ data.tar.gz: 3d571c38e86c48b3c5f0b881406821c25d858c5c03826c51bcee5b0f036f417eda6a3a6fa80e862ce74d2cef71d919bba9edde88c9edc531049fb0182180a4de
@@ -1,5 +1,5 @@
1
- #LyX 2.0 created this file. For more info see http://www.lyx.org/
2
- \lyxformat 413
1
+ #LyX 2.1 created this file. For more info see http://www.lyx.org/
2
+ \lyxformat 474
3
3
  \begin_document
4
4
  \begin_header
5
5
  \textclass article
@@ -12,13 +12,13 @@
12
12
  \font_roman default
13
13
  \font_sans default
14
14
  \font_typewriter default
15
+ \font_math auto
15
16
  \font_default_family default
16
17
  \use_non_tex_fonts false
17
18
  \font_sc false
18
19
  \font_osf false
19
20
  \font_sf_scale 100
20
21
  \font_tt_scale 100
21
-
22
22
  \graphics default
23
23
  \default_output_format default
24
24
  \output_sync 0
@@ -29,15 +29,24 @@
29
29
  \use_hyperref false
30
30
  \papersize default
31
31
  \use_geometry true
32
- \use_amsmath 1
33
- \use_esint 1
34
- \use_mhchem 1
35
- \use_mathdots 1
36
- \cite_engine natbib_authoryear
32
+ \use_package amsmath 1
33
+ \use_package amssymb 1
34
+ \use_package cancel 1
35
+ \use_package esint 1
36
+ \use_package mathdots 1
37
+ \use_package mathtools 1
38
+ \use_package mhchem 1
39
+ \use_package stackrel 1
40
+ \use_package stmaryrd 1
41
+ \use_package undertilde 1
42
+ \cite_engine natbib
43
+ \cite_engine_type authoryear
44
+ \biblio_style plainnat
37
45
  \use_bibtopic false
38
46
  \use_indices false
39
47
  \paperorientation portrait
40
48
  \suppress_date false
49
+ \justification true
41
50
  \use_refstyle 0
42
51
  \index Index
43
52
  \shortcut idx
@@ -124,11 +133,11 @@ Variables and constants
124
133
  \begin_layout Standard
125
134
  In Ruby, everything
126
135
  \begin_inset Foot
127
- status collapsed
136
+ status open
128
137
 
129
138
  \begin_layout Plain Layout
130
139
  Almost everything.
131
- Non-object include eg.
140
+ Non-objects include eg.
132
141
  variables or argument fields.
133
142
  \end_layout
134
143
 
@@ -2906,14 +2915,8 @@ YNelson
2906
2915
  YPetri
2907
2916
  \family default
2908
2917
  domain model is parametrized subclassing.
2909
- Literature on the topic does exist
2910
- \begin_inset CommandInset citation
2911
- LatexCommand citep
2912
- key "Roberts1996efp"
2913
-
2914
- \end_inset
2915
-
2916
- , but again, the concept is best explained on examples:
2918
+ Literature on the topic does exist, but the concept is best explained on
2919
+ examples:
2917
2920
  \end_layout
2918
2921
 
2919
2922
  \begin_layout LyX-Code
@@ -3258,20 +3261,5 @@ Convenience methods are especially suited for non-reusable code, but their
3258
3261
  use may sometimes be efficient also in reusable code.
3259
3262
  \end_layout
3260
3263
 
3261
- \begin_layout LyX-Code
3262
-
3263
- \end_layout
3264
-
3265
- \begin_layout LyX-Code
3266
- \begin_inset CommandInset bibtex
3267
- LatexCommand bibtex
3268
- bibfiles "/home/boris/b/5ced/ced"
3269
- options "plainnat"
3270
-
3271
- \end_inset
3272
-
3273
-
3274
- \end_layout
3275
-
3276
3264
  \end_body
3277
3265
  \end_document
@@ -1,5 +1,5 @@
1
- #LyX 2.0 created this file. For more info see http://www.lyx.org/
2
- \lyxformat 413
1
+ #LyX 2.1 created this file. For more info see http://www.lyx.org/
2
+ \lyxformat 474
3
3
  \begin_document
4
4
  \begin_header
5
5
  \textclass article
@@ -12,13 +12,13 @@
12
12
  \font_roman default
13
13
  \font_sans default
14
14
  \font_typewriter default
15
+ \font_math auto
15
16
  \font_default_family default
16
17
  \use_non_tex_fonts false
17
18
  \font_sc false
18
19
  \font_osf false
19
20
  \font_sf_scale 100
20
21
  \font_tt_scale 100
21
-
22
22
  \graphics default
23
23
  \default_output_format default
24
24
  \output_sync 0
@@ -29,15 +29,24 @@
29
29
  \use_hyperref false
30
30
  \papersize default
31
31
  \use_geometry true
32
- \use_amsmath 1
33
- \use_esint 1
34
- \use_mhchem 1
35
- \use_mathdots 1
36
- \cite_engine natbib_authoryear
32
+ \use_package amsmath 1
33
+ \use_package amssymb 1
34
+ \use_package cancel 1
35
+ \use_package esint 1
36
+ \use_package mathdots 1
37
+ \use_package mathtools 1
38
+ \use_package mhchem 1
39
+ \use_package stackrel 1
40
+ \use_package stmaryrd 1
41
+ \use_package undertilde 1
42
+ \cite_engine natbib
43
+ \cite_engine_type authoryear
44
+ \biblio_style plainnat
37
45
  \use_bibtopic false
38
46
  \use_indices false
39
47
  \paperorientation portrait
40
48
  \suppress_date false
49
+ \justification true
41
50
  \use_refstyle 0
42
51
  \index Index
43
52
  \shortcut idx
@@ -76,40 +85,30 @@ Introduction
76
85
  This document is a hands-on guide to
77
86
  \family typewriter
78
87
  \color blue
79
- YNelson
88
+ YPetri
80
89
  \family default
81
90
  \color inherit
82
91
  ,
92
+ \family typewriter
93
+ \color blue
94
+ YNelson
95
+ \family default
96
+ \color inherit
97
+ and
83
98
  \emph on
84
99
  \color green
85
100
  Nelson nets
86
101
  \emph default
87
102
  \color inherit
88
- and, partially,
103
+ , which in turn rely on
89
104
  \color red
90
105
  Ruby
91
106
  \color inherit
92
107
  language.
93
- It is not assumed that the reader is familiar with any of these, though
94
- familiarity with Ruby syntax would be an advantage.
95
- This document can at the same time serve as a guide to
96
- \family typewriter
97
- \color blue
98
- YPetri
99
- \family default
100
- \color inherit
101
- , which is one of the two main components of
102
- \family typewriter
103
- YNelson
104
- \family default
105
- , and which caters solely to the concerns of Petri net-based modelling of
106
- dynamical systems.
107
-
108
- \end_layout
109
-
110
- \begin_layout Standard
111
- If you have never heard about Nelson nets, do not wonder: it is a semi-novel
112
- concept based on
108
+ It is not assumed you are familiar with Ruby, you can follow this guide
109
+ even if you never heard about it (but you will have to install it).
110
+ You more than likely never heard about Nelson nets.
111
+ Nelson net is a novel concept of
113
112
  \emph on
114
113
  \color green
115
114
  Petri nets
@@ -122,15 +121,10 @@ ZZ structures
122
121
  \emph default
123
122
  \color inherit
124
123
  .
125
- If you follow this guide closely, you will receive a concise and efficient
126
- introduction to each of these three.
127
- (Remark:
128
- \emph on
129
- only the Petri net aspect defined by YPetri is covered in this version
130
- of this guide.
131
- ZZ structure aspect will be covered in the future versions of this manual.)
132
- \emph default
133
- Newly introduced
124
+ Do not worry about them: just follow the guide and you will learn everything
125
+ in time.
126
+ The text of this guide lets you know when new keywords and are introduced.
127
+ When mentioned for the first time,
134
128
  \color red
135
129
  Ruby keywords and terms
136
130
  \color inherit
@@ -141,7 +135,7 @@ Petri net terms
141
135
  in green, and
142
136
  \family typewriter
143
137
  \color blue
144
- YNelson
138
+ YPetri / YNelson
145
139
  \family default
146
140
  keywords and terms
147
141
  \color inherit
@@ -155,8 +149,7 @@ YNelson
155
149
  YNelson
156
150
  \family default
157
151
  \color inherit
158
- is a domain model and a simulator of Nelson nets, a specific universal
159
- type of
152
+ serves to specify and simulate Nelson nets, a derivative of
160
153
  \emph on
161
154
  \color green
162
155
  functional
@@ -166,40 +159,56 @@ functional
166
159
  Petri nets
167
160
  \emph default
168
161
  \color inherit
169
- living in a
162
+ that live in
170
163
  \emph on
171
164
  \color green
172
165
  ZZ space
173
166
  \emph default
174
167
  \color inherit
175
168
  .
176
-
169
+ (You don't need to worry about ZZ space yet.)
170
+ \family typewriter
171
+ \color blue
172
+ YPetri
173
+ \family default
174
+ \color inherit
175
+ serves to specify and simulate Petri nets.
176
+ Petri nets are one of the basic formalisms in systems simulation.
177
+ I designed
178
+ \family typewriter
179
+ YPetri
180
+ \family default
181
+ and
177
182
  \family typewriter
178
183
  YNelson
179
184
  \family default
180
- is designed for the purpose of modelling and simulation of dynamical systems,
181
- especially biochemical systems.
182
- Modelling dynamical systems (including biochemical systems) is one of the
183
- typical applications of Petri nets.
184
- For a review of the various flavors of Petri nets used in modelling biochemical
185
- systems, see eg.
186
-
185
+ because I needed to specify biochemical systems and I believed a Ruby DSL
186
+ would be ideal for that task.
187
+ Use of Petri nets for specifying biochemical systems is reviewed eg.
188
+ in
187
189
  \begin_inset CommandInset citation
188
190
  LatexCommand citet
189
191
  key "Bos2008mbs"
190
192
 
193
+ \end_inset
194
+
195
+ and
196
+ \begin_inset CommandInset citation
197
+ LatexCommand citet
198
+ key "Koch2015pns"
199
+
191
200
  \end_inset
192
201
 
193
202
  .
194
203
 
195
204
  \family typewriter
196
- YNelson
205
+ YPetri
197
206
  \family default
198
- introduces its own universal Petri net type, which is similar, but not
199
- identical with
207
+ provides a universal Petri net abstraction similar, but not identical with
208
+
200
209
  \emph on
201
210
  \color green
202
- hybrid functional Petri nets (HFPN)
211
+ hybrid functional Petri net (HFPN)
203
212
  \emph default
204
213
  \color inherit
205
214
  introduced by
@@ -210,132 +219,103 @@ key "Matsuno2011brs"
210
219
  \end_inset
211
220
 
212
221
  .
213
- This universal Petri net is defined in
222
+
214
223
  \family typewriter
215
224
  YPetri
216
225
  \family default
217
- gem, on which
226
+ /
218
227
  \family typewriter
219
228
  YNelson
220
229
  \family default
221
- is based, and it purports to provide a universal Petri net abstraction
222
- and a DSL to rule them all and in Ruby bind them.
230
+ serve equally well not just for biochemical systems, but for arbitrary
231
+ dynamical systems.
223
232
  \end_layout
224
233
 
225
234
  \begin_layout Standard
226
-
235
+ Finally, please forgive me for taking your time with this guide.
236
+ If you want to seriously work with
237
+ \emph on
238
+ complicated
239
+ \emph default
240
+ Petri Nets, no tool can avoid taking you through the process of learning
241
+ the language and the tool's interface.
242
+ Visual Petri net modelling tools are nice for simple tasks, such as drawing
243
+ arcs between places and transitions, but you need text anyway to write
244
+ the mathematical functions that govern firing of transitions.
245
+
227
246
  \family typewriter
228
- YNelson
247
+ YPetri
229
248
  \family default
230
- (and
249
+ /
231
250
  \family typewriter
232
- YPetri
251
+ YNelson
233
252
  \family default
234
- ) is implemented as an
235
- \emph on
236
- \color red
237
- internal domain-specific language (DSL)
238
- \emph default
239
- \color inherit
240
- in
253
+ are all textual without commiting the sin of introducing a new programming
254
+ language.
255
+ They are implemented as
241
256
  \emph on
242
257
  \color red
243
- Ruby programming language
258
+ internal domain-specific languages (DSL)
244
259
  \emph default
245
260
  \color inherit
246
- , which you can use in scripts, or access interactively from
261
+ using Ruby as a host language.
262
+ You can run them interactively from
247
263
  \color red
248
- inferior Ruby interpreter (
264
+ Ruby interpreter (
249
265
  \emph on
250
266
  irb
251
267
  \emph default
252
268
  )
253
269
  \color inherit
254
270
  .
255
- It is publicly available as
256
- \emph on
257
- \color blue
258
-
259
- \begin_inset CommandInset href
260
- LatexCommand href
261
- name "y_nelson gem"
262
- target "https://rubygems.org/gems/y_nelson"
263
-
264
- \end_inset
271
+ In this way, you can freely use the host language to automate your interaction
272
+ with Petri nets.
273
+ \end_layout
265
274
 
275
+ \begin_layout Standard
266
276
 
267
- \emph default
268
- \color inherit
269
- (
270
- \emph on
271
- \color red
272
- gem
273
- \emph default
274
- \color inherit
275
- = Ruby library).
276
-
277
277
  \family typewriter
278
- YNelson
279
- \family default
280
- belongs to a series of Ruby gems (
281
- \family typewriter
282
- \color blue
283
-
284
- \begin_inset CommandInset href
285
- LatexCommand href
286
- name "YPetri"
287
- target "https://rubygems.org/gems/y_petri"
288
-
289
- \end_inset
290
-
291
-
278
+ YPetri
292
279
  \family default
293
- \color inherit
294
- ,
280
+ /
295
281
  \family typewriter
296
282
  YNelson
297
283
  \family default
298
- ,
299
- \family typewriter
300
- \color blue
301
- YChem
302
- \family default
303
- \color inherit
304
- ,
305
- \family typewriter
306
- \color blue
307
- YCell
308
- \family default
309
- \color inherit
310
- ,
311
- \family typewriter
284
+ are publicly available as
285
+ \emph on
312
286
  \color blue
313
287
 
314
288
  \begin_inset CommandInset href
315
289
  LatexCommand href
316
- name "Yzz"
317
- target "https://rubygems.org/gems/yzz"
290
+ name "y_petri"
291
+ target "https://rubygems.org/gems/y_petri"
318
292
 
319
293
  \end_inset
320
294
 
321
295
 
322
- \family default
296
+ \emph default
323
297
  \color inherit
324
- , metrology library
325
- \family typewriter
298
+ and
299
+ \emph on
326
300
  \color blue
327
301
 
328
302
  \begin_inset CommandInset href
329
303
  LatexCommand href
330
- name "SY"
331
- target "https://rubygems.org/gems/sy"
304
+ name "y_nelson gem"
305
+ target "https://rubygems.org/gems/y_nelson"
332
306
 
333
307
  \end_inset
334
308
 
335
309
 
336
- \family default
310
+ \emph default
337
311
  \color inherit
338
- ...), whose design intent is to bring ergonomy into biochemical modelling.
312
+ gems (
313
+ \emph on
314
+ \color red
315
+ gem
316
+ \emph default
317
+ \color inherit
318
+ = Ruby library).
339
319
 
340
320
  \family typewriter
341
321
  YNelson
@@ -348,68 +328,32 @@ YPetri
348
328
  \family typewriter
349
329
  Yzz
350
330
  \family default
351
- gems, its usage together with
331
+ gems, which in turn depend on our
352
332
  \family typewriter
353
- SY
333
+ YSupport
354
334
  \family default
355
- might be desirable when dealing with physical units.
356
- At the time of writing this text,
335
+ gem.
336
+ Splitting the more general concerns to multiple gem is a desirable feature
337
+ – separation of concerns is a maxim of good software engineering.
338
+ I also separated dealing with physical units in your models out into
357
339
  \family typewriter
358
- YNelson
340
+ SY
359
341
  \family default
360
- was the only publicly available internal DSL for modelling dynamic systems
361
- in Ruby.
362
- DSLs designed for the purpose of modelling are known from other languages,
363
- but they are generally
342
+ gem (
364
343
  \emph on
365
- \color red
366
- external
367
- \emph default
368
- \color inherit
369
- , not internal DSLs.
370
- They are sometimes denoted as domain-specific modeling languages (DSML),
371
- a term which also applies to
372
- \family typewriter
373
- YNelson
374
- \family default
375
- .
376
- \end_layout
344
+ \color blue
345
+
346
+ \begin_inset CommandInset href
347
+ LatexCommand href
348
+ name "sy"
349
+ target "https://rubygems.org/gems/sy"
350
+
351
+ \end_inset
352
+
377
353
 
378
- \begin_layout Standard
379
- All in all, if you want to seriously work with
380
- \emph on
381
- complicated
382
354
  \emph default
383
- Petri Nets, no tool can avoid taking you through the process of learning
384
- the language of the tool's interface.
385
- This language can be visual only partially.
386
- GUI Petri net modelling tools can provide visual commands for simple tasks,
387
- such as creating places and transitions, or drawing arcs between them,
388
- but a textual language is needed anyway for more complex tasks, such as
389
- writing mathematical functions that govern firing of transitions, or managing
390
- the Petri net in an automated manner.
391
-
392
- \family typewriter
393
- YNelson
394
- \family default
395
- is all textual, but it does not introduce its own language.
396
- It relies on powerful and intuitive syntax of a widely adopted general-purpose
397
- computer language – Ruby.
398
-
399
- \family typewriter
400
- YNelson
401
- \family default
402
- is open source and leverages on the freedom and respect for the user inherent
403
- to its host language, whose role in making
404
- \family typewriter
405
- YNelson
406
- \family default
407
- good can hardly be overstated.
408
- Possible bugs or missing features will never get you as a
409
- \family typewriter
410
- YNelson
411
- \family default
412
- user in a dead end situation.
355
+ \color inherit
356
+ ).
413
357
  \end_layout
414
358
 
415
359
  \begin_layout Part*
@@ -502,7 +446,11 @@ That's it.
502
446
  very
503
447
  \emph default
504
448
  difficult at first, but stick with it.
505
- It seems stupidly obvious, but, if you have a problem installing
449
+ It seems stupidly obvious, but if you have a problem installing
450
+ \family typewriter
451
+ YPetri
452
+ \family default
453
+ and
506
454
  \family typewriter
507
455
  YNelson
508
456
  \family default
@@ -540,7 +488,7 @@ Prerequisites
540
488
  \end_layout
541
489
 
542
490
  \begin_layout Standard
543
- Most importantly, you will need a working installation of Ruby 1.9 on your
491
+ Firstly, you will need a working installation of Ruby 2.3 or later on your
544
492
  computer.
545
493
  Once this condition is met, basic
546
494
  \family typewriter
@@ -559,6 +507,11 @@ gem install y_nelson
559
507
  \end_inset
560
508
 
561
509
  in the command prompt.
510
+ This will install most other dependencies, such as
511
+ \family typewriter
512
+ YPetri
513
+ \family default
514
+ .
562
515
  However,
563
516
  \family typewriter
564
517
  YNelson
@@ -631,16 +584,10 @@ require
631
584
  include
632
585
  \family default
633
586
  ' statements before each of the usage examples written below.
634
- Also, please notice that this guide itself is alpha stage, so the actual
635
-
636
- \family typewriter
637
- YNelson
638
- \family default
639
- version you will be using may somewhat differ from this guide.
640
- Also, the nucleotide metabolism model in Example 3 is yet to be tuned to
641
- be realistic.
587
+ The nucleotide metabolism model in Example 3 is not realiscit (its kinetics
588
+ is not precise).
642
589
  If something in this guide does not work, please do not hesitate to notify
643
- us, we will appreciate your feedback.
590
+ me, I will appreciate your feedback.
644
591
  \end_layout
645
592
 
646
593
  \begin_layout Part*
@@ -653,7 +600,7 @@ This example is a gentle introduction to Petri net terminology,
653
600
  YNelson
654
601
  \family default
655
602
  DSL terminology, and Ruby syntax.
656
- The most basic capability, that
603
+ The most basic capability that
657
604
  \family typewriter
658
605
  YNelson
659
606
  \family default
@@ -2000,7 +1947,24 @@ Example II: Convenience
2000
1947
  \end_layout
2001
1948
 
2002
1949
  \begin_layout Standard
2003
- So far, we have seen only one
1950
+ So far, to avoid confusing you, I used fairly conservative syntax.
1951
+
1952
+ \family typewriter
1953
+ YNelson
1954
+ \family default
1955
+ can do better than that.
1956
+ For convenience, many long keywords have short aliases.
1957
+ Frequently used syntactic constructs usually have shorter way of expressing
1958
+ the same.
1959
+ \end_layout
1960
+
1961
+ \begin_layout Standard
1962
+ As you have seen, in
1963
+ \family typewriter
1964
+ YNelson
1965
+ \family default
1966
+ one often uses transition constructors.
1967
+ Thus far, we have seen only one
2004
1968
  \emph on
2005
1969
  constructor method
2006
1970
  \emph default
@@ -2049,14 +2013,18 @@ YNelson::Transition
2049
2013
  \end_layout
2050
2014
 
2051
2015
  \begin_layout Standard
2052
- Use of whole words in the constructor method makes the
2016
+ Using long keywords in the constructor method makes the
2053
2017
  \family typewriter
2054
2018
  YNelson
2055
2019
  \family default
2056
- DSL very explicit.
2057
- But for the cases, where trading readability for brevity is desirable,
2058
- these syntactic constructs can be shortened.
2059
- Actually, we have already used this convenience in the earlier examples.
2020
+ code easy to read.
2021
+ But for the cases where trading readability for brevity is desirable, such
2022
+ as when you are playing with YNelson inside
2023
+ \emph on
2024
+ irb
2025
+ \emph default
2026
+ session, you will appreciate convenience.
2027
+ Actually, we already used syntactic shorthands in the earlier examples.
2060
2028
  We didn't type :
2061
2029
  \end_layout
2062
2030
 
@@ -2069,7 +2037,15 @@ A2B
2069
2037
  \begin_inset Quotes erd
2070
2038
  \end_inset
2071
2039
 
2072
- , codomain: [A, B], stoichiometry: [-1, 1] )
2040
+ ,
2041
+ \end_layout
2042
+
2043
+ \begin_layout LyX-Code
2044
+ codomain: [A, B],
2045
+ \end_layout
2046
+
2047
+ \begin_layout LyX-Code
2048
+ stoichiometry: [-1, 1] )
2073
2049
  \end_layout
2074
2050
 
2075
2051
  \begin_layout LyX-Code
@@ -2085,33 +2061,35 @@ A2B = Transition( stoichiometry: { A: -1, B: 1 } )
2085
2061
  \end_layout
2086
2062
 
2087
2063
  \begin_layout Standard
2088
- Even shorter way to express the same would be:
2064
+ Just so you know, the above shorthand is not easy to program in Ruby.
2065
+ When designing
2066
+ \family typewriter
2067
+ YNelson
2068
+ \family default
2069
+ , I took a lot of pain for your convenience.
2070
+ Even shorter way to express the same would be:
2089
2071
  \end_layout
2090
2072
 
2091
2073
  \begin_layout LyX-Code
2092
- A2B = Transition s: { A: -1, B: 1 }
2074
+ A2B = Transition
2075
+ \color blue
2076
+ s
2077
+ \color inherit
2078
+ : { A: -1, B: 1 }
2093
2079
  \end_layout
2094
2080
 
2095
2081
  \begin_layout Standard
2096
- The above is a timeless transition.
2097
- But we could think eg.
2098
- about a more complicated transition, that would transfer tokens from
2099
- \family typewriter
2100
- B
2101
- \family default
2102
- to
2082
+ The above is a very simple timeless transition that just takes one token
2083
+ from
2103
2084
  \family typewriter
2104
2085
  A
2105
2086
  \family default
2106
- with rate depending on the square root of the product of marking of
2107
- \family typewriter
2108
- C
2109
- \family default
2110
- and
2087
+ and puts it into
2111
2088
  \family typewriter
2112
- D
2089
+ B
2113
2090
  \family default
2114
2091
  .
2092
+ (Constructor convenience is even more powerful for complex transitions.)
2115
2093
  Start a new
2116
2094
  \family typewriter
2117
2095
  irb
@@ -2128,163 +2106,127 @@ include YNelson
2128
2106
  \end_layout
2129
2107
 
2130
2108
  \begin_layout LyX-Code
2131
- A = Place( default_marking: 5 )
2109
+ A = Place
2110
+ \color blue
2111
+ default_marking
2112
+ \color inherit
2113
+ : 5
2132
2114
  \end_layout
2133
2115
 
2134
- \begin_layout LyX-Code
2135
- B = Place m!: 5 # notice
2136
- \begin_inset Quotes eld
2137
- \end_inset
2138
-
2116
+ \begin_layout Standard
2117
+ Constantly typing
2118
+ \family typewriter
2119
+ default_marking
2120
+ \family default
2121
+ is tiresome.
2122
+ Shorter way to say the same is by using the alias
2123
+ \family typewriter
2124
+ \color blue
2139
2125
  m!
2140
- \begin_inset Quotes erd
2141
- \end_inset
2142
-
2143
- alias for
2144
- \begin_inset Quotes eld
2145
- \end_inset
2146
-
2147
- default marking
2148
- \begin_inset Quotes erd
2149
- \end_inset
2150
-
2151
-
2126
+ \family default
2127
+ \color inherit
2128
+ of the same:
2152
2129
  \end_layout
2153
2130
 
2154
2131
  \begin_layout LyX-Code
2155
- C = Place m!: 1
2132
+ B = Place m!: 5
2156
2133
  \end_layout
2157
2134
 
2158
2135
  \begin_layout LyX-Code
2159
- D = Place m!: 1
2160
- \end_layout
2161
-
2162
- \begin_layout Standard
2163
- Let's check our work:
2164
- \end_layout
2165
-
2166
- \begin_layout LyX-Code
2167
- places.map &:marking
2136
+ C = Place m!: 1
2168
2137
  \end_layout
2169
2138
 
2170
2139
  \begin_layout LyX-Code
2171
- #=> [5, 5, 1, 1]
2140
+ D = Place m!: 1
2172
2141
  \end_layout
2173
2142
 
2174
2143
  \begin_layout Standard
2175
- Indeed, the net state has been set according to the default markings of
2176
- the places.
2177
- Now let's define the transition we want:
2178
- \end_layout
2179
-
2180
- \begin_layout LyX-Code
2181
- B2A = Transition( stoichiometry: { B: -1, A: 1 },
2182
- \end_layout
2183
-
2184
- \begin_layout LyX-Code
2185
- domain: [C, D],
2144
+ Let's check the net's marking vector now:
2186
2145
  \end_layout
2187
2146
 
2188
2147
  \begin_layout LyX-Code
2189
- rate: lambda { |x, y| ( x * y ) ** 0.5 } )
2190
- \end_layout
2191
-
2192
- \begin_layout LyX-Code
2193
- #=> B2A
2148
+ places.map &:marking #=> [5, 5, 1, 1]
2194
2149
  \end_layout
2195
2150
 
2196
2151
  \begin_layout Standard
2197
- To prove that it works, let's fire it for 0.1 time units:
2198
- \end_layout
2199
-
2200
- \begin_layout LyX-Code
2201
- B2A.fire! 0.1
2202
- \end_layout
2203
-
2204
- \begin_layout LyX-Code
2205
- #=> nil
2206
- \end_layout
2207
-
2208
- \begin_layout LyX-Code
2209
- places.map &:marking
2152
+ If you typed everything correctly, you should see the above result.
2153
+ Shorter way to ask for the same information is:
2210
2154
  \end_layout
2211
2155
 
2212
2156
  \begin_layout LyX-Code
2213
- #=> [5.1, 4.9, 1, 1]
2157
+ net.marking #=> [5, 5, 1, 1]
2214
2158
  \end_layout
2215
2159
 
2216
2160
  \begin_layout Standard
2217
- You can try to change marking of C and D to control the rate:
2161
+ Even shorter way to say the same is:
2218
2162
  \end_layout
2219
2163
 
2220
2164
  \begin_layout LyX-Code
2221
- [A, B].each &:
2165
+ net.
2222
2166
  \color blue
2223
- reset_marking
2167
+ m
2168
+ \color inherit
2169
+ #=> [5, 5, 1, 1]
2224
2170
  \end_layout
2225
2171
 
2226
- \begin_layout LyX-Code
2227
- C.marking = 4
2172
+ \begin_layout Standard
2173
+ Now let's define the transition we want:
2228
2174
  \end_layout
2229
2175
 
2230
2176
  \begin_layout LyX-Code
2231
- D.marking = 9
2177
+ B2A = Transition( stoichiometry: { B: -1, A: 1 },
2232
2178
  \end_layout
2233
2179
 
2234
2180
  \begin_layout LyX-Code
2235
- places.map &:marking
2181
+ domain: [C, D],
2236
2182
  \end_layout
2237
2183
 
2238
2184
  \begin_layout LyX-Code
2239
- #=> [5, 5, 4, 9]
2185
+ rate: lambda { |x, y| ( x * y ) ** 0.5 } )
2240
2186
  \end_layout
2241
2187
 
2242
- \begin_layout LyX-Code
2243
- B2A.fire! 0.1
2188
+ \begin_layout Standard
2189
+ To prove that it works, let's fire it for 0.1 time units:
2244
2190
  \end_layout
2245
2191
 
2246
2192
  \begin_layout LyX-Code
2247
- places.map &:marking
2193
+ B2A.fire! 0.1 #=> nil
2248
2194
  \end_layout
2249
2195
 
2250
2196
  \begin_layout LyX-Code
2251
- #=> [5.6, 4.4, 4, 9]
2197
+ net.m #=> [5.1, 4.9, 1, 1]
2252
2198
  \end_layout
2253
2199
 
2254
2200
  \begin_layout Standard
2255
- We can see that the rate of
2256
- \family typewriter
2257
- B2A
2258
- \family default
2259
- has risen 6 times as expected (4 * 9 is 36), so
2260
- \family typewriter
2261
- B2A
2262
- \family default
2263
- works.
2264
- The question is, could we have written
2201
+ Can we express its constructor more concisely? The answer is yes.
2202
+
2265
2203
  \family typewriter
2266
2204
  B2A
2267
2205
  \family default
2268
- more concisely? For
2206
+ is a
2269
2207
  \family typewriter
2270
2208
  TS
2271
2209
  \family default
2272
- transitions (check
2210
+ transition (check
2273
2211
  \family typewriter
2274
2212
  B2A.type
2275
2213
  \family default
2276
- to make sure that it's a
2214
+ to make sure it is true), and for
2277
2215
  \family typewriter
2278
2216
  TS
2279
2217
  \family default
2280
- transition),
2218
+ transitions,
2281
2219
  \family typewriter
2282
2220
  \color blue
2283
2221
  TS()
2284
2222
  \family default
2285
2223
  \color inherit
2286
- constructor is available, allowing to express the same transition with
2287
- a shorter syntactic construct:
2224
+ convenience constructor is available.
2225
+ With
2226
+ \family typewriter
2227
+ TS()
2228
+ \family default
2229
+ constructor, the definition of B2A would be much shorter:
2288
2230
  \end_layout
2289
2231
 
2290
2232
  \begin_layout LyX-Code
@@ -2292,31 +2234,22 @@ B2A = TS domain: [C, D], A: 1, B: -1 do |x, y| ( x * y ) ** 0.5 end
2292
2234
  \end_layout
2293
2235
 
2294
2236
  \begin_layout Standard
2295
- Restart the
2296
- \family typewriter
2297
- irb
2298
- \family default
2299
- session again and use this shorter construct to see that the resulting
2300
- transition behaves like before.
2301
- Note the
2237
+ Note the
2302
2238
  \family typewriter
2303
2239
  \color red
2304
2240
  do ...
2305
2241
  end
2306
2242
  \family default
2307
2243
  \color inherit
2308
- part of the construct: Using lambda syntax, it defines the rate function
2244
+ part in the above line: Using lambda syntax, it defines the rate function
2309
2245
  of the transition.
2310
- \end_layout
2311
-
2312
- \begin_layout Standard
2313
- One more convenience constructor I want to mention here is
2246
+ Another convenience constructor worth mentioning is
2314
2247
  \family typewriter
2315
2248
  \color blue
2316
2249
  AT()
2317
2250
  \family default
2318
2251
  \color inherit
2319
- constructor for assignment transition.
2252
+ for assignment transition.
2320
2253
  Earlier, we defined:
2321
2254
  \end_layout
2322
2255
 
@@ -2325,11 +2258,11 @@ A_to_42 = Transition codomain: A, assignment: lambda { 42 }
2325
2258
  \end_layout
2326
2259
 
2327
2260
  \begin_layout Standard
2328
- This can be conveniently rewritten using
2261
+ Using
2329
2262
  \family typewriter
2330
2263
  AT()
2331
2264
  \family default
2332
- constructor as:
2265
+ constructor, we can shorten this to:
2333
2266
  \end_layout
2334
2267
 
2335
2268
  \begin_layout LyX-Code
@@ -2337,13 +2270,42 @@ A_to_42 = AT A do 42 end
2337
2270
  \end_layout
2338
2271
 
2339
2272
  \begin_layout Standard
2340
- In short, syntactic shorthands are less readable than full
2273
+ In short, syntactic shorthands can save a lot of typing.
2274
+ If you still miss some syntactic shorthand, feel free to define it on your
2275
+ own.
2276
+ For example, let us define a custom method named
2341
2277
  \family typewriter
2342
- Transition()
2278
+ Foo
2343
2279
  \family default
2344
- statements, but can save a lot of space and typing.
2345
- In any case, in Ruby, the user can easily defined new aliases and routines
2346
- that make the frequent tasks easier to type.
2280
+ that acts as a constructor of places with default marking.
2281
+ \end_layout
2282
+
2283
+ \begin_layout LyX-Code
2284
+
2285
+ \color red
2286
+ def
2287
+ \color inherit
2288
+ Foo( m )
2289
+ \end_layout
2290
+
2291
+ \begin_layout LyX-Code
2292
+ Place( default_marking: m )
2293
+ \end_layout
2294
+
2295
+ \begin_layout LyX-Code
2296
+ end
2297
+ \end_layout
2298
+
2299
+ \begin_layout Standard
2300
+ After this, you can define places with default marking with even less typing:
2301
+ \end_layout
2302
+
2303
+ \begin_layout LyX-Code
2304
+ X = Foo 42
2305
+ \end_layout
2306
+
2307
+ \begin_layout LyX-Code
2308
+ Y = Foo 43
2347
2309
  \end_layout
2348
2310
 
2349
2311
  \begin_layout Part*
@@ -2379,34 +2341,28 @@ TimedSimulation
2379
2341
  YNelson::Place
2380
2342
  \family default
2381
2343
  instances is irrelevant.
2382
- We just need to specify the initial state.
2383
- One way to do this is by specifying
2384
- \family typewriter
2385
- \color blue
2386
- :default_marking
2387
- \family default
2388
- \color inherit
2389
- named argument:
2344
+ We just need to specify the initial state eg.
2345
+ by specifying the default marking of the places:
2390
2346
  \end_layout
2391
2347
 
2392
2348
  \begin_layout LyX-Code
2393
- A = Place(
2394
- \color blue
2395
- default_marking:
2396
- \color inherit
2397
- 0.5 )
2349
+ require 'y_nelson'
2398
2350
  \end_layout
2399
2351
 
2400
2352
  \begin_layout LyX-Code
2401
- #=> A
2353
+ include YNelson
2402
2354
  \end_layout
2403
2355
 
2404
2356
  \begin_layout LyX-Code
2405
- B = Place( default_marking: 0.5 )
2357
+ A = Place
2358
+ \color blue
2359
+ m!:
2360
+ \color inherit
2361
+ 0.5
2406
2362
  \end_layout
2407
2363
 
2408
2364
  \begin_layout LyX-Code
2409
- #=> B
2365
+ B = Place m!: 0.5
2410
2366
  \end_layout
2411
2367
 
2412
2368
  \begin_layout Standard
@@ -2418,11 +2374,11 @@ A
2418
2374
  \end_layout
2419
2375
 
2420
2376
  \begin_layout LyX-Code
2421
- A_pump = Transition( stoichiometry: { A: -1 }, rate: proc { 0.005 } )
2422
- \end_layout
2423
-
2424
- \begin_layout LyX-Code
2425
- #=> A_pump
2377
+ A_pump = Transition s: { A: -1 }, rate:
2378
+ \color red
2379
+ proc
2380
+ \color inherit
2381
+ { 0.005 }
2426
2382
  \end_layout
2427
2383
 
2428
2384
  \begin_layout Standard
@@ -2440,18 +2396,14 @@ proc { 0.005 }
2440
2396
  A
2441
2397
  \family default
2442
2398
  .
2443
- You can notice, that this closure expects no arguments and always outputs
2399
+ You can notice that this closure expects no arguments and always outputs
2444
2400
  0.005 as its return value.
2445
2401
  It is the simplest possible way to write a constant function.
2446
2402
  For comparison,
2447
2403
  \end_layout
2448
2404
 
2449
2405
  \begin_layout LyX-Code
2450
- B_decay = Transition( stoichiometry: { B: -1 }, rate: 0.05 )
2451
- \end_layout
2452
-
2453
- \begin_layout LyX-Code
2454
- #=> B_decay
2406
+ B_decay = Transition s: { B: -1 }, rate: 0.05
2455
2407
  \end_layout
2456
2408
 
2457
2409
  \begin_layout Standard
@@ -2473,25 +2425,23 @@ net
2473
2425
  \end_layout
2474
2426
 
2475
2427
  \begin_layout LyX-Code
2476
- #=> #<Net: name: Top, 2 pp, 2 tt>
2428
+ #=> #<Net: name: Top, 2 places, 2 transitions>
2477
2429
  \end_layout
2478
2430
 
2479
2431
  \begin_layout Standard
2480
- We can execute this Petri net as
2432
+ We can execute this Petri net as a
2481
2433
  \family typewriter
2482
- TimedSimulation
2434
+ Simulation
2483
2435
  \family default
2484
- simply by typing:
2436
+ object simply by typing:
2485
2437
  \end_layout
2486
2438
 
2487
2439
  \begin_layout LyX-Code
2488
2440
 
2489
2441
  \color blue
2490
2442
  run!
2491
- \end_layout
2492
-
2493
- \begin_layout LyX-Code
2494
- #=> 60
2443
+ \color inherit
2444
+ #=> 60
2495
2445
  \end_layout
2496
2446
 
2497
2447
  \begin_layout Standard
@@ -2501,7 +2451,7 @@ run!
2501
2451
  \family default
2502
2452
  creates and executes a
2503
2453
  \family typewriter
2504
- TimedSimulation
2454
+ Simulation
2505
2455
  \family default
2506
2456
  instance.
2507
2457
  The return value is the simulation instance itself (see the inspect string
@@ -2542,11 +2492,7 @@ YNelson::Place
2542
2492
  \end_layout
2543
2493
 
2544
2494
  \begin_layout LyX-Code
2545
- places.map &:marking
2546
- \end_layout
2547
-
2548
- \begin_layout LyX-Code
2549
- #=> [0.5, 0.5]
2495
+ net.marking #=> [0.5, 0.5]
2550
2496
  \end_layout
2551
2497
 
2552
2498
  \begin_layout Standard
@@ -2562,8 +2508,7 @@ settings
2562
2508
  \end_layout
2563
2509
 
2564
2510
  \begin_layout LyX-Code
2565
- #=> {:method=>:pseudo_euler, :guarded=>false, :step=>0.1, :sampling=>5, :time=>0..6
2566
- 0}
2511
+ #=> {:method=>:basic, :guarded=>false, :step=>0.1, :sampling=>5, :time=>0..60}
2567
2512
  \end_layout
2568
2513
 
2569
2514
  \begin_layout Standard
@@ -2660,15 +2605,11 @@ gnuplot
2660
2605
  \begin_layout LyX-Code
2661
2606
 
2662
2607
  \color blue
2663
- recording.plot
2608
+ recording.plot
2664
2609
  \color inherit
2665
2610
  # plots a graph
2666
2611
  \end_layout
2667
2612
 
2668
- \begin_layout LyX-Code
2669
- #=> ""
2670
- \end_layout
2671
-
2672
2613
  \begin_layout Standard
2673
2614
  Previous command plots the default feature set, which is marking of the
2674
2615
  places.
@@ -2677,15 +2618,31 @@ Previous command plots the default feature set, which is marking of the
2677
2618
  \end_layout
2678
2619
 
2679
2620
  \begin_layout LyX-Code
2680
- recording.gradient.plot
2621
+ recording.
2622
+ \color blue
2623
+ gradient
2624
+ \color inherit
2625
+ .plot
2681
2626
  \end_layout
2682
2627
 
2683
2628
  \begin_layout LyX-Code
2684
- recording.flux.plot
2629
+ recording.
2630
+ \color blue
2631
+ flux
2632
+ \color inherit
2633
+ .plot
2685
2634
  \end_layout
2686
2635
 
2687
2636
  \begin_layout LyX-Code
2688
- recording.delta( delta_time: 0.1 ).plot
2637
+ recording.
2638
+ \color blue
2639
+ delta
2640
+ \color inherit
2641
+ (
2642
+ \color blue
2643
+ delta_time
2644
+ \color inherit
2645
+ : 0.1 ).plot
2689
2646
  \end_layout
2690
2647
 
2691
2648
  \begin_layout Standard
@@ -2697,8 +2654,10 @@ delta_time
2697
2654
  given delta time.
2698
2655
  As for
2699
2656
  \family typewriter
2657
+ \color blue
2700
2658
  firing
2701
2659
  \family default
2660
+ \color inherit
2702
2661
  , a feature of
2703
2662
  \family typewriter
2704
2663
  tS
@@ -2715,17 +2674,17 @@ Example IV: A real system.
2715
2674
  \end_layout
2716
2675
 
2717
2676
  \begin_layout Standard
2718
- A highly simplified cell-biological pathway simulated with
2719
- \family typewriter
2720
- YNelson::TimedSimulation
2721
- \family default
2722
- .
2677
+ A highly simplified cell-biological pathway.
2723
2678
  Let's first define some assumptions.
2724
2679
  Type in the following commands (output not shown):
2725
2680
  \end_layout
2726
2681
 
2727
2682
  \begin_layout LyX-Code
2728
- require 'y_nelson' and include YNelson
2683
+ require 'y_nelson'
2684
+ \end_layout
2685
+
2686
+ \begin_layout LyX-Code
2687
+ include YNelson
2729
2688
  \end_layout
2730
2689
 
2731
2690
  \begin_layout LyX-Code
@@ -3252,6 +3211,12 @@ Flux of the transitions can be plotted by:
3252
3211
  recording.flux.plot
3253
3212
  \end_layout
3254
3213
 
3214
+ \begin_layout Standard
3215
+ Please note that although this system qualitatively represents part of the
3216
+ deoxynucleotide metabolism network, its behavior is not realistic, because
3217
+ the available kinetic constants are not precise.
3218
+ \end_layout
3219
+
3255
3220
  \begin_layout Part*
3256
3221
  Example V: Using SY.
3257
3222
  \end_layout
@@ -3270,7 +3235,7 @@ SY
3270
3235
  \color inherit
3271
3236
  .
3272
3237
  If you are experienced with biochemical modeling, then you surely know
3273
- how big pain in the heel physical units are.
3238
+ how big pain the physical units are.
3274
3239
  Also, in
3275
3240
  \series bold
3276
3241
  Example III
@@ -3328,35 +3293,19 @@ Numeric
3328
3293
  \end_layout
3329
3294
 
3330
3295
  \begin_layout LyX-Code
3331
- 1.m
3332
- \end_layout
3333
-
3334
- \begin_layout LyX-Code
3335
- #=> #<±Magnitude: 1.m>
3296
+ 1.m #=> #<±Magnitude: 1.m>
3336
3297
  \end_layout
3337
3298
 
3338
3299
  \begin_layout LyX-Code
3339
- 1.s
3300
+ 1.s #=> #<±Magnitude: 1.s>
3340
3301
  \end_layout
3341
3302
 
3342
3303
  \begin_layout LyX-Code
3343
- #=> #<±Magnitude: 1.s>
3304
+ 1.kg.m.s(-2) #=> #<±Magnitude: 1.N>
3344
3305
  \end_layout
3345
3306
 
3346
3307
  \begin_layout LyX-Code
3347
- 1.kg.m.s(-2)
3348
- \end_layout
3349
-
3350
- \begin_layout LyX-Code
3351
- #=> #<±Magnitude: 1.N>
3352
- \end_layout
3353
-
3354
- \begin_layout LyX-Code
3355
- 1.cm + 1.mm
3356
- \end_layout
3357
-
3358
- \begin_layout LyX-Code
3359
- #=> #<±Magnitude: 0.011.m>
3308
+ 1.cm + 1.mm #=> #<±Magnitude: 0.011.m>
3360
3309
  \end_layout
3361
3310
 
3362
3311
  \begin_layout Standard
@@ -3369,19 +3318,11 @@ SY::Magnitude
3369
3318
  \end_layout
3370
3319
 
3371
3320
  \begin_layout LyX-Code
3372
- 1.m.quantity
3373
- \end_layout
3374
-
3375
- \begin_layout LyX-Code
3376
- #=> #<Quantity:Length±>
3377
- \end_layout
3378
-
3379
- \begin_layout LyX-Code
3380
- 1.cm.min⁻¹.quantity
3321
+ 1.m.quantity #=> #<Quantity:Length>
3381
3322
  \end_layout
3382
3323
 
3383
3324
  \begin_layout LyX-Code
3384
- #=> #<Quantity:Speed±>
3325
+ 1.cm.min⁻¹.quantity #=> #<Quantity:Speed>
3385
3326
  \end_layout
3386
3327
 
3387
3328
  \begin_layout Standard
@@ -3409,19 +3350,11 @@ to_f)
3409
3350
  \end_layout
3410
3351
 
3411
3352
  \begin_layout LyX-Code
3412
- 1.km.amount
3353
+ 1.km.amount #=> 1000.0
3413
3354
  \end_layout
3414
3355
 
3415
3356
  \begin_layout LyX-Code
3416
- #=> 1000.0
3417
- \end_layout
3418
-
3419
- \begin_layout LyX-Code
3420
- 1.cm.to_f
3421
- \end_layout
3422
-
3423
- \begin_layout LyX-Code
3424
- #=> 0.01
3357
+ 1.cm.to_f #=> 0.01
3425
3358
  \end_layout
3426
3359
 
3427
3360
  \begin_layout Subsection*
@@ -3443,138 +3376,92 @@ irb
3443
3376
  \end_layout
3444
3377
 
3445
3378
  \begin_layout LyX-Code
3446
- require 'sy'; require 'y_nelson' and include YNelson
3379
+ require 'sy'
3447
3380
  \end_layout
3448
3381
 
3449
3382
  \begin_layout LyX-Code
3450
- A = Place m!: 3.mM
3383
+ require 'y_nelson'
3451
3384
  \end_layout
3452
3385
 
3453
3386
  \begin_layout LyX-Code
3454
- #=> A
3387
+ include YNelson
3455
3388
  \end_layout
3456
3389
 
3457
3390
  \begin_layout LyX-Code
3458
- B = Place m!: 4.mM
3391
+ A = Place m!: 3.mM
3459
3392
  \end_layout
3460
3393
 
3461
3394
  \begin_layout LyX-Code
3462
- #=> B
3395
+ B = Place m!: 4.mM
3463
3396
  \end_layout
3464
3397
 
3465
3398
  \begin_layout LyX-Code
3466
3399
  A2B = Transition s: { A: -1, B: 1 }, rate: 0.05.s⁻¹
3467
3400
  \end_layout
3468
3401
 
3469
- \begin_layout LyX-Code
3470
- #=> A2B
3471
- \end_layout
3472
-
3473
3402
  \begin_layout LyX-Code
3474
3403
  B_decay = Transition s: { B: -1 }, rate: 0.002.s⁻¹
3475
3404
  \end_layout
3476
3405
 
3477
- \begin_layout LyX-Code
3478
- #=>
3479
- \family typewriter
3480
- B_decay
3481
- \end_layout
3482
-
3483
3406
  \begin_layout Standard
3484
- Now we have created places and transitions, whose marking and rate closures
3485
- are defined in physical units.
3407
+ We hereby specified marking and rate in physical units.
3486
3408
  Presently,
3487
3409
  \family typewriter
3488
- YNelson::TimedSimulation
3410
+ YNelson
3489
3411
  \family default
3490
- will not accept such Petri net, so the only thing we can do is play the
3491
- token game ourselves:
3492
- \end_layout
3493
-
3494
- \begin_layout LyX-Code
3495
- fire_both_transitions = proc { |delta_t|
3412
+ is not able to simulate such nets, but we can play token game with it:
3496
3413
  \end_layout
3497
3414
 
3498
3415
  \begin_layout LyX-Code
3499
- A2B.fire! delta_t
3416
+ net.m #=> [#<±Magnitude: 0.003.M>, #<±Magnitude: 0.004.M>]
3500
3417
  \end_layout
3501
3418
 
3502
3419
  \begin_layout LyX-Code
3503
- B_decay.fire! delta_t
3420
+ A2B.fire! 1.s
3504
3421
  \end_layout
3505
3422
 
3506
3423
  \begin_layout LyX-Code
3507
- }
3424
+ B_decay.fire! 1.s
3508
3425
  \end_layout
3509
3426
 
3510
3427
  \begin_layout LyX-Code
3511
- #=> #<Proc:0x9b48f1c@(irb):19>
3428
+ net.m #=> [#<±Magnitude: 0.00285.M>, #<±Magnitude: 0.00414.M>]
3512
3429
  \end_layout
3513
3430
 
3514
3431
  \begin_layout Standard
3515
- Here, we have defined a closure accepting one argument
3516
- \begin_inset Formula $\Delta$
3517
- \end_inset
3518
-
3519
- t, which it will use to
3520
- \family typewriter
3521
- fire!
3522
- \family default
3523
- both
3524
- \family typewriter
3525
- A2B
3526
- \family default
3527
- and
3528
- \family typewriter
3529
- B_decay
3530
- \family default
3531
- .
3532
- By calling this closure repeatedly, we can simulate the network without
3533
- use of
3534
- \family typewriter
3535
- TimedSimulation
3536
- \family default
3537
- :
3432
+ Let us fire the 2 defined transitions for 100 seconds:
3538
3433
  \end_layout
3539
3434
 
3540
3435
  \begin_layout LyX-Code
3541
- places.map &:marking
3436
+ 100.times do
3542
3437
  \end_layout
3543
3438
 
3544
3439
  \begin_layout LyX-Code
3545
- #=> [#<±Magnitude: 0.003.M>, #<±Magnitude: 0.004.M>]
3440
+ A2B.fire! 1.s
3546
3441
  \end_layout
3547
3442
 
3548
3443
  \begin_layout LyX-Code
3549
- fire_both_transitions.( 1.s )
3444
+ B_decay.fire! 1.s
3550
3445
  \end_layout
3551
3446
 
3552
3447
  \begin_layout LyX-Code
3553
- #=> nil
3448
+ end
3554
3449
  \end_layout
3555
3450
 
3556
3451
  \begin_layout LyX-Code
3557
- places.map &:marking
3452
+ net.m #=> [#<±Magnitude: 1.69e-05.M>, #<±Magnitude: 0.0058.M>]
3558
3453
  \end_layout
3559
3454
 
3560
- \begin_layout LyX-Code
3561
- #=> [#<±Magnitude: 0.00285.M>, #<±Magnitude: 0.00414.M>]
3562
- \end_layout
3563
-
3564
- \begin_layout LyX-Code
3565
- 100.times do fire_both_transitions.( 1.s ) end
3566
- \end_layout
3567
-
3568
- \begin_layout LyX-Code
3569
- #=> 100
3570
- \end_layout
3571
-
3572
- \begin_layout LyX-Code
3573
- places.map &:marking
3574
- \end_layout
3575
-
3576
- \begin_layout LyX-Code
3577
- #=> [#<±Magnitude: 1.69e-05.M>, #<±Magnitude: 0.0058.M>]
3455
+ \begin_layout Standard
3456
+ Finally, let us inspect the resulting marking of
3457
+ \family typewriter
3458
+ A
3459
+ \family default
3460
+ and
3461
+ \family typewriter
3462
+ B
3463
+ \family default
3464
+ expressed in micromolars:
3578
3465
  \end_layout
3579
3466
 
3580
3467
  \begin_layout LyX-Code
@@ -3582,19 +3469,11 @@ A.marking.
3582
3469
  \color blue
3583
3470
  in
3584
3471
  \color inherit
3585
- :µM
3472
+ :µM #=> 16.873508277951963
3586
3473
  \end_layout
3587
3474
 
3588
3475
  \begin_layout LyX-Code
3589
- #=> 16.873508277951963
3590
- \end_layout
3591
-
3592
- \begin_layout LyX-Code
3593
- B.marking.in :µM
3594
- \end_layout
3595
-
3596
- \begin_layout LyX-Code
3597
- #=> 5797.976678013365
3476
+ B.marking.in :µM #=> 5797.976678013365
3598
3477
  \end_layout
3599
3478
 
3600
3479
  \begin_layout Part*
@@ -3602,21 +3481,24 @@ Example VI: Other simulation methods
3602
3481
  \end_layout
3603
3482
 
3604
3483
  \begin_layout Standard
3605
- At this moment, the default simulation method is implicit Euler (or
3484
+ At this moment, the default simulation method
3606
3485
  \family typewriter
3607
- pseudo_euler
3486
+ basic
3608
3487
  \family default
3609
-
3610
- \emph on
3611
- pseudo
3612
- \emph default
3613
- because timeless transitions and assignment transtitions also fire at each
3614
- step in time).
3615
- From other simulation methods, Gillespie algorithm is available:
3488
+ method.
3489
+ This method is also called is implicit Euler, because when simulating timed
3490
+ nets, it implies first-order Euler method.
3491
+ For timed nets, YNelson provides two other methods: Runge-Kutta 4th order
3492
+ method and Gillespie stochastic method.
3493
+ Demonstrating Gillespie method:
3616
3494
  \end_layout
3617
3495
 
3618
3496
  \begin_layout LyX-Code
3619
- require 'y_nelson' and include YNelson
3497
+ require 'y_nelson'
3498
+ \end_layout
3499
+
3500
+ \begin_layout LyX-Code
3501
+ include YNelson
3620
3502
  \end_layout
3621
3503
 
3622
3504
  \begin_layout LyX-Code
@@ -3688,8 +3570,8 @@ plot_state
3688
3570
  \end_layout
3689
3571
 
3690
3572
  \begin_layout Standard
3691
- The state recording should show the random walk of the system state over
3692
- 50 time units.
3573
+ The state recording should show a random walk of the system state over the
3574
+ period of 50 time units.
3693
3575
  \end_layout
3694
3576
 
3695
3577
  \begin_layout LyX-Code