Delete a JuMP model entirely


#1

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,
Rasoul


#2

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 (https://docs.julialang.org/en/v1/manual/faq/#How-do-I-delete-an-object-in-memory?-1).

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


#3

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,
Rasoul