# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import numpy as np
import matplotlib.pyplot as plt
# -----------define HJ agolrathiem para
delta = 0.5 # step size
alfa = 1 # speed rate
beta = 0.5 # decrease rate
epsilon = 0.002 # min stepsize
iniPO = np.array([6,1]) # initial point
G = 10 # 探测次数
# -----------define function
# min f(x):=(1−x1)^2+5(x2−x1^2)^2
def fun(A):
ff = (1 - A[0]) ** 2 + 5 * (A[1] - A[0] ** 2) ** 2
return ff
iniPO_ff = np.array([fun(iniPO)])
X = iniPO
X_ff = iniPO_ff
Y = X
Y_ff =X_ff
x = iniPO
y = iniPO
# -----------explore step
dim = iniPO.shape[0] # dimation
e = [1]*dim
E = np.diag(e)
k=0
while delta > epsilon:
for i in range(0,dim):
y_new_plus = y + delta * E[i,:]
ff = fun(y)
ff_new = np.array([fun(y_new_plus)])
temp = Y
tem
hooke jeeves算法(模式搜索法)
最新推荐文章于 2025-05-17 15:18:37 发布