From 43e29f928b848967d3cb44288ed3331c5fb8193f Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Wed, 4 May 2022 01:12:52 +0200 Subject: [PATCH] Add network-form->network/boolean. --- networks.rkt | 20 +++++++++++++++++++- scribblings/networks.scrbl | 12 ++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/networks.rkt b/networks.rkt index 464db3e..cbd3e15 100644 --- a/networks.rkt +++ b/networks.rkt @@ -19,7 +19,7 @@ update-function-form->update-function/any update-function-form->update-function/boolean update-function-form->update-function/01 - network-form->network/any + network-form->network/any network-form->network/boolean ) (define-type (State a) (VariableMapping a)) @@ -175,6 +175,24 @@ 'b '(#f #t))))) (define s (hash 'a #t 'b #t)) (check-equal? ((hash-ref (network-functions bn) 'a) s) #t))) + + (: network-form->network/boolean (-> (NetworkForm Boolean) (Network Boolean))) + (define (network-form->network/boolean nf) + (network + (for/hash ([(x form) (in-hash (network-form-forms nf))]) + : (VariableMapping (UpdateFunction Boolean)) + (values x (update-function-form->update-function/boolean form))) + (network-form-domains nf))) + + (module+ test + (test-case "network-form->network/boolean" + (define bn (network-form->network/boolean + (network-form (hash 'a '(and a b) + 'b '(not b)) + (hash 'a '(#f #t) + 'b '(#f #t))))) + (define s (hash 'a #t 'b #t)) + (check-equal? ((hash-ref (network-functions bn) 'a) s) #t))) ) (require 'typed) diff --git a/scribblings/networks.scrbl b/scribblings/networks.scrbl index 03dbd06..cd6c047 100644 --- a/scribblings/networks.scrbl +++ b/scribblings/networks.scrbl @@ -285,6 +285,18 @@ Builds a network from a network form. 'b '(#f #t)))) ]} +@defproc[(network-form->network/boolean [nf (NetworkForm Boolean)]) (Network Boolean)]{ + +Like @racket[network-form->network/any], but builds a Boolean network. + +@ex[ +(network-form->network/boolean + (network-form (hash 'a '(and a b) + 'b '(not b)) + (hash 'a '(#f #t) + 'b '(#f #t)))) +]} + @section{Inferring interaction graphs} This section provides inference of both unsigned and signed interaction graphs.