How to get specified number of solutions
回答済みThere are 6 solutions for this problem. I want random 4 solutions. Also I want to get
solutions like this form 0 1 1 0.
I use this comment.
gurobi_cl ResultFile=coins.sol Sample.lp
Maximize
v0 + v1 + v2 + v3
Subject To
C1 : v0 + v1 + v2 + v3 <= 2
Binaries
v0 v1 v2 v3
End
0
-
正式なコメント
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?. -
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
投稿コメントは受け付けていません。
コメント
2件のコメント