有MATLAB大神吗,输入参数太多怎么调整,请具体说下
(1)main.m:clearallclcn=50;x0=10*rand(n,1)delta=1;[x,k]=SCGM(x0,delta)(2)SCGM.m:functi...
(1)main.m:clear allclcn = 50;x0 = 10*rand(n,1)delta = 1;[x,k] = SCGM(x0,delta)(2)SCGM.m:function [s]= SCGM(g,B,epsilon,delta)n = length(g);x = zeros(n,1);r0 = g;r = r0;p = -g;flag = 1;if sqrt(sum(r0.^2)) < epsilon s = x; flag = 0;endwhile flag if p'*B*p <= 0 tau = ecfc(p'*p,2*x'*p,x'*x-delta^2); s = x+tau*p; flag = 0; disp('非正曲率') continue; end alpha = (r'*r)/(p'*B*p); x_t = x+alpha*p; if sqrt(sum(x_t.^2)) >= delta tau = ecfc(p'*p,2*x'*p,x'*x-delta^2); s = x+tau*p; flag = 0; disp('达到信赖域边界') continue; end r_t = r+alpha*B*p; if sqrt(sum(r_t.^2)) < epsilon*sqrt(sum(r0.^2)) s = x_t; flag = 0; disp('满足停止测试') continue; end beta = (r_t'*r_t)/(r'*r); p = -r_t+beta*p; x = x_t; r = r_t;endk = k-1;
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询