/sigmah/src/test/java/org/sigmah/server/report/generator/map/GeneticTracer.java
http://sigma-h.googlecode.com/ · Java · 42 lines · 24 code · 7 blank · 11 comment · 1 complexity · e10cb395d1f7b13f06b9a48033692da7 MD5 · raw file
- /*
- * All Sigmah code is released under the GNU General Public License v3
- * See COPYRIGHT.txt and LICENSE.txt.
- */
-
- package org.sigmah.server.report.generator.map;
- /*
- * @author Alex Bertram
- */
-
- public class GeneticTracer implements GeneticSolver.Tracer {
-
-
- public void breeding(GeneticSolver solver, int i, int j) {
- System.out.println(String.format("Breeding phenotypes %d and %d", i, j));
- }
-
- public void evolved(GeneticSolver solver, int generation, int stagnationCount) {
- System.out.println(String.format("Generation %d evolved, fitness = %f", generation,
- solver.getFittest().getFitness()));
- }
-
- private String phenotypeToString(int[] p) {
- StringBuilder sb = new StringBuilder();
- for(int i = 0; i!=p.length; ++i) {
- String value = Integer.toString(p[i]);
- int len = value.length();
- while(len++ < 3) {
- sb.append(' ');
- }
- sb.append(value);
- }
- return sb.toString();
- }
-
- public void crossover(GeneticSolver solver, int[] p1, int[] p2, int xoverPoint, int[] c1, int[] c2) {
- // System.out.println("Parent 1 = " + phenotypeToString(p1));
- // System.out.println("Parent 2 = " + phenotypeToString(p2));
- // System.out.println("Child 1 = " + phenotypeToString(c1));
- // System.out.println("Child 2 = " + phenotypeToString(c2));
- }
- }