aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/population/Chromosome.java
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-05-14 01:32:51 +0100
committerEduardo Pedroni <ep625@york.ac.uk>2014-05-14 01:32:51 +0100
commitc35a6806df01481c1b169cd0fc47660ea1cc10fb (patch)
tree7a9a90d88a9b962bcc091533997df798ac454423 /src/jcgp/backend/population/Chromosome.java
parent95b4a9421923cec63b6e0e8f58972d146100bd0f (diff)
Refactored Mutable, commented a little bit of the GUI package
Diffstat (limited to 'src/jcgp/backend/population/Chromosome.java')
-rw-r--r--src/jcgp/backend/population/Chromosome.java26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/jcgp/backend/population/Chromosome.java b/src/jcgp/backend/population/Chromosome.java
index 673bb26..e28032c 100644
--- a/src/jcgp/backend/population/Chromosome.java
+++ b/src/jcgp/backend/population/Chromosome.java
@@ -149,7 +149,7 @@ public class Chromosome implements Comparable<Chromosome> {
// set random outputs
for (Output output : outputs) {
- output.setConnection(0, getRandomConnection());
+ output.setSource(getRandomConnection());
}
}
@@ -198,9 +198,9 @@ public class Chromosome implements Comparable<Chromosome> {
for (int o = 0; o < outputs.length; o++) {
copyOutput = clone.getOutput(o).getSource();
if (copyOutput instanceof Input) {
- outputs[o].setConnection(0, inputs[((Input) copyOutput).getIndex()]);
+ outputs[o].setSource(inputs[((Input) copyOutput).getIndex()]);
} else if (copyOutput instanceof Node) {
- outputs[o].setConnection(0, nodes[((Node) copyOutput).getRow()][((Node) copyOutput).getColumn()]);
+ outputs[o].setSource(nodes[((Node) copyOutput).getRow()][((Node) copyOutput).getColumn()]);
} else {
// something bad happened
System.out.println("Warning: Connection of subtype " + copyOutput.getClass().toString() + " is not explicitly handled by copy constructor.");
@@ -212,6 +212,16 @@ public class Chromosome implements Comparable<Chromosome> {
}
/**
+ * Returns a reference to the indexed input.
+ *
+ * @param index the input index.
+ * @return the input reference.
+ */
+ public Input getInput(int index) {
+ return inputs[index];
+ }
+
+ /**
* Returns a reference to any node, addressed by row and column.
*
* @param row the row of the node.
@@ -233,16 +243,6 @@ public class Chromosome implements Comparable<Chromosome> {
}
/**
- * Returns a reference to the indexed input.
- *
- * @param index the input index.
- * @return the input reference.
- */
- public Input getInput(int index) {
- return inputs[index];
- }
-
- /**
* @return the fitness of the chromosome.
*/
public double getFitness() {