├── Comprehensive.m ├── Elevation_data.xlsx ├── Elevation_map.m ├── README.md ├── SA.m ├── SA.pptx ├── ants.m ├── ants.pptx ├── ga.m ├── ga.pptx ├── gituse.txt ├── impGA.m ├── leader_follower.m ├── leader_follower.pdf ├── mydata.xlsx ├── normalGA.m ├── partially_binary.m ├── partially_binary.pdf ├── partially_binary.xlsx ├── plane ├── circledist.m ├── classification.m ├── data2.m ├── hangji.xlsx ├── hangji2.xlsx ├── pos.xlsx ├── q3test.m ├── question1.m ├── qufendian.m ├── qusetion3.m └── test.m ├── pso.m ├── pso.pptx ├── quality_threshold.m ├── rankGA.m ├── rank_base.m ├── robust_model ├── Attraction_obj.m ├── Main.m ├── Market_N.m ├── Qj_data.xls ├── SortA.m ├── Wi_data.xls ├── addlocation.m ├── addquality.m ├── addquality1.m ├── addquality3.m ├── al_q_level.m ├── cal_cost.m ├── crossover.m ├── del_E.m ├── dij_data.xls ├── fj_data.xlsx ├── greedy_init.m ├── init_Y.m ├── location_data.xlsx ├── min_market.m └── opt_2.m ├── tabu.m └── tabu.pptx /Comprehensive.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/Comprehensive.m -------------------------------------------------------------------------------- /Elevation_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/Elevation_data.xlsx -------------------------------------------------------------------------------- /Elevation_map.m: -------------------------------------------------------------------------------- 1 | height=xlsread('Elevation data.xlsx'); 2 | [X,Y]=meshgrid(0:38.2:2912*38.2,0:38.2:2774*38.2); 3 | % mesh(X,Y,height) 4 | pcolor(X,Y,height) 5 | shading interp; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Intelligent_Algorithm 2 | 用matlab解决路径规划和竞争设施选址问题 3 | 4 | 一、五个基础算法以及示例: 5 | 6 | ga 遗传算法解决分配问题 7 | 8 | 问题描述: 9 | 现有10个工人去做10件工作,每个工人完成每项工作所需时间不同。 10 | 要求每个工人只做一项工作,每项工作只由一个工人完成。 11 | 怎样指派工人完成工作可以使所用总时间最少? 12 | tabu 禁忌搜索算法解决解决商旅问题 13 | 14 | 问题描述: 15 | 某5个城市旅行商问题, 16 | 用禁忌搜索算法实使得旅行商走过所有城市后回到原点的总路径最小。 17 | 18 | ants 蚁群算法 19 | 20 | 问题描述: 21 | 设有19个客户随机分布于长为10km的正方形区域内。配送中心位于区域正中央,其坐标为(0,0)。 22 | 各客户的坐标及需求量如下表所示,配送中心拥有若干辆载重量为9t的车辆,对客户进行服务时都从配送中心出发, 23 | 完成对客户点的配送任务后再回到配送中心。现要求以最少的车辆数、最小的车辆总行程来完成货物的派送任务, 24 | 用蚁群算法求解该VRP问题(vehicle routing problem)。 25 | SA 模拟退火算法 26 | 27 | 问题描述: 28 | n 个工作将要指派给n 个工人分别完成,问如何安排可使总的工作时间达到最小 29 | PSO 粒子群算法 30 | 31 | 问题描述: 32 | 在一范围为(0,0)到(100,100)的矩形区域内,散布着40个连锁超市。要求在该矩形区域内确定9个位置建立配送中心。 33 | 已知各配送中心容量不限,每个超市只由一个配送中心负责配送,使得9个配送中心到所有超市的总配送物流量(距 34 | 离×需求量)最小,其中配送中心到超市的距离为直线距离。 35 | 36 | 二、竞争设施选址问题相关论文以及代码复现: 37 | 38 | 论文一: 39 | 40 | Qi M.Y., Xia M.F., Zhang Y., Miao L.X. Competitive facility location problem with foresight considering 41 | service distance limitations[J]. Computers & Industrial Engineering, 2017; 112:483-491. 42 | 43 | 在只有两个竞争设施的情况下,存在一个领导者和一个跟随者,领导者在潜在位点先放置设施,跟随者根据领导者的选 44 | 址情况选择新的设施点。在领导者知道追随者目标函数的情况下如何设置选址位点是论文研究的重点。 45 | 46 | 思路:采用了双层禁忌搜索算法,将追随者当前最优解放入领导者可交换的备选位点中,将领导者当前位点与备选位点邻 47 | 域交换,生成新解进行下一轮求解。 48 | 49 | 代码:leader_follower.m 50 | 51 | 算例:随机生成 52 | 53 | 论文二: 54 | 55 | Fernández P., Pelegrín B., Lančinskas A., Žilinskas J. New heuristic algorithms for discrete competitive 56 | location problems with binary and partially binary customer behavior[J]. Computers & Operations Research, 57 | 2017; 79: 12-18. 58 | 59 | 市场中已经存在两个以上的竞争公司,每个公司都有相应数量的现有设施,现在有一家新的公司要进入市场,如何选择新 60 | 设施位点使得新进入公司获得的市场份额最大是该论文研究的重点 61 | 62 | 思路:基于排名的离散优化算法 63 | 代码:partially_binary.m 64 | 算例:http://www.tageo.com/index-e-sp-cities-ES.htm 65 | 66 | 三、在已知高程数据的情况下画高程图: 67 | 68 | 代码:Elevation_map.m 69 | 70 | 高程数据:Elevation_data.xlsx -------------------------------------------------------------------------------- /SA.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/SA.m -------------------------------------------------------------------------------- /SA.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/SA.pptx -------------------------------------------------------------------------------- /ants.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/ants.m -------------------------------------------------------------------------------- /ants.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/ants.pptx -------------------------------------------------------------------------------- /ga.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/ga.m -------------------------------------------------------------------------------- /ga.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/ga.pptx -------------------------------------------------------------------------------- /gituse.txt: -------------------------------------------------------------------------------- 1 | git使用总结: 2 | 3 | vim模式可以在bach模式下更改文件内容(vim README.md) 4 | i插入,esc命令模式,:wq保存离开 5 | https://www.runoob.com/linux/linux-vim.html 6 | pwd查看当前在哪个文件夹下 7 | ls -a 查找当前文件夹下的文件(包括隐藏文件) 8 | ll 查看当前文件夹下的文件数量 9 | git status 查看当前状态 10 | git init 初始化仓库 11 | git add 将文件添加到暂存区 12 | git commit -m "提交备注" 13 | 14 | 若将修改提交到了暂存区但还未commit到最终仓库(暂存区到工作区回滚): 15 | git reset HEAD (文件名) 将暂存区的修改回归到工作区 16 | git checkout -- (文件名) 清理工作区 17 | 图形界面:直接从暂存区丢弃该文件 18 | 若修改已经commit: 19 | git log 查看日志,若日志太多无法结束时可以按q结束 20 | git reset --hard (log查看到的对应的commit_id) 暂存区和最终仓库中的文件都回滚到上一次需求 21 | 图形界面:重置分支到上一次提交,有未提交的更改出现在了工作区,丢弃工作区的文件 22 | 23 | 清空本地仓库: 24 | git rm (本地文件名) 清空工作区(此时暂存区和仓库还未清空) 25 | git commit -m “备注” 提交后才清空仓库 26 | 图形界面:工作区删除,删除动作出现在工作区中,从工作区添加到暂存区,再从暂存区进行最终的提交,这次提交后才会删除文件 27 | 28 | 创建SSH key: 29 | ssh-keygen -t rsa -C "xxx@xx.com" 注册github账号的邮箱 30 | 可默认通过回车进行后续的选择,passphrase可以不用输,若已有key可以直接输入y覆盖 31 | 在c/Users/用户名下面找到/.ssh文件夹 32 | 路径改到/.ssh文件夹下,输入cat id_rsa.pub回车得到SSH key,将该key复制到github中setting下的new SSH key中 33 | 输入ssh -T git@github.com可检查是否已经连通,遇到warning再连接一次应该就没问题了,出现hi 34 | 35 | 添加远程仓库: 36 | 命令行: 37 | 在github上新建一个仓库,可以直接复制里面提示的命令 38 | .... 39 | git remote add origin https://github.com/jullyjelly/first_try.git 40 | git push -u origin master 将本地的master与远程的master关联并推送 41 | 即可成功推上github 42 | 若再次提交可以直接git push,因为已经关联了 43 | 图形界面: 44 | 右键master,点击创建拉取请求,点击远程仓库中的添加,远端名称写origin, 45 | 路径从新建的远程仓库中复制过来,用户名是提交的用户名。若远程下面有一个origin则关联成功 46 | 右键master,选择推送到origin,直接默认推送即可无需设置 47 | 此时可能会出现推送失败的情况,工具->选项->一般->SSH客户端改成openSSH即可 48 | 49 | 50 | 把旧项目提交到Git上,但是会有一些历史记录,删除这些历史记录,形成一个全新的仓库,并且保持代码不变: 51 | git checkout --orphan latest_branch 52 | git add -A 53 | git commit -am "commit message" 54 | git branch -D master 55 | git branch -m master 56 | git push -f origin master 57 | https://segmentfault.com/a/1190000013082390 58 | 59 | github提交回退旧版本代码并更改后的文件到主分支上: 60 | git reset --hard (log查看到的对应的commit_id) 61 | git push origin master --force 强行覆盖远程记录 62 | https://segmentfault.com/q/1010000009800764/a-1020000009800939 63 | 64 | 克隆仓库: 65 | 命令模式: 66 | git clone git@github.com:jullyjelly/clone1.git(复制的地址) 67 | cd clone1并进行下一步操作(echo,git add,git commit) 68 | 可直接git push,因为已经进行了关联 69 | 克隆会新建一个远程仓库同名的文件夹,因此可以不用自己新建文件夹,可直接在有其他仓库的文件夹下操作 70 | 图形化界面: 71 | 需要新建一个文件夹 72 | 添加->克隆,复制SSH到源路径,设置目标路径即新建的文件夹 73 | 添加文件,然后自动建立了远程可以直接推送 74 | 75 | 标签管理: 76 | 77 | git tag 查看所有标签 78 | git tag (name 如v1.0.1) 创建标签 79 | git push origin (name 如v1.0.1) 标签发布,推送到远程 80 | 可在github文件上方的branch->tag来查看标签 81 | 其他命令: 82 | git tag -a (name)-m "comment备注" 83 | git tag -d name 删除标签 84 | 图形界面:工具栏上方点击标签,命名,选择指定的提交(commit id),勾选推送标签到origin即可推送到远程 85 | 右键标签,点击删除即可删除标签,在弹出的对话框中勾选删除远程就可以同时删除远程仓库中的标签了 86 | 87 | 分支管理: 88 | git branch (feat) 添加新分支 89 | git branch 查看当前branch 带绿色星号的即为当前branch 90 | git checkout (feat) 切换分支 91 | 在当前分支下进行操作 92 | 若需要分支合并:切换到要合并的分支下git checkout (master) 93 | git merge (feat) 将feat分支合并到master上 94 | git branch -d (feat) 删除分支 95 | 图形界面: 96 | 工具栏点击分支->新分支—>输入分支名->勾选工作副本原本 97 | 双击哪个分支即在哪个分支下操作 98 | 操作完以后,若需要合并,工具栏点击合并,点击指定的commit,左下角可点击立即合并提交 99 | 100 | 版本回退错误的解决: 101 | https://blog.csdn.net/themagickeyjianan/article/details/78923322 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /impGA.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/impGA.m -------------------------------------------------------------------------------- /leader_follower.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/leader_follower.m -------------------------------------------------------------------------------- /leader_follower.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/leader_follower.pdf -------------------------------------------------------------------------------- /mydata.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/mydata.xlsx -------------------------------------------------------------------------------- /normalGA.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/normalGA.m -------------------------------------------------------------------------------- /partially_binary.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/partially_binary.m -------------------------------------------------------------------------------- /partially_binary.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/partially_binary.pdf -------------------------------------------------------------------------------- /partially_binary.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/partially_binary.xlsx -------------------------------------------------------------------------------- /plane/circledist.m: -------------------------------------------------------------------------------- 1 | % close all;clear all;clc; 2 | % R=5;r=5; 3 | % syms u v; 4 | % ezmesh((R+r*cos(u))*cos(v),(R+r*cos(u))*sin(v),r*sin(u),[-pi,pi]); 5 | % hold on; 6 | % % ezmesh(r*cos(u)*cos(v),r*cos(u)*sin(v),r*sin(u),[-pi,pi]) 7 | % grid off 8 | % 9 | % axis equal; 10 | % axis([-20 20 -20 20 -30 30]); 11 | % line([20 0] ,[ 10 0],[ -30 0]); 12 | % hold on; 13 | % line([20 0] ,[ 10 0],[ 30 0]) 14 | % format long; 15 | % 16 | position=xlsread('hangji2.xlsx'); 17 | [m,~]=size(position); 18 | distance=zeros(m,m); 19 | for i=1:m 20 | for j=1:m 21 | distance(i,j) = sqrt((position(i,1)-position(j,1))^2+(position(i,2)-position(j,2))^2+(position(i,3)-position(j,3))^2); 22 | end 23 | end 24 | locpop=[ 1 25 | 151 26 | 115 27 | 235 28 | 129 29 | 228 30 | 310 31 | 306 32 | 124 33 | 232 34 | 161 35 | 93 36 | 94 37 | 62 38 | 293 39 | 327]; 40 | [x,~]=size(locpop); 41 | a=0; 42 | b=0; 43 | bpop=[]; 44 | for i=1:x-2 45 | A=position(locpop(i,1),1:3); 46 | B=position(locpop(i+1,1),1:3); 47 | C=position(locpop(i+2,1),1:3); 48 | AB=B-A; 49 | CA=A-C; 50 | d=AB(1,1)*CA(1,1)+AB(1,2)*CA(1,2)+AB(1,3)*CA(1,3); 51 | m=sqrt(AB(1,1)^2+AB(1,2)^2+AB(1,3)^2)*sqrt(CA(1,1)^2+CA(1,2)^2+CA(1,3)^2); 52 | cosn=d/m; 53 | angle=acos(cosn)*180/pi; 54 | dist=distance(locpop(i,1),locpop(i+1,1))-2*cosd(angle/2)*400+(1-angle/180)*400*pi; 55 | a=a+dist; 56 | rdist=dist-cosd(angle/2)*400+(1-angle/180)*200*pi 57 | b=b+rdist; 58 | bpop=[bpop;b]; 59 | end 60 | a=a+(1-angle/180)*200*pi+distance(locpop(x-1,1),locpop(x,1))-cosd(angle/2)*400; 61 | b=b+(1-angle/180)*200*pi+distance(locpop(x-1,1),locpop(x,1))-cosd(angle/2)*400; 62 | bpop=[bpop;b] -------------------------------------------------------------------------------- /plane/classification.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/plane/classification.m -------------------------------------------------------------------------------- /plane/data2.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/plane/data2.m -------------------------------------------------------------------------------- /plane/hangji.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/plane/hangji.xlsx -------------------------------------------------------------------------------- /plane/hangji2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/plane/hangji2.xlsx -------------------------------------------------------------------------------- /plane/pos.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/plane/pos.xlsx -------------------------------------------------------------------------------- /plane/q3test.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/plane/q3test.m -------------------------------------------------------------------------------- /plane/question1.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/plane/question1.m -------------------------------------------------------------------------------- /plane/qufendian.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/plane/qufendian.m -------------------------------------------------------------------------------- /plane/qusetion3.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/plane/qusetion3.m -------------------------------------------------------------------------------- /plane/test.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/plane/test.m -------------------------------------------------------------------------------- /pso.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/pso.m -------------------------------------------------------------------------------- /pso.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/pso.pptx -------------------------------------------------------------------------------- /quality_threshold.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/quality_threshold.m -------------------------------------------------------------------------------- /rankGA.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/rankGA.m -------------------------------------------------------------------------------- /rank_base.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/rank_base.m -------------------------------------------------------------------------------- /robust_model/Attraction_obj.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/Attraction_obj.m -------------------------------------------------------------------------------- /robust_model/Main.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/Main.m -------------------------------------------------------------------------------- /robust_model/Market_N.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/Market_N.m -------------------------------------------------------------------------------- /robust_model/Qj_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/Qj_data.xls -------------------------------------------------------------------------------- /robust_model/SortA.m: -------------------------------------------------------------------------------- 1 | function [QY,xstar]=SortA(ai,bi,lambda) 2 | % sorting-based algorithm to solve the linear programming: \min \sum (ai*bi*xi) s.t. \sum(bi*xi)>=lambda, 0\leq xi\leq 1. 3 | n=length(ai); 4 | xstar=zeros(1,n); 5 | [a,b]=sort(ai); 6 | a1=a; 7 | b1=bi(b); 8 | s=sum(a1<0); 9 | bcum=cumsum(b1); 10 | k=sum(bcum=k+1 13 | QY=sum(c(1:s)); 14 | xstar(1:s)=1; 15 | else 16 | QY=sum(c(1:k))+a(k+1)*(lambda-sum(b1(1:k))); 17 | xstar(1:k)=1; 18 | xstar(k+1)=(lambda-sum(b1(1:k)))/b1(k+1); 19 | end 20 | xstar(b)=xstar; 21 | end -------------------------------------------------------------------------------- /robust_model/Wi_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/Wi_data.xls -------------------------------------------------------------------------------- /robust_model/addlocation.m: -------------------------------------------------------------------------------- 1 | function [Y,oz_Y]=addlocation(rjk,Y,oz_Y) 2 | candi_rjk=rjk; 3 | [s,~]=size(Y); 4 | for i=1:s 5 | x=find(candi_rjk(:,3)==Y(i,2)); 6 | candi_rjk(x,:)=[]; 7 | end 8 | sum_rjk=candi_rjk; 9 | sum_rjk(:,1)=cumsum(candi_rjk(:,1)); 10 | [size_srjk,~]=size(sum_rjk); 11 | sum_rjk(:,1)=sum_rjk(:,1)./sum_rjk(size_srjk,1); 12 | sum_rjk=[0 0 0 0;sum_rjk]; 13 | lunpan=rand; 14 | for i=1:size_srjk 15 | if lunpan>=sum_rjk(i,1) && lunpan=1 4 | YN=Y;oz_YN=oz_Y; 5 | if sum(Y(:,3))maxQY 22 | maxQY=QY1; 23 | YN=Y1; 24 | oz_YN=oz_Y1; 25 | end 26 | end 27 | end 28 | else 29 | break; 30 | end 31 | Y=YN;oz_Y=oz_YN;QY=maxQY; 32 | end 33 | 34 | end 35 | -------------------------------------------------------------------------------- /robust_model/addquality1.m: -------------------------------------------------------------------------------- 1 | function [Y,oz_Y]=addquality1(G,Y,oz_Y,alpha,cost_jk,n_qlevel) 2 | [s,~]=size(Y); 3 | while floor((G-sum(oz_Y(:,2)))/(20*alpha))>=1 4 | if sum(Y(:,3))maxQY 22 | maxQY=QY1; 23 | YN=Y1; 24 | oz_YN=oz_Y1; 25 | end 26 | end 27 | end 28 | else 29 | break; 30 | end 31 | Y=YN;oz_Y=oz_YN;QY=maxQY; 32 | end 33 | 34 | end 35 | -------------------------------------------------------------------------------- /robust_model/al_q_level.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/al_q_level.m -------------------------------------------------------------------------------- /robust_model/cal_cost.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/cal_cost.m -------------------------------------------------------------------------------- /robust_model/crossover.m: -------------------------------------------------------------------------------- 1 | function [Y,oz_Y]=crossover(Y,oz_Y,rjk,G) 2 | 3 | [Y,oz_Y]=addlocation(rjk,Y,oz_Y); 4 | 5 | while sum(oz_Y(:,2))>G 6 | [s,~]=size(Y); 7 | cross_index=randsrc(1,1,(1:s)); 8 | [~,x,~]=intersect(oz_Y(:,3:4),Y(cross_index,2:3),"rows"); 9 | oz_Y(x,1:2)=0; 10 | Y(cross_index,:)=[]; 11 | end 12 | end 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /robust_model/del_E.m: -------------------------------------------------------------------------------- 1 | function cost_jk=del_E(n_qlevel,location_E,cost_jk_all) 2 | cost_jk=cost_jk_all; 3 | for i=1:1:n_qlevel 4 | x=find(cost_jk(:,n_qlevel+1)==location_E(i)); 5 | cost_jk(x,:)=[]; 6 | end 7 | end -------------------------------------------------------------------------------- /robust_model/dij_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/dij_data.xls -------------------------------------------------------------------------------- /robust_model/fj_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/fj_data.xlsx -------------------------------------------------------------------------------- /robust_model/greedy_init.m: -------------------------------------------------------------------------------- 1 | function [oz_Y,Y,QY]=greedy_init(m,num_E,location_E,dij,Rc,Rq,q_t,quality_N,Qj,Wi,gamma,n_qlevel,cost_jk,G) 2 | oz_Y=zeros((m-num_E)*n_qlevel,4); 3 | for i=1:(m-num_E) 4 | for j=1:n_qlevel 5 | oz_Y((i-1)*n_qlevel+j,3)=cost_jk(i,n_qlevel+1); 6 | oz_Y((i-1)*n_qlevel+j,4)=j; 7 | end 8 | end 9 | 10 | [sozY,~]=size(oz_Y); 11 | Y=[]; 12 | while sum(oz_Y(:,2))+min(min(cost_jk(:,1:5)))<=G 13 | if ~isempty(Y) 14 | [s,~]=size(Y); 15 | QY=min_market(m,num_E,location_E,s,dij,Rc,Rq,Y,q_t,quality_N,Qj,Wi,gamma); 16 | else 17 | QY=0; 18 | end 19 | 20 | b_dita=0; 21 | for i=1:sozY 22 | x=find(cost_jk(:,n_qlevel+1)==oz_Y(i,3)); 23 | if oz_Y(i,2)==0 & sum(oz_Y(:,2))+cost_jk(x,oz_Y(i,4))<=G 24 | st_oz_Y=oz_Y; 25 | st_oz_Y(i,2)=cost_jk(x,oz_Y(i,4));st_oz_Y(i,1)=1; 26 | y=find(st_oz_Y(:,2)>0); 27 | st_Y=st_oz_Y(y,2:4); 28 | [s,~]=size(st_Y); 29 | st_QY=min_market(m,num_E,location_E,s,dij,Rc,Rq,st_Y,q_t,quality_N,Qj,Wi,gamma); 30 | dita=(st_QY-QY)./cost_jk(x,oz_Y(i,4)); 31 | end 32 | if dita>b_dita 33 | b_dita=dita; 34 | b_Y=st_Y; 35 | b_oz_Y=st_oz_Y; 36 | b_QY=st_QY; 37 | end 38 | end 39 | oz_Y=b_oz_Y; 40 | Y=b_Y; 41 | QY=b_QY; 42 | end 43 | end -------------------------------------------------------------------------------- /robust_model/init_Y.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/init_Y.m -------------------------------------------------------------------------------- /robust_model/location_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/robust_model/location_data.xlsx -------------------------------------------------------------------------------- /robust_model/min_market.m: -------------------------------------------------------------------------------- 1 | function QY=min_market(m,num_E,location_E,num_N,dij,Rc,Rq,Y,q_t,quality_N,Qj,Wi,gamma) 2 | [ACY,AQY]=Attraction_obj(m,num_E,location_E,num_N,dij,Rc,Rq,Y,q_t,quality_N,Qj); 3 | ai=ACY-AQY; 4 | bi=Wi; 5 | lambda=gamma*sum(Wi); 6 | [QY1,xstar]=SortA(ai,bi,lambda); 7 | QY=QY1+sum(Wi.*AQY); 8 | end -------------------------------------------------------------------------------- /robust_model/opt_2.m: -------------------------------------------------------------------------------- 1 | function [YN,QY,oz_YN]=opt_2(m,num_E,location_E,dij,Rc,Rq,Y,q_t,quality_N,Qj,Wi,gamma,QY,cost_jk_all,oz_Y) 2 | len=size(Y,1); 3 | YN=Y; 4 | oz_YN=oz_Y; 5 | for i=1:len-1 6 | for j=i+1:len 7 | Y1=Y; 8 | oz_Y1=oz_Y; 9 | if Y(i,3)~=Y(j,3) 10 | Y1(i,3)=Y(j,3); 11 | Y1(j,3)=Y(i,3); 12 | [~,index,~]=intersect(oz_Y1(:,3:4),Y1(i,2:3),"rows"); 13 | Y1(i,1)=cost_jk_all(Y1(i,2),Y1(i,3)); 14 | oz_Y1(index,1)=1;oz_Y1(index,2)=Y1(i,1); 15 | 16 | [~,index,~]=intersect(oz_Y1(:,3:4),Y1(j,2:3),"rows"); 17 | Y1(j,1)=cost_jk_all(Y1(j,2),Y1(j,3)); 18 | oz_Y1(index,1)=1;oz_Y1(index,2)=Y1(j,1); 19 | QY1=min_market(m,num_E,location_E,len,dij,Rc,Rq,Y1,q_t,quality_N,Qj,Wi,gamma); 20 | else 21 | QY1=QY; 22 | end 23 | if QY1>QY 24 | QY=QY1; 25 | YN=Y1; 26 | oz_YN=oz_Y1; 27 | end 28 | end 29 | end 30 | end -------------------------------------------------------------------------------- /tabu.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/tabu.m -------------------------------------------------------------------------------- /tabu.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jullyjelly/Intelligent_Algorithm/e600f7a24fa1444b9827589400701e61ba48df12/tabu.pptx --------------------------------------------------------------------------------