Type random-boolean-network/n.

This commit is contained in:
Sergiu Ivanov 2023-03-26 22:34:45 +02:00
parent 861665e205
commit e6764b2dd6
2 changed files with 32 additions and 1 deletions

View file

@ -51,7 +51,7 @@
table+vars->network table->network table+headers->network
random-function/state random-boolean-function/state random-network
random-boolean-network
random-boolean-network random-boolean-network/n
)
(define-type (State a) (VariableMapping a))
@ -1109,6 +1109,26 @@
(#t #f #t #f #t #f)
(#t #t #f #f #f #t)
(#t #t #t #t #t #f)))))
(: random-boolean-network/n (-> Positive-Integer (Network Boolean)))
(define (random-boolean-network/n n)
(random-boolean-network (for/list : (Listof Variable)
([i (in-range n)])
(string->symbol (format "x~a" i)))))
(module+ test
(test-case "random-boolean-network/n"
(check-equal?
(tabulate-network+headers (random-boolean-network/n 3))
'((x0 x1 x2 f-x0 f-x1 f-x2)
(#f #f #f #f #t #f)
(#f #f #t #f #f #t)
(#f #t #f #t #f #f)
(#f #t #t #f #t #t)
(#t #f #f #t #t #t)
(#t #f #t #t #f #t)
(#t #t #f #t #t #f)
(#t #t #t #t #f #t)))))
)
(require 'typed)

View file

@ -934,6 +934,17 @@ Generates a random Boolean network with the given variables.
(tabulate-network+headers (random-boolean-network '(x y z)))
]}
@defproc[(random-boolean-network/n [n Positive-Integer])
(Network Boolean)]{
Like @racket[random-boolean-network], but also generates the names of
the variables for the network. The variables have the names @tt{x0}
to @tt{xk}, where @italic{k = n - 1}.
@ex[
(tabulate-network+headers (random-boolean-network/n 3))
]}
@section{TBF/TBN and SBF/SBN}
This section defines threshold Boolean functions (TBF) and networks (TBN), as