8-4 ������������������

MATLAB ѤFƭӫOӶiƾǨƪ̨ΤơA`NСG

`ҰQת̨ΤƤkO򥻪kAYŪ̦ϥθkAiHϥΡųΤƤucv]Optimization Toolbox^C

ڭ̤гܨƪ̤pơCpGznMD humps b [0.3, 1] ̤pȡAi fminbnd OӧX̤pȪoIAҦpG

Example 1: 08-@ƾǨƪBzPR/fminbnd01.m[x, minValue] = fminbnd(@humps, 0.3, 1) % ϥ fminbnd OX̤pȪoI fplot(@humps, [0.3, 1]); grid on line(x, minValue, 'marker', 'o', 'color', 'r'); % Plot the minimum point x = 0.6370 minValue = 11.2528

ѤWҥiAMATLAB Do̤pȵoͦb x = 0.637AB̤pȬ 11.2528CYnDMD̤pȪL{Aiϥ optimset Oӳ]wܿﶵAAN optimset Ǧ^cܼưeJ fminbndAҦpG

Example 2: 08-@ƾǨƪBzPR/fminbnd02.mopt = optimset('disp', 'iter'); % ܨCӨBJG [x, minValue] = fminbnd(@humps, 0.3, 1, opt) Func-count x f(x) Procedure 1 0.567376 12.9098 initial 2 0.732624 13.7746 golden 3 0.465248 25.1714 golden 4 0.644416 11.2693 parabolic 5 0.6413 11.2583 parabolic 6 0.637618 11.2529 parabolic 7 0.636985 11.2528 parabolic 8 0.637019 11.2528 parabolic 9 0.637052 11.2528 parabolic Optimization terminated: the current x satisfies the termination criteria using OPTIONS.TolX of 1.000000e-04 x = 0.6370 minValue = 11.2528

