0

I am working on a project in which I am trying to implement the "Evolving Virtual Creatures" idea, written by Karl Sims.

The problem is that in every tutorial I have read, they build the individuals from integers or booleans, like this:

pop.subpop.0.species        = ec.vector.BitVectorSpecies
pop.subpop.0.species.ind    = ec.vector.BitVectorIndividual

But what if I have a Class named "Node", which is way more complicated than these ones? There is no such ec.vector.BitVectorNode. In the ECJ Tutorial page (http://cs.gmu.edu/~eclab/projects/ecj/docs/), there's a Tutorial named "Post-Tutorial Discussion" in which the following is written:

Arbitrary Representations It's fairly easy to make arbitrary representations with ECJ. Just subclass Individual and add in your own representation. You may need to make your own BreedingPipelines which know how to cross over or mutate your representation.

My class Node extends Individual, but I have no idea how to proceed or what changes do I have to apply to the common code to create a population (like the code in the Tutorials 1 and 2, for example)

This is the declaration of its attributes:

public class Node extends Individual
{
/** Properties */
private static final long serialVersionUID = -4771047292470201612L;
private double length;
private double width;
private double height;
private int recLimit;
private Joint joint;
private Set<Sensor> setSensors = new HashSet<Sensor>();
private Set<Neuron> setNeurons = new HashSet<Neuron>();
private Set<Effector> setEffectors = new HashSet<Effector>();
private Set<Connection> setConnections = new HashSet<Connection>();

//And then the methods

Any help will be very appreciated.

Stephan Herrmann
  • 7,963
  • 2
  • 27
  • 38
chopeds
  • 287
  • 1
  • 5
  • 21

1 Answers1

1

Tutorials 1&2 are examples of how to use the ECJ package to define and solve a problem with genetic algorithms, not genetic programming (for the difference between the two see here).

In genetic algorithms you have to "encode" your problem into some kind of a genome, bits or integers are common encoding representations as tutorial 1&2 show, so you have to find a way to extract this genome from your instances of the Node class (your population) to encode the problem. Just to be super clear, in other words your node class has to have a getGenome method or you need some other object that encapsulates the encoding logic and can look into your Node instances and know how to extract the genome.

If you are trying to instead evolve the class itself (not entirely clear from your question), Tutorial 4 shows how to use the genetic programming package. If what you're actually trying to do is "evolve code" (genetic programming) with this package that's the tutorial you should refer to.

Community
  • 1
  • 1
JohnIdol
  • 48,899
  • 61
  • 158
  • 242
  • Thanks, JohnIdol. What you said sounds a bit confusing to me, though. I have edited the post with the attributes of the Node class so that you can understand a bit more what the class looks like. What you said is that I have to transform, somehow, all this attributes into a vector of integers or booleans? – chopeds Mar 18 '15 at 14:04
  • That's exactly what I am saying - the topic of encoding neural networks for example (which you seem to have inside your node class) for evolving them with genetic algorithms is a very specific one and there's a lot of material on it, here's a paper just about that (how to encode neural networks for genetic algorithms) that will point you to a number of relevant references --> http://homepages.inf.ed.ac.uk/pkoehn/publications/encoding96.pdf / Also see http://en.wikipedia.org/wiki/Neuroevolution_of_augmenting_topologies and http://en.wikipedia.org/wiki/Neuroevolution – JohnIdol Mar 18 '15 at 14:26