⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo3.m

📁 This contribution provides functions for finding an optimum parameter set using the evolutionary alg
💻 M
字号:
function demo3%DEMO3  Demo for usage of DIFFERENTIALEVOLUTION.%		DEMO3 starts searching the minimum of Shekel's Foxholes as a demo. This%		demo is similar to DEMO2 except that it uses a function to check%		parameter vectors for validity. Modify this function for your first%		optimization. %%		Markus Buehren%		Last modified 09.08.2008 %%		See also DIFFERENTIALEVOLUTION, FOXHOLES.% set titleoptimInfo.title = 'Demo 3 (Shekel''s Foxholes with constraint)';% specify objective functionobjFctHandle = @foxholes;% define parameter names, ranges, quantizations and initial values :paramDefCell = {'', [-65 65; -65 65], [0; 0], [0; -30]};% (single vector-valued parameter with no name, as function foxholes is% called with a parameter vector as only input) % no additional function parameters neededobjFctSettings = {};% no parameter vector neededobjFctParams = [];% get default DE parametersDEParams = getdefaultparams;% set number of population members (often 10*D is suggested; here we use% more as we know that the Foxholes functions has many local minima).DEParams.NP = 50;% do not use slave process hereDEParams.feedSlaveProc  = 0;% use a subfunction to check parameter vectors for validityDEParams.validChkHandle = @demo3_constraint;% set timesDEParams.maxiter        = 100;DEParams.maxtime        = 60;  % in secondsDEParams.maxclock       = [];% set display optionsDEParams.refreshiter    = 1;DEParams.refreshtime    = 10;  % in secondsDEParams.refreshtime2   = 20;  % in secondsDEParams.refreshtime3   = 40;  % in seconds% do not send E-mailsemailParams = [];% set random state in order to always use the same population members hererand('state', 1);% start differential evolution[bestmem, bestval] = ...	differentialevolution(DEParams, paramDefCell, objFctHandle, ...	objFctSettings, objFctParams, emailParams, optimInfo); %#okdisp(' ');disp('Best parameter set returned by function differentialevolution:');disp(bestmem);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function valid = demo3_constraint(x)% constraint function must accept the same input arguments as the objective% function!x0 = [-30, -30];r0 = 40;% as an example, set values outside some circle to invalidvalid = (x(1) - x0(1))^2 + (x(2) - x0(2))^2 < r0^2;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -