Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added functionality for printing json formatted logs.
Also added a odd problem example that includes log printing.
- Loading branch information
Showing
5 changed files
with
152 additions
and
44 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
;; odd.clj | |||
;; an example problem for clojush, a Push/PushGP system written in Clojure | |||
;; Lee Spector, lspector@hampshire.edu, 2010 | |||
|
|||
(ns clojush.examples.odd-csv-and-json | |||
(:use [clojush.pushgp.pushgp] | |||
[clojush.pushstate] | |||
[clojush.interpreter])) | |||
|
|||
;;;;;;;;;;;; | |||
;; The "odd" problem: take a positive integer input and push a Boolean indicating | |||
;; whether or not the input is an odd number. There are many ways to compute this | |||
;; and PushGP sometimes finds unusual methods. | |||
|
|||
;; This version shows how you can print csv and json log files. | |||
|
|||
(define-registered | |||
in | |||
(fn [state] (push-item (stack-ref :auxiliary 0 state) :integer state))) | |||
|
|||
(pushgp | |||
:use-single-thread true | |||
:error-function (fn [program] | |||
(doall | |||
(for [input (range 10)] | |||
(let [state (run-push program | |||
(push-item input :auxiliary | |||
(push-item input :integer | |||
(make-push-state)))) | |||
top-bool (top-item :boolean state)] | |||
(if (not (= top-bool :no-stack-item)) | |||
(if (= top-bool (odd? input)) 0 1) | |||
1000))))) | |||
:atom-generators (concat (registered-nonrandom) | |||
(list (fn [] (rand-int 100)) | |||
'in)) | |||
:print-csv-logs true | |||
:print-json-logs true | |||
:csv-log-filename "log.csv" | |||
:json-log-filename "log.json" | |||
:log-fitnesses-for-all-cases false | |||
:json-log-program-strings false | |||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters