[rules-users] Re: Drools : usage as appointment booking engine ?

2009-05-08 Thread Wim Vancroonenburg
That makes a lot of sense. Metaheuristics and local search methods 
(which Drools Solver supports) are great for creating schedules, roster, 
plannings, ... . I've been using Drools Solver for a bed assignment 
problem in health care (more of a benchmark problem) and it performs 
well. Colleagues of mine are solving exam-timetables and 
course-timetables  with metaheuristics, so these type of problems should 
be equally doable with Drools Solver.


Drools Solver does not have any time "operators" like Nicolas says, that 
is something that your model should implement.


Sincerely,

Wim Vancroonenburg

Greg Barton wrote:
Well, Fusion is mainly geared towards processing incoming dynamic events.  

Drools-solver would be best for creating the appointment schedule.  However, if you want to react to real time changes that may affect your schedule, you could always use drools-fusion for that. (i.e. we have an appointment for Bob, Alice, and Chuck in Room D on Monday.  Then an event comes in saying Chuck is sick within 30 minues of the appointment.  If Chuck is a critical member of the meeting the system decides to reschedule, but without the "only on Mondays" constraint.)  


So drools-solver would create the schedule, and drools-fusion would decide in 
real time based on the current schedule structure and the incoming events 
whether to respaawn a solver session to adjust the schedule.  Does that make 
sense?

--- On Thu, 5/7/09, Damien Raude-Morvan  wrote:


From: Damien Raude-Morvan 
Subject: Re: [rules-users] Drools : usage as appointment booking engine ?
To: "Rules Users List" 
Date: Thursday, May 7, 2009, 10:50 AM

Hello,

Hi Nicolas,


you should look at drools-solver
here is a link to the


documentation

Thanks this documentation, I was using oudated
documentation from
http://users.telenet.be/geoffrey/tmp/solver/manual/html_single/
.

I've evaluated drools-solver, for example trying to
evolve
"lessonschedule" sample to include some time
constraints but I failed to
use time "operators" in drools solver.

I found Drools Fusion time constraints (before, inside,
meets) interesting
but for now haven't been able to build something with
it. Drools Fusion
"StockTick" sample seems oriented to STREAM event
and not to managing time
slots and constraints on this time slots.

Anybody having experience with such problems ?

Regards,


2009/5/7 Damien Raude-Morvan



Hi,

I'm evaluating use of Drools 5 as an

appointment booking engine.

My input data are :
- some time slots, defined with a start and end

time.

- some appointment constraints (only monday, only

morning, appointment

theorical duration)

I've looked at Drools 5 Fusion without finding

a way to go with this.

Can someone give me some pointer / start URL about

how to solve this

kind
of problems ?

--
Damien Raude-Morvan / www.drazzib.com

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



  
___

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



___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Avoid unnecessary rule activation when object is retracted

2009-05-08 Thread lsilva

After hours loking for a solutions I finally found it. I had to avoid using
"from" in this case, according to recomendation that I found in this
http://www.nabble.com/Rules-with-from-always-loops-(Drools-4.0.7)-td21930651.html#a21997926
Message 

So, I retired from my rules sentences like:

usageItem: EstimatedElectricUsage() from
account.getElectricUsageEstimation(1,6);

And I had to insert each EstimatedElectricUsage object directly in the
working memory.


