JavaGenes, NASA Ames. Written largely by Al Globus

gov.nasa.javaGenes.graph
Class TwoVertexGraphCrossover

java.lang.Object
  extended bygov.nasa.javaGenes.core.ChildMaker
      extended bygov.nasa.javaGenes.graph.TwoVertexGraphCrossover
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
MoleculeTwoVertexCrossover

public abstract class TwoVertexGraphCrossover
extends ChildMaker

implements the crossover operator described in "JavaGenes: Evolving Graphs with Crossover," Al Globus, Sean Atsatt, John Lawton, and Todd Wipke and found at http://www.nas.nasa.gov/~globus/papers/JavaGenes/paper.html

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gov.nasa.javaGenes.core.ChildMaker
cumulative, forEvolution, last
 
Constructor Summary
TwoVertexGraphCrossover()
           
 
Method Summary
 Evolvable[] crossover(Graph father, Graph mother)
          Mate
protected  Vertex[] getVerticesForDivision(Graph graph)
           
 boolean isRequired(BrokenEdge edge)
          is it essential that is broken edge be satisfied during crossover.
 Evolvable[] makeChildren(Evolvable[] parents)
          Defaults to mutation, any subclass wanting more than one parent must over-ride.
 int numberOfParents()
           
abstract  void processInitialBrokenEdge(Graph graph, BrokenEdge b1, BrokenGraph second)
          find and connect a second broken edge
 BrokenGraph[] randomDivision(Graph g)
          Randomly rip a copy of this in two.
 Graph randomMerge(BrokenGraph gg1, BrokenGraph gg2)
          merge two BrokenGraph objects and return the resulting graph.
 
Methods inherited from class gov.nasa.javaGenes.core.ChildMaker
checkLastResults, checkResults, clearLast, getAndClearLastTabSeparatedResults, getFitnessFunctionNames, getLastTabSeparatedResults, headerFragment, makeChildren, mutate, neverUsed, proportionDown, results, setFitnessFunction, setFitnessFunctionNames, subClassMeasures, tabSeparatedResults, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TwoVertexGraphCrossover

public TwoVertexGraphCrossover()
Method Detail

numberOfParents

public int numberOfParents()
Overrides:
numberOfParents in class ChildMaker
Returns:
the number of parents makeChildren expects. I.e., the length of the array passed to makeChildren. If not implemented by subclass, defaults to 1 (mutation).

makeChildren

public Evolvable[] makeChildren(Evolvable[] parents)
Description copied from class: ChildMaker
Defaults to mutation, any subclass wanting more than one parent must over-ride. Mutators can over-ride mutate(Evovlable)

Overrides:
makeChildren in class ChildMaker
Parameters:
parents - the evolvables from which children will be created. By convention, the parents are not modified.
Returns:
the children created. Subclass must implement copyForEvolution()

crossover

public Evolvable[] crossover(Graph father,
                             Graph mother)
Mate

Returns:
an array of length 2 with the children in it
See Also:
randomDivision(gov.nasa.javaGenes.graph.Graph), BrokenGraph, randomMerge(gov.nasa.javaGenes.graph.BrokenGraph, gov.nasa.javaGenes.graph.BrokenGraph)

randomDivision

public BrokenGraph[] randomDivision(Graph g)
Randomly rip a copy of this in two.

Returns:
an array of length 2 with the pieces in it.

getVerticesForDivision

protected Vertex[] getVerticesForDivision(Graph graph)

randomMerge

public Graph randomMerge(BrokenGraph gg1,
                         BrokenGraph gg2)
merge two BrokenGraph objects and return the resulting graph. Merge the BrokenEdge objects of each BrokenGraph at random. Maintain edge compatibility where possible. If one BrokenGraph has excess BrokenEdge objects, randomly discard the excess or connect to a random vertex in the other BrokenGraph.


processInitialBrokenEdge

public abstract void processInitialBrokenEdge(Graph graph,
                                              BrokenEdge b1,
                                              BrokenGraph second)
find and connect a second broken edge

Parameters:
graph - graph being created
b1 - the first broken edge to be connected
second - graph from which the second broken edge must come

isRequired

public boolean isRequired(BrokenEdge edge)
is it essential that is broken edge be satisfied during crossover.

Returns:
false by default. Subclasses must redefine.

JavaGenes, NASA Ames. Written largely by Al Globus