/*
 * GenerationInfo.java
 *
 * Created on 24. listopad 2005, 12:49
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package cz.pcland.ga;

/**
 *
 * @author petr
 */
public class GenerationInfo {
    private BaseIndividual bestString;
    private int generationNum;
    
    /*Evaluations*/
    private double avgEval;
    private double sumEval;
    private double lowestEval;
    double bestEval;
    
    /*Fitnesses*/
    private double avgFitness;
    private double sumFitness;
    private double lowestFitness;
    double bestFitness;
    
    double distribution_evals[];
    double distribution_fitnesses[];
    
    
    
    /** Creates a new instance of GenerationInfo */
    public GenerationInfo(double bestEval, BaseIndividual bestStr, double sumEval, double avgEval, double lowestEval, int generationNum, double[] distribution_evals,
              double avgFitness, double sumFitness, double lowestFitness, double bestFitness, double[] distribution_fitnesses
            ) {
        this.bestEval = bestEval;
        this.bestString = bestStr;
        this.avgEval = avgEval;
        this.sumEval = sumEval;
        this.lowestEval = lowestEval;
        this.generationNum = generationNum;
        //this.toFitnessAdded = toFitnessAdded;
        this.distribution_evals = distribution_evals;
        this.avgFitness = avgFitness;
        this.sumFitness = sumFitness;
        this.lowestFitness = lowestFitness;
        this.bestFitness = bestFitness;
        this.distribution_fitnesses = distribution_fitnesses;
    }
    
    // public double getToFitnessAdded(){ return this.toFitnessAdded;}
    public BaseIndividual getBestString() {return bestString;}
    public int getGenNum() {return this.generationNum;}
    
    public double getBestRank(){return this.bestEval;}
    public double getAvgRank() {return this.avgEval;}
    public double getLowestRank() {return this.lowestEval;}
   
    
    public double getBestFitness(){return this.bestFitness;}
    public double getAvgFitness() {return this.avgFitness;}
    public double getLowestFitness() {return this.lowestFitness;}
    
    public double[] getDistributionRanks() {return this.distribution_evals;}
    public double[] getDistributionFitness() {return this.distribution_fitnesses;}
    
    public String toString() {
        double rndBestRank = (int)((bestEval)*10);
        rndBestRank = rndBestRank/10;
        
        double rndLowestRank = (int)((lowestEval)*10);
        rndLowestRank = rndLowestRank/10;
        
        double rndAvgRank = (int)((avgEval)*10);
        rndAvgRank = rndAvgRank/10;
        
        double rndBestFitness = (int)((bestFitness)*10);
        rndBestFitness = rndBestFitness/10;
        
        
        
        return  "<html>" +
                "<font color=blue> Generation " + generationNum + ".</font>" + "<br>" +
                " Avg rank: <font color=green> " + rndAvgRank +"</font>"+
                ", Highest rank: <font color=green>  " + rndBestRank +"</font>"+
                ", Highest fitness: <font color=green>  " + rndBestFitness +"</font>" +
                ", lowest rank: <font color=green> " + rndLowestRank +"</font>";
    }
    
}
