 
 ;(map last (read-data))
 
-;(def test-cases-shuffled
-;  (shuffle (read-data)))
 
-(defn define-test-cases
+(defn define-fitness-cases
   "Returns a map with two keys: train and test. Train maps to a
-   subset of 251 random test cases (70%), and test maps to the
-   remaining 108 test cases (30%). These sets are different each
+   subset of 251 random fitness cases (70%), and test maps to the
+   remaining 108 fitness cases (30%). These sets are different each
    time this is called."
   []
-  (let [test-cases-shuffled (shuffle (read-data))
+  (let [fitness-cases-shuffled (shuffle (read-data))
         train-num 251]
-    {:train (subvec test-cases-shuffled 0 train-num)
-     :test (subvec test-cases-shuffled train-num)}))
+    {:train (subvec fitness-cases-shuffled 0 train-num)
+     :test (subvec fitness-cases-shuffled train-num)}))
 
-;(count (:test (define-test-cases)))
+;; Define the fitness cases. Do this once per run, so that train and test
+;; subsets stay the same throughout a run.
+(def bioavailability-fitness-cases (define-fitness-cases))
 
 
-;(run-push '(4 5 integer_add yyy6) (make-push-state))
-
-
-;(define-registered (symbol (str "x" (+ 4 2))) (fn [state] (push-item 2999 :integer state)))
-
-;(doseq [a (map #(symbol (str "x" %)) (range 241))]
-;  (define-registered a (fn [state] (push-item 2999 :integer state))))
-
-
-;(sort (map str (vec @registered-instructions)))
+;; Helper functions to get specific train and test cases
+;(defn train-fitness-case
+;  "Returns train fitness case number n for this run."
+;  [n]
+;  (nth (:train bioavailability-fitness-cases) n))
+;
+;(defn test-fitness-case
+;  "Returns test fitness case number n for this run."
+;  [n]
+;  (nth (:test bioavailability-fitness-cases) n))
 
 
 ;; I want x0 through x240 to be instructions that, when executed, push
 ;; the float from that column onto the float stack.
+(doseq [[numb symb] (map #(vector % (symbol (str "x" %))) (range 241))]
+  (eval `(define-registered ~symb (fn [state#] (push-item (stack-ref :auxiliary ~numb state#) :float state#)))))
+  
+;(sort (map str (vec @registered-instructions)))
 
 
 ;; This definition of atom-generators makes it so that choosing a terminal

;; the method used in the paper above.
(def bioavailability-atom-generators
  (list
    (fn [] (lrand-nth (list 'integer_div 'integer_mult 'integer_add 'integer_sub)))
    (fn [] (lrand-nth (for [n (range 241)]
                        (symbol (str "x" n)))))
    ))

;; bioavailability.clj
;;
;; This problem is a symbolic regression problem with 359 fitness cases
;; over 241 variables. Each fitness case is a candidate drug compound,
;; with each variable being a bi-dimensional molecule descriptor of
;; that compound. The data file data/bioavailability.txt
;; contains the data, with the last column being the target variable,
