package ac.essex.gp.interfaces;

import ac.essex.gp.individuals.Individual;
import ac.essex.gp.params.GPParams;
import ac.essex.gp.problems.Problem;
import ac.essex.gp.Evolve;

/**
 * <p/>
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version,
 * provided that any use properly credits the author.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details at http://www.gnu.org
 * </p>
 *
 * @author Olly Oechsle, University of Essex, Date: 17-Jan-2007
 * @version 1.0
 */
public abstract class GPInterface {

    protected int totalIndividualsEvaluated;
    protected int currentGeneration;
    protected boolean isIdeal;
    protected Individual bestIndividual;

    public GPInterface() {
        totalIndividualsEvaluated = 0;
        currentGeneration = 0;
        isIdeal = false;
        bestIndividual = null;
    }

    public abstract void fatal(String message);
    public abstract void message(String message);

    public abstract void onStartEvolution(Evolve e, Problem p);

    public void incrementIndividualEvaluations() {
        totalIndividualsEvaluated++;
    }

    public void incrementGenerations() {
        currentGeneration++;
    }

    public abstract void onGenerationStart();
    public abstract void onGenerationEnd();
    public abstract void onStopped();

    public void setBestIndividual(Individual individual) {
        bestIndividual = individual;
    }

    public int getTotalIndividualsEvaluated() {
        return totalIndividualsEvaluated;
    }

    public int getCurrentGeneration() {
        return currentGeneration;
    }

    public void setIdeal(boolean isIdeal) {
        this.isIdeal = isIdeal;
    }

    public boolean bestIndividualWasIdeal() {
        return isIdeal;
    }

    public Individual getBestIndividual() {
        return bestIndividual;
    }

    public abstract void dispose();

    public abstract void onEndEvolution(GPParams params);

}
