When trying to write out each component as a separate constraint, I need to add an index i
to the original constraint_T
function like this
function constraint_T(i, Θ...)
vΘ = collect(Θ)
θ₁ = vΘ[1]
θ₃ = vΘ[2:4]
RC = vΘ[5]
EV = reshape(vΘ[6:end], 2, S)
θ = BusParameters(θ₁=θ₁, θ₃=θ₃, RC=RC)
EVᵢ = T(EV, θ, i)
return EVᵢ - EV[i]
end
Then register the function with one additional parameter
JuMP.register(model, :constraint_T, 1+5+2*S, constraint_T, autodiff=true )
And add the separate constraints
for i in 1:2*S
@NLconstraint(model, constraint_T(i, Θ...) == 0)
end
But this introduces the additional parameter i
that Autodiff is trying to differentiate, which of course will cause problems. How should let Autodiff skops to differentiate with i
? Any suggestions @odow?