[rules-users] Using accumulate function

2012-04-09 Thread sanal
Hi,
  Iam trying to use the accumulate function of the drools.I need to
accumulate based on the result of a rule execution.
 Eg: Suppose i have list of orders and another list of conditions
for a particular package.I need to check weather each of the order is part
of package or not.
   Suppose  a qty limit is set to 1 for a item in package definition and
the item is ordered 2 times.
While checking the condition, both of the item will go under package.
Actually for second record the rule should get executed based on result of
the 1 record's rule execution and so on.
 So I require a looping rule execution.
How can i achive this using Drools.


Rule Package Rate_21
salience 65515
when
$objOrderedComponents:AccumulatedComponent()
$packageDefinition:PackageDefinition($packageId:packageId)
$accumulatedQty:Number()
from accumulate(
$accQtyComponent:OrderedComponent(packageChargeRecordId==$packageId, $AccQty
: componentQty) from
$objOrderedComponents.getOrderedComponentList(),sum($AccQty ) )

$orderedComponent:OrderedComponent($id1:componentKey,$qty:componentQty) 
from $objOrderedComponents.getOrderedComponentList() and
$pkgComps:PackageComponent(componentKey==$id1,(quantityLmt
=($qty+$accumulatedQty.intValue( from
$packageDefinition.getPackageComponentList()
then
$orderedComponent.setIsComponentApplicable(true);
$orderedComponent.setPackageChargeRecordId($packageId);  
end


Regards
Sanal.P

--
View this message in context: 
http://drools.46999.n3.nabble.com/Using-accumulate-function-tp3896078p3896078.html
Sent from the Drools: User forum 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] Objects from Working Memory not available in drl

2012-04-09 Thread Magublafix
Hey guys,

I'm playing with the drools planner a few days now and got stuck.
I have a Solution with an PlanningEntity Ambulance and a normal Class
SendAmbulance.
I add a List SendAmbulance to the Working Memory with the getProblemFacts()
method. The Ambulance objects are loaded automatically.
The problem now is that i can access the Ambulance Objects within the drl
correctly but nut the SendAmbulance objects.
Has somebody an advice for me to solve this?

thanks,
Magublafix

--
View this message in context: 
http://drools.46999.n3.nabble.com/Objects-from-Working-Memory-not-available-in-drl-tp3896957p3896957.html
Sent from the Drools: User forum 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] Employee Shift Rostering: algorithm details

2012-04-09 Thread HarrySimons
Hi,

I'm new both to Drools Planner and to metaheuristic algorithms like Tabu
Search. Though I have done some preliminary reading on the Net on how this
algorithm 'generally' works -- including reading the 'plain-English'
portions of Chapter 8 of the 'Essentials of Metaheuristics' book -- it still
isn't perfectly clear to me how an actual implementation of the algorithm
would code the 'Tweak' / 'Next Move' function (other than via a random
combination of planning variables) in an application such as Employee Shift
Rostering with a very large search space and with multiple planning
variables.

On the page (http://www.jboss.org/drools/drools-planner.html) where Drools
Planner is compared side-by-side to other naive (greedy algorithms-based)
approachesfor various kinds of problems, could it be the case that the
algorithms used in Drools Planner were able to perfectly solve the
highlighted problems only because of the use of extremely small search
spaces / input datasets?! A wikipedia entry related to metaheuristic
algorithms says that not only is it possible that such an algorithm may not
give an optimal solution, it may not even give any solution at all(!!) due
to the algorithm reaching its timeout limit specified by the user. I'm
assuming it won't be possible to specify a timeout value in days or even
hours for any metaheuristics-based approach to a real-world problem of a
real-world scale.

Lastly, from looking at the pseudocode of Tabu Search, it *appears* that the
core, 'driver portion' of the algorithm may itself be not all that hard to
implement; it is rather the call-back portion of the algorithm (such as the
problem-specific Tweak / Next Move function, which the driver portion calls
back)  that may be hardest to implement. Given this, what would be the
advantages of using Drools Planner over a from-scratch, hand-coded version
of Tabu Search (other than its declarative, rule-based flexibility which a
hand-coded, from-scratch version may not want to implement due to its focus
on solving a specific planning problem vs. a whole slew of generic planning
problems requiring a generic piece of code such as Drools Planner)?

Would greatly appreciate if someone more knowlegeable than me could clarify
/ elaborate on the above getting-started questions of mine.

Regards,
/HS

--
View this message in context: 
http://drools.46999.n3.nabble.com/Employee-Shift-Rostering-algorithm-details-tp3897546p3897546.html
Sent from the Drools: User forum 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] Return List of Fired Rule Name from Decision table

2012-04-09 Thread Vincent Legendre
Title: CARTE DE VISITE

  
  
You should use an AgendaListener instead of polluting your rules
with such things.
see there :
http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-expert-docs/html_single/index.html#d0e2003


Le 09/04/2012 03:21, s a a crit:

  
I have resolved this problem using the following
approach

  
Create a Class with a method (say) 
  
 PrintRuleName(KContext
kcontext) { System.out.println(kcontext.getRuleName());}
  


In the decision table in the action Create an Instance of
  this class and call this method by passing kcontext. Action
  would look like
( Action for each row in decision table will have this)

PrintClass ThePrintClass = new PrintClass();
ThePrintClass.setPrintRuleName(kcontext);


SA




  
 
 From:
srinivasasanda srinivasasa...@gmail.com
To:
rules-users@lists.jboss.org 
Sent:
Thursday, April 5, 2012 8:56 AM
Subject:
[rules-users] Return List of Fired Rule Name from
Decision table
   

Hi,

when a rule fires i am storing the rule name in Result field
of type list as 
result.add(drools.getRule().getName()) -- in 'part' of a
normal rule.

Now i am using decision table,how can i get the rule names
fired. 
I am not able to give java statement in action or in row
contain field.Where
to write that Java statement in Decison Table?Can you
suggest me please.

Thanks
Srinivasa Sanda

--
View this message in context:
http://drools.46999.n3.nabble.com/Return-List-of-Fired-Rule-Name-from-Decision-table-tp3887158p3887158.html
Sent from the Drools: User forum 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




-- 
  
  
  
  
  Vincent
LEGENDRE
  Consultant
  Snior
   
  
  EURODECISION
  9A
rue de la Porte de Buc 78000 VERSAILLES
Tl. : +33 (0)1 39 07 12 40
Direct : +33 (0)1 39 07 26 16
www.eurodecision.com


  

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


Re: [rules-users] Employee Shift Rostering: algorithm details

2012-04-09 Thread ge0ffrey
Drools Planner has 7 real examples, which use large datasets and are solved
near optimal in reasonable time. For example, the nurse rostering example
have search spaces over 10^2000. Research competions show that
metaheuristics are the only algorithems that can handle it in robuust way.

Wikipedia's notes are correct: there is no guarentee that the optimal
solution is found, but exact methods take forever and simplex like methods
perform much worse overall in the competitions.
For example, in the nurserostering example, the medium hint 01 example
performed 100 times ( 10 000%) on a well known simplex framework (the other
datasets were around 5% better or worse).

Tabu search is easy to implement, but there are many optimizations that
Planner implements, such as aspiration, ... Its been improved and under
constant benchmarking since 2006, so it would take some work to replicate
:-)

--
View this message in context: 
http://drools.46999.n3.nabble.com/Employee-Shift-Rostering-algorithm-details-tp3897546p3897706.html
Sent from the Drools: User forum 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] Employee Shift Rostering: algorithm details

