Re: [rules-users] MVEL strict mode -- when, why?

2010-06-19 Thread Barry Kaplan

Hey Edson, 

If I don't explicitly set strict to false my rules fail to compile. I will
create a simple example. Or maybe this two phase is post 5.0.1?

-barry
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/MVEL-strict-mode-when-why-tp95666p907803.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] MVEL strict mode -- when, why?

2010-06-09 Thread Barry Kaplan

Ping???
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/MVEL-strict-mode-when-why-tp95666p883142.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] MVEL strict mode -- when, why?

2010-06-09 Thread Barry Kaplan

From the MVEL docs (http://mvel.codehaus.org/MVEL+2.0+Typing):

Strict Typing

Strict typing in MVEL is an optional mode for the compiler, in which all
types must be fully qualified, either by declaration or inference.

Enabling Strict Mode
When compiling an expression, the compiler can be put into strict mode
through the ParserContext by setting setStrictTypeEnforcement(true).

Satisfying type strictness can be accomplished both by requiring explicit
declaration of types inside the expression, or by notifying the parser ahead
of time of what the types of certain inputs are.

For example:

ExpressionCompiler compiler = new ExpressionCompiler(expr);

ParserContext context = new ParserContext();
context.setStrictTypeEnforcement(true);

context.addInput(message, Message.class);
context.addInput(person, Person.class);

compiler.compile(context);

In this example we inform the compiler that this expression will be
accepting two external inputs: message and person and what the types of
those inputs are. This allows the compiler to determine if a particular call
is safe at compile time, instead of failing at runtime.
Note about Generic Types
You must use Strong Typing Mode to enable awareness of generic types. Type
parameters for collections and other types will not be visible in
strict-typing mode alone.
Strong Typing

Strong typing is a newly introduced mode in MVEL 2.0. It is different from
strict mode in the sense that strongly typed mode requires that all
variables be type qualified. Contrast this with strict mode which only
requires that properties and method calls be qualified at compile-time.

See the full article: Strong Typing Mode 
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/MVEL-strict-mode-when-why-tp95666p883155.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] Potential Deadlock using fireUntilHalt and signalEvent

2010-05-18 Thread Barry Kaplan

Thanks for tracking that down. I've had to stop using fireUntilHalt due to
deadlocks but did not get the chance to determine the problem.

-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Potential-Deadlock-using-fireUntilHalt-and-signalEvent-tp826121p826897.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] Fusion and open-ended intervals?

2010-04-15 Thread Barry Kaplan

If I understand you correctly Edson, you have provided a better description
to solution 1) in my post above.

This works to a degree but leaves a bit to be desired. For example when
correlating instant events as during the interval events (ie, startX,
endX, eventX) those correlations cannot simply use during, because there
may be no eventX yet (ie, endX has not yet occurred). 

This requires patterns of the form:

instant: InstantEvent
beginX: BeginX
(or (and instant after beginX
not endX(id == beginX.id)
 instant is during eventX(id == beginX.id)

Which like I said gets messy. 

Again, if the @timestamp and @duration were not stored in the fact handle
and could be altered via a working-memory update then instant is during
eventX would work in all instances. The trade off is that it would make the
drools internals much more complex as behaviors scheduled based on
@timestamp and @duration would need to be modified according on a wm.update,
along with all race conditions that would entail.

It could also be argued that modifying an event's timestamp smells for
purity reasons. But that would depend the perspective you take. Some events
unfold over time (hence the modeling construct of using startX, endX,
eventX). So a counter argument might be that a CEP engine should have first
class support events of this nature.




-- 
View this message in context: 
http://n3.nabble.com/Fusion-and-open-ended-intervals-tp719076p721426.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] Fusion and open-ended intervals?

2010-04-15 Thread Barry Kaplan

Actually Greg I did something very similar. Since drools locks down the event
temporal values, I added to my event class some helper methods indicating
whether the interval is open or closed:

abstract class Event {
  def interval: Interval  // joda interval
  def isOpen = interval.end.getMillis == infiniteMillis
  def isClosed = !isOpen
}

And then in rules, when to consider only open intervals I do something like

when
  device: Device()
  executionState: ExecutionStateEvent(deviceId == device.id, name ==
STOPPED) from entry-point mtconnect
  not (DowntimeInterval(deviceId == device.id, open == true, this includes
executionState) from entry-point downtime)

This is not going to work for all situations, but its a pattern in the
toolbox.

-barry
-- 
View this message in context: 
http://n3.nabble.com/Fusion-and-open-ended-intervals-tp719076p722744.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] Mvel and import issues

2010-04-14 Thread Barry Kaplan

There is a mvel bug that I run into from time to time relating to imports. I
present it here to hopefully save others from spending too much time
discovering the work around.

My drl file starts like:

  import systeminsights.model.device.*
  import systeminsights.event.mtconnect.*
  import systeminsights.plugin.downtime.*

  declare DowntimeInterval
@role(event)
@timestamp(interval.start.getMillis)
@duration(interval.toDurationMillis)
  end
 
Every once in a while mvel will fail with ClassNotFoundException for the
class DowntimeInterval. If I change the imports to:

  import systeminsights.model.device.*
  import systeminsights.event.mtconnect.*
  import systeminsights.plugin.downtime.*
  import systeminsights.plugin.downtime.DonwtimeInterval

Then mvel finds the class. Later on, after making various edits I will
remove the redundant import and won't get the exception. 

I can't reproduce this in any way -- its completely intermittent for causes 

(begin:rant)
80% of the time I spend debugging drools issues ends up as an mvel quirk
(end:rant)
-- 
View this message in context: 
http://n3.nabble.com/Mvel-and-import-issues-tp719007p719007.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] Fusion and open-ended intervals?

2010-04-14 Thread Barry Kaplan

A fusion design question:

I have events that represent intervals. Initially the intervals are
open-ended (kind a like the current state of an entity). Other events are
matched during the interval and correlated. At some point the interval
will be closed (eg, a specific downtime interval is closed because the
device is no online again). 

All the events in this system are immutable -- so if some property of an
event changes, it is cloned and modified in working-memory. For the case of
the interval events, initially the interval is inserted open-ended, and at
some point later closed and then modified. 

This does not work with fusion however, since an event's duration is
maintained by the fact-handle not the event itself. Hence a modify with a
now closed interval (ie, a finite @duration) has no effect. I'm guessing the
temporal values are maintained the handle to ensure stable values for the
behaviors that trigger based on temporal values, which is reasonable.

So I'm looking for alternative designs. Some are:
  1) Modeled the intervals as begin/end events, but that gets messy real
fast (have to correlate 
  the begin/end events somehow, can't use evaluators like 'includes' or
'during', etc). 
  2) Retract the interval event when it is closed (this way closed intervals
no longer correlate 
  with other incoming events). But then we really have a manually
