aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/population/Output.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/backend/population/Output.java')
-rw-r--r--src/jcgp/backend/population/Output.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/jcgp/backend/population/Output.java b/src/jcgp/backend/population/Output.java
new file mode 100644
index 0000000..aa94ab6
--- /dev/null
+++ b/src/jcgp/backend/population/Output.java
@@ -0,0 +1,69 @@
+package jcgp.backend.population;
+
+import java.util.ArrayList;
+
+public class Output extends Gene implements MutableElement {
+
+ private Connection source;
+ private Chromosome chromosome;
+ private int index;
+
+ public Output(Chromosome chromosome, int index) {
+ this.chromosome = chromosome;
+ this.index = index;
+ //this.source = new SimpleObjectProperty<Connection>();
+ }
+
+ public Object calculate() {
+ Object result = source.getValue();
+ return result;
+ }
+
+ @Override
+ public void setConnection(int index, Connection newConnection) {
+ source = newConnection;
+ chromosome.recomputeActiveNodes();
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public Connection getSource() {
+ return source;
+ }
+
+// public SimpleObjectProperty<Connection> sourceProperty() {
+// return source;
+// }
+
+ public void getActiveNodes(ArrayList<Node> activeNodes) {
+ if (source instanceof Node) {
+ ((Node) source).getActive(activeNodes);
+ }
+ }
+
+ @Override
+ public boolean copyOf(MutableElement m) {
+ if (this != m) {
+ if (m instanceof Output) {
+ Output o = (Output) m;
+ if (index == o.getIndex()) {
+ if (source != o.getSource()) {
+ if (source instanceof Input && o.getSource() instanceof Input) {
+ if (((Input) source).getIndex() == ((Input) o.getSource()).getIndex()) {
+ return true;
+ }
+ } else if (source instanceof Node && o.getSource() instanceof Node) {
+ if (((Node) source).getRow() == ((Node) o.getSource()).getRow() &&
+ ((Node) source).getColumn() == ((Node) o.getSource()).getColumn()) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+}