这里给出我的参考内容:
首先是清风的模拟退火
清风模拟退火
然后是学了matplotlib动图
matplotlib动图
下面上代码!
#本功能实现最小值的求解#
from matplotlib import pyplot as plt
import numpy as np
import random
import math
plt.ion()#这里需要把matplotlib改为交互状态
#初始值设定
hi=3
lo=-3
alf=0.95
T=100
#目标函数
def f(x):
return 11*np.sin(x)+7*np.cos(5*x)##注意这里要是np.sin
#可视化函数(开始清楚一次然后重复的画)
def visual(x)