Retrieving multiple optimal solutions for multiscenario in Python
AnsweredHi, I used below code to create 5 scenarios and I want to find 10 best solutions for each scenario, but I don't know how to retrieve all solutions for each scenario. I can only obtain 10 best solutions for the first scenario. Could you please let me know how to resolve it? Thank you!
# set parameters
m.setParam(GRB.Param.PoolSolutions, 10)
m.setParam(GRB.Param.PoolSearchMode, 2)
m.NumScenarios = 5
for i in range(5):
m.Params.ScenarioNumber = i
m.ScenNName = 'change = ' + str(5 - i)
changeConstr.ScenNRhs = 5 - i
# retrieve solutions
for i in range(m.SolCount):
m.setParam(GRB.Param.SolutionNumber, i)
m.update()
sol = (A.getAttr("xn"),B.getAttr("xn"),m.PoolObjVal)
0
-
At present, obtaining n best solutions for each scenario in a multi-scenario model through solution pools is not supported.
0 -
Hi,
Not the best way, but maybe you can extract each scenario using m.SingleScenarioModel(), and then optimize all of them to retrieve all solutions for each scenario.
I am trying the below as well:
0
Please sign in to leave a comment.
Comments
2 comments