Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Handling CPLEX memory exceptions in C++

    Posted 02/15/08 05:38 PM

    Originally posted by: SystemAdmin


    [aroso said:]

    Hi,

    I'm trying to run a program that calls CPLEX multiple times. The program structure is something like this:
    declare variables, load model, etc.
    ...
    IloIntVarMap TVar();
    ...
    while (some condition is met) {
    ...
    for (IloInt i = 0;i<N;i++) {<br /> for (IloInt j = 0;j<N;j++) {<br /> for (IloInt t = 0;t<T;t++) {<br /> IloMapIndexArray indices(env);
    indices.add(i+1);
    indices.add(j+1);
    indices.add(t+1);
    IloNumVar TVarElement = TVar.getAt(indices);
    TVarElement.setLB(T[i][j][t]);
    TVarElement.setUB(T[i][j][t]);
    }
    }
    }
    cplex.solve();
    IloIntVarMap XVar = opl.getElement("X").asIntVarMap();

    for (IloInt i = 0;i<iNProdutos;i++) {<br /> IloIntVarMap subX = XVar.getSub(i+1);
    for (IloInt t = 0;t<iNPeriodos;t++) {<br /> X[i][t] = (int) cplex.getValue(subX.get(t+1));
    }

    }

    ...
    }

    After a while, I get
    terminate called after throwing an instance of 'IloMemoryException'


    I think this can be avoided using the endAll method. However, I want to do it only when necessary, i.e., I don't want to do it every iteration because loading everything again takes too much time. Is there any way to automatically clean all memory when a certain level is reached? Or is there any improvement that can be made to the code to avoid this problem?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Handling CPLEX memory exceptions in C++

    Posted 02/18/08 01:18 AM

    Originally posted by: SystemAdmin


    [alain.chabrier said:]

    HI,

    you should reuse the index array from an iterator to another, or at least end it.

    Alain
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Handling CPLEX memory exceptions in C++

    Posted 02/18/08 06:27 PM

    Originally posted by: SystemAdmin


    [aroso said:]

    Thanks Alain, ending the index array has (so far) solved the problem!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer