diff --git a/networks-tests.rkt b/networks-tests.rkt index 9039834..1c847ba 100644 --- a/networks-tests.rkt +++ b/networks-tests.rkt @@ -96,3 +96,8 @@ (check-false (has-edge? sig2 'c 'a)) (check-equal? (edge-weight sig2 'a 'b) 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))))) diff --git a/networks.rkt b/networks.rkt index 590df13..52aab7f 100644 --- a/networks.rkt +++ b/networks.rkt @@ -30,7 +30,9 @@ [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))] [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 (contract-out [variable? (-> any/c boolean?)] [state? (-> any/c boolean?)] @@ -254,3 +256,12 @@ ;;; A network dynamics is a network plus a 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)))