Hi all,
I’m implementing a PCE-expanded AC power flow model. In JuMP, one of my nonlinear constraints looks like:
@constraint(opf, pfP[i=1:n_bus, k=1:K],
p[i,k] * T2_diag[k] ==
sum(
(G[i,j]*(E[i,l1]*E[j,l2] + F[i,l1]*F[j,l2])
+ B[i,j]*(F[i,l1]*E[j,l2] - E[i,l1]*F[j,l2])) * val
for (l1, l2, val) in T3_zip[k], j in 1:n_bus
)
)
This works well in JuMP and converts to ExaModels quickly.
However, when I try to implement the same constraint directly in ExaModels (using generators, flattened tensor data, or custom kernel functions), the model construction becomes much slower and the resulting nnzj/nnzh are 3–7× larger than the JuMP-generated ExaModel.
So my questions are:
- Is there a recommended pattern for writing large multi-index nonlinear sums in ExaModels?
- Why does JuMP → ExaModels generate a much smaller expression graph than my hand-written version?
- Are there examples or documentation on expressing tensor-structured nonlinear constraints efficiently in ExaModels?
Any advice or example code would be greatly appreciated.
Thanks!