✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
为了解决现有冷热电联供型综合能源系统大多只单一考虑系统机组投资成本或系统环境污染,影响系统整体优化运行的问题,以系统经济性和环保性为目标,对冷热电联供系统进行研究分析。构建含燃气轮机、燃气锅炉、电制冷机等机组 的冷热电联供系统优化模型并建立约束条件。结果表明粒子群算法能够同时兼顾系统的经济性和环保性,使系统运行更加优化,为之后的能源供给系统的规划提供前期依据。
⛄ 部分代码
classdef Repository
properties
swarm
rep_size
Grid
grid_size
alpha
beta
gamma
end
methods
function obj = Repository(swarm,rep_size,grid_size,alpha,beta,gamma)
if nargin>0
obj.rep_size = rep_size;
swarm = Particle.updateDomination(swarm);
obj.swarm = swarm(~[swarm.isDominated]);
obj.grid_size=grid_size;
obj.alpha=alpha;
obj.beta = beta;
obj.gamma = gamma;
obj.Grid=obj.grid();
for i = 1:length(obj.swarm)
obj.swarm(i) = obj.swarm(i).updateGridIndex(obj.Grid);
end
end
end
function Grid = grid(obj)
C = vertcat(obj.swarm.cost);
cmin = min(C,[],1);
cmax = max(C,[],1);
dc = cmax - cmin;
cmin = cmin - obj.alpha * dc;
cmax = cmax + obj.alpha * dc;
nObj = size(C,2);
empty_grid.LB = [];
empty_grid.UB = [];
Grid = repmat(empty_grid,nObj,1);
for j = 1:nObj
cj = linspace(cmin(j),cmax(j),obj.grid_size+1);
Grid(j).LB = [-inf, cj];
Grid(j).UB = [cj, +inf];
end
end
function leader = SelectLeader(obj)
GI = [obj.swarm.GridIndex];
OC = unique(GI);
N = zeros(size(OC));
for k = 1:length(OC)
N(k) = length(find(GI==OC(k)));
end
P = exp(-obj.beta*N);
P = P/sum(P);
sci = Repository.RouletteWheelSelection(P);
sc = OC(sci);
SCM = find(GI==sc);
smi = randi([1 length(SCM)]);
sm = SCM(smi);
leader = obj.swarm(sm);
end
function obj = DeleteOneRepMemebr(obj)
GI=[obj.swarm.GridIndex];
OC=unique(GI);
N=zeros(size(OC));
for k=1:length(OC)
N(k)=length(find(GI==OC(k)));
end
P=exp(obj.gamma*N);
P=P/sum(P);
sci=Repository.RouletteWheelSelection(P);
sc=OC(sci);
SCM=find(GI==sc);
smi=randi([1 length(SCM)]);
sm=SCM(smi);
obj.swarm(sm)=[];
end
function obj = update(obj,swarm)
swarm = Particle.updateDomination(swarm);
obj.swarm = [obj.swarm,swarm(~[swarm.isDominated])];
obj.swarm = Particle.updateDomination(obj.swarm);
obj.swarm = obj.swarm(~[obj.swarm.isDominated]);
obj.Grid=obj.grid();
for i = 1:length(obj.swarm)
obj.swarm(i) = obj.swarm(i).updateGridIndex(obj.Grid);
end
Extra=length(obj.swarm)-obj.rep_size;
for e=1:Extra
obj=obj.DeleteOneRepMemebr();
end
end
end
methods (Static)
function i = RouletteWheelSelection(P)
i = find(rand<=cumsum(P),1,'first');
end
end
end
⛄ 运行结果
⛄ 参考文献
[1]李海平, 齐卓砾, 胡君朋. 基于FFT-DBN的行星齿轮箱齿面磨损故障智能判定方法研究[J]. 测控技术, 2020, 39(12):6.