|
JGAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectexamples.knapsack.KnapsackMain
public class KnapsackMain
This class provides an implementation of the classic knapsack problem using a genetic algorithm. The goal of the problem is to reach a given volume (of a knapsack) by putting a number of items into the knapsack. The closer the sum of the item volumes to the given volume the better.
For further descriptions, compare the "coins" example also provided.
Field Summary | |
---|---|
static java.lang.String[] |
itemNames
Names of arbitrary items, only for outputting something imaginable |
static double[] |
itemVolumes
Volumes of arbitrary items in ccm |
Constructor Summary | |
---|---|
KnapsackMain()
|
Method Summary | |
---|---|
static void |
findItemsForVolume(double a_knapsackVolume)
Executes the genetic algorithm to determine the minimum number of items necessary to make up the given target volume. |
static void |
main(java.lang.String[] args)
Main method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double[] itemVolumes
public static final java.lang.String[] itemNames
Constructor Detail |
---|
public KnapsackMain()
Method Detail |
---|
public static void findItemsForVolume(double a_knapsackVolume) throws java.lang.Exception
a_knapsackVolume
- the target volume for which this method is
attempting to produce the optimal list of items
java.lang.Exception
public static void main(java.lang.String[] args)
args
- first and single element in the array = volume of the knapsack
to fill as a double value
|
JGAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |