Compare commits
No commits in common. "b611115f8c8e9d456482e17838c554e17989f90b" and "764b4612f109cbc5f3b7d92e608ed0decefa3848" have entirely different histories.
b611115f8c
...
764b4612f1
2 changed files with 1 additions and 108 deletions
|
@ -130,47 +130,3 @@ 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)))
|
||||
]}
|
||||
|
||||
@defproc[(lists+headers->tbfs/state [lsts+headers (Pairof (Listof Variable) (Listof (Listof Real)))])
|
||||
(Listof TBF/State)]{
|
||||
|
||||
Like @racket[lists+vars->tbfs/state], but the names of the variables
|
||||
are taken from the first line of @racket[lsts+headers].
|
||||
|
||||
All the lines in @racket[lsts+headers] are assumed to be of the same
|
||||
lenght, which means in particular that the last element of the first
|
||||
line (the threshold column) is discarded.
|
||||
|
||||
@ex[
|
||||
(lists+headers->tbfs/state '((x y f) (1 2 3) (1 1 2)))
|
||||
]}
|
||||
|
||||
@defproc[(lists->tbfs/state [lsts (Listof (Liostf Real))])
|
||||
(Listof TBF/State)]{
|
||||
|
||||
Like @racket[lists+vars->tbfs/state], but the names of the variables
|
||||
are generated as @tt{xi}, where @italic{i} is the index of the
|
||||
variable, starting from 0.
|
||||
|
||||
@ex[
|
||||
(lists->tbfs/state '((1 2 3) (1 1 2)))
|
||||
]}
|
||||
|
||||
@deftogether[(@defproc[(lists+vars->sbfs/state [vars (Listof Variable)]
|
||||
[lsts (Listof (Listof Real))])
|
||||
(Listof TBF/State)]
|
||||
@defproc[(lists+headers->sbfs/state
|
||||
[lsts (Pairof (Listof Variable) (Listof (Listof Real)))])
|
||||
(Listof TBF/State)]
|
||||
@defproc[(lists->sbfs/state [lsts (Listof (Listof Real))])
|
||||
(Listof TBF/State)])]{
|
||||
|
||||
Like the corresponding TBF-related functions, but which create SBFs.
|
||||
In other words, the input lists are treated as lists of weights, and
|
||||
the thresholds are set to 0.
|
||||
|
||||
@ex[
|
||||
(lists+vars->sbfs/state '(x y) '((1 2) (1 1)))
|
||||
(lists+headers->sbfs/state '((x y) (1 2) (1 1)))
|
||||
(lists->sbfs/state '((1 2) (1 1)))
|
||||
]}
|
||||
|
|
65
tbn.rkt
65
tbn.rkt
|
@ -25,8 +25,7 @@
|
|||
(struct-out tbf/state) TBF/State tbf/state-w tbf/state-θ make-tbf/state
|
||||
sbf/state? apply-tbf/state
|
||||
|
||||
lists+vars->tbfs/state lists+headers->tbfs/state lists->tbfs/state
|
||||
lists+vars->sbfs/state lists+headers->sbfs/state lists->sbfs/state
|
||||
lists+vars->tbfs/state
|
||||
)
|
||||
|
||||
(: apply-tbf-to-state (-> TBF (State (U Zero One)) (U Zero One)))
|
||||
|
@ -94,68 +93,6 @@
|
|||
(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)))))
|
||||
|
||||
(: lists+headers->tbfs/state (-> (Pairof (Listof Variable) (Listof (Listof Real)))
|
||||
(Listof TBF/State)))
|
||||
(define (lists+headers->tbfs/state lsts+headers)
|
||||
(lists+vars->tbfs/state (drop-right (car lsts+headers) 1)
|
||||
(cdr lsts+headers)))
|
||||
|
||||
(module+ test
|
||||
(test-case "lists+headers->tbfs/state"
|
||||
(check-equal? (lists+headers->tbfs/state '((x y f) (1 2 3) (1 1 2)))
|
||||
(list (tbf/state '#hash((x . 1) (y . 2)) 3)
|
||||
(tbf/state '#hash((x . 1) (y . 1)) 2)))))
|
||||
|
||||
(: lists->tbfs/state (-> (Listof (Listof Real)) (Listof TBF/State)))
|
||||
(define (lists->tbfs/state lsts)
|
||||
(lists+vars->tbfs/state
|
||||
(for/list ([i (in-range (length (car lsts)))])
|
||||
(string->symbol (format "x~a" i)))
|
||||
lsts))
|
||||
|
||||
(module+ test
|
||||
(test-case "lists->tbfs/state"
|
||||
(check-equal? (lists->tbfs/state '((1 2 3) (1 1 2)))
|
||||
(list (tbf/state '#hash((x0 . 1) (x1 . 2)) 3)
|
||||
(tbf/state '#hash((x0 . 1) (x1 . 1)) 2)))))
|
||||
|
||||
(: lists+vars->sbfs/state (-> (Listof Variable) (Listof (Listof Real))
|
||||
(Listof TBF/State)))
|
||||
(define (lists+vars->sbfs/state vars lsts)
|
||||
(for/list ([lst (in-list lsts)])
|
||||
(make-tbf/state (map (inst cons Variable Real) vars lst) 0)))
|
||||
|
||||
(module+ test
|
||||
(test-case "lists+vars->sbfs/state"
|
||||
(check-equal? (lists+vars->sbfs/state '(x y) '((1 2) (1 1)))
|
||||
(list (tbf/state '#hash((x . 1) (y . 2)) 0)
|
||||
(tbf/state '#hash((x . 1) (y . 1)) 0)))))
|
||||
|
||||
(: lists+headers->sbfs/state (-> (Pairof (Listof Variable) (Listof (Listof Real)))
|
||||
(Listof TBF/State)))
|
||||
(define (lists+headers->sbfs/state lsts)
|
||||
(lists+vars->sbfs/state (car lsts) (cdr lsts)))
|
||||
|
||||
(module+ test
|
||||
(test-case "lists+headers->sbfs/state"
|
||||
(check-equal? (lists+headers->sbfs/state '((x y) (1 2) (1 1)))
|
||||
(list (tbf/state '#hash((x . 1) (y . 2)) 0)
|
||||
(tbf/state '#hash((x . 1) (y . 1)) 0)))))
|
||||
|
||||
(: lists->sbfs/state (-> (Listof (Listof Real)) (Listof TBF/State)))
|
||||
(define (lists->sbfs/state lsts)
|
||||
(lists+vars->sbfs/state
|
||||
(for/list ([i (in-range (length (car lsts)))])
|
||||
(string->symbol (format "x~a" i)))
|
||||
lsts))
|
||||
|
||||
(module+ test
|
||||
(test-case "lists->sbfs/state"
|
||||
(check-equal? (lists->sbfs/state '((1 2) (1 1)))
|
||||
(list
|
||||
(tbf/state '#hash((x0 . 1) (x1 . 2)) 0)
|
||||
(tbf/state '#hash((x0 . 1) (x1 . 1)) 0)))))
|
||||
)
|
||||
|
||||
(module+ test
|
||||
|
|
Loading…
Reference in a new issue