Frage

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]
        }
    }
War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top