diff --git a/networks.rkt b/networks.rkt index 3ad8a9d..53e6952 100644 --- a/networks.rkt +++ b/networks.rkt @@ -20,7 +20,7 @@ update-function-form->update-function/boolean update-function-form->update-function/01 network-form->network/any network-form->network/boolean - network-form->network/01 + network-form->network/01 make-boolean-network-form ) (define-type (State a) (VariableMapping a)) @@ -212,6 +212,19 @@ 'b '(0 1))))) (define s (hash 'a 1 'b 1)) (check-equal? ((hash-ref (network-functions bn) 'a) s) 1))) + + (: make-boolean-network-form (-> (VariableMapping UpdateFunctionForm) + (NetworkForm Boolean))) + (define (make-boolean-network-form forms) + (network-form forms (make-boolean-domains (hash-keys forms)))) + + (module+ test + (test-case "make-boolean-network-form" + (check-equal? (make-boolean-network-form (hash 'a '(and a b) + 'b '(not b))) + (network-form + '#hash((a . (and a b)) (b . (not b))) + '#hash((a . (#f #t)) (b . (#f #t))))))) ) (require 'typed) @@ -228,8 +241,7 @@ [struct dynamics ([network network?] [mode mode?])]) ;; Functions - (contract-out [make-boolean-network-form (-> variable-mapping? network-form?)] - [forms->boolean-network (-> variable-mapping? network?)] + (contract-out [forms->boolean-network (-> variable-mapping? network?)] [list-syntactic-interactions (-> network-form? variable? (listof variable?))] [build-syntactic-interaction-graph (-> network-form? graph?)] [interaction? (-> network? variable? variable? boolean?)] @@ -376,19 +388,6 @@ (define update-function-form? any/c) -;;; Build a Boolean network form from a given mapping assigning forms -;;; to variables. -(define (make-boolean-network-form forms) - (network-form forms (make-boolean-domains (hash-keys forms)))) - -(module+ test - (test-case "make-boolean-network-form" - (check-equal? (make-boolean-network-form (hash 'a '(and a b) - 'b '(not b))) - (network-form - '#hash((a . (and a b)) (b . (not b))) - '#hash((a . (#f #t)) (b . (#f #t))))))) - ;;; Build a Boolean network from a given mapping assigning forms ;;; to variables. (define forms->boolean-network diff --git a/scribblings/networks.scrbl b/scribblings/networks.scrbl index 1c68671..c5bd199 100644 --- a/scribblings/networks.scrbl +++ b/scribblings/networks.scrbl @@ -310,6 +310,16 @@ domains are expressed as @tt{{0,1}}. 'b '(0 1)))) ]} +@defproc[(make-boolean-network-form [forms (VariableMapping UpdateFunctionForm)]) + (NetworkForm Boolean)]{ + +Build a Boolean network form from a given mapping assigning forms to variables. + +@ex[ +(make-boolean-network-form (hash 'a '(and a b) + 'b '(not b))) +]} + @section{Inferring interaction graphs} This section provides inference of both unsigned and signed interaction graphs.