maintained state machine
  using only facts, and there can be no reasoning over a series these
interval events.
 (eg, 3 downtimes longer than 2 minutes in the last hour).

Opinions?

-barry

-- 
View this message in context: 
http://n3.nabble.com/Fusion-and-open-ended-intervals-tp719076p719076.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] drl's and silent failures

2010-04-08 Thread Barry Kaplan

No jira yet, my brain was too frazzled late last night. Dialect was mvel
against 5.0.1.

Also ran into a few internal exceptions wrt to window:length(1) and doing an
explicit retract of an event from that window. In 5.0.1 it yielded an NPE,
in 5.1.M1 it yielded an internal error (can't build trunk). Should be able
to reproduce easily, but I want to try to figured these out myself as part
of learning the internals a bit more.
-- 
View this message in context: 
http://n3.nabble.com/drl-s-and-silent-failures-tp704973p706069.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] drl's and silent failures

2010-04-07 Thread Barry Kaplan

** warning: This is a rant, but it just might save you some head scratching
if you run into these issues **

I really hate writing rules. Not, well not rules, but rules in the DRL
language. There are so many edge conditions that fail silently. Here just
two from today:

...
then
   retract(f1) // some comment
   retract(f2)
end

In the above retract(f2) will not be invoke. No message about any problems
-- it just doesn't happen. Remove the comment and f2 is retracted. 

And, where 'ksession' is a global

...
then
   update(ksession.getFactHandle(f1), new MyF1(10, 10))
end

In this one the constructor used for MyF1 does not exists. No message, just
silent failure. Change the rule to:

...
then
   MyF1 fi_new = MyF1(10, 10)
   update(ksession.getFactHandle(f1), f1_new)
end

And now the error message about the missing constructor is produced. 

-- 
View this message in context: 
http://n3.nabble.com/drl-s-and-silent-failures-tp704973p704973.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] No sources for the snapshot builds??

2010-04-07 Thread Barry Kaplan

Really?
-- 
View this message in context: 
http://n3.nabble.com/No-sources-for-the-snapshot-builds-tp705081p705081.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] Overriding default evaluators

2010-03-11 Thread Barry Kaplan

That may be how its supposed to work, but it does not.
PackageBuilderConfiguration#buildEvaluatorRegistry selects properties from
'chainedProperties' from the two collections of properties -- the drools
default and the scala extensions -- into a single map. It then adds the
evaluators from that combined map, which is now intermingled so the add
order is undefined.

My workaround was, after the registry is first created but before any drls
are parsed (hack alert):

  def registerScalaEvaluators(kbuilder: KnowledgeBuilder) {
val kbuilderConfig =
kbuilder.asInstanceOf[KnowledgeBuilderImpl].getPackageBuilder.getPackageBuilderConfiguration
val chainedProperties = kbuilderConfig.getChainedProperties
val evaluatorRegistry = kbuilderConfig.getEvaluatorRegistry

val scalaEntries = new java.util.HashMap[String, String]
chainedProperties.mapStartsWith(scalaEntries,
EvaluatorOption.PROPERTY_NAME+scala_, true)
for (className - scalaEntries.values) {
  evaluatorRegistry.addEvaluatorDefinition(className)
}
  }





-- 
View this message in context: 
http://n3.nabble.com/Overriding-default-evaluators-tp441342p442360.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] Overriding default evaluators

2010-03-11 Thread Barry Kaplan

I should point out that this is only a problem when overriding operators. 

But I won't, at least here, go into the other nasty hacks I have to do to
get around the non-polymorphic ValueType systems. I'm assuming that that
design is there for performance reasons (ie, to eliminate the need for
instanceOf checks) but it really creates serious smells all over the code
base. Ok, I guess I'm going into it ;-)

Consider SetEvaluatorDefintion. It has to define duplicate evaluators for
all the ValueTypes -- even though they all do the same thing. This
duplication is seems to exists only to support the lookup of evaluators by
ValueType. Of course I did not follow this pattern in the scala evaluators
since I'm way too lazy for that ;-)

Anyway, I've worked around all my issues for now. Once I get mostly done
with scala extensions to the DRL syntax I'll compile my issues and maybe we
can discuss modifications to drools internals. 
-- 
View this message in context: 
http://n3.nabble.com/Overriding-default-evaluators-tp441342p442366.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] MVEL strict mode -- when, why?

2009-12-20 Thread Barry Kaplan

I have never gotten any of my rules to compile using mvel strict mode. If I
leave the default I get spews of error messages that I can't make any sense
of.  For example with:
 
---
package systeminsights.plugin.core.schedule

rule foo
when
  eval(true)
then
  // noop
end
---

I get messages like 

[Error: Failed to compile: 3 compilation error(s): 
 - (1,21) unqualified type in strict mode for: plugin
 - (1,26) unqualified type in strict mode for: core
 - (1,35) unqualified type in strict mode for: schedule]
[Near : {... Unknown }]
 ^
[Line: 1, Column: 0]

If I set strict mode to false all is good.

So, what is actually going on with strict mode? And how does one interpret
messages such as the above?

-barry
-- 
View this message in context: 
http://n3.nabble.com/MVEL-strict-mode-when-why-tp95666p95666.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] mythical functions

2009-12-20 Thread Barry Kaplan


Chris Richmond wrote:
 
 So..assuming I *did* want to put a simple function in my .drl
 file..*where*
 do I have to put it?  My oringal question about how to make a simple
 function declaration is still a mystery to me.
 

Did this ever get answered? I have never been able to use a function. I
always get mvel compile errors.

Consider this:


package systeminsights.plugin.core.schedule

dialect mvel

function String f() {
  return function;
}

rule Invoke function
when
  eval(true)
then
  System.out.println(*** f= f())
end



With strict mvel:

[Error: Failed to compile: 1 compilation error(s): 
 - (1,3) unable to resolve method using strict-mode: java.lang.Object.f()]
[Near : {... Unknown }]
 ^
[Line: 1, Column: 0]
at
org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:78)


