[rules-users] Adding .package files to a KnowledgePackage

2012-09-11 Thread Paul Ryan
So drools will respect files with a .package extension as a place for declared 
types, functions, etc. when used with these in the class path. How can a import 
these into a KnowledgePackage/KnowledgeBase so they can get compiled along with 
stuff when this is not in the class path at startup? My use case is such that 
these are not in the same space and can't be loaded at startup time in most 
cases.

Any help is greatly appreciated,

-- Paul Ryan


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


[rules-users] Cutom Attributes in Drools

2012-09-11 Thread dme1
Hi,

Is there support for Custom Attributes in Drools? What I want to do is add
attributes which determines when rules should be fired as well as attributes
that the rule updates which I can query at a later time.

E.g. Fire rule only for specific regions. So when new rules are
created/added BAs can define if it is applicable to specific regions.

Then the rule could result in a violation that could or could not be
overriden, so I want to add an attribute called override which is set by the
rule, which I can check after all rules are fired. I can use MetaData to
define this, but I need a pre-defined list which BAs can choose from when
creating a new rule.

Any thoughts on how I can implement this would be appreciated.

Thanks,
dme




--
View this message in context: 
http://drools.46999.n3.nabble.com/Cutom-Attributes-in-Drools-tp4019692.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] problem when upgrading to 5.4.0.Final, got UnsupportedOperationException on an update call

2012-09-11 Thread Michal Bali
Hi all,

I am upgrading an application from 5.3.0.Final to 5.4.0.Final and I am
getting the following exception:
Exception executing consequence for rule "ruleThatFails" in
indexingproblem.remove.me.anditworks:
java.lang.UnsupportedOperationException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1212)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1446)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at com.mycompany.app.IndexingProblemMain.main(IndexingProblemMain.java:36)
Caused by: java.lang.UnsupportedOperationException
at org.drools.reteoo.BaseLeftTuple.getPrevious(BaseLeftTuple.java:480)
at org.drools.core.util.index.LeftTupleList.remove(LeftTupleList.java:114)
at org.drools.core.util.index.LeftTupleList.removeAdd(LeftTupleList.java:68)
at org.drools.reteoo.JoinNode.modifyLeftTuple(JoinNode.java:310)
at
org.drools.reteoo.LeftTupleSource.doModifyLeftTuple(LeftTupleSource.java:304)
at
org.drools.reteoo.LeftTupleSource.modifyLeftTuple(LeftTupleSource.java:278)
at org.drools.reteoo.JoinNode.modifyLeftTuple(JoinNode.java:437)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateModifyLeftTuple(SingleLeftTupleSinkAdapter.java:205)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyObject(SingleLeftTupleSinkAdapter.java:235)
at
org.drools.reteoo.LeftInputAdapterNode.modifyObject(LeftInputAdapterNode.java:170)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateModifyObject(SingleObjectSinkAdapter.java:68)
at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:157)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:507)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:421)
at org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:314)
at org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:265)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:483)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:383)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:337)
at
indexingproblem.remove.me.anditworks.Rule_ruleThatFails_b159773c7b1a41a2a93044d2816b96ca.defaultConsequence(Rule_ruleThatFails_b159773c7b1a41a2a93044d2816b96ca.java:9)
at
indexingproblem.remove.me.anditworks.Rule_ruleThatFails_b159773c7b1a41a2a93044d2816b96caDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
indexingproblem.remove.me.anditworks.Rule_ruleThatFails_b159773c7b1a41a2a93044d2816b96caDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1277)
... 6 more


I have tried to create a minimal test case that recreates this issue, here
it is:
package indexingproblem.remove.me.anditworks;

declare Criteria
  processed : boolean
end

declare CheeseCriteria extends Criteria
end

rule setUp
salience 1
when
 then
insert(new CheeseCriteria());
end

rule aaa
  when
CheeseCriteria(  )
  then
end

rule bbb
  when
CheeseCriteria( )
  then
end

rule ccc
  when
CheeseCriteria(  )
  then
end


