Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Cplex 12.1 Python API - how to free the problem ?

    Posted 01/09/10 09:45 AM

    Originally posted by: SystemAdmin


    Hi to everyone.

    Is there any way to free the problem (created as "cpl = cplex.Cplex()") in Python API ?

    For example it can be done in C API as "status = CPXfreeprob (env, &lp)".

    Any ideas ?

    Thanks,
    CZ
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cplex 12.1 Python API - how to free the problem ?

    Posted 01/10/10 10:49 AM

    Originally posted by: SystemAdmin


    You can do 'del cpl' but actually reference counting and the garbage
    collector should take care of releasing the model. Is there a reason
    why you cannot rely on that?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cplex 12.1 Python API - how to free the problem ?

    Posted 01/14/10 09:43 AM

    Originally posted by: SystemAdmin


    I can use "del cpl".

    Please try this code. I run it under Win XP.

    The program takes on my OS 176 MBytes of memory so I supose it doesn't release a memory.

    import cplex
    import sys
    import gc

    if __name__ == "__main__":
    gc.enable()
    for i in xrange( 1000 ):
    #import cplex
    cpl = cplex.Cplex()
    del cpl
    gc.collect()

    sys.stdin.read(1)

    What is your opinion about this ?
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cplex 12.1 Python API - how to free the problem ?

    Posted 01/14/10 09:47 AM

    Originally posted by: SystemAdmin


    Some correction for code:

    import cplex
    import sys
    import gc
     
    if __name__ == "__main__":
            gc.enable()
            for i in xrange( 1000 ):
                    #import cplex
                    cpl = cplex.Cplex()
                    del cpl 
                    gc.collect()
     
            sys.stdin.read(1)
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Cplex 12.1 Python API - how to free the problem ?

    Posted 01/14/10 03:37 PM

    Originally posted by: SystemAdmin


    Hello Cezary,

    This is a known issue.

    One possible workaround is to construct a single instance of the cplex.Cplex() class and modify it, rather than construct new instances of the class at every iteration. For example, if you are reading a set of problems stored as .lp files, you can use the read method of the Cplex class:
    <verbatim>
    cpl = cplex.Cplex()
    for i in range(1000):
    cpl.read("prob" + str(i) + ".lp")
    cpl.solve()
    </verbatim>
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Cplex 12.1 Python API - how to free the problem ?

    Posted 04/22/10 07:32 PM

    Originally posted by: GregHines


    Hi, any idea when this problem might get fixed? With my code, the leak is pretty bad (the memory gets over 200m very quickly and continues to rise).
    My program can have a several hundred LPs which need to be solved many times (with the constraints being updated each time)- so writing to a file each time is going to be really slow. The LPs are created dynamically so I can't do anything in advance.

    Any suggestions would be greatly appreciated.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Cplex 12.1 Python API - how to free the problem ?

    Posted 04/22/10 08:41 PM

    Originally posted by: SystemAdmin


    This issue is fixed in CPLEX 12.1.1, which is available through FixCentral.

    http://www-933.ibm.com/support/fixcentral/

    Philip Starhill
    CPLEX Research Engineer
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Cplex 12.1 Python API - how to free the problem ?

    Posted 04/26/10 11:08 AM

    Originally posted by: GregHines


    I tried upgrading to 12.1.1 and was told
    "The following fixes cannot be downloaded due to an entitlement failure."

    I assume this is because I am accessing CPLEX through the Academic Initiative. Any idea when 12.1.1 will become available for people using the Academic Initiative?

    thanks, Greg
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Cplex 12.1 Python API - how to free the problem ?

    Posted 05/03/10 07:37 PM

    Originally posted by: SystemAdmin


    Hi Greg,

    That's correct, unfortunately updates on FixCentral are not available to Academic Initiative users. We're currently looking into how we can deliver fixes to Academic Initiative users. Please send me a mail at pstarhill (at) us (dot) ibm (dot) com and I'll let you know when new information becomes available.

    Philip Starhill
    CPLEX Research Engineer
    #CPLEXOptimizers
    #DecisionOptimization