Jacobian elements in the row are very small Topic is solved

Problems with modeling
Post Reply
Alexanre.ito
User
User
Posts: 38
Joined: 4 years ago

Jacobian elements in the row are very small

Post by Alexanre.ito »

Hi,
I'm using the SBB solver as MINLP.
in my model have some equations that the variables are very small, between [0.001 , 0.1]. So I use ".scale".

But some equations still have this problem.
Some equations have power lower than 1 (ex. var**0.47), so I change the equation to ( var1 **100 =e= ....var**47; )
Solve the problem but transfer to the other equation the same situation.

Now I'm trying to ".scale" the equations.

But I'd like to know if is the correct form to solve this problems.
Some have something to share.

Code: Select all

inmi(nnd)..      ir(nnd)*ir1(nnd) =g= 0.0055;
inmi1(nnd)..     ir1(nnd)**100 =e= qr(nnd)**(47)*arcbin(nnd);
inma(nnd)..      (ir(nnd)**3)*(qr(nnd)**2) =l= (2.73**3)*arcbin(nnd);
cprm(nn,d)..     lr(nn,d) =e= ir(nn,d)*distxy(nn) ;

manning(nnd)..  mann*qr(nnd)*pm1(nnd) =e= am1(nnd)*ir2(nnd)*arcbin(nnd);

amol1(nnd)..    am1(nnd)**3    =e= am(nnd)**5;
pmol1(nnd)..    pm1(nnd)**3    =e= pm(nnd)**2;
inmi2(nnd)..    ir2(nnd)**2    =e= ir(nnd)*arcbin(nnd);
angull(nn,d)..   thetaa(nn,d) =e= 2*yr(nn,d)/dc(d)*arcbin(nn,d);
angul(nn,d)..    theta(nn,d)  =e= 2*arccos(1-thetaa(nn,d))*arcbin(nn,d)
                                  *arcbin(nn,d);
                                  
frud(nnd)..     fr(nnd)*fr1(nnd) =e= fr2(nnd);

frud1(nnd)..    fr1(nnd)   =e=  sqrt(g*am(nnd))*am(nnd);

frud2(nnd)..    fr2(nnd)   =e= qr(nnd)*b(nnd)*arcbin(nnd);                                 
The .lst show errors like

