LinQuadOptInterface.jl icon indicating copy to clipboard operation
LinQuadOptInterface.jl copied to clipboard

Lazy variables dict after delete.

Open joaquimg opened this issue 6 years ago • 7 comments

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.

joaquimg avatar Mar 14 '19 22:03 joaquimg

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

blegat avatar Mar 15 '19 02:03 blegat

@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

ndinsmore avatar Apr 09 '19 17:04 ndinsmore

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.

joaquimg avatar Apr 09 '19 17:04 joaquimg

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.

blegat avatar Apr 10 '19 09:04 blegat

Yea but then the vector would grow a lot. The other options it to re use like mosek.

joaquimg avatar Apr 10 '19 13:04 joaquimg

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.

blegat avatar Apr 10 '19 17:04 blegat

I think that addition should be as fast as possible and deletion should only come after. Deletion could be improved with batch deletion later.

joaquimg avatar Apr 10 '19 21:04 joaquimg