TimefoldAI / timefold-solver

The open source AI solver. Timefold is the successor of OptaPlanner, by the OptaPlanner team. Optimize the vehicle routing problem, employee rostering, task assignment, maintenance scheduling and other planning problems with an Open Source AI constraint solver
https://timefold.ai
Apache License 2.0
806 stars 67 forks source link

ScoreAnalysis.summary() for debugging purposes #883

Closed ge0ffrey closed 2 days ago

ge0ffrey commented 3 weeks ago

During POC work it's very handy to be able to drop a score analysis in System.out.print().

ScoreExplanation has this, with the getSummary() method. It shows all constraints and the top 3 constraint matches per constraint.

Why only top 3 matches? In practice during debugging you need to know the first match often, to be able to prove the constraint is there with one match. But the other 297 matches are verbosity that kills the usefulness of getSummary() for debugging purposes. So top 3 is ideal.

If matches weren't fetched, no matches are shown in summary().

ge0ffrey commented 3 weeks ago

ScoreAnalysis should probably also get a toString() method.

Separate issue for @Christopher-Chianelli : enable this in python land too (if it doesn't happen automatically :)

print(score_analysis) <timefold.solver.score._score_analysis.ScoreAnalysis object at 0x3614cba10>