TimefoldAI / timefold-solver-python

Timefold Solver is an AI constraint solver for Python to optimize the Vehicle Routing Problem, Employee Rostering, Maintenance Scheduling, Task Assignment, School Timetabling, Cloud Optimization, Conference Scheduling, Job Shop Scheduling, Bin Packing and many more planning problems.
https://timefold.ai
Apache License 2.0
27 stars 3 forks source link

print(ScoreAnalysis): make it easy to analyze a score during POC #76

Closed ge0ffrey closed 2 days ago

ge0ffrey commented 3 weeks ago

print() is great during POC ScoreAnalysis and ConstraintAnalysis should work will it wel

Blocked by https://github.com/TimefoldAI/timefold-solver/issues/883 This should work well in Java too.

Current status:

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

{ConstraintRef(package_name='org.jpyinterpreter.user.employee_scheduling.domain', constraint_name='Desired day for employee'): <timefold.solver.score._score_analysis.ConstraintAnalysis object at 0x1049b6fc0>, ConstraintRef(package_name='org.jpyinterpreter.user.employee_scheduling.domain', constraint_name='Undesired day for employee'): <timefold.solver.score._score_analysis.ConstraintAnalysis object at 0x17eddc440>, ConstraintRef(package_name='org.jpyinterpreter.user.employee_scheduling.domain', constraint_name='At least 10 hours between 2 shifts'): <timefold.solver.score._score_analysis.ConstraintAnalysis object at 0x17eddc110>, ConstraintRef(package_name='org.jpyinterpreter.user.employee_scheduling.domain', constraint_name='Max one shift per day'): <timefold.solver.score._score_analysis.ConstraintAnalysis object at 0x17eddc200>, ConstraintRef(package_name='org.jpyinterpreter.user.employee_scheduling.domain', constraint_name='Missing required skill'): <timefold.solver.score._score_analysis.ConstraintAnalysis object at 0x17eddc350>, ConstraintRef(package_name='org.jpyinterpreter.user.employee_scheduling.domain', constraint_name='Overlapping shift'): <timefold.solver.score._score_analysis.ConstraintAnalysis object at 0x17eddc380>, ConstraintRef(package_name='org.jpyinterpreter.user.employee_scheduling.domain', constraint_name='Unavailable employee'): <timefold.solver.score._score_analysis.ConstraintAnalysis object at 0x17eddc2f0>}

Desired: I want to know how many overlapping shifts there are, at which impact weight. Pretty printed (see ScoreExplanation docs)

ge0ffrey commented 2 weeks ago

Also MatchAnalysis should have good toString()

print(f'      {match}')

INFO:app:    16 matches: At least 10 hours between 2 shifts = -9600hard/0soft
INFO:app:      <timefold.solver.score._score_analysis.MatchAnalysis object at 0x17731ddc0>
INFO:app:      <timefold.solver.score._score_analysis.MatchAnalysis object at 0x1023597f0>
ge0ffrey commented 2 weeks ago

Probably needs an upstream fix?