From a995c081b7717b2f1a3e842d4b9ca51fa817d144 Mon Sep 17 00:00:00 2001 From: Henrique Becker Date: Wed, 3 Mar 2021 18:53:04 -0300 Subject: [PATCH] Commenting arcane trick in column deletion. (#399) --- src/MOI_wrapper.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 9e6d81d1..bebbe8f8 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -401,6 +401,11 @@ function _update_if_necessary(model::Optimizer) if model.needs_update sort!(model.columns_deleted_since_last_update) for var_info in values(model.variable_info) + # The trick here is: searchsortedlast returns, in O(log n), the + # last index with a column smaller than var_info.column, over + # columns_deleted_since_last_update this is the same as the number + # of columns deleted before it, and how much its value need to be + # shifted. var_info.column -= searchsortedlast( model.columns_deleted_since_last_update, var_info.column )