Add network-form->network/boolean.

This commit is contained in:
Sergiu Ivanov 2022-05-04 01:12:52 +02:00
parent b795be0a39
commit 43e29f928b
2 changed files with 31 additions and 1 deletions

View file

@ -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)

View file

@ -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.