AmplNLWriter, NLexpression, can't evaluate pow('(0,0.45),

Hi all,

I am trying include a power expression in my objective function. and I get an error “can’t evaluate pow’(0,0.45)”, even though I forced my variables to start from 1e-20. Has anyone an idea why?

using JuMP
using AmplNLWriter
using Ipopt

m = Model(with_optimizer(AmplNLWriter.Optimizer, /path_to_couenne.exe"))

@variable(m, x[1:NP, 1:NP] >= 1e-20 )
@variable(m, c[1:NP, 1:NC] >= 1e-20)
@variable(m, t[1:NP, 1:NP, 1:NT], Bin)
@variable(m, 0<= TP[1:NP, 1:NP] <= 100)

@constraint(m, 0 .<= Cmax - c)
@constraint(m, 0 .<= QP - x’*QP)
@constraint(m, 1 .>= sum(x, dims=2))
@constraint(m, 1 .== sum(t, dims=3))

.
.
.

@NLexpression(m, Di[i=1:NP, j=1:NP], 0.363 (x[i,j]QP[i]/3600/hoursperday)^0.45rho^0.131000)
@NLobjective(m, Min, sum((0.0008Di[i,j]^2 + 0.002Di[i,j])*Dis[i,j] for i = 1:NP, j = 1:NP))

JuMP.optimize!(m)

Please read: Please read: make it easier to help you.

Particularly about formatting your code with triple-backticks, and providing a minimum working example (e.g., what is QP?). Also provide the full error.

The likely culprit is that x[i,j] * QP[i] / 3600 / 24 is too small for Couenne’s numerical precision.

Does the error go away if you make the lower bounds a lot larger (e.g., >= 0.1)?

You could also think about rescaling the problem. For example, you could multiple the objective by 10_000 to get some nicer numbers.

1 Like

Thank you for the tips!