• 大小: 2KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-04-17
  • 语言: Matlab
  • 标签: 寻优  PSO  

资源简介

改进后的离散粒子群算法,支持多种寻优解决方案

资源截图

代码片段和文件信息


%初始化
clear all;
clc;
tic;         %计时开始
c1=2;        %学习因子1
c2=2.1;      %学习因子2
wcmax=0.9;        %惯性权重
wcmin=0.4;
N=100;         %种群大小
D=10;
genMax=50;     %最大迭代次数
C=1.3;        
A1=1.6;       
A2=1.5;       
R1=0.9;        %(OFC)技术
R2=0.85;       %(PC)技术
Ld1=0.25;      %能量损失1
Ld2=0.21;      %能量损失2
P=[200    250    150   600       500    250    300     400      200      250];
%F =[1      1      1     1         1     0.5    0.5     0.5       0.7     0.7];
F =[1.186  1.186  1.186 1.186   1.186  0.434   0.434   0.434     0.78    0.78];
%映射
for i=1:N                        %初始化数据
    for j=1:D
        x=3*rand();       
        if (x>0)&(x<1)
            X(ij)=0;
        elseif (x>=1)&(x<2)
            X(ij)=1;
        elseif (x>=2)&(x<3)
            X(ij)=2;
        end
    end 
end
for i=1:N
    for j=1:D
        V(ij)=2*rand()-1;
    end
end
 
 for i=1:N 
     for j=1:D
         ss=rand();
         if X(i2)==1
            if ss>=0.5
               X(i2)=0;
            else
               X(i2)=2;
            end            %对初始解进行可行性筛选
         elseif X(i6)==1
            if ss>=0.5
               X(i6)=0;
            else
               X(i6)=2;
            end            %对初始解进行可行性筛选
         end
     end
 end
temp=zeros(N1);          
for i=1:N
    for j=1:D
        if X(ij)==0
           temp(i)=temp(i)+(C-1)*P(j);      %      成本约束
        elseif X(ij)==1
           temp(i)=temp(i)+C*P(j)-A1*P(j);  %     成本约束
        elseif X(ij)==2
           temp(i)=temp(i)+C*P(j)-A2*P(j);  %成本约束
        end
    end
end                                               %整体50判定
    for i=1:N
        while (temp(i)<0)
           for j=1:D
               x=3*rand();               %随机产生一个数
               if (x>0)&(x<1)
                  X(ij)=0;              %粒子位置矢量在0-1上选择不配置碳捕集技术
               elseif (x>=1)&(x<2)
                  X(ij)=1;              %粒子位置矢量在1-2上选择第1种碳捕集技术
               elseif (x>=2)&(x<3)
                 X(ij)=2;               %粒子位置矢量在2-3上选择第2种碳捕集技术
               end
           end
           for j=1:D                     
               ss=rand();
               if X(i2)==1
                  if ss>=0.5
                     X(i2)=0;
                  else
                     X(i2)=2;
                  end            
              elseif X(i6)==1
                  if ss>=0.5
                     X(i6)=0;
                  else
                     X(i6)=2;
                  end    
              end
           end
           temp(i)=0;                     %约束条件清0
           for j=1:D
               if X(ij)==0
                   temp(i)=temp(i)+(C-1)*P(j);
               elseif X(ij)==1
                   temp(i)=temp(i)+C*P(j)-A1*P(j);
               elseif X(ij)==2
                   temp(i)=temp(i)+C*P(j)-A2*P(j);
               end
           end
        end
    end                                    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件          78  2014-06-02 10:43  PSO源程序\Untitled.m
     文件       10252  2014-06-02 10:43  PSO源程序\test.m
     目录           0  2014-06-02 10:44  PSO源程序\

评论

共有 条评论