empty_particle.position=[];
empty_particle.velocity=[];
empty_particle.cost=[];
empty_particle.best.position=[];
empty_particle.best.cost=[];
%---------
particle=repmat(empty_particle,NPOP,1);
globalbest.cost=inf;
globalbest.position=[];
%rnwfct_best=inf;
for i=1:NPOP
cc=1;%a value for cost
ww=0.3;% a value for lose of load probability%
kkk=2;%renewable energy factor%
ff=0;
%C=0.9;%price of electricity
%W=0.2;%lose of load probability%
%K=0.99;%renewable energy factor%
while ww>=W | kkk>=K% LOLP/REfactor
particle(i).position(1,:)=unifrnd(0,45,1,nvars);%pv kW
particle(i).position(2,:)=unifrnd(0,8,1,nvars);%autonomy days
particle(i).position(3,:)=unifrnd(1,20,1,nvars);%number of houses
particle(i).position(4,:)=unifrnd(0,10,1,nvars);%number of wind turbine
for g=1:4
particle(i).velocity(g,:)=rand(1,nvars);
end
%----convert------------
p_npv=particle(i).position(1);
ad=particle(i).position(2);
houses=round(particle(i).position(3));
nwt=round(particle(i).position(4));
%-----------------------
[LPSP,price_electricity,renewable_factor,b,ali]=techno_economic_analysis_pso(houses,p_npv,ad,nwt);
ff=ff+1;
ww(i)=LPSP;
kkk(i)=renewable_factor;
end
particle(i).cost=price_electricity;
particle(i).best.position=particle(i).position;
particle(i).best.cost=particle(i).cost;
if particle(i).best.cost<globalbest.cost
globalbest=particle(i).best;
end
end
Fminn=zeros(max_it,1);
%% PSO main loop
% disp(‘Iteration Reliability’);
% disp(’-----------------------------’);
for u=1:max_it
vv=0;
for i=1:NPOP
cc=1;%a value for cost
LPSP=0.3;% a value for lose of load probability%
renewable_factor=2;%
bb=0;
%C=0.9;%price of electricity
%W=0.2;%lose of load probability%
%K=0.99;%renewable energy factor%
% ww=0.3100;% a value for lose of load probability%
% kkk=2100;%renewable energy factor%
while (LPSP)>=W | (renewable_factor)>=K
for y=1:4
particle(i).velocity(y,:)=w1*particle(i).velocity(y,:)+c1*rand*...
(particle(i).best.position(y,:)-particle(i).position(y,:))...
+c2*rand*(globalbest.position(y,:)-particle(i).position(y,:));
%particle(i).velocity(y,:)=min(max(particle(i).velocity(y,:),-velmax),velmax);
particle(i).position(y,:)=particle(i).position(y,:)+particle(i).velocity(y,:);
% flag=(particle(i).position(kk,:)<LB(kk) | particle(i).position(kk,:)>UB(kk));
% particle(i).velocity(flag)=-particle(i).velocity(flag);
particle(i).position(y,:)=min(max(particle(i).position(y,:),LB(y)),UB(y));
end
%p_npv(i,:)=round(particle(i).position(1,:));
oo=0;
%ad(i,:)=round(particle(i).position(2,:));
p_npv=round(particle(i).position(1));
ad=round(particle(i).position(2));
houses=round(particle(i).position(3));
nwt=round(particle(i).position(4));
%[cc ww]=constraints(c,w,nnn(i,:),zz(i,:),zmax,nmax,N);
[LPSP,price_electricity,renewable_factor,b,ali]=techno_economic_analysis_pso(houses,p_npv,ad,nwt);
bb=bb+1;
end
%----convert------------
% az(i,:)=round(particle(i).position(1,:));
% z(i,:)=round(particle(i).position(2,:));
% n(i,:)=round(particle(i).position(3,:));
% sol(i).pos(1,:)=round(particle(i).position(1,:));
% sol(i).pos(2,:)=round(particle(i).position(2,:));
% sol(i).pos(3,:)=round(particle(i).position(3,:));
%-----------------------
%[LPSP,price_electricity,renewable_factor]=techno_economic_analysis_pso(houses,p_npv,ad,nwt);
particle(i).cost=price_electricity;
%rnwfct=renewable_factor;
%particle(i).cost=objective_function(sol(i).pos);
vv=vv+1;
if particle(i).cost<particle(i).best.cost
particle(i).best.cost=particle(i).cost;
particle(i).best.position=particle(i).position;
if particle(i).best.cost<globalbest.cost%& rnwfct<rnwfct_best
globalbest=particle(i).best;
% rnwfct_best=rnwfct;
end
end
end
Fminn(u)=globalbest.cost;
Xmin=globalbest.position;
p_npv=round(globalbest.position(1));
ad=round(globalbest.position(2));
houses=round(globalbest.position(3));
nwt=round(globalbest.position(4));
% w=wdamp*w;
% disp(['Iteration ‘,num2str(u),’: Best cost= ',num2str(Fminn(u))]);
end`end`@TOC
欢迎使用Markdown编辑器
你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。
新的改变
我们对Markdown编辑器进行了一些功能拓展与语法支持,除了标准的Markdown编辑器功能,我们增加了如下几点新功能,帮助你用它写博客:
- 全新的界面设计 ,将会带来全新的写作体验;
- 在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样式 进行展示;
- 增加了 图片拖拽 功能,你可以将本地的图片直接拖拽到编辑区域直接展示;
- 全新的 KaTeX数学公式 语法;
- 增加了支持甘特图的mermaid语法1 功能;
- 增加了 多屏幕编辑 Markdown文章功能;
- 增加了 焦点写作模式、预览模式、简洁写作模式、左右区域同步滚轮设置 等功能,功能按钮位于编辑区域与预览区域中间;
- 增加了 检查列表 功能。
功能快捷键
撤销:Ctrl/Command + Z
重做:Ctrl/Command + Y
加粗:Ctrl/Command + B
斜体:Ctrl/Command + I
标题:Ctrl/Command + Shift + H
无序列表:Ctrl/Command + Shift + U
有序列表:Ctrl/Command + Shift + O
检查列表:Ctrl/Command + Shift + C
插入代码:Ctrl/Command + Shift + K
插入链接:Ctrl/Command + Shift + L
插入图片:Ctrl/Command + Shift + G
查找:Ctrl/Command + F
替换:Ctrl/Command + G
合理的创建标题,有助于目录的生成
直接输入1次#,并按下space后,将生成1级标题。
输入2次#,并按下space后,将生成2级标题。
以此类推,我们支持6级标题。有助于使用TOC
语法后生成一个完美的目录。
如何改变文本的样式
强调文本 强调文本
加粗文本 加粗文本
标记文本<