aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/resources/ModifiableResources.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/backend/resources/ModifiableResources.java')
-rw-r--r--src/jcgp/backend/resources/ModifiableResources.java143
1 files changed, 70 insertions, 73 deletions
diff --git a/src/jcgp/backend/resources/ModifiableResources.java b/src/jcgp/backend/resources/ModifiableResources.java
index 53dc815..3dab2aa 100644
--- a/src/jcgp/backend/resources/ModifiableResources.java
+++ b/src/jcgp/backend/resources/ModifiableResources.java
@@ -3,8 +3,9 @@ package jcgp.backend.resources;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import jcgp.backend.function.FunctionSet;
-import jcgp.backend.resources.parameters.IntegerParameter;
-import jcgp.backend.resources.parameters.ParameterStatus;
+import jcgp.backend.parameters.IntegerParameter;
+import jcgp.backend.parameters.ParameterStatus;
+import jcgp.backend.parameters.monitors.IntegerMonitor;
/**
*
@@ -18,205 +19,236 @@ import jcgp.backend.resources.parameters.ParameterStatus;
*/
public class ModifiableResources extends Resources {
+ /**
+ * Creates an instance of this class and initialises
+ * all base parameters to default values. See
+ * {@code createBaseParameters} for the exact parameter
+ * initialisation.
+ */
public ModifiableResources() {
createBaseParameters();
}
- public void setValues(String filePath) {
-
- }
-
/**
- * @param rows the rows to set
+ * @param rows the number of rows to set.
*/
public void setRows(int rows) {
this.rows.set(rows);
}
/**
- * @param columns the columns to set
+ * @param columns the number of columns to set.
*/
public void setColumns(int columns) {
this.columns.set(columns);
}
/**
- * @param inputs the inputs to set
+ * @param inputs the number of inputs to set.
*/
public void setInputs(int inputs) {
this.inputs.set(inputs);
}
/**
- * @param outputs the outputs to set
+ * @param outputs the number of outputs to set.
*/
public void setOutputs(int outputs) {
this.outputs.set(outputs);
}
/**
- * @param populationSize the populationSize to set
+ * @param populationSize the population size to set.
*/
public void setPopulationSize(int populationSize) {
this.populationSize.set(populationSize);
}
/**
- * @param levelsBack the levelsBack to set
+ * @param levelsBack the levels back to set.
*/
public void setLevelsBack(int levelsBack) {
this.levelsBack.set(levelsBack);
}
/**
- * @param currentGeneration the currentGeneration to set
+ * @param currentGeneration the current generation to set.
*/
public void setCurrentGeneration(int currentGeneration) {
this.currentGeneration.set(currentGeneration);
}
+
+ /**
+ * Adds 1 to the current generation.
+ */
+ public void incrementGeneration() {
+ this.currentGeneration.set(currentGeneration.get() + 1);
+ }
/**
- * @param generations the generations to set
+ * @param generations the total generations to set.
*/
public void setGenerations(int generations) {
this.generations.set(generations);
}
-
+
/**
- * @param currentRun the currentRun to set
+ * @param currentRun the current run to set.
*/
public void setCurrentRun(int currentRun) {
this.currentRun.set(currentRun);
}
/**
- * @param runs the runs to set
+ * Adds 1 to the current generation.
+ */
+ public void incrementRun() {
+ currentRun.set(currentRun.get() + 1);
+ }
+
+ /**
+ * @param runs the total runs to set.
*/
public void setRuns(int runs) {
this.runs.set(runs);
}
/**
- * @param arity the arity to set
+ * This is called automatically by the experiment when the arity changes.
+ *
+ * @param arity the arity to set.
*/
public void setArity(int arity) {
this.arity.set(arity);
}
/**
- * @param seed the seed to set
+ * @param seed the seed to set.
*/
public void setSeed(int seed) {
this.seed.set(seed);
}
/**
- * @param report the report to set
+ * @param report the report interval to set.
*/
public void setReportInterval(int report) {
this.reportInterval.set(report);
}
/**
- * @return the rows
+ * @return the rows parameter.
*/
public IntegerParameter getRowsParameter() {
return rows;
}
/**
- * @return the columns
+ * @return the columns parameter.
*/
public IntegerParameter getColumnsParameter() {
return columns;
}
/**
- * @return the inputs
+ * @return the inputs parameter.
*/
public IntegerParameter getInputsParameter() {
return inputs;
}
/**
- * @return the outputs
+ * @return the outputs parameter.
*/
public IntegerParameter getOutputsParameter() {
return outputs;
}
/**
- * @return the populationSize
+ * @return the population size parameter.
*/
public IntegerParameter getPopulationSizeParameter() {
return populationSize;
}
/**
- * @return the levelsBack
+ * @return the levels back parameter.
*/
public IntegerParameter getLevelsBackParameter() {
return levelsBack;
}
/**
- * @return the currentGeneration
+ * @return the current generation parameter.
*/
public IntegerParameter getCurrentGenerationParameter() {
return currentGeneration;
}
/**
- * @return the generations
+ * @return the total generations parameter.
*/
public IntegerParameter getGenerationsParameter() {
return generations;
}
/**
- * @return the currentRun
+ * @return the current run parameter.
*/
public IntegerParameter getCurrentRunParameter() {
return currentRun;
}
/**
- * @return the runs
+ * @return the total runs parameter.
*/
public IntegerParameter getRunsParameter() {
return runs;
}
/**
- * @return the arity
+ * @return the arity parameter.
*/
public IntegerParameter getArityParameter() {
return arity;
}
/**
- * @return the seed
+ * @return the seed parameter.
*/
public IntegerParameter getSeedParameter() {
return seed;
}
/**
- * @return the report
+ * @return the report interval parameter.
*/
public IntegerParameter getReportIntervalParameter() {
return reportInterval;
}
+ /**
+ * Update the current function set.
+ *
+ * @param functionSet the new function set.
+ */
public void setFunctionSet(FunctionSet functionSet) {
this.functionSet = functionSet;
setArity(functionSet.getMaxArity());
}
+ /**
+ * This can be set to null if no extra console is desired.
+ *
+ * @param console the extra console for the experiment to use.
+ */
public void setConsole(Console console) {
this.console = console;
}
+ /**
+ * For internal use only, this initialises all base parameters to default values.
+ */
private void createBaseParameters() {
rows = new IntegerParameter(5, "Rows", false, true) {
@Override
@@ -242,29 +274,9 @@ public class ModifiableResources extends Resources {
}
};
- inputs = new IntegerParameter(3, "Inputs", true, false) {
- @Override
- public void validate(Number newValue) {
- if (newValue.intValue() <= 0) {
- status = ParameterStatus.INVALID;
- status.setDetails("Chromosome must have at least 1 input.");
- } else {
- status = ParameterStatus.VALID;
- }
- }
- };
+ inputs = new IntegerMonitor(3, "Inputs");
- outputs = new IntegerParameter(3, "Outputs", true, false) {
- @Override
- public void validate(Number newValue) {
- if (newValue.intValue() <= 0) {
- status = ParameterStatus.INVALID;
- status.setDetails("Chromosome must have at least 1 output.");
- } else {
- status = ParameterStatus.VALID;
- }
- }
- };
+ outputs = new IntegerMonitor(3, "Outputs");
populationSize = new IntegerParameter(5, "Population", false, true) {
@Override
@@ -308,12 +320,7 @@ public class ModifiableResources extends Resources {
}
};
- currentGeneration = new IntegerParameter(1, "Generation", true, false) {
- @Override
- public void validate(Number newValue) {
- // blank
- }
- };
+ currentGeneration = new IntegerMonitor(1, "Generation");
runs = new IntegerParameter(5, "Runs") {
@Override
@@ -330,19 +337,9 @@ public class ModifiableResources extends Resources {
}
};
- currentRun = new IntegerParameter(1, "Run", true, false) {
- @Override
- public void validate(Number newValue) {
- // blank
- }
- };
+ currentRun = new IntegerMonitor(1, "Run");
- arity = new IntegerParameter(0, "Max arity", true, false) {
- @Override
- public void validate(Number newValue) {
- // blank
- }
- };
+ arity = new IntegerMonitor(0, "Max arity");
seed = new IntegerParameter(1234, "Seed", false, true) {
@Override