How do I get all the optimal solutions from my linear programming with pyscipopt?

227 Views Asked by At

How do I get all the optimal solutions from my linear programming with pyscipopt? I just want to display them(using print()).

I see that my Linear Programming has several optimal feasible solutions. However, I can only view one. The function model.getNBestSolsFound() gives me the number of optimal solutions.

Many thanks for your help!

1

There are 1 best solutions below

2
On

@user22146991! You can use print(model.getSols()) to get what you wanted.

Sometimes (I suspect it's whenever the trivial heuristic solves the problem) PySCIPOpt can't print the solutions, but they're still there. You can iterate through the solution and then, in each solution, iterate through the variables.

EDIT: This answer assumes that SCIP manages to find all the optimal solutions you want since it stops the solving process as soon as it proves the optimality of a solution, as discussed in the comments.