[rules-users] [Planner]

ge0ffrey ge0ffrey.spam at gmail.com
Fri May 3 04:16:58 EDT 2013


Mats Norén wrote
> Hi,
> I've got a really simple problem that I can't seem to fix. :-)
> I'm trying to use a simplified model for a room planning problem.
> The planning entity is a Topic and the planning variables are Room and
> TimeSlot.
> A Person is tied to a Topic as a moderator.
> Each Person can have multiple Topics as an interest.
> 
> The hard constraints are that a Person cannot be moderator in two Topics
> at
> the same TimeSlot and that there cannot be multiple Topics in the same
> Room
> at the same TimeSlot.
> 
> rule "conflictingModeratorInSameTimeslot"
>     when
>         $leftTopic : Topic($leftId : id, $leftTimeslot : timeSlot,
> timeSlot
> != null, $leftModerator: moderator)
>         $rightTopic : Topic(timeSlot == $leftTimeslot, moderator ==
> $leftModerator, id > $leftId)
>     then
>         scoreHolder.addHardConstraintMatch(kcontext, -1);
> end
> 
> rule "multipleTopicsInSameRoomAndTimeslot"
>     when
>         $leftTopic : Topic($leftId : id, $leftTimeslot : timeSlot,
> timeSlot
> != null, $leftRoom: room)
>         $rightTopic : Topic(timeSlot == $leftTimeslot, room == $leftRoom,
> id > $leftId)
>     then
>         scoreHolder.addHardConstraintMatch(kcontext, -1);
> end

yep, that's like in the curriculum course scheduling example


Mats Norén wrote
> The soft constraint that I have a problem with is that a Person has
> multiple Topics as interests and I would like to penalize the Solution
> with
> the number of Topics in the Persons interests collection with the number
> of
> Topics that are allocated at the same TimeSlot.
> 
> Any ideas on how to go about this?

when
  $p : Person
  $rightTopic : Topic( $leftId : id, $t : timelsot)
  exists Interest(person == $p, topic == $leftTopic)
  Topic(id > $leftId, timeslot == $t)
  exists Interest(person == $p, topic == $rightTopic)
then
  // This will count the number of conflicting topic pairs
  // 2 conflicting topics count 1
  // 3 conflicting topics count 3
  // 4 conflicting topics count 6

You 'll probably want to split up the class Topic into Topic and
TopicAssignement, like in the examination example (see domain diagram in
latest manual)






--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-Planner-tp4023586p4023658.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list