📄 six-hump camelback.m
字号:
%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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -