1

I am using IBM CPLEX library for an optimization problem in Java. Since main memory was not enough for the application I found a property of CPLEX : "Memory emphasis: letting the optimizer use disk for storage". Default value for Memory Emphasis is 0. How can I change this property in Java?

    for (int i = 0; i < GreenOverlayGlobals.numNodes; i++) {

        for (int j = 0; j < GreenOverlayGlobals.numNodes; j++) {

            IloLinearNumExpr expr2 = cplex.linearNumExpr();
            for (int p = 0; p < GreenOverlayGlobals.numPathPairs; p++) {

                cplex.addLe(xPath[i][j][p], xLink[i][j]); //x[i][j][p] <= x[i][j]
                expr2.addTerm(1, xPath[i][j][p]);
            }
            cplex.addLe(xLink[i][j], expr2); //x[i][j] <= sump_x[i][j][p]
        }
    }
David Nehme
  • 21,379
  • 8
  • 78
  • 117
fatma.ekici
  • 2,787
  • 4
  • 28
  • 30
  • Are you sure you can't do anything to reduce the memory requirement of your optimization problem? – user327301 Aug 21 '13 at 17:24
  • In fact memory allocated from heap is not that much in my application. CPLEX uses memory upto 12GB while finding the optimal solution. I do not know the details of internal logic of CPLEX library. – fatma.ekici Aug 21 '13 at 17:50

1 Answers1

1

You set parameters in cplex java with the IloCplex.setParameter() method. To allow the mip tree to be stored on disk, you can use the NodeFileInd, and WorkDir to specify a directory for storage. Two other parameters can be used to reduce the memory consumption of cplex. You can set MemoryEmphasis to True which will instruct cplex to try to conserve memory. You can also turn on "strong branching" by setting the parameter VarSel to 3. Strong branching causes cplex to spend more time at each node selecting higher-quality child nodes, which usually make the search tree smaller.

To use the setParameter method, assuming you have an IloCplex object called cplex.

cplex.setParam(IloCplex.IntParam.VarSel, 4);
cplex.setParam(IloCplex.BoolParam.MemoryEmphasis, true);

Keep in mind, there parameters only affect cplex during a .solve(). If you are running out of memory before the .solve(), the parameters won't do anything. Since cplex models are usually very sparse, the most common cause of excess memory consumption is adding too many terms with 0 coefficients.

David Nehme
  • 21,379
  • 8
  • 78
  • 117
  • I was running out of memory before solve(). I am new in using CPLEX. Is there any method to get rid of this sparsity? – fatma.ekici Aug 21 '13 at 18:44
  • I included the code snippet where I ran out of memory in my question. Memory exception is given in cplex.addLe() line where I add the constraints. numNodes is the number of nodes in the input graph. Am I adding excessive constraints? Could it be the reason of memory exception? – fatma.ekici Aug 21 '13 at 18:53
  • You are creating numNodes^3 nonzeros to your model and you are assuming a complete graph (you can have links between all nodes). What are you trying to compute? – David Nehme Aug 21 '13 at 18:59
  • I am not assuming a complete graph. There is a constraint like "x_ijp < x_ij". x_ijp is the decision variable that is 1 if link ij is included in path p. I tried to express that constraint in terms of CPLEX. – fatma.ekici Aug 21 '13 at 19:14
  • @fatma.ekici The outer two for loops generate all pairs of nodes in a graph. That defines a complete graph( plus self loops from i to i). – David Nehme Aug 21 '13 at 20:36