aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/population
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/population')
-rw-r--r--src/jcgp/population/Chromosome.java18
-rw-r--r--src/jcgp/population/Connection.java1
-rw-r--r--src/jcgp/population/Input.java5
-rw-r--r--src/jcgp/population/Node.java6
-rw-r--r--src/jcgp/population/Output.java6
5 files changed, 35 insertions, 1 deletions
diff --git a/src/jcgp/population/Chromosome.java b/src/jcgp/population/Chromosome.java
index 3e61a10..996e765 100644
--- a/src/jcgp/population/Chromosome.java
+++ b/src/jcgp/population/Chromosome.java
@@ -300,4 +300,22 @@ public class Chromosome {
}
return false;
}
+
+ public void printNodes() {
+ for (int r = 0; r < Parameters.getRows(); r++) {
+ System.out.print("r: " + r + "\t");
+ for (int c = 0; c < Parameters.getColumns(); c++) {
+ System.out.print("N: (" + r + ", " + c + ") ");
+ for (int i = 0; i < Parameters.getMaxArity(); i++) {
+ System.out.print("C" + i + ": (" + nodes[r][c].getConnection(i).getDescription() + ") ");
+ }
+ System.out.print("F: " + nodes[r][c].getFunction().toString() + "\t");
+ }
+ System.out.print("\n");
+ }
+
+ for (int o = 0; o < Parameters.getOutputs(); o++) {
+ System.out.print("o: " + o + " (" + outputs[o].getSource().getDescription() + ")\t");
+ }
+ }
}
diff --git a/src/jcgp/population/Connection.java b/src/jcgp/population/Connection.java
index 751fe10..63a171e 100644
--- a/src/jcgp/population/Connection.java
+++ b/src/jcgp/population/Connection.java
@@ -4,5 +4,6 @@ public interface Connection {
public Object getValue();
+ public String getDescription();
}
diff --git a/src/jcgp/population/Input.java b/src/jcgp/population/Input.java
index e793bf6..5c545d6 100644
--- a/src/jcgp/population/Input.java
+++ b/src/jcgp/population/Input.java
@@ -21,4 +21,9 @@ public class Input implements Connection {
public int getIndex() {
return index;
}
+
+ @Override
+ public String getDescription() {
+ return "i: " + index;
+ }
}
diff --git a/src/jcgp/population/Node.java b/src/jcgp/population/Node.java
index 35d33cb..1741235 100644
--- a/src/jcgp/population/Node.java
+++ b/src/jcgp/population/Node.java
@@ -25,6 +25,7 @@ public class Node implements MutableElement, Connection {
@Override
public Object getValue() {
+ //System.out.print("Calculating node: (" + row + ", " + column + ") > ");
return function.run(Arrays.copyOfRange(connections, 0, function.getArity()));
}
@@ -110,4 +111,9 @@ public class Node implements MutableElement, Connection {
}
return false;
}
+
+ @Override
+ public String getDescription() {
+ return "n: " + row + ", " + column;
+ }
}
diff --git a/src/jcgp/population/Output.java b/src/jcgp/population/Output.java
index b3ce74f..0df51e9 100644
--- a/src/jcgp/population/Output.java
+++ b/src/jcgp/population/Output.java
@@ -2,6 +2,8 @@ package jcgp.population;
import java.util.ArrayList;
+import jcgp.Parameters;
+
public class Output implements MutableElement {
private Connection source;
@@ -15,7 +17,9 @@ public class Output implements MutableElement {
public Object calculate() {
Object result = source.getValue();
- System.out.println("Output " + index + ": " + result);
+ if (Parameters.getDebug()) {
+ System.out.println("Output " + index + ": " + result);
+ }
return result;
}