From 9da863deab9fd9b3556913349581dfe750bdea07 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Sun, 21 Feb 2016 22:31:28 -0600 Subject: [PATCH 1/2] Using `long` to avoid `bigint` `N`s in printouts. --- src/simple_search/experiment.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple_search/experiment.clj b/src/simple_search/experiment.clj index d4c53aa..eea1fe4 100644 --- a/src/simple_search/experiment.clj +++ b/src/simple_search/experiment.clj @@ -27,7 +27,7 @@ (:label (:problem result)) (:max-evals result) (:run-number result) - (:score @(:answer result))))) + (long (:score @(:answer result)))))) ;; This really shouldn't be necessary, as I should have included the labels ;; in the maps when generated the problem files. Unfortunately I only just From a68077a5df71df7ada325ba0f08599eacdc5bbf3 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Sun, 21 Feb 2016 22:32:23 -0600 Subject: [PATCH 2/2] Switched from futures to agents. Hopefully this will scale better, especially when people are doing a _lot_ of combinations or runs. --- src/simple_search/experiment.clj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/simple_search/experiment.clj b/src/simple_search/experiment.clj index eea1fe4..c804388 100644 --- a/src/simple_search/experiment.clj +++ b/src/simple_search/experiment.clj @@ -13,7 +13,13 @@ (for [searcher searchers p problems n (range num-replications)] - (let [answer (future (searcher p max-evals))] + ; The `nil` here sets the answer to initially be nil so we can + ; tell if it's been evaluated or not. + (let [answer (agent nil)] + ; The `send` says to evaluate `(searcher p max-evals)` in another + ; thread when convenient, and replace the old value of the answer + ; (marked by the placeholder argument `_`) with that new value. + (send answer (fn [_] (searcher p max-evals))) {:searcher searcher :problem p :max-evals max-evals @@ -23,6 +29,8 @@ (defn print-experimental-results [results] (doseq [result results] + (when (nil? @(:answer result)) + (await (:answer result))) (println (:label (meta (:searcher result))) (:label (:problem result)) (:max-evals result)