function dedemov(action);
% DE function minimization demonstration.
% dedemov is called with no parameters.
%
% Differential Evolution for MATLAB
% Copyright (C) 1996 R. Storn
% International Computer Science Institute (ICSI)
% 1947 Center Street, Suite 600
% Berkeley, CA 94704
% E-mail: storn@icsi.berkeley.edu
% WWW: http://http.icsi.berkeley.edu/~storn
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 1, or (at your option)
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. A copy of the GNU
% General Public License can be obtained from the
% Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
if nargin<1, %---number of arguments less than one ?
action='initialize';
end;
if strcmp(action,'initialize'),
%---Header of Window--------------------------------
figNumber=figure( ...
'Name','Differential Evolution Demo', ...
'NumberTitle','off', ...
'Visible','off');
%---define area for graphics------------------------
axes( ...
'Units','normalized', ...
'Visible','off', ...
'Position',[0.1 0.35 0.60 0.75]);
%---Set up the Comment Window-----------------------
top1=0.25;
left1=0.05;
right1=0.75;
bottom1=0.05;
labelHt1=0.05;
spacing1=0.005;
promptStr=str2mat(' ',...
' This demo shows the track of the best', ...
' population member for each generation.');
%---First, the MiniCommand Window frame------------------------
frmBorder=0.02;
frmPos1=[left1-frmBorder bottom1-frmBorder ...
(right1-left1)+2*frmBorder (top1-bottom1)+2*frmBorder];
uicontrol( ...
'Style','frame', ...
'Units','normalized', ...
'Position',frmPos1, ...
'BackgroundColor',[0.5 0.5 0.5]);
%---Then the text label----------------------------------------
labelPos1=[left1 top1-labelHt1 (right1-left1) labelHt1];
uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos1, ...
'BackgroundColor',[0.5 0.5 0.5], ...
'ForegroundColor',[1 1 1], ...
'String','Comment Window');
%---Then the editable text field-------------------------------
txtPos1=[left1 bottom1 (right1-left1) top1-bottom1-labelHt1-spacing1];
txtHndl=uicontrol( ...
'Style','edit', ...
'Units','normalized', ...
'Max',10, ...
'BackgroundColor',[1 1 1], ...
'Position',txtPos1, ...
'Callback','dedemov(''eval'')', ...
'String',promptStr);
%---Save the text handle for future use------------------------
set(gcf,'UserData',txtHndl)
%==============================================================
%---Information for all buttons (and menus)--------------------
labelColor=[0.8 0.8 0.8];
yInitPos=0.90;
menutop=0.95;
btnTop = 0.6;
top=0.75;
left=0.785;
btnWid=0.175;
btnHt=0.06;
textHeight = 0.05;
textWidth = 0.06;
%---Spacing between the button and the next command's label
spacing=0.019;
%---The CONSOLE frame------------------------------------------
frmBorder=0.019; frmBottom=0.04;
frmHeight = 0.92; frmWidth = btnWid;
yPos=frmBottom-frmBorder;
frmPos=[left-frmBorder yPos frmWidth+2*frmBorder frmHeight+2*frmBorder];
h=uicontrol( ...
'Style','frame', ...
'Units','normalized', ...
'Position',frmPos, ...
'BackgroundColor',[0.5 0.5 0.5]);
%===Define the individual selection items======================
%---The DE strategy Selection Menu-----------------------------
btnNumber=1;
yPos=menutop-(btnNumber-1)*(btnHt+spacing);
btnPos=[left yPos-btnHt btnWid btnHt];
labelStr='rand/1|best/1|best/2|rtb/1|rand/2';
callbackStr='dedemov(''changemethod'');';
MethodHndl=uicontrol( ...
'Style','popupmenu', ...
'Units','normalized', ...
'Position',btnPos, ...
'String',labelStr, ...
'Interruptible','yes', ...
'Callback',callbackStr);
%---Size of Population NP--------------------------------------
btnNumber=1;
yPos=menutop-(btnNumber-1)*(btnHt+spacing);
top = yPos - btnHt - spacing;
labelWidth = frmWidth-textWidth-.01;
labelBottom=top-textHeight;
labelLeft = left;
labelPos = [labelLeft labelBottom labelWidth textHeight];
h = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','NP', ...
'Interruptible','no', ...
'BackgroundColor',[0.5 0.5 0.5], ...
'ForegroundColor','white');
%---Weighting factor F-----------------------------------------
btnNumber=2;
yPos=menutop-(btnNumber-1)*(btnHt+spacing);
top = yPos - btnHt - spacing;
labelWidth = frmWidth-textWidth-.01;
labelBottom=top-textHeight;
labelLeft = left;
labelPos = [labelLeft labelBottom labelWidth textHeight];
h = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','F', ...
'Interruptible','no', ...
'BackgroundColor',[0.5 0.5 0.5], ...
'ForegroundColor','white');
%---Crossover probability CR-----------------------------------
btnNumber=3;
yPos=menutop-(btnNumber-1)*(btnHt+spacing);
top = yPos - btnHt - spacing;
labelWidth = frmWidth-textWidth-.01;
labelBottom=top-textHeight;
labelLeft = left;
labelPos = [labelLeft labelBottom labelWidth textHeight];
h = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','CR', ...
'Interruptible','no', ...
'BackgroundColor',[0.5 0.5 0.5], ...
'ForegroundColor','white');
%---Maximum number of iterations itermax------------------------
btnNumber=4;
yPos=menutop-(btnNumber-1)*(btnHt+spacing);
top = yPos - btnHt - spacing;
labelWidth = frmWidth-textWidth-.01;
labelBottom=top-textHeight;
labelLeft = left;
labelPos = [labelLeft labelBottom labelWidth textHeight];
h = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','itermax', ...
'Interruptible','no', ...
'BackgroundColor',[0.5 0.5 0.5], ...
'ForegroundColor','white');
%---Text field---------------------------------------------------
textPos = [labelLeft+labelWidth-.015 labelBottom textWidth+.025 7*.85*textHeight];
callbackStr = 'dedemov(''setContr'')';
%---Enter the default values-------------------------------------
str = sprintf('15\n\n0.9\n\n0.9\n\n200');
mat = [15; 0.9; 0.9; 200]; % default values
CvarsHndl = uicontrol( ...
'Style','edit', ...
'Units','normalized', ...
'Position',textPos, ...
'Max',2, ... % makes this a multiline edit object
'Horiz','right', ...
'Background','white', ...
'Foreground','black', ...
'String',str,'Userdata',mat, ...
'callback',callbackStr);
%---The INFO button-----------------------------------------------
uicontrol( ...
'Style','push', ...
'Units','normalized', ...
'Position',[left bottom1+btnHt+spacing btnWid btnHt], ...
'String','Info', ...
'Callback','dedemov(''info'')');
%---The CLOSE button--------------------------------------------
uicontrol( ...
'Style','push', ...
'Units','normalized', ...
'Position',[left bottom1 btnWid btnHt], ...
'String','Close', ...
'Callback','close(gcf)');
%---Get Handles--------------------------------------------------
chndlList=[MethodHndl CvarsHndl txtHndl];
%---Now uncover the figure-----------------------------------
set(figNumber, ...
'Visible','on', ...
'UserData',chndlList);
dedemov('demobutton') %---> Go and optimize
return
%===Different actions============================================
%---Modified control variables-----------------------------------
elseif strcmp(action,'setContr'),
v = get(gco,'Userdata');
str = get(gco,'String');
ind = find(abs(str)<32);
str(ind) = 32*ones(size(ind));
str = str';
vv = eval(['[' str(' ']'],'-1')';
if vv == -1
vv = v;
elseif length(vv)~=4 %must be 4 items as specified above
vv = v;
end
str = sprintf('%g\n\n%g\n\n%g\n\n%g\n\n%g\n\n%g',vv(1),vv(2),vv(3),vv(4));%,...
%vv(5), vv(6));
set(gco,'Userdata',vv,'String',str) %take new data
dedemov('demobutton') %---> Go and optimize
return
%---Modified method----------------------------------------------
elseif strcmp(action,'changemethod'),
v = get(gco,'value'); % 1 = DE/rand/1, 2 = DE/best/1, 3 = DE/best/2,
% 4 = DE/rand-to-best/1, 5 = DE/rand/2
chndlList = get(gcf,'UserData');
dedemov('demobutton') %---> Go and optimize
return
%-----Start optimization-----------------------------------
elseif strcmp(action,'demobutton'),
%---Plotting the banana function---------------------------
cla reset;
%axis off;
x=-2:.2:2;
y=-1:.2:3;
[xx,yy]=meshgrid(x,y);
zz=100*(yy-xx.^2).^2+(1-xx).^2;
%---Set up the appropriate colormap--------------------------------------
%---In this case, the colormap has been chosen to give the surface plot--
%---a nice healthy banana color.-----------------------------------------
hsv2=hsv;
hsv3=[hsv2(11:64,; hsv2(1:10,];
%---draw the surface plot-----------------------
surfHndl=surface(x,y,zz,'EdgeColor',[.8 .8 .8]);
axis([-2 2 -2 2]);
text(-1,-3,'x(1)'); %---substitute for xlabel
ylabel('x(2)');
%axis off;
view(10,55);
colormap(hsv3);
hold on;
[c,contHndl]=contour3(x,y,zz+50,[100 500],'k');
set(contHndl,'Color',[.8 .8 .8]);
drawnow
plot3(1,1,0,'ko', ...
'MarkerSize',15, ...
'LineWidth',2, ...
'EraseMode','none');
text(0.8,1.4,0,' goal', ...
'Color',[0 0 0], ...
'EraseMode','none');
%---Get handles----------------------------------------
chndlList=get(gcf,'Userdata');
MethodHndl = chndlList(1);
CvarsHndl = chndlList(2);
txtHndl = chndlList(3);
%---initialize variables-------------------------------
cvars = get(CvarsHndl,'UserData');
NP = cvars(1); % population size
F = cvars(2); % weighting factor
CR = cvars(3); % crossover probability
itermax = cvars(4); % maximum number of iterations
strategy = get(MethodHndl,'value');
D = 2;
%---as a reminder labelStr='rand/1|best/1|best/2|rtb/1';
%---Now run the DE demo eventually---------------------
[bestmem,nfeval]=devec(NP,D,F,CR,itermax,strategy);
str1=sprintf(' x(1) = %d x(2) = %d',bestmem(1),bestmem(2));
str2=sprintf(' Number of function evaluations: %d', nfeval);
%str1=get(txtHndl,'String');
strout=str2mat(str1,' ',str2);
set(txtHndl,'String',strout);
%---Info button----------------------------------------
elseif strcmp(action,'info'),
ttlStr=get(gcf,'Name');
hlpStr= ...
[' '
' This demonstration shows the minimization '
' of Rosenbrock''s "banana function": '
' '
' f(x)= 100*(x(2)-x(1)^2)^2+(1-x(1))^2 '
' '
' by Differential Evolution (DE). DE is a sto- '
' chastic minimization procedure for continuous '
' space functions that may be non-differentiable, '
' nonlinear and multimodal. DE requires just 3 '
' control variables: '
' '
' Number of population members NP '
' Difference vector weight F ex [0, 2] '
' Crossover probability CR ex [0, 1] '
' '
' As a first guess NP=10*(number of parameters) '
' is usually a good choice. '
' '
' File name: dedemov.m '];
helpfun(ttlStr,hlpStr);
end; % if strcmp(action, ...
function [bestmem,nfeval] = devec(NP,D,F,CR,itermax,strategy);
% Run DE minimization
%
% Output arguments:
% ----------------
% bestmem : parameter vector with best solution
% nfeval : number of function evaluations
%
% Input arguments:
% ---------------
% NP : number of population members
% D : number of parameters of the objective
% function
% F : DE-stepsize F ex [0, 2]
% CR : crossover probabililty constant ex [0, 1]
% itermax : maximum number of iterations (generations)
% strategy : 1 --> DE/best/1
% 2 --> DE/rand/1
% 3 --> DE/rand-to-best/1
% 4 --> DE/best/2
% else DE/rand/2
%
% Objective function: has still to be coded into the routine at locations
% designated by >>>>>>>>>>>eval<<<<<<<<<<<<<<<
%
% Example:
% [bestmem,nfeval] = devec(NP,D,F,CR,itermax,strategy);
%
% Used by: dedemov.m
%
% Differential Evolution for MATLAB
% Copyright (C) June 1996 R. Storn
% International Computer Science Institute (ICSI)
% 1947 Center Street, Suite 600
% Berkeley, CA 94704
% E-mail: storn@icsi.berkeley.edu
% WWW: http://http.icsi.berkeley.edu/~storn
%
% devec is a vectorized variant of DE which, however, has two
% properties which differ from the original version of DE:
% 1) The random selection of vectors is performed by shuffling the
% population array. Hence a certain vector can't be chosen twice
% in the same term of the perturbation expression.
% 2) The crossover parameters are chosen randomly, with a probability
% according to a binomial distribution, and need not be adjacent.
% This requires CR usually to be taken larger than in the original
% version of DE.
% Due to the vectorized expressions devec executes fairly fast
% in MATLAB's interpreter environment.
%
% In order to let devec optimize your own objective function you have
% to alter the code as devec was written for simplicity.
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 1, or (at your option)
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. A copy of the GNU
% General Public License can be obtained from the
% Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%-----Check input variables-----------------------------------------------
if (NP < 5)
fprintf(1,'Error! NP should be >= 5\n');
end
if ((CR < 0) | (CR > 1))
fprintf(1,'Error! CR should be ex [0,1]\n');
end
if (itermax < 0)
fprintf(1,'Error! itermax should be > 0\n');
end
%-----Initialize population and some arrays-------------------------------
pop = zeros(NP,D); %initialize pop to gain speed
lowbound1 = -3; % Lower bound for parameters (all parameters treated alike)
highbound1 = -1; % Upper bound for parameters (all parameters treated alike)
lowbound2 = 1; % Lower bound for parameters (all parameters treated alike)
highbound2 = 3; % Upper bound for parameters (all parameters treated alike)
%----pop is a matrix of size NPxD. It will be initialized-------------
%----with random values between highbound and lowbound----------------
for i=1:NP
pop(i,1) = lowbound1 + rand*(highbound1 - lowbound1);
pop(i,2) = lowbound2 + rand*(highbound2 - lowbound2);
end
popold = zeros(size(pop)); % toggle population
val = zeros(1,NP); % create and reset the "cost array"
bestmem = zeros(1,D); % best population member ever
bestmemit = zeros(1,D); % best population member in iteration
nfeval = 0; % number of function evaluations
%------Evaluate the best member after initialization----------------------
%------Objective function is the Rosenbrock saddle------------------------
%------100*(x2-x1^2)^2+(1-x1)^2.------------------------------------------
ibest = 1; % start with first population member
% >>>>>>>>>>>eval<<<<<<<<<<<<<<<
val(1) = 100*(pop(ibest,2)-pop(ibest,1)^2)^2 + (1-pop(ibest,1))^2;
bestval = val(1); % best objective function value so far
nfeval = nfeval + 1;
for i=2:NP % check the remaining members
% >>>>>>>>>>>eval<<<<<<<<<<<<<<<
val(i) = 100*(pop(i,2)-pop(i,1)^2)^2 + (1-pop(i,1))^2;
nfeval = nfeval + 1;
if (val(i) < bestval) % if member is better
ibest = i; % save its location
bestval = val(i);
end
end
bestmemit = pop(ibest,; % best member of current iteration
bestvalit = bestval; % best value of current iteration
bestmem = bestmemit; % best member ever
xplt(NP,pop,bestmem,1); % 3D-plot function
%------DE-Minimization---------------------------------------------
%------popold is the population which has to compete. It is--------
%------static through one iteration. pop is the newly--------------
%------emerging population.----------------------------------------
pm1 = zeros(NP,D); % initialize population matrix 1
pm2 = zeros(NP,D); % initialize population matrix 2
pm3 = zeros(NP,D); % initialize population matrix 3
pm4 = zeros(NP,D); % initialize population matrix 4
pm5 = zeros(NP,D); % initialize population matrix 5
bm = zeros(NP,D); % initialize bestmember matrix
ui = zeros(NP,D); % intermediate population of perturbed vectors
mui = zeros(NP,D); % mask for intermediate population
mpo = zeros(NP,D); % mask for old population
rot = (0:1:NP-1); % rotating index array
rt = zeros(NP); % another rotating index array
a1 = zeros(NP); % index array
a2 = zeros(NP); % index array
a3 = zeros(NP); % index array
a4 = zeros(NP); % index array
a5 = zeros(NP); % index array
ind = zeros(4);
iter = 1;
while ((iter < itermax) & (bestval > 1.e-6))
popold = pop; % save the old population
ind = randperm(4); % index pointer array
a1 = randperm(NP); % shuffle locations of vectors
rt = rem(rot+ind(1),NP); % rotate indices by ind(1) positions
a2 = a1(rt+1); % rotate vector locations
rt = rem(rot+ind(2),NP);
a3 = a2(rt+1);
rt = rem(rot+ind(3),NP);
a4 = a3(rt+1);
rt = rem(rot+ind(4),NP);
a5 = a4(rt+1);
pm1 = popold(a1,; % shuffled population 1
pm2 = popold(a2,; % shuffled population 2
pm3 = popold(a3,; % shuffled population 3
pm4 = popold(a4,; % shuffled population 4
pm5 = popold(a5,; % shuffled population 5
for i=1:NP % population filled with the best member
bm(i, = bestmemit; % of the last iteration
end
mui = rand(NP,D) < CR; % all random numbers < CR are 1, 0 otherwise
mpo = mui < 0.5; % inverse mask to mui
if (strategy == 1) % DE/best/1
ui = bm + F*(pm1 - pm2); % differential variation
ui = popold.*mpo + ui.*mui; % binomial crossover
elseif (strategy == 2) % DE/rand/1
ui = pm3 + F*(pm1 - pm2); % differential variation
ui = popold.*mpo + ui.*mui; % binomial crossover
elseif (strategy == 3) % DE/rand-to-best/1
ui = popold + F*(bm-popold) + F*(pm1 - pm2);
ui = popold.*mpo + ui.*mui; % binomial crossover
elseif (strategy == 4) % DE/best/2
ui = bm + F*(pm1 - pm2 + pm3 - pm4); % differential variation
ui = popold.*mpo + ui.*mui; % binomial crossover
else % DE/rand/2
ui = pm5 + F*(pm1 - pm2 + pm3 - pm4); % differential variation
ui = popold.*mpo + ui.*mui; % binomial crossover
end
%-----Select which vectors are allowed to enter the new population------------
for i=1:NP
% >>>>>>>>>>>eval<<<<<<<<<<<<<<<
tempval = 100*(ui(i,2)-ui(i,1)^2)^2 + (1-ui(i,1))^2; % check cost of competitor
nfeval = nfeval + 1;
if (tempval <= val(i)) % if competitor is better than value in "cost array"
pop(i,:) = ui(i,:); % replace old vector with new one (for new iteration)
val(i) = tempval; % save value in "cost array"
%----we update bestval only in case of success to save time-----------
if (tempval < bestval) % if competitor better than the best one ever
bestval = tempval; % new best value
bestmem = ui(i,:); % new best parameter vector ever
end
end
end %---end for imember=1:NP
bestmemit = bestmem; % freeze the best member of this iteration for the coming
% iteration. This is needed for some of the strategies.
%----Output section----------------------------------------------------------
if (rem(iter,10) == 0)
fprintf(1,'Iteration: %d, Best: %f, F: %f, CR: %f, NP: %d\n',iter,bestval,F,CR,NP);
for n=1
fprintf(1,'best(%d) = %f\n',n,bestmem(n));
end
end
%----Continue plotting-------------------------------------------------------
xplt(NP,pop,bestmem,1); % 3D-plot function
iter = iter + 1;
end %---end while ((iter < itermax) ...
function out = xplt(NP,pop,vec,flag)
% xplt plots a coloured point with coordinates vec(1), vec(2)
% on a 3D-surface if flag is not equal 0. Otherwise NP colored
% points, stored in pop, will be plotted.
%
% Example: xplt(NP,pop)
% where pop is a two-dimensional array of NP points
%
%
% Used by: der.m
if (flag == 0) %---draw entire population----------
for i=1:NP
x1=pop(i,1);
x2=pop(i,2);
z1=100*(x2-x1.^2).^2+(1-x1).^2;
plot3(x1,x2,z1,'r.', ...
'EraseMode','none', ...
'MarkerSize',15);
drawnow; %---Draws current graph now
out = [];
end
else
x1 = vec(1);
x2 = vec(2);
z1=100*(x2-x1.^2).^2+(1-x1).^2;
plot3(x1,x2,z1,'r.', ...
'EraseMode','none', ...
'MarkerSize',15);
drawnow; %---Draws current graph now
out = [];
end
function [bestmem,bestval,nfeval] = devec3(fname,VTR,D,XVmin,XVmax,y,NP,itermax,F,CR,strategy,refresh);
% minimization of a user-supplied function with respect to x(1),
% using the differential evolution (DE) algorithm of Rainer Storn
% (http://www.icsi.berkeley.edu/~storn/code.html)
%
% Special thanks go to Ken Price (kprice@solano.community.net) and
% Arnold Neumaier (http://solon.cma.univie.ac.at/~neum/) for their
% valuable contributions to improve the code.
%
% Strategies with exponential crossover, further input variable
% tests, and arbitrary function name implemented by Jim Van Zandt
% <jrv@vanzandt.mv.com>, 12/97.
%
% Output arguments:
% ----------------
% bestmem parameter vector with best solution
% bestval best objective function value
% nfeval number of function evaluations
%
% Input arguments:
% ---------------
%
% fname string naming a function f(x,y) to minimize
% VTR "Value To Reach". devec3 will stop its minimization
% if either the maximum number of iterations "itermax"
% is reached or the best parameter vector "bestmem"
% has found a value f(bestmem,y) <= VTR.
% D number of parameters of the objective function
% XVmin vector of lower bounds XVmin(1) ... XVmin(D)
% of initial population
% *** note: these are not bound constraints!! ***
% XVmax vector of upper bounds XVmax(1) ... XVmax(D)
% of initial population
% y problem data vector (must remain fixed during the
% minimization)
% NP number of population members
% itermax maximum number of iterations (generations)
% F DE-stepsize F from interval [0, 2]
% CR crossover probability constant from interval [0, 1]
% strategy 1 --> DE/best/1/exp 6 --> DE/best/1/bin
% 2 --> DE/rand/1/exp 7 --> DE/rand/1/bin
% 3 --> DE/rand-to-best/1/exp 8 --> DE/rand-to-best/1/bin
% 4 --> DE/best/2/exp 9 --> DE/best/2/bin
% 5 --> DE/rand/2/exp else DE/rand/2/bin
% Experiments suggest that /bin likes to have a slightly
% larger CR than /exp.
% refresh intermediate output will be produced after "refresh"
% iterations. No intermediate output will be produced
% if refresh is < 1
%
% The first four arguments are essential (though they have
% default values, too). In particular, the algorithm seems to
% work well only if [XVmin,XVmax] covers the region where the
% global minimum is expected. DE is also somewhat sensitive to
% the choice of the stepsize F. A good initial guess is to
% choose F from interval [0.5, 1], e.g. 0.8. CR, the crossover
% probability constant from interval [0, 1] helps to maintain
% the diversity of the population and is rather uncritical. The
% number of population members NP is also not very critical. A
% good initial guess is 10*D. Depending on the difficulty of the
% problem NP can be lower than 10*D or must be higher than 10*D
% to achieve convergence.
% If the parameters are correlated, high values of CR work better.
% The reverse is true for no correlation.
%
% default values in case of missing input arguments:
% VTR = 1.e-6;
% D = 2;
% XVmin = [-2 -2];
% XVmax = [2 2];
% y=[];
% NP = 10*D;
% itermax = 200;
% F = 0.8;
% CR = 0.5;
% strategy = 7;
% refresh = 10;
%
% Cost function: function result = f(x,y);
% has to be defined by the user and is minimized
% w.r. to x(1).
%
% Example to find the minimum of the Rosenbrock saddle:
% ----------------------------------------------------
% Define f.m as:
% function result = f(x,y);
% result = 100*(x(2)-x(1)^2)^2+(1-x(1))^2;
% end
% Then type:
%
% VTR = 1.e-6;
% D = 2;
% XVmin = [-2 -2];
% XVmax = [2 2];
% [bestmem,bestval,nfeval] = devec3("f",VTR,D,XVmin,XVmax);
%
% The same example with a more complete argument list is handled in
% run1.m
%
% About devec3.m
% --------------
% Differential Evolution for MATLAB
% Copyright (C) 1996, 1997 R. Storn
% International Computer Science Institute (ICSI)
% 1947 Center Street, Suite 600
% Berkeley, CA 94704
% E-mail: storn@icsi.berkeley.edu
% WWW: http://http.icsi.berkeley.edu/~storn
%
% devec is a vectorized variant of DE which, however, has a
% propertiy which differs from the original version of DE:
% 1) The random selection of vectors is performed by shuffling the
% population array. Hence a certain vector can't be chosen twice
% in the same term of the perturbation expression.
%
% Due to the vectorized expressions devec3 executes fairly fast
% in MATLAB's interpreter environment.
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 1, or (at your option)
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU G
【轉(zhuǎn)貼】matlab的差分算法實(shí)現(xiàn)以及蟻群算法介紹
來(lái)源:互聯(lián)網(wǎng) 發(fā)布日期:2011-10-01 20:05:47 瀏覽:131751次
導(dǎo)讀:研學(xué)論壇 function dedemov(action);% DE function minimization demonstration.% dedemov is called with no parameters.%% Differential Evolution for MATLA...
相關(guān)內(nèi)容
- 印度中產(chǎn)“新寵”:5G網(wǎng)絡(luò)成生活必需,民眾愿意為高速網(wǎng)絡(luò)買(mǎi)單
- 國(guó)家數(shù)據(jù)局:有序推進(jìn)5G網(wǎng)絡(luò)向5G-A升級(jí)演進(jìn) 全面推進(jìn)6G網(wǎng)絡(luò)技術(shù)研發(fā)創(chuàng)新
- 5G網(wǎng)絡(luò):向未來(lái)演進(jìn),開(kāi)啟全面智能新時(shí)代
- 高通孟樸:5G和AI的融合為新型工業(yè)制造帶來(lái)智能化飛躍
- 5G工廠與工業(yè)互聯(lián)網(wǎng)融合:驅(qū)動(dòng)產(chǎn)業(yè)創(chuàng)新與升級(jí)
- 高通孟樸:以5G和AI正在加速推動(dòng)多個(gè)行業(yè)的數(shù)字化轉(zhuǎn)型和創(chuàng)新發(fā)展
- 東南亞多國(guó)邀中企合作開(kāi)發(fā)5G網(wǎng)絡(luò),泰總理:愿同中方在多領(lǐng)域加強(qiáng)合作
- 尚網(wǎng)網(wǎng)絡(luò)CEO朱立華:WiFi技術(shù)有助解決5G峰值流量問(wèn)題
- 愛(ài)立信中國(guó)區(qū)總裁方迎:5G發(fā)展仍面臨兩大挑戰(zhàn),“新質(zhì)網(wǎng)絡(luò)”將創(chuàng)造“新質(zhì)價(jià)值”
- 華為楊超斌:5G-A 釋放移動(dòng) AI 無(wú)限潛能
- 通宇通訊:已開(kāi)發(fā)出面向5G-A的空地一體化賦形綠色天線
- 中國(guó)提前完成5G建設(shè)目標(biāo):正式開(kāi)啟5G-A時(shí)代
- 中國(guó)廣電曾慶軍:5G NR廣播擴(kuò)展到衛(wèi)星覆蓋,國(guó)產(chǎn)芯片的車(chē)載音視頻系統(tǒng)等均可預(yù)載功能
- 當(dāng)5G-A與AI融合,聯(lián)接網(wǎng)絡(luò)底座需不斷創(chuàng)新與演進(jìn)
- 5G下半場(chǎng) 萬(wàn)億級(jí)5G-A無(wú)源物聯(lián)時(shí)代來(lái)了
- 曝蘋(píng)果自研5G基帶性能弱于高通:iPhone信號(hào)問(wèn)題無(wú)解
- 中國(guó)聯(lián)通:擬向華為、中興展開(kāi)5G網(wǎng)絡(luò)設(shè)備競(jìng)爭(zhēng)性談判采購(gòu)
- 蘋(píng)果自研5G基帶細(xì)節(jié)曝光:3年3款芯片,全面替代高通
- 韓琳:基礎(chǔ)電信企業(yè)如何借助5G-A挖掘業(yè)務(wù)潛力?
- 愛(ài)立信中國(guó)區(qū)總裁方迎:構(gòu)建新質(zhì)網(wǎng)絡(luò) 推動(dòng)5G下半場(chǎng)實(shí)現(xiàn)卓越價(jià)值
AiLab云推薦
最新資訊
- 天翼智庫(kù)饒少陽(yáng):AI+5G融合助推高階廣泛智能落地
- 5G下半場(chǎng) 萬(wàn)億級(jí)5G-A無(wú)源物聯(lián)時(shí)代來(lái)了
- 5G+AI,一條拉鏈如何開(kāi)啟數(shù)智化轉(zhuǎn)型之路?|一線
- 5G網(wǎng)絡(luò):向未來(lái)演進(jìn),開(kāi)啟全面智能新時(shí)代
- 5G-A如何助飛低空經(jīng)濟(jì)?探訪全球首個(gè)5G-A機(jī)場(chǎng)通感一體基站|一線
- 全球首個(gè) 5G-A 區(qū)域在中東點(diǎn)亮
- 中國(guó)科學(xué)院院士尹浩:5G商用遍布全球,仍需解決安全保障問(wèn)題
- 中國(guó)提前完成5G建設(shè)目標(biāo):正式開(kāi)啟5G-A時(shí)代
- 推進(jìn)5G向5G-A升級(jí),券商:一體化算力體系新基建有望夯實(shí)
- 5G規(guī)模化應(yīng)用時(shí)間表確定 5G-A支撐低空經(jīng)濟(jì)加速落地 通信業(yè)增長(zhǎng)空間進(jìn)一步打開(kāi)|行業(yè)觀察
本月熱點(diǎn)
- 如何買(mǎi)到便宜大碗的 5G 套餐?聊聊你也許不知道的 CPE、MiFi 和物聯(lián)卡
- 愛(ài)立信中國(guó)區(qū)總裁方迎:5G發(fā)展仍面臨兩大挑戰(zhàn),“新質(zhì)網(wǎng)絡(luò)”將創(chuàng)造“新質(zhì)價(jià)值”
- 東南亞多國(guó)邀中企合作開(kāi)發(fā)5G網(wǎng)絡(luò),泰總理:愿同中方在多領(lǐng)域加強(qiáng)合作
- 從數(shù)字化到智能化,探訪中國(guó)首個(gè)五星5G工廠 中興通訊副總裁陸平:5G革新了生產(chǎn)方式
- 蘋(píng)果自研5G基帶細(xì)節(jié)曝光:3年3款芯片,全面替代高通
- 5G網(wǎng)絡(luò):向未來(lái)演進(jìn),開(kāi)啟全面智能新時(shí)代
- 中國(guó)科學(xué)院院士尹浩:5G商用遍布全球,仍需解決安全保障問(wèn)題
- 中國(guó)廣電曾慶軍:5G NR廣播擴(kuò)展到衛(wèi)星覆蓋,國(guó)產(chǎn)芯片的車(chē)載音視頻系統(tǒng)等均可預(yù)載功能
- 天翼智庫(kù)饒少陽(yáng):AI+5G融合助推高階廣泛智能落地
- 5G+AI,一條拉鏈如何開(kāi)啟數(shù)智化轉(zhuǎn)型之路?|一線
熱門(mén)排行
-
當(dāng)海外華文媒體遇見(jiàn)中國(guó)首座5G煤礦:數(shù)智轉(zhuǎn)型就在眼前
閱讀量:8139
-
如何買(mǎi)到便宜大碗的 5G 套餐?聊聊你也許不知道的 CPE、MiFi 和物聯(lián)卡
閱讀量:4196
-
5G-A商用加速:北京運(yùn)營(yíng)商齊發(fā)力,創(chuàng)新應(yīng)用場(chǎng)景欣欣向榮
閱讀量:4114
-
美版蘋(píng)果 iPhone 16 Pro 實(shí)測(cè):5G下載超400 Mbps、平均增幅23.7%
閱讀量:3381
-
消息稱(chēng)國(guó)內(nèi)“通信大廠開(kāi)始搞 5G SOC”
閱讀量:3170
-
精彩回顧 | 5G-A與AI融合產(chǎn)業(yè)論壇行業(yè)大咖觀點(diǎn)
閱讀量:3151