diff --git a/networks.rkt b/networks.rkt index 93ad496..4f0dc90 100644 --- a/networks.rkt +++ b/networks.rkt @@ -51,6 +51,7 @@ table+vars->network table->network table+headers->network random-function/state random-boolean-function/state random-network + random-boolean-network ) (define-type (State a) (VariableMapping a)) @@ -1090,6 +1091,24 @@ (check-equal? (tabulate-network+headers (random-network (hash 'a '(1 2) 'b '(#f #t)))) '((a b f-a f-b) (1 #f 1 #f) (1 #t 1 #f) (2 #f 2 #t) (2 #t 2 #f))))) + + (: random-boolean-network (-> (Listof Variable) (Network Boolean))) + (define (random-boolean-network vars) + (random-network (make-boolean-domains vars))) + + (module+ test + (test-case "random-boolean-network" + (check-equal? + (tabulate-network+headers (random-boolean-network '(x y z))) + '((x y z f-x f-y f-z) + (#f #f #f #t #t #t) + (#f #f #t #f #f #f) + (#f #t #f #t #t #t) + (#f #t #t #f #t #f) + (#t #f #f #t #t #t) + (#t #f #t #f #t #f) + (#t #t #f #f #f #t) + (#t #t #t #t #t #f))))) ) (require 'typed) diff --git a/scribblings/networks.scrbl b/scribblings/networks.scrbl index b47edfb..15abf32 100644 --- a/scribblings/networks.scrbl +++ b/scribblings/networks.scrbl @@ -925,6 +925,15 @@ Generates a random network from the given domain mapping. (tabulate-network+headers (random-network (hash 'a '(1 2) 'b '(#f #t)))) ]} +@defproc[(random-boolean-network [vars (Listof Variable)]) + (Network Boolean)]{ + +Generates a random Boolean network with the given variables. + +@ex[ +(tabulate-network+headers (random-boolean-network '(x y z))) +]} + @section{TBF/TBN and SBF/SBN} This section defines threshold Boolean functions (TBF) and networks (TBN), as