项目作者: OnurSahin20

项目描述 :
This repository contains 4 metaheuristic search algorithm for optimization
高级语言:
项目地址: git://github.com/OnurSahin20/MetaheuristicOptimizationAlgorithms.git


MetaheuristicOptimizationAlgorithms

This repository contains 4 metaheuristic search algorithms 1) Genetic Algorithm 2) Differential Evolution 3) Cuckoo Search 4) Harmony Search and I used minimization problem which called the Michalewicz test function for the performance of algorithms. I don’t test algorithms carefully, therefore somewhere in the codes, there might be some flaws.I’ve been trying to write these codes in Python as efficiently as possible. My request you who will look into codes please criticize me and show my mistakes or better way to write code. Contact with me at ogungorsahin@gmail.com
Example

  1. import numpy as np
  2. from GA_functions import genetic_algorithm
  3. import time
  4. import matplotlib.pyplot as plt
  5. start = time.perf_counter()
  6. nd = 5
  7. lb = np.array([0] * nd)
  8. ub = np.array([np.pi] * nd)
  9. P = 50
  10. Generation = 2500
  11. m = 15
  12. minprob = True
  13. Pc = 0.85
  14. Pm = 0.03
  15. def michalewicz(xx):
  16. mm = 10
  17. n1 = np.shape(xx)[0]
  18. n2 = np.shape(xx)[1]
  19. outputs = np.zeros((n1, 1))
  20. for i in range(n1):
  21. s = 0
  22. for j in range(1, n2 + 1):
  23. s = s + np.sin(xx[i, j - 1]) * (np.sin(j * xx[i, j - 1] ** 2 / np.pi)) ** (2 * mm)
  24. outputs[i, 0] = -s
  25. return outputs
  26. list1 = genetic_algorithm(P, nd, lb, ub, michalewicz, Generation)
  27. list2 = range(0, Generation)
  28. end = time.perf_counter()
  29. print('Process time is {}'.format(end-start))
  30. plt.plot(list2, list1, label="graph", color="red")
  31. plt.semilogx()
  32. plt.xlabel("GENERATİON", color="blue")
  33. plt.ylabel("OBJECTİVE VALUES", color="blue")
  34. plt.legend()
  35. plt.show()

Exampes also avaliable in the given codes. Hope this repository will be useful for those interested