Re: [rules-users] Optaplanner order schedule performance problem

2013-11-20 Thread Geoffrey De Smet

  
  
I don't have the time budget to do a full code review for a
community question,
but here are my initial thoughts:


A) Is your average calculation count per second above 5000?
If not, figure out which score rules are slowing you down.


B) Your assessment of "Concept with timeslots has to many possible
order positions." might be correct.

I've seen before on job shop scheduling problems,
that having second grained accuracy on starting time, in cases with
days/weeks of running time,
where each job (=order) takes minutes - is inefficient in a
straightforward model, currently.
Specifically because the constraints want the jobs to be pasted
after each other.

Here are (parts of) a solution for B):

1) Use a smarter (more complex model) that leaves less pointless
combinations.
Some idea's:
- Look at the Project Job Scheduling example's source code.
  http://www.youtube.com/watch?v=_2zweB9JD7c
If orders have dependencies on each other, this works well.
- Look at Vehicle Routing with Time windows. Maybe this model works
for you:
Each Vehicle = 1 of your machines. Each customer = 1 job.
ArrivalTime = startingOrderTime.
Setup times etc are added automatically in the arrivalTime due to
the VariableListener.

2) (Future) For OptaPlanner 6.1.0.Beta1 (which is coming soon), we
are working on numeric ValueRanges.
  https://issues.jboss.org/browse/PLANNER-160
This way, if a the values are (00:01, 00:02, 00:03, ..., 00:55,
...),
OptaPlanner understands that 00:02 is closer to 00:03 than to 00:55,
and the generic change move selector will support a gaussian
distribution random close to it's current value.

3) (Future) "CH based metaheuristics" (also called "indirect
metaheuristics" - or by me "feature L").
Too hard to explain now, but research shows this is very promising
for these kind of use cases (a big leap forward).
I am confident I can make it simple to use (despite it's inherit
complexity), hopefully for 6.1.
It does have some drawbacks and limitations (especially if you rely
on a specific types of soft constraints).


On 20-11-13 17:32, Mohr, Michael wrote:


  
  
  
  
Hi,

I must find start and end times for orders on different
equipment’s in requirement of a stock.
What can I do better to get faster a solution.

I read the forum entries but it don't helps.
- Scheduling events with varying durations - corrupted score
- Time Slots vs Time Periods
Graphics
  and detail description
  in the pdf. 
 
 
Domain model

@PlanningEntity
EquipmentAllocation has a Equipment
EquipmentAllocation has a Order
EquipmentAllocation has a TimeSlot
--
@PlanningVariable
Order
Attribute: quantity
--
TimeSlot
Attribute: startTime, endTime, duration, sequenceNumber
--
Material
Attribute: stock, minStock, maxStock
--
Material Demand has a TimeSlot
Attribute: quantity
--

Conditions:
-        Order is executable on each equipment.
-        Orders has different sizes.
-        Order running time is depending of the material and
the equipment.
-        Gaps between orders are possible if there is no
demand.
-        Gaps between orders are possible when there is a
equipment setup time.
-        Parallel orders with same material on different
equipment’s are possible.

Target:
-        Calculate start and endtims for an order.
-        Start and endtime is precisely one minute (maximum
five minutes if runtime is to long).
-        Satisfy only the demand of a material.
-        Good result in 5 minutes.
-        No exceed min or max stock.

Plan data:
-        Plan for 24 hours.
-        Plan 35 orders (normal order time is 2 hours).
-        Plan 5 demands with different materials (7 orders
per demand).
-        Plan 3 equipment’s.

Problem:
-        No result in 5 minutes.
-        Concept with ti

Re: [rules-users] Nullable Planning Variable

2013-11-20 Thread Geoffrey De Smet
In 6.0.0.CR5 (and earlier) there was a bug in the CH with nullable 
variables that forced them to pick a non-null value.
Try 6.0.0.Final. The release announcement will go out next week.

Also, that version has an example (and therefor an integration test) of 
a nullable variable:
the hospital bed planning example has been redefined and rewritten to 
accommodate for overconstrained planning.

On 21-11-13 05:35, newbie wrote:
> I am using 6.0.0CR5. I configure the planning variable to be null. Now using
> the construction heuristic 
>  FIRST_FIT
>  
>FIRST_NON_DETERIORATING_SCORE
>  
>
>
> all the planning entities was assigned with a planning variable even if the
> assignment lead to a negative hard constraint. I assumed that some of it
> will be assigned by null to avoid the negative hard constraint. Is my
> assumption correct way of using the nullable planning varibale config?
> Thanks.
>
>
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/Nullable-Planning-Variable-tp4026757p4026862.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


Re: [rules-users] Nullable Planning Variable

2013-11-20 Thread newbie
I am using 6.0.0CR5. I configure the planning variable to be null. Now using
the construction heuristic 
FIRST_FIT

  FIRST_NON_DETERIORATING_SCORE

  

all the planning entities was assigned with a planning variable even if the
assignment lead to a negative hard constraint. I assumed that some of it
will be assigned by null to avoid the negative hard constraint. Is my
assumption correct way of using the nullable planning varibale config?
Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Nullable-Planning-Variable-tp4026757p4026862.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] New Workbench Videos

