JGAP

examples.gp.anttrail
Class AntTrailProblem

java.lang.Object
  extended by org.jgap.gp.GPProblem
      extended by examples.gp.anttrail.AntTrailProblem

public class AntTrailProblem
extends GPProblem

The ant trail problem. It demonstrates Genetic Programming (GP) capabilities of JGAP.

The ant trail problem searches for a solution to let an ant pick up as many food as possible on a given parcours with as few steps as possible. The ant can move, take food and see food in adjacent fields.

Whenever a new best solution has been found, the ant trail is printed to the console. Additionally, the tree represented by the GP program is output in graphical representation.

Since:
3.01

Field Summary
protected  int[][] m_map
           
static int m_maxMoves
          Maximum number of moves allowed.
protected static int totalFood
           
 
Constructor Summary
AntTrailProblem(GPConfiguration config, java.lang.String a_filename)
           
 
Method Summary
 GPGenotype create()
          Sets up the functions to use and other parameters.
protected  void displaySolution(int[][] a_antmap)
          Display ant trail as found by GP.
static void main(java.lang.String[] args)
          Starts the example.
 
Methods inherited from class org.jgap.gp.GPProblem
createTree, getGPConfiguration, setGPConfiguration, showTree, showTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_map

protected int[][] m_map

totalFood

protected static int totalFood

m_maxMoves

public static int m_maxMoves
Maximum number of moves allowed.

Constructor Detail

AntTrailProblem

public AntTrailProblem(GPConfiguration config,
                       java.lang.String a_filename)
                throws InvalidConfigurationException,
                       java.lang.Exception
Throws:
InvalidConfigurationException
java.lang.Exception
Method Detail

create

public GPGenotype create()
                  throws InvalidConfigurationException
Sets up the functions to use and other parameters. Then creates the initial genotype.

Specified by:
create in class GPProblem
Returns:
the genotype created
Throws:
InvalidConfigurationException
Since:
3.0

main

public static void main(java.lang.String[] args)
Starts the example.

Parameters:
args - ignored
Throws:
java.lang.Exception
Since:
3.0

displaySolution

protected void displaySolution(int[][] a_antmap)
Display ant trail as found by GP.

Parameters:
a_antmap - the map containing the trail

JGAP