networks: Add and use domain-mapping/c.

This commit is contained in:
Sergiu Ivanov 2020-02-23 09:12:01 +01:00
parent bdbbae6eb6
commit 245b22316e
1 changed files with 9 additions and 5 deletions

View File

@ -23,12 +23,12 @@
network?)]
[list-interactions (-> network-form? variable? (listof variable?))]
[build-interaction-graph (-> network-form? graph?)]
[build-all-states (-> (hash/c variable? generic-set?) (listof state?))]
[build-all-states (-> domain-mapping/c (listof state?))]
[build-all-states-same-domain (-> (listof variable?) generic-set? (listof state?))]
[make-same-domains (-> (listof variable?) generic-set? (hash/c variable? generic-set?))]
[make-boolean-domains (-> (listof variable?) (hash/c variable? (list/c #f #t)))]
[get-interaction-sign (-> network-form? (hash/c variable? generic-set?) variable? variable? (or/c '+ '- '0))]
[build-signed-interaction-graph (-> network-form? (hash/c variable? generic-set?) graph?)])
[get-interaction-sign (-> network-form? domain-mapping/c variable? variable? (or/c '+ '- '0))]
[build-signed-interaction-graph (-> network-form? domain-mapping/c graph?)])
;; Predicates
(contract-out [variable? (-> any/c boolean?)]
[state? (-> any/c boolean?)]
@ -37,7 +37,8 @@
;; Contracts
(contract-out [state/c contract?]
[network/c contract?]
[update-function/c contract?])
[update-function/c contract?]
[domain-mapping/c contract?])
;; Syntax
st nn)
@ -146,7 +147,10 @@
(unweighted-graph/adj
(for/list ([(var _) n]) (cons var (list-interactions n var))))))
;;; Given a list of pairs mapping variables to generic sets of their
;;; A domain mapping is a hash set mapping variables to the lists of
;;; values in their domains.
(define domain-mapping/c (hash/c variable? list?))
;;; Given a hash-set mapping variables to generic sets of their
;;; possible values, constructs the list of all possible states.
(define (build-all-states vars-domains)