package jcgp.backend.modules.problem; import java.io.File; import jcgp.backend.function.FunctionSet; import jcgp.backend.modules.Module; import jcgp.backend.population.Chromosome; import jcgp.backend.population.Population; import jcgp.backend.resources.ModifiableResources; import jcgp.backend.resources.Resources; /** * Defines the general behaviour of a CGP problem. The primary function of Problem * is to evaluate a population and assign *

* Parameters may be specified to control the implemented problem. Any parameters * returned by {@code getLocalParameters()} should be displayed by the user interface, * if it is being used. See {@link Parameter} for more information. *

* It is advisable to use {@code Resources.reportln()} and {@code Resources.report()} * to print any relevant information. Note that reportln() and report() are affected * by the report interval base parameter. Use {@code Resources.println()} and * {@code Resources.print()} to print information regardless of the current generation. * See {@link Resources} for more information. * * @see Module * * @author Eduardo Pedroni * */ public abstract class Problem implements Module { protected FunctionSet functionSet; private String fileExtension = ".*"; private String name = this.getClass().getSimpleName(); public abstract void evaluate(Population population, Resources resources); public FunctionSet getFunctionSet() { return functionSet; } public abstract boolean isPerfectSolution(Chromosome fittest); public abstract void parseProblemData(File file, ModifiableResources resources); public void setFileExtension(String fileExtension) { this.fileExtension = fileExtension; } public String getFileExtension() { return fileExtension; } public void setProblemName(String newName) { this.name = newName; } public String getProblemName() { return name; } @Override public String toString() { return name; } }