[rules-users] please help on complex rule (linking entities)

Michiel Vermandel mvermand at yahoo.com
Thu Dec 6 03:30:45 EST 2012


Hi Davido,

I'm not an expert on Drools but here is how I would try to solve it.
You said you know which jobs belong together.
So when you instantiate these jobs , you search for the job with the longest duration.
That becomes the lead-job of your project.
Add a reference to that job in all other jobs of the project and create a getter in the job class ( getLead() ).
Then write a rule like:

when
    $job = Job($lead:lead)
    eval($job.begin < $lead.begin || $job.end > $lead.end)
then
    insertLogical(new IntConstraintOccurrence("beyondLead", ConstraintType.NEGATIVE_HARD, penalty, .??.));
end

 
not really sure which arguments to put as a last.

Maybe there is a better, faster way?

Regards,

Michiel

-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials


________________________________
 From: Dave Brubanks <davebrubanks at rocketmail.com>
To: "rules-users at lists.jboss.org" <rules-users at lists.jboss.org> 
Sent: Wednesday, December 5, 2012 9:51 PM
Subject: [rules-users] please help on complex rule (linking entities)
 

Hi all,

(after writing this mail I realized that it became quite long, but please hang in there with me. my actual question is not that big, I only need to build some context.)

I need to implement a planning for placing new floors in hotels (renovation).
Renovating a single hotel requires a number of jobs. For example

- replacing wooden floor in the lobby
- replacing carpets in the bedrooms
- replacing tiles in the bathroom

Each kind of replacement is done by a specialized kind team. 
Thus for example a team that places wooden floors will only do that.


for each renovation project we decide which jobs are needed (for example only carpet and tiles) and we make an estimate of how many people we want to send there and how long it will take to complete the job. 

For example: we have a 

Renovation
 A
- replacing wooden floor : 3 weeks, 2 workers
- replacing carpet floor : 5 weeks, 4 workers
- replacing tiles: 4 weeks, 5 workers

Renovation B
- replacing carpet floor : 3 weeks, 1 workers
- replacing tiles: 3 weeks, 2 workers

... and so on.

Now we need to schedule the renovations.
Actually we took the replacement jobs as planning entity, I hope that was the right choise:
In case of renovation A we will have
- 2 jobs of type wood, each lasting 3 weeks.
- 4 jobs of type carpet, each lasting 5 weeks
- 5 jobs of type tile, each lasting 4 weeks.

I currently do not have projects as facts. I do have the project-id set on a Job on its instantiation (so I know which jobs belong together).

When scheduling the jobs of a renovation we need to follow these rules:
- it does not matter when a renovation is planned (for now) (within a given number of weeks - usually 12)
- a resource with the
 required skill needs to be available for doing that kind of job (planning-variable)
- the start of a job needs to be planned in a week (one of 12 - planning 12 weeks at the time) - we do not plan exactly on a day. 
- the job is always done in 1 sequential block of x weeks, no gaps between.
- !! all jobs need to be done within the time of the longest job in the project.
   So in Renovation A all jobs need to be fitted in a time span of 5 weeks.
   In Renovation A the wooden-floor team can start in week 1, 2 or 3 of the 5-week span.
- the jobs of a project do not have to start in the same week (for better occupation)

I already have some rules up and running, but the one I cannot figure how to do is how I can plan the jobs of a renovation project so that they all are planned within the span of the largest job.
Currently I have all jobs of a project to start in the same week... but that limits the number of
 solutions.
In order to get this extra flexibility, do I need to introduce a kind of holder-fact (project)?

Any ideas will be greatly appreciated.

Thanks
Davido


_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20121206/8166ec2e/attachment.html 


More information about the rules-users mailing list