example: Start explaining tbf/state and TBN.

This commit is contained in:
Sergiu Ivanov 2020-10-11 23:22:37 +02:00
parent 2a71a1cd93
commit f06c5bc8ff

View file

@ -876,6 +876,65 @@ tab
(list (tbf '#(1 -1) 0) (tbf '#(2 2) 0)) (list (tbf '#(1 -1) 0) (tbf '#(2 2) 0))
:END: :END:
** Threshold Boolean networks (TBN) <<tbn>>
=dds= includes a number of useful definitions for working with
threshold Boolean networks: networks of threshold Boolean
functions. Since, standalone TBF do give names to their inputs,
=dds= also defines TBF operating on states:
#+BEGIN_SRC racket :results output drawer
(make-tbf/state '((a . 1) (b . 1)) 1)
#+END_SRC
#+RESULTS:
:results:
(tbf/state '#hash((a . 1) (b . 1)) 1)
:end:
As the example standalone TBF, this TBF only returns 1 when both
inputs are activated:
#+BEGIN_SRC racket :results output drawer
(apply-tbf/state (make-tbf/state '((a . 1) (b . 1)) 1)
(make-state '((a . 1) (b . 1))))
#+END_SRC
#+RESULTS:
:results:
1
:end:
Here's how you can read this TBF from an Org-mode table:
#+NAME: simple-tbf/state
| a | b | f |
| 1 | 1 | 1 |
#+BEGIN_SRC racket :results output drawer :var simple-tbf/state=munch-sexp(simple-tbf/state)
(read-org-tbfs/state simple-tbf/state)
#+END_SRC
#+RESULTS:
:results:
(list (tbf/state '#hash((a . 1) (b . 1)) 1))
:end:
Note that the header of the rightmost column is discarded.
=read-org-tbfs/state= can also read multiple TBFs at once:
#+NAME: simple-tbfs/state
| a | b | f |
| 1 | 1 | 1 |
| -2 | 1 | 0 |
#+BEGIN_SRC racket :results output drawer :var simple-tbfs/state=munch-sexp(simple-tbfs/state)
(read-org-tbfs/state simple-tbfs/state)
#+END_SRC
#+RESULTS:
:results:
(list (tbf/state '#hash((a . 1) (b . 1)) 1) (tbf/state '#hash((a . -2) (b . 1)) 0))
:end:
* Reaction systems * Reaction systems
:PROPERTIES: :PROPERTIES:
:header-args:racket: :prologue "#lang racket\n(require graph dds/rs dds/utils)" :header-args:racket: :prologue "#lang racket\n(require graph dds/rs dds/utils)"