Skip to main content

How to return the solution for each iteration when using barrier method? (C++)

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Jaromił Najman
    • Gurobi Staff

    Hi,

    There is no direct way to access the solution of each Barrier iteration. However, you can get each solution point by a small workaround.

    You can set the Method parameter to 2 to enforce the Barrier algorithm and set the Crossover parameter to 0 to turn off crossover. Then you can set the BarIterLimit parameter to a value \(n\) which will be the last iteration of the Barrier algorithm.

    With these settings you can optimize your model, which will run only up to iteration \(n\) and then get the current iteration solution via

    model.getVars()

    and get the current iteration solution value via

    m.objVal()

    To get all solutions, you will have to re-iterate the above for different \(n\).

    Best regards,
    Jaromił

    1

Post is closed for comments.