Obtaining intermediate solutions while the or-tools solver runs

83 views
Skip to first unread message

Alberto Manzini

unread,
Dec 16, 2025, 3:20:22 PM12/16/25
to or-tools-discuss

Louie Hext

unread,
Feb 7, 2026, 3:49:07 AM (4 days ago) Feb 7
to or-tools-discuss
You can add some small rewards / penalties such that these "intermediary" solutions no longer all have the same exact objective.

Louie Hext

unread,
Feb 7, 2026, 4:53:17 AM (4 days ago) Feb 7
to or-tools-discuss
Or step back, why do you want these intermediary solutions?

Is it that you think they will be better than the ones found later? -> improve your objective 

Do you want to find more of an range of good solutions rather than an optimal? Solve once, take some threshold of the optimal objective found, then set a new constraint that the objective must be above that. Then solve with enumerate all solutions.
Message has been deleted

Alberto Manzini

unread,
7:09 AM (16 hours ago) 7:09 AM
to or-tools-discuss
No, I need the intermediate solutions to be validated by another tool in order to measure other KPIs that cannot be computed in the optimization model
That is why I need possibly all solutions found by solver, but taking into account the objective function minimization

Louie Hext

unread,
11:38 AM (12 hours ago) 11:38 AM
to or-tools-discuss
Ahh interesting problem. So ultimately your objective in CP-sat doesn't reflect your true objective.

I think you need to change "I need all possible solutions" to "the best solution is likely to be in the top x% of my CP-sat objective".

If possible you can come up with some heuristics that captures the kpis you are missing such that your CP-sat ojective is more useful.
Then solve again with a constraint based on the % of your best solution, and set enumerate all solutions to true in the solver settings.

I've had similar problems in the past. One thing to be careful of is adding in too many factors into the objective such that it slows down the solve, without these factors actually helping.

Some other ideas I've explored;
- doing multiple solves and adjusting the weights in the objective slightly. This would give  slightly different solutions.
- locking certain variables to force the solver to explore a subset of the solutions.
Reply all
Reply to author
Forward
0 new messages