Type random-boolean-network/n.
This commit is contained in:
parent
861665e205
commit
e6764b2dd6
2 changed files with 32 additions and 1 deletions
22
networks.rkt
22
networks.rkt
|
@ -51,7 +51,7 @@
|
||||||
table+vars->network table->network table+headers->network
|
table+vars->network table->network table+headers->network
|
||||||
|
|
||||||
random-function/state random-boolean-function/state random-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))
|
(define-type (State a) (VariableMapping a))
|
||||||
|
@ -1109,6 +1109,26 @@
|
||||||
(#t #f #t #f #t #f)
|
(#t #f #t #f #t #f)
|
||||||
(#t #t #f #f #f #t)
|
(#t #t #f #f #f #t)
|
||||||
(#t #t #t #t #t #f)))))
|
(#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)
|
(require 'typed)
|
||||||
|
|
|
@ -934,6 +934,17 @@ Generates a random Boolean network with the given variables.
|
||||||
(tabulate-network+headers (random-boolean-network '(x y z)))
|
(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}
|
@section{TBF/TBN and SBF/SBN}
|
||||||
|
|
||||||
This section defines threshold Boolean functions (TBF) and networks (TBN), as
|
This section defines threshold Boolean functions (TBF) and networks (TBN), as
|
||||||
|
|
Loading…
Reference in a new issue