✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
车间作业调度问题(Job Shop Scheduling Problem, JSSP)是现代生产制造系统中一个广受关注的典型生产线调度问题.由于车间作业调度具有工艺路径约束和资源(机器)独占性约束,使其成为了一个NP难问题.本文研究了基于和声搜索算法及其在解决车间作业调度问题中的应用.
⛄ 部分代码
%% Harmony Search Parallel Machine Scheduling (HS-PMS)
clc;
clear;
close all;
global NFE;
NFE=0;
%% Problem Definition
model=CreateModel(); % Create Model of the Problem
CostFunction=@(x) MyCost(x,model); % Cost Function
nVar=model.nVar; % Number of Decision Variables
VarSize=[1 nVar]; % Size of Decision Variables Matrix
VarMin = 0; % Lower Bound of Decision Variables
VarMax = 1; % Upper Bound of Decision Variables
%% Harmony Search Parameters
MaxIt = 100; % Maximum Number of Iterations
HMS = 20; % Harmony Memory Size
nNew = 20; % Number of New Harmonies
HMCR = 0.9; % Harmony Memory Consideration Rate
PAR = 0.1; % Pitch Adjustment Rate
FW = 0.02*(VarMax-VarMin); % Fret Width (Bandwidth)
FW_damp = 0.995; % Fret Width Damp Ratio
%% Start
% Empty Harmony Structure
empty_harmony.Position = [];
empty_harmony.Cost = [];
empty_harmony.Sol = [];
% Initialize Harmony Memory
HM = repmat(empty_harmony, HMS, 1);
% Create Initial Harmonies
for i = 1:HMS
HM(i).Position = unifrnd(VarMin, VarMax, VarSize);
[HM(i).Cost HM(i).Sol] = CostFunction(HM(i).Position);
end
% Sort Harmony Memory
[~, SortOrder] = sort([HM.Cost]);
HM = HM(SortOrder);
% Update Best Solution Ever Found
BestSol = HM(1);
% Array to Hold Best Cost Values
BestCost = zeros(MaxIt, 1);
%% Harmony Search Body
for it = 1:MaxIt
% Initialize Array for New Harmonies
NEW = repmat(empty_harmony, nNew, 1);
% Create New Harmonies
for k = 1:nNew
% Create New Harmony Position
NEW(k).Position = unifrnd(VarMin, VarMax, VarSize);
for j = 1:nVar
if rand <= HMCR
% Use Harmony Memory
i = randi([1 HMS]);
NEW(k).Position(j) = HM(i).Position(j);
end
% Pitch Adjustment
if rand <= PAR
%DELTA = FW*unifrnd(-1, +1); % Uniform
DELTA = FW*randn(); % Gaussian (Normal)
NEW(k).Position(j) = NEW(k).Position(j)+DELTA;
end
end
% Apply Variable Limits
NEW(k).Position = max(NEW(k).Position, VarMin);
NEW(k).Position = min(NEW(k).Position, VarMax);
% Evaluation
[NEW(k).Cost NEW(k).Sol] = CostFunction(NEW(k).Position);
end
% Merge Harmony Memory and New Harmonies
HM = [HM
NEW];
% Sort Harmony Memory
[~, SortOrder] = sort([HM.Cost]);
HM = HM(SortOrder);
% Truncate Extra Harmonies
HM = HM(1:HMS);
% Update Best Solution Ever Found
BestSol = HM(1);
% Store Best Cost Ever Found
BestCost(it) = BestSol.Cost;
% Store NFE
nfe(it)=NFE;
% Iteration
disp(['In Iteration ' num2str(it) ': NFE = ' num2str(nfe(it)) ', Cost is = ' num2str(BestCost(it))]);
% Plot Res
figure(1);
PlotSolution(BestSol.Sol,model);
end
%% Show Results
figure;
plot(nfe,BestCost,'-og','linewidth',1,'MarkerSize',7,'MarkerFaceColor',[0.9,0.1,0.1]);
title('Harmony Search','FontSize', 15,'FontWeight','bold');
xlabel(' NFE','FontSize', 15,'FontWeight','bold');
ylabel(' Cost Value','FontSize', 15,'FontWeight','bold');
xlim([0 inf])
xlim([0 inf])
ax = gca;
ax.FontSize = 15;
set(gca,'Color','b')
legend({'HS PMS'},'FontSize',12,'FontWeight','bold','TextColor','g');
⛄ 运行结果
⛄ 参考文献
[1] 韩玉艳. 阻塞流水车间的优化调度方法的研究[D]. 聊城大学.
[2] 朱航. 基于改进和声搜索算法的车间作业调度问题研究[D]. 南京理工大学, 2015.
[3] 沈桂芳, 李敬明, 陈平. 基于RUD的和声搜索算法求解作业车间调度问题[J]. 江苏师范大学学报:自然科学版, 2017, 35(4):4.
[4] 王艳, 吴龙成, 纪志成,等. 基于改进和声搜索算法的多目标硫化车间调度[J]. 系统仿真学报, 2018, 30(1):8.