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.

The executable knapsack_month_year_jar has a .bat file (for windows) or a .sh file (for linux) to simplify its execution. There is always the console option using the Java command java -jar knapsack_month_year_jar

 

How do I use it?


Figure 2. JCL Knapsack application – Main view

 

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

  • Each line must have the parameters of a given item and they are: the item index (must be unique), the item weight and its value.

There is a sample in the Knapsack folder of the application (see Fig 3)

After that, you must Load the file and there is a button for that. After loading the file it will be presented in the top text box of the program, as shown below:

Figure 3. 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 Fig 4.

Figure 4. 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 HPC team.