Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Export all feasible solutions in txt file (docplex.mp)

  • 1.  Export all feasible solutions in txt file (docplex.mp)

    Posted Mon November 28, 2022 01:29 PM
    Hello All,
    I am trying to export all feasible solutions for my MIP problem (docplex.mp) in a txt file. What is the most efficient way to do this? Thank you!

    ------------------------------
    Daniela Cantarino
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Export all feasible solutions in txt file (docplex.mp)

    Posted Mon November 28, 2022 02:12 PM
    Edited by System Admin Fri January 20, 2023 04:17 PM
    you have to extend the ProgressListener class or the SolutionListener and add it to the model with model.add_progress_listener

    Look at https://github.com/IBMDecisionOptimization/docplex/blob/master/docplex/mp/progress.py , for example how the TextProgressListener is implemented if you want to write the solution to a file as soon as it is found, or at SolutionListener, which will collect all the solutions, which you will write to a file all at once.
    Note that the CPLEX callback do not ensure to get all the solutions. In most MIPs, all of them are collected, but in some extreme cases, the callback may not be triggered.


    ------------------------------
    Vincent Beraudier
    ------------------------------