I am using CP-SAT solver to solve a scheduling problem. So far, I've been coming up with lots of hard constraints and searching for all feasible solutions using:
solver = ortools.sat.python.cp_model.CpSolver()
solver.SearchForAllSolutions(model, callback)
I decided to start adding soft constraints by defining penalties and setting the model's objective to minimize those penalties. I refer a lot to
examples/python/shift_scheduling_sat.py when adding such constraints. Since I specify minimization objective, I can't use
solver.SearchForAllSolutions(model, callback) anymore and have to use
solver.SolveWithSolutionCallback(model, callback) that searches for a single
optimal solution.
My question is: is it possible to search for many optimal solutions? The way I currently define soft constraints, there is still quite a few solutions with an objective function value of zero. Even if there is only one optimal solution, is it possible to search for many solutions that are close to optimal within some delta?
My application requires me to generate many alternative solutions that are "good" (there's many feasible solutions but some are better than others). When searching for all feasible solution without defining any soft constraints, there is sometimes way too many solutions that are hard to compare to each other (finding the "better" ones). On the other extreme, after defining some soft constraints I can only search for a single optimal solution. Is there some middle ground where I can search for, let's say, 50 solutions that are close to optimal?