lsilva wrote:
> 
> Hi, I'll appreciate any help in this issue
> 
> I'm going to explain my problem, using the next rules as example:
> 
> BEGIN RULE FILE
> (pricing.drl)##
> #created on: 04/05/2009
> package com.mycompany.pricing
> 
> import com.company.FeatureQuoteRequest;
> import com.company.Account;
> import com.company.EstimatedElectricUsage;
> import com.company.AuxDecimal
>  
> global AuxDecimal auxDecimal1;
> 
> #first rule group to calculate the Capacity Factor
> rule "Start capacity factor calculation"
>   salience 20
> when
>   featureQuoteRequest: FeatureQuoteRequest(feature == 'CAPACITY_FACTOR',
> priceAmount == null);
>   account: Account();
>   usageItem: EstimatedElectricUsage() from
> account.getElectricUsageEstimation(1,6);
> then
>   insert (usageItem);
>   drools.setFocus("monthly_capacity_factor"); 
> end
> 
> 
> rule "Get monthly Capacity factor"
>   agenda-group 'monthly_capacity_factor'
> when
>   featureQuoteRequest: FeatureQuoteRequest(feature == 'CAPACITY_FACTOR',
> priceAmount == null);
>   account: Account();
>   usage: EstimatedElectricUsage();
> then
>   auxDecimal1.add(usage.getValue() * 2 + 1);
>   retract(usage);
> end
>  
> rule "Get total Capacity factor"
>   salience 10
> when
>   featureQuoteRequest: FeatureQuoteRequest(feature == 'CAPACITY_FACTOR',
> priceAmount == null);
>   account: Account();
>   totalEstimatedElectricUsage: Double() from
> accumulate(EstimatedElectricUsage (value: value) from
> account.getElectricUsageEstimation(1,6), sum(value));
> then
> 
> featureQuoteRequest.setPriceAmount(auxDecimal1.getValue()/totalEstimatedElectricUsage);
> end
> 
> 
> #second rule group to calculate the Transmision Factor
> rule "Start transmision factor calculation"
>   salience 20
> when
>   featureQuoteRequest: FeatureQuoteRequest(feature == 
> 'TRANSMISION_FACTOR',
> priceAmount == null);
>   account: Account();
>   usageItem: EstimatedElectricUsage() from
> account.getElectricUsageEstimation(1,6);
> then
>   insert (usageItem);
>   drools.setFocus("monthly_transmision_factor"); 
> end
> 
> rule "Get monthly Transmision factor"
>   agenda-group 'monthly_transmision_factor'
> when
>   featureQuoteRequest: FeatureQuoteRequest(feature == 
> 'TRANSMISION_FACTOR',
> priceAmount == null);
>   account: Account();
>   usage: EstimatedElectricUsage();
> then
>   auxDecimal1.add(usage.getValue() * 2 + 1);
>   retract(usage);
> end
>  
> rule "Get total Transmision factor"
>   salience 10
> when
>   featureQuoteRequest: FeatureQuoteRequest(feature == 
> 'TRANSMISION_FACTOR',
> priceAmount == null);
>   account: Account();
>   totalEstimatedElectricUsage: Double() from
> accumulate(EstimatedElectricUsage (value: value) from
> account.getElectricUsageEstimation(1,6), sum(value));
> then
> 
> featureQuoteRequest.setPriceAmount(auxDecimal1.getValue()/totalEstimatedElectricUsage);
> end
> 
> END RULE FILE (pricing.drl)##
> 
> 
> 
> 
> And I have the nex class to process the rules:
> 
> BEGIN JAVA CLASS FILE ##
> 1. package com.company;
> 2. 
> 3. import java.io.InputStreamReader;
> 4. import java.io.Reader;
> 5. import java.util.ArrayList;
> 6. import java.util.List;
> 7. 
> 8. import org.drools.FactHandle;
> 9. import org.drools.RuleBase;
> 10. import org.drools.RuleBaseFactory;
> 11. import org.drools.WorkingMemory;
> 12. import org.drools.audit.WorkingMemoryFileLogger;
> 13. import org.drools.compiler.PackageBuilder;
> 14. import org.drools.rule.Package;
> 15. 
> 16. public class PricingCalc {
> 17. 
> 18.   FactHandle handleQuoteRequest = null;
> 19.   FactHandle handleAccount = null;
> 20.   
> 21.   public PricingCalc() {
> 22.   }
> 23.
> 24.   public static final void main(String[] args) {
> 25.   PricingCalc pricingCalc = new PricingCalc();
> 26.   pricingCalc.runPricingCalc();
> 27.   }
> 28.
> 29.   private void runPricingCalc(){
> 30.   try {
> 31.   
> 32.   //load up the rulebase
> 33.   RuleBase ruleBase = readRule();
> 34.   WorkingMemory workingMemory =
> ruleBase.newStatefulSession();
> 35.   
> 36.   WorkingMemoryFileLogger logger = new
> WorkingMemoryFileLogger(workingMemory);
> 37.   

Re: [rules-users] drools solver for 2d knapsack problem

2009-05-08 Thread Wolfgang Laun
That's indeed more like a problem for using rules (and far from the plain
"cutting sheet" I had in mind), From the examples, itc2007 and
lessonsschedule might give you an idea how to approach your problem.
-W


On Fri, May 8, 2009 at 1:05 PM, Olaf Raether  wrote:

>
> I think it´s more a knapsack problem. And the rectangles have to follow
> some
> business rules,
> so that´s the reason try to using solver. Here´s an image of the problem.
>
> http://www.nabble.com/file/p23443994/2dknapsack.jpg 2dknapsack.jpg
>
> The big rectangle is the load area of a truck und the small ones are racks.
> And i have to
> put them on the truck. And the Business rules come into the play, cause the
> racks can only
> mounted in a special manner on the track.
>
> Any hint is welcome
>
>
>
> Wolfgang Laun-2 wrote:
> >
> > I've researched this, a long time ago (trying to find a solution for a
> > problem from the "worse" class). Even then, several results could be
> found
> > in the literature for the "cutting sheet" problem for rectangles, showing
> > that certain parameters (w.r.t. to rectangle dimensions being multiples
> of
> > each other, replication factors, etc.) influence the problem space
> > considerably. (Cutting random rectangles from a sheet is hardly an
> > industry
> > problem.)
> >
> > Having said that, drools-solver should be able to handle this problem.
> >
> > However, it is very likely that there is an algorithm that solves your
> > particular problem more efficiently.
> >
> > -W
> >
> >
> > On Fri, May 8, 2009 at 9:59 AM, Olaf Raether  wrote:
> >
> >>
> >> Rectangles within a Rectangle
> >>
> >> OR
> >>
> >>
> >> Wolfgang Laun-2 wrote:
> >> >
> >> > Rectangles or simple polygons or worse?
> >> > -W
> >> >
> >> > On Fri, May 8, 2009 at 9:02 AM, Olaf Raether 
> wrote:
> >> >
> >> >> Hey , i would like to use drools solver for a 2d knapsack problem.
> >> >> Has anyone expirience with that ?
> >> >> Is drools solver made for such a task ?
> >> >>
> >> >> Thank for hints
> >> >>
> >> >> Olaf Raether
> >> >>
> >> >> ___
> >> >> rules-users mailing list
> >> >> rules-users@lists.jboss.org
> >> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >> >>
> >> >
> >> > ___
> >> > rules-users mailing list
> >> > rules-users@lists.jboss.org
> >> > https://lists.jboss.org/mailman/listinfo/rules-users
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/drools-solver-for-2d-knapsack-problem-tp23441149p23441743.html
> >> Sent from the drools - user mailing list archive at Nabble.com.
> >>
> >> ___
> >> rules-users mailing list
> >> rules-users@lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> >
> > ___
> > rules-users mailing list
> > rules-users@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/drools-solver-for-2d-knapsack-problem-tp23441149p23443994.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools solver for 2d knapsack problem

2009-05-08 Thread Olaf Raether

I think it´s more a knapsack problem. And the rectangles have to follow some
business rules,
so that´s the reason try to using solver. Here´s an image of the problem.

http://www.nabble.com/file/p23443994/2dknapsack.jpg 2dknapsack.jpg 

The big rectangle is the load area of a truck und the small ones are racks.
And i have to 
put them on the truck. And the Business rules come into the play, cause the
racks can only 
mounted in a special manner on the track.

Any hint is welcome



Wolfgang Laun-2 wrote:
> 
> I've researched this, a long time ago (trying to find a solution for a
> problem from the "worse" class). Even then, several results could be found
> in the literature for the "cutting sheet" problem for rectangles, showing
> that certain parameters (w.r.t. to rectangle dimensions being multiples of
> each other, replication factors, etc.) influence the problem space
> considerably. (Cutting random rectangles from a sheet is hardly an
> industry
> problem.)
> 
> Having said that, drools-solver should be able to handle this problem.
> 
> However, it is very likely that there is an algorithm that solves your
> particular problem more efficiently.
> 
> -W
> 
> 
> On Fri, May 8, 2009 at 9:59 AM, Olaf Raether  wrote:
> 
>>
>> Rectangles within a Rectangle
>>
>> OR
>>
>>
>> Wolfgang Laun-2 wrote:
>> >
>> > Rectangles or simple polygons or worse?
>> > -W
>> >
>> > On Fri, May 8, 2009 at 9:02 AM, Olaf Raether  wrote:
>> >
>> >> Hey , i would like to use drools solver for a 2d knapsack problem.
>> >> Has anyone expirience with that ?
>> >> Is drools solver made for such a task ?
>> >>
>> >> Thank for hints
>> >>
>> >> Olaf Raether
>> >>
>> >> ___
>> >> rules-users mailing list
>> >> rules-users@lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >>
>> >
>> > ___
>> > rules-users mailing list
>> > rules-users@lists.jboss.org
>> > https://lists.jboss.org/mailman/listinfo/rules-users
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/drools-solver-for-2d-knapsack-problem-tp23441149p23441743.html
>> Sent from the drools - user mailing list archive at Nabble.com.
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> 
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/drools-solver-for-2d-knapsack-problem-tp23441149p23443994.html
Sent from the drools - user mailing list archive at Nabble.com.


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools solver for 2d knapsack problem