2012-04-09 Thread Patrik Dufresne
I may not be an expert, but I may give you some tips.

Read below


Patrik Dufresne


On Mon, Apr 9, 2012 at 1:57 PM, HarrySimons simonsha...@gmail.com wrote:

 Hi,

 I'm new both to Drools Planner and to metaheuristic algorithms like Tabu
 Search. Though I have done some preliminary reading on the Net on how this
 algorithm 'generally' works -- including reading the 'plain-English'
 portions of Chapter 8 of the 'Essentials of Metaheuristics' book -- it
 still
 isn't perfectly clear to me how an actual implementation of the algorithm
 would code the 'Tweak' / 'Next Move' function (other than via a random
 combination of planning variables) in an application such as Employee Shift
 Rostering with a very large search space and with multiple planning
 variables.


If you look closer to the Nurse-Rostering example, you will notice the most
important moves are EmployeeChangeMove and ShiftAssignmentSwapMove. Those
moves may be qualify as small moves. As recommended in the Drool-planner
user guide, Tabu search perform great with small moves (see Chapter 8.5).
It's generally very simple to implement this type of moves and may be
sufficient for your problem.
As I understand, you generally create all the possible moves. Then
drools-planner will select them randomly.


 On the page (http://www.jboss.org/drools/drools-planner.html) where Drools
 Planner is compared side-by-side to other naive (greedy algorithms-based)
 approachesfor various kinds of problems, could it be the case that the
 algorithms used in Drools Planner were able to perfectly solve the
 highlighted problems only because of the use of extremely small search
 spaces / input datasets?! A wikipedia entry related to metaheuristic
 algorithms says that not only is it possible that such an algorithm may not
 give an optimal solution, it may not even give any solution at all(!!) due
 to the algorithm reaching its timeout limit specified by the user. I'm
 assuming it won't be possible to specify a timeout value in days or even
 hours for any metaheuristics-based approach to a real-world problem of a
 real-world scale.


In real-world problem involving workforce management, you should get
a feasible solution very fast. With drools-planner you can configure a
construction heuristic to get a first feasible solution -- the
nurse-rostering example use one. Then the tabu search is used to improve
the solution. You may then consider the solution created by the
construction heuristic as the worst solution.


 Lastly, from looking at the pseudocode of Tabu Search, it *appears* that
 the
 core, 'driver portion' of the algorithm may itself be not all that hard to
 implement; it is rather the call-back portion of the algorithm (such as the
 problem-specific Tweak / Next Move function, which the driver portion calls
 back)  that may be hardest to implement. Given this, what would be the
 advantages of using Drools Planner over a from-scratch, hand-coded version
 of Tabu Search (other than its declarative, rule-based flexibility which a
 hand-coded, from-scratch version may not want to implement due to its focus
 on solving a specific planning problem vs. a whole slew of generic planning
 problems requiring a generic piece of code such as Drools Planner)?

 I would definitely recommend drools-planner to your own implementation of
the Tabu search just to benefit from the drools engine it self which
provide you a very fast way to calculate the solution's score. The score is
calculated using an accumulate and then doesn't required to calculate the
score from scratch. I benchmark drools vs a plain java score function and
drools is way way faster.


 Would greatly appreciate if someone more knowlegeable than me could clarify
 / elaborate on the above getting-started questions of mine.

 Regards,
 /HS

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Employee-Shift-Rostering-algorithm-details-tp3897546p3897546.html
 Sent from the Drools: User forum 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