云制造网站,自己如何免费制作一个网站,长尾词seo排名优化,网页网站建设的步骤流程图前言#xff1a;我又从仓库里面翻出来了2020年写的一篇博文#xff0c;作为我无知青葱岁月的留影。
粒子群算法求解多配送中心的车辆调度优化问题#xff08;python3#xff09;
紧接上一篇文章《遗传粒子群 求解多配送中心车辆调度问题#xff08;python#xff09;》…前言我又从仓库里面翻出来了2020年写的一篇博文作为我无知青葱岁月的留影。
粒子群算法求解多配送中心的车辆调度优化问题python3
紧接上一篇文章《遗传粒子群 求解多配送中心车辆调度问题python》考虑采用多线程的方式封装粒子群算法加快算法的整体求解速度。
1.代码实现
def get_lower_solution(location_index):location_customer_list allocation_customer(location_index)ind_routes []ind_value 0thread_list []for i in range(len(location_index)):supply_index location_index[i]demand_nodes location_customer_list[i]demand_nodes [i 1 for i in demand_nodes] # 需求节点的编号从1开始demand_node_num len(demand_nodes)# 采用粒子群算法针对需求节点的索引进行计算下层模型的成本pso_parameter_dict[dim] pso_parameter_dict[solution_layer] * demand_node_num # 一个粒子的维度pso_parameter_dict[x_bound] [[1, data_dict[vehicle_num]], [1, demand_node_num]] # 自变量的上下限限制distance_graph, pathTime_graph get_pathLen_time(supply_index)# 初始化粒子群类pso pso_operation(pso_parameter_dict, data_dict,demand_nodes, distance_graph, pathTime_graph, )thread_list.append(pso)for ind_thread in thread_list:ind_thread.start()for ind_thread in thread_list:ind_thread.join()best_routes, best_value ind_thread.get_result()ind_routes best_routesind_value best_valuereturn ind_routes, ind_value2.效能比较
感觉并没有快为了防止粒子群算法封装的类函数的属性被修改所以采用了锁的机制。
3.小结
参考文章 1.python队列基本使用https://www.cnblogs.com/yhleng/p/9493457.html 2.Python建立多线程任务并获取每个线程返回值https://www.cnblogs.com/bethansy/p/7965820.html 3.Python—线程的锁https://blog.csdn.net/weixin_41678001/article/details/84487536 4.Python threading(多线程https://www.cnblogs.com/leozhanggg/p/10317494.html 5.Python中的多线程 https://baijiahao.baidu.com/s?id1637308955850713833wfrspiderforpc 6.Python多线程与队列https://www.cnblogs.com/yonguo123/p/11901050.html 7.Python多线程——队列Queuehttps://www.jianshu.com/p/e30d302ebdeb 8.python 实现多线程并返回函数返回值的三种方法https://blog.csdn.net/qq_43178297/article/details/102805223 9.Python3用多线程替代for循环提升程序运行速度 https://www.cnblogs.com/LanTianYou/p/11498525.html 10.[Python技巧]如何加快循环操作和Numpy数组运算速度 https://blog.csdn.net/lc013/article/details/100033413 11.多线程https://www.liaoxuefeng.com/wiki/897692888725344/923056337842176