Name styles of variables, parameters, sets, etc...


#1

When building a JuMP model, one thing I feel very important is to distinguish between variables and parameters in each equation. It’s important because, for example, the term “var. * par.” is linear but the term “var. * var.” is nonlinear, so linear solvers like CPLEX won’t return anything if you have a nonlinear equation like that.

So a good name style could not only give the model a good look but also helps to debug. I think it might be a good idea to have all the variables in lower cases and parameters in upper case, e.g., ’ @variable(m, x) ’ and X = 1 so you can tell immediately the different between @constraint(m, x * X <= 3) and @constraint(m, x * x <= 3)

How about the name of sets, models, equations?


#2

The JuMP style guide has some things to say on this:
http://www.juliaopt.org/JuMP.jl/latest/style/#JuMP-macro-syntax-1
http://www.juliaopt.org/JuMP.jl/latest/style/#Naming-1

We would probably recommend something like

model = Model()
@variable(model, var_x)
par_x = 1
@constraint(model, con_1, par_x * var_x <= 3)