# Get rid of a JuMP model

**URL:** <https://discourse.julialang.org/t/get-rid-of-a-jump-model/19721>\
**Category:** Optimization (Mathematical)\
**Created:** [January 16, 2019, 7:55pm UTC](https://discourse.julialang.org/t/get-rid-of-a-jump-model/19721 "2019-01-16T19:55:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [January 16, 2019, 7:55pm UTC](https://discourse.julialang.org/t/get-rid-of-a-jump-model/19721/1 "2019-01-16T19:55:08Z")

</div>

Hi All,

I have a function in my code that builds a model and solve it and return the result. I have to call this function repeatedly. Although my code works properly I get the following warning after calling the function which makes my code super sluggish as it goes forward.

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

```

Can you please let me know how I can get rid of the model after it is solved to prevent this issue. Any help would be appreciated.

All the best,  
Rasoul

---

<div class="post-metadata">

**Author:** ![tkluck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkluck/32/15769_2.png) [@tkluck](https://discourse.julialang.org/u/tkluck)\
**Post date:** [January 16, 2019, 8:15pm UTC](https://discourse.julialang.org/t/get-rid-of-a-jump-model/19721/2 "2019-01-16T20:15:04Z")

</div>

What do you get when you replace the declaration for `va` by something like

```julia
x = @variable(m, [1:N], ...).

```

as suggested?

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [January 16, 2019, 9:59pm UTC](https://discourse.julialang.org/t/get-rid-of-a-jump-model/19721/3 "2019-01-16T21:59:20Z")

</div>

It is not clear how to define variables as is suggested by the warnings. variables in the model are kept and new variables would be added to the model as the code goes forward. There should be a way to get rid of the older variables in the model. Please let me know if you have any information about removing variables in a model. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![tkluck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkluck/32/15769_2.png) [@tkluck](https://discourse.julialang.org/u/tkluck)\
**Post date:** [January 16, 2019, 10:08pm UTC](https://discourse.julialang.org/t/get-rid-of-a-jump-model/19721/4 "2019-01-16T22:08:49Z")

</div>

Do post some code so we can help you.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [January 16, 2019, 11:05pm UTC](https://discourse.julialang.org/t/get-rid-of-a-jump-model/19721/5 "2019-01-16T23:05:49Z")

</div>

The current released version of JuMP (0.18) does not have the ability to delete variables.

This oversight is fixed in the upcoming release of JuMP. (Read more about that [here](https://discourse.julialang.org/t/mathoptinterface-and-upcoming-breaking-changes-in-jump-0-19/4874).)

If you want to try it out for a spin, there are installation instructions at [JuMP 0.19-beta released (JuMP/MathOptInterface)](https://discourse.julialang.org/t/jump-0-19-beta-released-jump-mathoptinterface/18850). (Warning! It’s a beta!)

Once you’re using the beta, you can read about deleting variables in the [new docs](http://www.juliaopt.org/JuMP.jl/latest/variables/#Deleting-variables-1) .