With non-strict mvel:

org.drools.runtime.rule.ConsequenceException: rule: Invoke function

at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)
at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:975)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:915)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1121)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:698)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:664)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:198)
at
systeminsights.infra.drools.DroolsGroovyTestFixture.fireAllRules(DroolsGroovyTestFixture.groovy:89)
at
systeminsights.infra.drools.DroolsGroovyTestFixture._clinit__closure19(DroolsGroovyTestFixture.groovy:226)
at
systeminsights.infra.drools.DroolsGroovyTestFixture.getProperty(DroolsGroovyTestFixture.groovy)
at systeminsights.plugin.core.schedule.FunctionsTest.With device(_) -
device(_) is effective(FunctionsTest.groovy:19)
Caused by: [Error: unable to access property (null parent): f]
[Near : {... Unknown }]
 ^
[Line: 1, Column: 0]


-- 
View this message in context: http://n3.nabble.com/functions-tp60463p95669.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] mythical functions

2009-12-20 Thread Barry Kaplan

Yes, the above example had a typo:

  System.out.println(*** f= f())

Was really when I ran the test:

  System.out.println(*** f= + f())


-- 
View this message in context: http://n3.nabble.com/functions-tp60463p95673.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] mythical functions

2009-12-20 Thread Barry Kaplan

Interesting, if I change from mvel to java and remove the package statement:


function String f() {
  return function;
}

rule Invoke function
when
  eval(true)
then
  System.out.println(*** f= + f());
end
---

Then this works.

So then, what permutations of mvel/java actually work:

--
1. Java + Qualified package:


package systeminsights.plugin.core.schedule

function String f() {
  return function;
}

rule Invoke function
when
  eval(true)
then
  System.out.println(*** f= + f());
end
---
 
Nope, this gives the obscure exception

org.drools.RuntimeDroolsException: java.lang.ClassNotFoundException:
systeminsights.plugin.core.schedule.Rule_Invoke_function_0ConsequenceInvoker


--
2. Java + simple package


package systeminsights
...


Yep, this works. 

--
3. Mvel + qualified package + strict

Nope:

[Error: Failed to compile: 1 compilation error(s): 
 - (1,3) unable to resolve method using strict-mode: java.lang.Object.f()]
[Near : {... Unknown }]
 ^
[Line: 1, Column: 0]

--
4. Mvel + qualified package + non-strict

Nope:

at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)
at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:975)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:915)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1121)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:698)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:664)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:198)
at
systeminsights.infra.drools.DroolsGroovyTestFixture.fireAllRules(DroolsGroovyTestFixture.groovy:89)
at
systeminsights.infra.drools.DroolsGroovyTestFixture._clinit__closure19(DroolsGroovyTestFixture.groovy:226)
at
systeminsights.infra.drools.DroolsGroovyTestFixture.getProperty(DroolsGroovyTestFixture.groovy)
at systeminsights.plugin.core.schedule.FunctionsTest.With device(_) -
device(_) is effective(FunctionsTest.groovy:19)
Caused by: [Error: unable to access property (null parent): f]
[Near : {... Unknown }]
 ^
[Line: 1, Column: 0]
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:860)

--
5. Mvel + simple package + strict


package systeminsights

dialect mvel

function String f() {
  return function
}

rule Invoke function
when
  eval(true)
then
  System.out.println(*** f= + f())
end
---

Nope:

[Error: Failed to compile: 1 compilation error(s): 
 - (1,3) unable to resolve method using strict-mode: java.lang.Object.f()]
[Near : {... Unknown }]
 ^
