## Search for harmony

The harmony search algorithm was inspired by the improvisation of jazz musicians. Specifically, the process by which musicians (who may have never performed together before) quickly refine their individual improvisation through variation resulting in aesthetic harmony.

Each musician corresponds to an attribute in a candidate solution in the domain, and the pitch and range of each instrument correspond to the limits and constraints of the decision variable. Harmony among musicians is considered a complete candidate solution at any given time, and the aesthetic appreciation of harmony by the audience represents the specific cost function of the problem. Musicians seek harmony over time through small variations and improvisations, which results in an improvement over the cost function.

The objective of the search for harmony is to use the good candidate solutions already discovered to influence the creation of new candidate solutions towards the location of the optima. This is achieved by stochastically creating candidate solutions in stages, where each component is either drawn at random from a high-quality solution memory, adjusted from the high-quality solution memory, or randomly assigned within the limits of the problem.

The memory of the candidate solutions is initially random, and a greedy acceptance criterion is only used to admit new candidate solutions if they have an improved objective value, replacing an existing member.

The adjustment of a pitch selected in the harmony search memory is generally linear, for example for continuous optimization of functions:

x = x + range * e

where range is a user parameter (height bandwidth) to control the size of the changes, and e is a uniformly random number in [-1; 1].

The harmony search algorithm was designed as a generalized optimization method for a optimization continuous, discrete and constrained and has been applied to many types of optimization problems.

Harmony memory with a rate (HMCR) in [0; 1] controls the use of harmony memory information or the generation of a random pitch. As such, it controls the rate of convergence of the algorithm and is typically configured in [0.7; 0.95]. The height adjustment rate (PAR) in [0; 1] controls the tuning frequency of the pitches selected in the harmony memory, usually configured in [0,1; 0.5]. High values can cause the search to converge prematurely. The pitch adjustment rate and method of adjustment (amount of adjustment or fret width) are generally fixed, having a linear effect over time.

When creating a new harmony, aggregations of pitches can be taken through the musicians into the memory of the harmony. Updating the harmony memory is generally a greedy process, although other considerations such as diversity can be used when the most similar harmony is replaced.