• 大小: 10.3MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-26
  • 语言: Matlab
  • 标签:

资源简介

1.matlab代码,在matpower环境下进行潮流计算,用略微修改的ieee30节点,程序在main.m中 2.仅考虑了负荷的波动 如有原理性的错误望指出

资源截图

代码片段和文件信息

function ABC
%%算法参数设置
NP=12;   %%NP=雇佣蜂数=跟随蜂数
limit=24;
maxCycle=100;

%控制变量上下限
ub=[1.05 8 5];   %机端电压、变压器档位、并联电容器档位
lb=[0.95 0 0];    %变压器变比=档位*0.025+0.9  并联电容器容量=档位*10(MW)

%系统参数
shuju=data_ieee30;
n1=shuju.gen(:1);      %发电机节点
n2=find(shuju.branch(:9)~=0);  %变压器支路
n3=find(shuju.bus(:6)~=0);     %并联电容器节点
d1=length(n1);
d2=length(n2);
d3=length(n3);          
dim=[d1 d2 d3];        %控制变量维数
ND=sum(dim);           %总维数

%初始化
for i=1:NP
    foods(i:)=foodGenerate(ublbdim);   %蜜源,即解
    shuju=shujuGenerate(shujufoods(i:)dimn1n2n3);
    objVal(i)=objFun(shuju);              %目标函数值
    fitness(i)=1/(objVal(i)+1);           %适应度
end

[best bestInd]=min(objVal);
globalMin=best;
globalSolution=foods(bestInd:);
globalMins=zeros(1maxCycle);

trial=zeros(1NP);    %解未更新代数     

for iter=1:maxCycle
    %雇佣蜂工作 vid=xid+r(xid-xjd)
    for i=1:NP
        d=randi(ND);
        j=randi(NP);
        while j==i
            j=randi(NP);
        end
        %得到新的蜜源
        sol=foods(i:);
        sol(d)=foods(id)+(foods(id)-foods(jd))*(rand-0.5)*2;
        %限制蜜源位置
        sol=bound(solublbdim);
        %计算适应度
        shuju=shujuGenerate(shujusoldimn1n2n3);
        objValSol=objFun(shuju);
        fitnessSol=1/(1+objValSol);
        %贪婪选择
        if fitnessSol>fitness(i)
            foods(i:)=sol;
            fitness(i)=fitnessSol;
            objVal(i)=objValSol;
            trial(i)=0;
        else
            trial(i)=trial(i)+1;
        end
    end
    
    prob=fitness/sum(fitness);
    
    %跟随蜂开始工作
    i=1;
    t=0;
    while t        if rand            t=t+1;
            d=randi(ND);
            j=randi(NP);
            while j==i
                j=randi(NP);
            end
            %得到新的蜜源
            sol=foods(i:);
            sol(d)=foods(id)+(foods(id)-foods(jd))*(rand-0.5)*2;
            %限制蜜源位置
            sol=bound(solublbdim);
            %计算适应度
            shuju=shujuGenerate(shujusoldimn1n2n3);
            objValSol=objFun(shuju);
            fitnessSol=1/(1+objValSol);
             %贪婪选择
            if fitnessSol>fitness(i)
               foods(i:)=sol;
               fitness(i)=fitnessSol;
               objVal(i)=objValSol;
               trial(i)=0;
            else
                trial(i)=trial(i)+1;
            end
        end
        
        i=i+1;
        if i==NP+1
            i=1;
        end
    end
    
    [best bestInd]=min(objVal);
    if best        globalMin=best;
        globalSolution=foods(bestInd:);
    end
    
    globalMins(iter)=globalMin;
    %侦查蜂开始工作
    [maxTrial ind]=max(trial);
    if maxTrial>limit
       foods(ind:)=foodGenerate(ublbdim);
       shuju=shujuGenerate(shujufoods(ind:)dimn1n2n3);
       objVal(ind)=objFun(shuju);
       fitness(ind)=1/(1+objVal(ind));
       trial(ind)=0;
    end
end
globalMins
plot(globalMins)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-09-30 21:36  matpower6.0\
     目录           0  2017-05-29 18:22  matpower6.0\@opf_model\
     文件         711  2016-12-17 01:34  matpower6.0\@opf_model\display.m
     文件         434  2016-12-17 01:34  matpower6.0\@opf_model\get_mpc.m
     文件        2226  2016-12-17 01:34  matpower6.0\@opf_model\opf_model.m
     目录           0  2017-05-29 18:22  matpower6.0\@opt_model\
     文件        8151  2016-12-17 01:34  matpower6.0\@opt_model\add_constraints.m
     文件        9467  2016-12-17 01:34  matpower6.0\@opt_model\add_costs.m
     文件        6060  2016-12-17 01:34  matpower6.0\@opt_model\add_vars.m
     文件        6993  2016-12-17 01:34  matpower6.0\@opt_model\build_cost_params.m
     文件        3145  2016-12-17 01:34  matpower6.0\@opt_model\compute_cost.m
     文件        2293  2016-12-17 01:34  matpower6.0\@opt_model\describe_idx.m
     文件        5177  2016-12-17 01:34  matpower6.0\@opt_model\display.m
     文件         645  2016-12-17 01:34  matpower6.0\@opt_model\get.m
     文件        1625  2016-12-17 01:34  matpower6.0\@opt_model\getN.m
     文件        2196  2016-12-17 01:34  matpower6.0\@opt_model\get_cost_params.m
     文件        2168  2016-12-17 01:34  matpower6.0\@opt_model\get_idx.m
     文件        4465  2016-12-17 01:34  matpower6.0\@opt_model\getv.m
     文件        4191  2016-12-17 01:34  matpower6.0\@opt_model\linear_constraints.m
     文件        7901  2016-12-17 01:34  matpower6.0\@opt_model\opt_model.m
     文件        1132  2016-12-17 01:34  matpower6.0\@opt_model\userdata.m
     文件        4559  2017-05-29 18:38  matpower6.0\ABC.m
     文件         319  2016-12-17 01:34  matpower6.0\AUTHORS
     文件         972  2016-12-17 01:34  matpower6.0\Contents.m
     文件        2840  2016-12-17 01:34  matpower6.0\LICENSE
     文件       19884  2016-12-17 01:34  matpower6.0\README
     文件       20337  2016-12-17 01:34  matpower6.0\README.txt
     文件        5191  2016-12-17 01:34  matpower6.0\add_userfcn.m
     文件       17385  2016-12-17 01:34  matpower6.0\apply_changes.m
     文件        2065  2016-12-17 01:34  matpower6.0\bustypes.m
     文件       33539  2016-12-17 01:33  matpower6.0\case118.m
............此处省略496个文件信息

评论

共有 条评论

相关资源