2013-11-20 Thread Mark Proctor
5 short videos, to be played individually or continuously (play all) in the 
playlist, that demonstrates the new Workbench.
http://tinyurl.com/nhqtdqu

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


Re: [rules-users] How to know which condition passed from list of conditions

2013-11-20 Thread swaroop
Thanks David,Iam currently running on 5.5 . Planning to upgrade to 6 . I have
enough information to start on with inputs provided by you , mark and
melchoir55.

Regards
Oggu



--
View this message in context: 
http://drools.46999.n3.nabble.com/How-to-know-which-condition-passed-from-list-of-conditions-tp4026853p4026858.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] How to know which condition passed from list of conditions

2013-11-20 Thread Davide Sottara
Which version are you using? Latest versions support named consequences,
which allow to rules in a more compact form:

when
A() do[a]
( B() do[b]
  or
  C() do[c]
)
D() do[d]
then
  // main consequence here
then[a]
  // this will be executed when A() is matched
then[b]
  // A() B()
then[c]
  // A() C()
then[d]
 // same as main consequence
end

You can then use the main consequence for your normal business logic.

In a rule's consequence you can also use the context variables "drools"
or "kcontext", of type KnowledgeHelper and KnowledgeRuntime respectively.
They expose some context information such as the rule being fired and
the tuple (and thus the chain of facts) that led to the activation.

If this is not enough, you may have to customize the engine and extend
the condition nodes (alpha and beta) to fire events when a fact or a tuple
satisfies the local constraints. It's not terribly difficult to do, but
not immediate either.
Best
Davide

On 11/20/2013 04:40 PM, Isaac Martin wrote:
> I preface this with saying that you should be doing what Mark
> suggests. If what he suggests is going to create "too many drools" or
> "clutter your files" then I'd recommend putting them in a decision
> table. 
>
> Another way you could get information like this is to use the event
> listeners built into drools in order to give you information about
> activation events. For example, you could have a listener print out
> the antecedents to a drool in the beforeActivationFired method.
>
>
> On Wed, Nov 20, 2013 at 1:18 PM, Mark Proctor  > wrote:
>
> create additional rules, with just the patterns you know you want
> to match and record the result in the consequence - so you can
> check/assert later.
>
> Mark
> On 20 Nov 2013, at 20:49, swaroop  > wrote:
>
> > Hi ,
> >
> > Is there any way to determine which conditions matched/passed
> from list of
> > conditions defined for a rule . Also it would be helpful to know
> if there is
> > any means to relate a fact and the rule fired. In the below
> mentioned rule
> > can we know which condition passed ?
> >
> > Eg;
> > rule "check which Object matched"
> > when
> > Any of following conditions are true
> > Condition1
> > Condition2
> > Condition3
> > then
> > insert(Obj A)
> >
> >
> > Regards
> > Oggu
> >
> >
> >
> > --
> > View this message in context:
> 
> http://drools.46999.n3.nabble.com/How-to-know-which-condition-passed-from-list-of-conditions-tp4026853.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
>
>
>
>
> ___
> 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] How to know which condition passed from list of conditions

2013-11-20 Thread swaroop
Thanks Mark and melchoir55. I see there is value in creating rules for the
match . But i guess i have to rely on event listeners due to the number of
rules / combinations and depth of object model as well

Regards
Oggu



--
View this message in context: 
http://drools.46999.n3.nabble.com/How-to-know-which-condition-passed-from-list-of-conditions-tp4026853p4026856.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] How to know which condition passed from list of conditions

2013-11-20 Thread Isaac Martin
I preface this with saying that you should be doing what Mark suggests. If
what he suggests is going to create "too many drools" or "clutter your
files" then I'd recommend putting them in a decision table.

Another way you could get information like this is to use the event
listeners built into drools in order to give you information about
activation events. For example, you could have a listener print out the
antecedents to a drool in the beforeActivationFired method.


On Wed, Nov 20, 2013 at 1:18 PM, Mark Proctor  wrote:

