aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/statistics/RunEntry.java
blob: 0953c49b904147e7b0eaff7d8ac018257c0fb473 (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
package jcgp.backend.statistics;

/**
 * This class encapsulates the data contained in a log entry.
 * <br><br>
 * Once constructed, data can only be retrieved. Note that
 * the generation argument in the constructor (and consequently
 * the value returned by {@code getGeneration()} refer to the 
 * last generation when improvement occurred.
 * 
 * @see StatisticsLogger
 * @author Eduardo Pedroni
 *
 */
public class RunEntry {
	
	private int generation, activeNodes;
	private double bestFitness;
	private boolean successful;
	
	/**
	 * Creates a new run entry for a logger. 
	 * 
	 * @param generation the generation when fitness improvement last occurred.
	 * @param fitness the best fitness achieved.
	 * @param active the number of active nodes in the best solution found.
	 * @param successful whether or not the run found a perfect solution.
	 */
	public RunEntry(int generation, double fitness, int active, boolean successful) {
		this.generation = generation;
		this.bestFitness = fitness;
		this.activeNodes = active;
		this.successful = successful;
	}
	
	/**
	 * @return the generation when improvement last occurred.
	 */
	public int getGeneration() {
		return generation;
	}
	/**
	 * @return the best fitness achieved during the run.
	 */
	public double getFitness() {
		return bestFitness;
	}
	/**
	 * @return true if the run was successful.
	 */
	public boolean isSuccessful() {
		return successful;
	}
	
	/**
	 * @return the number of active nodes in the best solution found. 
	 */
	public int getActiveNodes() {
		return activeNodes;
	}

}