大连理工优化方法matlab,大连理工大学2016年秋季优化方法大作业.pdf
優化方法
期末上機大作業
姓 名:李嵐松
學 部:電信學部電氣工程
學 號
2016 年 11 月 9 日
1°最速下降法
//最速下降法主函數//
function lls=di1titidu(x)=di1titidu(x)
x0=x; eps=1e-4; k=0; g0=g(x0); s0=4; k=0; g0=g(x0); s0=-g0;
while (k>=0)
if norm(g0)
break;
else
lanmed=10;c=0.1;i=0; lanmed=10;c=0.1;i=0;
while i>=0&&i<100 100
x=x0+lanmed*s0;
if f(x)>(f(x0)+c*lanmed*g0'*s0) f(x)>(f(x0)+c*lanmed*g0'*s0)
lanmed=lanmed/2; lanmed=lanmed/2;
i=i+1;
else
break;
end
end
x=x0+lanmed*s0;
x0=x;
g0=g(x);
s0=-g0;
k=k+1;
end
end
lls=x;
sll=f(x);
fprintf('after %d iterations,obtain the optimal solution.iterations,obtain the optimal solution.\n\\nThe optimal
solution is %f.\n\n The optimal "x" is "ans".n The optimal "x" is "ans".\n',k,sll);
//f(x)//
function f=f(x)
x1=[1 0]*x;
x2=[0 1]*x;
f=(1-x1)^2+100*(x2-x1^2)^2;
//梯度函數//
function g=g(x)
x1=[1 0]*x;
x2=[0 1]*x;
g=[-2*(1-x1)-400*x1*(x2-x1^2);
200*(x2-x1^2)];
//運行過程//
>> x=[0;0]
x =
0
0
>> di1titidu(x)
after 4574 iterations,obtain the optimal solution.
The optimal solution is 0.000000.
The optimal "x" is "ans".
ans =
1.0001
1.0002
2 °牛頓法
//牛頓法主函數//
function s=di2tinewton(x)
x0=x; eps=1e-4; k=0;
g0=g(x0); h0=h(x0);s0=-inv(h0)*g0;
while (k>=0&&k<1000)
if norm(g0)
break;
else
x=x0+s0;
x0=x;
g0=g(x);
h0=h(x);
s0=-in
總結
以上是生活随笔為你收集整理的大连理工优化方法matlab,大连理工大学2016年秋季优化方法大作业.pdf的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AMD Zen 4装机成本曝光:果断攒钱
- 下一篇: 脸书二号人物桑德伯格14年后离职:自曝原