当前位置: 首页 > news >正文

做网站怎么建立文件夹wordpress桌面宠物

做网站怎么建立文件夹,wordpress桌面宠物,中国建设银行北京分行官网站,广州网站推广找哪里发展历史和算法思想 模拟退火算法#xff08;Simulated Annealing, SA#xff09;是一种基于热力学原理的随机优化算法#xff0c;最早由 S. Kirkpatrick, C. D. Gelatt 和 M. P. Vecchi 于 1983 年提出。算法的灵感来自于固体物理学中的退火过程#xff1a;通过加热和缓慢… 发展历史和算法思想 模拟退火算法Simulated Annealing, SA是一种基于热力学原理的随机优化算法最早由 S. Kirkpatrick, C. D. Gelatt 和 M. P. Vecchi 于 1983 年提出。算法的灵感来自于固体物理学中的退火过程通过加热和缓慢冷却金属可以减少其结构中的缺陷使其达到低能量的稳定状态。 数学原理 模拟退火算法的核心思想是通过模拟退火过程来搜索最优解。在优化过程中算法允许在一定概率下接受较差的解以避免陷入局部最优解。该概率由以下公式给出 其中 是当前解的能量目标函数值。 是新解的能量。 是当前温度。 是指数函数。 当温度逐渐降低时算法更倾向于接受更优的解。通过适当的降温策略算法可以逐步逼近全局最优解。 主要步骤 初始化设定初始温度 和初始解 。 邻域搜索从当前解 的邻域中随机选择一个新解 。 能量差计算计算当前解和新解的能量差 。 接受准则如果 则接受新解否则以概率 接受新解。 降温逐渐降低温度 。 重复步骤 2-5直到达到停止条件如温度过低或迭代次数达到上限。 应用场景 模拟退火算法适用于求解各种组合优化问题和连续优化问题主要包括但不限于 旅行商问题TSP 背包问题 车辆路径问题 图着色问题 生产调度问题 函数优化 可视化Python示例 以下是一个使用模拟退火算法解决旅行商问题TSP的Python可视化示例 import numpy as np import matplotlib.pyplot as plt# 计算路径长度 def path_length(path, distance_matrix):return sum(distance_matrix[path[i], path[i1]] for i in range(len(path)-1))  distance_matrix[path[-1], path[0]]# 模拟退火算法 def simulated_annealing_tsp(distance_matrix, n_iterations, temp, cooling_rate):num_cities  len(distance_matrix)best_path  np.arange(num_cities)np.random.shuffle(best_path)best_eval  path_length(best_path, distance_matrix)curr_path, curr_eval  best_path.copy(), best_evalscores  [best_eval]for i in range(n_iterations):candidate_path  curr_path.copy()l, r  np.random.randint(0, num_cities, size2)if l  r:l, r  r, lcandidate_path[l:r1]  np.flip(candidate_path[l:r1])candidate_eval  path_length(candidate_path, distance_matrix)if candidate_eval  best_eval:best_path, best_eval  candidate_path.copy(), candidate_evalscores.append(best_eval)print(fIteration {i}, Best Score: {best_eval})diff  candidate_eval - curr_evalt  temp / float(i  1)metropolis  np.exp(-diff / t)if diff  0 or np.random.rand()  metropolis:curr_path, curr_eval  candidate_path.copy(), candidate_evaltemp * cooling_ratereturn best_path, best_eval, scores# 参数设置 num_cities  20 n_iterations  1000 temp  100 cooling_rate  0.995# 生成随机城市坐标 coords  np.random.rand(num_cities, 2) distance_matrix  np.linalg.norm(coords[:, np.newaxis] - coords[np.newaxis, :], axis2)# 运行模拟退火算法 best_path, best_eval, scores  simulated_annealing_tsp(distance_matrix, n_iterations, temp, cooling_rate) print(fBest Path: {best_path}, Best Path Length: {best_eval})# 可视化 plt.figure() plt.subplot(2, 1, 1) plt.scatter(coords[:, 0], coords[:, 1], cred) for i in range(num_cities):plt.annotate(str(i), (coords[i, 0], coords[i, 1])) for i in range(num_cities):plt.plot([coords[best_path[i], 0], coords[best_path[(i  1) % num_cities], 0]],[coords[best_path[i], 1], coords[best_path[(i  1) % num_cities], 1]], b-) plt.title(Best Path)plt.subplot(2, 1, 2) plt.plot(scores, labelBest Path Length) plt.xlabel(Iteration) plt.ylabel(Path Length) plt.legend()plt.tight_layout() plt.show() 输出: ... Iteration 896, Best Score: 4.171655916012842 Iteration 993, Best Score: 4.137952785183053 Best Path: [ 0 13 12 18  8 14  5 11 16  7 10  2  3 15 19  4  6  9 17  1], Best Path Length: 4.137952785183053可视化结果 代码说明 计算路径长度函数计算给定路径的总长度。 模拟退火算法 初始化当前路径、最佳路径及其评价值。 在每次迭代中从当前路径的邻域中随机选择一个新路径。 通过反转路径段来生成邻域解。 计算新路径的长度并根据接受准则决定是否接受新路径。 逐步降低温度并记录最佳路径的长度。 参数设置设置城市数量、迭代次数、初始温度和降温率。 生成随机城市坐标生成随机城市坐标并计算距离矩阵。 运行算法调用模拟退火算法并输出最佳路径和最佳路径长度。 可视化绘制城市坐标图和优化过程中最佳路径长度的变化曲线。 以上内容总结自网络如有帮助欢迎转发我们下次再见
http://www.hkea.cn/news/14429302/

相关文章:

  • 南京网站建设要多少钱wordpress挖
  • 网站建设培训个人4.请简述网站建设流程的过程
  • 东莞市研发网站建设品牌wordpress自动加文章tittle
  • 做药的常用网站商标设计费用一般是多少
  • 安顺做网站的公司手机能创建网站吗
  • 网站优化哪家公司好兴义市住房和城乡建设局网站
  • 企业做网站需要提供什么资料家居企业网站建设流程
  • 织梦网站手机页怎么做多功能响应式wordpress主题
  • 衡水专业制作网站网站子网页怎么做
  • 找公司做网站有什么好处在360网站做公告怎么弄
  • 企业制作网站公司如何进行网站域名解析
  • 网站开发案例详解pdf公司seo营销
  • 旅游网站制作百度云番禺网站建设效果
  • 国外网站平台海珠区pc端网站建设
  • 网站建设的意义和作用wordpress 显示微博
  • 哪个网站做美食自媒体更好免费的韩国网站服务器
  • 部队网站建设招标专门做推广的软文
  • 国外网站无法访问优化大师下载安装app
  • 素材网站官网广告公司网站官网
  • 广州17网站一起做网店哈尔滨网站建设企业
  • 专做自驾游的网站wordpress新增页面
  • 网站收录了怎么做排名平面设计培训班学费一般多少钱
  • 丰涵网站建设科技wordpress为什么打开商城非常慢
  • 上海 企矩 网站建设民勤县建设局网站
  • 做网站宝安图怪兽海报制作官网
  • 网站备案期间可以建站给别人做的网站要复杂做安全扫描
  • 网站怎么推广运营广东省建设安全协会网站
  • 经验范围 网站建设怎么做网站首页关键词
  • 珠宝网站建设方案网站建设单选
  • 上海网站建设服务站霸网络上海建网站服务器