# Change of variable and constraint name

**URL:** https://discourse.julialang.org/t/change-of-variable-and-constraint-name/3860
**Category:** Optimization (Mathematical)
**Created:** [May 22, 2017, 7:07pm UTC](https://discourse.julialang.org/t/change-of-variable-and-constraint-name/3860 "2017-05-22T19:07:48Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)
#### Post date: [May 22, 2017, 7:07pm UTC](https://discourse.julialang.org/t/change-of-variable-and-constraint-name/3860/1 "2017-05-22T19:07:48Z")

</div>

Please let me know the way to change variable name and constraint name. We usually do it in CPLEX to change default name of variables and constraints to make it more meaningful and to give better understanding of .lp file.

---

<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: [May 22, 2017, 8:32pm UTC](https://discourse.julialang.org/t/change-of-variable-and-constraint-name/3860/2 "2017-05-22T20:32:40Z")

</div>

Use the `basename` keyword:

```julia
x = @variable(m, [1:3], basename="myvariable-$i")

```

---

<div class="post-metadata">

### Author: ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)
#### Post date: [May 23, 2017, 4:52pm UTC](https://discourse.julialang.org/t/change-of-variable-and-constraint-name/3860/3 "2017-05-23T16:52:27Z")

</div>

Respected Sir,

Please check the code. Unfortunately, .lp file is still naming variable “x” as VAR1 instead of “VARX”.

```julia
using JuMP
using Clp
m = Model(solver=ClpSolver())
x=@variable(m,0 <= x <= 40,basename="VarX")

@variable(m, y <= 0)
@variable(m, z <= 0)
@objective(m, Max, x + y + z)
@addConstraint(m, const1, -x + y + z <= 20)
@addConstraint(m, const2, x + 3y + z <= 30)
solve(m)
println(" Optimal Solutions:")
println(" x = ", getvalue(x))
println(" y = ", getvalue(y))
println(" z = ", getvalue(z))
println("Objective Value:",getobjectivevalue(m))
writeLP(m,"C:/model1.lp")

```

Thanks,

---

<div class="post-metadata">

### Author: ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)
#### Post date: [May 23, 2017, 7:44pm UTC](https://discourse.julialang.org/t/change-of-variable-and-constraint-name/3860/4 "2017-05-23T19:44:18Z")

</div>

[http://www.juliaopt.org/JuMP.jl/0.16/refmodel.html](http://www.juliaopt.org/JuMP.jl/0.16/refmodel.html)

> `writeLP(m::Model, filename::AbstractString; genericnames=true)` - write the model to filename in the LP file format. Set `genericnames=false` for user-defined variable names.

---

<div class="post-metadata">

### Author: ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)
#### Post date: [May 24, 2017, 4:09am UTC](https://discourse.julialang.org/t/change-of-variable-and-constraint-name/3860/5 "2017-05-24T04:09:20Z")

</div>

Dear Sir,

I have been facing to load “Ipopt”. Is there any sequence to load “Ipopt”,“Cpl”, and “JuMP”? I load earlier “JuMP” first and then “Clp” and it worked. Please let me know sequence of loading,if any.

Thanks and regards,

---

<div class="post-metadata">

### Author: ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)
#### Post date: [May 24, 2017, 1:19pm UTC](https://discourse.julialang.org/t/change-of-variable-and-constraint-name/3860/6 "2017-05-24T13:19:19Z")

</div>

Dear Sir,

Thanks for your support. As per your instruction I changed  
code and included the following to rename variables:

```julia
writeLP(m::Model, filename::AbstractString; genericnames=true)

```

Please let me know about infeasibility testing. I am using Clp. How to get  
conflicting equations in JuMP?

Thanks and regards,
