[rules-users] Drools Planner: entity was never added to this ScoreDirector?
Cedric Hurst
cedric at spantree.net
Fri May 4 18:09:12 EDT 2012
Hi all,
I'm working on a Drools Planner 5.4.0.CR1 implementation for a scheduling
app.
First, some background:
The solution class is 'Schedule' and the PlanningEntity is 'Meeting'.
Meetings consist of timeslots (or 'slots'), and two participants in
complimentary roles 'planners' and 'suppliers'. Since there are more
planners than suppliers, I've structured the Schedule model so that its
meeting collection is basically the cross-product of slots and planners.
Suppliers are configured as the @PlanningVariable in a meeting. The meeting
list in the schedule is also annotated as a
@PlanningEntityCollectionProperty. I've structured three MoveFactories that
add, subtract or swap suppliers from meeting to meeting.
That part works fairly well, however, when I try to try to run my solution
through a Solver, I am inevitably plagued with a dreaded message like this:
java.lang.IllegalArgumentException: The entity (Meeting[slot: 26, planner:
29C2E0FF-00EE-409F-B05B-B175B30A6B45, supplier:
BB25B297-54FA-45BD-923A-C209848E74B4,
hashCode: 1219749520, solutionHashCode: -1086095971, slotHashCode:
436282962, plannerHashCode: -2037841459]) was never added to this
ScoreDirector.
at
org.drools.planner.core.score.director.drools.DroolsScoreDirector.afterAllVariablesChanged(DroolsScoreDirector.java:110)
at
org.drools.planner.core.score.director.drools.DroolsScoreDirector.afterVariableChanged(DroolsScoreDirector.java:120)
at
com.somecompany.scheduler.moves.AddSupplierToMeetingMove.doMove(AddSupplierToMeetingMove.groovy:36)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.doMove(DefaultDecider.java:128)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.decideNextStep(DefaultDecider.java:103)
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolverPhase.solve(DefaultLocalSearchSolverPhase.java:57)
at
org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:183)
at
org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:151)
at
org.spockframework.util.GroovyRuntimeUtil.invokeMethod(GroovyRuntimeUtil.java:100)
at com.somecompany.scheduler.solver.SolverSpec.should solve
schedule(SolverSpec.groovy:59)
It seems to happen randomly, with different entities each time, but I've not
yet had a successful run of a full solve cycle without hitting it a least
once. Unfortunately, it kills my whole process.
I've step debugged through the planner internals and verified that all the
meetings are getting added to the working memory, including the offending
one:
2012-05-04 16:30:17,379 INFO com.somecompany.scheduler.solver.SolverSpec
- Meeting[slot: 26, planner: 29C2E0FF-00EE-409F-B05B-B175B30A6B45, supplier:
FEA76C13-C9E2-42EC-977C-BCBB0BD1FFA0, hashCode: 1219749520,
solutionHashCode: -574491332, slotHashCode: 436282962, plannerHashCode:
-2037841459]
I was pretty certain my issue has to do with the meeting's hashCode value,
but as you'll see they're exactly the same in working memory as they are
when . I'm using commons HashCodeBuilder and EqualsBuilder to check only
the fixed slot and planner values. The solutionHashCode changes based on
the slot, planner and supplier-- supplier being the @PlanningVariable. I've
pasted the full log, with trace enabled, here for review:
https://gist.github.com/raw/93752853a0996ae1c016/d0ca35f5c531a2fa25e6a106c90257b015500931/solver-error.log
The error is listed at 2012-05-04 16:30:37,168.
The original meeting in working memory is listed at 2012-05-04 16:30:17,379
(toward the middle of entries with that timestamp).
I couldn't find an easy way to add a knowledge session logger in planner,
but that might also be useful.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Planner-entity-was-never-added-to-this-ScoreDirector-tp3963528.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120504/3527bf0b/attachment.html
More information about the rules-users
mailing list