aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/statistics/RunEntry.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/backend/statistics/RunEntry.java')
-rw-r--r--src/jcgp/backend/statistics/RunEntry.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/jcgp/backend/statistics/RunEntry.java b/src/jcgp/backend/statistics/RunEntry.java
new file mode 100644
index 0000000..0953c49
--- /dev/null
+++ b/src/jcgp/backend/statistics/RunEntry.java
@@ -0,0 +1,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;
+ }
+
+}