0

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.

MattWolc24
  • 106
  • 1
  • 9

1 Answers1

2

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.

Lukáš Petrovický
  • 3,945
  • 1
  • 11
  • 20
  • There's no way I can set up justifications manually? I thought they ways I'd tried would work, but I'm not sure why they haven't. – MattWolc24 Jul 07 '23 at 20:57
  • Constraint justifications only work with incremental score calculation, where the score is computed bit by bit. In easy score calculation, the score is computed all in one big chunk. The only way how you could do constraint justifications is completely hand-rolled. When you receive the solution, analyze entities and their values and produce whatever information you need. But there isn't - and can not be - support for this in the easy calculator. It has no concept of a constraint. – Lukáš Petrovický Jul 07 '23 at 20:59
  • Ok thanks for the help – MattWolc24 Jul 07 '23 at 21:01