Type random-network.
This commit is contained in:
parent
e2e0ee6903
commit
5e155d0a61
2 changed files with 23 additions and 1 deletions
15
networks.rkt
15
networks.rkt
|
@ -50,7 +50,7 @@
|
|||
|
||||
table+vars->network table->network table+headers->network
|
||||
|
||||
random-function/state random-boolean-function/state
|
||||
random-function/state random-boolean-function/state random-network
|
||||
)
|
||||
|
||||
(define-type (State a) (VariableMapping a))
|
||||
|
@ -1077,6 +1077,19 @@
|
|||
(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 #t)))))
|
||||
|
||||
(: random-network (All (a) (-> (DomainMapping a) (Network a))))
|
||||
(define (random-network domains)
|
||||
(network (for/hash : (VariableMapping (UpdateFunction a))
|
||||
([(x x-dom) (in-hash domains)])
|
||||
(values x (random-function/state domains x-dom)))
|
||||
domains))
|
||||
|
||||
(module+ test
|
||||
(test-case "random-network"
|
||||
(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)))))
|
||||
)
|
||||
|
||||
(require 'typed)
|
||||
|
|
|
@ -916,6 +916,15 @@ variables in @racket[args].
|
|||
(tabulate-state+headers/boolean (random-boolean-function/state '(a b)) '(a b))
|
||||
]}
|
||||
|
||||
@defproc[(random-network [domains (DomainMapping a)])
|
||||
(Network a)]{
|
||||
|
||||
Generates a random network from the given domain mapping.
|
||||
|
||||
@ex[
|
||||
(tabulate-network+headers (random-network (hash 'a '(1 2) 'b '(#f #t))))
|
||||
]}
|
||||
|
||||
@section{TBF/TBN and SBF/SBN}
|
||||
|
||||
This section defines threshold Boolean functions (TBF) and networks (TBN), as
|
||||
|
|
Loading…
Reference in a new issue