diff --git a/src/propeller/simplification.cljc b/src/propeller/simplification.cljc index 5527be0..fbd47b1 100644 --- a/src/propeller/simplification.cljc +++ b/src/propeller/simplification.cljc @@ -20,18 +20,15 @@ (delete-at-indices (choose-random-k k (range (count plushy))) plushy)) (defn auto-simplify-plushy - "naive auto-simplification with simple k annealing" - [argmap plushy steps error-function training-data start-k decrease-k-on-failure-prob verbose?] - (if verbose? (prn "Starting Auto-Simplification" {:current-plushy-length (count plushy) :k start-k :decrease-k-on-failure-prob decrease-k-on-failure-prob})) + "naive auto-simplification" + [argmap plushy steps error-function training-data k verbose?] + (if verbose? (prn {:start-plushy-length (count plushy) :k k})) (let [initial-errors (:errors (error-function argmap training-data {:plushy plushy}))] - (loop [step 0 curr-plushy plushy k start-k] - (if (and verbose? (= (mod step 50) 0)) (pr {:step step :k k} " ")) + (loop [step 0 curr-plushy plushy] (if (< steps step) - (do (if verbose? (prn "Finished Auto-Simplification" {:final-plushy-length (count curr-plushy) :final-plushy curr-plushy})) curr-plushy) - (let [new-plushy (delete-k-random k curr-plushy) + (do (if verbose? (prn {:final-plushy-length (count curr-plushy) :final-plushy curr-plushy})) curr-plushy) + (let [new-plushy (delete-k-random (rand-int k) curr-plushy) new-plushy-errors (:errors (error-function argmap training-data {:plushy new-plushy})) new-equal? (= new-plushy-errors initial-errors)] - (print-str new-plushy new-plushy-errors new-equal?) (recur (inc step) - (if new-equal? new-plushy curr-plushy) - (if new-equal? k (if (and (> k 1) (< (rand) decrease-k-on-failure-prob)) (dec k) k)))))))) \ No newline at end of file + (if new-equal? new-plushy curr-plushy))))))) \ No newline at end of file