[Line: 1, Column: 0]

--
6. Mvel + simple package + non-strict

Nope:

org.drools.runtime.rule.ConsequenceException: rule: Invoke function

at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)
at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:975)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:915)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1121)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:698)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:664)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:198)
at
systeminsights.infra.drools.DroolsGroovyTestFixture.fireAllRules(DroolsGroovyTestFixture.groovy:89)
at
systeminsights.infra.drools.DroolsGroovyTestFixture._clinit__closure19(DroolsGroovyTestFixture.groovy:226)
at
systeminsights.infra.drools.DroolsGroovyTestFixture.getProperty(DroolsGroovyTestFixture.groovy)
at systeminsights.plugin.core.schedule.FunctionsTest.With device(_) -
device(_) is effective(FunctionsTest.groovy:19)
Caused by: [Error: unable to access property (null parent): f]
[Near : {... Unknown }]
 ^
[Line: 1, Column: 0]
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:860)

--
7. Mvel + no package + strict

Nope:

[Error: Failed to compile: 1 compilation error(s): 
 - (1,3) unable to resolve method using strict-mode: java.lang.Object.f()]
[Near : {... Unknown }]
  

Re: [rules-users] Trivial rule with condition in RHS won't compile, help please

2009-12-03 Thread Barry Kaplan

Ok, I found http://n3.nabble.com/Strange-MVEL-error-td62055.html#a62055 which
indicates that expressions are disabled in mvel RHS. I understand good
intentions, but I **need** this expression for this particular situation.
Anybody know some what to turn this back on?

Also, when I try wrap the RHS in a function, that also fails. I'm guessing
because I declare dialect mvel for the entire file. If this is why
function fails to compile with an if-statement, this must be a bug.
-- 
View this message in context: 
http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-tp67458p67472.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] Trivial rule with condition in RHS won't compile, help please

2009-12-03 Thread Barry Kaplan

The following rule:

rule test dialect mvel
when
eval(true)
then
if (true) {
System.out.println(***)
}
end

Fails with:

java.lang.RuntimeException: Unable to build expression for 'consequence':
was expecting type: java.lang.Object; but found type: void 'if (true) {
System.out.println(***)
}
true
' : [Rule name='test']

I can't for the live of me figure out what mvel is bitching about.

Note that the following does compile:

rule test dialect mvel
when
eval(true)
then
//if (true) {
System.out.println(***)
//}
end
-- 
View this message in context: 
http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-tp67458p67458.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] Trivial rule with condition in RHS won't compile, help please

2009-12-03 Thread Barry Kaplan


Greg Barton wrote:
 
 You can use them in the RHS, but just with java dialect. 
 

This is inconsistent. If they can be used in java, then they should not be
disabled for mvel. 



-- 
View this message in context: 
http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-tp67458p67488.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] MVEL wows: what does importInjectionRequired mean?

2009-12-02 Thread Barry Kaplan

I'm at my wits end. I have two simple rules in two separate packages, they
are of the form:

rule1:
  import somepackage.*
  global somepackage.Foo foo
  ...
  then
 foo.doSomething(...)
  end

rule2:
  import otherpackage.*
  global otherpackage.Gar gar
  ...
  then
 gar.doSomething(...)
  end

When mvel is resolving foo for rule1 it does so via
org.mvel2.compiler.CompiledExpression#getValue:line-104

When resolving gar for rule2 it does so via
org.mvel2.compiler.CompiledExpression#getValue:line-107

The difference is that for rule1 the variable 'importInjectionRequired' is
true, which results in 'foo' being resolved, but for rule2 this variable is
false which results in 'gar' not being resolved.