2009-05-08 Thread Wolfgang Laun
I've researched this, a long time ago (trying to find a solution for a
problem from the "worse" class). Even then, several results could be found
in the literature for the "cutting sheet" problem for rectangles, showing
that certain parameters (w.r.t. to rectangle dimensions being multiples of
each other, replication factors, etc.) influence the problem space
considerably. (Cutting random rectangles from a sheet is hardly an industry
problem.)

Having said that, drools-solver should be able to handle this problem.

However, it is very likely that there is an algorithm that solves your
particular problem more efficiently.

-W


On Fri, May 8, 2009 at 9:59 AM, Olaf Raether  wrote:

>
> Rectangles within a Rectangle
>
> OR
>
>
> Wolfgang Laun-2 wrote:
> >
> > Rectangles or simple polygons or worse?
> > -W
> >
> > On Fri, May 8, 2009 at 9:02 AM, Olaf Raether  wrote:
> >
> >> Hey , i would like to use drools solver for a 2d knapsack problem.
> >> Has anyone expirience with that ?
> >> Is drools solver made for such a task ?
> >>
> >> Thank for hints
> >>
> >> Olaf Raether
> >>
> >> ___
> >> rules-users mailing list
> >> rules-users@lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> >
> > ___
> > rules-users mailing list
> > rules-users@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/drools-solver-for-2d-knapsack-problem-tp23441149p23441743.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] trying to retrieve facts from WorkingMemory

