Hi, I am relatively new to the Drools space and I am working on a project
utilizing Drools planner (5.4.0.Beta1) for use in scheduling events. I have
a set of events of varying duration and a set of possible venues for the
events with varying availability. I read some previous comments relating to
similar problems and it seems that the best approach is to create time slots
for each of the venues and then assign the events to time slots based on the
availability similar to how the CloudBalancing example assigns tasks to
machines. The difference is that I need to know the actual start/end time of
each event for a given time slot during planning in order to make sure that
an event is not scheduled at the same time as another event from a previous
run of the solver for another schedule.
Here is how the problem is modeled (simplified to the important parts):
- Event (Planning entity) {venueTimeSlot, startDateTime, endDateTime,
duration}
- VenueTimeSlot (Planning Variable) {Venue, startDateTime, endDateTime,
duration}
- PreviousEvent (Constraint) {Venue, startDateTime, endDateTime}
And the pertinent rules:
// Rule that makes sure the time slot can fit the number of events scheduled
in it.
rule "minimalDurationTotal"
when
$venueTimeSlot : VenueTimeSlot($duration : duration)
$minimalDurationTotal : Number(intValue > $duration) from
accumulate(
Event(venueTimeSlot == $venueTimeSlot, $minimalDuration :
totalDuration),
sum($minimalDuration)
)
then
insertLogical(new IntConstraintOccurrence("minimalDurationTotal",
ConstraintType.NEGATIVE_HARD, $minimalDurationTotal.intValue() - $duration,
$venueTimeSlot));
end
// Rule that checks for any previous events that were already scheduled for
this venue
rule "previousEventConflict"
when
$e : Event($venue:venueTimeSlot.venue)
exists PreviousEvent(venue == $venue, startDateTime <= $e.endDateTime,
$e.startDateTime <= endDateTime)
then
insertLogical(new IntConstraintOccurrence("previousEventConflict",
ConstraintType.NEGATIVE_HARD, 1, $e));
end
// Rule that calculates the start/end date time for the event based on the
events in the time slot
rule "updateEventDateTime"
salience 10
when
$e : Event()
$eventList : LinkedList() from collect(
Event(venueTimeSlot == $e.venueTimeSlot)
)
then
$e.updateDateFromEventList($eventList); --> Loops through the events and
sets the startDateTime
end
Ok, so this rule that updates the date time is where I am not sure about, I
get an error about score corruption during the construction heuristic phase.
java.lang.IllegalStateException: Score corruption: the presumedScore
(0hard/0soft) is not the uncorruptedScore (-1hard/0soft):
The workingMemory has 0 ConstraintOccurrence(s) lacking:
previousEventConflict/NEGATIVE_HARD:[Event 75]=1
Check the score rules who created those ConstraintOccurrences. Verify that
each ConstraintOccurrence's causes and weight is correct.
Problem is I don't know what order the events were "added to the time slot"
so every time I call the updateDateFromEventList method the list of events
may be in a different order and therefore change the actual time they occur.
How is it that I set the position of the event when the time slot is set by
the construction heuristic? Or is there a better way altogether to model
this?
Any insight you can provide would be appreciated.
Best Regards,
Nick
--
View this message in context:
http://drools.46999.n3.nabble.com/Scheduling-events-with-varying-duration...
Sent from the Drools: User forum mailing list archive at
Nabble.com.