WCX x ȪܤƤά۹ƭ f(x)A̫@CXDpȪkAq`OηjM]Golden Section Search^άOߪuk]Parabolic Interpolation^CѦCXrTiHDAҺX x Ȫ~tp 10 -4 C

YnP~tިA fminbnd Ǧ^p⵲GAi optimset ӹFCUұN x ~td򴣰 0.1G

Example 3: 08-@ƾǨƪBzPR/fminbnd03.mopt = optimset( 'disp', 'iter', 'TolX', 0.1); % ܨCӨBJGó]w~teԭ [x, minValue] = fminbnd(@humps, 0.3, 1, opt) Func-count x f(x) Procedure 1 0.567376 12.9098 initial 2 0.732624 13.7746 golden 3 0.465248 25.1714 golden 4 0.644416 11.2693 parabolic 5 0.611083 11.4646 parabolic 6 0.677749 11.7353 parabolic Optimization terminated: the current x satisfies the termination criteria using OPTIONS.TolX of 1.000000e-01 x = 0.6444 minValue = 11.2693

HWdҧOܨƨDέȡAYnDhܼƨƪȡAi fminsearch ODoAzw@Ӱ_lIAH fminsearch ڥHDXb_lI񪺧̤pȡ]Local Minima^C]zؼШƬOG $$f(x_1, x_2, x_3)=(x_1-1)^2+5(x_2-2)^2+(x_3-3)^2$$

zͤ@ MATLAB objective.mA䤺eiܦpUG

function y = objective(x) y = (x(1)-1).^2 + 5*(x(2)-2).^2 + (x(3)-3).^2;

Y_lI $(x_1, x_2, x_3)=(0, 0, 0)$Ahڭ̥iHJpUHD̤pȪoͦmG

Example 4: 08-@ƾǨƪBzPR/fminsearch01.mx0 = [0, 0, 0]; x = fminsearch(@objective, x0) x = 1.0000 2.0000 3.0000

fminsearch ϥΪkOUY Simplex jM]Downhill Simplex Search^AԲӰѦҸƥi ̪t@^ۧ@GuNeuro V Fuzzy and Soft Computingv, Prentice Hall, 1997C

MATLAB ̨Τƪk\hPﶵAoǿﶵOgѥt@ӿJ޼ơ]Input Argument^ӶiJ fminbnd fminsearchAϥλykG

x = fminbnd(@function, x1, x2, options)

x = fminsearch(@function, x0, options )

䤤 options O@ӵcܼơA]tQhANUس̨Τƪﶵ]ΰѼơ^C]wodz̨ΤƿﶵAi optimset OAϥλykG

options = optimset(prop1, value1, prop2, value2, K)

䤤 prop1Bprop2 OW١Avalue1Bvalue2 OȡCҦpApeҭzAYn MATLAB LXC@ӳ̨ΤƨBJGAéP~tdAhi]wpUG

Example 5: 08-@ƾǨƪBzPR/optimset01.moptions = optimset('Disp', 'iter', 'TolX', 0.1); fieldNames=fieldnames(options); fprintf('No. of fields = %d\n', length(fieldNames)); options No. of fields = 55 options = <a href="matlab:helpPopup struct" style="font-weight:bold">struct</a> with fields: Display: 'iter' MaxFunEvals: [] MaxIter: [] TolFun: [] TolX: 0.1000 FunValCheck: [] OutputFcn: [] PlotFcns: [] ActiveConstrTol: [] Algorithm: [] AlwaysHonorConstraints: [] DerivativeCheck: [] Diagnostics: [] DiffMaxChange: [] DiffMinChange: [] FinDiffRelStep: [] FinDiffType: [] GoalsExactAchieve: [] GradConstr: [] GradObj: [] HessFcn: [] Hessian: [] HessMult: [] HessPattern: [] HessUpdate: [] InitBarrierParam: [] InitTrustRegionRadius: [] Jacobian: [] JacobMult: [] JacobPattern: [] LargeScale: [] MaxNodes: [] MaxPCGIter: [] MaxProjCGIter: [] MaxSQPIter: [] MaxTime: [] MeritFunction: [] MinAbsMax: [] NoStopIfFlatInfeas: [] ObjectiveLimit: [] PhaseOneTotalScaling: [] Preconditioner: [] PrecondBandWidth: [] RelLineSrchBnd: [] RelLineSrchBndDuration: [] ScaleProblem: [] SubproblemAlgorithm: [] TolCon: [] TolConSQP: [] TolGradCon: [] TolPCG: [] TolProjCG: [] TolProjCGAbs: [] TypicalX: [] UseParallel: []

ѤWҥiAoptions @QhAHh̨ΤƫOݨDC]䥦̨ΤƫOiųΤƤuc]Optimization Toolbox^v^M options 첳hAƹWAäOC@ȳ|QΨApGܬOůx}AN MATLAB |ϥΦ쪺w]ȨӶiBCtAoptimset |ھڿJ̨ΤƨƦW٦Ӧ^ǤPGAҦpڭ̥iH˵P fminbnd ̨ΤƿﶵG

Example 6: 08-@ƾǨƪBzPR/optimset02.moptions = optimset('fminbnd'); fieldNames=fieldnames(options); fprintf('No. of fields = %d\n', length(fieldNames)); for i=1:length(fieldNames) if ~isempty(options.(fieldNames{i})) fprintf('options.%s=%s\n', fieldNames{i}, num2str(options.(fieldNames{i}))); end endNo. of fields = 55 options.Display=notify options.MaxFunEvals=500 options.MaxIter=500 options.TolX=0.0001 options.FunValCheck=off

bWƽdҤAڭ̯SONȬŦrꪺiRAH`ܪŶC

Yn˵P fminsearch ̨ΤƿﶵAiHJpU

Example 7: 08-@ƾǨƪBzPR/optimset03.moptions = optimset('fminsearch'); fieldNames=fieldnames(options); fprintf('No. of fields = %d\n', length(fieldNames)); for i=1:length(fieldNames) if ~isempty(options.(fieldNames{i})) fprintf('options.%s=%s\n', fieldNames{i}, num2str(options.(fieldNames{i}))); end end No. of fields = 55 options.Display=notify options.MaxFunEvals=200*numberofvariables options.MaxIter=200*numberofvariables options.TolFun=0.0001 options.TolX=0.0001 options.FunValCheck=off

P fminbnd M fminsearch n̨ΤƿﶵiHpUG

  1. Display Y 0 ]w]ȡ^AhܤB⵲GCϤAY 0AhܹBL{GC
  2. MaxFunEvals OƨDȹB]Function Evaluation^̰ơA fminbnd w]ȬO 500A fminsearch w]ȬO 200 W x0 סC
  3. MaxIter O̤j|NơA fminbnd w]ȬO 500A fminsearch w]ȬO 200 W x0 סC
  4. TolFun OMwפjMƭȮeԫסAw] $10^{-4}$]ﶵuQ fminsearch ΨAfminbnd äϥΡ^C
  5. TolX OMwפjMܼƭȮeԫסAw] $10^{-4}$C

Hint
  • ̨ΤƨëD@iΡAq`L{O@AСA̫~বĮ̃IC̨ΤƪGM_lIwܤjpF@Ө}n_lIA[ֳ̨ΤƦĪtסAǫ̂έȡ]Global Optimum^|C
  • P MATLABA optimset OǦ^ﶵi঳ҤPAOtʨäjC


MATLAB{]pGig