| java.lang.Object examples.knapsack.KnapsackMain
KnapsackMain | public class KnapsackMain (Code) | | 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.
author: Klaus Meffert since: 2.3 |
Method Summary | |
public 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. | public static void | main(String[] args) Main method. |
itemNames | final public static String[] itemNames(Code) | | Names of arbitrary items, only for outputting something imaginable
|
itemVolumes | final public static double[] itemVolumes(Code) | | Volumes of arbitrary items in ccm
|
findItemsForVolume | public static void findItemsForVolume(double a_knapsackVolume) throws Exception(Code) | | Executes the genetic algorithm to determine the minimum number of
items necessary to make up the given target volume. The solution will then
be written to the console.
Parameters: a_knapsackVolume - the target volume for which this method isattempting to produce the optimal list of items throws: Exception - author: Klaus Meffert since: 2.3 |
main | public static void main(String[] args)(Code) | | Main method. A single command-line argument is expected, which is the
volume to create (in other words, 75 would be equal to 75 ccm).
Parameters: args - first and single element in the array = volume of the knapsackto fill as a double value author: Klaus Meffert since: 2.3 |
|
|