Knapsack Algorithms
Essay Preview: Knapsack Algorithms
Report this essay
This section contains the discussion of the algorithms used and their results. Paragraph 2.1 explains the used algorithms. Paragraph 2.2 is about the experiments done with these algorithms. Paragraph 2.3 deals with the results of these experiments.

2.1 Algorithms used
2.1.1 GreedySolver
The Greedy solver uses the Greedy principle to fill the knapsack. This means that the algorithm always selects the best parcels first. It then puts as much as possible of these parcels in the knapsack. When that is not possible anymore it selects the second best parcel, etc.

For selecting the best parcel it uses two different selection methods. The first one is selecting the parcel with the highest value/volume ratio. The second one is selecting the parcel with the greatest volume.

The algorithm runs two times. The first time the best parcel is the parcel with the highest value/volume ratio. The second time it runs the best parcel is the parcel with the greatest volume. After running two times the algorithm compares the two values of the loaded cargo. The cargo with the highest loading value will be used as the solution.

The two different selecting methods are implemented, because when the value/volume ratios of the parcels are nearly the same it is better to look at the volume instead of the value/volume ratio. Larger parcels are usually harder to place, so it is better to place them first. The space left can then be filled with the smaller parcels.

2.1.2 OneWallBuildSolver
The OneWallBuildSolver uses some ideas of the wall building algorithm. The idea of the algorithm is that it moves forwards through the whole cargo from left to right and from bottom to top. At every position it inserts a parcel, computes a score, removes the parcel and it inserts the next parcel or the same parcel with another rotation. After the algorithm has tried all the parcels and their rotations in a position, the parcel with its specific rotation that gives the highest score will be selected and inserted.

The getCargoScore(Cargo aCargo); method computes this score. To compute this score it uses four parameters with their corresponding weights. Three of the parameters deal with the space left in

Get Your Essay

Cite this page

Best Parcels And Discussion Of The Algorithms. (April 3, 2021). Retrieved from