networks: Add pretty-print-state.

This commit is contained in:
Sergiu Ivanov 2020-02-23 19:24:53 +01:00
parent 4063a21bce
commit 3a873ab256
2 changed files with 7 additions and 1 deletions

View file

@ -98,6 +98,7 @@
(check-equal? (edge-weight sig2 'b 'a) -1)))
(test-case "Dynamics of networks"
(check-equal? (pretty-print-state (st '((a . #f) (b . 3)))) "a:#f b:3")
(let ([vars '(a b c)])
(check-equal? (make-asyn vars) (set (set 'a) (set 'b) (set 'c)))
(check-equal? (make-syn vars) (set (set 'a 'b 'c))))

View file

@ -40,7 +40,8 @@
[dds-step-one-annotated (-> dynamics? state? (set/c (cons/c modality? state?)))]
[dds-step (-> dynamics? (set/c state? #:kind 'dont-care) (set/c state?))]
[dds-build-state-graph (-> dynamics? (set/c state? #:kind 'dont-care) graph?)]
[dds-build-n-step-state-graph (-> dynamics? (set/c state? #:kind 'dont-care) number? graph?)])
[dds-build-n-step-state-graph (-> dynamics? (set/c state? #:kind 'dont-care) number? graph?)]
[pretty-print-state (-> state? string?)])
;; Predicates
(contract-out [variable? (-> any/c boolean?)]
[state? (-> any/c boolean?)]
@ -299,3 +300,7 @@
;;; Creates the synchronous dynamics for a given network.
(define (make-syn-dynamics network)
(make-dynamics-from-func network make-syn))
;;; Pretty-prints a state of the network.
(define (pretty-print-state s)
(string-join (for/list ([(key val) s]) (format "~a:~a" key val))))