Code: Select all

 inmi(n1,n2,d1): Infeasible row with only small Jacobian elements.
    inmi(n1,n2,d2): Infeasible row with only small Jacobian elements.
    inmi(n1,n2,d3): Infeasible row with only small Jacobian elements.
    inmi(n1,n2,d4): Infeasible row with only small Jacobian elements.
    inmi(n1,n2,d5): Infeasible row with only small Jacobian elements.
    inmi(n1,n2,d6): Infeasible row with only small Jacobian elements.
    inmi1(n1,n2,d1): All Jacobian elements in the row are very small.
    inmi1(n1,n2,d2): All Jacobian elements in the row are very small.
    inmi1(n1,n2,d3): All Jacobian elements in the row are very small.
    inmi1(n1,n2,d4): All Jacobian elements in the row are very small.
    inmi1(n1,n2,d5): All Jacobian elements in the row are very small.
    inmi1(n1,n2,d6): All Jacobian elements in the row are very small.
    inmi2(n1,n2,d1): All Jacobian elements in the row are very small.
    inmi2(n1,n2,d2): All Jacobian elements in the row are very small.
    inmi2(n1,n2,d3): All Jacobian elements in the row are very small.
    inmi2(n1,n2,d4): All Jacobian elements in the row are very small.
    inmi2(n1,n2,d5): All Jacobian elements in the row are very small.
    inmi2(n1,n2,d6): All Jacobian elements in the row are very small.
    manning(n1,n2,d1): All Jacobian elements in the row are very small.
    manning(n1,n2,d2): All Jacobian elements in the row are very small.
    manning(n1,n2,d3): All Jacobian elements in the row are very small.
    manning(n1,n2,d4): All Jacobian elements in the row are very small.
    manning(n1,n2,d5): All Jacobian elements in the row are very small.
    manning(n1,n2,d6): All Jacobian elements in the row are very small.
    amol1(n1,n2,d1): All Jacobian elements in the row are very small.
    amol1(n1,n2,d2): All Jacobian elements in the row are very small.
    amol1(n1,n2,d3): All Jacobian elements in the row are very small.
    amol1(n1,n2,d4): All Jacobian elements in the row are very small.
    amol1(n1,n2,d5): All Jacobian elements in the row are very small.
    amol1(n1,n2,d6): All Jacobian elements in the row are very small.
    pmol1(n1,n2,d1): All Jacobian elements in the row are very small.
    pmol1(n1,n2,d2): All Jacobian elements in the row are very small.
    pmol1(n1,n2,d3): All Jacobian elements in the row are very small.
    pmol1(n1,n2,d4): All Jacobian elements in the row are very small.
    pmol1(n1,n2,d5): All Jacobian elements in the row are very small.
    pmol1(n1,n2,d6): All Jacobian elements in the row are very small.
    cofan(n1,n2,d1): All Jacobian elements in the row are very small.
    cofan(n1,n2,d2): All Jacobian elements in the row are very small.
    cofan(n1,n2,d3): All Jacobian elements in the row are very small.
    cofan(n1,n2,d4): All Jacobian elements in the row are very small.
    cofan(n1,n2,d5): All Jacobian elements in the row are very small.
    cofan(n1,n2,d6): All Jacobian elements in the row are very small.
    cofan(n2,n1,d1): All Jacobian elements in the row are very small.
    cofan(n2,n1,d2): All Jacobian elements in the row are very small.
    cofan(n2,n1,d3): All Jacobian elements in the row are very small.
    cofan(n2,n1,d4): All Jacobian elements in the row are very small.
    cofan(n2,n1,d5): All Jacobian elements in the row are very small.
    cofan(n2,n1,d6): All Jacobian elements in the row are very small.
and

Code: Select all

**** ERRORS/WARNINGS IN EQUATION angul(n1,n2,d1)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n1,n2,d2)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n1,n2,d3)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n1,n2,d4)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n1,n2,d5)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n1,n2,d6)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n2,n1,d1)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n2,n1,d2)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n2,n1,d3)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n2,n1,d4)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n2,n1,d5)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION angul(n2,n1,d6)
     5 warning(s): arccos: GRAD SINGULAR: x = 1

**** ERRORS/WARNINGS IN EQUATION frud1(n1,n2,d1)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION frud1(n1,n2,d2)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION frud1(n1,n2,d3)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION frud1(n1,n2,d4)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION frud1(n1,n2,d5)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION frud1(n1,n2,d6)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION vel(n1,n2,d1)
     5 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n1,n2,d2)
     5 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n1,n2,d3)
     5 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n1,n2,d4)
     5 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n1,n2,d5)
     5 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n1,n2,d6)
     5 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n2,n1,d1)
     6 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n2,n1,d2)
     6 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n2,n1,d3)
     6 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n2,n1,d4)
     6 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n2,n1,d5)
     6 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION vel(n2,n1,d6)
     6 warning(s): vcPower: GRAD SINGULAR: x**c, x=0, 0<c<1

**** ERRORS/WARNINGS IN EQUATION velc(n1,n2,d1)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION velc(n1,n2,d2)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION velc(n1,n2,d3)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION velc(n1,n2,d4)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION velc(n1,n2,d5)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0

**** ERRORS/WARNINGS IN EQUATION velc(n1,n2,d6)
     5 warning(s): sqrt: GRAD SINGULAR: x = 0
Thanks
User avatar
dirkse
Moderator
Moderator
Posts: 215
Joined: 7 years ago
Location: Fairfax, VA

Re: Jacobian elements in the row are very small

Post by dirkse »

Hi,

