networks: Add make-syn and make-asyn.
This commit is contained in:
parent
2fa89f05b9
commit
c9cbb1c951
2 changed files with 17 additions and 1 deletions
|
@ -96,3 +96,8 @@
|
||||||
(check-false (has-edge? sig2 'c 'a))
|
(check-false (has-edge? sig2 'c 'a))
|
||||||
(check-equal? (edge-weight sig2 'a 'b) 1)
|
(check-equal? (edge-weight sig2 'a 'b) 1)
|
||||||
(check-equal? (edge-weight sig2 'b 'a) -1)))
|
(check-equal? (edge-weight sig2 'b 'a) -1)))
|
||||||
|
|
||||||
|
(test-case "Dynamics of networks"
|
||||||
|
(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)))))
|
||||||
|
|
13
networks.rkt
13
networks.rkt
|
@ -30,7 +30,9 @@
|
||||||
[make-boolean-domains (-> (listof variable?) (hash/c variable? (list/c #f #t)))]
|
[make-boolean-domains (-> (listof variable?) (hash/c variable? (list/c #f #t)))]
|
||||||
[get-interaction-sign (-> network-form? domain-mapping/c variable? variable? (or/c '+ '- '0))]
|
[get-interaction-sign (-> network-form? domain-mapping/c variable? variable? (or/c '+ '- '0))]
|
||||||
[build-signed-interaction-graph (-> network-form? domain-mapping/c graph?)]
|
[build-signed-interaction-graph (-> network-form? domain-mapping/c graph?)]
|
||||||
[build-boolean-signed-interaction-graph (-> network-form? graph?)])
|
[build-boolean-signed-interaction-graph (-> network-form? graph?)]
|
||||||
|
[make-asyn (-> (listof variable?) mode?)]
|
||||||
|
[make-syn (-> (listof variable?) mode?)])
|
||||||
;; Predicates
|
;; Predicates
|
||||||
(contract-out [variable? (-> any/c boolean?)]
|
(contract-out [variable? (-> any/c boolean?)]
|
||||||
[state? (-> any/c boolean?)]
|
[state? (-> any/c boolean?)]
|
||||||
|
@ -254,3 +256,12 @@
|
||||||
|
|
||||||
;;; A network dynamics is a network plus a mode.
|
;;; A network dynamics is a network plus a mode.
|
||||||
(struct dynamics (network mode))
|
(struct dynamics (network mode))
|
||||||
|
|
||||||
|
;;; Given a list of variables, builds the asynchronous mode (a set of
|
||||||
|
;;; singletons).
|
||||||
|
(define (make-asyn vars)
|
||||||
|
(for/set ([v vars]) (set v)))
|
||||||
|
|
||||||
|
;;; Given a list of variables, builds the synchronous mode (a set
|
||||||
|
;;; containing the set of variables).
|
||||||
|
(define (make-syn vars) (set (list->set vars)))
|
||||||
|
|
Loading…
Reference in a new issue