Вопрос

can someone explain the purpose of the methods that need to be implemented for incremental score calculation? I understand all the after... methods, but why should I adjust the score before an entity is added, removed or a variable is changed (beforeEntityAdded, beforeVariableChanged, beforeEntityRemoved)?

Это было полезно?

Решение

See this image from the 6.0.0.Final docs:

enter image description here

Also see the section "incremental score calculation" (which also explains why this is so much faster than SimpleScoreCalculator). Look at the example implementations. You'll see that beforeVariableChanged() is needed to retract the violated constraint matches that no longer match.

In the diagram above, the ChangeMove needs to get +1 because AB no longer match during the beforeVariableChanged() method and -1 becaues AC now match during the afterVariableChanged method.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top