Optimization terminated: first-order optimality less than OPTIONS.TolFun, and no negative/zero curvature detected in trust region model.

4 Ansichten (letzte 30 Tage)
When TolFun is 1e-6, I got the above message in 0th iteration. So no further iteration is not going on. How i will solve that problem.

Antworten (1)

Matt J
Matt J am 15 Apr. 2014
Bearbeitet: Matt J am 15 Apr. 2014
It might be good news. The optimization might have succeeded. Call whatever function it is you're using with more output arguments, so you can check the value of the gradient and other diagnostic information, like the EXITFLAG, output.firstorderopt, and output.stepsize
  4 Kommentare
smitirupa
smitirupa am 17 Apr. 2014
Bearbeitet: Matt J am 17 Apr. 2014
*M-function file*
function er_norm=obj_fun(constants,xdata,ydata)
% x=xdata;
% y=ydata;
C0=constants(1);C1=constants(2);C2=constants(3);C3=constants(4);C4=constants(5)
% C4=constants(5);
% c5=constants(4);
ynew=C0+C1*xdata.^1+C2*xdata.^2+C3*xdata.^3+C4*xdata.^4
% er_norm=norm(ynew-ydata)
Run file
clear;
clc;
format long
data=xlsread('uic60.xlsx');
options = optimset('Display','iter','MaxIter',1e6,'TolFun',1e-32,'MaxFunEvals',1e4,'TolX',1e-12);
xdata=data(:,1);
ydata=data(:,2);
C0=0.0013e-5; C1=0.05e-5; C2=0.050e-8; C3=1e-8; C4=1e-8;
constants=[C0 C1 C2 C3 C4 ];
x0=[C0 C1 C2 C3 C4];
f=@(x,xdata)C0+C1*xdata.^1+C2*xdata.^2+C3*xdata.^3+C4*xdata.^4
C0=constants(1); C1=constants(2); C2=constants(3); C3=constants(4); C4=constants(5);
[x,resnorm,residual,exitflag,output]=lsqcurvefit(f,x0,xdata,ydata,[],[],options)
hold on
plot(xdata,ydata,xdata,f(x,xdata))
hold off
Output
Iteration Func-count f(x) step optimality CG-iterations
0 6 0.0213194 0
Optimization terminated: first-order optimality less than OPTIONS.TolFun,
and no negative/zero curvature detected in trust region model.
x =
1.0e-006 *
0.013000000000000 0.500000000000000 0.000500000000000 0.010000000000000 0.010000000000000
resnorm =
0.021319448979382
residual =
0.022935647666543
0.023656562500035
0.024356871699866
0.025019867046445
0.025633290174737
0.026185655588680
0.026669444268175
0.027079640891809
0.027413127048670
0.027667330252872
0.027840305551303
0.027930623282206
0.027937480382255
0.027860616651143
0.027700403307839
0.027458049835533
0.027135791605277
0.026741063395763
0.026286298265767
0.025780306693696
0.025228612201459
0.024635093285392
0.024001373315168
0.023328973281281
0.022619515997451
0.021874698169094
0.021096298908960
0.020286164636195
0.019446186558797
0.018578369810777
0.017684771000595
0.016768921428978
0.015839440091998
0.014902604350151
0.013962464085410
0.013024009034124
0.012094644594510
0.011183955871576
0.010300513176566
0.009450913772099
0.008640223741933
0.007873802280339
0.007156439816903
0.006492522579311
0.005885429179882
0.005337132152756
0.004847230419930
0.004412992162858
0.004028749502575
0.003687592949644
0.003381492624863
0.003103786830481
0.002849529871807
0.002615211321742
0.002398800414927
0.002198575461979
0.002013065540527
0.001840938989762
0.001681007933138
0.001532206494037
0.001393597821352
0.001264345981194
0.001143720532711
0.001031070393152
0.000925826840403
0.000827481436292
0.000735587976429
0.000649744912417
0.000569596612284
0.000494819910255
0.000425124919974
0.000360244998115
0.000299937263116
0.000243975168336
0.000192148814180
0.000144259366930
0.000100119206205
0.000059547532453
0.000022370360660
-0.000011583201362
-0.000042481120883
-0.000070491855813
-0.000095784700387
-0.000118533101906
-0.000138915199198
-0.000157117092201
-0.000173333578265
-0.000187771275313
-0.000200649542713
-0.000212203214292
-0.000222683663747
-0.000232360766126
-0.000241524032413
-0.000250483286458
-0.000259569749041
-0.000269134790273
-0.000279550789851
-0.000291207202182
-0.000304510957187
-0.000319878960482
-0.000337737729934
-0.000358511358458
-0.000382620009492
-0.000410462318839
-0.000442412301963
-0.000478795192309
-0.000519882244883
-0.000565859108261
-0.000616776225174
-0.000671469488819
thanx
Matt J
Matt J am 17 Apr. 2014
Bearbeitet: Matt J am 19 Apr. 2014
LSQCURVEFIT is trying to minimize your objective function
f=@(x,xdata)C0+C1*xdata.^1+C2*xdata.^2+C3*xdata.^3+C4*xdata.^4
as a function of 'x'. However, the function you've provided has no actual dependence on x, only on xdata. So, since all points have zero gradient, lsqcurvefit stops with any initial point x0 that you choose.
If your goal is to fit xdata,ydata to a one-dimensional 4th order polynomial, you should just use POLYFIT,
constants=polyfit(xdata,ydata,4);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Least Squares finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by