I am planning to develop a very large power system model. In AMPL it took 1-2h to generate the model and 12h to solve the model with cplex.
In JuMP one can use symbols to create DenseAxisArrays of Variables and Constraints. But as I read it seems that these take much longer than normal arrays in the model preparation.
There fore I want to use NamedDimsArrays (NamedDims.jl) to ensure proper/safe coupling of JuMP Variable arrays in different constraints. (I also try to figure out if AxisKeys.jl or Dictionaries.jl can help to make a performant but easy to read and debug large JuMP optimization model.)
But I am not sure how one would best create NamedDimsArrays of JuMP Variables and constraints?
m=Model()
time_steps=(1:10)
temp_levels=(5:5:95)
cav_levels=(1:2)
storageLevelBalance=NamedDimsArray{(:x, :y, :z),VariableRef,3,Array{VariableRef,3}}[]; sizehint!(storageLevelBalance, 380)
for ts in time_steps, tl in temp_levels,cl in cav_levels @variable(m,storageLevelBalance[ts,tl,cl]) end
ERROR: An object of name storageLevelBalance is already attached to this model.
But this works
for ts in time_steps, tl in temp_levels,cl in cav_levels
@variable(m,base_name = “storageLevelBalance[$ts,$tl,$cl]”)
end
Is this the way to go?
Why gives specifying a variable name @variable(m,storageLevelBalance[ts,tl,cl]) an error while
@variable(m,base_name = “storageLevelBalance[$ts,$tl,$cl]”) is fine?
Further question:
Reasons for meaningful indices:
- Avoid model mistakes: Sum( i in Ind)A[i,j]x[i] is not the same as Sum( i in Ind)A[j,i]x[i]. Here I by accident flipped the indices in the Matrix A. If A would be defined over different sets in the first or second index then to model would complain if it is fed with a wrong index. If it is only integers how can the model know I did a mistake?
- Easy inspection of optimization results: If I look at the optimization results, I want to know e.g. which power plant has a lot of installed capacity. Cap[“Bartimore2”]=1500 is more clear then Cap[2569]=1500
Lineflow[“Baltimore”,”NewYork”]=2300 is more clear result than Lineflow[224,432]=2300 where I have to look up what line (224,432) is.
Are there any other suggestions how to create a very large performant JuMP model, but with the 2 features mentioned above(Prevent index coupling mistakes and easy inspection of model results)?