0

My model supports real-time change by Solver#addProblemFactChange and ProblemFactChange interface. Implementing doChange method of this interface, I actively use notifications of scoreDirector by methods like beforeEntityRemoved, beforeProblemFactRemoved, beforeProblemFactChanged and other. Besides, incremental score calculator of model implements callback methods beforeEntityAdded, beforeEntityRemoved and their after-versions.

Investigating solver behavior, I saw such diagram of score calculator calls from optaplanner:

Callbacks call diagram

That is optaplanner doesn't invoke entities related methods of calculator despite model changes. Why so occurs and why necessary to notify scoreDirector?

injecto
  • 829
  • 1
  • 10
  • 23
  • That diagram doesn't look right... or I am intepreting/parsing it incorrectly. Standardizing on an UML sequence diagram should remove my parsing issues. – Geoffrey De Smet Apr 24 '15 at 07:22
  • @GeoffreyDeSmet Yes, my diagram isn't canonical. I use it only to show absence of some callbacks. Correct sequence diagram already exist [in docs](http://docs.jboss.org/optaplanner/release/6.2.0.Final/optaplanner-docs/html_single/images/Chapter-Score_calculation/incrementalScoreCalculatorSequenceDiagram.png). – injecto Apr 24 '15 at 08:09

1 Answers1

1

The ProblemFactChange api has been designed to allow incremental changes to the problem, therefore you need to call before|afterProblemFactAdded|Changed|Removed(), otherwise implementing incremental problem changes with be impossible (without changing the API).

It's the ScoreDirector's responsibility to handle those events:

  • DroolsScoreDirector works incrementally for problem facts too (not just planning variables).
  • IncrementalScoreDirector does not do it incrementally yet for problem facts (but it does for planning variables). There is just some stopgap code with a TODO there in 6.2, which works but doesn't work as fast as it should.

I created a jira issue to track this issue.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120