Class Folding

java.lang.Object
  extended by Folding

public class Folding
extends java.lang.Object

The class Folding implements the top level of the algorithm. It has a main method that reads a chain from the command line. Here is a sample run.

 > java Folding hphpphhp

 Best solution:
  Chromosome [fitness=-2, genes=[Right, Up, Up, Left, Down, Left, Up], chain=hphpphhp]
 
Because of the ``probabilistic'' nature of the algorithm, each run is likely to produce a new solution.


Field Summary
static java.lang.String DEFAULT_CHAIN
          The chain that will be used if no argument was supplied on the command line.
static int MAX_GENERATIONS
          A constant that specifies the maximum number of generations (iterations) for a run.
 
Constructor Summary
Folding()
           
 
Method Summary
static void main(java.lang.String[] args)
          The main method of this program.
static Chromosome solve(java.lang.String chain)
          Implements the top loop of the genetic algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_GENERATIONS

public static final int MAX_GENERATIONS
A constant that specifies the maximum number of generations (iterations) for a run.

See Also:
Constant Field Values

DEFAULT_CHAIN

public static final java.lang.String DEFAULT_CHAIN
The chain that will be used if no argument was supplied on the command line.

See Also:
Constant Field Values
Constructor Detail

Folding

public Folding()
Method Detail

solve

public static Chromosome solve(java.lang.String chain)
Implements the top loop of the genetic algorithm. You must complete the implementation of the method.

Parameters:
chain - The chain for which a fold is sought
Returns:
the best solution for this run

main

public static void main(java.lang.String[] args)
The main method of this program. Examples of the execution of the program from the command line:
 > java Folding ppphhpphhppppphhhhhhhpphhpppphhpphpp
 > java Folding hphpphhphpphphhpphph
 > java Folding hphpphhp
 

Parameters:
args - the array of arguments that were passed to the main method, generally on the command line