资源简介
蚁群、粒子群、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个文件信息
相关资源
- 基于LMS算法的均衡器MATLAB实现代码
- matlab关于商场人数的泊松随机过程仿
- 脉冲编码调制PCM调制与解调
- 64QAM调制解调
- matlab遗传算法程序以求解函数的极值
- 毕业论文 基于matlab的PSK通信系统仿真
- matlab 代码实现 信号 数字 变频
- KUKA六关节机器人matlab仿真
- hurst指数的MATLAB实现
- PSO-RBF的MATLAB程序实现
- 商人过河MATLAB.rar
- MatlabR2017aWin64Crack.rar
- Student_5_BDS_Positioning.m
- IEEE-6 14 30节点系统 MATLAB 潮流计算
- 飞行器六自由度建模 线性化 matlab程序
-
三相电压不平衡度计算 simuli
nk模型 - PMSM矢量控制
- xPC target
- MATLAB与DSP进行UDP通信的简单程序
- 内点法最优潮流MATLAB算法
- Logistic曲线的三种参数估计方法及ma
- TDOA等无线定位算法大全
- 内点法测试程序—matlab
- 智能优化算法及其MATLAB
- 4QAM调制的OFDM程序matlab的
- 基于matlab的数字电子琴的完全指导手
- l1-Magic工具箱
- hough变换matlab程序
- 高斯混合模型GMM 及高斯混合回归MAT
-
风力发电机整体MATLABSIMUli
nk建模
评论
共有 条评论