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

資源簡(jiǎn)介

CMAES(自適應(yīng)協(xié)方差矩陣進(jìn)化算法)的Matlab實(shí)現(xiàn),包含動(dòng)畫演示的小Demo。

資源截圖

代碼片段和文件信息


%?CMA-ES:?Evolution?Strategy?with?Covariance?Matrix?Adaptation?for
%?nonlinear?function?minimization.
%
%?This?code?is?an?excerpt?from?cmaes.m?and?implements?the?key?parts
%?of?the?algorithm.?It?is?intendend?to?be?used?for?READING?and
%?UNDERSTANDING?the?basic?flow?and?all?details?of?the?CMA?*algorithm*.
%?Computational?efficiency?is?sometimes?disregarded.
%?--------------------?Initialization?--------------------------------
%?User?defined?input?parameters?(need?to?be?edited)
clear?all;clc;

target_function?=?@(x)(x(1)-1).^2+0.3*sin(x(1))+(x(2)-1).^2+0.3*sin(x(2));

x_o?=?[3:-0.01:0];
y_o?=?zeros(length(x_o)length(x_o));
for?index_i?=?1:length(x_o)
????for?index_j?=?1:length(x_o)
????????y_o(index_iindex_j)?=?target_function([x_o(index_i)?x_o(index_j)]);
????end
end

subplot(121);
mesh(x_ox_oy_o);
subplot(122);
mesh(x_ox_oy_o);
%?subplot(222);
%?contourf(x_ox_oy_o20);
set(gcf‘outerposition‘get(0‘screensize‘));

noise?=?0.1;
N?=?2;?%?number?of?objective?variables/problem?dimension
xmean?=?[2.5;2.5];?%?objective?variables?initial?point
sigma?=?0.05;?%?coordinate?wise?standard?deviation?(step-size)
stopeval?=?20;

%?Strategy?parameter?setting:?Selection
lambda?=?4+floor(3*log(N));?%?population?size?offspring?number
lambda?=?20;
mu?=?lambda/2;?%?lambda=12;?mu=3;?weights?=?ones(mu1);?would?be?(3_I12)-ES
weights?=?log(mu+1/2)-log(1:mu)‘;?%?muXone?recombination?weights
mu?=?floor(mu);?%?number?of?parents/points?for?recombination
weights?=?weights/sum(weights);?%?normalize?recombination?weights?array
mueff=sum(weights)^2/sum(weights.^2);?%?variance-effective?size?of?mu

%?Strategy?parameter?setting:?Adaptation
cc?=?(4+mueff/N)?/?(N+4?+?2*mueff/N);?%?time?constant?for?cumulation?for?C
cs?=?(mueff+2)/(N+mueff+5);?%?t-const?for?cumulation?for?sigma?control
c1?=?2?/?((N+1.3)^2+mueff);?%?learning?rate?for?rank-one?update?of?C
cmu?=?2?*?(mueff-2+1/mueff)?/?((N+2)^2+2*mueff/2);?%?and?for?rank-mu?update
damps?=?1?+?2*max(0?sqrt((mueff-1)/(N+1))-1)?+?cs;?%?damping?for?sigma

%?Initialize?dynamic?(internal)?strategy?parameters?and?constants
pc?=?zeros(N1);?ps?=?zeros(N1);?%?evolution?paths?for?C?and?sigma
B?=?eye(N);?%?B?defines?the?coordinate?system
D?=?eye(N);?%?diagonal?matrix?D?defines?the?scaling
C?=?B*D*(B*D)‘;?%?covariance?matrix
eigeneval?=?0;?%?B?and?D?updated?at?counteval?==?0
chiN=N^0.5*(1-1/(4*N)+1/(21*N^2));?%?expectation?of

Opt_Record?=?[];
n=0;

pause(1);
?%?--------------------?Generation?Loop?--------------------------------

counteval?=?0;?%?the?next?40?lines?contain?the?20?lines?of?interesting?code
while?counteval?
???%?Generate?and?evaluate?lambda?offspring
????for?k=1:lambda
????????arz(:k)?=?randn(N1);?%?standard?normally?distributed?vector
????????arx(:k)?=?xmean?+?sigma?*?(B*D?*?arz(:k));?%?add?mutation?%?Eq.?40
????????arfitness(k)?=?target_function(arx(:k))?+?noise*randn;?%?objective?function?call
????end
????
????%%?繪制響應(yīng)

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????4689??2019-04-19?23:04??CMAES_demo.m
?????文件?????????174??2019-03-26?20:31??Opt_Target_Function.m

評(píng)論

共有 條評(píng)論