How can I write an optimization problem and PSO code separately?
    조회 수: 6 (최근 30일)
  
       이전 댓글 표시
    
Hello
I am trying to write a code using the PSO algorithm to optimize the PV and battery system. So I was looking for an example code and there was one in Mathworks. But there is an optimization problem in it with PSO code. How can I write an optimization problem and PSO code separately? Please help me
Example code part of PSO:
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
Example code:
Techno-Economic Analysis of Hybrid Renewable Energy System with PSO
댓글 수: 0
답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Particle Swarm에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
