代码拉取完成,页面将自动刷新
from numpy.core.fromnumeric import mean
from aoa import AOA
import rastrigin_problem
numOfObj = 20
maximumIteration = 10
C1 = 2
C2 = 6
C3 = 2 # coc engineering problem
C4 = 0.5 # coc engineering problem // sesuai dengan paper
# standar optimization problem for constants C3 and C4
# C3=1
# C4=2
function = rastrigin_problem.mainFunction
dim = rastrigin_problem.dimention
positionLimit = rastrigin_problem.limitInputs
limitFunction = rastrigin_problem.limitFunction
fitness = rastrigin_problem.fitness
lowerBound = positionLimit[0].lowerBound
upperBound = positionLimit[0].upperBound
solution, population = AOA(numOfObj,lowerBound,upperBound,maximumIteration,C3,C4, function, dim,positionLimit,limitFunction,fitness)
print(f"Restrigin Solution \nBestScore: {solution.score} \n x or position: {solution.position}\n")
# import math
# from numpy import random
# def rastrigin(x):
# temp = x**2
# nTemp = 10 - (10*math.cos(2*math.pi*x))
# return temp + nTemp
# X = Y = []
# for obyek in population :
# X += obyek.position
# for x in obyek.position:
# Y.append(rastrigin(x))
# print(f"len Y:{len(Y)}, lenX : {len(X)}")
# # normalisasi
# # for i in range(len(X)):
# # X[i] = (X[i] - mean(X))/(max(X) - min(X))
# # Y[i] = (Y[i] - mean(Y))/(max(Y) - min(Y))
# # for data in population:
# # print(data.position)
# # print("\n")
# import matplotlib.pyplot as plt
# # plt.scatter(X,Y)
# # plt.show()
# plt.scatter(X,Y)
# plt.plot(X,Y,"--")
# plt.show()
# plt.hist(Y)
# plt.show()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。