In my EasyScoreCalculator code, whenever it deducts points from the soft score because of logic I set up, I want it to record some sort of message for me to view with the solution to help explain the score ("Deducted X points because Job Y is directly after Job X").
I've tried multiple ways of doing this, but none have seemed to work. If Lesson.java is my planning entity, I've tried creating a property in that class for EasyScoreCalculator to record the reason in (myLesson.addScoreExplanation("Deducted X points because Y")
). The EasyScoreCalculator clears the scoreExplanations of each Lesson when it evaluates a new solution. I've also tried just recording these messages in my main class with public static List<String> scoreExplanations
. As well as a couple others, I've found that in the result I see messages that seem to belong to other solutions (not the optimal one). I'm not very sure what to do about this. Any advice?
Keep in mind, I'm very new to OptaPlanner, and this functionality probably exists somewhere. Thank you.
There is no way to do what you're asking, out of the box. The reason why EasyScoreCalculator
is "easy" is that it sacrifices some features for the sake of simplicity of implementation.
If you need constraint justifications, you need to look into Constraint Streams. IncrementalScoreCalculator
technically also supports justifications, but as a beginner, I believe you'll have a much better time with Constraint Streams.