Originally posted by: davidfk
Thanks Daniel. In my case I delete a rather large amount of constraints on rather few occasions, hence I would like to do the cleanup immediately. I do not care about the order of the constraints (I manually keep track).
Would the following be a valid way of deleting constraints? And not leak?
IloRangeArray constraints;
// Fill constraints with e.g. 5 IloRange objects
[...]
// Delete element with index 2:
constraints[2].end();
// Copy last handle to constraints[2]
constraints[2] = constraints[constraints.getSize()-1];
// Decrease size of array:
constraints.setSize(constraints.getSize()-1);
May it be a problem that both constraints[2] and constraints[4] contain the same handle before decreasing the array size? Should I set the last slot to NULL before decreasing the array size?
And a last question: In case I remove many constraints (M constraints), does it matter performance-wise whether I decrease the array size by 1 multiple times or a single time by M?
#CPLEXOptimizers#DecisionOptimization