$firm should be $context...To post the rule in the public sphere I had to modify some variables(legal company issues :-) ). The same goes for the rule name(my replacement of text is not very good).
I understand Wolfgang's point...I just made a poor assumption(something as someone who has used drools for several years I shouldn't have done...every once and a while I guess I get a brain fart) Davide Sottara wrote > Am I wrong or these are not the (only) rules that are being run? > > 1) The exception is thrown as the consequence of a rule called > > com.nasdaq.rms.nq.status.Rule_Calculate_Firm_Participation_Ratio_cfb033f33c2b404fb2bff8e1b9af0175 > > "Rule Calculate Firm Participation Ratio", which is not shown. > > 2) The Rule "Add baseline to context..." modifies a $firm which is not > bound anywhere > in that rule.. > > 3) Looking at the stack trace, the consequence happens in a MVEL > Constraint, which > is in an Alpha Node immediately after an ObjectTypeNode. This usually > means that > the failing constraint is the first in the pattern, which is not the > case in your > "Calculate Participation Ratio". > (to Wolfgang's point: it is not mandatory, since "and" is commutative, > but this is what > usually happens in practice) > > You also have multiple threads... is that "avgVolume" computed using an > accumulate > somewhere? I wonder if there are critical races..... > > On 11/01/2013 11:17 AM, gboro54 wrote: >> Agreed. In this case it is possible to move to the RHS...but I have to >> ask >> what if I need to use the math as part of a constraint. Is it not safe to >> assume the divisor is 0 even if I do the check? That seems like an issue >> as >> I do have cases which this will be required >> >> >> Stephen Masters wrote >>> Given that you don’t seem to using the result as a constraint, then I >>> can’t see any benefit to it being on the LHS. So yes, It would be better >>> on the RHS. >>> >>> Steve >>> >>> >>> On 1 Nov 2013, at 17:58, Wolfgang Laun < >>> wolfgang.laun@ >>> > wrote: >>> >>>> I can anticipate the answer where OP says that there is a constraint >>>> restricting argVolume to > 0. However, I don't think that independent >>>> constraints such as we see them in this rule are evaluated as if they >>>> were in a single logical expression, with Java semantics. >>>> >>>> The seductive possibility of binding to a half-baked expression (i.e., >>>> $ratio:(volumeAccumulations["total"]/consolidatdVolume.avgVolume)) >>>> should be discarded. This value can safely be computed on the RHS >>>> where the denominator's value being !=0 is asserted. >>>> >>>> -W >>>> >>>> On 01/11/2013, Stephen Masters < >>> stephen.masters@ >>> > wrote: >>>>> Divide by zero exceptions usually occur when you try to divide by >>>>> zero. >>>>> >>>>> So … first question … is consolidatdVolume.avgVolume ever zero? >>>>> >>>>> >>>>> On 1 Nov 2013, at 16:17, gboro54 < >>> gboro54@ >>> > wrote: >>>>>> I have rules like the following: >>>>>> >>>>>> rule "Add Baseline to Context if it does not exists exists or not >>>>>> greater >>>>>> then 0" >>>>>> no-loop true >>>>>> when >>>>>> $context:Context($id:id,baselineParticipation==null || >>>>>> >>>>>> baselineParticipation.baselineRatio==null||baselineParticipation.baselineRatio==0) >>>>>> then >>>>>> modify($firm) {setBaselineParticipation(new >>>>>> BaselineParticipation($id,new >>>>>> BigDecimal(0.00485)))}; >>>>>> >>>>>> end >>>>>> >>>>>> rule "Calculate Participation Ratio" >>>>>> no-loop true >>>>>> when >>>>>> >>>>>> $context:Context(consolidatdVolume!=null,consolidatdVolume.avgVolume>0, >>>>>> >>>>>> volumeAccumulations["total"]!=null,volumeAccumulations["total"]>0, >>>>>> >>>>>> $ratio:(volumeAccumulations["total"]/consolidatdVolume.avgVolume)) >>>>>> then >>>>>> ConcurrentMap calculatedRatios=$firm.getCalculatedRatios(); >>>>>> calculatedRatios.put("fparticipationRatio",new >>>>>> BigDecimal($ratio)); >>>>>> modify($firm){setCalculatedRatios(calculatedRatios)}; >>>>>> end >>>>>> >>>>>> Despite the checks I get the following exception and any insight into >>>>>> why >>>>>> would be great: >>>>>> >>>>>> Exception executing consequence for rule "Calculate Firm >>>>>> Participation >>>>>> Ratio" in com.nasdaq.rms.nq.status: java.lang.ArithmeticException: / >>>>>> by >>>>>> zero >>>>>> Exception executing consequence for rule "Calculate Firm >>>>>> Participation >>>>>> Ratio" in com.nasdaq.rms.nq.status: java.lang.ArithmeticException: / >>>>>> by >>>>>> zero >>>>>> at >>>>>> org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) >>>>>> at >>>>>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297) >>>>>> at >>>>>> org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221) >>>>>> at >>>>>> org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456) >>>>>> 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.nasdaq.fq.rms.workflow.processor.rules.PerformanceStatusAssignmentProcessor.doWork(PerformanceStatusAssignmentProcessor.java:156) >>>>>> at >>>>>> com.ften.ssr.workqueue.WorkItemRunnable.run(WorkItemRunnable.java:48) >>>>>> at >>>>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) >>>>>> at >>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) >>>>>> at java.lang.Thread.run(Thread.java:724) >>>>>> Caused by: java.lang.ArithmeticException: / by zero >>>>>> at >>>>>> ConditionEvaluatorda6271cf5a744b6bbdb9c717cae2edb7.evaluate(Unknown >>>>>> Source) >>>>>> at >>>>>> org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:200) >>>>>> at >>>>>> org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:157) >>>>>> at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:154) >>>>>> at >>>>>> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:507) >>>>>> at >>>>>> org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:432) >>>>>> 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:432) >>>>>> 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 >>>>>> com.nasdaq.rms.nq.status.Rule_Calculate_Firm_Participation_Ratio_cfb033f33c2b404fb2bff8e1b9af0175.defaultConsequence(Unknown >>>>>> Source) >>>>>> at >>>>>> com.nasdaq.rms.nq.status.Rule_Calculate_Firm_Participation_Ratio_cfb033f33c2b404fb2bff8e1b9af0175DefaultConsequenceInvokerGenerated.evaluate(Unknown >>>>>> Source) >>>>>> at >>>>>> com.nasdaq.rms.nq.status.Rule_Calculate_Firm_Participation_Ratio_cfb033f33c2b404fb2bff8e1b9af0175DefaultConsequenceInvoker.evaluate(Unknown >>>>>> Source) >>>>>> at >>>>>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287) >>>>>> ... 10 more >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> View this message in context: >>>>>> http://drools.46999.n3.nabble.com/Drools-5-5-divide-by-0-exception-tp4026582.html >>>>>> Sent from the Drools: User forum mailing list archive at Nabble.com. >>>>>> _______________________________________________ >>>>>> rules-users mailing list >>>>>> >>> rules-users@.jboss >>>>>> https://lists.jboss.org/mailman/listinfo/rules-users >>>>> >>>>> _______________________________________________ >>>>> rules-users mailing list >>>>> >>> rules-users@.jboss >>>>> https://lists.jboss.org/mailman/listinfo/rules-users >>>>> >>>> _______________________________________________ >>>> rules-users mailing list >>>> >>> rules-users@.jboss >>>> https://lists.jboss.org/mailman/listinfo/rules-users >>> >>> _______________________________________________ >>> rules-users mailing list >>> rules-users@.jboss >>> https://lists.jboss.org/mailman/listinfo/rules-users >> >> >> >> >> -- >> View this message in context: >> http://drools.46999.n3.nabble.com/Drools-5-5-divide-by-0-exception-tp4026582p4026591.html >> Sent from the Drools: User forum mailing list archive at Nabble.com. >> >> _______________________________________________ >> rules-users mailing list >> > rules-users@.jboss >> https://lists.jboss.org/mailman/listinfo/rules-users > > _______________________________________________ > rules-users mailing list > rules-users@.jboss > https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/Drools-5-5-divide-by-0-exception-tp4026582p4026597.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