From ce2d10526a8018f41f8b354808c7f07c87b657a8 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sat, 28 Nov 2020 22:55:44 +0100 Subject: [PATCH] example: Update Random functions and networks. --- example/dots/exampleHc023j.svg | 2 +- example/dots/examplePIN5ac.svg | 84 ++++++++++++++++++++++++---------- example/example.org | 54 ++++++++++++---------- 3 files changed, 91 insertions(+), 49 deletions(-) diff --git a/example/dots/exampleHc023j.svg b/example/dots/exampleHc023j.svg index 05d4020..c613c00 100644 --- a/example/dots/exampleHc023j.svg +++ b/example/dots/exampleHc023j.svg @@ -130,7 +130,7 @@ node4->node4 -{c}{b} +{b}{c} diff --git a/example/dots/examplePIN5ac.svg b/example/dots/examplePIN5ac.svg index 7b10d04..cac11b3 100644 --- a/example/dots/examplePIN5ac.svg +++ b/example/dots/examplePIN5ac.svg @@ -4,42 +4,80 @@ - - + + G - + node0 - -c + +c - - -node2 - -a - - + -node0->node2 - - -+ +node0->node0 + +0 node1 - -b + +b + + + +node0->node1 + +0 + + + +node2 + +a + + + +node0->node2 + + +1 + + + +node1->node1 + +-1 - + node1->node2 - - -+ + + +1 + + + +node2->node0 + + +0 + + + +node2->node1 + + +0 + + + +node2->node2 + +0 diff --git a/example/example.org b/example/example.org index bac091c..0277927 100644 --- a/example/example.org +++ b/example/example.org @@ -725,7 +725,7 @@ tab #+END_SRC #+RESULTS: - :RESULTS: + :results: | a | b | c | f | | #f | 1 | cold | 4 | | #f | 1 | hot | 5 | @@ -735,17 +735,17 @@ tab | #t | 1 | hot | 6 | | #t | 2 | cold | 4 | | #t | 2 | hot | 5 | - :END: + :end: We can build an entire random network over these domains: #+BEGIN_SRC racket :results table drawer :var simple-domains=munch-sexp(simple-domains) (random-seed 0) (define n (random-network (unorgv simple-domains))) -(tabulate-network n (unorgv simple-domains)) +(tabulate-network n) #+END_SRC #+RESULTS: - :RESULTS: + :results: | a | b | c | f-a | f-b | f-c | | #f | 1 | cold | #f | 2 | hot | | #f | 1 | hot | #f | 2 | cold | @@ -755,7 +755,7 @@ tab | #t | 1 | hot | #t | 1 | cold | | #t | 2 | cold | #f | 2 | hot | | #t | 2 | hot | #t | 1 | cold | - :END: + :end: Let's snapshot this random network and give it a name. #+NAME: rnd-network @@ -769,16 +769,16 @@ tab | #t | 2 | cold | #f | 2 | hot | | #t | 2 | hot | #t | 1 | cold | - Here's how we can read back this table as a Boolean network: + Here's how we can read back this table as a network: #+HEADER: :var rnd-network=munch-sexp(rnd-network) #+BEGIN_SRC racket :results output drawer (string->any rnd-network) #+END_SRC #+RESULTS: - :RESULTS: + :results: '(("a" "b" "c" "f-a" "f-b" "f-c") ("#f" 1 "cold" "#f" 2 "hot") ("#f" 1 "hot" "#f" 2 "cold") ("#f" 2 "cold" "#t" 1 "cold") ("#f" 2 "hot" "#t" 2 "hot") ("#t" 1 "cold" "#f" 2 "cold") ("#t" 1 "hot" "#t" 1 "cold") ("#t" 2 "cold" "#f" 2 "hot") ("#t" 2 "hot" "#t" 1 "cold")) - :END: + :end: You can use =table->network= to convert a table such as [[rnd-network][rnd-network]] to a network. @@ -788,19 +788,23 @@ tab #+END_SRC #+RESULTS: - :RESULTS: - '#hash((a . #) (b . #) (c . #)) - :END: + :results: + (network '#hash((a . #) (b . #) (c . #)) '#hash((a . (#f #t)) (b . (1 2)) (c . (cold hot)))) + :end: Here's the state graph of [[rnd-network][rnd-network]]. #+NAME: rnd-network-sg #+HEADER: :var rnd-network=munch-sexp(rnd-network) #+HEADER: :var simple-domains=munch-sexp(simple-domains) #+BEGIN_SRC racket :results silent drawer -(define n (table->network (unorg rnd-network))) -(define rnd-asyn (make-asyn-dynamics n)) -(define states (list->set (build-all-states (unorgv simple-domains)))) -(dotit (pretty-print-state-graph (dds-build-state-graph-annotated rnd-asyn states))) +((compose + dotit + pretty-print-state-graph + build-full-state-graph-annotated + make-asyn-dynamics + table->network + unorg) + rnd-network) #+END_SRC #+BEGIN_SRC dot :file dots/exampleHc023j.svg :results raw drawer :cmd sfdp :noweb yes @@ -808,17 +812,21 @@ tab #+END_SRC #+RESULTS: - :RESULTS: + :results: [[file:dots/exampleHc023j.svg]] - :END: + :end: Here's the signed interaction graph of [[rnd-network][rnd-network]]. #+NAME: rnd-network-ig #+HEADER: :var rnd-network=munch-sexp(rnd-network) #+HEADER: :var simple-domains=munch-sexp(simple-domains) #+BEGIN_SRC racket :results silent drawer -(define n (table->network (unorg rnd-network))) -(dotit (build-signed-interaction-graph n (unorgv simple-domains))) +((compose + dotit + build-signed-interaction-graph + table->network + unorg) + rnd-network) #+END_SRC #+BEGIN_SRC dot :file dots/examplePIN5ac.svg :results raw drawer :cmd sfdp :noweb yes @@ -826,13 +834,9 @@ tab #+END_SRC #+RESULTS: - :RESULTS: + :results: [[file:dots/examplePIN5ac.svg]] - :END: - - Note that =build-signed-interaction-graph= only includes the + and - the - arcs in the graph, as it does not have access to the symbolic - description of the function. + :end: ** Standalone threshold Boolean functions (TBF) /Note:/ Before using the objects described in this section,