NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

A Heuristics-Guided Simplified Discrete Harmony Search Algorithm for Solving 0-1 Knapsack Problem

Fuyuan Zheng, Kui Cheng, Kai Yang, Ning Li, Yu Lin, Yiwen ZhongAlgorithms 2025

TL;DR

This paper introduces a simplified Harmony Search (HS) algorithm, called SDHS, specifically designed for the 0-1 Knapsack Problem (0-1KP). By removing the random search operator and employing heuristic-guided item selection based on profit-weight ratio and profit, SDHS achieves better performance and simpler implementation than existing HS variants, outperforming state-of-the-art algorithms on large-scale instances.

What Problem Does This Paper Address?

The 0-1 Knapsack Problem (0-1KP) is a classic combinatorial optimization challenge with wide-ranging applications, from resource allocation to portfolio selection. It involves selecting items with specific profits and weights to maximize total profit without exceeding a knapsack's capacity, where each item can either be fully included or excluded. Because the 0-1KP is NP-hard, finding optimal solutions is computationally expensive for large instances. Metaheuristics, like Harmony Search (HS), are often used to find near-optimal solutions. However, standard HS algorithms can be complex to implement and tune, often requiring multiple parameters and sophisticated operators. This paper aims to address these limitations by proposing a simplified, yet effective, discrete HS algorithm that is easier to implement and tune while maintaining or improving performance for the 0-1KP.

Methods

The authors propose a Simplified Discrete Harmony Search (SDHS) algorithm. The core idea is to streamline the standard HS by:

  • Eliminating the Random Search Operator: This operator in traditional HS is used to introduce new solutions and maintain diversity. SDHS removes it, relying on other mechanisms for exploration.
  • Single Intrinsic Parameter: The algorithm only requires tuning one parameter: the harmony memory size (hms). This significantly simplifies implementation and parameter tuning compared to standard HS, which has harmony memory consideration rate (hmcr) and pitch adjustment rate (par) as additional parameters.
  • Heuristics-Guided Operators:
    • Memory Consideration Operator: This operator constructs a new solution by considering items based on their profit-weight ratio in non-ascending order. Items are selected from the harmony memory.
  • Solution-Level Pitch Adjustment Operator: This operator enhances the constructed solution by greedily considering items based on their profit in non-ascending order. It attempts to add items that are not currently in the knapsack if capacity allows. This operator works at the solution level, unlike the dimension-level pitch adjustment in standard HS.

These two heuristic-guided operators work together to construct and refine feasible solutions, aiming to balance exploration and exploitation effectively.

Datasets

The authors evaluated their SDHS algorithm on three sets of large-scale 0-1KP instances, which are commonly used in the literature for benchmarking knapsack problem algorithms. These sets include:

  • The first instance set: 16 uncorrelated instances with item numbers ranging from 500 to 6400.
  • The second instance set: Uncorrelated, weakly correlated, and strongly correlated instances, with item numbers ranging from 800 to 2000.
  • The third instance set: Weakly correlated, strongly correlated, multiple strongly correlated, profit ceiling, and uncorrelated instances, with varying item numbers.

Specific instances like KP01-KP15 were used for detailed analysis.

Key Insights and Ideas

  • Simplification Enhances Performance: Removing the random search operator and relying on heuristic-guided operators, particularly the profit-weight ratio and profit, not only simplifies the algorithm but also leads to improved performance. This suggests that for the 0-1KP, a more focused, heuristic-driven approach can be more effective than a purely random exploration.
  • Profit-Weight Ratio vs. Profit: The paper highlights the distinct roles of profit-weight ratio and profit. The profit-weight ratio is effective for initial item selection (memory consideration), while pure profit is crucial for fine-tuning and enhancing solutions (pitch adjustment). This dual-heuristic approach seems to be a key factor in SDHS's success.
  • Harmony Memory Size (hms) is Crucial: The study demonstrates that hms significantly influences the convergence speed and diversity of the algorithm. Too small an hms can lead to premature convergence, while too large an hms can slow down exploitation. Finding a suitable hms is key to achieving good performance.
  • Efficiency Beyond Standard HS: The SDHS algorithm's time complexity is improved by using a heap structure for the harmony memory, reducing the update complexity from O(hms) to O(log2 hms). This, combined with the reduced parameter set, makes it more practical.

Key Results

  • Outperforms State-of-the-Art: SDHS consistently outperformed thirteen other state-of-the-art metaheuristics (including various HS variants, cuckoo search, particle swarm optimization, etc.) on large-scale 0-1KP instances.
  • Average Improvement: An average improvement of 0.55% in solution quality was observed on large problem instances.
  • Best-Known Solutions: SDHS was able to find the best-known solutions on a significant number of instances, often outperforming other algorithms in terms of best, worst, and mean values.
  • Parameter Simplicity: The algorithm's performance is robust across a wide range of hms values, and its single-parameter nature greatly simplifies tuning.
  • Efficiency: The running time of SDHS is independent of the knapsack's capacity, a significant advantage over dynamic programming approaches, which struggle with large capacities.

Limitations and Future Work

  • Generalizability to Other Problems: The authors acknowledge that the strict binary nature of the 0-1KP decision variables might contribute to SDHS's success. Extending SDHS to other combinatorial optimization problems with more complex variable domains or graph structures might be challenging due to the absence of a random jumping mechanism, which could lead to premature convergence in such cases.
  • Heuristic Dependency: The algorithm's effectiveness relies heavily on the chosen heuristics (profit-weight ratio and profit). While these are generally effective for the knapsack problem, their optimality across all possible, potentially "deceptive," knapsack instances cannot be guaranteed.
  • Future Work: The authors suggest exploring whether the strategies employed by SDHS remain effective and efficient for other variants of the knapsack problem.

Summary updated

BibTeX
@inproceedings{zheng2025heuristics,
  author = {Fuyuan Zheng and Kui Cheng and Kai Yang and Ning Li and Yu Lin and Yiwen Zhong},
  title = {{A Heuristics-Guided Simplified Discrete Harmony Search Algorithm for Solving 0-1 Knapsack Problem}},
  booktitle = {Algorithms},
  year = {2025},
  doi = {10.3390/a18050295},
}
Figure