Add random-boolean-function/state.
This commit is contained in:
parent
f5349a3659
commit
59b90d4c12
2 changed files with 23 additions and 0 deletions
13
networks.rkt
13
networks.rkt
|
@ -49,6 +49,8 @@
|
|||
tabulate-network tabulate-network+headers
|
||||
|
||||
table+vars->network table->network table+headers->network
|
||||
|
||||
random-function/state random-boolean-function/state
|
||||
)
|
||||
|
||||
(define-type (State a) (VariableMapping a))
|
||||
|
@ -1064,6 +1066,17 @@
|
|||
(define f (random-function/state doms '(e f)))
|
||||
(check-equal? (tabulate-state+headers f doms)
|
||||
'((a b f1) (1 3 e) (1 4 e) (2 3 f) (2 4 e)))))
|
||||
|
||||
(: random-boolean-function/state (-> (Listof Variable) (-> (State Boolean) Boolean)))
|
||||
(define (random-boolean-function/state args)
|
||||
(random-function/state (make-boolean-domains args) '(#f #t)))
|
||||
|
||||
(module+ test
|
||||
(test-case "random-boolean-function/state"
|
||||
(random-seed 1)
|
||||
(define f (random-boolean-function/state '(x1 x2)))
|
||||
(check-equal? (tabulate-state+headers/boolean f '(x1 x2))
|
||||
'((x1 x2 f1) (#f #f #f) (#f #t #f) (#t #f #t) (#t #t #f)))))
|
||||
)
|
||||
|
||||
(require 'typed)
|
||||
|
|
|
@ -906,6 +906,16 @@ by @racket[arg-domains] and producing values in @racket[func-domain].
|
|||
(tabulate-state+headers f doms))
|
||||
]}
|
||||
|
||||
@defproc[(random-boolean-function/state [args (Listof Variable)])
|
||||
(-> (State a) a)]{
|
||||
|
||||
Generates a random Boolean function accepting states over the
|
||||
variables in @racket[args].
|
||||
|
||||
@ex[
|
||||
(tabulate-state+headers/boolean (random-boolean-function/state '(a b)) '(a b))
|
||||
]}
|
||||
|
||||
@section{TBF/TBN and SBF/SBN}
|
||||
|
||||
This section defines threshold Boolean functions (TBF) and networks (TBN), as
|
||||
|
|
Loading…
Reference in a new issue