|
12 | 12 | import es.ugr.osgiliath.evolutionary.individual.Fitness;
|
13 | 13 | import es.ugr.osgiliath.evolutionary.individual.Individual;
|
14 | 14 | import es.ugr.osgiliath.planetwars.fitness.PlanetWarsFitnessCalculator;
|
| 15 | +import es.ugr.osgiliath.planetwars.fitness.PlanetWarsHierarchicalFitness; |
15 | 16 | import es.ugr.osgiliath.utils.Logger;
|
16 | 17 |
|
17 | 18 | public class PlanetWarsReplacer extends OsgiliathService implements Replacer {
|
@@ -52,7 +53,34 @@ public void select(Population pop, ArrayList<Individual> parents,
|
52 | 53 |
|
53 | 54 | System.out.println("BEST FITNESS "+ pop.getNBestIndividuals(1).get(0));
|
54 | 55 |
|
55 |
| - this.analyze(pop); |
| 56 | + //this.analyze(pop); |
| 57 | + //PRINTING ALL THE POPULATION |
| 58 | + List<Individual> all = pop.getAllIndividuals(); |
| 59 | + Debug debug = new Debug(); |
| 60 | + for(Individual inda:all){ |
| 61 | + String message = ""; |
| 62 | + BasicIndividual ind = (BasicIndividual) inda; |
| 63 | + |
| 64 | + int indSize = ((TreeGenome)ind.getGenome()).getDepth(); |
| 65 | + int indNodes = ((TreeGenome)ind.getGenome()).getNumberOfNodes(); |
| 66 | + int age = ((TreeGenome)ind.getGenome()).getNumberOfNodes(); |
| 67 | + String treeString = debug.resumeTree(inda); |
| 68 | + String treelargo = debug.writePlanetWarsTree((TreeGenome)ind.getGenome()); |
| 69 | + double victories = ((PlanetWarsHierarchicalFitness) ind.getFitness()).getPrimaryFitness(); |
| 70 | + double turns = ((PlanetWarsHierarchicalFitness) ind.getFitness()).getSecondaryFitness(); |
| 71 | + //IT,NUM_EVALUATIONS,TIME,SIM,SIZE,DEPTH,AGE,STAMP,TREE,VICTORIES,TURNS |
| 72 | + message = currentGeneration+","+ |
| 73 | + "0"+","+ |
| 74 | + "0"+","+ |
| 75 | + indNodes+","+ |
| 76 | + indSize+","+ |
| 77 | + age+","+ |
| 78 | + treeString+","+ |
| 79 | + treelargo+","+ |
| 80 | + victories+ |
| 81 | + turns+"\n"; |
| 82 | + this.log.statsX(message, ""); |
| 83 | + } |
56 | 84 | }
|
57 | 85 |
|
58 | 86 |
|
@@ -117,14 +145,14 @@ public void analyze(Population pop){
|
117 | 145 | PlanetWarsFitnessCalculator fc = new PlanetWarsFitnessCalculator(1);
|
118 | 146 | String tree = fc.writePlanetWarsTree((TreeGenome)bestI.getGenome());
|
119 | 147 | log.stats(
|
120 |
| - bestFitness.toString()+";"+ |
121 |
| - avgFitness.toString()+";"+ |
122 |
| - bestSize+";"+ |
123 |
| - averageSize+";"+ |
124 |
| - bestNodes+";"+ |
125 |
| - averageNodes+";"+ |
126 |
| - bestAge+";"+ |
127 |
| - averageAge+";"+ |
| 148 | + bestFitness.toString()+","+ |
| 149 | + avgFitness.toString()+","+ |
| 150 | + bestSize+","+ |
| 151 | + averageSize+","+ |
| 152 | + bestNodes+","+ |
| 153 | + averageNodes+","+ |
| 154 | + bestAge+","+ |
| 155 | + averageAge+","+ |
128 | 156 | tree+"\n"
|
129 | 157 | );
|
130 | 158 | }
|
|
0 commit comments