From 20b3357910409ab6e1ea07d32d5c51718dd0f7ce Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 18 Oct 2020 23:10:43 +0200 Subject: [PATCH] example: Show how to build state graphs of TBN. --- example/example.org | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/example/example.org b/example/example.org index c3b6153..b0be0f5 100644 --- a/example/example.org +++ b/example/example.org @@ -1019,6 +1019,45 @@ tab | -2 | 1 | :end: + Finally, =dds= defines utilities for working with TBN (networks of + TBF). For example, here is how you can define and read a TBN from + a table: + + #+NAME: tbfs-nots + | - | x | y | θ | + | y | -1 | 0 | -1 | + | x | 0 | -1 | -1 | + + #+BEGIN_SRC racket :results output drawer :var tbfs-nots=munch-sexp(tbfs-nots) +(read-org-tbn tbfs-nots) + #+END_SRC + + #+RESULTS: + :results: + (hash 'x (tbf/state '#hash((x . 0) (y . -1)) -1) 'y (tbf/state '#hash((x . -1) (y . 0)) -1)) + :end: + + To take a look at the behaviour of this TBN, you can convert it to + a =network= using =tbn->network= and build its state graph: + + #+NAME: tbfs-nots-sg + #+BEGIN_SRC racket :results silent drawer :var tbfs-nots=munch-sexp(tbfs-nots) +(dotit ((compose pretty-print-state-graph + build-full-01-state-graph + make-syn-dynamics + tbn->network + read-org-tbn) tbfs-nots)) + #+END_SRC + + #+BEGIN_SRC dot :file dots/examplew206DH.svg :results raw drawer :cmd sfdp :noweb yes +<> + #+END_SRC + + #+RESULTS: + :results: + [[file:dots/examplew206DH.svg]] + :end: + * Reaction systems :PROPERTIES: :header-args:racket: :prologue "#lang racket\n(require graph dds/rs dds/utils)"