rule eeeFalse
  when
Criteria( processed == false )
then
end

declare Filter

end

rule fffTrue
  when
Criteria( processed == true )
Filter(  )
then

end

rule ruleThatFails
  when
$criteria : Criteria( processed == false )
then
modify($criteria) {
setProcessed(true)
}
end

I've tried to run it on 5.5.0-SNAPSHOT, but I got the same result. Note
that if you change the rule package to be "package indexingproblem" the
exception is not thrown. The code for building the KnowledgeBase is
standard, I haven't used any additional options. No fact is inserted only
one fireAllRules call.

Please let me know if I should create a new JIRA ticket for this or if I am
doing something wrong.

Thanking you in advance.
Best regards,
Michal
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Continuous Planning values for task planning

2012-09-11 Thread Geoffrey De Smet

  
  

Op 11-09-12 04:02, Josef Bajada
  schreef:

Hi Geoffrey,
  
  
  I managed to implement the solution with the relative end
Times. (I haven't yet used the incremental score calculation
because I haven't quite understood how I implement it)

If you use DRL, the incremental score calculation comes
automatically.
Basically, the average calculation score count should be above
1000/s, even for cases with 1000+ entities. Without incremental
score calcluation, the average calculation score count won't be
anywhere near that when the entityList size scales out.

  

  
  However I am facing one problem with our approach:
  
  
  Lets say we have 3 tasks A, B, and C, each of duration 1 just
for simplicity, with these constraints:
  
  
  a) B can only start between A.endTime + 10 and A.endTime +
100
  b) C can only start between A.endTime + 50 and A.endTime +
100 
  c) C can only start between B.endTime + 10 and B.endTime + 20
  
  
  With our approach of B.startTime = max(prev.endTime,
A.endTime + 10)  B will always be scheduled to start at time 11
(and end at time 12) given the hard constraints above.
  On the other hand C cannot start before time 51, thus
violating constaint C. 
  

Good point. The question is whether you need to go for an
implementation
1) for which B can have any gap with A between 10 and 100
or 2) for which B can only chose from a specific set of gap lengths
between 10 and 100: 11, 99, 51, (51 - B length), ...
I think 2) is probably not realistic, if you start adding many other
tasks it becomes unmanageable (unless we are overlooking a clever
way to filter potential gaps).

Ok,  so the question is if we want this design:

1) @PlanningEntity class Task {
   @PlanningVariable Task previousTask;
   @PlanningVariable int gap;
}

Or your original design:

0) @PlanningEntity class Task {
   @PlanningVariable int startTime;
}

(there might be other designs too)

It kinda depends on your planning window length what might works
best:
Presume you have a planning window length of 10 and 200 tasks
and an average maximum gap of 100.
In case 0), each of 200 tasks will have 1 variable with 10
values. => that's a search space of 10^200 = 10^1000.
In case 1), each of 200 tasks will have 2 variables, one var with
200 values and one var with on average 100 values. => that's a
search space of (100 * 200)^200 = 10^860.
Note that those kind of search space sizes are ok, don't let the
numbers scare you.


  The only solution to this would be to move B forward to start
at time 30. Is there any technique to detect these situations
and make such adjustments?

In a custom MoveFactory you could detect these situations and
generate moves for them.
The advantage of design 1) is that you 'd be effectively pushing all
the tasks dependent on the task that get moved too.
If those dependent task don't get pushed back, they 'll cause a hard
constraint to trigger and the move will be very unlikely to win the
local search step.
This is known as a "score trap" (see manual).

You might also want to take a long hard look at as complex as
BedDesignationPillarPartSwapMoveFactory in the hospital bed planning
example.
The idea is to swap 2 chains of tasks, instead of just 2 tasks.


  
  
  thanks again,
  
  
  Josef
  
  
  
  
  

