From 039769eaf6ca8a5454db5bf333b6087e2be6ca04 Mon Sep 17 00:00:00 2001 From: Ryan Boldi Date: Sat, 11 Jun 2022 10:30:51 -0400 Subject: [PATCH] gcd problem implemented --- src/propeller/problems/PSB2/fuel_cost.cljc | 4 ++-- src/propeller/problems/PSB2/gcd.cljc | 12 ++++++++---- src/propeller/problems/data_creation.cljc | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/propeller/problems/PSB2/fuel_cost.cljc b/src/propeller/problems/PSB2/fuel_cost.cljc index 071bf99..3c9379d 100644 --- a/src/propeller/problems/PSB2/fuel_cost.cljc +++ b/src/propeller/problems/PSB2/fuel_cost.cljc @@ -20,8 +20,8 @@ ; Source: https://arxiv.org/pdf/2106.06086.pdf ; ============================================================ -(def train-data (dc/read-data-that-has-no-strings "fuel-cost" "train")) -(def test-data (dc/read-data-that-has-no-strings "fuel-cost" "test")) +(def train-data (dc/read-data-formatted "fuel-cost" "train")) +(def test-data (dc/read-data-formatted "fuel-cost" "test")) ; Random integer between -100 and 100 (from smallest) (defn random-int [] (- (rand-int 201) 100)) diff --git a/src/propeller/problems/PSB2/gcd.cljc b/src/propeller/problems/PSB2/gcd.cljc index 209900e..9d0a948 100644 --- a/src/propeller/problems/PSB2/gcd.cljc +++ b/src/propeller/problems/PSB2/gcd.cljc @@ -2,6 +2,7 @@ (:require [psb2.core :as psb2] [propeller.genome :as genome] [propeller.push.interpreter :as interpreter] + [propeller.problems.data-creation :as dc] [propeller.utils :as utils] [propeller.push.instructions :refer [get-stack-instructions]] [propeller.push.state :as state] @@ -17,7 +18,10 @@ ; Source: https://arxiv.org/pdf/2106.06086.pdf ; ================================================================== -(def train-and-test-data (psb2/fetch-examples "data" "gcd" 200 2000)) +;(def train-and-test-data (psb2/fetch-examples "data" "gcd" 200 2000)) + +(def train-data (dc/read-data-formatted "gcd" "train")) +(def test-data (dc/read-data-formatted "gcd" "test")) (defn random-int [] (- (rand-int 201) 100)) @@ -76,9 +80,9 @@ (merge {:instructions instructions :error-function error-function - :training-data (:train train-and-test-data) - :testing-data (:test train-and-test-data) - :case-t-size (count (:train train-and-test-data)) + :training-data train-data + :testing-data test-data + :case-t-size (count train-data) :case-parent-rate 0 :case-parent-gens 1 :max-generations 300 diff --git a/src/propeller/problems/data_creation.cljc b/src/propeller/problems/data_creation.cljc index 33c38e5..de40c82 100644 --- a/src/propeller/problems/data_creation.cljc +++ b/src/propeller/problems/data_creation.cljc @@ -77,7 +77,7 @@ (str before) before))) -(defn read-data-that-has-no-strings [problem train-or-test] +(defn read-data-formatted [problem train-or-test] (apply list (with-open [reader (io/reader (str "picked/" problem "-" train-or-test ".csv"))] (let [csv-data (csv/read-csv reader)] (mapv zipmap