# Dynamic NL expression in julia

Hi, I am using Juniper to solve MNILP and with array of nonlinear expression i am getting invalid model error. is there a way to generate nonlinear expression names in a loop like

``````@variable(model,x)
zz=0.0
for i in 1:5
for j in 1:5
global zz=zz+1
println(zz)
xmm_\$zz=@NLexpression(model,x+x*x+zz)
end
end
println(model)``````

I am using Juniper to solve MNILP and with array of nonlinear expression i am getting invalid model error.

What code did you try and what is the error? Remember that it is easier to help if you can provide a reproducible example.

Do you want something like the following?

``````model = Model()
@variable(model, x)
@NLexpression(model, xmm[i=1:5, j=1:5], x + x * x + 5(i-1) + j)
xmm[2, 3]
``````

Thanks for the reply. I am trying to build a NL exp.

``````           for t in 1:N
WBMOM[t]=   @NLexpression(mod,Tnkcn[t,1] + Tnk[p,t]*Tnkcn[t,2]*zz*Tnk[p,t]
+  Tnk[p,t]*Tnkcn[t,3]*(zz*Tnk[p,t])^2 +Tnk[p,t]*Tnkcn[t,4]*(zz*Tnk[p,t])^3 +
Tnk[p,t]*Tnkcn[t,5]*(zz*Tnk[p,t])^4
+Tnk[p,t]*Tnkcn[t,6]*(zz*Tnk[p,t])^5 +Tnk[p,t]*Tnkcn[t,7]*(zz*Tnk[p,t])^6	)
end

This resolves this issue. But model is still invalid and trying to pinpoint the expression /constraints.``````