Delete a JuMP model entirely


Hi All,

Is there any way to delete a JuMP model after solving it? I have to call a function repeatedly to solve my problem but after the first call, I get the following error for every single variable in the model. Please let me know how can I solve this issue. Thanks in advance!

Warning: A variable or constraint named td is already attached to this model. If creating variables programmatically, use the anonymous variable syntax x = @variable(m, [1:N], ...).

All the best,


A JuMP model is a Julia object like anything else. It’s deleted by the garbage collector at some time after there are no more references to it (

It sounds like you want to pass a new model to the function on each call instead of reusing the same one.


Thanks for the response! It was useful.
I had already tried to delete variables by the same procedure but I couldn’t. Deleting the entire model works for me.

All the best,