You don't say what symbols are variables and what are parameters (attaching the whole code would take care of this), so I will make some assumptions.

You mention you have "(ex. var**0.47), so I change the equation to ( var1 **100 =e= ....var**47; )". This is not a good idea. x**0.47 is similar to sqrt(x) - this evaluates very nicely if you keep the x nicely positive. x >= 1e-10 is not nice. x >= 1e-2 is nice.

Your errors

Code: Select all

    inmi(n1,n2,d1): Infeasible row with only small Jacobian elements.
    inmi(n1,n2,d2): Infeasible row with only small Jacobian elements.
are about this equation:

Code: Select all

inmi(nnd)..      ir(nnd)*ir1(nnd) =g= 0.0055;
I'm guessing both ir and ir1 are variables. Do they have any bounds on them? In any case, if you start with the default initial point - zero - your Jacobian will also be zero. This will be a challenge for the solver. Try to make both ir and ir1 positive at the initial point.

Re: the next error:

Code: Select all

**** ERRORS/WARNINGS IN EQUATION angul(n1,n2,d1)
     5 warning(s): arccos: GRAD SINGULAR: x = 1
This is saying that at the initial point, the input to the arccos function is 1. If cos(x) = 1, then f(x)=cos(x) is at a max so the derivative of f(x) = 0. This implies that for the inverse function, the derivative is infinite/undefined at this point. If you use a function like arccos(y) in a model, you should constrain y to be nicely between -1 and 1. Again, don't try to get to close to -1 or 1 either. Nothing good is going to happen to arccos(y) and its derivatives as y approaches -1 or 1.

HTH,

-Steve
Alexanre.ito
User
User
Posts: 38
Joined: 4 years ago

Re: Jacobian elements in the row are very small

Post by Alexanre.ito »

Thanks for your time, and I'm sorry if I was not so clear,
Your assumptions is right. Changed the situation but still not working.

"ir1 are variables. Do they have any bounds on them?"
Yes, here it is: they are too small so I tried the scalar function, explained at the end.

Code: Select all

Scalars	 
	 imin      slope Min                (m per m)      /  0.001  /
         imax     slope Máx                 (m per m)      /  0.10   /;
         
*  bounds  
ir.lo(n,n,d)     = imin  ;    ir.up(n,n,d)     = imax  ;
I try use the Scale function, but I'm not sure what is going on. I Think that the GAMS is multiplying the equation to approximate the constants to values greater than 1.

Code: Select all

Rede.ScaleOpt = 1;
ir.scale(n,np,d) = imin;
Probably the ir varialble, is ok now.

Now my error is:

Code: Select all

*** Error at line 605: log10: FUNC SINGULAR: x = 0
--- RedeEsg2_2020_06_14.gms(623) 6 Mb 1 Error
*** Error at line 623: log: FUNC SINGULAR: x = 0
--- RedeEsg2_2020_06_14.gms(632) 6 Mb 2 Errors
*** Error at line 632: log: FUNC SINGULAR: x = 0
--- RedeEsg2_2020_06_14.gms(636) 6 Mb 3 Errors
*** Error at line 636: log: FUNC SINGULAR: x = 0
--- RedeEsg2_2020_06_14.gms(772) 4 Mb 4 Errors
*** SOLVE aborted
3 SETs (n - node, nn - arc and d - diameter)
The variable SET (nn and nnd)
Parameter are 3 here: ((1)-nn(n,np), (2)-dc(d) commercial diameter, (3)-nnd(n,n,d)).
the others are variables
kpvc is a Scalar.

