等式约束极值问题-外点罚函数法

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

重庆科技学院学生实验报告

附录function [x,minf] = minGeneralPF(f,x0,h,c1,p,var,eps) format long;

if nargin == 6

eps = 1.0e-4;

end

k = 0;

FE = 0;

for i=1:length(h)

FE = FE + (h(i))^2;

end

x1 = transpose(x0);

x2 = inf;

while 1

M = c1*p;

FF = M*FE;

SumF = f + FF;

[x2,minf] = minNT(SumF,transpose(x1),var);

if norm(x2 - x1)<=eps

x = x2;

break;

else

c1 = M;

x1 = x2;

end

end

minf = subs(f,var,x);

format short;

%牛顿法求解无约束最优化问题

function [x,minf] = minNT(f,x0,var,eps)

format long;

if nargin == 3

eps = 1.0e-6;

end

tol = 1;

x0 = transpose(x0);

gradf = jacobian(f,var);

jacf = jacobian(gradf,var);

while tol>eps

v = subs(gradf,var,x0);

tol = norm(v);

pv = subs(jacf,var,x0);

p = -inv(pv)*transpose(v);

p = double(p);

x1 = x0 + p;

x0 = x1;

end

x = x1;

minf = subs(f,var,x);

format short;

>> syms x y;

>> minGeneralPF(x^2+y^2,[1,1],y^2-1,1000,10,[x,y],0.0001) ans =

1.0000

相关文档
最新文档