Variables | Meaning |
---|---|
hms | Harmony memory size |
iter | The number of iterations |
hmcr | Harmony memory consideration rate |
par | Pitch adjustment rate |
bw | Bandwidth |
nnew | The number of new harmonies created in each iteration |
lb | The lower bound (list) |
ub | The upper bound (list) |
pos | The set of harmonies (list) |
score | The score of harmonies (list) |
dim | Dimension (list) |
new_pos | The set of newly created harmonies (list) |
new_score | The score of newly created harmonies (list) |
gbest | The score of the global best harmony |
gbest_pos | The position of the global best harmony (list) |
iter_best | The global best score of each iteration (list) |
con_iter | The last iteration number when "gbest" is updated |
if __name__ == '__main__':
# Parameter settings
hms = 30
iter = 1000
hmcr = 0.9
par = 0.1
bw = 0.02
nnew = 20
lb = [0, 0, 10, 10]
ub = [99, 99, 200, 200]
print(main(hms, iter, hmcr, par, bw, nnew, lb, ub))
The HS converges at its 674-th iteration, and the global best value is 8114.787624542521.
{
'best score': 8114.787624542521,
'best solution': [1.3078025478995294, 0.6468035853866221, 67.40186804119926, 10],
'convergence iteration': 674
}