I’m curious about the difference between two versions
The Model
uses caching, which can batch various operations, etc, but it has the downside of requiring a copy of the model.
direct_mode
stores only a single copy of the model and performs exactly what you type. In your case, delete.(m, m[:c3])
is equivalent to calling
for c in m[:c3]
delete(m, c)
end
so you are iteratively deleting a large number of constraints, and Gurobi is not efficient at deleting constraints.
For the error, JuMP knows how to delete a vector of constraints but not a matrix. Do delete(m, vec(m[:c3]))
I constructed a general model for energy system optimization and modify some constraints according to my specific scenarios.
Read Design patterns for larger models · JuMP
I strongly suggest that, instead of building everything and then deleting some constraints, you add only the constraints and variables that are necessary in the first place.