Originally posted by: DavidNLarsson
Hi,
I'm working on a Branch and Price implementation for large MILP. To locate fractional variables (and most of all, to find the 'best' fractional variable, by some definition of 'best') prone to branching, during the course of the branching procedure, several times over my program extracts expressions from constraints in the RMP model.
During this procedure, I've noticed a small (~0.0007MB) increase in total memory usage every time the IloRange::getExpr() method is used. I've given an example below.
Q: Is this memory use expected? Is there any way to free the memory used when invoking this method?
TIA.
Regards,
David.
(I'm using ILOG Concert Technology Version 2.9)
// ------------------------------------------------------------------------------------
// Small but unexpected memory usage when invoking the IloRange::getExpr() method.
// ------------------------------------------------------------------------------------
// libraries
#include <ilcplex/ilocplex.h>
ILOSTLBEGIN
using namespace std;
#define MEGA 1.0e6
#define SOME_CONSTANT ...
// main
int main (int argc, char **argv)
{
// create the optimization enviroment
IloEnv env;
// no error catching for this simple example.. :)
// create IloModel object associated with the optimization problem
IloModel optModel(env);
// some constrant
IloRangeArray someConstraint(env);
// some temporary expression
// some counter
IloInt t;
/* Some operations on the model, defining variables, "filling" constraints etc. ... */
// now, a loop where I for some reason want to extract - expression by expression - the
// content of 'someConstraint':
for (t = 0; t < SOME_CONSTANT; t++) {
env.out() << "memUsage = " << (env.getMemoryUsage())/MEGA << "MB, t = " << t << endl;
// get expression from specific constraint:
tempExpr = someConstraint[m].getExpr();
// Perform some operations ...
// clear tempExpr
tempExpr.clear();
}
// use method ::end() inherited from IloExtractable class
// to "free all the resources used by the invoking object".
tempExpr.end()
// QUESTION/PROBLEM:
// In my actual program, a loop similar to the one above is called very many times.
// For each iteration, I see an increase in memory use of 0.0006-00007MB.
// (No portion of this memory is returned after i use the end() method, probably as
// the tempExpr has already been "cleared", ::clear().)
// This leads to a heavy memory use in a much faster pace than expected.
// Q: Is this normal and to be expected, a small memory usage when using the getExpr() method?
// (If "A: Yes", I simply have to deter refrain an implementation as this, or is there any way
// to get out off that slight mem-use?)
// ...
env.end();
return 0;
} // END of main()
#CPLEXOptimizers#DecisionOptimization