Harmony Search — Music-Inspired Metaheuristic Optimization

Decision Sciences
Introduced by
Zong Woo Geem, Joong Hoon Kim, G. V. Loganathan
Year
2001
Type
Metaheuristic population-based optimization

What does it do?

Harmony Search (HS) is a population-based metaheuristic for optimisation, introduced by Geem, Kim, and Loganathan in 2001.

It is modelled on the improvisation of musicians and builds each candidate solution from three operators: memory consideration, pitch adjustment, and random selection. It applies to both continuous and discrete decision variables and does not require gradient information. It has been applied to engineering design, water distribution network design, and scheduling problems.

The intuition behind the method

Imagine a jazz band improvising together: each musician remembers good melodies from past performances, occasionally tweaks a note by a small amount to refine the sound, and sometimes plays a completely random note to explore new territory. Harmony Search works the same way. A population of candidate solutions (the harmony memory) is maintained; at each step a new candidate is built by picking values either from remembered good solutions, adjusting those values slightly, or drawing a fresh random value. Over many iterations, this process nudges the population toward better and better solutions without needing gradients or derivatives.

History

Harmony Search was proposed in 2001 by Zong Woo Geem, Joong Hoon Kim, and G. V. Loganathan in the journal Simulation. The analogy is the improvisation of music players, who draw on remembered material, make small adjustments, and sometimes play a new note. The abstract of the original paper reports illustrations on a traveling salesman problem and a least-cost pipe network design problem. In 2007, Mahdavi, Fesanghary, and Damangir introduced the Improved Harmony Search (IHS), which varies PAR and the pitch bandwidth over iterations. Later work extended the method to other problems, including university course timetabling and home healthcare routing and scheduling.

When to use it

Choose Harmony Search when you need to optimise an objective function that can be evaluated but not differentiated, for example because it is a black box, non-convex, or mixes continuous and discrete variables. It is a reasonable candidate for engineering design, pipe network layout, and scheduling problems, where the objective can be evaluated repeatedly. Do not choose it when the objective is smooth and convex, or when gradients are available and a gradient-based or exact method is tractable, since such methods are usually more efficient. The method also requires that you can define a feasible range for each variable and a representation of a complete solution (the harmony) before it can run. Its parameters (HMS, HMCR, PAR) need to be set for the problem, so plan for tuning or a pilot run.

Limitations and considerations

  • Each new harmony is assembled one variable at a time, so problems with many decision variables are generally harder for the search and may need a larger evaluation budget.
  • Performance is sensitive to the choice of HMS, HMCR, and PAR; poor tuning leads to premature convergence or excessive exploration.
  • No convergence guarantees to the global optimum; like all metaheuristics, it may stall in local optima.
  • Requires defining the feasible range and a problem-specific harmony representation before the algorithm can be applied.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Gradient-free: works on black-box objective functions where derivatives are unavailable or expensive to obtain.
  • Handles both continuous and discrete decision variables within the same framework.
  • Conceptually simple with few hyperparameters (HMS, HMCR, PAR), making it accessible and easy to implement.
  • Naturally balances exploration (random selection) and exploitation (memory consideration and pitch adjustment).
  • The improvisation and replacement loop is generic, but the harmony representation, variable ranges, and constraint handling must be defined for each problem.

Applications

  • Engineering design optimisation, where the objective is typically cost or weight under constraints.
  • Least-cost pipe network design, such as water distribution networks; this is one of the two illustrations in the original paper.
  • Timetabling and scheduling, including university course timetabling, where harmony search is one of several metaheuristics applied.
  • Routing and scheduling in home healthcare, where a hybrid of harmony search and a genetic algorithm has been proposed for coordinated caregiver routing and scheduling.

How it works

How it works

1

A harmony memory of fixed size (HMS) is filled with randomly generated candidate solutions, and each one is evaluated against the objective function, so the initial memory costs HMS function evaluations. The memory holds the HMS solutions that later improvisations draw on: a larger memory keeps more candidate solutions available for recombination, while a smaller one concentrates the search on fewer solutions.

2