> create additional rules, with just the patterns you know you want to match
> and record the result in the consequence - so you can check/assert later.
>
> Mark
> On 20 Nov 2013, at 20:49, swaroop  wrote:
>
> > Hi ,
> >
> > Is there any way to determine which conditions matched/passed from list
> of
> > conditions defined for a rule . Also it would be helpful to know if
> there is
> > any means to relate a fact and the rule fired. In the below mentioned
> rule
> > can we know which condition passed ?
> >
> > Eg;
> > rule "check which Object matched"
> > when
> > Any of following conditions are true
> > Condition1
> > Condition2
> > Condition3
> > then
> > insert(Obj A)
> >
> >
> > Regards
> > Oggu
> >
> >
> >
> > --
> > View this message in context:
> http://drools.46999.n3.nabble.com/How-to-know-which-condition-passed-from-list-of-conditions-tp4026853.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
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] How to know which condition passed from list of conditions

2013-11-20 Thread Mark Proctor
create additional rules, with just the patterns you know you want to match and 
record the result in the consequence - so you can check/assert later.

Mark
On 20 Nov 2013, at 20:49, swaroop  wrote:

> Hi ,
> 
> Is there any way to determine which conditions matched/passed from list of
> conditions defined for a rule . Also it would be helpful to know if there is
> any means to relate a fact and the rule fired. In the below mentioned rule
> can we know which condition passed ?
> 
> Eg;
> rule "check which Object matched"
> when
> Any of following conditions are true
> Condition1 
> Condition2
> Condition3
> then
> insert(Obj A)
> 
> 
> Regards
> Oggu
> 
> 
> 
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/How-to-know-which-condition-passed-from-list-of-conditions-tp4026853.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


[rules-users] How to know which condition passed from list of conditions

2013-11-20 Thread swaroop
Hi ,

Is there any way to determine which conditions matched/passed from list of
conditions defined for a rule . Also it would be helpful to know if there is
any means to relate a fact and the rule fired. In the below mentioned rule
can we know which condition passed ?

Eg;
rule "check which Object matched"
when
Any of following conditions are true
Condition1 
Condition2
Condition3
then
insert(Obj A)


Regards
Oggu



--
View this message in context: 
http://drools.46999.n3.nabble.com/How-to-know-which-condition-passed-from-list-of-conditions-tp4026853.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] 5.6.0.CR1 gives a NullPointerException in after evaluator

2013-11-20 Thread Davide Sottara
Jonathan,
thanks for the hints. This seems to be a critical bug, could you please
provide some additional details
or, ideally, the unit test that you are running?
It would be really appreciated
Thanks
Davide

On 11/18/2013 04:28 PM, Jonathan Knehr wrote:
> I only use it from a single thread. What I meant was that for example, for 
> the same set of rules, the issue never was created with, say, 20 iterations 
> of inserting the same facts/events over again. Instead, it was more on the 
> order of a few hundred thousand before the NPEs started showing up. Literally 
> running the same unit test in a loop until it NPE'ed. But all from a single 
> thread...
>
> Sent from my iPhone
>
>> On Nov 18, 2013, at 4:00 PM, Davide Sottara  wrote:
>>
>> Jonathan,
>> Drools 5.5 was never meant to be multi-threaded. 5.6 tries to put a few
>> patches here and there, 6.0 is going in that direction and 6.1 will
>> hopefully solve the problem.
>> Thanks for the hint to the "internal hash table", it may give us ideas
>> on what to test next. However, if you or anyone could ever reproduce the
>> issue and submit a test
>> case that would be REALLY appreciated
>> Thanks
>> Davide
>>
>>> On 11/18/2013 12:04 PM, Jonathan Knehr wrote:
>>> In the past I've tried to reproduce a similar issue.
>>>
>>> Don't know if this will help, but I could not reproduce the NPEs without 
>>> running a large amount of events into the rule engine. A small unit test 
>>> never reproduced these issues for me, which made it harder. Not sure about 
>>> this issue in particular, but other ones I've seen seem to be related to 
>>> the internal hash table eventually misplacing objects. This created all 
>>> sorts of odd symptoms, namely NPEs all over the place in random drools 
>>> classes. But I think all of these are just symptoms of the same bug at the 
>>> core level somewhere. They all are related IMO.
>>>
>>> Sent from my iPhone
>>>
 On Nov 18, 2013, at 9:48 AM, Davide Sottara  wrote:

 I tried to reproduce the problem, with no success.
 Could you please create a self-contained unit test?
 If confirmed, I'll fix the problem as soon as possible
 Thanks
 Davide

