diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-03-30 21:07:37 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-03-30 21:07:37 +0100 |
commit | 04b35ccdad6e18701ede823e333118b0b22907c2 (patch) | |
tree | 0e993a5ffee4e63c4a2a6eca137da72b2453f868 /src/jcgp/function | |
parent | 2bf2d3ac2c578de481ecfd545d58be73c5628996 (diff) |
Running into some issues with running the CGP loop in the background with bindings.
Diffstat (limited to 'src/jcgp/function')
-rw-r--r-- | src/jcgp/function/Arithmetic.java | 1 | ||||
-rw-r--r-- | src/jcgp/function/BitwiseLogic.java | 1 | ||||
-rw-r--r-- | src/jcgp/function/BooleanLogic.java | 1 | ||||
-rw-r--r-- | src/jcgp/function/FunctionSet.java | 19 |
4 files changed, 16 insertions, 6 deletions
diff --git a/src/jcgp/function/Arithmetic.java b/src/jcgp/function/Arithmetic.java index 7ec1366..b61ee65 100644 --- a/src/jcgp/function/Arithmetic.java +++ b/src/jcgp/function/Arithmetic.java @@ -9,7 +9,6 @@ import jcgp.population.Connection; public class Arithmetic extends FunctionSet { public Arithmetic() { - maxArity = 2; name = "Arithmetic"; functionList = new Function[]{ new Addition(), diff --git a/src/jcgp/function/BitwiseLogic.java b/src/jcgp/function/BitwiseLogic.java index 033534d..7ced8e8 100644 --- a/src/jcgp/function/BitwiseLogic.java +++ b/src/jcgp/function/BitwiseLogic.java @@ -9,7 +9,6 @@ import jcgp.population.Connection; public class BitwiseLogic extends FunctionSet { public BitwiseLogic() { - maxArity = 2; name = "32-bit Logic"; functionList = new Function[]{ new And(), diff --git a/src/jcgp/function/BooleanLogic.java b/src/jcgp/function/BooleanLogic.java index d31b798..7e441f2 100644 --- a/src/jcgp/function/BooleanLogic.java +++ b/src/jcgp/function/BooleanLogic.java @@ -9,7 +9,6 @@ import jcgp.population.Connection; public class BooleanLogic extends FunctionSet { public BooleanLogic() { - maxArity = 2; name = "1-bit Logic"; functionList = new Function[]{ new And(), diff --git a/src/jcgp/function/FunctionSet.java b/src/jcgp/function/FunctionSet.java index 49ff7e7..fef8f88 100644 --- a/src/jcgp/function/FunctionSet.java +++ b/src/jcgp/function/FunctionSet.java @@ -12,7 +12,6 @@ import java.util.Iterator; public abstract class FunctionSet { protected Function[] functionList; protected ArrayList<Function> allowedFunctions; - protected int maxArity; protected String name; public int getAllowedFunctionCount() { @@ -23,12 +22,22 @@ public abstract class FunctionSet { return functionList.length; } - public Function getFunction(int index) { + public Function getAllowedFunction(int index) { return allowedFunctions.get(index); } + public Function getFunction(int index) { + return functionList[index]; + } + public int getMaxArity(){ - return maxArity; + int arity = 0; + for (Function function : allowedFunctions) { + if (function.getArity() > arity) { + arity = function.getArity(); + } + } + return arity; } public String getName() { @@ -58,4 +67,8 @@ public abstract class FunctionSet { public String toString() { return name; } + + public boolean isEnabled(Function f) { + return allowedFunctions.contains(f); + } }
\ No newline at end of file |