A new candidate solution (a new harmony) is composed decision-variable by decision-variable. For each variable, the algorithm draws a random number: if it falls below the harmony memory consideration rate (HMCR), the value is copied from one of the solutions already in memory; otherwise a completely random value is drawn from the variable's feasible range. HMCR therefore balances exploitation of past experience against exploration of the search space.

3

When a value is copied from memory, a second coin flip decides whether pitch adjustment is applied. With probability PAR (pitch adjustment rate), the copied value is perturbed by a small amount, nudged up or down within a bandwidth bw for continuous variables, or moved to a neighbouring discrete value. This local refinement step is analogous to a musician fine-tuning a note.

4

The new harmony is evaluated against the objective function. Assuming minimisation, if it is better than the worst solution currently in memory, it replaces that worst entry; otherwise it is discarded. For maximisation the comparison is reversed: the new harmony replaces the entry with the lowest objective value only if it has a higher value. The memory thus always retains the HMS best solutions found so far, gradually improving over iterations.

5

The loop repeats for a pre-set number of function evaluations or until a stopping criterion (e.g., convergence tolerance) is met. The best solution in the harmony memory at termination is returned as the algorithm's answer.

Common pitfalls

  • Setting HMCR too high (close to 1) reduces exploration: the algorithm reuses memory values heavily and can stagnate near local optima. Raising PAR can partly compensate, but the two parameters should be tuned together.
  • Setting PAR too low means values copied from memory are almost never adjusted, so there is little local refinement around good solutions and the search depends mainly on existing memory values and random draws.
  • Running too few iterations on complex problems: Harmony Search needs sufficient function evaluations to converge; a budget that is too small returns a poor approximate solution.
  • Keeping PAR and the bandwidth bw fixed for the whole run when the problem needs broad early search and fine late search. The Improved Harmony Search (IHS, Mahdavi et al., 2007) addresses this by increasing PAR and decreasing bw over iterations, so the search makes broader changes early and finer adjustments later.
  • Forgetting to adapt the harmony representation to the specific problem structure: an ill-defined feasible range or an unsuitable variable encoding will prevent the algorithm from finding meaningful solutions.

Frequently asked questions

How do I choose HMS, HMCR, and PAR?

There is no universal setting, and parameter values reported in the literature differ between problems, so treat any starting values as hypotheses to test. Run a small sensitivity analysis over HMCR and PAR on your own problem, check whether the best value found depends strongly on these settings, and use the same evaluation budget when comparing settings.

Does Harmony Search guarantee finding the global optimum?

No. Like all metaheuristics, Harmony Search is a heuristic and provides no theoretical guarantee of reaching the global optimum. It is designed to find good approximate solutions in reasonable computation time, particularly on non-convex or black-box problems where exact methods are impractical.

What is the difference between the original HS and Improved Harmony Search (IHS)?

In the original HS, PAR and the pitch adjustment bandwidth bw are fixed throughout the run. IHS (Mahdavi et al., 2007) increases PAR and decreases bw over iterations, so the search makes broader changes early and finer adjustments later. Whether this improves results on a given problem should be checked on that problem rather than assumed.

Can Harmony Search handle constraints?

Yes. Constraints are commonly handled through penalty functions added to the objective, or by repair operators that map infeasible solutions back into the feasible region. The algorithm itself does not natively enforce constraints, so the constraint-handling strategy must be defined as part of the problem setup.

Related methods

Sources

  1. Geem, Z. W., Kim, J. H., & Loganathan, G. V. (2001). A New Heuristic Optimization Algorithm: Harmony Search. Simulation, 76(2), 60–68.

    Open DOI reference
  2. Mahdavi, M., Fesanghary, M., & Damangir, E. (2007). An Improved Harmony Search Algorithm for Solving Optimization Problems. Applied Mathematics and Computation, 188(2), 1567–1579.

    Open DOI reference
  3. 01_a1de2edf7f9cc4615168f0f0264becdaffa06b77, p. 15

  4. 01_781d55a406f17408a1753d0a68773a0f1985b92f, p. 3