always this message : The first-order optimality measure, 0.0, is less than options

2 次查看(过去 30 天)
hello all,
Recently I came to the forum to ask for help about the functions of the tool box "optimization". I used "lsqnonlin" "lsqcurvefit" "finminuc" and every time I the same result:
my optimization stops after one iteration and the result: The first-order optimality measure, 0.000000e +000, IS = Less than options.TolFun 1.000000e-006.
after reading the documentation, it understand that is possible that i have a local minimum, yet when I change a little the starting values i have always the same problem: it seems odd to me that every time I put a game parameters of the algorithm says I have a local minimum?!?
can you tell me your opinion on that and how can I solve this. thank you very much

回答(3 个)

21did21
21did21 2011-11-7
Gamma=0.21;
A=5100;
B=-0.07;
parametresInitiaux=[Gamma A B];
lb=[0.13 3500 -1.5];
ub=[2.6 8000 5];
options = optimset('Display','iter','MaxIter',40,'TolX',1e-16,'TolFun',1e-25)
[x,resnorm] = lsqnonlin(@calculs,parametresInitiaux,lb,ub,options);
and for calculs:
function RESIDU=calculs(parametresI)
[Rm_num,Fv_num] = WriteCalculTreatment(parametresI(1),parametresI(2),parametresI(3));
RmMine=Rm_num;
FvMine=Fv_num;
residuVect=abs(Rm_exp-Rm_num)+abs(Fv_exp-Fv_num);
RESIDU=residuVect';
the function "WriteCalculTreatment" launch calculations from a software to get Rm_num et Fv_num
when i use fminuc i do this in my function "calcul"
residuVect=(Rm_exp-Rm_num)'*(Rm_exp-Rm_num)+(Fv_exp-Fv_num)'*(Fv_exp-Fv_num);
RESIDU=residuVect;
  2 个评论
Jan
Jan 2011-11-7
Please post the code by editing the original image and use code formatting as explained in the "Markup help" link. In the current form, the code is not readable.
Walter Roberson
Walter Roberson 2011-11-7
We would need to see WriteCalculTreatment to determine more.
What also need to see the functions Rm_exp and Fv_exp. We deduce they are functions because if they were variables they would have to be initialized within the scope of calculs.
Why do you bother to set RmMine or FvMine ? They are not global or persistent variables, so their value is going to be thrown away (unless they happen to be shared within a scope that you do not show us.)

请先登录,再进行评论。


21did21
21did21 2011-11-7
thank for your help !
Jan : i have already put the matlab code with code formatting...?
Walter : Rm_exp and Fv_exp are global variables. RmMine and FvMine are not necessary.
the function "writeCalculTreatment" is this :
function [Rm_num,Rv_num]=WriteCalculTreatment(Gamma1,A1,B1,DO_mg,DO_si,timeT6)
currentFolder=cd('E:\methodeINVERSE'); T6folder = cd('E:\methodeINVERSE\T6'); T200folder = cd('E:\methodeINVERSE\T200'); T300folder = cd('E:\methodeINVERSE\T300'); T400folder = cd('E:\methodeINVERSE\T400'); T500folder = cd('E:\methodeINVERSE\T500'); T560folder = cd('E:\methodeINVERSE\T560');
currentFolder='E:\methodeINVERSE';
T6folder = 'E:\methodeINVERSE\T6';
T200folder = 'E:\methodeINVERSE\T200';
T300folder = 'E:\methodeINVERSE\T300';
T400folder = 'E:\methodeINVERSE\T400';
T500folder = 'E:\methodeINVERSE\T500';
T560folder = 'E:\methodeINVERSE\T560';
writeT6DataFile(Gamma1,A1,B1,DO_mg,DO_si,timeT6,T6folder,currentFolder);
writeDataFile(Gamma1,A1,B1,DO_mg,DO_si,T200folder,currentFolder);
writeDataFile(Gamma1,A1,B1,DO_mg,DO_si,T300folder,currentFolder);
writeDataFile(Gamma1,A1,B1,DO_mg,DO_si,T400folder,currentFolder);
writeDataFile(Gamma1,A1,B1,DO_mg,DO_si,T500folder,currentFolder);
writeDataFile(Gamma1,A1,B1,DO_mg,DO_si,T560folder,currentFolder);
%%on lance calcul T6 et on transfert ces resultats dans autres dossier
launchT6calcul(T6folder,currentFolder);
%%on ecrit toutes les distributions initiales et lance les calculs
%associés
writeInputFile(T200folder,currentFolder);
writeInputFile(T300folder,currentFolder);
writeInputFile(T400folder,currentFolder);
writeInputFile(T500folder,currentFolder);
writeInputFile(T560folder,currentFolder);
%%detection de la fin des resultats
finishCalculation(T200folder,currentFolder);
finishCalculation(T300folder,currentFolder);
finishCalculation(T400folder,currentFolder);
finishCalculation(T500folder,currentFolder);
finishCalculation(T560folder,currentFolder);
%%traitement des resultats
resultRayon=zeros(6,1);
resultFraction=zeros(6,1);
[R1,F1]=resultTreatment(T6folder,currentFolder);
resultRayon(1,1)=R1;
resultFraction(1,1)=F1;
[R2,F2]=resultTreatment(T200folder,currentFolder);
resultRayon(2,1)=R2;
resultFraction(2,1)=F2;
[R3,F3]=resultTreatment(T300folder,currentFolder);
resultRayon(3,1)=R3;
resultFraction(3,1)=F3;
[R4,F4]=resultTreatment(T400folder,currentFolder);
resultRayon(4,1)=R4;
resultFraction(4,1)=F4;
[R5,F5]=resultTreatment(T500folder,currentFolder);
resultRayon(5,1)=R5;
resultFraction(5,1)=F5;
[R6,F6]=resultTreatment(T560folder,currentFolder);
resultRayon(6,1)=R6;
resultFraction(6,1)=F6;
%%renvoi des donnees
Rm_num=resultRayon;
Rv_num=resultFraction;
here i write data for the software and i launch calculs with the software and i retrieve results. => when i use my programm without lsqnonlin it works nice (my resultats are the results which i have directly with the software) => when i use lsqnonlin it says that the gradient of my function is null ??? (but if i change the value manually i can see what i haven't a minimum...)
  1 个评论
Walter Roberson
Walter Roberson 2011-11-7
No variable is global unless it has been declared as global in the scope of the routine that is using it. The most obvious way to do that is with a "global" statement right inside calculs; the other methods require that the various routines be "nested" within the routine that declares the variable as global.
Your WriteCalculTreatment function needs all 6 of the variables declared in its header, as it attempts to pass all 6 of them to WriteT6DataFile() . Your calcul() routine is, however, only passing three parameters to WriteCalculTreatment

请先登录,再进行评论。


21did21
21did21 2011-11-10
1°) thank walter i will see this
2°) i have one general question :
how i can increase the discretisation for the gradient in all this optimization function ?

类别

Help CenterFile Exchange 中查找有关 Financial Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by