JGAP

examples
Class MapGeneExample

java.lang.Object
  extended by examples.MapGeneExample

public class MapGeneExample
extends java.lang.Object

This class provides an implementation of the classic "Make change" problem using a genetic algorithm. It is equivalent to the example in class MinimizingMakeChange in the same package, except that it uses a MapGene. A MapGene allows to specify discrete values for possible solutions. Instead, an IntegerGene (used in the original example) uses a range of values.

Since:
3.6

Constructor Summary
MapGeneExample()
           
 
Method Summary
static void main(java.lang.String[] args)
          Main method.
static void makeChangeForAmount(int a_targetChangeAmount)
          Executes the genetic algorithm to determine the minimum number of coins necessary to make up the given target amount of change.
static boolean uniqueChromosomes(Population a_pop)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapGeneExample

public MapGeneExample()
Method Detail

makeChangeForAmount

public static void makeChangeForAmount(int a_targetChangeAmount)
                                throws java.lang.Exception
Executes the genetic algorithm to determine the minimum number of coins necessary to make up the given target amount of change. The solution will then be written to System.out.

Parameters:
a_targetChangeAmount - the target amount of change for which this method is attempting to produce the minimum number of coins
Throws:
java.lang.Exception
Since:
1.0

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Main method. A single command-line argument is expected, which is the amount of change to create (in other words, 75 would be equal to 75 cents).

Parameters:
args - amount of change in cents to create
Throws:
java.lang.Exception
Since:
1.0

uniqueChromosomes

public static boolean uniqueChromosomes(Population a_pop)
Parameters:
a_pop - the population to verify
Returns:
true if all chromosomes in the populationa are unique
Since:
3.3.1

JGAP