Fix the O(N^2) bug of passColName and passRowName#1780
Fix the O(N^2) bug of passColName and passRowName#1780jajhall merged 1 commit intoERGO-Code:fix-passnamefrom
Conversation
|
I need to investigate why unit tests fail before merging into latest. Don't create PR to master, please |
|
Sorry, I will choose |
|
This fix fails when changing existing names in a model. I'm not fluent in the use of
works at all. The problem is that this retains the old name, so
is triggered in
fails. The old name needs to be removed from the map, rather than (conservatively) clearing the map when I appreciate that we've got an Do compile with |
|
It is more complex than I thought. It should be two steps:
|
|
I think this should do it. |
This fixes a performance issue when
Highs_addColandHighs_passColNameare called in sequence to add new variables.After
Highs_addColis called, there isncolumns and thecols_hash_also hasnelements because ofHiGHS/src/lp_data/HighsInterface.cpp
Line 201 in 13363c9
HiGHS/src/lp_data/HighsLp.cpp
Line 315 in 13363c9
cols_hash_will be rebuilt if it is empty.Then, if
Highs_passColNameis called to set the name of columnn,cols_hash_is cleared.Now when$O(N^2)$ .
Highs_addColandHighs_passColNameare called in sequence to addNcolumns,cols_hash_has to be rebuilt forNtimes with length1,2,...,N, which makes the complexityIn fact, when we call
Highs_passColName,cols_hash_can update one element instead of clearing all contents.The bug is discovered in coin-or/python-mip#372 .