Type network-form.

This commit is contained in:
Sergiu Ivanov 2022-05-02 00:27:55 +02:00
parent 84134340e5
commit b97bbfd972
2 changed files with 30 additions and 15 deletions

View file

@ -15,7 +15,7 @@
make-same-domains make-boolean-domains make-boolean-network
make-01-domains make-01-network update
UpdateFunctionForm
UpdateFunctionForm (struct-out network-form) NetworkForm
)
(define-type (State a) (VariableMapping a))
@ -118,6 +118,11 @@
#hash((x1 . #f) (x2 . #t)))))
(define-type UpdateFunctionForm Any)
(struct (a) network-form ([forms : (VariableMapping UpdateFunctionForm)]
[domains : (DomainMapping a)])
#:transparent
#:type-name NetworkForm)
)
(require 'typed)
@ -132,11 +137,7 @@
(contract-out [struct tbf/state ([weights (hash/c variable? number?)]
[threshold number?])]
[struct dynamics ([network network?]
[mode mode?])]
[struct network ([functions (hash/c variable? procedure?)]
[domains domain-mapping/c])]
[struct network-form ([forms variable-mapping?]
[domains domain-mapping/c])])
[mode mode?])])
;; Functions
(contract-out [update-function-form->update-function (-> update-function-form? update-function/c)]
[network-form->network (-> network-form? network?)]
@ -288,15 +289,6 @@
(define update-function-form? any/c)
;;; A network form consists of a mapping from variables to the forms
;;; of their update functions, together with a mapping from its
;;; variables to its update functions.
;;;
;;; The domain mapping does not have to assign domains to all
;;; variables (e.g., it may be empty), but in this case the functions
;;; which need to know the domains will not work.
(struct network-form (forms domains) #:transparent)
;;; Build an update function from an update function form.
(define (update-function-form->update-function form)
(λ (s) (eval1-with s form)))

View file

@ -208,6 +208,29 @@ and which can be evaluated with @racket[eval].
}
@defstruct*[network-form ([functions (VariableMapping NetworkForm)]
[domains (DomainMapping a)])]{
A network form consists of a mapping from variables to the forms of their
update functions, together with a mapping from its variables to its
update functions.
The domain mapping does not have to assign domains to all variables (e.g., it
may be empty), but in this case the functions which need to know the domains
will not work.
Instances of @racket[network-form] have the type @racket[NetworkForm].
}
@deftypeform[(NetworkForm a)]{
The type of instances of @racket[network-form].
@ex[
(network-form (hash 'a '(and a b) 'b '(or a b))
(hash 'a '(#f #t) 'b '(#f #t)))
]}
@section{Inferring interaction graphs}