JGAP

examples.energy
Class CoinsEnergy

java.lang.Object
  extended by examples.energy.CoinsEnergy

public class CoinsEnergy
extends java.lang.Object

THIS EXAMPLE IS NOT IMPLEMENTED FULLY! For general description, see examples.MinimizingMakeChange.

Additionally, each to coin an energy value is assigned (new feature since JGAP version 2.4). Energy is interpreted here as weight of a coin. You could think of a coins holder that wants a low total weight as possible and that is capable of only holding a given maximum weight.

Since:
2.4

Nested Class Summary
static class CoinsEnergy.EnergyGeneConstraintChecker
          Uses to set the energy when a new allele is set
 
Constructor Summary
CoinsEnergy()
           
 
Method Summary
protected static int getValue(java.lang.String[] args, int index)
           
static void main(java.lang.String[] args)
          Main method.
static void makeChangeForAmount(int a_targetChangeAmount, double a_maxWeight)
          Executes the genetic algorithm to determine the minimum number of coins necessary to make up the given target amount of change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoinsEnergy

public CoinsEnergy()
Method Detail

makeChangeForAmount

public static void makeChangeForAmount(int a_targetChangeAmount,
                                       double a_maxWeight)
                                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
a_maxWeight - the maximum weight allowed in sum over all 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

getValue

protected static int getValue(java.lang.String[] args,
                              int index)

JGAP