zl程序教程

您现在的位置是:首页 >  后端

当前栏目

基于蜜蜂算法的资源受限项目优化调度(Matlab代码实现)

MATLAB资源算法项目代码 实现 基于 优化
2023-09-14 09:05:21 时间

💥💥💥💞💞💞欢迎来到本博客❤️❤️❤️💥💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

👨‍💻4 Matlab代码实现

💥1 概述

     资源受限项目调度问题(Resource-constrained Project Scheduling Problem,RCPSP)是项目管理领域的一类重要问题,是指在满足项目资源约束以及活动时序约束的条件下,通过合理分配资源,为项目中的每一个活动安排起始时间,从而实现项目管理目标的最优化。RCPSP问题广泛存在于各个生产领域,对于企业缩短项目工期、降低生产成本具有重要的经济意义同时对于社会节约资源、减少浪费具有显著的生态意义。此外,RCPSP在理论上属于组合优化问题,具有NP-hard性为求解该问题学者进行了大量的研究,主要提出精确算法和启发式算法两类方法但现有求解方法和实际应用之间仍然有较大差距。因此,本文研究资源受限项目调度问题具有重要的理论价值和实际意义。

📚2 运行结果

部分代码:

clc;
clear;
close all;
global NFE;
NFE=0;

%% Problem 
model=CreateModel2();
CostFunction=@(x) MyCost(x,model);        % Cost Function
nVar=model.N;             % Number of Decision Variables
VarSize=[1 nVar];   % Size of Decision Variables Matrix
VarMin=0;         % Lower Bound of Variables
VarMax=1;         % Upper Bound of Variables

%% DE Parameters
MaxIt = 100;      % Maximum Number of Iterations
nPop = 20;        % Population Size
beta_min = 0.2;   % Lower Bound of Scaling Factor
beta_max = 0.8;   % Upper Bound of Scaling Factor
pCR = 0.2;        % Crossover Probability

%% Start
empty_individual.Position = [];
empty_individual.Cost = [];
empty_individual.Sol = [];
BestSol.Cost = inf;
pop = repmat(empty_individual, nPop, 1);
for i = 1:nPop
pop(i).Position = unifrnd(VarMin, VarMax, VarSize);
[pop(i).Cost pop(i).Sol] = CostFunction(pop(i).Position);
if pop(i).Cost<BestSol.Cost
BestSol = pop(i);
end
end
BestCost = zeros(MaxIt, 1);

%% DE
for it = 1:MaxIt
for i = 1:nPop
x = pop(i).Position;
A = randperm(nPop);
A(A == i) = [];
a = A(1);
b = A(2);
c = A(3);

% Mutation
%beta = unifrnd(beta_min, beta_max);
beta = unifrnd(beta_min, beta_max, VarSize);
y = pop(a).Position+beta.*(pop(b).Position-pop(c).Position);
y = max(y, VarMin);
y = min(y, VarMax);
% Crossover
z = zeros(size(x));
j0 = randi([1 numel(x)]);
for j = 1:numel(x)
if j == j0 || rand <= pCR
z(j) = y(j);
else
z(j) = x(j);
end
end
NewSol.Position = z;
[NewSol.Cost NewSol.Sol] = CostFunction(NewSol.Position);
if NewSol.Cost<pop(i).Cost
pop(i) = NewSol;
if pop(i).Cost<BestSol.Cost
BestSol = pop(i);
end
end
end
% Update Best Cost
BestCost(it) = BestSol.Cost;
nfe(it)=NFE;
% Show Iteration Information
disp(['Iteration ' num2str(it) ': DE Best Cost = ' num2str(BestCost(it))]);
end

🎉3 参考文献

[1]刘燕. 基于改进遗传算法的资源受限项目调度优化研究[D].南京财经大学,2019.DOI:10.27705/d.cnki.gnjcj.2019.000090.

👨‍💻4 Matlab代码实现