メインコンテンツへスキップ

How to get specified number of solutions

回答済み

コメント

2件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff 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?.
  • Silke Horn
    • Gurobi Staff Gurobi Staff

    Hi,

    There are more than six feasible solutions but six optimal ones. To get multiple solutions, you can use the Solution Pool feature.

    I am not aware of any way to retrieve multiple solutions using the command-line tool (gurobi_cl), but you could use a short Python script instead. E.g.

    model.params.PoolSolutions = 4
    model.params.PoolSearchMode = 2   # find n best solutions (increases the cost of the solve)

    model.optimize()
    for i in range(model.SolCount):
    model.params.SolutionNumber = i
    result = model.getAttr("Xn", model.getVars())
    print(result)
    0

投稿コメントは受け付けていません。