networks: Add pretty-print-state.
This commit is contained in:
parent
4063a21bce
commit
3a873ab256
2 changed files with 7 additions and 1 deletions
|
@ -98,6 +98,7 @@
|
||||||
(check-equal? (edge-weight sig2 'b 'a) -1)))
|
(check-equal? (edge-weight sig2 'b 'a) -1)))
|
||||||
|
|
||||||
(test-case "Dynamics of networks"
|
(test-case "Dynamics of networks"
|
||||||
|
(check-equal? (pretty-print-state (st '((a . #f) (b . 3)))) "a:#f b:3")
|
||||||
(let ([vars '(a b c)])
|
(let ([vars '(a b c)])
|
||||||
(check-equal? (make-asyn vars) (set (set 'a) (set 'b) (set 'c)))
|
(check-equal? (make-asyn vars) (set (set 'a) (set 'b) (set 'c)))
|
||||||
(check-equal? (make-syn vars) (set (set 'a 'b 'c))))
|
(check-equal? (make-syn vars) (set (set 'a 'b 'c))))
|
||||||
|
|
|
@ -40,7 +40,8 @@
|
||||||
[dds-step-one-annotated (-> dynamics? state? (set/c (cons/c modality? state?)))]
|
[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-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-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
|
;; Predicates
|
||||||
(contract-out [variable? (-> any/c boolean?)]
|
(contract-out [variable? (-> any/c boolean?)]
|
||||||
[state? (-> any/c boolean?)]
|
[state? (-> any/c boolean?)]
|
||||||
|
@ -299,3 +300,7 @@
|
||||||
;;; Creates the synchronous dynamics for a given network.
|
;;; Creates the synchronous dynamics for a given network.
|
||||||
(define (make-syn-dynamics network)
|
(define (make-syn-dynamics network)
|
||||||
(make-dynamics-from-func network make-syn))
|
(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))))
|
||||||
|
|
Loading…
Reference in a new issue