Lazy variables dict after delete.
Currently we have a dict mapping variables to indices. We only actualy need that onde a variable is deleted, before deletion the variable reference already have the correct index. By implementing this we can bring back performance of JuMP 0.18 in many parts of the code, in models that do not require deletions.
MosekTools has a special linked list to have it more efficient than a Dict when you delete variables: https://github.com/JuliaOpt/MosekTools.jl/blob/master/src/LinkedInts.jl This is related but it's not a priority, not using the dict when no variable has been deleted has higher priority
@joaquimg do you have a sense of which operations are slow right now and on which solver? Because if you apply #95, #101, https://github.com/JuliaOpt/Clp.jl/pull/57, most of the profiling I have done seems to indicate that the Julia code is no longer the bottleneck. Atleast when using Clp
Clp and GLPK are much slower that Gurobi, CPLEX and Xpress. I’d say that adding contraints is the way to test this. The require many dictionary lookups.
Why having a Dict instead of a Vector ? If variables are deleted you could just store 0 to specify that the variable index is not valid.
Yea but then the vector would grow a lot. The other options it to re use like mosek.
Mosek also use a vector for mapping MOI index to Mosek column. It reuses columns but not MOI index. The MOIU Model also has vectors which as large as the number of variables created (including those deleted). We should not optimize the variable deletion case too much IMO.
I think that addition should be as fast as possible and deletion should only come after. Deletion could be improved with batch deletion later.