six-hump camelback.m

来自「通用模拟退火优化算法 General simulated annealing 」· M 代码 · 共 28 行

M
28
字号
%six-hump camelback"函数形式为
camel = @(x,y)(4-2.1*x.^2+x.^4/3).*x.^2+x.*y+4*(y.^2-1).*y.^2;
%我们先将该函数化成标准形式
loss = @(p)camel(p(1),p(2));
%ANNeAL的调用格式和matlab优化工具箱中的大部分函数相似
%[minimum,fval] = anneal(loss, x0 options),loss是优化函数;x0是初值;options是参数设置,详见help anneal
[x f] = anneal(loss,[0 0])
You can improve the performance of your code by using exact
name matches and we therefore recommend that you update your
usage accordingly. Alternatively, you can disable this warning using
warning('off','MATLAB:dispatcher:InexactCaseMatch').
This warning will become an error in future releases.

  Initial temperature:      1
  Final temperature:        4.01735e-007
  Consecutive rejections:   1153
  Number of function calls: 5993
  Total final loss:         -1.03163

x =

    0.0897   -0.7128


f =

   -1.0316

⌨️ 快捷键说明

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