Type make-tbf/state.
This commit is contained in:
parent
490127593c
commit
ed67927803
2 changed files with 21 additions and 1 deletions
|
@ -70,3 +70,14 @@ Shorter synonyms for field accessors of @racket[tbf/state].
|
||||||
(values (tbf/state-w tbfs)
|
(values (tbf/state-w tbfs)
|
||||||
(tbf/state-θ tbfs)))
|
(tbf/state-θ tbfs)))
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
@defproc[(make-tbf/state [pairs (Listof (Pairof Variable Real))]
|
||||||
|
[threshold Real])
|
||||||
|
TBF/State]{
|
||||||
|
|
||||||
|
Makes a @racket[TBF/State] from a list of pairs of names of variables
|
||||||
|
and weights, as well as a threshold.
|
||||||
|
|
||||||
|
@ex[
|
||||||
|
(make-tbf/state '((x1 . 1) (x2 . 1)) 1)
|
||||||
|
]}
|
||||||
|
|
11
tbn.rkt
11
tbn.rkt
|
@ -15,7 +15,7 @@
|
||||||
(provide
|
(provide
|
||||||
apply-tbf-to-state
|
apply-tbf-to-state
|
||||||
|
|
||||||
(struct-out tbf/state) TBF/State tbf/state-w tbf/state-θ
|
(struct-out tbf/state) TBF/State tbf/state-w tbf/state-θ make-tbf/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)))
|
||||||
|
@ -36,6 +36,15 @@
|
||||||
(define tbf/state-w tbf/state-weights)
|
(define tbf/state-w tbf/state-weights)
|
||||||
(define tbf/state-θ tbf/state-threshold)
|
(define tbf/state-θ tbf/state-threshold)
|
||||||
|
|
||||||
|
(: make-tbf/state (-> (Listof (Pairof Variable Real)) Real TBF/State))
|
||||||
|
(define (make-tbf/state pairs threshold)
|
||||||
|
(tbf/state (make-immutable-hash pairs) threshold))
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(test-case "tbf/state"
|
||||||
|
(define f (make-tbf/state '((x1 . 1) (x2 . 1)) 1))
|
||||||
|
(check-equal? (tbf/state-w f) #hash((x1 . 1) (x2 . 1)))
|
||||||
|
(check-equal? (tbf/state-θ f) 1)))
|
||||||
)
|
)
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
|
|
Loading…
Reference in a new issue