RE : [rules-users] Re: [drools-solver] help for defining my drools model/ moves

Laurent Michenaud lmichenaud at adeuza.com
Mon Jun 29 13:46:36 EDT 2009


Hi,

Thanks for your answer. I will study it next.

I have changed a little my solution and the solver
seems to do more things and finds more solutions :
- The move list are generated at each loop.
- The init solution has no customer availability and 
the only possible move is to choose one.
- When a customer availability is chosen, i initialize
the resource shifts list of the solution myself.
- Then, the only possible moves are to replace a resource shift
by another one, or add one if the number of needed persons is not reached.

My soft rules are the following:
- sum of all distances between the resources and the appointment.
- the number of resource shifts * 1000 ( less resource shifts is considered a better solution ).

I have configured a solution recaller to keep the n best solutions.

Please look at the log of the solutions below because i think i
have a problem :

    Solution 1 : 
         score : 0hard/-102030soft
         CustomerAvailability : [start=2009-05-11 10:00:00.0,end=2009-05-11 12:00:00.0,duration=120]
         persons count : 3
         distance : 100030
         ResourceShift[id=1,period=[start=2009-05-11 08:00:00.0,end=2009-05-11 12:00:00.0,duration=240],resourceId=1,distance=100000]
         ResourceShift[id=3,period=[start=2009-05-11 09:00:00.0,end=2009-05-11 11:00:00.0,duration=120],resourceId=2,distance=30]
    /
    Solution 2 : 
         score : 0hard/-104070soft
         CustomerAvailability : [start=2009-05-11 10:00:00.0,end=2009-05-11 12:00:00.0,duration=120]
         persons count : 3
         distance : 40
         ResourceShift[id=4,period=[start=2009-05-11 08:00:00.0,end=2009-05-11 12:00:00.0,duration=240],resourceId=3,distance=10]
         ResourceShift[id=3,period=[start=2009-05-11 09:00:00.0,end=2009-05-11 11:00:00.0,duration=120],resourceId=2,distance=30]
    /

I understand the score of the solution 1 ( distance(10000 + 30) + (2 resourceShifts * 1000) = 102030
but i don't understand the score of the solution 2, it is like if it has added the score of
solution 1 + ( distance(10+30) + 2 resourceShifts * 1000) = 104070
It should be 2040.

My soft rule constraints are :

rule "mySoftConstraint"
when
	$appointmentSlot: AppointmentSlot()
then
   insertLogical(new IntConstraintOccurrence("mySoftConstraint",
    	ConstraintType.NEGATIVE_SOFT,
    	$appointmentSlot.getCurrentDistance() + ( $appointmentSlot.getNbShifts() * 1000 ),
        $appointmentSlot)); 
end

It is quite hard to debug that part of the framework and your help would
be welcomed.

Best regards
Michenux.


-------- Message d'origine--------
De: rules-users-bounces at lists.jboss.org de la part de Geoffrey De Smet
Date: lun. 29/06/2009 19:00
À: rules-users at lists.jboss.org
Objet : [rules-users] Re: [drools-solver] help for defining my drools model/ moves
 
I call this problem a "score trap".

The problem is that your moves are to fine grained relatively to the 
rewarding aspect of the score function.

Here are some options:

1) You could introduce an extra bigger move (with a seperate movefactory 
so you can configure relativeSelections independently of your currrent 
movefactories and evaluate the union of those generated moves) which 
creates a new availability and immediatly fills in appointments and 
resources too.

In the examination problem for example, you 'll see 3 moves:
RoomChangeMove & PeriodChangeMove (fine grained)
ExamSwitchMove (course grained as it moves 2 exams, both in room and period)

2) You could also change the rewarding aspect of your score function to 
avoid score traps. Like a chosen availability with less then 5 resources 
doesn't trigger the constraint.

In the manners2009 problem for example, you 'll see the extra score rule 
atLeastOneJobTypePerTableScoreGuider:
- twoSameJobTypePerTable: punish all tables without 2 of a profession
- atLeastOneJobTypePerTableScoreGuider: punish all tables with 1 of a 
profession even harder
The SeatDesignationSwitchMove can only move 1 profession at a time at a 
table, so without atLeastOneJobTypePerTableScoreGuider it would have no 
insentive to move 1 profession to a table with 0 of that profession.

3) On trunk you can plug in a custom deciderScoreComparatorFactory and a 
custom ScoreDefinition. Keep the annoying constraint separately in the 
Score and make your deciderScoreComparatorFactory ignore it every 50 
steps for a duration of 10 steps.

With kind regards,
Geoffrey De Smet


Laurent Michenaud schreef:
> Hi,
> 
> Here is my test :
> I have an appointment to schedule on a customer availability.
> I have a list of customer availabilities.
> A customer availability is a period.
> An appointment needs an exact number of persons.
> A resource is composed of persons ( between 1 and n ) and has availabilities too.
> 
> The problem is to schedule the appointment : it has to choose the
> right resource availabilities that matches one of the customer availabilities and 
> the total number of persons inside chosen resources must match exactly the 
> needed number of persons of the appointment.
> 
> My moves are for the moment :
> - Change the customer availability.
> - Add a resource to the list of chosen resources.
> 
> My init is :
> - One of the customer availability is taken
> - 0 resource taken.
> 
> First, i don't know if my model and my init are ok.
> Secondly, the solver does the following :
> 
> - At the beginning, the score is bad because there is no resource.
> So, it begins adding resource and the score is getting better
> but when it changes the availability, the score gets very bad either because
> the chosen resources don't match the new availability or it has no resource
> inside. The solver doesnot seem to interest in the new chosen availibity with no
> resource, but i wish it does.
> 
> Thanks for your remarks/help
> 
> Best regards
> 
> 
> 
> 
> 
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 5612 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20090629/64fde9e6/attachment.bin 


More information about the rules-users mailing list