I am trying to solve a nonlinear model using JuMP. Part of the constraints come from the gradient of a nonlinear function. I am trying to compute it using ForwardDiff. As such, I need to define an operator and then pass it as a constraint (from the post @constraint with ForwardDiff.gradient).
But I am aware that @operator only allows for scalar-valued outputs. I saw from the documentation (User-defined operators with vector outputs · JuMP) that we need to define one operator for each component of the vector. E.g., it is done as follows:
Is there a way to define it using a loop or some other way so I do not need to write an explicit operator line per component? I have a relatively large model, so I wonder if there is a better way than copy pasting and changing the index.
In terms of the above MWE, my question is that I would love to not having to write f1, f2, f3, etc., separately as I want to set the gradient (vector) to be equal to another vector-valued function.
Let me know if there is anything unclear above. Thanks!!