# Running into a deprecation while assigning variables and constraints in JuMP (v0.18.5) on Julia (0.7.0)

**URL:** <https://discourse.julialang.org/t/running-into-a-deprecation-while-assigning-variables-and-constraints-in-jump-v0-18-5-on-julia-0-7-0/22635>\
**Category:** General Usage\
**Tags:** jump\
**Created:** [April 2, 2019, 1:24pm UTC](https://discourse.julialang.org/t/running-into-a-deprecation-while-assigning-variables-and-constraints-in-jump-v0-18-5-on-julia-0-7-0/22635 "2019-04-02T13:24:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lonewolf92](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@Lonewolf92](https://discourse.julialang.org/u/Lonewolf92)\
**Post date:** [April 2, 2019, 1:24pm UTC](https://discourse.julialang.org/t/running-into-a-deprecation-while-assigning-variables-and-constraints-in-jump-v0-18-5-on-julia-0-7-0/22635/1 "2019-04-02T13:24:48Z")

</div>

A deprecation warning is thrown when i add my variables or constraints for my optimization problem. The warning is :

┌ Warning: Deprecated syntax `implicit assignment to global variable `#20###368``.  
│ Use `global #20###368` instead.  
└ @ none:0

This code used to run without any warning on Julia 0.6.2.

```julia

using JuMP, Gurobi, DelimitedFiles, PyPlot, LightGraphs, GraphPlot, Compose, Colors

@variable(IMTLP,Intermodal_shipping[i=1:n_hubs,j=1:n_hubs,m=1:n_modes,k=1:n_customers,p=1:n_products,t=1:n_echelons]>=0,Int)

@constraint(IMTLP, SDemandcon[t=1:n_echelons, g=1:n_customers, k=1:n_customers, p=1:n_products], Direct_shipping[k,g,p,t]+sum(Endhaul_shipping[j,g,k,p,t] for j in 1:n_hubs)>=Demand_specific[g,k,p,t])

```

How to avoid this warning??

---

<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:** [April 2, 2019, 1:48pm UTC](https://discourse.julialang.org/t/running-into-a-deprecation-while-assigning-variables-and-constraints-in-jump-v0-18-5-on-julia-0-7-0/22635/2 "2019-04-02T13:48:13Z")

</div>

Please read the following post, and provide a minimum working example. If the warning is coming from your code, fix it. If the warning is coming from JuMP, upgrade to Julia 1.0.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

**Author:** ![Lonewolf92](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@Lonewolf92](https://discourse.julialang.org/u/Lonewolf92)\
**Post date:** [April 2, 2019, 2:13pm UTC](https://discourse.julialang.org/t/running-into-a-deprecation-while-assigning-variables-and-constraints-in-jump-v0-18-5-on-julia-0-7-0/22635/3 "2019-04-02T14:13:30Z")

</div>

> ```julia
> using JuMP, Gurobi
> 
> my = Model(solver=GurobiSolver())
> 
> @variable(my, x[1:2]>=0, Int)
> 
> @constraint(my, x[1] == x[2])
> 
> @objective(my, Min, x[1] + x[2])
> 
> status = solve(my)
> 
> print(my)
> 
> ```

> ```julia
> ┌ Warning: Deprecated syntax `implicit assignment to global variable `#2781###740``.
> │ Use `global #2781###740` instead.
> └ @ none:0
> ┌ Warning: Deprecated syntax `implicit assignment to global variable `#2781###740``.
> │ Use `global #2781###740` instead.
> └ @ none:0
> Academic license - for non-commercial use only
> Optimize a model with 1 rows, 2 columns and 2 nonzeros
> Variable types: 0 continuous, 2 integer (0 binary)
> Coefficient statistics:
> Matrix range [1e+00, 1e+00]
> Objective range [1e+00, 1e+00]
> Bounds range [0e+00, 0e+00]
> RHS range [0e+00, 0e+00]
> Found heuristic solution: objective 0.0000000
> 
> Explored 0 nodes (0 simplex iterations) in 0.00 seconds
> Thread count was 1 (of 4 available processors)
> 
> Solution count 1: 0
> 
> Optimal solution found (tolerance 1.00e-04)
> Best objective 0.000000000000e+00, best bound 0.000000000000e+00, gap 0.0000%
> Min x[1] + x[2]
> Subject to
> x[1] - x[2] == 0
> x[i] >= 0, integer, for all i in {1,2}
> 
> ```

---

<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:** [April 2, 2019, 2:25pm UTC](https://discourse.julialang.org/t/running-into-a-deprecation-while-assigning-variables-and-constraints-in-jump-v0-18-5-on-julia-0-7-0/22635/4 "2019-04-02T14:25:47Z")

</div>

These warnings are in 0.7 only. The code will work as-is in Julia 1.0.

Note that when you upgrade to Julia 1.0, you will get JuMP 0.19, not 18.5. Here are the docs:  
[http://www.juliaopt.org/JuMP.jl/v0.19/quickstart/](http://www.juliaopt.org/JuMP.jl/v0.19/quickstart/)

Only two lines change. Your code becomes:

```julia
using JuMP, Gurobi
my = Model(with_optimizer(Gurobi.Optimizer)) # Changed
@variable(my, x[1:2]>=0, Int)
@constraint(my, x[1] == x[2])
@objective(my, Min, x[1] + x[2])
optimize!(my) # Changed
print(my)

```

---

<div class="post-metadata">

**Author:** ![Lonewolf92](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@Lonewolf92](https://discourse.julialang.org/u/Lonewolf92)\
**Post date:** [April 2, 2019, 2:26pm UTC](https://discourse.julialang.org/t/running-into-a-deprecation-while-assigning-variables-and-constraints-in-jump-v0-18-5-on-julia-0-7-0/22635/5 "2019-04-02T14:26:48Z")

</div>

ok, i didn’t know that. Thanks
