networks: Make dynamics inherit from dds and implement dds-step.
This commit is contained in:
parent
9e818ad2bf
commit
5d5d0347e8
2 changed files with 16 additions and 3 deletions
|
@ -107,4 +107,11 @@
|
|||
(check-equal? (dynamics-network asyn) n)
|
||||
(check-equal? (dynamics-mode asyn) (set (set 'a) (set 'b)))
|
||||
(check-equal? (dynamics-network syn) n)
|
||||
(check-equal? (dynamics-mode syn) (set (set 'a 'b)))))
|
||||
(check-equal? (dynamics-mode syn) (set (set 'a 'b))))
|
||||
(let* ([n (nn '((a . (not a)) (b . b)))]
|
||||
[asyn (make-asyn-dynamics n)]
|
||||
[syn (make-syn-dynamics n)]
|
||||
[s (st '((a . #t) (b . #f)))])
|
||||
(check-equal? (dds-step asyn s) (set (st '((a . #f) (b . #f)))
|
||||
(st '((a . #t) (b . #f)))))
|
||||
(check-equal? (dds-step syn s) (set (st '((a . #f) (b . #f)))))))
|
||||
|
|
10
networks.rkt
10
networks.rkt
|
@ -35,7 +35,9 @@
|
|||
[make-syn (-> (listof variable?) mode?)]
|
||||
[make-dynamics-from-func (-> network? (-> (listof variable?) mode?) dynamics?)]
|
||||
[make-asyn-dynamics (-> network? dynamics?)]
|
||||
[make-syn-dynamics (-> network? dynamics?)])
|
||||
[make-syn-dynamics (-> network? dynamics?)]
|
||||
[dds-step (-> dynamics? state? (set/c state?))]
|
||||
)
|
||||
;; Predicates
|
||||
(contract-out [variable? (-> any/c boolean?)]
|
||||
[state? (-> any/c boolean?)]
|
||||
|
@ -258,7 +260,11 @@
|
|||
(define mode? (set/c (set/c variable?)))
|
||||
|
||||
;;; A network dynamics is a network plus a mode.
|
||||
(struct dynamics (network mode))
|
||||
(struct dynamics (network mode)
|
||||
#:methods gen:dds
|
||||
[(define/match (dds-step dyn s)
|
||||
[((dynamics network mode) s)
|
||||
(for/set ([m mode]) (update network s m))])])
|
||||
|
||||
;;; Given a list of variables, builds the asynchronous mode (a set of
|
||||
;;; singletons).
|
||||
|
|
Loading…
Reference in a new issue