I suspecting that its important that the packages and the global instances
are added dynamically *after* the session is created (in scala'ish dialect):

val session = createSessionUsingNoPackages

val kbuilder1 = KnowledgeBuilderFactory.newKnowledgeBuilder
kbuilder1.add(rule1.drl, ResourceType.DRL)
session.knowledgeBase addKnowledgePackages (kbuilder1.getKnowledgePackages)
session addGlobal (foo, foo)

val kbuilder2 = KnowledgeBuilderFactory.newKnowledgeBuilder
kbuilder2.add(rule2.drl, ResourceType.DRL)
session.knowledgeBase addKnowledgePackages (kbuilder2.getKnowledgePackages)
session addGlobal (Gar, gar)

If just one or the other packages are added the session, then either
variable is resolved. But if both are added the session the 'gar' is not
resolved. It does not matter what order they added to the session. I can
also try to access 'gar' in rule1 and it also will not be resolved.

I guess I really don't expect any help on this, but I will boil it down to a
simple test and submit it to jira

-barry
-- 
View this message in context: 
http://n3.nabble.com/MVEL-wows-what-does-importInjectionRequired-mean-tp66496p66496.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] MVEL wows: what does importInjectionRequired mean?

2009-12-02 Thread Barry Kaplan

Oh boy, what a ride. In my real code the two variables are called
DeviceOperatingStateModel and DeviceUtilizationStateModel. Just as an
experiment I renamed the second to aa -- low and behold the variable was
resolved. Then I changed to DeviceUtilizationStateModelx and
deviceUtilizationStateModel and both of those were resolved. 

This is so strange. There something about the name
DeviceUtilizationStateModel that mvel just does not like! (Ok, surely
that's not it and its something else in classpath. But its more fun to make
believe that mvel doesn't like my names).
-- 
View this message in context: 
http://n3.nabble.com/MVEL-wows-what-does-importInjectionRequired-mean-tp66496p66543.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] MVEL wows: what does importInjectionRequired mean?

2009-12-02 Thread Barry Kaplan


Wolfgang Laun-2 wrote:
 
 The usual approach is to add all KPs in a single add call:
 

Yes, but for my system rules are modular and there is no single place where
they are all known. I could of course define a dual-pass configuration, but
that adds a lot of boilerplate code that adds no business value.

-- 
View this message in context: 
http://n3.nabble.com/MVEL-wows-what-does-importInjectionRequired-mean-tp66496p66595.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] Does Session effeciently filter unused facts, or...

2009-11-24 Thread Barry Kaplan

Greg, I'm not following how this is related to my question. Probably I was
unclear.

Suppose I have 1000 event types/classes, but rules that use only 50 types in
LHS patterns. I will be receiving events of random types at say 100hz. The
question is whether I should just insert the events regardless of whether
any rule actually uses the instances' event type (because the rete-oo will
filter out the unused types very quickly) or whether I should add a filter
before sesssion.insert(..) to let only those types of events that are
actually used by a rule.

My second problem/question then becomes: How to determine which
types/classes are actually used in LHS patterns for a given package? By this
I mean, how can I write code to make this determination.
-- 
View this message in context: 
http://old.nabble.com/Does-Session-effeciently-filter-unused-facts%2C-or...-tp26489782p26505340.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] Does Session effeciently filter unused facts, or...

2009-11-24 Thread Barry Kaplan

Ah, yes Edson. I didn't even think of that. That will probably force my hand
to filter. 

But that then leaves me with how to determine the set of classes used in the
rules. Doing it by textual inspection is not viable since rules can be added
as part of the application (by users'). 

-- 
View this message in context: 
http://old.nabble.com/Does-Session-effeciently-filter-unused-facts%2C-or...-tp26489782p26507196.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] Does Session effeciently filter unused facts, or...

2009-11-24 Thread Barry Kaplan

An option like that would be ideal. However it would also be nice to have the
ability to determine the fact types so filtering pre
fact-handle-creation/insertion can be done as well.

In the meantime, for our current design at least, it will almost always be
the case that we can scale out if we overload drools. ie, Have a separate
thread/process per device (or subset), as the rules/cep processing is
hierarchical. Higher levels will be consuming events generated by lower
levels, but the rate of creation will decrease up the hierarchy.


Edson Tirelli-4 wrote:
 
 For future versions, I think we
 should add a kbase configuration option to tell the engine what to do in
 case of facts that don't match any rule: either keep them (as it does
 today)
 or discard them right away. What do you think?
 

-- 
View this message in context: 
http://old.nabble.com/Does-Session-effeciently-filter-unused-facts%2C-or...-tp26489782p26507232.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] Does Session effeciently filter unused facts, or...

2009-11-23 Thread Barry Kaplan

... should I put a filter before insert(). 

I will have lots of events coming from hardware devices, only some of which
be applicable to a given session instance. I've tried extracting the
declared types from the packages, but that doesn't include classes used in
patterns which where only imported. So determine the actual set of event
classes used by a given set of packages seems not to be so easy.

I've drilled down to EntryPointNode.assertObject..
-- 
View this message in context: 
http://old.nabble.com/Does-Session-effeciently-filter-unused-facts%2C-or...-tp26489782p26489782.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] Can't use global in RHS constructor call

2009-11-20 Thread Barry Kaplan

In the following, [A] works but [B] yields the exception below. Is this some
kind of limitation of MVEL?


dialect mvel
...
global StateFactory stateFactory
global String NotOperating
...
rule transition
when
   ...
then
   newState = stateFactory(NotOpering)  // [A]
   newState = new State(NotOperating)  // [B]
end


--
Caused by: [Error: unable to access property (null parent): NotOperating]
[Near : {... Unknown }]
 ^
[Line: 1, Column: 0]
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:860)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:584)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:312)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:138)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:133)
at
org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:41)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileConstructor(ReflectiveAccessorOptimizer.java:1090)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeObjectCreation(ReflectiveAccessorOptimizer.java:1047)
at
org.mvel2.ast.NewObjectNode.getReducedValueAccelerated(NewObjectNode.java:158)
at
org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:37)
at
org.mvel2.ast.AssignmentNode.getReducedValueAccelerated(AssignmentNode.java:89)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:104)
at org.mvel2.MVEL.executeExpression(MVEL.java:995)
at 
org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:87)
at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:966)
-- 
View this message in context: 
http://old.nabble.com/Can%27t-use-global-in-RHS-constructor-call-tp26418622p26418622.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] immediate vs path bound variables wrt performance?

2009-09-02 Thread Barry Kaplan

The docs state that == with bound variables is very fast due to hashing. The
example only shows a simple bound value, eg

   Person( likes : favouriteCheese )
   Cheese( type == likes )

In the following will drools create an implicit hashed variable for
'$p.likes' and yield the same performance?

   $p : Person( )
   Cheese( type == $p.likes )

 
-- 
View this message in context: 
http://www.nabble.com/immediate-vs-path-bound-variables-wrt-performance--tp25269900p25269900.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] immediate vs path bound variables wrt performance?

2009-09-02 Thread Barry Kaplan

Ok, I think I just found my answer, from 4.8.2.1

'Note: Nested accessors have a much greater performance cost than direct
field accesses, so use them carefully.

But is the simple case in the previous post considered nested?


