Type random-boolean-network.

This commit is contained in:
Sergiu Ivanov 2023-03-25 16:29:33 +01:00
parent 5e155d0a61
commit 861665e205
2 changed files with 28 additions and 0 deletions

View File

@ -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)

View File

@ -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