function demo1
%DEMO1 Demo for usage of DIFFERENTIALEVOLUTION.
% Set title
optimInfo.title = 'Demo 1 (Rosenbrock''s saddle)';
% Specify objective function
objFctHandle = @rosenbrocksaddle;
% Define parameter names, ranges and quantization:
% 1. column: parameter names
% 2. column: parameter ranges
% 3. column: parameter quantizations
% 4. column: initial values (optional)
paramDefCell = {
'parameter1', [-3 3], 0.01
'parameter2', [-3 3], 0.01
};
% Set initial parameter values in struct objFctParams
objFctParams.parameter1 = -2;
objFctParams.parameter2 = 2.5;
% Set single additional function parameter
objFctSettings = 100;
% Get default DE parameters
DEParams = getdefaultparams;
% Set number of population members (often 10*D is suggested)
DEParams.NP = 20;
% Do not use slave processes here. If you want to, set feedSlaveProc to 1 and
% run startmulticoreslave.m in at least one additional Matlab session.
DEParams.feedSlaveProc = 0;
% Set times
DEParams.maxiter = 20;
DEParams.maxtime = 30; % in seconds
DEParams.maxclock = [];
% Set display options
DEParams.infoIterations = 1;
DEParams.infoPeriod = 10; % in seconds
% Do not send E-mails
emailParams = [];
% Set random state in order to always use the same population members here
setrandomseed(1);
% Start differential evolution
[bestmem, bestval, bestFctParams, nrOfIterations, resultFileName] = differentialevolution(...
DEParams, paramDefCell, objFctHandle, objFctSettings, objFctParams, emailParams, optimInfo); %#ok
disp(' ');
disp('Best parameter set returned by function differentialevolution:');
disp(bestFctParams);
% Continue optimization by loading result file
if DEParams.saveHistory
disp(' ');
disp(textwrap2(sprintf(...
'Now continuing optimization by loading result file %s.', resultFileName)));
disp(' ');
DEParams.maxiter = 100;
DEParams.maxtime = 60; % in seconds
[bestmem, bestval, bestFctParams] = differentialevolution(...
DEParams, paramDefCell, objFctHandle, objFctSettings, objFctParams, emailParams, optimInfo, ...
resultFileName); %#ok
disp(' ');
disp('Best parameter set returned by function differentialevolution:');
disp(bestFctParams);
end
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.
- 79.
- 80.