Code: Select all

 605  ccrf(nn,d)..    crf(nn,d)*crf1(nn,d)  =e=
 606                               (-2)*sqr(2)* log10(crf2(nn,d)+crf3(nn,d));
 607  ccrf1(nn,d)..    crf1(nn,d)              =e=    3.83*rr(nn,d)**0.105 ;
 608  ccrf2(nn,d)..    crf2(nn,d)*3.7*dc(d)    =e=    kpvc;
 609  ccrf3(nn,d)..    crf3(nn,d)*rr(nn,d)     =e=    1.78 ;
 
 623  fator5(nn,d)..   fatt5(nn,d)*(log( fatt2(nn,d) + fatt3(nn,d))
 624                                                         - fatt4(nn,d))**(16) =e=  1;
 
 632  fatoz5(nn,d)..   fatz5(nn,d)*(log( fatz2(nn,d) + fatz3(nn,d) )
 633                                                          - fatz4(nn,d) )**(16) =e=  1;
 
 636  admfat(nn,d)..   fatt(nn,d) =e= (1 - 0.377*log(epl(nn,d))
 637                                                - 0.546*(epl(nn,d)-1)
 638                                               + 0.104*(epl(nn,d)-1)*(epl(nn,d)-1))*fatz(nn,d);
 
I have a variable that is binary, so I have to try the existency of the connection of the nothes (nn) with the comertial diameter (dc(d)).
So i'm using the PRIOR function, to test the SET diameters and the order of arc nn(n,np) or nn(np,n). Have some arcs that will not exist.
Only one of the composition nnd(n,n, d) will be used, the others will be zero.

I think that (binary variable) is the problem with the LOG and LOG10. I tried some $ conditions at the equations, depending of dc(d), the arc (nn),nnd(nn,d), but was not helpful.

Code: Select all

ccrf(nn,d)$dc(d)..    crf(nn,d)*crf1(nn,d)  =e=
                           (-2)*sqr(2)* log10(crf2(nn,d)+crf3(nn,d));
or                           
         ccrf(nn,d)$nn..    crf(nn,d)*crf1(nn,d)  =e=
                           (-2)*sqr(2)* log10(crf2(nn,d)+crf3(nn,d));
or                                             
         ccrf(nn,d)$nnd(nn,d)..    crf(nn,d)*crf1(nn,d)  =e=
                           (-2)*sqr(2)* log10(crf2(nn,d)+crf3(nn,d));                  
                           
I'd like an opinion, I'm realy lost.
I've read many manuals (one that have more than 2000 pgs), looked for articles, all the exemples of Model Library.
So, I don't know if I'm right or wrong, or what I'm doing is right or wrong, or what I'm supposed to do.

Thanks a lot for your time.
dirkse wrote: 3 years ago Hi,

You don't say what symbols are variables and what are parameters (attaching the whole code would take care of this), so I will make some assumptions.

You mention you have "(ex. var**0.47), so I change the equation to ( var1 **100 =e= ....var**47; )". This is not a good idea. x**0.47 is similar to sqrt(x) - this evaluates very nicely if you keep the x nicely positive. x >= 1e-10 is not nice. x >= 1e-2 is nice.

Your errors

Code: Select all

    inmi(n1,n2,d1): Infeasible row with only small Jacobian elements.
    inmi(n1,n2,d2): Infeasible row with only small Jacobian elements.
are about this equation:

Code: Select all

inmi(nnd)..      ir(nnd)*ir1(nnd) =g= 0.0055;
I'm guessing both ir and ir1 are variables. Do they have any bounds on them? In any case, if you start with the default initial point - zero - your Jacobian will also be zero. This will be a challenge for the solver. Try to make both ir and ir1 positive at the initial point.

Re: the next error:

Code: Select all

**** ERRORS/WARNINGS IN EQUATION angul(n1,n2,d1)
     5 warning(s): arccos: GRAD SINGULAR: x = 1
This is saying that at the initial point, the input to the arccos function is 1. If cos(x) = 1, then f(x)=cos(x) is at a max so the derivative of f(x) = 0. This implies that for the inverse function, the derivative is infinite/undefined at this point. If you use a function like arccos(y) in a model, you should constrain y to be nicely between -1 and 1. Again, don't try to get to close to -1 or 1 either. Nothing good is going to happen to arccos(y) and its derivatives as y approaches -1 or 1.

HTH,

-Steve
Post Reply