aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/modules/problem/Problem.java
blob: 368d51229f20a30bcf49f7d9ccf2941bebb73365 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 
 * <br><br>
 * 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. 
 * <br><br>
 * 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;
	}
}