Some trick in NLconstraint to avoid NaN or Inf for zero initial condition ?

Hello all,

I am new using JuMP. In my code, I added a thermodynamic model (UNIQUAC). When xNT1 = 0.001 it work well. But when the value is almost zero (1e-11) it doesn’t work and JuMP give me “Warning: Cutting back alpha due to evaluation error”, “WARNING: Problem in step computation; switching to emergency mode.” and others warnings because of the term “ΨNT1/xNT1”.

@NLconstraint(m, log(gamNT1) == ((log(ΨNT1/xNT1) + (z/2.0)*q[1]*log(θNT1/ΨNT1) + lj[1] - (ΨNT1/xNT1)*(xNT1*lj[1]+xNT2*lj[2]+xNT3*lj[3]+xNT4*lj[4])) + (q[1]*(1.0-log(fNT1)-(dNT1))) ) )

I tried to use “ConditionalJuMP.jl” but I am using ipopt solver and it gives me that ipopt “Solver does not support discrete variables”
So, there is some way to avoid that problem?
In MATLAB I just use the if condition.
If xNT1 == 0
gamNT1 = 1
else
log(gamNT1) == ((log(ΨNT1/xNT1) +…,

Sorry, everyone,
I solved the problem.

2 Likes

Hi, how did you did it?

1 Like

If you have log(x), add a constraint that x >= 0.001 (or some appropriate small positive value). You can also set the initial value of a variable using the start keyword:

@variable(model, x >= 0.001, start = 1)

1 Like