[rules-users] accumulate funtion in xml

Isabelle Hupont ihupont at ita.es
Fri Sep 28 06:59:20 EDT 2007


Hi Fernando!!

I have fixed the problem... I didn't changed drools v3 modify(_i) statement
by drools v4 update(-i).
Now everything works well!
Thanks a lot for your attention.




Isabelle Hupont wrote:
> 
> Sorry!! I mixed the .class and. java files!! ;)
> Here is the source code. I also paste the code I am using to read the rule
> package: 
> 
> public RuleBase readRulePackage() throws PersistenceException{
> 		// Reads a set of rules from XML file
> 		try {					
> 
> 			PackageBuilder builder = new PackageBuilder();
> 			builder.addPackageFromXml(new InputStreamReader(new
> FileInputStream(ruleFile)));
> 
> 			ruleBase = RuleBaseFactory.newRuleBase();
> 			ruleBase.addPackage(builder.getPackage());
> 			return ruleBase;
> 			
> 		} catch (Exception e){
> 			e.printStackTrace();
> 			throw new PersistenceException("Error reading rules file");
> 		}
> 	}
> 
> thx! http://www.nabble.com/file/p12935779/Instance.java Instance.java 
> 
> 
> Fernando Meyer Camargo wrote:
>> 
>> Hi isabelle,
>> 
>> When I said instance class, I was meaning your instance source code ;)
>> 
>> Regards
>> 
>> On 9/28/07, Isabelle Hupont <ihupont at ita.es> wrote:
>>>
>>>
>>> Hi Fernando!
>>>
>>> Mi Instance class is the Weka class I attach....
>>> Thanks for your attention.
>>> Isabelle.
>>> http://www.nabble.com/file/p12935480/Instance.class Instance.class
>>>
>>>
>>>
>>> Fernando Meyer Camargo wrote:
>>> >
>>> > Could you please provide your Instance class ?
>>> >
>>> >
>>> > On 9/27/07, Isabelle Hupont <ihupont at ita.es> wrote:
>>> >>
>>> >>
>>> >> Hi!
>>> >>
>>> >> I want to program the following drl rule in xml:
>>> >>
>>> >> rule "average calculation"
>>> >>         no-loop true
>>> >>         when
>>> >>                 _i : Instance()
>>> >>                 _average : Double()
>>> >>                                 from accumulate(accInst: Instance(),
>>> >>                                                        average(
>>> >> accInst.value("tend")))
>>> >>                 eval(_average < 20000)
>>> >>         then
>>> >>                 _i.setValue("tend",2000);
>>> >> end
>>> >>
>>> >>
>>> >> For it, I have implemented the following xml file:
>>> >>
>>> >> <?xml version="1.0" encoding="UTF-8"?>
>>> >> <package name="org.prophet.fuzzy"
>>> xmlns="http://drools.org/drools-4.0"
>>> >>     xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
>>> >> xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
>>> >>     <import name="weka.core.*"/>
>>> >>     <import name="org.prophet.gui.docking.*"/>
>>> >>     <import name="org.prophet.persistence.*"/>
>>> >>     <import name="org.prophet.persistence.hibernate.*"/>
>>> >>     <import name="org.prophet.rules.*"/>
>>> >>     <import name="org.prophet.*"/>
>>> >>     <rule name="Rule1">
>>> >>         <rule-attribute name="no-loop" value="true"/>
>>> >>         <lhs>
>>> >>             <pattern identifier="_i" object-type="Instance"/>
>>> >>             <pattern identifier="_average" object-type="Double">
>>> >>                 <from>
>>> >>                     <accumulate>
>>> >>                         <pattern identifier="accInst"
>>> >> object-type="Instance"/>
>>> >>                         <external-function evaluator="average"
>>> >> expression="accInst.value(&quot;tend&quot;)"/>
>>> >>                     </accumulate>
>>> >>                 </from>
>>> >>             </pattern>
>>> >>             <eval>_average &lt; 20000.0</eval>
>>> >>         </lhs>
>>> >>         <rhs>
>>> >> _i.setValue("tend", 2000.0); manageRuleFired("Rule1", null, _i);
>>> >> modify(_i);</rhs>
>>> >>     </rule>
>>> >> </package>
>>> >>
>>> >> And I have the following error when reading the rule package:
>>> >>
>>> >> org.drools.rule.InvalidRulePackage: Rule Compilation error _average
>>> >> cannot
>>> >> be resolved _i cannot be resolved _i cannot be resolved _i__Handle__
>>> >> cannot
>>> >> be resolved _i cannot be resolved
>>> >>
>>> >>
>>> >> I also have tried to replace the xml identifier <pattern> by <column>
>>> >> with
>>> >> no result. Can you help me, please?
>>> >>
>>> >>
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/accumulate-funtion-in-xml-tf4526879.html#a12916380
>>> >> Sent from the drools - user mailing list archive at Nabble.com.
>>> >>
>>> >> _______________________________________________
>>> >> rules-users mailing list
>>> >> rules-users at lists.jboss.org
>>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Fernando Meyer http://fmeyer.org
>>> > JBoss Rules Core Developer
>>> > fmcamargo at gmail.com
>>> >
>>> > _______________________________________________
>>> > rules-users mailing list
>>> > rules-users at lists.jboss.org
>>> > https://lists.jboss.org/mailman/listinfo/rules-users
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/accumulate-funtion-in-xml-tf4526879.html#a12935480
>>> Sent from the drools - user mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>> 
>> 
>> 
>> -- 
>> Fernando Meyer http://fmeyer.org
>> JBoss Rules Core Developer
>> fmcamargo at gmail.com
>> 
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/accumulate-funtion-in-xml-tf4526879.html#a12938379
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list