2009-05-08 Thread Michal Bali
try drools.getWorkingMemory()

On Thu, May 7, 2009 at 12:23 PM, Kevin Alonso  wrote:

> I“m trying to retrieve the information of the Working memory inside an
> action element of the ruleflow.
>
> I have already writed a query in to .drl file
>
> query "Random Word"
>   rw : RandomWord()
> end
>
> And part of the code in the action element is the next:
>
> QueryResults results = workingMemory.getQueryResults("Random Word" );
> System.out.println( "we have " + results.size() + " random words" );
>
> I have obtained this code  from documentation, but I don“t know how to get
> the workingMemory object.
>
> Regards,
>
> Kevin
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools solver for 2d knapsack problem

2009-05-08 Thread Olaf Raether

Rectangles within a Rectangle

OR


Wolfgang Laun-2 wrote:
> 
> Rectangles or simple polygons or worse?
> -W
> 
> On Fri, May 8, 2009 at 9:02 AM, Olaf Raether  wrote:
> 
>> Hey , i would like to use drools solver for a 2d knapsack problem.
>> Has anyone expirience with that ?
>> Is drools solver made for such a task ?
>>
>> Thank for hints
>>
>> Olaf Raether
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> 
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/drools-solver-for-2d-knapsack-problem-tp23441149p23441743.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools solver for 2d knapsack problem

2009-05-08 Thread Wolfgang Laun
Rectangles or simple polygons or worse?
-W

On Fri, May 8, 2009 at 9:02 AM, Olaf Raether  wrote:

> Hey , i would like to use drools solver for a 2d knapsack problem.
> Has anyone expirience with that ?
> Is drools solver made for such a task ?
>
> Thank for hints
>
> Olaf Raether
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] drools solver for 2d knapsack problem

2009-05-08 Thread Olaf Raether
Hey , i would like to use drools solver for a 2d knapsack problem.
Has anyone expirience with that ?
Is drools solver made for such a task ?

Thank for hints

Olaf Raether

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users