complex rule conditions
by sweng
Hi,
I want to use some "complex" conditions on the lhs of a rule.
Following the example in the drools-expert docu:
Person( girlAge : age, sex = "F" )
Person( eval( age == girlAge + 2 ), sex = 'M' )
I have try the following rule:
rule "detect stop of cars"
when
p1:PositionReportEvent( $t1:time)
p2:PositionReportEvent( eval(time == $t1 + 30))
then
System.out.println("do something");
end
but it is never triggered.
--
View this message in context: http://n3.nabble.com/complex-rule-conditions-tp188717p188717.html
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 9 months
Strange rule compilation issue.
by Brice Figureau
Hi,
I have the following MVEL expression in a rule (with drools 5.1.0M1):
Scenario( id == 6147 )
Scenario is an interface which has the following accessor (and tons of
other methods):
public interface Scenario
{
...
public int getId();
...
}
But either in Eclipse or when compiling the rules I get the following
error:
Unable to create Field Extractor for 'id' of '[ClassObjectType class=com.daysofwonder.mm.Scenario]'
I tried tons of variants including:
Scenario( getId == 6147 )
that still doesn't work.
The only variant I could make work is:
$s : Scenario( )
Scenario ( eval($s.getId() == 6147 ) )
which is plain ugly.
using something else than a Scenario or defining a new interface with
only getId() in it makes it work.
Any idea about what I got wrong?
How can I debug the situation?
Thanks,
--
Brice Figureau
My Blog: http://www.masterzen.fr/
14 years, 9 months
Performance and Memory Utilization - StatefulKnowledgeSession
by HonorGod
I have over million rows of data that are stored in a fact model. I have to
apply 2 sets of rules [coming from 2 decision tables - cannot combine them
for a specific reason] on each fact model.
I have created static knowledgebases and stored them in cache so that they
can be used when ever new StatefulKnowledgeSessions are required.
This is how I am doing it -
Iterating over the fact model one after the other and pass them to the
method that applies rules -
public int applyRules(MyModel model) {
int noOfRulesFired = 0 ;
StatefulKnowledgeSession kSession =
((KnowledgeBase)DroolsKnowledgeBaseManager.getInstance().knowledgeBases.get("FirstSetOfRules")).newStatefulKnowledgeSession()
;
kSession.insert(model);
noOfRulesFired = kSession.fireAllRules();
if( noOfRulesFired >= 1 ) {
kSession =
((KnowledgeBase)DroolsKnowledgeBaseManager.getInstance().knowledgeBases.get("SecondSetOfRules")).newStatefulKnowledgeSession()
;
kSession.insert(model);
kSession.insert(this);
noOfRulesFired +=kSession.fireAllRules();
}
kSession.dispose() ;
return noOfRulesFired ;
}
Is this good approach? How can I reuse StatefulKnowledgeSessions so that I
can insert my fact models one at a time and fire rules. Creating new
StatefulKnowledgeSession for every fact model is consuming lot of memory and
even though dispose() is called before existing method - GC might not clean
it instently.
Please assist [I am in middle of UAT and started to notice that memory
consumption is too high] .
Thanks
--
View this message in context: http://n3.nabble.com/Performance-and-Memory-Utilization-StatefulKnowledge...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 9 months
completeMoveTabuSize VS partialMoveTabuSize
by dmzpippo-drools@yahoo.it
Hi all,
What is the difference between completeMoveTabuSize and partialMoveTabuSize?
By what method compares the current move with moves in the tabu list?
thanks,
Marco
14 years, 9 months
Tabo List question
by dmzpippo-drools@yahoo.it
Hi all,
I have a problem with the list of taboo search. I
have a move class with many attributes and I want to consider that a
move is taboo by only two or three of its attributes (integer values).
For example:
I have two lists (each has its own id), the move is to move an object (which has its own id) from a list to another. then the attributes that identify the move are the three identifiers (id_object, id_SRC_List, id_DST_List).
when I make
this move I would consider taboo all the moves that bring me back the item in the original list. ie all the moves of type
(Id_object, id_of_any_other_List, id_SRC_List).
I
don't think that I can use CompletTaboSize (or undoMove etc..) because I think that
two moves that perform the same exchange can be considered different
because of other attributes. is this correct ?
For now I'm trying to use the PropertyTaboList.
public Collection <? extends Object> getTabuProperties () (
HashMap <Integer, Integer> propertyTaboo = new HashMap <Integer,Integer> (1);
propertyTaboo.put (CustomerNumber, sourceRoute); // id_object, id_SRC_List
return Collections.singletonList (propertyTaboo);
)
I do not know if it reaches the target.
Someone has some advice on how I could do?
Another question, is possible to stop the solver after X iteration and then restart maintaining the tabo list?
ragards,
Marco
14 years, 9 months
drools flow package issue
by Nair, Mahesh
______________________________________________
Hi ,
I am facing this weird issue when I try running a Stateful session created from 2 different package files (one is the main flow and the other is the sub flow. I am using SNAPSHOT jars for the 5.1.0 version. (https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/t...)
The only difference being that I am loading the main process and the sub process from 2 different package files (in my case a BLOB in the database).
The processes run individually; But when I tie them up (have a Re-usable sub process node in the main flow) together I get the below exception,
CONSOLE OUTPUT BELOW
SUBPROCESS Node 1
SUBPROCESS Node 2
SUBPROCESS Node 1
SUBPROCESS Node 2
java.lang.NoSuchMethodError: com.qwest.Process_com_qwest_0.action2(Lorg/drools/spi/KnowledgeHelper;Lorg/drools/spi/ProcessContext;)V
at com.qwest.Process_com_qwest_0Action2Invoker.execute(Process_com_qwest_0Action2Invoker.java:20)
at org.drools.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:54)
at org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:112)
at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:148)
at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:135)
at org.drools.workflow.instance.impl.ExtendedNodeInstanceImpl.triggerCompleted(ExtendedNodeInstanceImpl.java:37)
at org.drools.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:101)
at org.drools.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:82)
at org.drools.workflow.instance.node.SubProcessNodeInstance.internalTrigger(SubProcessNodeInstance.java:122)
at org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:112)
at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:148)
at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:135)
at org.drools.workflow.instance.node.ActionNodeInstance.triggerCompleted(ActionNodeInstance.java:62)
at org.drools.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:58)
at org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:112)
at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:148)
at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:135)
at org.drools.workflow.instance.node.ActionNodeInstance.triggerCompleted(ActionNodeInstance.java:62)
at org.drools.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:58)
at org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:112)
at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:148)
at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:135)
at org.drools.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)
at org.drools.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)
at org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:112)
at org.drools.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:16)
at org.drools.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:185)
at org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:284)
at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1763)
at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1741)
at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:284)
I create the KnowledgeSession usign the code below,
conf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
conf.setOption(EventProcessingOption.STREAM);
builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
for (Iterator iterator = flowList.iterator(); iterator.hasNext();) {
RFFlowInfoT rfFlowInfo = (RFFlowInfoT) iterator.next();
pkgBytes = rfFlowInfo.getPkgFile();
try {
ByteArrayInputStream bInputStream = new ByteArrayInputStream(pkgBytes);
if (bInputStream == null) {
System.out.println("Unable to create input stream from the pkg");
} else {
builder.add(ResourceFactory.newInputStreamResource(bInputStream), ResourceType.PKG);
}
} catch (Exception e) {
e.printStackTrace();
}
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(conf);
kbase.addKnowledgePackages(builder.getKnowledgePackages());
kSession = kbase.newStatefulKnowledgeSession();
try {
final ProcessInstance process = kSession.startProcess("mainFlow");
int iResult = kSession.fireAllRules();
System.out.println("rules fired! hopefully!!");
} catch (Throwable e) {
e.printStackTrace();
}
The flowList has contains 2 objects (main flow and the sub flow in the field pkgFile which is a byte array I get reading from a BLOB in the database). When I run, I notice that the sub process starts executing first and then the exception is thrown (as shown in the console output above)
I have attached the rf files in this mail.
Please let me where I am going wrong?
One more thing to note is that this issue does not arise if I create one single Package object (containing both main flow and sub flow rf xml files).
It works fine when I create the KnowledgeSession from the same code above (just that the flowList now contains only one object of Package class which has both the main flow and sub flow combined)
Is this a bug or is there something I am doing wrong.
Regards,
Mahesh
________________________________
This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.
14 years, 9 months
Property tabo list
by dmzpippo-drools@yahoo.it
Hi all,
I have a problem with the list of taboo search. I
have a move class with many attributes and I want to consider that a
move is taboo by only two or three of its attributes (integer values).
For example:
I have two lists (each has its own id), the move is to move an object (which has its own id) from a list to another. then the attributes that identify the move are the three identifiers (id_object, id_SRC_List, id_DST_List).
when I make this move I would consider taboo all the moves that bring me back the item in the original list. ie all the moves of type
(Id_object, id_of_any_other_List, id_SRC_List).
I
don't think that I can use CompletTaboSize (or undoMove etc..) because I think that
two moves that perform the same exchange can be considered different
because of other attributes.
For now I'm trying to use the PropertyTaboList.
public Collection <? extends Object> getTabuProperties () (
HashMap <Integer, Integer> propertyTaboo = new HashMap <Integer,Integer> (1);
propertyTaboo.put (CustomerNumber, sourceRoute); // id_object, id_SRC_List
return Collections.singletonList (propertyTaboo);
)
I do not know if it reaches the target.
Someone has some advice on how I could do?
ragards,
Marco
14 years, 10 months