On 20 August 2012 09:46, Geoffrey De
  Smet 
  wrote:
  
 You 'll want
  incremental score calculation (with delta's) for your "end
  times".
   
  http://docs.jboss.org/drools/release/5.4.0.Final/drools-planner-docs/html_single/index.html#incrementalScoreCalculation
  
  So that naturally puts the calculation of those end times
  in the scoreDRL (or IncrementalJavaCalculator if you're
  not using drools).
  Whether or not that endTime should be a property on the
  model (at least the model that Planner works with), is an
  open design question.
  If it isn't, you can use insertLogicals in DRL, like I did
  in nurserostering to calculate the number of sequential
  weekends being worked etc.
  If it is a property on your model, either the DRL must
  first "correct it" (with higher salience rules for
  example),
  or custom moves must "correct it" as they are being done
  (which is very hard as it entails constraints

[rules-users] ClasscastException in drools ant task

2012-09-11 Thread sk_mutyala
Hi All,

I am trying to build a sample drools project using ant and getting the below
error. I am using "drools-distribution-5.4.0.Final" release jars in my
project. Unable to get this issue resolved as not sure what really went
wrong.

RuleBaseTask failed: Unable to load dialect
'org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel:org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration'
at
org.drools.contrib.DroolsCompilerAntTask.execute(DroolsCompilerAntTask.java:159)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1307)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at
org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:33)
at org.apache.tools.ant.Project.executeTargets(Project.java:1191)
at
org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423)
at
org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137)
Caused by: org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel:org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration'
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:313)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:298)
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:187)
at
org.drools.compiler.PackageBuilderConfiguration.(PackageBuilderConfiguration.java:140)
at
org.drools.contrib.DroolsCompilerAntTask.getPackageBuilder(DroolsCompilerAntTask.java:556)
at
org.drools.contrib.DroolsCompilerAntTask.createWithPackageBuilder(DroolsCompilerAntTask.java:266)
at
org.drools.contrib.DroolsCompilerAntTask.execute(DroolsCompilerAntTask.java:156)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at
org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
... 2 more
Caused by: java.lang.ClassCastException:
org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:308)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:298)
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:189)
at
org.drools.compiler.PackageBuilderConfiguration.(PackageBuilderConfiguration.java:142)
at
org.drools.contrib.DroolsCompilerAntTask.getPackageBuilder(DroolsCompilerAntTask.java:558)
at
org.drools.contrib.DroolsCompilerAntTask.createWithPackageBuilder(DroolsCompilerAntTask.java:266)
at
org.drools.contrib.DroolsCompilerAntTask.execute(DroolsCompilerAntTask.java:156)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

Re: [rules-users] Guvnor Declarative Model

2012-09-11 Thread Vincent LEGENDRE
It may be faster to get the drools source code and change the generation by 
yourself.
And post the new code to Edson ...

- Mail original -

De: "Jean-Paul Shemali" 
À: rules-users@lists.jboss.org
Envoyé: Mardi 11 Septembre 2012 08:29:08
Objet: Re: [rules-users] Guvnor Declarative Model


Exactly what I was thinking about, but I wanted to check first if I could reuse 
drools' bytecode generation instead of adding another thirdparty to the mix 
(one of my previous questions actually). I do want to avoid messing with custom 
classloaders as much as I can :-)
>From what I've seen, it doesn't seem to be easily reusable though




Date: Mon, 10 Sep 2012 17:33:43 +0200
From: vincent.legen...@eurodecision.com
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Guvnor Declarative Model


Ok, not simple indeed ...
And why can't you generate a POJO instead of declarative fact ?



De: "Jean-Paul Shemali" 
À: rules-users@lists.jboss.org
Envoyé: Lundi 10 Septembre 2012 10:06:43
Objet: Re: [rules-users] Guvnor Declarative Model


Simply by not writing them in drools, but in another (proprietary) language, 
which in turn gets translated to drools at runtime.
Of course there's nothing really simple about the translation and how the 
actual facts get generated




Date: Sat, 8 Sep 2012 23:53:47 +0200
From: vincent.legen...@eurodecision.com
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Guvnor Declarative Model


How can you declare your facts (or rules) if you don't know beforehand the 
structure of the POJO to use ?

___ 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