JCL Knapsack

 

What does the sample do?

The knapsack problem is a combinatorial problem. The problem can be stated as follows: what is the best way to put different item values and weights in a container that supports up to a maximum weight?

The algorithm used in this example was the brute force where each possible solution is handled by a distributed task. After several task executions the best ones are selected. 

How do I run it?

To use the application, you must first start a JCL cluster. See JCL installation guide for that.

After that the user must import the Eclipse Knapsack project and run the Main class of it.  A GUI will open (identical to Figure 1)

 

How do I use it?


Figure 1. JCL Knapsack application – Main view

 

You must load a text file with all input data. This file must be created respecting the following restrictions:

  • the item index (must be unique), the item weight and its value.

There is a sample in the Knapsack folder of the application (see Figure 2)

After that, you must Load the file and there is a button for that. 

Figure 2. JCL Knapsack application after load an input file

 

After loading the data, you must configure the program execution parameters, precisely its capacity and DIV:

  • Capacity refers to the capacity of the container or the maximum weight for the program.
  • DIV is how many partitions or bins the problem will be divided.

After that, just click in execute Knapsack to start the application. The result will be displayed after the best solution is found, as illustrated in Figure 3.

Figure 3. JCL Knapsack application – Run brute force algorithm

 

Questions or comments, where can I go?

Questions about the API or about the codes of this application? See JCL installation guide and programming guide. 

If you have any questions, please contact the JCL team.