-- 
View this message in context: 
http://www.nabble.com/immediate-vs-path-bound-variables-wrt-performance--tp25269900p25269967.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] Order matters!

2009-08-30 Thread Barry Kaplan

Found my problem. I was invoking kbuilder.add(..) for the declarations
/after/ the rules. Simply switching the order fixed the problem. 
-- 
View this message in context: 
http://www.nabble.com/Share-%27declare%27-by-adding-drl-to-KnowledgeBuilder--tp25208077p25216742.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] Not conditional 'not' for event streams?

2009-08-30 Thread Barry Kaplan

I'm trying to formulate a condition like:

$se : StartEvent()   
from entry-point stream

$fe : FinishedEvent(exchangeId == $se.exchangeId, this after[0s,30s] 
$se) 
from entry-point stream
  
not AbortedEvent(exchangeId == $se.exchangeId, this after[0s,30s] $se) 
from entry-point stream

A compile error is issued due to the use of 'not' on the last clause. Is
this not supported? Is there another way to obtain this behavior.

Even this simple clause is not value:

not AbortedEvent()  from entry-point stream



The corresponding esper for this would be something like:

select * from pattern [every s=StartEvent - 
(f=FinishedEvent(exchangeId = s.echangeId) where timer:within(30
sec)
and not AbortedEvent(exchangeId = s.echangeId) where
timer:within(30 sec)]

-- 
View this message in context: 
http://www.nabble.com/Not-conditional-%27not%27-for-event-streams--tp25217095p25217095.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] Conditional 'not' invalid for event streams?

2009-08-30 Thread Barry Kaplan

Well, I seem to have gotten past the compilation error by using parens:

...
not (AbortedEvent(exchangeId == $se.exchangeId, this after[0s,30s] $se) 
from entry-point stream)

But my rule does not fire as expected. Has anybody formed a rule like this
with events?

(BTW, does the Rete Tree in eclipse have any practical function, given that
none of the nodes are labeled?)

-barry
-- 
View this message in context: 
http://www.nabble.com/Conditional-%27not%27-invalid-for-event-streams--tp25217095p25217265.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] Conditional 'not' invalid for event streams?

2009-08-30 Thread Barry Kaplan

After looking at ../integrationtests/test_CEP_DelayingNot.drl I'm getting
closer, but not really understanding. I can get a greenbar with the below.
However if change the last advanceTime() value to anything less than 30 the
test fails. So it seems that the the conditional not clause does not start
its window until the first two clauses are true. 

Why would this be? Why does it not start ticking when the first StartEvent
is inserted?


rule [every s-f!a] How do I use patterns to correlate events arriving
in-order or out-of-order?
when
$se : StartEvent($exchangeId : exchangeId)  
 
from entry-point stream

$fe : FinishedEvent(exchangeId == $exchangeId, this after[0s,30s] $se) 
from entry-point stream
  
not (AbortedEvent(exchangeId == $exchangeId, this after[0s,30s] $se) 
from entry-point stream)
then
results.put(startEvent, $se);
results.put(finishedEvent, $fe);
end

@Test
def void
How_do_I_use_patterns_to_correlate_events_arriving_in_order_or_out_of_order__B()
{
insert new StartEvent(id: se1, exchangeId: BBB)
advanceTime 10, SECONDS
fireAllRules()
assert results.isEmpty()

advanceTime 10, SECONDS
insert new FinishedEvent(id: fe1, exchangeId: BBB)
fireAllRules()
assert results.isEmpty()

advanceTime 30, SECONDS
assert results[startEvent].id == se1
assert results[finishedEvent].id == fe1
}

-- 
View this message in context: 
http://www.nabble.com/Conditional-%27not%27-invalid-for-event-streams--tp25217095p25217673.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] Behavioral differences between session.insert() and entryPoint.insert()?

2009-08-30 Thread Barry Kaplan

I am seeing different behavior whether I insert events directly into session
or into a named entry-point. 

The below rule and test is greenbar'ed:


rule How_do_I_correlate_events_arriving_in_2_or_more_streams?
when
$e : WithdrawalEvent($accountNumber : accountNumber, $amount : amount)
over window:time(30s) 
from entry-point stream
$f : FraudWarningEvent(accountNumber == $accountNumber) over
window:time(30s) 
from entry-point stream
then
results.put(accountNumber, $accountNumber);
results.put(amount, $amount);
end

def insert(fact) { 
session.getWorkingMemoryEntryPoint(stream).insert(fact)
}

@Test
def void How_do_I_correlate_events_arriving_in_2_or_more_streams() {
// Not the same account
insert new WithdrawalEvent(accountNumber: AAA, amount: 100)
insert new FraudWarningEvent(accountNumber: BBB)
fireAllRules()
assert results.isEmpty()

// Not within the 30s window
advanceTime 31, SECONDS
insert new FraudWarningEvent(accountNumber: AAA)
fireAllRules()
assert results.isEmpty()


}


But if I do not specify a stream in the rules (ie, remove the 'from
entry-point stream') and instead insert directly into the session (like
many of the the drools integration do)...

def insert(fact) { 
session.insert(fact)
}

...the test fails. It does not matter how far I advance the clock before
inserting the (second) FraudWarningEvent, the rule always fires. 

I only found this difference after looking at the integration tests and
seing that I did not need to use a named entry-point for events. Did I
understand incorrectly? (I was looking at
/drools-compiler/src/test/resources/org/drools/integrationtests/test_CEP_DelayingNot.drl
and its associated java test.)

-- 
View this message in context: 
http://www.nabble.com/Behavioral-differences-between-session.insert%28%29-and-entryPoint.insert%28%29--tp25217843p25217843.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] Conditional 'not' invalid for event streams?

2009-08-30 Thread Barry Kaplan

Good evening Edson,

I am using insert time -- the event classes have no timestamps properties.

BTW, I have git project with all this code, but I don't think this last bit
is pushed yet... (http://github.com/memelet/drools-esper/tree/master). Maybe
once I've gotten thru the pattersn we can add it to drools-contrib as
additional examples?

-barry


-- 
View this message in context: 
http://www.nabble.com/Conditional-%27not%27-invalid-for-event-streams--tp25217095p25218351.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] clock.advanceTime behaviour?

2009-08-29 Thread Barry Kaplan

I've been using esper for some time with great success. But the appeal of
having integrated rules is overwhelming. To get familiar with Fusion, I'm
trying to implement the esper patterns, yet I and am stuck on the very first
one:

How do I measure the rate of arrival of events in a given time period?
 - select count(*) as cnt from MarketDataEvent.win:time_batch(1 second)

For now I'm just trying to get my rule to fire at all, so its not really
trying to count just trigger when the number events in the window exceeds a
certain number. (But I admit, I'm not sure how to just the get running count
over the window, so if anybody knows...):

declare MarketDataEvent
@role(event)
end

rule How do I measure the rate of arrival of events in a given time
period?
when
$count : Long( longValue  5) from accumulate ( 
$e: MarketDataEvent() over window:time(1s) from entry-point
stream, count($e))
then
System.out.println(*  5);
end

My test driver is just inserting events every 10ms:

(1..10).each { 
drools.clock.advanceTime(10, TimeUnit.MILLISECONDS)
drools.entryPoint.insert(new MarketDataEvent(it as String))
drools.session.fireAllRules()
}


If I do /not/ advance the clock, then I rule fires each time after the 5th
insert. But if the clock /is/ advanced (at any increment) then the rule
never fires.

Any clues what I might be missing?

thanks!
-- 
View this message in context: 
http://www.nabble.com/clock.advanceTime-behaviour--tp25205578p25205578.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] clock.advanceTime behaviour?

2009-08-29 Thread Barry Kaplan

The @expires( 10s ) did the trick. (I was already in stream mode). 

I was just debugging down into WorkingMemoryReteExpireAction and was saw
that every time I advanced the clock the events in the window were evicted.
I guess this is the 5.0.1 bug. 

Are there maven snapshot builds? I'll be happy to use those.

thanks very much Edson!
-- 
View this message in context: 
http://www.nabble.com/clock.advanceTime-behaviour--tp25205578p25207390.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] clock.advanceTime behaviour?

2009-08-29 Thread Barry Kaplan

I'm building 5.1.0-SNAPSHOT now... Is there already some support batch
windows in there now?
-- 
View this message in context: 
http://www.nabble.com/clock.advanceTime-behaviour--tp25205578p25207433.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] Share 'declare' by adding drl to KnowledgeBuilder?

2009-08-29 Thread Barry Kaplan

I have a drl that only contains a declare statement. When I load a drl
containing rules I also load that drl. But when the rule executes I get an
error which is the same as if I didn't have the declare.

When I debug and check the PackageDescr for the drl containing the 'declare'
the TypeDeclarationDescr is in the package and seems to have the correct
values.

Both the rule and the drl with the 'declare' are in the same package:

declartions.drl:
---
package memelet.droolsesper

import memelet.droolsesper.MarketDataEvent

declare MarketDataEvent
@role(event)
@expires(10s)
end
---

rule.drl:
---
package memelet.droolsesper

import memelet.droolsesper.ArrivalRate

global ArrivalRate arrivalRate

rule How do I measure the rate of arrival of events in a given time
period?
/*
 select count(*) as cnt from MarketDataEvent.win:time_batch(1 second)
*/
/*
 5.0.1 does not support 'time_batch', so the best we can do is capture the
 continous count. 
*/
when
$rate : Long() from accumulate ( 
$e: MarketDataEvent() over window:time(1s) from entry-point
stream, count($e))

then
arrivalRate.value = $rate;
end
---

-- 
View this message in context: 
http://www.nabble.com/Share-%27declare%27-by-adding-drl-to-KnowledgeBuilder--tp25208077p25208077.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] DSL debugging?

2008-06-24 Thread Barry Kaplan

Also, I get these below errors, which seems to indicate that something is
very wrong with rule parser. Like it cannot parse anything because of the
expander?

[25] Unable to expand: Strategy strategy = new
Strategy(drools.getRule().getName(), 1, 
[26] Unable to expand: new StrategyLeg(LongShort.LONG,
availableQuantity, equity));
[27] Unable to expand: insertLogical(strategy);
[6] Unable to expand: equity : EquityInstrument()[8] Unable to expand:
position : Position([9] Unable to expand: instrument == equity,[10] Unable
to expand: longShort == LongShort.SHORT,[11] Unable to expand: quantity 
0)[13] Unable to expand: legsQuantity : Integer(intValue 
position.quantity)[14] Unable to expand: from accumulate( StrategyLeg([15]
Unable to expand: priority  1,[16] Unable to expand: instrument ==
equity,[17] Unable to expand: longShort == LongShort.SHORT,[18] Unable to
expand: legQuantity : quantity )[19] Unable to expand:
legsQuantity(legQuantity) )[22] Unable to expand: int
availableQuantity = position.getQuantity() - legsQuantity;  
[23] Unable to expand: Strategy strategy = new
Strategy(drools.getRule().getName(), 1, 
[24] Unable to expand: new StrategyLeg(LongShort.SHORT,
availableQuantity, equity));
[25] Unable to expand: insertLogical(strategy);

-- 
View this message in context: 
http://www.nabble.com/DSL-debugging--tp18095970p18096038.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] LHS reuse?

2008-06-18 Thread Barry Kaplan

I have a set of rules that /all/ contain the following condition...

positionQuantityAllocatedToLegs : 
Integer(intValue  position.quantity)
from accumulate( StrategyLeg(priority  1, instrument == equity,
 longShort ==
LongShort.LONG, legQuantity : quantity )
 legsQuantity(legQuantity) )   

...the only difference being the values for the StrategyLeg. 

It would be very nice if there was some way to create reusable LHS
constructs, say maybe something like:

positionQuantityAllocatedToLegs : legsAllocation(1, position.quantity,
LongShort.LONG)

Where 'legsAllocation' is replaced with the condition above. Is there such a
mechanism, or need I simply live with large amounts of duplication in my
LHS?

thanks!

-- 
View this message in context: 
http://www.nabble.com/LHS-reuse--tp17986260p17986260.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] No accumulator function found for identifier

2008-06-17 Thread Barry Kaplan

Is there any other magic for the IDE to see this file? With
drools.packagebuilder.conf in my windows home directory I still get the IDE
error. 

Also, for my environment I'm not using a property file at runtime -- I
create the properties in code and construct a PackageBuilderConfiguration.
It would be nice if there was another way to configure the IDE that is
compatible for this supported use of the API.

-barry

-- 
View this message in context: 
http://www.nabble.com/No-accumulator-function-found-for-identifier-tp17339463p17932670.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] question on rule efficiency

2008-06-05 Thread Barry Kaplan

When the value of a property is compared across two instances, is it better
to create variables for the properties, or is using the object.property for
the comparison equivalent?

Here's an example: I need to match based on the strikePrice property. Is
either version better than the other?


version 1)

   putContract  : OptionInstrument(
   optionType == OptionType.PUT) 
   callContract : OptionInstrument(
   optionType == OptionType.CALL,
   strikePrice  putContract.strikePrice)  
// compare using navigation

version 2)
   putContract  : OptionInstrument(
   optionType == OptionType.PUT,
   putStrikePrice : strikePrice)  
