[sparse modelling] Does JuMP automatically remove "uninfluent" variables from constraints/objective?

Hello, I am designing a non-linear model where some quantities depend from many variables, but only a few of them actually have a parameter that allow the dependent variable to play.
The actual implementation is:

quantity_i = prod(price[p]^e[p] for p in products)

Where a few e[p] are actually different than zero.
Is JuMP smart enough to “remove” there variables from the constraint or should I write each constrain separately as to remove the dependency from the uninfluent variables ?

Do you use a sparse vector to store e?

no. that’s the way to go ?

JuMP will not do presolving.
If some variable does not matter for a constraint such as yours you should write them without the variables that do not matter.

if the variables that "don’t matter’ is defined in the data (trough a parameter, e in my case) rather than in the code is there a way to still keep the structure of the constraint homogeneous ?
My constraints are currently :

@NLconstraint(m, demand[p in 1:np, r in 1:nr],  d[p,r]  == const_d[p,r] * prod(pd[p,r]^ e_d[p,r,in_p,in_r] for in_p in 1:np, in_r in 1:nr ) )
@NLconstraint(m, supply[p in 1:np, r in 1:nr],  s[p,r]  == const_s[p,r] * prod(ps[p,r]^ e_s[p,r,in_p,in_r] for in_p in 1:np, in_r in 1:nr ) )

I could add a “logic” to test for e_d/e_d being equal to zero, but this would be “passed” to the solver I think.
Otherwise I could write many unidimensional constraints, all with a different structure (with the removal of irrelevant variables logic outside the constraint) but how will I get them? by name ?

Doesn’t it work when the coefficients are sparse though?

Does something like this work? (I haven’t tested, so there might be typos, etc.)

sets = Dict(
    (p, r) => [
        (inp, inr) for inp in 1:np for inr in 1:nr if !iszero(e_d[p,r,in_p,in_r])
    ] for p in 1:np, r in 1:nr
)
@NLconstraint(
    m, 
    demand[p in 1:np, r in 1:nr],
    d[p,r]  == const_d[p,r] * prod(pd[p,r]^e_d[p,r,in_p,in_r] for (in_p, in_r) in sets[(p, r)])
)