networks: Add make-01-network.

This commit is contained in:
Sergiu Ivanov 2020-11-28 23:01:57 +01:00
parent ce2d10526a
commit c0ec7369fd

View file

@ -25,6 +25,7 @@
[domains domain-mapping/c])]) [domains domain-mapping/c])])
;; Functions ;; Functions
(contract-out [make-boolean-network (-> (hash/c variable? procedure?) network?)] (contract-out [make-boolean-network (-> (hash/c variable? procedure?) network?)]
[make-01-network (-> (hash/c variable? procedure?) network?)]
[update (-> network? state? (set/c variable? #:kind 'dont-care) state?)] [update (-> network? state? (set/c variable? #:kind 'dont-care) state?)]
[make-state (-> (listof (cons/c symbol? any/c)) state?)] [make-state (-> (listof (cons/c symbol? any/c)) state?)]
[make-state-booleanize (-> (listof (cons/c symbol? (or/c 0 1))) state?)] [make-state-booleanize (-> (listof (cons/c symbol? (or/c 0 1))) state?)]
@ -190,6 +191,11 @@
(define (make-boolean-network funcs) (define (make-boolean-network funcs)
(network funcs (make-boolean-domains (hash-keys funcs)))) (network funcs (make-boolean-domains (hash-keys funcs))))
;;; Build a network from a given hash table assigning functions to
;;; variables by attributing the domain {0,1} to every variable.
(define (make-01-network funcs)
(network funcs (make-01-domains (hash-keys funcs))))
(module+ test (module+ test
(test-case "make-boolean-network" (test-case "make-boolean-network"
(define f1 (λ (s) (let ([x1 (hash-ref s 'x1)] (define f1 (λ (s) (let ([x1 (hash-ref s 'x1)]