// delcare the variable
   callContract : OptionInstrument(
   optionType == OptionType.CALL,
   strikePrice  putStrikePrice) 
// compare using variable

-- 
View this message in context: 
http://www.nabble.com/question-on-rule-efficiency-tp17672843p17672843.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] Matching on instanceof without eval?

2008-05-24 Thread Barry Kaplan

Edson, I do not assert the Instruments, on the Positions which contains
multiple Instruments. I an trying to match Option Positions (ie, Positions
that contain one or more Option legs).

What I did was...

when
position : Position(option : instrument, option.class ==
OptionInstrument)

...and this works correctly. Is the above more or less efficient than using
eval or the from-clause? It certainly is easier to read.

thanks!

-barry
-- 
View this message in context: 
http://www.nabble.com/Matching-on-instanceof-without-eval--tp17425953p17453068.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] Matching on instanceof without eval?

2008-05-23 Thread Barry Kaplan

I would like to match on the class of a field. I know I can use eval(option
instanceof OptionInstrument), but my understanding is that the use of eval
precludes indexing. What I want is something like the below, which does not
work. Is some other mechanism other than putting type codes that are
redundant with the class for this use case?

thanks!


rule Long Call/Put, Short Uncovered Call/Put
when 
position : Position(option : instrument, option.class ==
OptionInstrument.class)
then
...
end


