-
Notifications
You must be signed in to change notification settings - Fork 0
/
soccerconfig.clj
55 lines (50 loc) · 2.08 KB
/
soccerconfig.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(ns darwin.problems.soccerconfig
;(:require [darwin.gp.selection :as selection])
;(:require [darwin.gp.crossover :as crossover])
;(:require [darwin.gp.crossover :as crossover])
;(:require [darwin.problems.pathfindingtests.machine :as testing])
(:gen-class))
(require '[clojure.java.io :as io])
(import '[java.net Socket])
;IP and port of cluster head
(def target-ip "")
(def target-port 5555)
;push incoming socket connection to channel: (go (>! inbound-stack input))
(defn send-to-cluster
"send an individual to the cluster"
[indiv test-number]
(let [mark-indiv (assoc indiv :test-number test-number)
socket (Socket. target-ip target-port)
writer (io/writer socket)
reader (DataInputStream. (BufferedInputStream. (.getInputStream socket)))]
(.write writer (str (pr-str mark-indiv) "\n"))
(.flush writer)
;readline blocks until server response
(let [serverresponse (read-string (.readLine reader))]
(.close socket) serverresponse)))
(def configuration
{:genomic true
:instructions instructions
:literals (range 90)
:inputses '(())
:program-arity 0
:testcases (list
#(send-to-cluster % 1)
#(send-to-cluster % 2))
:behavioral-diversity #(testing/calculate-behavior-div % 5) ; TODO: play with the frame
:max-generations 500
:population-size 200
:initial-percent-literals 0.4
:max-initial-program-size 100
:min-initial-program-size 50
:evolution-config {:selection novelty-selection
:crossover #(crossover/alternation-crossover %1 %2 0.2 6)
:percentages '([40 :crossover]
[25 :deletion]
[5 :addition]
[30 :mutation])
:deletion-percent 7
:addition-percent 7
:mutation-percent 7
:keep-test-attribute :novelty
:individual-transform (fn [ind] (assoc ind :exit-states (map #(:move %) (:exit-states ind))))}}))