Compare commits
No commits in common. "764b4612f109cbc5f3b7d92e608ed0decefa3848" and "e8ebab58cacdbc83965e8f49fd387fe6807710cb" have entirely different histories.
764b4612f1
...
e8ebab58ca
|
@ -7,7 +7,7 @@
|
||||||
@(define functions-evaluator
|
@(define functions-evaluator
|
||||||
(parameterize ([sandbox-output 'string]
|
(parameterize ([sandbox-output 'string]
|
||||||
[sandbox-error-output 'string]
|
[sandbox-error-output 'string]
|
||||||
[sandbox-memory-limit 500])
|
[sandbox-memory-limit 50])
|
||||||
(make-evaluator 'typed/racket #:requires '("functions.rkt"))))
|
(make-evaluator 'typed/racket #:requires '("functions.rkt"))))
|
||||||
|
|
||||||
@(define-syntax-rule (ex . args)
|
@(define-syntax-rule (ex . args)
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
@(define networks-evaluator
|
@(define networks-evaluator
|
||||||
(parameterize ([sandbox-output 'string]
|
(parameterize ([sandbox-output 'string]
|
||||||
[sandbox-error-output 'string]
|
[sandbox-error-output 'string]
|
||||||
[sandbox-memory-limit 500])
|
[sandbox-memory-limit 50])
|
||||||
(make-evaluator 'typed/racket #:requires '("networks.rkt"))))
|
(make-evaluator 'typed/racket #:requires '("networks.rkt"))))
|
||||||
|
|
||||||
@(define-syntax-rule (ex . args)
|
@(define-syntax-rule (ex . args)
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
@(define tbn-evaluator
|
@(define tbn-evaluator
|
||||||
(parameterize ([sandbox-output 'string]
|
(parameterize ([sandbox-output 'string]
|
||||||
[sandbox-error-output 'string]
|
[sandbox-error-output 'string]
|
||||||
[sandbox-memory-limit 500])
|
[sandbox-memory-limit 50])
|
||||||
(make-evaluator 'typed/racket #:requires '((submod "tbn.rkt" typed)))))
|
(make-evaluator 'typed/racket #:requires '((submod "tbn.rkt" typed)))))
|
||||||
|
|
||||||
@(define-syntax-rule (ex . args)
|
@(define-syntax-rule (ex . args)
|
||||||
|
@ -26,8 +26,6 @@
|
||||||
|
|
||||||
@defmodule[(submod dds/tbn typed)]
|
@defmodule[(submod dds/tbn typed)]
|
||||||
|
|
||||||
@section{TBFs and states}
|
|
||||||
|
|
||||||
This module defines threshold Boolean networks (TBN), as well as sign
|
This module defines threshold Boolean networks (TBN), as well as sign
|
||||||
Boolean networks (SBN). The update functions in such networks are
|
Boolean networks (SBN). The update functions in such networks are
|
||||||
respectively @seclink["tbf" #:doc '(lib
|
respectively @seclink["tbf" #:doc '(lib
|
||||||
|
@ -114,19 +112,3 @@ input values.
|
||||||
(apply-tbf/state (tbf/state (hash 'a 2 'b -2) 1)
|
(apply-tbf/state (tbf/state (hash 'a 2 'b -2) 1)
|
||||||
(hash 'a 1 'b 0 'c 1))
|
(hash 'a 1 'b 0 'c 1))
|
||||||
]}
|
]}
|
||||||
|
|
||||||
@section{Reading TBFs and SBFs}
|
|
||||||
|
|
||||||
@defproc[(lists+vars->tbfs/state [vars (Listof Variable)]
|
|
||||||
[lsts (Listof (Listof Real))])
|
|
||||||
(Listof TBF/State)]{
|
|
||||||
|
|
||||||
Reads a list of @racket[TBF/State] from a list of list of
|
|
||||||
@racket[Real]s.
|
|
||||||
|
|
||||||
The last element of each list is taken to be the threshold of the
|
|
||||||
TBFs, and the rest of the elements are taken to be the weights.
|
|
||||||
|
|
||||||
@ex[
|
|
||||||
(lists+vars->tbfs/state '(x y) '((1 2 3) (1 1 2)))
|
|
||||||
]}
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
@(define utils-evaluator
|
@(define utils-evaluator
|
||||||
(parameterize ([sandbox-output 'string]
|
(parameterize ([sandbox-output 'string]
|
||||||
[sandbox-error-output 'string]
|
[sandbox-error-output 'string]
|
||||||
[sandbox-memory-limit 500])
|
[sandbox-memory-limit 50])
|
||||||
(make-evaluator 'typed/racket #:requires '("utils.rkt"))))
|
(make-evaluator 'typed/racket #:requires '("utils.rkt"))))
|
||||||
|
|
||||||
@(define-syntax-rule (ex . args)
|
@(define-syntax-rule (ex . args)
|
||||||
|
|
18
tbn.rkt
18
tbn.rkt
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
(struct-out tbf/state) TBF/State tbf/state-w tbf/state-θ make-tbf/state
|
(struct-out tbf/state) TBF/State tbf/state-w tbf/state-θ make-tbf/state
|
||||||
sbf/state? apply-tbf/state
|
sbf/state? apply-tbf/state
|
||||||
|
|
||||||
lists+vars->tbfs/state
|
|
||||||
)
|
)
|
||||||
|
|
||||||
(: apply-tbf-to-state (-> TBF (State (U Zero One)) (U Zero One)))
|
(: apply-tbf-to-state (-> TBF (State (U Zero One)) (U Zero One)))
|
||||||
|
@ -77,22 +75,6 @@
|
||||||
(define tbf (make-tbf/state '((a . 2) (b . -2)) 1))
|
(define tbf (make-tbf/state '((a . 2) (b . -2)) 1))
|
||||||
(check-equal? (apply-tbf/state tbf st1) 1)
|
(check-equal? (apply-tbf/state tbf st1) 1)
|
||||||
(check-equal? (apply-tbf/state tbf st2) 0)))
|
(check-equal? (apply-tbf/state tbf st2) 0)))
|
||||||
|
|
||||||
(: lists+vars->tbfs/state (-> (Listof Variable) (Listof (Listof Real))
|
|
||||||
(Listof TBF/State)))
|
|
||||||
(define (lists+vars->tbfs/state vars lsts)
|
|
||||||
(for/list ([lst (in-list lsts)])
|
|
||||||
(define-values (ws θ) (split-at-right lst 1))
|
|
||||||
(make-tbf/state (for/list ([x (in-list vars)]
|
|
||||||
[w (in-list ws)])
|
|
||||||
(cons x w))
|
|
||||||
(car θ))))
|
|
||||||
|
|
||||||
(module+ test
|
|
||||||
(test-case "lists+vars->tbfs/state"
|
|
||||||
(check-equal? (lists+vars->tbfs/state '(x y) '((1 2 3) (1 1 2)))
|
|
||||||
(list (tbf/state '#hash((x . 1) (y . 2)) 3)
|
|
||||||
(tbf/state '#hash((x . 1) (y . 1)) 2)))))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
|
|
Loading…
Reference in New Issue
Block a user