Type update-function-form->update-function.
This commit is contained in:
parent
b97bbfd972
commit
320ae55456
2 changed files with 26 additions and 12 deletions
24
networks.rkt
24
networks.rkt
|
@ -16,6 +16,7 @@
|
||||||
make-01-domains make-01-network update
|
make-01-domains make-01-network update
|
||||||
|
|
||||||
UpdateFunctionForm (struct-out network-form) NetworkForm
|
UpdateFunctionForm (struct-out network-form) NetworkForm
|
||||||
|
update-function-form->update-function
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-type (State a) (VariableMapping a))
|
(define-type (State a) (VariableMapping a))
|
||||||
|
@ -123,6 +124,16 @@
|
||||||
[domains : (DomainMapping a)])
|
[domains : (DomainMapping a)])
|
||||||
#:transparent
|
#:transparent
|
||||||
#:type-name NetworkForm)
|
#:type-name NetworkForm)
|
||||||
|
|
||||||
|
(: update-function-form->update-function (-> UpdateFunctionForm (UpdateFunction Any)))
|
||||||
|
(define (update-function-form->update-function form)
|
||||||
|
(λ (s) (eval1-with s form)))
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(test-case "update-function-form->update-function"
|
||||||
|
(define s (hash 'x #t 'y #f))
|
||||||
|
(define f (update-function-form->update-function '(and x y)))
|
||||||
|
(check-equal? (f s) #f)))
|
||||||
)
|
)
|
||||||
|
|
||||||
(require 'typed)
|
(require 'typed)
|
||||||
|
@ -139,8 +150,7 @@
|
||||||
[struct dynamics ([network network?]
|
[struct dynamics ([network network?]
|
||||||
[mode mode?])])
|
[mode mode?])])
|
||||||
;; Functions
|
;; Functions
|
||||||
(contract-out [update-function-form->update-function (-> update-function-form? update-function/c)]
|
(contract-out [network-form->network (-> network-form? network?)]
|
||||||
[network-form->network (-> network-form? network?)]
|
|
||||||
[make-boolean-network-form (-> variable-mapping? network-form?)]
|
[make-boolean-network-form (-> variable-mapping? network-form?)]
|
||||||
[forms->boolean-network (-> variable-mapping? network?)]
|
[forms->boolean-network (-> variable-mapping? network?)]
|
||||||
[list-syntactic-interactions (-> network-form? variable? (listof variable?))]
|
[list-syntactic-interactions (-> network-form? variable? (listof variable?))]
|
||||||
|
@ -289,16 +299,6 @@
|
||||||
|
|
||||||
(define update-function-form? any/c)
|
(define update-function-form? any/c)
|
||||||
|
|
||||||
;;; Build an update function from an update function form.
|
|
||||||
(define (update-function-form->update-function form)
|
|
||||||
(λ (s) (eval1-with s form)))
|
|
||||||
|
|
||||||
(module+ test
|
|
||||||
(test-case "update-function-form->update-function"
|
|
||||||
(define s (hash 'x #t 'y #f))
|
|
||||||
(define f (update-function-form->update-function '(and x y)))
|
|
||||||
(check-equal? (f s) #f)))
|
|
||||||
|
|
||||||
;;; Build a network from a network form.
|
;;; Build a network from a network form.
|
||||||
(define (network-form->network nf)
|
(define (network-form->network nf)
|
||||||
(network
|
(network
|
||||||
|
|
|
@ -232,6 +232,20 @@ The type of instances of @racket[network-form].
|
||||||
(hash 'a '(#f #t) 'b '(#f #t)))
|
(hash 'a '(#f #t) 'b '(#f #t)))
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
@defproc[(update-function-form->update-function [func UpdateFunctionForm])
|
||||||
|
(UpdateFunction Any)]{
|
||||||
|
|
||||||
|
Builds an update function from an update function form.
|
||||||
|
|
||||||
|
@ex[
|
||||||
|
(define and-from-form (update-function-form->update-function '(and x y)))
|
||||||
|
(and-from-form (hash 'x #f 'y #f))
|
||||||
|
(and-from-form (hash 'x #f 'y #t))
|
||||||
|
(and-from-form (hash 'x #t 'y #f))
|
||||||
|
(and-from-form (hash 'x #t 'y #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