基于改进二进制粒子群算法的含需求响应机组组合问题研究(matlab代码)

目录

[1 主要内容](#1 主要内容)

[2 部分代码](#2 部分代码)

[3 程序结果](#3 程序结果)

[4 下载链接](#4 下载链接)


1 主要内容

该程序复现《A Modified Binary PSO to solve the Thermal Unit Commitment Problem》第五章内容,主要做的是一个考虑需求响应的机组组合问题,首先构建了机组组合问题的基本模型,在此基础上,进一步考虑负荷侧管理,也就是需求响应,在调控过程中通过补偿引导负荷侧积极进行需求响应,在模型的求解上,采用了一种基于改进二进制粒子群算法的求解方法,相较于传统的粒子群算法,更加创新,而且求解的效果更好,代码出图效果非常好。该程序函数比较多,主函数为Swarm_generator,运行结果已经保存在Graphs文件夹内部,可以通过运行Graphs.m直接得到出图结果。程序采用matlab编程,注释为英文,适合具有编程经验的同学下载学习!

2 部分代码

复制代码
N=size(I,1); %%%Number of TGU's
T=24;        %%%Study period duration
​
%%%%fmincon.m solver options for F_LIM_ED
OPTS = optimoptions('fmincon','Algorithm','sqp','display','off','ConstraintTolerance',1e-2,'OptimalityTolerance',1.0000e-02,'MaxIterations',100, 'StepTolerance',1e-2,'MaxFunctionEvaluations',100);
​
%%%%%%%%%%%%%%%%%%%%%%%%%%UNIT DATA%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
​
%%%Generator limits
PGI_MAX=I(:,1); %%%Upper generation limit for each generator
PGI_MIN=I(:,2); %%%Lower generation limit for each generator
​
%%%I/O curve for each generator is modeled by a smooth quadratic function 
%%%i.e C(Pgi)=ai*Pgi^2+bi*Pgi+ci 
ai=I(:,3);
bi=I(:,4);
ci=I(:,5);
​
[I_C_SORT_EXS,IDX_EXS,I_C_SORT_INS,IDX_INS] = AFLC(ai,bi,ci,PGI_MAX); %%%Unit priority list assuming same fuel cost for every unit
​
%%MINIMUM TIME DATA
MUT=I(:,6);     %%%Minimum up-time for each generator
MDT=I(:,7);     %%%Minimum down-time for each generator
​
%%START-UP AND SHUT-DOWN COSTS
SU_H=I(:,8);
SU_C=I(:,9);
CSH=I(:,10);
init_status=I(:,11);
​
%%%%OTHER CONSTRAINTS
M_R=I(:,13);    %%MR units 
U_N=I(:,14);    %%Unavailable units
​
%%%% MR & UN hours & units 
    
    %%Hr begin  Hr end
MR=[  10          15  ];
UN=[                  ];
​
%%%% Prohibitive operative zones (POZ)
     %%%Unit    %%%POZ   
POZ=[  [1  150 165; 1  448,453]
       [2  90  110; 2  240 250]
       [8  20   30; 8  40  45]
       [10 12   17; 10 35  45]];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%MAIN LOOP%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
​
%%%%%%Initiaize solution (NxT) schedule solution as an empty array
Init_SOL=zeros(N,T);
​
complete=ones(1,T); %%%Nth unit operation schedule is ON for all t
sum_Pgi_max=sum(PGI_MAX);
​
%%%%%Define swarm size (Either particle or bee)
SWARM_SZ=20;
PART_BEE=0;
YES_CNT=0;
NO_CNT=0;
​
population=zeros(SWARM_SZ,N*T);
total_COST=zeros(SWARM_SZ,1);
​
while PART_BEE0); %%%Find the exception indices for must run units
UN_idx=find(U_N>0); %%%Find the exception indices for unavailable units 
​
%%%%%%%%%%%%Determine initial status of units %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
​
Tdiff_UP=zeros(N,3);%%%Exception indices for coupling constraints Tdiff_UP
Tdiff_DW=zeros(N,3);%%%Exception indices for coupling constraints Tdiff_DW
​
for k=1:N
   Tdiff_UP(k,1)=k;  
   Tdiff_DW(k,1)=k;  
     
   if ismember(k,MR_idx) || ismember(k,UN_idx) %%%If must run or unavailable unit, continue schedule repair without modifying INIT_SOL
       continue
​
   else
       P=1+(PGI_MAX(k)/sum_Pgi_max);
       
       if init_status(k)>0 %%Unit Online for ti=init_status hours
           Tdiff_U=init_status(k)-MUT(k);
           
           if Tdiff_U<0
                Tdiff_UP(k,2)=abs(Tdiff_U);
                
                Tdiff_UP(k,3)=1;
               
                Init_SOL(k,1:Tdiff_UP(k,2))=1;                
           else 
                Tdiff_UP(k,2)=0;
                
                Tdiff_UP(k,3)=0;
           end
​
           for j=Tdiff_UP(k,2)+1:T
               
               X=-1+(P-(-1))*rand;
               
               if X>=0
                   Init_SOL(k,j)=1;
               else
                   Init_SOL(k,j)=0;
               end    
           end
​
       else             %%Unit is offline for ti=init_status hours
           Tdiff_D=MDT(k)+init_status(k);
           
           if Tdiff_D>0
                Tdiff_DW(k,2)=abs(Tdiff_D);
               
                Init_SOL(k,1:Tdiff_D)=0;
                
                Tdiff_DW(k,3)=1;  
           else 
                Tdiff_DW(k,2)=0;
                
                Tdiff_DW(k,3)=0;
           end
​
           for j=Tdiff_DW(k,2)+1:T
                
               X=-1+(P-(-1))*rand;
               
               if X>=0
                   Init_SOL(k,j)=1;
               else
                   Init_SOL(k,j)=0;
               end    
           end
       end
   end
end
​
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%Check & Repair Coupling constraints %%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
​
%%%%Decompose commitment schedule into T single-hour unit combinations 
​
Exs_On_cap=zeros(3,T); %%Excess online capacity
Ins_On_cap=zeros(3,T); %%Insufficient online capacity
​
f_unit_ins_all=zeros(N,T); %%%This unit is not part of the exceptions MR,UN,Initialization
​
free_unit_ins=zeros(N,T);  %%%These units are offline and available to be turned off 
​
%%Check Excess online capacity first for full commitment
check_full_exs=ones(1,N)*PGI_MIN;     %%%Check if system has excess online capacity for a complete commitment
check_1=find(check_full_exs>P_D);
​
    if isempty(check_1)
        clear excp_exs f_unit_exs_all free_unit_exs Exs_On_cap
    else 
    %%%Excess online capacity schedule repair
        for t=1:T
            u_t=Init_SOL(:,t); %%Decompose into T single hour unit combinations
​
            Exs_On_cap(1,t)=u_t'*PGI_MIN;
            Exs_On_cap(2,t)=P_D(t);
​
            if Exs_On_cap(1,t)>P_D(t)
                Exs_On_cap(3,t)=1;
                format_exs='Excess capacity at hour %u. Repairing schedule...\n';
                fprintf(format_ins,t);  
            end
        end 
    end     
​
status_e=0;
status_f=0;
status_g=0;
​
status=[status_e,status_f,status_g];
trials=0;
max_trials=15;
​
    while ~all(status) 
    trials=trials+1;
    
    if trials>max_trials
        break
    end
    
    if trials==1
        %%%Insufficient online capacity initial schedule repair
        for t=1:T
            u_t=Init_SOL(:,t); %%Decompose into T single hour unit combinations
​
            Ins_On_cap(1,t)=u_t'*PGI_MAX;
            Ins_On_cap(2,t)=P_D(t)+SRREQ(t);
​
            if Ins_On_cap(1,t)

3 程序结果

4 下载链接

详见文后联系方式-->程序目录

相关推荐
chao1898441 小时前
基于 SPEA2 的多目标优化算法 MATLAB 实现
开发语言·算法·matlab
yongui478348 小时前
基于 GA 优化的 BP 神经网络算法分析与 MATLAB 实现
神经网络·算法·matlab
rit84324999 小时前
基于 MATLAB 的坐标变换程序
开发语言·matlab
listhi5209 小时前
LTE标准下Turbo码编译码仿真
算法·matlab
fie888910 小时前
城市环境下车辆目标跟踪算法 MATLAB 实现
算法·matlab·目标跟踪
机器学习之心10 小时前
轴承剩余寿命预测 | 基于BP神经网络的轴承剩余寿命预测MATLAB实现!
人工智能·神经网络·matlab·轴承剩余寿命预测
Evand J12 小时前
【无人机编队控制程序4】复杂障碍环境下多无人机编队避障(人工势场法APF)与协同控制,MATLAB仿真例程
开发语言·matlab·无人机·控制·apf·避障
南宫萧幕13 小时前
基于 MATLAB 的插电混动汽车 CD-CS 策略 WLTC 前向仿真实现
开发语言·matlab·汽车
yugi98783814 小时前
主动噪声控制中的 FXLMS 算法研究与 MATLAB 实现
开发语言·算法·matlab
kaikaile199516 小时前
基于 MATLAB 的3D 蒙特卡洛光子传输模拟
开发语言·matlab·3d