资源简介
蚁群、粒子群、GA、TS等算法解决Job shop问题matlab源码(附test文件)

代码片段和文件信息
% Ant Colony Opimization - Ant Colony System for Hybird Job Shop Sceduling
% Problem.
function [costs bestSol] = ACO(jobs m n ants iterations ...
rzero costFunc)
costEnd = 0;
costs = [];
bestSol = ones(1 n);
bestSolCost = costFunc(bestSol jobs m n);
phermone = ones(n m*m); % track phermone value on each path.
for i = 1:iterations
antPaths = []; % stores all antPaths
for a = 1:ants;
antPath = []; % current ants path
for l = 1:n % going down n layers in total
phermoneToNextLevel = [];
if l == 1 % layer 1 to n mapping
for j = 1:m
phermoneToNextLevel(j) = phermone(1 j);
end
else % rest layers are n to n mapping
lastNode = antPath(l-1);
phermoneRow = l;
phermoneColS = (lastNode - 1) * m + 1;
phermoneColF = lastNode * m;
phermoneToNextLevel = phermone(phermoneRow ...
phermoneColS:phermoneColF);
end
randVal = rand(1);
weights = phermoneToNextLevel;
testPath = antPath; % copy current ant path to calculate distance
for mi = 1:m
testPath(l) = mi;
% Construct a matrix to memorize this for better performance
distance = costFunc(testPath jobs m l) - costFunc(antPath ...
jobs m l-1);
weights(mi) = weights(mi) / (distance+1);
end
totalWeight = sum(weights);
weightAcc = 0;
nextIndex = 0;
if rand(1) < rzero % experience vs exploration
nextIndexs = find(weights == max(weights));
nextIndex = nextIndexs(randi(numel(nextIndexs)));
else
while randVal > (weightAcc / totalWeight)
nextIndex = nextIndex + 1;
weightAcc = weightAcc + weights(nextIndex);
end
end
antPath(l) = nextIndex;
end
antPaths(a :) = antPath;
end
antCosts = [];
% Find costs for all ant paths. Consider to use a vectoralization
% version of cost function for this process in matlab.
for a = 1:ants
antCosts(a) = costFunc(antPaths(a:) jobs m n);
end
bestAntCost = min(antCosts);
worstAntCost = max(antCosts);
bestAntPaths = antPaths(find(antCosts==bestAntCost) :);
% Update phermone
phermone = phermone .* 0.4;
if bestAntCost <= bestSolCost
% ONLY THE GLOBAL BEST ALLOW TO UPDATE
deltaPhermone = 1 / bestAntCost;
for s = 1:size(bestAntPaths 1)
bestAntPath = bestAntPaths(s:);
for ji = 1:n
pcol = 0;
if ji == 1 % first job
pcol = bestAntPath(ji);
else
lastNode = bestAntPath(ji - 1);
pcol = (lastNode - 1) * m + bestAntPath(ji);
end
phermone(ji pcol) = phermone(ji pcol) + deltaPhermone;
end
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-07-30 00:05 animated-archer-master\
文件 33 2014-07-30 00:05 animated-archer-master\.gitignore
文件 3190 2014-07-30 00:05 animated-archer-master\ACO.m
文件 378 2014-07-30 00:05 animated-archer-master\ACO_16t6m_test.m
文件 384 2014-07-30 00:05 animated-archer-master\ACO_17t5m_test.m
文件 391 2014-07-30 00:05 animated-archer-master\ACO_test.m
文件 575 2014-07-30 00:05 animated-archer-master\ALL_test_16t6m.m
文件 575 2014-07-30 00:05 animated-archer-master\ALL_test_17t5m.m
文件 5440 2014-07-30 00:05 animated-archer-master\GA.m
文件 344 2014-07-30 00:05 animated-archer-master\GA_16t6m_test.m
文件 348 2014-07-30 00:05 animated-archer-master\GA_17t5m_test.m
文件 352 2014-07-30 00:05 animated-archer-master\GA_test.m
文件 1383 2014-07-30 00:05 animated-archer-master\PSO.m
文件 367 2014-07-30 00:05 animated-archer-master\PSO_16t6m_test.m
文件 371 2014-07-30 00:05 animated-archer-master\PSO_17t5m_test.m
文件 2122 2014-07-30 00:05 animated-archer-master\PSO_lbest.m
文件 380 2014-07-30 00:05 animated-archer-master\PSO_test.m
文件 24316 2014-07-30 00:05 animated-archer-master\README.html
文件 9780 2014-07-30 00:05 animated-archer-master\README.org
文件 1539 2014-07-30 00:05 animated-archer-master\SA.m
文件 522 2014-07-30 00:05 animated-archer-master\SA_16t6m_test.m
文件 527 2014-07-30 00:05 animated-archer-master\SA_17t5m_test.m
文件 547 2014-07-30 00:05 animated-archer-master\SA_test.m
文件 957 2014-07-30 00:05 animated-archer-master\TS.m
文件 374 2014-07-30 00:05 animated-archer-master\TS_16t6m_test.m
文件 380 2014-07-30 00:05 animated-archer-master\TS_17t5m_test.m
文件 760 2014-07-30 00:05 animated-archer-master\TS_readme.txt
文件 384 2014-07-30 00:05 animated-archer-master\TS_test.m
文件 230 2014-07-30 00:05 animated-archer-master\cost.m
文件 215 2014-07-30 00:05 animated-archer-master\cost_test.m
文件 206 2014-07-30 00:05 animated-archer-master\findStartTemp.m
............此处省略16个文件信息
相关资源
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
评论
共有 条评论