aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/population/Output.java
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-03-23 18:05:13 +0000
committerEduardo Pedroni <ep625@york.ac.uk>2014-03-23 18:05:13 +0000
commit0c288cc1952809294c8d70d86b9f41b04878ac2e (patch)
treeef9671b711fe665a3156594663c083595861a4e6 /src/jcgp/population/Output.java
parentd3527a63e12c0e5288f1e7d2e2dc18e61d16b760 (diff)
Majorly refactored, node grid is fully implemented. About to attempt active path locking.
Diffstat (limited to 'src/jcgp/population/Output.java')
-rw-r--r--src/jcgp/population/Output.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/jcgp/population/Output.java b/src/jcgp/population/Output.java
index ccecae0..b7c6128 100644
--- a/src/jcgp/population/Output.java
+++ b/src/jcgp/population/Output.java
@@ -2,15 +2,18 @@ package jcgp.population;
import java.util.ArrayList;
-public class Output implements MutableElement {
+import javafx.beans.property.SimpleObjectProperty;
+
+public class Output extends Gene implements MutableElement {
- private Connection source;
+ private SimpleObjectProperty<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() {
@@ -19,8 +22,8 @@ public class Output implements MutableElement {
}
@Override
- public void setConnection(Connection newConnection) {
- source = newConnection;
+ public void setConnection(int index, Connection newConnection) {
+ source.set(newConnection);
chromosome.recomputeActiveNodes();
}
@@ -29,12 +32,16 @@ public class Output implements MutableElement {
}
public Connection getSource() {
+ return source.get();
+ }
+
+ public SimpleObjectProperty<Connection> sourceProperty() {
return source;
}
public void getActiveNodes(ArrayList<Node> activeNodes) {
- if (source instanceof Node) {
- ((Node) source).getActive(activeNodes);
+ if (source.get() instanceof Node) {
+ ((Node) source.get()).getActive(activeNodes);
}
}
@@ -44,14 +51,14 @@ public class Output implements MutableElement {
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()) {
+ if (source.get() != o.getSource()) {
+ if (source.get() instanceof Input && o.getSource() instanceof Input) {
+ if (((Input) source.get()).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()) {
+ } else if (source.get() instanceof Node && o.getSource() instanceof Node) {
+ if (((Node) source.get()).getRow() == ((Node) o.getSource()).getRow() &&
+ ((Node) source.get()).getColumn() == ((Node) o.getSource()).getColumn()) {
return true;
}
}