networks: Add random-network, random-boolean-network, random-boolean-networks/vars.
This commit is contained in:
parent
75b19c7977
commit
5fd16e4465
1 changed files with 18 additions and 0 deletions
18
networks.rkt
18
networks.rkt
|
@ -539,3 +539,21 @@
|
||||||
;;; variables appearing in the state.
|
;;; variables appearing in the state.
|
||||||
(define (random-boolean-function/state args)
|
(define (random-boolean-function/state args)
|
||||||
(random-function/state (make-boolean-domains args) '(#f #t)))
|
(random-function/state (make-boolean-domains args) '(#f #t)))
|
||||||
|
|
||||||
|
;;; Generates a random network from the given domain mapping.
|
||||||
|
(define/contract (random-network domains)
|
||||||
|
(domain-mapping/c . -> . network?)
|
||||||
|
(for/hash ([(x x-dom) (in-hash domains)])
|
||||||
|
(values x (random-function/state domains x-dom))))
|
||||||
|
|
||||||
|
;;; Generates a random Boolean network with the given variables.
|
||||||
|
(define/contract (random-boolean-network vars)
|
||||||
|
((listof variable?) . -> . network?)
|
||||||
|
(random-network (make-boolean-domains vars)))
|
||||||
|
|
||||||
|
;;; Like random-boolean-network, but also generates the names of the
|
||||||
|
;;; variables for the network. The variables have the names x0 to xk,
|
||||||
|
;;; where k = n - 1.
|
||||||
|
(define/contract (random-boolean-network/vars n)
|
||||||
|
(number? . -> . network?)
|
||||||
|
(random-boolean-network (for/list ([i (in-range n)]) (string->symbol (format "x~a" i)))))
|
||||||
|
|
Loading…
Reference in a new issue