Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Memory usage [C++]

    Posted Fri December 03, 2010 01:10 PM

    Originally posted by: eibanez


    Hi,

    This is my first post and I hope it is in the right place!

    I am developing and application that involves solving a large number of LP instances that vary just slightly. The problem is that because I am doing this so many times, I end up running out of memory every time.

    I am pretty sure that this increase in memory use comes from the fact that the model is being changed after it has been extracted.

    The following is the basic structure of my program:

    • Declare cplex variables (env, model, cplex, ranges, var, obj)
    • Load mps file in memory
    • Extract model into cplex
    • Begin a loop and each time:
    + Create a IloRangeArray variable with necessary constraints
    + Add constraints to model
    + Solve current model and analyze results
    + Remove constraints from model
    + End constraint variable
    What I had it mind is that by removing said constraints the model would return to its original definition and there would be no trace of that change in memory. Apparently this is not true.

    Please let me know if you need more insight to help me with this problem.

    Thanks very much,

    Eduardo
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Memory usage [C++]

    Posted Sat December 04, 2010 01:20 PM

    Originally posted by: JimDan


    There is a known bug/issue with CPLEX 12.2 memory management. I do not know if this bug is causing your crashes. You can find a related thread with a suggestion of a workaround from ILOG personnel here. The only other thought that I have (without knowing the details of your problem) is that if the LPs are only slightly different from one another, why go through the trouble of destroying and recreating the model again and again? Simply modify the model within the same IloModel/IloCplex object. This way, CPLEX can use/repair a previous basis so that your problems run faster.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Memory usage [C++]

    Posted Mon December 06, 2010 03:54 PM

    Originally posted by: eibanez


    Thanks for the link. I will have a look at it.

    Originally, I was modifying the model with each iteration but that also lead to a memory leak. The I thought that concentrating the modifications in a single object as constraints would help but it didn't.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Memory usage [C++]

    Posted Mon December 06, 2010 03:56 AM

    Originally posted by: SystemAdmin


    One reason might be that you are not releasing all allocated memory in the loop. Or are not removing all constraints that you added.
    Can you post your code here (at least the loop)?
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Memory usage [C++]

    Posted Mon December 06, 2010 03:56 PM

    Originally posted by: eibanez


    Here is part of the loop:

    // Force minimum investment (x) as lower bound
            IloRangeArray ConstrLB(env, 0);
            for (int i = 0; i < Ncap; ++i)
                    ConstrLB.add( var[0][i] >= x[i] );
            model.add( ConstrLB );
            
            // Solve problem
            SolveIndividual( objective, env, model, cplex, obj, var, rng );
            
            // Eliminate lower bound constraints
            model.remove( ConstrLB );
            ConstrLB.end();
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Memory usage [C++]

    Posted Mon December 06, 2010 05:25 PM

    Originally posted by: SystemAdmin


    What happens if you invoke ConstrLB.endElements() just before you invoke ConstrLB.end()?

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization