Add network-form->network/boolean.
This commit is contained in:
parent
b795be0a39
commit
43e29f928b
2 changed files with 31 additions and 1 deletions
20
networks.rkt
20
networks.rkt
|
@ -19,7 +19,7 @@
|
||||||
update-function-form->update-function/any
|
update-function-form->update-function/any
|
||||||
update-function-form->update-function/boolean
|
update-function-form->update-function/boolean
|
||||||
update-function-form->update-function/01
|
update-function-form->update-function/01
|
||||||
network-form->network/any
|
network-form->network/any network-form->network/boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-type (State a) (VariableMapping a))
|
(define-type (State a) (VariableMapping a))
|
||||||
|
@ -175,6 +175,24 @@
|
||||||
'b '(#f #t)))))
|
'b '(#f #t)))))
|
||||||
(define s (hash 'a #t 'b #t))
|
(define s (hash 'a #t 'b #t))
|
||||||
(check-equal? ((hash-ref (network-functions bn) 'a) s) #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)
|
(require 'typed)
|
||||||
|
|
|
@ -285,6 +285,18 @@ Builds a network from a network form.
|
||||||
'b '(#f #t))))
|
'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}
|
@section{Inferring interaction graphs}
|
||||||
|
|
||||||
This section provides inference of both unsigned and signed interaction graphs.
|
This section provides inference of both unsigned and signed interaction graphs.
|
||||||
|
|
Loading…
Reference in a new issue