主要内容

运行解算器

通过调用run进行优化

运行求解器几乎是相同的GlobalSearchMultiStart.语法上的唯一区别是MultiStart接受描述起始点的附加输入。

例如,假设你想找到一些局部极小值sixmin函数

sixmin = 4x2- 2.1x4+x6/ 3 +xy- 4y2+ 4y4

生成图形的代码

这个函数也称为六峰驼背函数[3].所有的局部极小值都在区域内3≤xy≤3

使用GlobalSearch运行的示例

求其若干局部极小值sixmin函数使用GlobalSearch,输入:

% %设置随机流以获得完全相同的输出% rng(14,'twister') gs = GlobalSearch;选择= optimoptions (@fmincon、“算法”、“内点”);sixmin = @ (x) (4 * x (1) ^ 2 - 2.1 * (1) ^ 4 + x(1) ^ 6/3……x(1)*x(2) - 4*x(2)^2 + 4*x(2)^4;问题= createOptimProblem (fmincon, x0,[1、2],…sixmin“客观”,“磅”,[3 3],乌兰巴托,3,3,…“选项”,选择);[xm,调频,兴,outptg manyminsg] =运行(gs、问题);

运行的输出(根据随机种子的不同而不同):

xm,调频,弗拉格,outptg manyminsg xm = 0.0898 -0.7127 fm = -1.0316兴= 1 outptg =结构体字段:funcCount: 2115 localSolverTotal: 3 localSolverSuccess: 3 localSolverIncomplete: 0 localSolverNoSolution: 0消息:“GlobalSearch停止,因为它分析所有的审判阿宝……' manyminsg = 1x2 GlobalOptimSolution数组的属性:X Fval Exitflag输出X0

使用MultiStart运行的示例

求其若干局部极小值sixmin函数使用50次运行fminconMultiStart,输入:

% %设置随机流以获得完全相同的输出% rng(14,'twister') ms = MultiStart;选择= optimoptions (@fmincon、“算法”、“内点”);sixmin = @ (x) (4 * x (1) ^ 2 - 2.1 * (1) ^ 4 + x(1) ^ 6/3……x(1)*x(2) - 4*x(2)^2 + 4*x(2)^4;问题= createOptimProblem (fmincon, x0,[1、2],…sixmin“客观”,“磅”,[3 3],乌兰巴托,3,3,…“选项”,选择);[xminm, fminm flagm、outptm manyminsm] =运行(女士,问题,50);

运行的输出(根据随机种子而变化):

xminm,fminm,flagm,outptm,manyminsm xminm = 0.0898 -0.7127 fminm = -1.0316 flagm = 1 outptm = struct with fields: funcCount: 2034 localSolverTotal: 50 localSolverSuccess: 50 localSolverIncomplete: 0 localSolverNoSolution: 0 message: 'MultiStart completed the runs from all start points。manyminsm = 1x6 GlobalOptimSolution数组的属性:X Fval Exitflag输出X0

在这种情况下,MultiStart定位所有六个局部极小值,而GlobalSearch位于两个。浏览有关MultiStart金宝搏官方网站解决方案,请参阅想象吸引力的盆地

相关的话题