Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

python cplex - solution pool memory and dump

  • 1.  python cplex - solution pool memory and dump

    Posted 03/24/18 11:55 AM

    Originally posted by: EvanSmith


    Hello,

     

    I have been using the standard API to dump say 10000 solutions from my pool

        for i in range(min(numsol, 10000)):
            filename = "%s/solution_%s.xml" % (root_folder, names[i])
            if i % 50 == 0:
                print("%s) Save solution %s to %s" % (i, names[i], filename))
            c.solution.pool.write(filename, i)

     

    I am finding my RAM explodes when I hit this part of my code.  How can I

    1) save as say JSON object JUST the decision variables.  Instead of the code above which saves XML

    2) how can I keep the memory under control (or use disk) at the point I hit the solution pool dump

     

    Thanks!

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: python cplex - solution pool memory and dump

    Posted 03/26/18 01:58 AM

    CPLEX can only export XML. If you want JSON you have to transform the XML using XSLT or something similar (there might be libraries available for this).

    To control what is written to the files use parameter CPX_PARAM_WRITELEVEL.

    I don't see a reason why your code would lead to an explosion of RAM. Are you sure that it happens inside this loop? What is `numsol` in your case?


    #CPLEXOptimizers
    #DecisionOptimization