From 943fd322c4583cb574e24cc57fa06f3f755fc196 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Mon, 12 Oct 2020 22:53:34 +0200 Subject: [PATCH] network: Add make-sbf/state. --- networks.rkt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/networks.rkt b/networks.rkt index eba1ef5..eeb3452 100644 --- a/networks.rkt +++ b/networks.rkt @@ -83,6 +83,7 @@ [tbf/state-w (-> tbf/state? (hash/c variable? number?))] [tbf/state-θ (-> tbf/state? number?)] [make-tbf/state (-> (listof (cons/c variable? number?)) number? tbf/state?)] + [make-sbf/state (-> (listof (cons/c variable? number?)) sbf/state?)] [apply-tbf/state (-> tbf/state? (hash/c variable? (or/c 0 1)) (or/c 0 1))] [lists->tbfs/state (->* ((listof (listof (or/c number? symbol?)))) (#:headers boolean?) @@ -982,6 +983,16 @@ (test-case "sbf/state?" (check-true (sbf/state? (tbf/state #hash((a . -1) (b . 1)) 0))))) +;;; Makes a state/tbf which is an SBF from a list of pairs of names of +;;; variables and weights. +(define (make-sbf/state pairs) + (make-tbf/state pairs 0)) + +(module+ test + (test-case "make-sbf/state" + (check-equal? (make-sbf/state '((a . -1) (b . 1))) + (make-tbf/state '((a . -1) (b . 1)) 0)))) + ;;; Applies a state TBF to its inputs. ;;; ;;; Applying a TBF consists in multiplying the weights by the