From 761021e0551beaaaac1120ef6da37a70281974b2 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Thu, 30 Jan 2014 16:03:33 +0000 Subject: Started formally implementing the class structure but ran into some issues. I'll re-design the structure to account for function mutations, function variety, generic data types and modularized behaviour. --- src/jcgp/chromosome/Chromosome.java | 17 ++++++++++++++ src/jcgp/chromosome/element/ChromosomeElement.java | 7 ++++++ src/jcgp/chromosome/element/Input.java | 11 +++++++++ src/jcgp/chromosome/element/MutableElement.java | 12 ++++++++++ src/jcgp/chromosome/element/Node.java | 26 ++++++++++++++++++++++ src/jcgp/chromosome/element/Output.java | 26 ++++++++++++++++++++++ src/jcgp/chromosome/functions/Function.java | 7 ++++++ src/jcgp/chromosome/functions/FunctionSet.java | 14 ++++++++++++ 8 files changed, 120 insertions(+) create mode 100644 src/jcgp/chromosome/Chromosome.java create mode 100644 src/jcgp/chromosome/element/ChromosomeElement.java create mode 100644 src/jcgp/chromosome/element/Input.java create mode 100644 src/jcgp/chromosome/element/MutableElement.java create mode 100644 src/jcgp/chromosome/element/Node.java create mode 100644 src/jcgp/chromosome/element/Output.java create mode 100644 src/jcgp/chromosome/functions/Function.java create mode 100644 src/jcgp/chromosome/functions/FunctionSet.java (limited to 'src/jcgp/chromosome') diff --git a/src/jcgp/chromosome/Chromosome.java b/src/jcgp/chromosome/Chromosome.java new file mode 100644 index 0000000..19d7e77 --- /dev/null +++ b/src/jcgp/chromosome/Chromosome.java @@ -0,0 +1,17 @@ +package jcgp.chromosome; + +import java.util.ArrayList; + +import jcgp.chromosome.element.ChromosomeElement; + +public class Chromosome { + + private ArrayList> nodes; + + public Chromosome() { + + + + } + +} diff --git a/src/jcgp/chromosome/element/ChromosomeElement.java b/src/jcgp/chromosome/element/ChromosomeElement.java new file mode 100644 index 0000000..2dc9107 --- /dev/null +++ b/src/jcgp/chromosome/element/ChromosomeElement.java @@ -0,0 +1,7 @@ +package jcgp.chromosome.element; + +public abstract class ChromosomeElement { + + public abstract int evaluate(); + +} diff --git a/src/jcgp/chromosome/element/Input.java b/src/jcgp/chromosome/element/Input.java new file mode 100644 index 0000000..de051dc --- /dev/null +++ b/src/jcgp/chromosome/element/Input.java @@ -0,0 +1,11 @@ +package jcgp.chromosome.element; + +public class Input extends ChromosomeElement { + + @Override + public int evaluate() { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/src/jcgp/chromosome/element/MutableElement.java b/src/jcgp/chromosome/element/MutableElement.java new file mode 100644 index 0000000..ed7e23c --- /dev/null +++ b/src/jcgp/chromosome/element/MutableElement.java @@ -0,0 +1,12 @@ +package jcgp.chromosome.element; + +import jcgp.chromosome.Chromosome; +import jcgp.chromosome.functions.FunctionSet; + +public interface MutableElement { + + public void initialise(Chromosome chromosome, FunctionSet functions); + + public void mutate(Chromosome chromosome, FunctionSet functions); + +} diff --git a/src/jcgp/chromosome/element/Node.java b/src/jcgp/chromosome/element/Node.java new file mode 100644 index 0000000..f97c680 --- /dev/null +++ b/src/jcgp/chromosome/element/Node.java @@ -0,0 +1,26 @@ +package jcgp.chromosome.element; + +import jcgp.chromosome.Chromosome; +import jcgp.chromosome.functions.FunctionSet; + +public class Node extends ChromosomeElement implements MutableElement { + + @Override + public void initialise(Chromosome chromosome, FunctionSet functions) { + // TODO Auto-generated method stub + + } + + @Override + public void mutate(Chromosome chromosome, FunctionSet functions) { + // TODO Auto-generated method stub + + } + + @Override + public int evaluate() { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/src/jcgp/chromosome/element/Output.java b/src/jcgp/chromosome/element/Output.java new file mode 100644 index 0000000..261e77d --- /dev/null +++ b/src/jcgp/chromosome/element/Output.java @@ -0,0 +1,26 @@ +package jcgp.chromosome.element; + +import jcgp.chromosome.Chromosome; +import jcgp.chromosome.functions.FunctionSet; + +public class Output extends ChromosomeElement implements MutableElement { + + @Override + public void initialise(Chromosome chromosome, FunctionSet functions) { + // TODO Auto-generated method stub + + } + + @Override + public void mutate(Chromosome chromosome, FunctionSet functions) { + // TODO Auto-generated method stub + + } + + @Override + public int evaluate() { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/src/jcgp/chromosome/functions/Function.java b/src/jcgp/chromosome/functions/Function.java new file mode 100644 index 0000000..27697be --- /dev/null +++ b/src/jcgp/chromosome/functions/Function.java @@ -0,0 +1,7 @@ +package jcgp.chromosome.functions; + +public abstract class Function { + + public abstract int run(); + +} diff --git a/src/jcgp/chromosome/functions/FunctionSet.java b/src/jcgp/chromosome/functions/FunctionSet.java new file mode 100644 index 0000000..e9d197a --- /dev/null +++ b/src/jcgp/chromosome/functions/FunctionSet.java @@ -0,0 +1,14 @@ +package jcgp.chromosome.functions; + +import java.util.ArrayList; + +public class FunctionSet { + + private ArrayList functions; + + public FunctionSet() { + functions = new ArrayList(); + } + + +} -- cgit v1.2.3