use of ntuple.RankCorrelation in project SimpleAsteroids by ljialin.
the class BanditEA method runTrials.
public static StatSummary runTrials(int nBandits, int nTrials) throws Exception {
StatSummary ss = new StatSummary();
ArrayList<int[][]> examples = new ArrayList<>();
// System.out.println(examples);
rankCorrelation = new RankCorrelation();
for (int i = 0; i < nTrials; i++) {
BanditEA ea = new BanditEA(nBandits);
ea.evaluator = new ShortestPathTest();
ElapsedTimer t = new ElapsedTimer();
ea.run(nEvals);
System.out.println(t);
if (ea.success) {
// ss.add(ea.trialsSoFar);
}
ss.add(ea.evaluate(ea.genome));
System.out.println("Checking fitness: " + ea.evaluate(ea.genome));
examples.add(toSquareArray(ea.genome.toArray()));
System.out.println("Rank correlation check:");
rankCorrelation.rankCorrelation();
}
System.out.println("Created mazes");
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String out = gson.toJson(examples);
System.out.println("Created JSON String");
// System.out.println(out);
String outputFile = "data/mazes.json";
PrintWriter writer = new PrintWriter(outputFile);
writer.print(out);
writer.close();
System.out.println("Wrote file with " + examples.size() + " examples");
return ss;
}
Aggregations