Change of variable and constraint name


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.


Use the basename keyword:

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


Respected Sir,

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

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)
println(" Optimal Solutions:")
println(" x = ", getvalue(x))
println(" y = ", getvalue(y))
println(" z = ", getvalue(z))
println("Objective Value:",getobjectivevalue(m))



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.


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,


Dear Sir,

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

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,