> On 11/14/2013 04:48 AM, abr wrote:
> Hi everyone,
>
> I tried to switch from 5.5.0.Final to 5.6.0.CR1 and got a null pointer
> exception in the evaluation of the after evaluator.
> (Exact method is:
> /org.drools.base.evaluators.AfterEvaluatorDefinition.AfterEvaluator.evaluate(InternalWorkingMemory,
> InternalReadAccessor, InternalFactHandle, InternalReadAccessor,
> InternalFactHandle)/ )
>
> When debugging, the exception occurs at the very first line of the method,
> in:
> /if ( extractor1.isNullValue( workingMemory, handle1.getObject() ) || 
>   extractor2.isNullValue( workingMemory, handle2.getObject() ) ) {
>   return false;
>   }
> /
> The cause of the exception is that handle1 is null.
>
> The rule where the exception occurs looks like:
> /MyFact(
>   fromdate before[ 0d ] $min,
>   ( todate == null || todate after[ 0d ] $max ) )
> /
>
> When the exception occurs, /MyFact.fromdate/ is not null, /$min/ is not
> null, /MyFact.todate/ is null, /$max/ is not null.
> In AfterEvaluator.evaluate : /extractor1/ refers to /MyFact.todate/,
> /extractor2/ refers to /$max/, /handle1/ is null, /handle2/ refers to the
> fact including the attribute to which /$max/ variable is bound to.
>
> Of course, this worked fine in 5.5.0.Final.
> I couldn't test this out in Drools 6.0.0.CR5 because I have dependencies 
> to
> drools-spring JAR that does not exist anymore in 6.0.0.CR5.
>
> Is it simple to fix this problem?
>
> Thanks in advance.
>
> Best,
> Alexis
>
>
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/5-6-0-CR1-gives-a-NullPointerException-in-after-evaluator-tp4026780.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
>>> ___
>>> 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] Change rules dielect to java through java program(rest api)

2013-11-20 Thread Michael Anstis
First, why do you want to change the dialect of a rule if you are not
authoring rules?

If you are simply consuming rules authored by somebody else; why do you
need to concern yourself with the dialect with which the rule was written?


On 20 November 2013 09:42, vargheseps  wrote:

> Hai
>  In my application i am not using drools ui. How to change the dialect
> from 'mvel' to java through REST API.
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Change-rules-dielect-to-java-through-java-program-rest-api-tp4026837p4026844.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

Re: [rules-users] Java Heap Space Out of Memory in Drools

2013-11-20 Thread Wolfgang Laun
The rule starts by pairing each Employee with each Requirement and
so you have 1000*1000 = 100 nodes in the network. This is an
anti-pattern for counting pairs from a subset (1%) of all pairs.

To count Assignments with identical pairs of Employee and Requirements
you just look at Assignments. Ideally, Assignments has an attribute
that enumerates them (or some other unique comparable id - a simple
object counter will do). Then you start the rule with

   Assignment( $e: employee, $r: requirement, $id: id)
   not Assignment( employee == $e, requirement == $r, id < $id )
   ...accumulate...

Best
-W




On 20/11/2013, newbie  wrote:
> My example was I have 1000 employees and 1000 requirement. Each requirement
> has duration of 10 months. The number of assignment therefore would be
> number of months of requirment * number of requirement all in all 1
> assignments.
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Java-Heap-Space-Out-of-Memory-tp4026825p4026839.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


Re: [rules-users] Change rules dielect to java through java program(rest api)

2013-11-20 Thread vargheseps
Hai
 In my application i am not using drools ui. How to change the dialect
from 'mvel' to java through REST API.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Change-rules-dielect-to-java-through-java-program-rest-api-tp4026837p4026844.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] Change rules dielect to java through java program(rest api)

2013-11-20 Thread Michael Anstis
The rule dialect is defined within the rule itself; so if you view the rule
source in Guvnor for "ruleName.drl" you'll see it's maven. You can set the
rule's dialect by adding a rule attribute.

WebClient.acceptLanguage() sets the HTTP accept-language header; which sets
the acceptable human language response; e.g. en-US. Specifying a value
"java" has no effect on rules.


On 20 November 2013 05:31, vargheseps  wrote:

> Hai
>
>  I have created rules from my application and uploaded to drools engine
> through API.
>
>  WebClient client =
> WebClient.create("http://ip:port
> /drools-guvnor/rest/packages/packageName/assets");
>  Response response= client.accept(MediaType.APPLICATION_ATOM_XML_TYPE)
>
> .type(MediaType.APPLICATION_OCTET_STREAM_TYPE)
>  .acceptLanguage("java")
> .header("slug", "ruleName.drl")
> .post("rulecontent");
>  *But when i am taking the source from drools guvnor i am getting the
> dialect 'mvel' but i want dialect 'java'*
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Change-rules-dielect-to-java-through-java-program-rest-api-tp4026837.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