91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 16KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-13
  • 語言: Matlab
  • 標簽: 粒子群??

資源簡介

粒子群優化的支持向量機matlab源代碼 有自己的部分還有其他人的需要可以下載

資源截圖

代碼片段和文件信息

%%?清空環境

clc
clear?

load?matlab111.mat
%%?載入數據
train=?data_train‘;
train_label?=label_train‘;
test?=data_test‘;
test_label?=label_test‘;

[trainpstrain]?=?mapminmax(train‘);
pstrain.ymin?=?0;
pstrain.ymax?=?1;
[trainpstrain]?=?mapminmax(trainpstrain);

[testpstest]?=?mapminmax(test‘);
pstest.ymin?=?0;
pstest.ymax?=?1;
[testpstest]?=?mapminmax(testpstest);

train?=?train‘;
test?=?test‘;

%%?參數初始化

%粒子群算法中的兩個參數
c1?=?1.6;?%?c1?belongs?to?[02]
c2?=?1.5;?%?c2?belongs?to?[02]

maxgen=300;???%?進化次數?
sizepop=30;???%?種群規模

popcmax=10^(2);
popcmin=10^(-1);
popgmax=10^(3);
popgmin=10^(-2);
k?=?0.6;?%?k?belongs?to?[0.11.0];
Vcmax?=?k*popcmax;
Vcmin?=?-Vcmax?;
Vgmax?=?k*popgmax;
Vgmin?=?-Vgmax?;

%?SVM參數初始化?
v?=?3;

%%?產生初始粒子和速度
for?i=1:sizepop
????%?隨機產生種群
????pop(i1)?=?(popcmax-popcmin)*rand+popcmin;????%?初始種群
????pop(i2)?=?(popgmax-popgmin)*rand+popgmin;
????V(i1)=Vcmax*rands(1);?%?初始化速度
????V(i2)=Vgmax*rands(1);
????%?計算初始適應度
????cmd?=?[‘-v?‘num2str(v)‘?-c?‘num2str(?pop(i1)?)‘?-g?‘num2str(?pop(i2)?)];
????fitness(i)?=?svmtrain(train_label?train?cmd);
????fitness(i)?=?-fitness(i);
end

%?找極值和極值點

[global_fitness?bestindex]=min(fitness);?%?全局極值
local_fitness=fitness;???%?個體極值初始化

global_x=pop(bestindex:);???%?全局極值點
local_x=pop;????%?個體極值點初始化

tic

%%?迭代尋優
for?i=1:maxgen
???
????for?j=1:sizepop
???????
????????%速度更新
????????wV?=?0.9;?%?wV?best?belongs?to?[0.81.2]
????????V(j:)?=?wV*V(j:)?+?c1*rand*(local_x(j:)?-?pop(j:))?+?c2*rand*(global_x?-?pop(j:));
????????if?V(j1)?>?Vcmax
????????????V(j1)?=?Vcmax;
????????end
????????if?V(j1)?????????????V(j1)?=?Vcmin;
????????end
????????if?V(j2)?>?Vgmax
????????????V(j2)?=?Vgmax;
????????end
????????if?V(j2)?????????????V(j2)?=?Vgmin;
????????end
???????
????????%種群更新
????????wP?=?0.6;
????????pop(j:)=pop(j:)+wP*V(j:);
????????if?pop(j1)?>?popcmax
????????????pop(j1)?=?popcmax;
????????end
????????if?pop(j1)?????????????pop(j1)?=?popcmin;
????????end
????????if?pop(j2)?>?popgmax
????????????pop(j2)?=?popgmax;
????????end
????????if?pop(j2)?????????????pop(j2)?=?popgmin;
????????end
???????
????????%?自適應粒子變異
????????if?rand>0.5
????????????k=ceil(2*rand);
????????????if?k?==?1
????????????????pop(jk)?=?(20-1)*rand+1;
????????????end
????????????if?k?==?2
????????????????pop(jk)?=?(popgmax-popgmin)*rand+popgmin;
????????????end???????????
????????end
???????
????????%適應度值
????????cmd?=?[‘-v?‘num2str(v)‘?-c?‘num2str(?pop(j1)?)‘?-g?‘num2str(?pop(j2)?)];
????????fitness(j)?=?svmtrain(train_label?train?cmd);
????????fitness(j)?=?-fitness(j);
????end
???
????%個體最優更新
????if?fitness(j)?????????local_x(j:)?=?pop(j:);
????????local_fitness(j)?=?fitness(j);
????end
???
????%群體最優更新
????if?fitness(j)?????????global_x?=?pop(j:);
????????global_fitness?=?fitness(j);
??

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????9187??2018-04-18?16:18??pso-SVM\matlab111.mat
?????文件????????3957??2018-04-18?20:13??pso-SVM\psoSVM.m
?????文件???????20168??2010-01-30?18:38??pso-SVM\wine.mat

評論

共有 條評論