/*
 * CigarApp.java 2003/03/18
 *
 *
*/


/*
 * An individual in the genetic algorithm's population. Needs to
 * provide storage and management of chromosome, fitness, and
 * objective function values
 *
 */
public interface CigarApp extends java.io.Serializable {

    /* 
     * Does any chromosome initialization that may be needed. Default
     * implementation would be the empty method
     *
     * @param pi the {@link Individual} to be initialized in an
     * application specific way
     */
    public void appInitChromosome(Individual pi, Population pop);

    /* 
     * Provided to write the headers of an application specific
     * phenotype printer. Since the application knows the phenotype,
     * it also knows how to print the phenotype. This method is called
     * once during CIGAR's initialization.
     */
    public void initPhenoPrint(Population p, String filename);

    /* 
     * Evaluates an individual and returns a fitness. 
     *
     * @param pi an {@link Individual} in the GA's {@link Population}
     *
     * @return a double non-negative fitness.
     */
    public double eval(Individual pi) throws ApplicationException;


    /*
     * Prints a representation of an {@link Individual}'s
     * phenotype. Usually prints the best individual in the
     * population.
     *
     * @param p the {@link Population}
     * @param filename which file to print to. May want to give it a
     * {@link BufferedOutputStream} instead of a filename in the
     * future.
     */
    public void phenoPrint(Population p, String filename); 


    /*
     * Application specific initialization like reading in data from a
     * file or other resource. This is called once before individual's
     * in the population are evaluated. 
     *
     * @param p The {@link Population} to be application specifically 
     * initialized. 
     */
    public void initialize(Population p);


}
