y_nelson 2.1.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3701 +0,0 @@
1
- #LyX 2.0 created this file. For more info see http://www.lyx.org/
2
- \lyxformat 413
3
- \begin_document
4
- \begin_header
5
- \textclass article
6
- \use_default_options false
7
- \maintain_unincluded_children false
8
- \language english
9
- \language_package default
10
- \inputencoding auto
11
- \fontencoding global
12
- \font_roman default
13
- \font_sans default
14
- \font_typewriter default
15
- \font_default_family default
16
- \use_non_tex_fonts false
17
- \font_sc false
18
- \font_osf false
19
- \font_sf_scale 100
20
- \font_tt_scale 100
21
-
22
- \graphics default
23
- \default_output_format default
24
- \output_sync 0
25
- \bibtex_command default
26
- \index_command default
27
- \paperfontsize default
28
- \spacing single
29
- \use_hyperref false
30
- \papersize default
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
37
- \use_bibtopic false
38
- \use_indices false
39
- \paperorientation portrait
40
- \suppress_date false
41
- \use_refstyle 0
42
- \index Index
43
- \shortcut idx
44
- \color #008000
45
- \end_index
46
- \leftmargin 2.2cm
47
- \topmargin 3cm
48
- \rightmargin 2.2cm
49
- \bottommargin 3cm
50
- \secnumdepth 3
51
- \tocdepth 3
52
- \paragraph_separation indent
53
- \paragraph_indentation default
54
- \quotes_language english
55
- \papercolumns 1
56
- \papersides 1
57
- \paperpagestyle default
58
- \tracking_changes false
59
- \output_changes false
60
- \html_math_output 0
61
- \html_css_as_file 0
62
- \html_be_strict false
63
- \end_header
64
-
65
- \begin_body
66
-
67
- \begin_layout Title
68
- YNelson: Hands-on Tutorial
69
- \end_layout
70
-
71
- \begin_layout Part*
72
- Introduction
73
- \end_layout
74
-
75
- \begin_layout Standard
76
- This document is a hands-on guide to
77
- \family typewriter
78
- \color blue
79
- YNelson
80
- \family default
81
- \color inherit
82
- ,
83
- \emph on
84
- \color green
85
- Nelson nets
86
- \emph default
87
- \color inherit
88
- and, partially,
89
- \color red
90
- Ruby
91
- \color inherit
92
- 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
- If you have never heard about Nelson nets, do not wonder: it is a semi-novel
96
- concept based on
97
- \emph on
98
- \color green
99
- Petri nets
100
- \emph default
101
- \color inherit
102
- crossed with Ted Nelson's
103
- \emph on
104
- \color green
105
- ZZ structures
106
- \emph default
107
- \color inherit
108
- .
109
- If you follow this guide closely, you will receive a concise and efficient
110
- introduction to each of these three (remark:
111
- \emph on
112
- only the Petri net aspect is covered in this version of this guide.
113
- ZZ structure aspect will be covered in the future versions of this manual)
114
- \emph default
115
- .
116
- Newly introduced
117
- \color red
118
- Ruby keywords and terms
119
- \color inherit
120
- are highlighted in red,
121
- \color green
122
- Petri net terms
123
- \color inherit
124
- in green, and
125
- \color blue
126
- YNelson keywords and terms
127
- \color inherit
128
- in blue throughout this document.
129
- \end_layout
130
-
131
- \begin_layout Standard
132
-
133
- \family typewriter
134
- \color blue
135
- YNelson
136
- \family default
137
- \color inherit
138
- is a domain model and a simulator of
139
- \emph on
140
- \color green
141
- functional
142
- \emph default
143
-
144
- \emph on
145
- Petri nets
146
- \emph default
147
- \color inherit
148
- living in the
149
- \emph on
150
- \color green
151
- ZZ space
152
- \emph default
153
- \color inherit
154
- .
155
- The Petri net flavor used in
156
- \family typewriter
157
- YNelson
158
- \family default
159
- is similar, but not identical with
160
- \emph on
161
- \color green
162
- hybrid functional Petri nets
163
- \emph default
164
- (HFPNs)
165
- \color inherit
166
- introduced by
167
- \begin_inset CommandInset citation
168
- LatexCommand citet
169
- key "Matsuno2011brs"
170
-
171
- \end_inset
172
-
173
- .
174
- For a recent review of the various flavors of Petri nets, see eg.
175
-
176
- \begin_inset CommandInset citation
177
- LatexCommand citet
178
- key "Bos2008mbs"
179
-
180
- \end_inset
181
-
182
- .
183
-
184
- \family typewriter
185
- YNelson
186
- \family default
187
- is implemented in
188
- \emph on
189
- \color red
190
- Ruby programming language
191
- \emph default
192
- \color inherit
193
- .
194
- It is publicly available as
195
- \emph on
196
- \color blue
197
-
198
- \begin_inset CommandInset href
199
- LatexCommand href
200
- name "y_nelson gem"
201
- target "https://rubygems.org/gems/y_nelson"
202
-
203
- \end_inset
204
-
205
-
206
- \emph default
207
- \color inherit
208
- (
209
- \emph on
210
- \color red
211
- gem
212
- \emph default
213
- \color inherit
214
- = Ruby library).
215
-
216
- \family typewriter
217
- YNelson
218
- \family default
219
- is one of the series of Ruby gems (
220
- \family typewriter
221
- \color blue
222
-
223
- \begin_inset CommandInset href
224
- LatexCommand href
225
- name "YPetri"
226
- target "https://rubygems.org/gems/y_petri"
227
-
228
- \end_inset
229
-
230
-
231
- \family default
232
- \color inherit
233
- ,
234
- \family typewriter
235
- \color blue
236
- YChem
237
- \family default
238
- \color inherit
239
- ,
240
- \family typewriter
241
- \color blue
242
- YCell
243
- \family default
244
- \color inherit
245
- ,
246
- \family typewriter
247
- \color blue
248
-
249
- \begin_inset CommandInset href
250
- LatexCommand href
251
- name "Yzz"
252
- target "https://rubygems.org/gems/yzz"
253
-
254
- \end_inset
255
-
256
-
257
- \family default
258
- \color inherit
259
- , metrology library
260
- \family typewriter
261
- \color blue
262
-
263
- \begin_inset CommandInset href
264
- LatexCommand href
265
- name "SY"
266
- target "https://rubygems.org/gems/sy"
267
-
268
- \end_inset
269
-
270
-
271
- \family default
272
- \color inherit
273
- ...), whose design intent is to bring ergonomy to biochemical modeling.
274
- Note that
275
- \family typewriter
276
- YNelson
277
- \family default
278
- depends on
279
- \family typewriter
280
- YPetri
281
- \family default
282
- and
283
- \family typewriter
284
- Yzz
285
- \family default
286
- gems, its usage together with
287
- \family typewriter
288
- SY
289
- \family default
290
- might be desirable if you are dealing with physical units.
291
- Also,
292
- \family typewriter
293
- YNelson
294
- \family default
295
- use is not limited to biochemistry, but for all the applications where
296
- Petri nets and/or relational databases are used.
297
- \end_layout
298
-
299
- \begin_layout Standard
300
-
301
- \family typewriter
302
- YNelson
303
- \family default
304
- provides a
305
- \emph on
306
- \color red
307
- domain-specific language
308
- \emph default
309
- (DSL)
310
- \color inherit
311
- , which you can use in scripts, or access interactively from
312
- \color red
313
- inferior Ruby interpreter (
314
- \emph on
315
- irb
316
- \emph default
317
- )
318
- \color inherit
319
- .
320
- A DSLs can be thought of as APIs with user-friendly syntax.
321
- As a believer in robot equality, I dislike the distinction between API
322
- and UI (user interface), and prefer common textual command interface (CI)
323
- for humanoid as well as cybernetic users.
324
- \end_layout
325
-
326
- \begin_layout Standard
327
- And why bother learning Ruby syntax and
328
- \family typewriter
329
- YNelson
330
- \family default
331
- ? Half-jokingly,
332
- \family typewriter
333
- YNelson
334
- \family default
335
- is
336
- \emph on
337
- The Simplest Way To Work With Complicated Petri Nets
338
- \emph default
339
- ™.
340
- Petri net software at higher development stage, or written for a different
341
- purpose than
342
- \family typewriter
343
- YNelson
344
- \family default
345
- , does exist.
346
- But none of the programs written for the same purpose as
347
- \family typewriter
348
- YNelson
349
- \family default
350
- can avoid taking the user through the process of learning the interface.
351
- Advantages of using textual DSL become apparent as soon as the user's models
352
- become less simple.
353
- \end_layout
354
-
355
- \begin_layout Part*
356
- Using This Guide, or
357
- \begin_inset Quotes eld
358
- \end_inset
359
-
360
- The Hard Way Is Easier
361
- \begin_inset Quotes erd
362
- \end_inset
363
-
364
-
365
- \end_layout
366
-
367
- \begin_layout Standard
368
- The phrase above is borrowed from the textbook by Zed Shaw named
369
- \begin_inset Quotes eld
370
- \end_inset
371
-
372
- Learn Ruby the Hard Way
373
- \begin_inset Quotes erd
374
- \end_inset
375
-
376
- (highly recommended,
377
- \emph on
378
- \color magenta
379
-
380
- \begin_inset CommandInset href
381
- LatexCommand href
382
- name "hyperlink here"
383
- target "http://ruby.learncodethehardway.org/"
384
-
385
- \end_inset
386
-
387
-
388
- \emph default
389
- \color inherit
390
- ).
391
- Apart from being a great shark-jumper, Zed is a great teacher familiar
392
- with many programming languages, and I will borrow his teaching method
393
- here.
394
- Citing Zed,
395
- \begin_inset Quotes eld
396
- \end_inset
397
-
398
- The title says it's the hard way...
399
- but actually it's not.
400
- \begin_inset Quotes erd
401
- \end_inset
402
-
403
- It's only
404
- \begin_inset Quotes eld
405
- \end_inset
406
-
407
- hard
408
- \begin_inset Quotes erd
409
- \end_inset
410
-
411
- because of the way people
412
- \emph on
413
- used
414
- \emph default
415
- to teach things.
416
-
417
- \family typewriter
418
- YNelson
419
- \family default
420
- is a language.
421
- To learn it and see its usefulness, you will still need to do the incredibly
422
- simple things that all language learners do:
423
- \end_layout
424
-
425
- \begin_layout Enumerate
426
- Go through each example.
427
- \end_layout
428
-
429
- \begin_layout Enumerate
430
- Type each sample code exactly.
431
- \end_layout
432
-
433
- \begin_layout Enumerate
434
- Make it run.
435
- \end_layout
436
-
437
- \begin_layout Standard
438
- \noindent
439
- That's it.
440
- This might feel
441
- \emph on
442
- very
443
- \emph default
444
- difficult at first, but stick with it.
445
- It seems stupidly obvious, but, if you have a problem installing
446
- \family typewriter
447
- YNelson
448
- \family default
449
- , running
450
- \emph on
451
- irb
452
- \emph default
453
- and typing, you will have a problem learning.
454
- If you go through this document without actually doing the exercises, you
455
- might as well just not even read it.
456
- Do not skip and do not skim.
457
- By typing each example
458
- \emph on
459
- exactly
460
- \emph default
461
- , you will be training your brain to focus on the details of what you are
462
- doing, as you are doing it.
463
- While you do these examples, typing each one in, you will be making mistakes.
464
- It's inevitable; humans do make mistakes.
465
- By doing so, you will train yourself to notice mistakes and other problems.
466
- Do not copy-paste.
467
- Type each code sample in, manually.
468
- The point is to train your hands, your brain, and your mind in how to read,
469
- write and see Ruby and
470
- \family typewriter
471
- YNelson
472
- \family default
473
- code.
474
- If you skip, skim and copy-paste, you are cheating yourself out of the
475
- effectiveness of this guide.
476
- \end_layout
477
-
478
- \begin_layout Part*
479
- Prerequisites
480
- \end_layout
481
-
482
- \begin_layout Standard
483
- Most importantly, you will need a working installation of Ruby 1.9 on your
484
- computer.
485
- Once this condition is met, basic
486
- \family typewriter
487
- YNelson
488
- \family default
489
- installation is as simple as typing
490
- \begin_inset Quotes eld
491
- \end_inset
492
-
493
-
494
- \family typewriter
495
- gem install y_nelson
496
- \family default
497
-
498
- \begin_inset Quotes erd
499
- \end_inset
500
-
501
- in the command prompt.
502
- However,
503
- \family typewriter
504
- YNelson
505
- \family default
506
- currently uses dependencies (gnuplot gem, graphviz gem...), whose installation
507
- may pose challenges.
508
- Once
509
- \family typewriter
510
- YNelson
511
- \family default
512
- is installed, run
513
- \emph on
514
- irb
515
- \emph default
516
- command interpreter, and type:
517
- \end_layout
518
-
519
- \begin_layout LyX-Code
520
-
521
- \color red
522
- require
523
- \color inherit
524
- 'y_nelson'
525
- \end_layout
526
-
527
- \begin_layout Standard
528
- After succesful
529
- \family typewriter
530
- require
531
- \family default
532
- , type:
533
- \end_layout
534
-
535
- \begin_layout LyX-Code
536
-
537
- \color red
538
- include
539
- \color inherit
540
- YNelson
541
- \end_layout
542
-
543
- \begin_layout Standard
544
- This will augment your irb command session with interactive
545
- \family typewriter
546
- YNelson
547
- \family default
548
- command interface (
549
- \family typewriter
550
- YNelson
551
- \family default
552
- DSL CI).
553
- You have to re-run
554
- \emph on
555
- irb
556
- \emph default
557
- from the scratch, and re-type '
558
- \family typewriter
559
- require
560
- \family default
561
- ' and '
562
- \family typewriter
563
- include
564
- \family default
565
- ' statements before each of the usage examples written below.
566
- Please, also notice that this guide itself is alpha stage, so the actual
567
-
568
- \family typewriter
569
- YNelson
570
- \family default
571
- version you will be using may somewhat differ from this guide.
572
- Also, the nucleotide metabolism model in Example 3 is yet to be tuned to
573
- be realistic.
574
- If something in this guide does not work, please do not hesitate to notify
575
- us, we will appreciate your feedback.
576
- \end_layout
577
-
578
- \begin_layout Part*
579
- Example I: Basics
580
- \end_layout
581
-
582
- \begin_layout Standard
583
- This example is a gentle introduction to Petri net terminology,
584
- \family typewriter
585
- YNelson
586
- \family default
587
- DSL terminology, and Ruby syntax.
588
- The most basic capability, that
589
- \family typewriter
590
- YNelson
591
- \family default
592
- offers, is that of user-driven
593
- \emph on
594
- \color green
595
- token game
596
- \emph default
597
- \color inherit
598
- .
599
- We will thus create a small Petri net containing 2
600
- \emph on
601
- \color green
602
- places
603
- \emph default
604
- \color inherit
605
- and play token game with it.
606
- \end_layout
607
-
608
- \begin_layout Subsection*
609
- Places
610
- \end_layout
611
-
612
- \begin_layout Standard
613
- Type:
614
- \end_layout
615
-
616
- \begin_layout LyX-Code
617
- A =
618
- \color blue
619
- Place
620
- \color inherit
621
- ()
622
- \end_layout
623
-
624
- \begin_layout Standard
625
- Syntactically, this will call
626
- \emph on
627
- \color red
628
- method
629
- \emph default
630
- \color inherit
631
- '
632
- \family typewriter
633
- Place
634
- \family default
635
- ' of
636
- \family typewriter
637
- YNelson
638
- \family default
639
- DSL and assign its
640
- \emph on
641
- \color red
642
- return value
643
- \emph default
644
- \color inherit
645
- to the
646
- \emph on
647
- \color red
648
- constant
649
- \emph default
650
- \color inherit
651
-
652
- \family typewriter
653
- A
654
- \family default
655
- .
656
- In this case, the return value is an
657
- \emph on
658
- \color red
659
- object
660
- \emph default
661
- \color inherit
662
- , which is an
663
- \emph on
664
- \color red
665
- instance
666
- \emph default
667
- \color inherit
668
- of
669
- \family typewriter
670
- \color blue
671
- YNelson::Place
672
- \family default
673
- \color inherit
674
-
675
- \emph on
676
- \color red
677
- class
678
- \emph default
679
- \color inherit
680
- .
681
- We say that
682
- \family typewriter
683
- YNelson::Place
684
- \family default
685
- class
686
- \emph on
687
- \color red
688
- represents
689
- \emph default
690
- \color inherit
691
- the concept of Petri net places in
692
- \family typewriter
693
- YNelson
694
- \family default
695
-
696
- \emph on
697
- domain model
698
- \emph default
699
- (and '
700
- \family typewriter
701
- Place
702
- \family default
703
- ' method is called a
704
- \emph on
705
- \color red
706
- constructor
707
- \emph default
708
- \color inherit
709
- of
710
- \family typewriter
711
- YNelson::Place
712
- \family default
713
- , which is not important.).
714
- Whole this object has now been assigned to
715
- \family typewriter
716
- A
717
- \family default
718
- .
719
- On the screen, you will see the output:
720
- \family typewriter
721
- #<Place: name: A, marking: nil, default_marking: ø>
722
- \family default
723
- .
724
- (This is the
725
- \emph on
726
- \color red
727
- inspect string
728
- \emph default
729
- \color inherit
730
- of the object, created by
731
- \family typewriter
732
- YNelson::Place#
733
- \color red
734
- inspect
735
- \family default
736
- \color inherit
737
- method, which is not important.) In the following, screen output will always
738
- be written immediately under the code sample, preceded by sherocket (
739
- \family typewriter
740
- #=>):
741
- \end_layout
742
-
743
- \begin_layout LyX-Code
744
- B = Place()
745
- \end_layout
746
-
747
- \begin_layout LyX-Code
748
-
749
- \family typewriter
750
- #=> #<Place: name: B, marking: nil, default_marking: ø>
751
- \end_layout
752
-
753
- \begin_layout Standard
754
- We have so far defined 2 Petri net places named
755
- \family typewriter
756
- A
757
- \family default
758
- ,
759
- \family typewriter
760
- B
761
- \family default
762
- .
763
- You can check it by typing:
764
- \end_layout
765
-
766
- \begin_layout LyX-Code
767
-
768
- \color blue
769
- places
770
- \color inherit
771
- ()
772
- \end_layout
773
-
774
- \begin_layout LyX-Code
775
- #=> [#<Place: name: A, marking: nil, default_marking: ø>,
776
- \end_layout
777
-
778
- \begin_layout LyX-Code
779
- #<Place: name: B, marking: nil, default_marking: ø>]
780
- \end_layout
781
-
782
- \begin_layout LyX-Code
783
- A.
784
- \color blue
785
- name
786
- \color inherit
787
- ()
788
- \end_layout
789
-
790
- \begin_layout LyX-Code
791
- #=> :A
792
- \end_layout
793
-
794
- \begin_layout Standard
795
- These have automatically become part of a default Petri net instance (of
796
-
797
- \family typewriter
798
- YNelson::Net
799
- \family default
800
- class; object id may vary):
801
- \end_layout
802
-
803
- \begin_layout LyX-Code
804
-
805
- \color blue
806
- net
807
- \color inherit
808
- ()
809
- \end_layout
810
-
811
- \begin_layout LyX-Code
812
- #=> #<Net: name: Top, 2 pp, 0 tt >
813
- \end_layout
814
-
815
- \begin_layout Standard
816
- Of course, you have full power of Ruby at your disposal.
817
- To eg.
818
- list only place names as strings, you can use standard Ruby methods:
819
- \end_layout
820
-
821
- \begin_layout LyX-Code
822
- places.
823
- \color red
824
- map
825
- \color inherit
826
- ( &:name )
827
- \end_layout
828
-
829
- \begin_layout LyX-Code
830
- #=> [:A, :B]
831
- \end_layout
832
-
833
- \begin_layout Standard
834
- Here, Ruby
835
- \family typewriter
836
- map
837
- \family default
838
- method transforms the
839
- \emph on
840
- \color red
841
- array
842
- \emph default
843
- \color inherit
844
- of places to the array of their names.
845
- The advantage of internal DSLs is, that one retains full power of the language,
846
- augmented with human-friendly, domain-specific CI.
847
- GUI systems generally sandbox the user inside their interface, with no
848
- way to overcome its limitations.
849
- But let us go on.
850
- Way above, you might have noticed '
851
- \family typewriter
852
- \color red
853
- nil
854
- \family default
855
- \color inherit
856
- ' in the places' inspect strings.
857
- This is because we have specified no
858
- \emph on
859
- \color green
860
- marking
861
- \emph default
862
- \color inherit
863
- for
864
- \family typewriter
865
- A
866
- \family default
867
- ,
868
- \family typewriter
869
- B
870
- \family default
871
- :
872
- \end_layout
873
-
874
- \begin_layout LyX-Code
875
- A.
876
- \color blue
877
- marking
878
- \color inherit
879
- ()
880
- \end_layout
881
-
882
- \begin_layout LyX-Code
883
- #=> nil
884
- \end_layout
885
-
886
- \begin_layout LyX-Code
887
- places.map( &:marking )
888
- \end_layout
889
-
890
- \begin_layout LyX-Code
891
- #=> [nil, nil]
892
- \end_layout
893
-
894
- \begin_layout Standard
895
- Let us give these two places some marking:
896
- \end_layout
897
-
898
- \begin_layout LyX-Code
899
- A.
900
- \color blue
901
- marking =
902
- \color inherit
903
- 2
904
- \end_layout
905
-
906
- \begin_layout LyX-Code
907
- #=> 2
908
- \end_layout
909
-
910
- \begin_layout LyX-Code
911
- B.marking = 5
912
- \end_layout
913
-
914
- \begin_layout LyX-Code
915
- #=> 5
916
- \end_layout
917
-
918
- \begin_layout Standard
919
- The marking has indeed changed:
920
- \end_layout
921
-
922
- \begin_layout LyX-Code
923
- places.map( &:marking )
924
- \end_layout
925
-
926
- \begin_layout LyX-Code
927
- #=> [2, 5]
928
- \end_layout
929
-
930
- \begin_layout Standard
931
- In classical Petri nets, this marking is understood as the number of
932
- \emph on
933
- \color green
934
- tokens
935
- \emph default
936
- \color inherit
937
- in each place, and is always an integer.
938
- In this case,
939
- \family typewriter
940
- A
941
- \family default
942
- contains 2 tokens, while
943
- \family typewriter
944
- B
945
- \family default
946
- contains 5 tokens.
947
- Tokens can represent anything: molecules, parts in the production line,
948
- trains in the railway network...
949
- \end_layout
950
-
951
- \begin_layout Subsection*
952
- Transitions
953
- \end_layout
954
-
955
- \begin_layout Standard
956
- The behavior of a Petri net is defined by
957
- \emph on
958
- \color green
959
- transitions
960
- \emph default
961
- \color inherit
962
- .
963
- Each transition defines a single operation: Adding / subtracting some amount
964
- of tokens to / from some places.
965
- Transition operation can often be expressed by the transition's
966
- \emph on
967
- stoichiometry
968
- \emph default
969
- – a list of places together with the number of tokens added / subtracted
970
- when the transition
971
- \emph on
972
- \color green
973
- fires
974
- \emph default
975
- \color inherit
976
- .
977
- For example, let us define:
978
- \end_layout
979
-
980
- \begin_layout LyX-Code
981
- A2B =
982
- \color blue
983
- Transition
984
- \color inherit
985
- ( stoichiometry: { A: -1, B: 1 } )
986
- \end_layout
987
-
988
- \begin_layout LyX-Code
989
- #=> #<Transition: A2B (tS)>
990
- \end_layout
991
-
992
- \begin_layout Standard
993
- Stoichiometry of this transition is given by
994
- \emph on
995
- \color red
996
- hash
997
- \emph default
998
- \color inherit
999
-
1000
- \family typewriter
1001
- { A: -1, B: 1 }
1002
- \family default
1003
- .
1004
- This hash is available from
1005
- \family typewriter
1006
- A2B
1007
- \family default
1008
- via '
1009
- \family typewriter
1010
- \color blue
1011
- s
1012
- \family default
1013
- \color inherit
1014
- ' method:
1015
- \end_layout
1016
-
1017
- \begin_layout LyX-Code
1018
- A2B.
1019
- \color blue
1020
- s
1021
- \color inherit
1022
- ()
1023
- \end_layout
1024
-
1025
- \begin_layout LyX-Code
1026
- #=> {:A=>-1, :B=>1}
1027
- \end_layout
1028
-
1029
- \begin_layout Standard
1030
-
1031
- \emph on
1032
- \color red
1033
- Keys
1034
- \emph default
1035
- \color inherit
1036
- of this hash are place names,
1037
- \emph on
1038
- \color red
1039
- values
1040
- \emph default
1041
- \color inherit
1042
- are
1043
- \emph on
1044
- \color green
1045
- stoichiometry coefficients
1046
- \emph default
1047
- \color inherit
1048
- .
1049
- ('Stoichiometry' is a word known from the domain of chemistry, but '
1050
- \emph on
1051
- stoicheion
1052
- \emph default
1053
- ' means simply 'element' in Greek, so there is no problem with using it
1054
- in the domain of general Petri nets.) To see the stoichiometry coefficients
1055
- of
1056
- \family typewriter
1057
- A2B
1058
- \family default
1059
- as an array, type:
1060
- \end_layout
1061
-
1062
- \begin_layout LyX-Code
1063
- A2B.
1064
- \color blue
1065
- stoichiometry
1066
- \color inherit
1067
- ()
1068
- \end_layout
1069
-
1070
- \begin_layout LyX-Code
1071
- #=> [-1, 1]
1072
- \end_layout
1073
-
1074
- \begin_layout Standard
1075
- Simply,
1076
- \family typewriter
1077
- A2B
1078
- \family default
1079
- subtracts 1 token from
1080
- \family typewriter
1081
- A
1082
- \family default
1083
- , and adds 1 token to
1084
- \family typewriter
1085
- B
1086
- \family default
1087
- .
1088
- This can represent conversion of
1089
- \family typewriter
1090
- A
1091
- \family default
1092
- to
1093
- \family typewriter
1094
- B
1095
- \family default
1096
- .
1097
- In classical Petri nets, the arrows connecting places and transitions are
1098
- called
1099
- \emph on
1100
- \color green
1101
- arcs
1102
- \emph default
1103
- \color inherit
1104
- .
1105
- (The term was borrowed from graph theory.) For example, at this moment,
1106
- our Petri net would contain one arc going from
1107
- \family typewriter
1108
- A
1109
- \family default
1110
- to
1111
- \family typewriter
1112
- A2B
1113
- \family default
1114
- , and one arc going from
1115
- \family typewriter
1116
- A2B
1117
- \family default
1118
- to
1119
- \family typewriter
1120
- B
1121
- \family default
1122
- .
1123
- In
1124
- \family typewriter
1125
- YNelson
1126
- \family default
1127
- domain model, 'arcs' are not first-class citizens.
1128
- The word is understood simply as a synonym for transitions' connectivity
1129
- – the list of places connected to each transition:
1130
- \end_layout
1131
-
1132
- \begin_layout LyX-Code
1133
- A2B.
1134
- \color blue
1135
- arcs
1136
- \color inherit
1137
- ()
1138
- \end_layout
1139
-
1140
- \begin_layout LyX-Code
1141
- #=> [#<Place: name: A, marking: 2, default_marking: ø >,
1142
- \end_layout
1143
-
1144
- \begin_layout LyX-Code
1145
- #<Place: name: B, marking: 5, default_marking: ø >]
1146
- \end_layout
1147
-
1148
- \begin_layout Standard
1149
- The transition
1150
- \family typewriter
1151
- A2B
1152
- \family default
1153
- is
1154
- \emph on
1155
- \color blue
1156
- timeless
1157
- \emph default
1158
- \color inherit
1159
- :
1160
- \end_layout
1161
-
1162
- \begin_layout LyX-Code
1163
- A2B.
1164
- \color blue
1165
- timeless?
1166
- \color inherit
1167
- ()
1168
- \end_layout
1169
-
1170
- \begin_layout LyX-Code
1171
- #=> true
1172
- \end_layout
1173
-
1174
- \begin_layout Standard
1175
- 'Timeless' means that the transition's firing is not defined in time – it
1176
- can fire anytime, as long as it is
1177
- \emph on
1178
- \color green
1179
- enabled
1180
- \emph default
1181
- \color inherit
1182
- .
1183
- Classical Petri nets are timeless.
1184
- In classical Petri nets, a transition is enabled whenever its
1185
- \emph on
1186
- \color blue
1187
- downstream arcs
1188
- \emph default
1189
- \color inherit
1190
- allow it to happen.
1191
- Downstream arcs, or
1192
- \emph on
1193
- \color blue
1194
- codomain
1195
- \emph default
1196
- \color inherit
1197
- of a transition (these two are synonyms) are those places, whose marking
1198
- can be directly affected by the transition's firing.
1199
- In this case, both
1200
- \family typewriter
1201
- A
1202
- \family default
1203
- and
1204
- \family typewriter
1205
- B
1206
- \family default
1207
- is affected:
1208
- \end_layout
1209
-
1210
- \begin_layout LyX-Code
1211
- A2B.
1212
- \color blue
1213
- downstream_arcs
1214
- \color inherit
1215
- ()
1216
- \end_layout
1217
-
1218
- \begin_layout LyX-Code
1219
- [#<Place: name: A, marking: 2, default_marking: ø>,
1220
- \end_layout
1221
-
1222
- \begin_layout LyX-Code
1223
- #<Place: name: B, marking: 5, default_marking: ø>]
1224
- \end_layout
1225
-
1226
- \begin_layout LyX-Code
1227
- A2B.
1228
- \color blue
1229
- codomain
1230
- \color inherit
1231
- ()
1232
- \end_layout
1233
-
1234
- \begin_layout LyX-Code
1235
- [#<Place: name: A, marking: 2, default_marking: ø>,
1236
- \end_layout
1237
-
1238
- \begin_layout LyX-Code
1239
- #<Place: name: B, marking: 5, default_marking: ø>]
1240
- \end_layout
1241
-
1242
- \begin_layout Standard
1243
- Since
1244
- \family typewriter
1245
- A2B
1246
- \family default
1247
- subtracts tokens from
1248
- \family typewriter
1249
- A
1250
- \family default
1251
- , it will be enabled so long, as there are any tokens left in
1252
- \family typewriter
1253
- A
1254
- \family default
1255
- .
1256
- \end_layout
1257
-
1258
- \begin_layout LyX-Code
1259
- A2B.
1260
- \color blue
1261
- enabled?
1262
- \color inherit
1263
- ()
1264
- \end_layout
1265
-
1266
- \begin_layout LyX-Code
1267
- #=> true
1268
- \end_layout
1269
-
1270
- \begin_layout Subsection*
1271
- Token game
1272
- \end_layout
1273
-
1274
- \begin_layout Standard
1275
- After
1276
- \family typewriter
1277
- A2B
1278
- \family default
1279
- fires, the marking will change:
1280
- \end_layout
1281
-
1282
- \begin_layout LyX-Code
1283
- A2B.
1284
- \color blue
1285
- fire!
1286
- \color inherit
1287
- ()
1288
- \end_layout
1289
-
1290
- \begin_layout LyX-Code
1291
- #=> nil
1292
- \end_layout
1293
-
1294
- \begin_layout LyX-Code
1295
- places.map( &:marking )
1296
- \end_layout
1297
-
1298
- \begin_layout LyX-Code
1299
- #=> [1, 6]
1300
- \end_layout
1301
-
1302
- \begin_layout LyX-Code
1303
- A2B.fire!()
1304
- \end_layout
1305
-
1306
- \begin_layout LyX-Code
1307
- #=> nil
1308
- \end_layout
1309
-
1310
- \begin_layout LyX-Code
1311
- places.map( &:marking )
1312
- \end_layout
1313
-
1314
- \begin_layout LyX-Code
1315
- #=> [0, 7]
1316
- \end_layout
1317
-
1318
- \begin_layout Standard
1319
- At this point, there are no tokens left in
1320
- \family typewriter
1321
- A
1322
- \family default
1323
- and
1324
- \family typewriter
1325
- A2B
1326
- \family default
1327
- becomes
1328
- \emph on
1329
- \color green
1330
- disabled
1331
- \emph default
1332
- \color inherit
1333
- :
1334
- \end_layout
1335
-
1336
- \begin_layout LyX-Code
1337
- A2B.enabled?
1338
- \end_layout
1339
-
1340
- \begin_layout LyX-Code
1341
- #=> false
1342
- \end_layout
1343
-
1344
- \begin_layout Standard
1345
- Attempt to fire a disabled transition
1346
- \emph on
1347
- \color red
1348
- raises
1349
- \emph default
1350
- \color inherit
1351
- an
1352
- \emph on
1353
- \color red
1354
- error
1355
- \emph default
1356
- \color inherit
1357
- (in Ruby, errors are friendly objects, who, like damsels in distress, are
1358
- meant to be rescued with a bonus outcome):
1359
- \end_layout
1360
-
1361
- \begin_layout LyX-Code
1362
- A2B.fire!
1363
- \end_layout
1364
-
1365
- \begin_layout LyX-Code
1366
- #=> RuntimeError: Firing of #<Transition: A2B (tS)> would result in negative
1367
- marking!
1368
- \end_layout
1369
-
1370
- \begin_layout Subsection*
1371
- Functional transitions and non-integer marking
1372
- \end_layout
1373
-
1374
- \begin_layout Standard
1375
- So far, all the examples were compatible with classical Petri nets.
1376
- But
1377
- \family typewriter
1378
- YNelson
1379
- \family default
1380
- goes beyond – it represents
1381
- \emph on
1382
- functional Petri nets
1383
- \emph default
1384
- , similar to HFPNs proposed by
1385
- \begin_inset CommandInset citation
1386
- LatexCommand citet
1387
- key "Matsuno2011brs"
1388
-
1389
- \end_inset
1390
-
1391
- , which was already mentioned in the introduction.
1392
-
1393
- \family typewriter
1394
- YNelson
1395
- \family default
1396
- domain model is similar, but not identical.
1397
- On the side of similarities,
1398
- \family typewriter
1399
- YNelson
1400
- \family default
1401
- allows non-integer marking of places:
1402
- \end_layout
1403
-
1404
- \begin_layout LyX-Code
1405
- C = Place(
1406
- \color blue
1407
- marking
1408
- \color inherit
1409
- : 7.77 )
1410
- \end_layout
1411
-
1412
- \begin_layout LyX-Code
1413
- #=> #<Place: name: C, marking: 7.77, default_marking: ø>
1414
- \end_layout
1415
-
1416
- \begin_layout Standard
1417
- Here, you can notice that marking of places can be specified already upon
1418
- initialization using '
1419
- \family typewriter
1420
- :marking
1421
- \family default
1422
- '
1423
- \emph on
1424
- \color red
1425
- named argument
1426
- \emph default
1427
- \color inherit
1428
- .
1429
- Let us now define a
1430
- \emph on
1431
- \color blue
1432
- timed
1433
- \emph default
1434
- \color inherit
1435
- transition, representing logarithmic decay of
1436
- \family typewriter
1437
- C
1438
- \family default
1439
- with a rate constant of 0.05:
1440
- \end_layout
1441
-
1442
- \begin_layout LyX-Code
1443
- C_decay = Transition( stoichiometry: { C: -1 },
1444
- \color blue
1445
- rate
1446
- \color inherit
1447
- : 0.05 )
1448
- \end_layout
1449
-
1450
- \begin_layout LyX-Code
1451
- #=> #<Transition: C_decay (TS)>
1452
- \end_layout
1453
-
1454
- \begin_layout LyX-Code
1455
- C_decay.
1456
- \color blue
1457
- timed?
1458
- \end_layout
1459
-
1460
- \begin_layout LyX-Code
1461
- #=> true
1462
- \end_layout
1463
-
1464
- \begin_layout Standard
1465
- Here, in the
1466
- \family typewriter
1467
- transition
1468
- \family default
1469
- constructor method, apart from '
1470
- \family typewriter
1471
- stoichiometry:
1472
- \family default
1473
- ' named argument, another named argument, '
1474
- \family typewriter
1475
- rate:
1476
- \family default
1477
- ', is introduced.
1478
- Under '
1479
- \family typewriter
1480
- rate:
1481
- \family default
1482
- ', it is possible to specify the transition's
1483
- \emph on
1484
- \color green
1485
- function
1486
- \emph default
1487
- \color inherit
1488
- , which governs its rate.
1489
- Specifying a function in Ruby requires special syntax (called Ruby
1490
- \emph on
1491
- \color red
1492
- closures
1493
- \emph default
1494
- \color inherit
1495
- ), based on lambda calculus.
1496
- Ruby closures are easy to learn.
1497
- But for the moment, in
1498
- \family typewriter
1499
- C_decay
1500
- \family default
1501
- transition, we are taking use of the convenience, that allows us to pass
1502
- a numeric value under '
1503
- \family typewriter
1504
- rate:
1505
- \family default
1506
- ' named argument, and have
1507
- \family typewriter
1508
- YNelson
1509
- \family default
1510
- create default mass action equation, using the supplied number as its rate
1511
- constant.
1512
- For
1513
- \family typewriter
1514
- C_decay
1515
- \family default
1516
- stoichiometry,
1517
- \family typewriter
1518
- { C: -1 }
1519
- \family default
1520
- , default mass action will be logarithmic decay with rate constant 0.05.
1521
- Naturally, when firing timed transitions, the time interval (
1522
- \begin_inset Formula $\Delta$
1523
- \end_inset
1524
-
1525
- time) must be specified, for which the transition should be active:
1526
- \end_layout
1527
-
1528
- \begin_layout LyX-Code
1529
- C_decay.fire!( 1 )
1530
- \end_layout
1531
-
1532
- \begin_layout LyX-Code
1533
- #=> nil
1534
- \end_layout
1535
-
1536
- \begin_layout LyX-Code
1537
- C.marking
1538
- \end_layout
1539
-
1540
- \begin_layout LyX-Code
1541
- #=> 7.3815
1542
- \end_layout
1543
-
1544
- \begin_layout LyX-Code
1545
- C_decay.fire! 1
1546
- \end_layout
1547
-
1548
- \begin_layout LyX-Code
1549
- #=> nil
1550
- \end_layout
1551
-
1552
- \begin_layout LyX-Code
1553
- C.marking
1554
- \end_layout
1555
-
1556
- \begin_layout LyX-Code
1557
- #=> 7.012425
1558
- \end_layout
1559
-
1560
- \begin_layout LyX-Code
1561
- C_decay.fire!( 0.1 )
1562
- \end_layout
1563
-
1564
- \begin_layout LyX-Code
1565
- #=> nil
1566
- \end_layout
1567
-
1568
- \begin_layout LyX-Code
1569
- C.marking
1570
- \end_layout
1571
-
1572
- \begin_layout LyX-Code
1573
- #=> 6.977362875000001
1574
- \end_layout
1575
-
1576
- \begin_layout LyX-Code
1577
- 100.
1578
- \color red
1579
- times
1580
- \color inherit
1581
- do C_decay.fire! 1 end
1582
- \end_layout
1583
-
1584
- \begin_layout LyX-Code
1585
- #=> 100
1586
- \end_layout
1587
-
1588
- \begin_layout LyX-Code
1589
- C.marking
1590
- \end_layout
1591
-
1592
- \begin_layout LyX-Code
1593
- #=> 0.04130968078231133
1594
- \end_layout
1595
-
1596
- \begin_layout Standard
1597
- The penultimate statement was a call of Ruby '
1598
- \family typewriter
1599
- times
1600
- \family default
1601
- ' method with the integer
1602
- \family typewriter
1603
- 100
1604
- \family default
1605
- as the receiver, which results in 100 time repetition of the statement
1606
- inside
1607
- \family typewriter
1608
- \color red
1609
- do ...
1610
- end
1611
- \family default
1612
- \emph on
1613
- block
1614
- \emph default
1615
- \color inherit
1616
- .
1617
- Instead of
1618
- \family typewriter
1619
- do ...
1620
- end
1621
- \family default
1622
- , it is possible to write a block using curly braces
1623
- \family typewriter
1624
- \color red
1625
- { ...
1626
- }
1627
- \family default
1628
- \color inherit
1629
- :
1630
- \end_layout
1631
-
1632
- \begin_layout LyX-Code
1633
- 100.times { C_decay.fire! 1 }
1634
- \end_layout
1635
-
1636
- \begin_layout LyX-Code
1637
- #=> 100
1638
- \end_layout
1639
-
1640
- \begin_layout Standard
1641
- This will cause another 100 time units of
1642
- \family typewriter
1643
- C_decay
1644
- \family default
1645
- firing.
1646
- This brings
1647
- \family typewriter
1648
- C
1649
- \family default
1650
- marking down to almost zero:
1651
- \end_layout
1652
-
1653
- \begin_layout LyX-Code
1654
- C.marking
1655
- \end_layout
1656
-
1657
- \begin_layout LyX-Code
1658
- #=> 0.00024457517215434527
1659
- \end_layout
1660
-
1661
- \begin_layout Subsection*
1662
- Four transition types
1663
- \end_layout
1664
-
1665
- \begin_layout Standard
1666
- Thus far, we have demonstrated transitions with stoichiometry, which were
1667
- either
1668
- \emph on
1669
- timed
1670
- \emph default
1671
- or not timed (
1672
- \emph on
1673
- timeless
1674
- \emph default
1675
- ).
1676
- Timed transitions are denoted by capital
1677
- \begin_inset Quotes eld
1678
- \end_inset
1679
-
1680
-
1681
- \family typewriter
1682
- T
1683
- \family default
1684
-
1685
- \begin_inset Quotes erd
1686
- \end_inset
1687
-
1688
- , timeless transitions by small
1689
- \begin_inset Quotes eld
1690
- \end_inset
1691
-
1692
-
1693
- \family typewriter
1694
- t
1695
- \family default
1696
-
1697
- \begin_inset Quotes erd
1698
- \end_inset
1699
-
1700
- .
1701
- Similarly, stoichiometric transitions are denoted by capital
1702
- \begin_inset Quotes eld
1703
- \end_inset
1704
-
1705
-
1706
- \family typewriter
1707
- S
1708
- \family default
1709
-
1710
- \begin_inset Quotes erd
1711
- \end_inset
1712
-
1713
- , while transitions without stoichiometry (
1714
- \emph on
1715
- non-stoichiometric
1716
- \emph default
1717
- transitions) by small
1718
- \begin_inset Quotes eld
1719
- \end_inset
1720
-
1721
-
1722
- \family typewriter
1723
- s
1724
- \family default
1725
-
1726
- \begin_inset Quotes erd
1727
- \end_inset
1728
-
1729
- .
1730
- Together, this gives 4 basic types of transitions:
1731
- \family typewriter
1732
- TS
1733
- \family default
1734
- ,
1735
- \family typewriter
1736
- tS
1737
- \family default
1738
- ,
1739
- \family typewriter
1740
- Ts
1741
- \family default
1742
- , and
1743
- \family typewriter
1744
- ts
1745
- \family default
1746
- .
1747
- \end_layout
1748
-
1749
- \begin_layout Standard
1750
- The user can ask the type of a transition by calling the
1751
- \family typewriter
1752
- \color blue
1753
- type
1754
- \family default
1755
- \color inherit
1756
- method:
1757
- \end_layout
1758
-
1759
- \begin_layout LyX-Code
1760
- A2B.type
1761
- \end_layout
1762
-
1763
- \begin_layout LyX-Code
1764
- #=> :tS
1765
- \end_layout
1766
-
1767
- \begin_layout Standard
1768
- Or investigate the type with inquirer methods:
1769
- \end_layout
1770
-
1771
- \begin_layout LyX-Code
1772
- A2B.
1773
- \color blue
1774
- t?
1775
- \end_layout
1776
-
1777
- \begin_layout LyX-Code
1778
- #=> true
1779
- \end_layout
1780
-
1781
- \begin_layout LyX-Code
1782
- A2B.
1783
- \color blue
1784
- T?
1785
- \end_layout
1786
-
1787
- \begin_layout LyX-Code
1788
- #=> false
1789
- \end_layout
1790
-
1791
- \begin_layout LyX-Code
1792
- A2B.
1793
- \color blue
1794
- s?
1795
- \end_layout
1796
-
1797
- \begin_layout LyX-Code
1798
- #=> false
1799
- \end_layout
1800
-
1801
- \begin_layout LyX-Code
1802
- A2B.
1803
- \color blue
1804
- S?
1805
- \end_layout
1806
-
1807
- \begin_layout LyX-Code
1808
- #=> true
1809
- \end_layout
1810
-
1811
- \begin_layout LyX-Code
1812
- A2B.
1813
- \color blue
1814
- TS?
1815
- \end_layout
1816
-
1817
- \begin_layout LyX-Code
1818
- #=> false
1819
- \end_layout
1820
-
1821
- \begin_layout LyX-Code
1822
- A2B.
1823
- \color blue
1824
- tS?
1825
- \end_layout
1826
-
1827
- \begin_layout LyX-Code
1828
- #=> true
1829
- \end_layout
1830
-
1831
- \begin_layout LyX-Code
1832
- A2B.
1833
- \color blue
1834
- Ts?
1835
- \end_layout
1836
-
1837
- \begin_layout LyX-Code
1838
- #=> false
1839
- \end_layout
1840
-
1841
- \begin_layout LyX-Code
1842
- A2B.
1843
- \color blue
1844
- ts?
1845
- \end_layout
1846
-
1847
- \begin_layout LyX-Code
1848
- #=> false
1849
- \end_layout
1850
-
1851
- \begin_layout Subsection*
1852
- Assignment transitions
1853
- \end_layout
1854
-
1855
- \begin_layout Standard
1856
- In
1857
- \family typewriter
1858
- YNelson
1859
- \family default
1860
- , there is one more transition type: an assignment transition, denoted by
1861
-
1862
- \begin_inset Quotes eld
1863
- \end_inset
1864
-
1865
-
1866
- \family typewriter
1867
- A
1868
- \family default
1869
-
1870
- \begin_inset Quotes erd
1871
- \end_inset
1872
-
1873
- .
1874
- Assignment transitions do not add or subtract tokens from their target,
1875
- but completely replace the codomain marking with their output.
1876
- (Again, in
1877
- \family typewriter
1878
- YNelson
1879
- \family default
1880
- transitions,
1881
- \emph on
1882
- domain
1883
- \emph default
1884
- and
1885
- \emph on
1886
- codomain
1887
- \emph default
1888
- mean respectively upstream and downstream places.) Transitions other than
1889
-
1890
- \family typewriter
1891
- A
1892
- \family default
1893
- transitions can be collectively called non-assignment transitions, denoted
1894
- by small
1895
- \begin_inset Quotes eld
1896
- \end_inset
1897
-
1898
-
1899
- \family typewriter
1900
- a
1901
- \family default
1902
-
1903
- \begin_inset Quotes erd
1904
- \end_inset
1905
-
1906
- .
1907
- Note that assignment action is already achievable with plain
1908
- \family typewriter
1909
- ts
1910
- \family default
1911
- transitions (by subtracting away the previous codomain marking), so
1912
- \family typewriter
1913
- A
1914
- \family default
1915
- transitions are not strictly needed – their separate existence is just
1916
- a syntactic convenience.
1917
- \end_layout
1918
-
1919
- \begin_layout Standard
1920
- One way to construct assignment transitions is by setting
1921
- \family typewriter
1922
- :assignment
1923
- \family default
1924
- named argument to
1925
- \emph on
1926
- true
1927
- \emph default
1928
- :
1929
- \end_layout
1930
-
1931
- \begin_layout LyX-Code
1932
- A_to_42 = Transition codomain: A, assignment: lambda { 42 }
1933
- \end_layout
1934
-
1935
- \begin_layout LyX-Code
1936
- #=> #<Transition: A_to_42 (A Assign.)>
1937
- \end_layout
1938
-
1939
- \begin_layout Standard
1940
- Firing this transition results in marking of
1941
- \family typewriter
1942
- A
1943
- \family default
1944
- being set to 42:
1945
- \end_layout
1946
-
1947
- \begin_layout LyX-Code
1948
- A_to_42.fire!
1949
- \end_layout
1950
-
1951
- \begin_layout LyX-Code
1952
- #=> nil
1953
- \end_layout
1954
-
1955
- \begin_layout LyX-Code
1956
- A.marking
1957
- \end_layout
1958
-
1959
- \begin_layout LyX-Code
1960
- #=> 42
1961
- \end_layout
1962
-
1963
- \begin_layout Standard
1964
- Assignment transitions are of special type
1965
- \family typewriter
1966
- A
1967
- \family default
1968
- :
1969
- \end_layout
1970
-
1971
- \begin_layout LyX-Code
1972
- A_to_42.type
1973
- \end_layout
1974
-
1975
- \begin_layout LyX-Code
1976
- #=> :A
1977
- \end_layout
1978
-
1979
- \begin_layout LyX-Code
1980
- A_to_42.A?
1981
- \end_layout
1982
-
1983
- \begin_layout LyX-Code
1984
- #=> true
1985
- \end_layout
1986
-
1987
- \begin_layout LyX-Code
1988
- A_to_42.a?
1989
- \end_layout
1990
-
1991
- \begin_layout LyX-Code
1992
- #=> false
1993
- \end_layout
1994
-
1995
- \begin_layout Part*
1996
- Example II: Convenience
1997
- \end_layout
1998
-
1999
- \begin_layout Standard
2000
- So far, we have seen only one
2001
- \emph on
2002
- constructor method
2003
- \emph default
2004
- for transitions:
2005
- \family typewriter
2006
- Transition()
2007
- \family default
2008
- .
2009
-
2010
- \family typewriter
2011
- Transition()
2012
- \family default
2013
- method accepts several different named arguments (
2014
- \family typewriter
2015
- :domain
2016
- \family default
2017
- ,
2018
- \family typewriter
2019
- :codomain
2020
- \family default
2021
- ,
2022
- \family typewriter
2023
- :stoichiometry
2024
- \family default
2025
-
2026
- \family typewriter
2027
- :assignment
2028
- \family default
2029
- ,
2030
- \family typewriter
2031
- :rate
2032
- \family default
2033
- ,
2034
- \family typewriter
2035
- :action
2036
- \family default
2037
- ,
2038
- \family typewriter
2039
- :name
2040
- \family default
2041
- ...) and depending on their values, returns a
2042
- \family typewriter
2043
- YNelson::Transition
2044
- \family default
2045
- class object of required type and properties.
2046
- \end_layout
2047
-
2048
- \begin_layout Standard
2049
- Use of whole words in the constructor method makes the
2050
- \family typewriter
2051
- YNelson
2052
- \family default
2053
- DSL very explicit.
2054
- But for the cases, where trading readability for brevity is desirable,
2055
- these syntactic constructs can be shortened.
2056
- Actually, we have already used this convenience in the earlier examples.
2057
- We didn't type :
2058
- \end_layout
2059
-
2060
- \begin_layout LyX-Code
2061
- Transition( name:
2062
- \begin_inset Quotes eld
2063
- \end_inset
2064
-
2065
- A2B
2066
- \begin_inset Quotes erd
2067
- \end_inset
2068
-
2069
- , codomain: [A, B], stoichiometry: [-1, 1] )
2070
- \end_layout
2071
-
2072
- \begin_layout LyX-Code
2073
- A2B = transition( :A2B )
2074
- \end_layout
2075
-
2076
- \begin_layout Standard
2077
- Instead, we just typed
2078
- \end_layout
2079
-
2080
- \begin_layout LyX-Code
2081
- A2B = Transition( stoichiometry: { A: -1, B: 1 } )
2082
- \end_layout
2083
-
2084
- \begin_layout Standard
2085
- Even shorter way to express the same would be:
2086
- \end_layout
2087
-
2088
- \begin_layout LyX-Code
2089
- A2B = Transition s: { A: -1, B: 1 }
2090
- \end_layout
2091
-
2092
- \begin_layout Standard
2093
- The above is a timeless transition.
2094
- But we could think eg.
2095
- about a more complicated transition, that would transfer tokens from
2096
- \family typewriter
2097
- B
2098
- \family default
2099
- to
2100
- \family typewriter
2101
- A
2102
- \family default
2103
- with rate depending on the square root of the product of marking of
2104
- \family typewriter
2105
- C
2106
- \family default
2107
- and
2108
- \family typewriter
2109
- D
2110
- \family default
2111
- .
2112
- Start a new
2113
- \family typewriter
2114
- irb
2115
- \family default
2116
- session and type:
2117
- \end_layout
2118
-
2119
- \begin_layout LyX-Code
2120
- require 'y_nelson'
2121
- \end_layout
2122
-
2123
- \begin_layout LyX-Code
2124
- include YNelson
2125
- \end_layout
2126
-
2127
- \begin_layout LyX-Code
2128
- A = Place( default_marking: 5 )
2129
- \end_layout
2130
-
2131
- \begin_layout LyX-Code
2132
- B = Place m!: 5 # notice
2133
- \begin_inset Quotes eld
2134
- \end_inset
2135
-
2136
- m!
2137
- \begin_inset Quotes erd
2138
- \end_inset
2139
-
2140
- alias for
2141
- \begin_inset Quotes eld
2142
- \end_inset
2143
-
2144
- default marking
2145
- \begin_inset Quotes erd
2146
- \end_inset
2147
-
2148
-
2149
- \end_layout
2150
-
2151
- \begin_layout LyX-Code
2152
- C = Place m!: 1
2153
- \end_layout
2154
-
2155
- \begin_layout LyX-Code
2156
- D = Place m!: 1
2157
- \end_layout
2158
-
2159
- \begin_layout Standard
2160
- Let's check our work:
2161
- \end_layout
2162
-
2163
- \begin_layout LyX-Code
2164
- places.map &:m
2165
- \end_layout
2166
-
2167
- \begin_layout LyX-Code
2168
- #=> [5, 5, 1, 1]
2169
- \end_layout
2170
-
2171
- \begin_layout Standard
2172
- Indeed, the net state has been set according to the default markings of
2173
- the places.
2174
- Now let's define the transition we want:
2175
- \end_layout
2176
-
2177
- \begin_layout LyX-Code
2178
- B2A = Transition( stoichiometry: { B: -1, A: 1 },
2179
- \end_layout
2180
-
2181
- \begin_layout LyX-Code
2182
- domain: [C, D],
2183
- \end_layout
2184
-
2185
- \begin_layout LyX-Code
2186
- rate: lambda { |x, y| ( x * y ) ** 0.5 } )
2187
- \end_layout
2188
-
2189
- \begin_layout LyX-Code
2190
- #=> #<Transition: B2A (TS)>
2191
- \end_layout
2192
-
2193
- \begin_layout Standard
2194
- To prove that it works, let's fire it for 0.1 time units:
2195
- \end_layout
2196
-
2197
- \begin_layout LyX-Code
2198
- B2A.fire! 0.1
2199
- \end_layout
2200
-
2201
- \begin_layout LyX-Code
2202
- #=> nil
2203
- \end_layout
2204
-
2205
- \begin_layout LyX-Code
2206
- places.map &:m
2207
- \end_layout
2208
-
2209
- \begin_layout LyX-Code
2210
- #=> [5.1, 4.9, 1, 1]
2211
- \end_layout
2212
-
2213
- \begin_layout Standard
2214
- You can try to change marking of C and D to control the rate:
2215
- \end_layout
2216
-
2217
- \begin_layout LyX-Code
2218
- [A, B].each &:
2219
- \color blue
2220
- reset_marking
2221
- \end_layout
2222
-
2223
- \begin_layout LyX-Code
2224
- C.m = 4
2225
- \end_layout
2226
-
2227
- \begin_layout LyX-Code
2228
- D.m = 9
2229
- \end_layout
2230
-
2231
- \begin_layout LyX-Code
2232
- places.map &:m
2233
- \end_layout
2234
-
2235
- \begin_layout LyX-Code
2236
- #=> [5, 5, 4, 9]
2237
- \end_layout
2238
-
2239
- \begin_layout LyX-Code
2240
- B2A.fire! 0.1
2241
- \end_layout
2242
-
2243
- \begin_layout LyX-Code
2244
- places.map &:m
2245
- \end_layout
2246
-
2247
- \begin_layout LyX-Code
2248
- #=> [5.6, 4.4, 4, 9]
2249
- \end_layout
2250
-
2251
- \begin_layout Standard
2252
- We can see that the rate of
2253
- \family typewriter
2254
- B2A
2255
- \family default
2256
- has risen 6 times as expected (4 * 9 is 36), so
2257
- \family typewriter
2258
- B2A
2259
- \family default
2260
- works.
2261
- The question is, could we have written
2262
- \family typewriter
2263
- B2A
2264
- \family default
2265
- more concisely? For
2266
- \family typewriter
2267
- TS
2268
- \family default
2269
- transitions (check
2270
- \family typewriter
2271
- B2A.type
2272
- \family default
2273
- to make sure that it's a
2274
- \family typewriter
2275
- TS
2276
- \family default
2277
- transition),
2278
- \family typewriter
2279
- \color blue
2280
- TS()
2281
- \family default
2282
- \color inherit
2283
- constructor is available, allowing to express the same transition with
2284
- a shorter syntactic construct:
2285
- \end_layout
2286
-
2287
- \begin_layout LyX-Code
2288
- B2A = TS domain: [C, D], A: 1, B: -1 do |x, y| ( x * y ) ** 0.5 end
2289
- \end_layout
2290
-
2291
- \begin_layout Standard
2292
- Restart the
2293
- \family typewriter
2294
- irb
2295
- \family default
2296
- session again and use this shorter construct to see that the resulting
2297
- transition behaves like before.
2298
- Note the
2299
- \family typewriter
2300
- \color red
2301
- do ...
2302
- end
2303
- \family default
2304
- \color inherit
2305
- part of the construct: Using lambda syntax, it defines the rate function
2306
- of the transition.
2307
- \end_layout
2308
-
2309
- \begin_layout Standard
2310
- One more convenience constructor I want to mention here is
2311
- \family typewriter
2312
- \color blue
2313
- AT()
2314
- \family default
2315
- \color inherit
2316
- constructor for assignment transition.
2317
- Earlier, we defined:
2318
- \end_layout
2319
-
2320
- \begin_layout LyX-Code
2321
- A_to_42 = Transition codomain: A, assignment: lambda { 42 }
2322
- \end_layout
2323
-
2324
- \begin_layout Standard
2325
- This can be conveniently rewritten using
2326
- \family typewriter
2327
- AT()
2328
- \family default
2329
- constructor as:
2330
- \end_layout
2331
-
2332
- \begin_layout LyX-Code
2333
- A_to_42 = AT A do 42 end
2334
- \end_layout
2335
-
2336
- \begin_layout Standard
2337
- In short, syntactic shorthands are less readable than full
2338
- \family typewriter
2339
- Transition()
2340
- \family default
2341
- statements, but can save a lot of space and typing.
2342
- In any case, in Ruby, the user can easily defined new aliases and routines
2343
- that make the frequent tasks easier to type.
2344
- \end_layout
2345
-
2346
- \begin_layout Part*
2347
- Example III: YNelson::Simulation
2348
- \end_layout
2349
-
2350
- \begin_layout Standard
2351
- So far, we have been defining Petri nets and playing the token game using
2352
-
2353
- \family typewriter
2354
- #fire!
2355
- \family default
2356
- method, let us now simulate a Petri net inside
2357
- \family typewriter
2358
- YNelson
2359
- \color blue
2360
- ::Simulation
2361
- \family default
2362
- \color inherit
2363
- .
2364
- Restart your irb session as described in the
2365
- \series bold
2366
- Prerequisites
2367
- \series default
2368
- chapter.
2369
- We will now define 2 places.
2370
- Since we are going to use
2371
- \family typewriter
2372
- TimedSimulation
2373
- \family default
2374
- , the marking owned by
2375
- \family typewriter
2376
- YNelson::Place
2377
- \family default
2378
- instances is irrelevant.
2379
- We just need to specify the initial state.
2380
- One way to do this is by specifying
2381
- \family typewriter
2382
- \color blue
2383
- :default_marking
2384
- \family default
2385
- \color inherit
2386
- named argument:
2387
- \end_layout
2388
-
2389
- \begin_layout LyX-Code
2390
- A = Place(
2391
- \color blue
2392
- default_marking:
2393
- \color inherit
2394
- 0.5 )
2395
- \end_layout
2396
-
2397
- \begin_layout LyX-Code
2398
- #=> #<Place: name: A, marking: 0.5, default_marking: 0.5>
2399
- \end_layout
2400
-
2401
- \begin_layout LyX-Code
2402
- B = Place( default_marking: 0.5 )
2403
- \end_layout
2404
-
2405
- \begin_layout LyX-Code
2406
- #=> #<Place: name: B, marking: 0.5, default_marking: 0.5>
2407
- \end_layout
2408
-
2409
- \begin_layout Standard
2410
- Now let us define a transition corresponding to pumping
2411
- \family typewriter
2412
- A
2413
- \family default
2414
- out of the system at a constant rate 0.005 per time unit.
2415
- \end_layout
2416
-
2417
- \begin_layout LyX-Code
2418
- A_pump = Transition( stoichiometry: { A: -1 }, rate: proc { 0.005 } )
2419
- \end_layout
2420
-
2421
- \begin_layout LyX-Code
2422
- #=> #<Transition: A_pump (TS)>
2423
- \end_layout
2424
-
2425
- \begin_layout Standard
2426
- Here,
2427
- \family typewriter
2428
- proc { 0.005 }
2429
- \family default
2430
- is a closure, that defines the rate function.
2431
- Closure
2432
- \family typewriter
2433
- proc { 0.005 }
2434
- \family default
2435
- ensures fixed rate 0.005 per time unit regardless of the marking of
2436
- \family typewriter
2437
- A
2438
- \family default
2439
- .
2440
- You can notice, that this closure expects no arguments and always outputs
2441
- 0.005 as its return value.
2442
- It is the simplest possible way to write a constant function.
2443
- For comparison,
2444
- \end_layout
2445
-
2446
- \begin_layout LyX-Code
2447
- B_decay = Transition( stoichiometry: { B: -1 }, rate: 0.05 )
2448
- \end_layout
2449
-
2450
- \begin_layout LyX-Code
2451
- #=> #<Transition: B_decay (TS)>
2452
- \end_layout
2453
-
2454
- \begin_layout Standard
2455
- will behind the scenes automatically create a slightly more complicated
2456
- mass action closure, which is logarithmic decay of
2457
- \family typewriter
2458
- B
2459
- \family default
2460
- in this case.
2461
- (You should remember this from
2462
- \series bold
2463
- Example I
2464
- \series default
2465
- .) Now we have created a net of 2 places and 2 transitions:
2466
- \end_layout
2467
-
2468
- \begin_layout LyX-Code
2469
- net
2470
- \end_layout
2471
-
2472
- \begin_layout LyX-Code
2473
- #=> #<Net: name: Top, 2 pp, 2 tt>
2474
- \end_layout
2475
-
2476
- \begin_layout Standard
2477
- We can execute this Petri net as
2478
- \family typewriter
2479
- TimedSimulation
2480
- \family default
2481
- simply by typing:
2482
- \end_layout
2483
-
2484
- \begin_layout LyX-Code
2485
-
2486
- \color blue
2487
- run!
2488
- \end_layout
2489
-
2490
- \begin_layout LyX-Code
2491
- #=> 60
2492
- \end_layout
2493
-
2494
- \begin_layout Standard
2495
- At this point,
2496
- \family typewriter
2497
- run!
2498
- \family default
2499
- creates and executes a
2500
- \family typewriter
2501
- TimedSimulation
2502
- \family default
2503
- instance.
2504
- The return value is the simulation instance itself (see the inspect string
2505
- above), which by now has already finished execution and holds the simulation
2506
- results.
2507
- This simulation instance is accessible via
2508
- \family typewriter
2509
- simulation
2510
- \family default
2511
- method.
2512
- \end_layout
2513
-
2514
- \begin_layout LyX-Code
2515
-
2516
- \color blue
2517
- simulation
2518
- \end_layout
2519
-
2520
- \begin_layout LyX-Code
2521
- #=> #<Simulation: time: 60, pp: 2, tt: 2, oid: 75530290>
2522
- \end_layout
2523
-
2524
- \begin_layout Standard
2525
- The simulation does not affect the net.
2526
- The simulation instance works with its own
2527
- \begin_inset Quotes eld
2528
- \end_inset
2529
-
2530
- mental image
2531
- \begin_inset Quotes erd
2532
- \end_inset
2533
-
2534
- of the net, therefore the marking owned by
2535
- \family typewriter
2536
- YNelson::Place
2537
- \family default
2538
- instances does not change:
2539
- \end_layout
2540
-
2541
- \begin_layout LyX-Code
2542
- places.map &:marking
2543
- \end_layout
2544
-
2545
- \begin_layout LyX-Code
2546
- #=> [0.5, 0.5]
2547
- \end_layout
2548
-
2549
- \begin_layout Standard
2550
- In a general case, it would be necessary to specify the simulation settings
2551
- (step size, sampling rate, simulation time etc.) before running the simulation.
2552
- Since we have not specified any, default settings were used:
2553
- \end_layout
2554
-
2555
- \begin_layout LyX-Code
2556
- simulation.
2557
- \color blue
2558
- settings
2559
- \end_layout
2560
-
2561
- \begin_layout LyX-Code
2562
- #=> {:step=>0.1, :sampling=>5, :time=>0..60}
2563
- \end_layout
2564
-
2565
- \begin_layout Standard
2566
- We can see sampling done by the simulation by typing:
2567
- \end_layout
2568
-
2569
- \begin_layout LyX-Code
2570
-
2571
- \color blue
2572
- print_recording
2573
- \end_layout
2574
-
2575
- \begin_layout LyX-Code
2576
- #=> :A :B
2577
- \end_layout
2578
-
2579
- \begin_layout LyX-Code
2580
- ----------------
2581
- \end_layout
2582
-
2583
- \begin_layout LyX-Code
2584
- 0.5000 0.5000
2585
- \end_layout
2586
-
2587
- \begin_layout LyX-Code
2588
- 0.4750 0.3892
2589
- \end_layout
2590
-
2591
- \begin_layout LyX-Code
2592
- 0.4500 0.3029
2593
- \end_layout
2594
-
2595
- \begin_layout LyX-Code
2596
- 0.4250 0.2357
2597
- \end_layout
2598
-
2599
- \begin_layout LyX-Code
2600
- 0.4000 0.1835
2601
- \end_layout
2602
-
2603
- \begin_layout LyX-Code
2604
- 0.3750 0.1428
2605
- \end_layout
2606
-
2607
- \begin_layout LyX-Code
2608
- 0.3500 0.1111
2609
- \end_layout
2610
-
2611
- \begin_layout LyX-Code
2612
- 0.3250 0.0865
2613
- \end_layout
2614
-
2615
- \begin_layout LyX-Code
2616
- 0.3000 0.0673
2617
- \end_layout
2618
-
2619
- \begin_layout LyX-Code
2620
- 0.2750 0.0524
2621
- \end_layout
2622
-
2623
- \begin_layout LyX-Code
2624
- 0.2500 0.0408
2625
- \end_layout
2626
-
2627
- \begin_layout LyX-Code
2628
- 0.2250 0.0317
2629
- \end_layout
2630
-
2631
- \begin_layout LyX-Code
2632
- 0.2000 0.0247
2633
- \end_layout
2634
-
2635
- \begin_layout LyX-Code
2636
- nil
2637
- \end_layout
2638
-
2639
- \begin_layout Standard
2640
- Indeed,
2641
- \family typewriter
2642
- A
2643
- \family default
2644
- is decreasing at a constant rate, while
2645
- \family typewriter
2646
- B
2647
- \family default
2648
- undergoes logarithmic decay.
2649
- In a graphical desktop, we can plot a graph (requires
2650
- \emph on
2651
- gnuplot
2652
- \emph default
2653
- gem):
2654
- \end_layout
2655
-
2656
- \begin_layout LyX-Code
2657
-
2658
- \color blue
2659
- recording.plot
2660
- \color inherit
2661
- # plots a graph
2662
- \end_layout
2663
-
2664
- \begin_layout LyX-Code
2665
- #=> ""
2666
- \end_layout
2667
-
2668
- \begin_layout Standard
2669
- Previous command plots the default feature set, which is marking of the
2670
- places.
2671
- We can investigate also features of the recording (gradient or delta of
2672
- places, firing or flux of the transitions...):
2673
- \end_layout
2674
-
2675
- \begin_layout LyX-Code
2676
- recording.gradient.plot
2677
- \end_layout
2678
-
2679
- \begin_layout LyX-Code
2680
- recording.flux.plot
2681
- \end_layout
2682
-
2683
- \begin_layout LyX-Code
2684
- recording.delta( delta_time: 0.1 ).plot
2685
- \end_layout
2686
-
2687
- \begin_layout Standard
2688
- The last feature set – delta – requires
2689
- \family typewriter
2690
- delta_time
2691
- \family default
2692
- named argument to extrapolate the changes (deltas) of the places in the
2693
- given delta time.
2694
- As for
2695
- \family typewriter
2696
- firing
2697
- \family default
2698
- , a feature of
2699
- \family typewriter
2700
- tS
2701
- \family default
2702
- transitions, the plot would show nothing here, as there ar no
2703
- \family typewriter
2704
- tS
2705
- \family default
2706
- transitions here.
2707
- \end_layout
2708
-
2709
- \begin_layout Part*
2710
- Example IV: A real system.
2711
- \end_layout
2712
-
2713
- \begin_layout Standard
2714
- A highly simplified cell-biological pathway simulated with
2715
- \family typewriter
2716
- YNelson::TimedSimulation
2717
- \family default
2718
- .
2719
- Let's first define some assumptions.
2720
- Type in the following commands (output not shown):
2721
- \end_layout
2722
-
2723
- \begin_layout LyX-Code
2724
- require 'y_nelson' and include YNelson
2725
- \end_layout
2726
-
2727
- \begin_layout LyX-Code
2728
-
2729
- \end_layout
2730
-
2731
- \begin_layout LyX-Code
2732
- Pieces_per_microM = 100_000
2733
- \end_layout
2734
-
2735
- \begin_layout LyX-Code
2736
-
2737
- \color blue
2738
- set_step
2739
- \color inherit
2740
- 10
2741
- \end_layout
2742
-
2743
- \begin_layout LyX-Code
2744
-
2745
- \color blue
2746
- set_sampling
2747
- \color inherit
2748
- 30
2749
- \end_layout
2750
-
2751
- \begin_layout LyX-Code
2752
-
2753
- \color blue
2754
- set_target_time
2755
- \color inherit
2756
- 30 * 60
2757
- \end_layout
2758
-
2759
- \begin_layout Standard
2760
- Let's define places corresponding to chemical species first (note that
2761
- \family typewriter
2762
- :
2763
- \color blue
2764
- m!
2765
- \family default
2766
- \color inherit
2767
- is a synonym for
2768
- \family typewriter
2769
- :default_marking)
2770
- \end_layout
2771
-
2772
- \begin_layout LyX-Code
2773
- AMP = Place
2774
- \color blue
2775
- m!
2776
- \color inherit
2777
- : 8695.0
2778
- \end_layout
2779
-
2780
- \begin_layout LyX-Code
2781
- ADP = Place m!: 6521.0
2782
- \end_layout
2783
-
2784
- \begin_layout LyX-Code
2785
- ATP = Place m!: 3152.0
2786
- \end_layout
2787
-
2788
- \begin_layout LyX-Code
2789
- DeoxyCytidine = Place m!: 5.0
2790
- \end_layout
2791
-
2792
- \begin_layout LyX-Code
2793
- DeoxyCTP = Place m!: 20.0
2794
- \end_layout
2795
-
2796
- \begin_layout LyX-Code
2797
- DeoxyGMP = Place m!: 20.0
2798
- \end_layout
2799
-
2800
- \begin_layout LyX-Code
2801
- UMP_UDP_pool = Place m!: 2737.0
2802
- \end_layout
2803
-
2804
- \begin_layout LyX-Code
2805
- DeoxyUMP_DeoxyUDP_pool = Place m!: 10.0
2806
- \end_layout
2807
-
2808
- \begin_layout LyX-Code
2809
- DeoxyTMP = Place m!: 50.0
2810
- \end_layout
2811
-
2812
- \begin_layout LyX-Code
2813
- DeoxyTDP_DeoxyTTP_pool = Place m!: 100.0
2814
- \end_layout
2815
-
2816
- \begin_layout LyX-Code
2817
- Thymidine = Place m!: 10.0
2818
- \end_layout
2819
-
2820
- \begin_layout Standard
2821
- All the places above have their marking in micromolars.
2822
- The enzyme places below will have their marking in molecules per cell:
2823
- \end_layout
2824
-
2825
- \begin_layout LyX-Code
2826
- TK1 = Place m!: 100_000 / Pieces_per_microM
2827
- \end_layout
2828
-
2829
- \begin_layout LyX-Code
2830
- TYMS = Place m!: 100_000 / Pieces_per_microM
2831
- \end_layout
2832
-
2833
- \begin_layout LyX-Code
2834
- RNR = Place m!: 100_000 / Pieces_per_microM
2835
- \end_layout
2836
-
2837
- \begin_layout LyX-Code
2838
- TMPK = Place m!: 100_000 / Pieces_per_microM
2839
- \end_layout
2840
-
2841
- \begin_layout Standard
2842
- Enzyme molecular weights:
2843
- \end_layout
2844
-
2845
- \begin_layout LyX-Code
2846
- TK1_kDa = 24.8
2847
- \end_layout
2848
-
2849
- \begin_layout LyX-Code
2850
- TYMS_kDa = 66.0
2851
- \end_layout
2852
-
2853
- \begin_layout LyX-Code
2854
- RNR_kDa = 140.0
2855
- \end_layout
2856
-
2857
- \begin_layout LyX-Code
2858
- TMPK_kDa = 50.0
2859
- \end_layout
2860
-
2861
- \begin_layout Standard
2862
- Enzyme specific activities (in
2863
- \emph on
2864
- micromolar
2865
- \emph default
2866
- /
2867
- \emph on
2868
- minute
2869
- \emph default
2870
- /
2871
- \emph on
2872
- mg
2873
- \emph default
2874
- ):
2875
- \end_layout
2876
-
2877
- \begin_layout LyX-Code
2878
- TK1_a = 5.40
2879
- \end_layout
2880
-
2881
- \begin_layout LyX-Code
2882
- TYMS_a = 3.80
2883
- \end_layout
2884
-
2885
- \begin_layout LyX-Code
2886
- RNR_a = 1.00
2887
- \end_layout
2888
-
2889
- \begin_layout LyX-Code
2890
- TMPK_a = 0.83
2891
- \end_layout
2892
-
2893
- \begin_layout Standard
2894
- Some species are kept fixed (as simulation-level clamps):
2895
- \end_layout
2896
-
2897
- \begin_layout LyX-Code
2898
-
2899
- \color blue
2900
- clamp
2901
- \color inherit
2902
- AMP: 8695.0, ADP: 6521.0, ATP: 3152.0
2903
- \end_layout
2904
-
2905
- \begin_layout LyX-Code
2906
- clamp DeoxyCytidine: 0.5, DeoxyCTP: 1.0, DeoxyGMP: 1.0
2907
- \end_layout
2908
-
2909
- \begin_layout LyX-Code
2910
- clamp Thymidine: 0.5
2911
- \end_layout
2912
-
2913
- \begin_layout LyX-Code
2914
- clamp UMP_UDP_pool: 2737.0
2915
- \end_layout
2916
-
2917
- \begin_layout Standard
2918
- Before defining transitions, let's define some functions first:
2919
- \end_layout
2920
-
2921
- \begin_layout LyX-Code
2922
- Vmax_per_min_per_enz_molecule =
2923
- \end_layout
2924
-
2925
- \begin_layout LyX-Code
2926
- lambda { |spec_act_microM_per_min_per_mg, kDa|
2927
- \end_layout
2928
-
2929
- \begin_layout LyX-Code
2930
- spec_act_microM_per_min_per_mg * kDa }
2931
- \end_layout
2932
-
2933
- \begin_layout LyX-Code
2934
- Vmax_per_min =
2935
- \end_layout
2936
-
2937
- \begin_layout LyX-Code
2938
- lambda { |spec_act, kDa, enz_molecules_per_cell|
2939
- \end_layout
2940
-
2941
- \begin_layout LyX-Code
2942
- Vmax_per_min_per_enz_molecule.( spec_act, kDa ) *
2943
- \end_layout
2944
-
2945
- \begin_layout LyX-Code
2946
- enz_molecules_per_cell }
2947
- \end_layout
2948
-
2949
- \begin_layout LyX-Code
2950
- Vmax_per_s =
2951
- \end_layout
2952
-
2953
- \begin_layout LyX-Code
2954
- lambda { |spec_act, kDa, enz_mol_per_cell|
2955
- \end_layout
2956
-
2957
- \begin_layout LyX-Code
2958
- Vmax_per_min.( spec_act, kDa, enz_mol_per_cell ) / 60 }
2959
- \end_layout
2960
-
2961
- \begin_layout LyX-Code
2962
- Km_reduced =
2963
- \end_layout
2964
-
2965
- \begin_layout LyX-Code
2966
- lambda { |km, ki_hash={}|
2967
- \end_layout
2968
-
2969
- \begin_layout LyX-Code
2970
- ki_hash.map { |c, ki| c / ki }.reduce( 1, :+ ) * km }
2971
- \end_layout
2972
-
2973
- \begin_layout LyX-Code
2974
- Occupancy =
2975
- \end_layout
2976
-
2977
- \begin_layout LyX-Code
2978
- lambda { |c, km, compet_inh_w_Ki_hash={}|
2979
- \end_layout
2980
-
2981
- \begin_layout LyX-Code
2982
- c / ( c + Km_reduced.( km, compet_inh_w_Ki_hash ) ) }
2983
- \end_layout
2984
-
2985
- \begin_layout LyX-Code
2986
- MM_with_inh_microM_per_second =
2987
- \end_layout
2988
-
2989
- \begin_layout LyX-Code
2990
- lambda { |c, spec_act, kDa, enz_mol_per_cell, km, ki_hash={}|
2991
- \end_layout
2992
-
2993
- \begin_layout LyX-Code
2994
- Vmax_per_s.( spec_act, kDa, enz_mol_per_cell ) *
2995
- \end_layout
2996
-
2997
- \begin_layout LyX-Code
2998
- Occupancy.( c, km, ki_hash ) }
2999
- \end_layout
3000
-
3001
- \begin_layout LyX-Code
3002
- MMi = MM_with_inh_microM_per_second
3003
- \end_layout
3004
-
3005
- \begin_layout Standard
3006
- Michaelis constants:
3007
- \end_layout
3008
-
3009
- \begin_layout LyX-Code
3010
- TK1_Thymidine_Km = 5.0
3011
- \end_layout
3012
-
3013
- \begin_layout LyX-Code
3014
- TYMS_DeoxyUMP_Km = 2.0
3015
- \end_layout
3016
-
3017
- \begin_layout LyX-Code
3018
- RNR_UDP_Km = 1.0
3019
- \end_layout
3020
-
3021
- \begin_layout LyX-Code
3022
- DNA_creation_speed = 3_000_000_000 / ( 12 * 3600 )
3023
- \end_layout
3024
-
3025
- \begin_layout LyX-Code
3026
- TMPK_DeoxyTMP_Km = 12.0
3027
- \end_layout
3028
-
3029
- \begin_layout Standard
3030
- And finally, let us define the transitions:
3031
- \end_layout
3032
-
3033
- \begin_layout LyX-Code
3034
- Transition name: :TK1_Thymidine_DeoxyTMP,
3035
- \end_layout
3036
-
3037
- \begin_layout LyX-Code
3038
-
3039
- \color blue
3040
- domain:
3041
- \color inherit
3042
- [ Thymidine, TK1, DeoxyTDP_DeoxyTTP_pool, DeoxyCTP,
3043
- \end_layout
3044
-
3045
- \begin_layout LyX-Code
3046
- DeoxyCytidine, AMP, ADP, ATP ],
3047
- \end_layout
3048
-
3049
- \begin_layout LyX-Code
3050
- stoichiometry: { Thymidine: -1, DeoxyTMP: 1 },
3051
- \end_layout
3052
-
3053
- \begin_layout LyX-Code
3054
- rate: proc { |c, e, pool1, ci2, ci3, master1, master2, master3|
3055
- \end_layout
3056
-
3057
- \begin_layout LyX-Code
3058
- ci1 = pool1 * master3 / ( master2 + master3 )
3059
- \end_layout
3060
-
3061
- \begin_layout LyX-Code
3062
- MMi.( c, TK1_a, TK1_kDa, e, TK1_Thymidine_Km,
3063
- \end_layout
3064
-
3065
- \begin_layout LyX-Code
3066
- ci1 => 13.5, ci2 => 0.8, ci3 => 40.0 ) }
3067
- \end_layout
3068
-
3069
- \begin_layout LyX-Code
3070
-
3071
- \end_layout
3072
-
3073
- \begin_layout LyX-Code
3074
- Transition name: :TYMS_DeoxyUMP_DeoxyTMP,
3075
- \end_layout
3076
-
3077
- \begin_layout LyX-Code
3078
- domain: [ DeoxyUMP_DeoxyUDP_pool, TYMS, AMP, ADP, ATP ],
3079
- \end_layout
3080
-
3081
- \begin_layout LyX-Code
3082
- stoichiometry: { DeoxyUMP_DeoxyUDP_pool: -1, DeoxyTMP: 1 },
3083
- \end_layout
3084
-
3085
- \begin_layout LyX-Code
3086
- rate: proc { |pool, e, mono, di, tri|
3087
- \end_layout
3088
-
3089
- \begin_layout LyX-Code
3090
- c = pool * di / ( mono + di )
3091
- \end_layout
3092
-
3093
- \begin_layout LyX-Code
3094
- MMi.( c, TYMS_a, TYMS_kDa, e, TYMS_DeoxyUMP_Km
3095
- ) }
3096
- \end_layout
3097
-
3098
- \begin_layout LyX-Code
3099
-
3100
- \end_layout
3101
-
3102
- \begin_layout LyX-Code
3103
- Transition name: :RNR_UDP_DeoxyUDP,
3104
- \end_layout
3105
-
3106
- \begin_layout LyX-Code
3107
- domain: [ UMP_UDP_pool, RNR, DeoxyUMP_DeoxyUDP_pool, AMP, ADP,
3108
- ATP ],
3109
- \end_layout
3110
-
3111
- \begin_layout LyX-Code
3112
- stoichiometry: { UMP_UDP_pool: -1, DeoxyUMP_DeoxyUDP_pool: 1
3113
- },
3114
- \end_layout
3115
-
3116
- \begin_layout LyX-Code
3117
- rate: proc { |pool, e, mono, di, tri|
3118
- \end_layout
3119
-
3120
- \begin_layout LyX-Code
3121
- c = pool * di / ( mono + di )
3122
- \end_layout
3123
-
3124
- \begin_layout LyX-Code
3125
- MMi.( c, RNR_a, RNR_kDa, e, RNR_UDP_Km ) }
3126
- \end_layout
3127
-
3128
- \begin_layout LyX-Code
3129
-
3130
- \end_layout
3131
-
3132
- \begin_layout LyX-Code
3133
- Transition name: :DNA_polymerase_consumption_of_DeoxyTTP,
3134
- \end_layout
3135
-
3136
- \begin_layout LyX-Code
3137
- stoichiometry: { DeoxyTDP_DeoxyTTP_pool: -1 },
3138
- \end_layout
3139
-
3140
- \begin_layout LyX-Code
3141
- rate: proc { DNA_creation_speed / 4 }
3142
- \end_layout
3143
-
3144
- \begin_layout LyX-Code
3145
-
3146
- \end_layout
3147
-
3148
- \begin_layout LyX-Code
3149
- Transition name: :TMPK_DeoxyTMP_DeoxyTDP,
3150
- \end_layout
3151
-
3152
- \begin_layout LyX-Code
3153
- domain: [ DeoxyTMP, TMPK, DeoxyTDP_DeoxyTTP_pool, DeoxyGMP, AMP,
3154
- ADP, ATP ],
3155
- \end_layout
3156
-
3157
- \begin_layout LyX-Code
3158
- stoichiometry: { DeoxyTMP: -1, TMPK: 0, DeoxyTDP_DeoxyTTP_pool:
3159
- 1 },
3160
- \end_layout
3161
-
3162
- \begin_layout LyX-Code
3163
- rate: proc { |c, e, pool, ci4, mono, di, tri|
3164
- \end_layout
3165
-
3166
- \begin_layout LyX-Code
3167
- ci1 = di
3168
- \end_layout
3169
-
3170
- \begin_layout LyX-Code
3171
- ci2 = pool * di / ( di + tri )
3172
- \end_layout
3173
-
3174
- \begin_layout LyX-Code
3175
- ci3 = pool * tri / ( di + tri )
3176
- \end_layout
3177
-
3178
- \begin_layout LyX-Code
3179
- MMi.( c, TMPK_a, TMPK_kDa, e, TMPK_DeoxyTMP_Km,
3180
- \end_layout
3181
-
3182
- \begin_layout LyX-Code
3183
- ci1 => 250.0, ci2 => 30.0, ci3 => 750, ci4 =>
3184
- 117 ) }
3185
- \end_layout
3186
-
3187
- \begin_layout LyX-Code
3188
- # require 'mathn'
3189
- \end_layout
3190
-
3191
- \begin_layout LyX-Code
3192
- Transition name: :PhosphataseI,
3193
- \end_layout
3194
-
3195
- \begin_layout LyX-Code
3196
- stoichiometry: { DeoxyTMP: -1, Thymidine: 1 },
3197
- \end_layout
3198
-
3199
- \begin_layout LyX-Code
3200
- rate: 0.04
3201
- \end_layout
3202
-
3203
- \begin_layout LyX-Code
3204
-
3205
- \end_layout
3206
-
3207
- \begin_layout LyX-Code
3208
- Transition name: :PhosphataseII,
3209
- \end_layout
3210
-
3211
- \begin_layout LyX-Code
3212
- stoichiometry: { DeoxyTDP_DeoxyTTP_pool: -1, DeoxyTMP: 1 },
3213
- \end_layout
3214
-
3215
- \begin_layout LyX-Code
3216
- rate: 0.01
3217
- \end_layout
3218
-
3219
- \begin_layout Standard
3220
- The created net can be visualized by:
3221
- \end_layout
3222
-
3223
- \begin_layout LyX-Code
3224
- net.visualize
3225
- \end_layout
3226
-
3227
- \begin_layout Standard
3228
- The simulation should work.
3229
- \end_layout
3230
-
3231
- \begin_layout LyX-Code
3232
- run!
3233
- \end_layout
3234
-
3235
- \begin_layout Standard
3236
- State recording can be plotted by:
3237
- \end_layout
3238
-
3239
- \begin_layout LyX-Code
3240
- recording.plot
3241
- \end_layout
3242
-
3243
- \begin_layout Standard
3244
- Flux of the transitions can be plotted by:
3245
- \end_layout
3246
-
3247
- \begin_layout LyX-Code
3248
- recording.flux.plot
3249
- \end_layout
3250
-
3251
- \begin_layout Part*
3252
- Example V: Using SY.
3253
- \end_layout
3254
-
3255
- \begin_layout Standard
3256
- Here, we'll take a look at using
3257
- \family typewriter
3258
- YNelson
3259
- \family default
3260
- with
3261
- \family typewriter
3262
- \color blue
3263
- SY
3264
- \family default
3265
- metrology library
3266
- \color inherit
3267
- .
3268
- If you are experienced with biochemical modeling, then you surely know
3269
- how big pain in the heel physical units are.
3270
- Also, in
3271
- \series bold
3272
- Example III
3273
- \series default
3274
- , you might have noticed how much attention has been spent on units (in
3275
- the assumptions, variable names, constant names...) You could have noticed
3276
- messy unit conversion formulas.
3277
- The aim of
3278
- \family typewriter
3279
- SY
3280
- \family default
3281
- is to take care of all this, to relieve the modeler from the task of unit
3282
- conversion, to clean up the model code, and let the modeler concentrate
3283
- on the real issue.
3284
- \end_layout
3285
-
3286
- \begin_layout Subsection*
3287
-
3288
- \family typewriter
3289
- SY
3290
- \family default
3291
- metrology library
3292
- \end_layout
3293
-
3294
- \begin_layout Standard
3295
-
3296
- \family typewriter
3297
- SY
3298
- \family default
3299
- is publicly available as a Ruby gem '
3300
- \family typewriter
3301
- sy
3302
- \family default
3303
- '.
3304
- After installing it (
3305
- \family typewriter
3306
- gem install sy
3307
- \family default
3308
- ), type:
3309
- \end_layout
3310
-
3311
- \begin_layout LyX-Code
3312
- require 'sy'
3313
- \end_layout
3314
-
3315
- \begin_layout Standard
3316
- Afterwards, your
3317
- \family typewriter
3318
- \color red
3319
- Numeric
3320
- \family default
3321
- \color inherit
3322
- objects (that is, numbers) should respond to methods representing physical
3323
- units:
3324
- \end_layout
3325
-
3326
- \begin_layout LyX-Code
3327
- 1.m
3328
- \end_layout
3329
-
3330
- \begin_layout LyX-Code
3331
- #=> #<±Magnitude: 1.m>
3332
- \end_layout
3333
-
3334
- \begin_layout LyX-Code
3335
- 1.s
3336
- \end_layout
3337
-
3338
- \begin_layout LyX-Code
3339
- #=> #<±Magnitude: 1.s>
3340
- \end_layout
3341
-
3342
- \begin_layout LyX-Code
3343
- 1.kg.m.s(-2)
3344
- \end_layout
3345
-
3346
- \begin_layout LyX-Code
3347
- #=> #<±Magnitude: 1.N>
3348
- \end_layout
3349
-
3350
- \begin_layout LyX-Code
3351
- 1.cm + 1.mm
3352
- \end_layout
3353
-
3354
- \begin_layout LyX-Code
3355
- #=> #<±Magnitude: 0.011.m>
3356
- \end_layout
3357
-
3358
- \begin_layout Standard
3359
- The core of the trick is that instead of naked numbers, numbers become magnitude
3360
- s (
3361
- \family typewriter
3362
- SY::Magnitude
3363
- \family default
3364
- ) of specified physical quantities:
3365
- \end_layout
3366
-
3367
- \begin_layout LyX-Code
3368
- 1.m.quantity
3369
- \end_layout
3370
-
3371
- \begin_layout LyX-Code
3372
- #=> #<Quantity:Length±>
3373
- \end_layout
3374
-
3375
- \begin_layout LyX-Code
3376
- 1.cm.min⁻¹.quantity
3377
- \end_layout
3378
-
3379
- \begin_layout LyX-Code
3380
- #=> #<Quantity:Speed±>
3381
- \end_layout
3382
-
3383
- \begin_layout Standard
3384
- (You can type
3385
- \family typewriter
3386
- 1.cm.min(-1)
3387
- \family default
3388
- if you find it difficult to type Unicode superscript characters "
3389
- \family typewriter
3390
- ⁻¹
3391
- \family default
3392
- ".) Magnitudes can be converted back to numbers with
3393
- \family typewriter
3394
- \color blue
3395
- amount
3396
- \family default
3397
- \color inherit
3398
- (alias
3399
- \family typewriter
3400
- \color blue
3401
- to_f)
3402
- \family default
3403
- \color inherit
3404
- method:
3405
- \end_layout
3406
-
3407
- \begin_layout LyX-Code
3408
- 1.km.amount
3409
- \end_layout
3410
-
3411
- \begin_layout LyX-Code
3412
- #=> 1000.0
3413
- \end_layout
3414
-
3415
- \begin_layout LyX-Code
3416
- 1.cm.to_f
3417
- \end_layout
3418
-
3419
- \begin_layout LyX-Code
3420
- #=> 0.01
3421
- \end_layout
3422
-
3423
- \begin_layout Subsection*
3424
- Collaboration between
3425
- \family typewriter
3426
- SY
3427
- \family default
3428
- and
3429
- \family typewriter
3430
- YNelson
3431
- \end_layout
3432
-
3433
- \begin_layout Standard
3434
- Enter:
3435
- \end_layout
3436
-
3437
- \begin_layout LyX-Code
3438
- A = Place m!: 3.mM
3439
- \end_layout
3440
-
3441
- \begin_layout LyX-Code
3442
- #=> #<Place: name: A, marking: 0.003.M, default_marking: 0.003.M >
3443
- \end_layout
3444
-
3445
- \begin_layout LyX-Code
3446
- B = Place m!: 4.mM
3447
- \end_layout
3448
-
3449
- \begin_layout LyX-Code
3450
- #=> #<Place: name: B, marking: 0.004.M, default_marking: 0.004.M >
3451
- \end_layout
3452
-
3453
- \begin_layout LyX-Code
3454
- A2B = Transition s: { A: -1, B: 1 }, rate: 0.05.s⁻¹
3455
- \end_layout
3456
-
3457
- \begin_layout LyX-Code
3458
- #=> #<Transition: A2B (SR) >
3459
- \end_layout
3460
-
3461
- \begin_layout LyX-Code
3462
- B_decay = Transition s: { B: -1 }, rate: 0.002.s⁻¹
3463
- \end_layout
3464
-
3465
- \begin_layout LyX-Code
3466
- #=>
3467
- \family typewriter
3468
- YNelson
3469
- \family default
3470
- ::Transition[ B_decay: stoichiometric transition with rate ]
3471
- \end_layout
3472
-
3473
- \begin_layout Standard
3474
- Now we have created places and transitions, whose marking and rate closures
3475
- are defined in physical units.
3476
- Presently,
3477
- \family typewriter
3478
- YNelson::TimedSimulation
3479
- \family default
3480
- will not accept such Petri net, so the only thing we can do is play the
3481
- token game ourselves:
3482
- \end_layout
3483
-
3484
- \begin_layout LyX-Code
3485
- fire_both_transitions = proc { |delta_t|
3486
- \end_layout
3487
-
3488
- \begin_layout LyX-Code
3489
- A2B.fire! delta_t
3490
- \end_layout
3491
-
3492
- \begin_layout LyX-Code
3493
- B_decay.fire! delta_t
3494
- \end_layout
3495
-
3496
- \begin_layout LyX-Code
3497
- }
3498
- \end_layout
3499
-
3500
- \begin_layout LyX-Code
3501
- #=> #<Proc:0x9b48f1c@(irb):19>
3502
- \end_layout
3503
-
3504
- \begin_layout Standard
3505
- Here, we have defined a closure accepting one argument
3506
- \begin_inset Formula $\Delta$
3507
- \end_inset
3508
-
3509
- t, which it will use to
3510
- \family typewriter
3511
- fire!
3512
- \family default
3513
- both
3514
- \family typewriter
3515
- A2B
3516
- \family default
3517
- and
3518
- \family typewriter
3519
- B_decay
3520
- \family default
3521
- .
3522
- By calling this closure repeatedly, we can simulate the network without
3523
- use of
3524
- \family typewriter
3525
- TimedSimulation
3526
- \family default
3527
- :
3528
- \end_layout
3529
-
3530
- \begin_layout LyX-Code
3531
- places.map &:marking
3532
- \end_layout
3533
-
3534
- \begin_layout LyX-Code
3535
- #=> [#<±Magnitude: 0.003.M>, #<±Magnitude: 0.004.M>]
3536
- \end_layout
3537
-
3538
- \begin_layout LyX-Code
3539
- fire_both_transitions.( 1.s )
3540
- \end_layout
3541
-
3542
- \begin_layout LyX-Code
3543
- #=> nil
3544
- \end_layout
3545
-
3546
- \begin_layout LyX-Code
3547
- places.map &:marking
3548
- \end_layout
3549
-
3550
- \begin_layout LyX-Code
3551
- #=> [#<±Magnitude: 0.00285.M>, #<±Magnitude: 0.00414.M>]
3552
- \end_layout
3553
-
3554
- \begin_layout LyX-Code
3555
- 100.times do fire_both_transitions.( 1.s ) end
3556
- \end_layout
3557
-
3558
- \begin_layout LyX-Code
3559
- #=> 100
3560
- \end_layout
3561
-
3562
- \begin_layout LyX-Code
3563
- places.map &:marking
3564
- \end_layout
3565
-
3566
- \begin_layout LyX-Code
3567
- #=> [#<±Magnitude: 1.69e-05.M>, #<±Magnitude: 0.0058.M>]
3568
- \end_layout
3569
-
3570
- \begin_layout LyX-Code
3571
- A.marking.
3572
- \color blue
3573
- in
3574
- \color inherit
3575
- :µM
3576
- \end_layout
3577
-
3578
- \begin_layout LyX-Code
3579
- #=> 16.873508277951963
3580
- \end_layout
3581
-
3582
- \begin_layout LyX-Code
3583
- B.marking.in :µM
3584
- \end_layout
3585
-
3586
- \begin_layout LyX-Code
3587
- #=> 5797.976678013365
3588
- \end_layout
3589
-
3590
- \begin_layout Part*
3591
- Example VI: Other simulation methods
3592
- \end_layout
3593
-
3594
- \begin_layout Standard
3595
- At this moment, the default simulation method is implicit Euler (or
3596
- \family typewriter
3597
- pseudo_euler
3598
- \family default
3599
-
3600
- \emph on
3601
- pseudo
3602
- \emph default
3603
- because timeless transitions and assignment transtitions also fire at each
3604
- step in time).
3605
- From other simulation methods, Gillespie algorithm is available:
3606
- \end_layout
3607
-
3608
- \begin_layout LyX-Code
3609
- require 'y_nelson' and include YNelson
3610
- \end_layout
3611
-
3612
- \begin_layout LyX-Code
3613
-
3614
- \end_layout
3615
-
3616
- \begin_layout LyX-Code
3617
- A = Place m!: 10
3618
- \end_layout
3619
-
3620
- \begin_layout LyX-Code
3621
- B = Place m!: 10
3622
- \end_layout
3623
-
3624
- \begin_layout LyX-Code
3625
- AB = Place m!: 0
3626
- \end_layout
3627
-
3628
- \begin_layout LyX-Code
3629
- AB_association = TS A: -1, B: -1, AB: 1, rate: 0.1
3630
- \end_layout
3631
-
3632
- \begin_layout LyX-Code
3633
- AB_dissociation = TS AB: -1, A: 1, B: 1, rate: 0.1
3634
- \end_layout
3635
-
3636
- \begin_layout LyX-Code
3637
- A2B = TS A: -1, B: 1, rate: 0.05
3638
- \end_layout
3639
-
3640
- \begin_layout LyX-Code
3641
- B2A = TS A: 1, B: -1, rate: 0.07
3642
- \end_layout
3643
-
3644
- \begin_layout LyX-Code
3645
-
3646
- \end_layout
3647
-
3648
- \begin_layout LyX-Code
3649
- set_step 1
3650
- \end_layout
3651
-
3652
- \begin_layout LyX-Code
3653
- set_target_time 50
3654
- \end_layout
3655
-
3656
- \begin_layout LyX-Code
3657
- set_sampling 1
3658
- \end_layout
3659
-
3660
- \begin_layout LyX-Code
3661
- set_simulation_method :gillespie
3662
- \end_layout
3663
-
3664
- \begin_layout LyX-Code
3665
-
3666
- \end_layout
3667
-
3668
- \begin_layout LyX-Code
3669
- run!
3670
- \end_layout
3671
-
3672
- \begin_layout LyX-Code
3673
- print_recording
3674
- \end_layout
3675
-
3676
- \begin_layout LyX-Code
3677
- plot_state
3678
- \end_layout
3679
-
3680
- \begin_layout Standard
3681
- The state recording should show the random walk of the system state over
3682
- 50 time units.
3683
- \end_layout
3684
-
3685
- \begin_layout LyX-Code
3686
-
3687
- \end_layout
3688
-
3689
- \begin_layout LyX-Code
3690
- \begin_inset CommandInset bibtex
3691
- LatexCommand bibtex
3692
- bibfiles "/home/boris/b/1num/num,/home/boris/b/2prp/prp"
3693
- options "plainnat"
3694
-
3695
- \end_inset
3696
-
3697
-
3698
- \end_layout
3699
-
3700
- \end_body
3701
- \end_document