-- 
View this message in context: 
http://www.nabble.com/Matching-on-instanceof-without-eval--tp17425953p17425953.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] Matching on instanceof without eval?

2008-05-23 Thread Barry Kaplan

Ok, I figured it out. Just a small typo on my part:

... option.class = OptionInstrument ...

not 

... option.class = OptionInstrument.class ...
-- 
View this message in context: 
http://www.nabble.com/Matching-on-instanceof-without-eval--tp17425953p17427082.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] debugging with 3.1M1 IDE?

2007-02-22 Thread Barry Kaplan
Well, I just checked out head and rebuilt the IDE with both the feature 
and plugin. But I get no drools launch type


(BTW, The ant/maven build seem to run clean. But importing the drools 
projects into eclipse results in lots of projects with errors. Is this 
expected for M1.)


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


Re: [rules-users] debugging with 3.1M1 IDE?

2007-02-22 Thread Barry Kaplan
::--))  I installed a fresh eclipse 3.2.2 and drools as the only plugin. 
All works!!! Then I added back all my plugins, and all /still/ works 
good. So, who knows. Who cares. Now I can have fun. Thanks all!!!


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


[rules-users] FYI: IDE 3.1M1 does not work with eclipse 3.3M5

2007-02-22 Thread Barry Kaplan
The problems seems to be the jar container created by the plugin in the 
project. In 3.3M5 it seems to only have the JDT. So for example classes 
like RuleBase and WorkingMemory are not found. This not really a problem 
for me since I'm going to add the jars to the project directly (as 
opposed to using the eclipse plugin.) But I'm not sure yet whether the 
compiler or debugger will work with 3.3M5.

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