You may want to also try attaching a salience attribute to each rule. -----Original Message----- From: Michael Neale [mailto:[EMAIL PROTECTED] Sent: Friday, 27 January 2006 11:06 AM To: user@drools.codehaus.org Subject: Re: [drools-user] Scheduling/Timetabling with drools
No I don't think you need to follow miss manners. Miss manners is designed to stress rule engines for performance profiling reasons, so probably not ideal to emulate ! I am not quite across what you are doing, but I can take a wild stab... (I hope no one gets hurt)... Well in the first rule when you match a Task to a Slot and then modify, instead assert a new object which is a tuple of the Task and Slot combination. Then have a 2nd rule which checks that combination - if its bad, it retracts that combination. If its OK, then it does the assignment (if it wasn't done before), and then retracts those Tasks/Slots so they are not considered again. Can something like that work? Or did I just take out someone eye (I can hear the screaming). Michael. On 1/27/06, Robert Jaemmrich <[EMAIL PROTECTED]> wrote: > > Hi, > > is it possible (or wise ;-) to use drools in a scheduling application? > > I want to place Tasks into Timeslots. Placement is dependant on certain > constraints (hard or maybe soft) and ressources. Each slot can contain > one task. > > E.g. I have some tasks {t1,t2,t3} to place on slots {s1,s2,s3,s4}. > > Constraints are defining which slots a task may be placed into > (c1{t1;s1..s4}, c2{t2;s1,s4}) or define a task sequence > (task1.slotNumber < task2.slotNumber). > > My naive "newbie approach" is to define two rules like this: > > <rule name="Assign Next" no-loop="yes"> > <parameter identifier="task"> > <class>Task</class> > </parameter> > <parameter identifier="slot"> > <class>Slot</class> > </parameter> > <java:condition> > slot.getTask() == null > </java:condition> > <java:condition> > task.getSlot() == null > </java:condition> > <java:consequence> > System.out.println("Placing "+task.getName()+" on > "+slot.getName()); > task.setSlot(slot); > slot.setTask(task); > drools.modifyObject(slot); > drools.modifyObject(task); > </java:consequence> > </rule> > > <rule name="Reset"> > <parameter identifier="task"> > <class>Task</class> > </parameter> > <parameter identifier="constraint"> > <class>Constraint</class> > </parameter> > <java:condition> > task.getSlot() != null > </java:condition> > <java:condition> > !constraint.isOK(task) > </java:condition> > <java:consequence> > System.out.println("Resetting ... "); > Slot slot = task.getSlot(); > task.setSlot(null); > drools.modifyObject(task); > slot.setTask(null); > drools.modifyObject(slot); > </java:consequence> > </rule> > > It assigns tuples of "Slot" and "Task" first and checks if they are ok > (constraint.isOK) second. This leads to an infinite loop flipping > between the two rules. > > Do I have to use a more "Miss Manners"ish approach of implementing some > sort of backtracking mechanism by myself? I think I have to use some > kind of depth search to avoid wasting huge quantities of workingMemory ..? > > Any help would be appreaciated! ;-) > > > TIA, > > Robert > This correspondence is for the named persons only. It may contain confidential or privileged information or both. No confidentiality or privilege is waived or lost by any mis transmission. If you receive this correspondence in error please delete it from your system immediately and notify the sender. You must not disclose, copy or relay on any part of this correspondence, if you are not the intended recipient. Any opinions expressed in this message are those of the individual sender except where the sender expressly, and with the authority, states them to be the opinions of the Department of Emergency Services, Queensland.