Re: [rules-users] Drools solver info => provide DSL instead of DRL to Drools Solver
by Geoffrey De Smet
Hi Marco,
[I've send this answer to the drools user list,
please post any follow ups on the user list instead of mailing it
directly to me.
You can use nntp://news.gmane.org #gmane.comp.java.drools.user if you
want to keep your mailbox clean.]
Drools Solver's xml configuration doesn't support <scoreDsl> entry's yet
That shouldn't be to much work. I just created a JIRA for it:
https://jira.jboss.org/jira/browse/JBRULES-2333
Patch welcome (attached to that jira) and I would apply it within a week
on trunk.
Short of doing the patch on trunk, you can do this workaround:
- build the Solver directly yourself (basically just fisheye.jboss.org
for XmlSolverConfigurer's code). Not recommended.
- supply a an empty drl to <scoreDrl>, build the Solver, cast it to
DefaultLocalSearchSolver and replace the rulebase.
Both are not ideal in the long run though.
With kind regards,
Geoffrey De Smet
Marco caminiti schreef:
> Hi Geoffrey,
> I'm Marco Caminiti an Italian student of computer engineering. I'm
> using drools solver for my thesis and I have a problem.
>
> For the thesis I made a model of bin packing writing the rules on a
> drl file, and thus far, so good.
>
> Now I want to rewrite the rules that must use the solver in a specific
> language, but if I put in the configuration file of the solver the URL
> of the file DSL (or file DSLR) the solver crashes because it can not
> be configured.
>
> I ask whether you can use the solver with DSL tool and if so how could
> I do.
>
> Sorry to bother you but on this argument I have not found
> documentation on the Internet, more than anything else I'm sorry for
> my English.
>
> Thanks from now for the answer.
> Marco Caminiti
>
>
16 years, 4 months
ConcurrentModificationException at org.drools.reteoo.ClassObjectTypeConf.getMatchingObjectTypes
by karthizap
I am using Drools-core.jar(version-5.0.0.CR1) and getting the following
exception. I could see similar stacktrace reported with
JIRA-1888(https://jira.jboss.org/jira/browse/JBRULES-1888) and its marked as
closed. Fix related to this Jira is not available (Rete.java) in the Drools
5.0.1 and 5.1.0 source code/drools-core jar files.
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
entryPoints = Collections.synchronizedMap((Map<EntryPoint,
EntryPointNode>) in.readObject());
ruleBase = ((DroolsObjectInputStream)in).getRuleBase();
super.readExternal( in );
}
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:841)
at java.util.HashMap$ValueIterator.next(HashMap.java:871)
at
org.drools.reteoo.ClassObjectTypeConf.getMatchingObjectTypes(ClassObjectTypeConf.java:171)
at
org.drools.reteoo.ClassObjectTypeConf.getObjectTypeNodes(ClassObjectTypeConf.java:163)
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:143)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1066)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1022)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:810)
Please let me know the correct fix for this problem.
--
View this message in context: http://old.nabble.com/ConcurrentModificationException-at-org.drools.reteo...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 4 months
Java beans inheritance
by Zohar Etzioni
Hi,
I have a class hierarchy of objects that I'm inserting as facts. Lets
say X, Y extends X and Z extends Y. I have a rule that is defined on X
and therefore applies to all of them, however in the rule I want to
ask about the class name and I'm referring to it as
class.name=="some.class". This should work as far as I understand coz
it keeps the java beans format, however it is not directly defined in
the class X but rather in Object. The error I'm getting is "Error:
could not access: name". Any idea what I'm doing wrong?
Thanks,
Dawg
16 years, 4 months
Odd class loading issues (java.lang.NoClassDefFoundError wrong name) running JUnit test cases via Ant
by Weaver, Scott
Hi,
I am running into a strange classloader issue when running test cases in Ant. Outside of Ant, the test cases and application itself just run fine. It's only when I attempt to run the test case from within Ant that I get the error below:
Drools 5.0.1
Ant 1.6
JUnit 4.7
<testcase classname="com.siemens.pl.it.gre.rules.TestJUnit" name="testRule" time="1.75">
<error message="TestObject (wrong name: com/siemens/pl/it/gre/rules/TestObject)" type="java.lang.NoClassDefFoundError">java.lang.NoClassDefFoundError: TestObject (wrong name: com/siemens/pl/it/gre/rules/TestObject)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at org.drools.rule.CompositeClassLoader.loadClass(CompositeClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.drools.base.ClassTypeResolver.resolveType(ClassTypeResolver.java:144)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:140)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:104)
at org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:69)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:68)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1159)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:649)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:290)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:488)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at com.siemens.pl.it.gre.rules.AbstractRulesTestCase.createRuleBase(AbstractRulesTestCase.java:62)
at com.siemens.pl.it.gre.rules.TestJUnit.setUp(TestJUnit.java:21)
</error>
Ant snippet:
<target name="unitTest2">
<junit fork="yes">
<classpath>
<path refid="classpath" />
</classpath>
<formatter type="xml" />
<test name="com.siemens.pl.it.gre.rules.TestJUnit" haltonfailure="yes" outfile="${test.reports.dir}/results">
<formatter type="xml" />
</test>
</junit>
</target>
Turning the "fork" option off has no effect.
Example rule:
package com.siemens.pl.it.rules.test
import com.siemens.pl.it.gre.rules.TestObject;
rule "Is Value 'foo'?"
when
$testObj : TestObject( value == "foo" )
then
$testObj.setResult(true);
end
Interestingly, if I fully-qualify the class in LHS like this: com.siemens.pl.it.rules.test.TestObject( value == "foo" ), the test runs just fine though I would prefer not to have to do this in all my rules if at all possible.
Thanks,
-scott
16 years, 4 months
Fusion : Timebased rules fire only for the first time after the start of the application (tomcat)
by Chetan Mahadev
Hi
I am trying to correlate two or more events when a condition gets satisfied.
The rule is working fine only when i start my tomcat, and it fires only for
the first match of the events.
But subsequent events fails to correalte ( or rule doesnt fire). Am not sure
wats the issue.
Currently I am using the following config when i build my KnowledgeBase:
knowledgeBaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
knowledgeBaseConfig.setOption( EventProcessingOption.STREAM );
kBase = KnowledgeBaseFactory.newKnowledgeBase( knowledgeBaseConfig
);
//kBase = newKbase();
kBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
KnowledgeSessionConfiguration knowledgeSessionConfig =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
((SessionConfiguration) knowledgeSessionConfig).setClockType(
ClockType.REALTIME_CLOCK );
Can anybody help here??
Regds
Chetan
16 years, 4 months
Reg: Writing complex rules in Grided editor
by bas karan
Hi,
I am new to Drools rules. Can any one of you tell me how can we write complex rules like below using Grided editor.
rule sequenceOfIncreasingWithdrawals
when
$account:Account($number : number)
$t1:TransactionCreatedEvent(fromAccountNumber == $number)
from entry-point TransactionStream
$t2:TransactionCreatedEvent(amount > $t1.amount,
fromAccountNumber == $number, this after[0, 3m] $t1)
from entry-point TransactionStream
not (TransactionCreatedEvent(fromAccountNumber == $number,
this after $t1, this before $t2 )
from entry-point TransactionStream)
$t3:TransactionCreatedEvent(amount > $t2.amount,
fromAccountNumber == $number, this after[0, 3m] $t2 )
from entry-point TransactionStream
not (TransactionCreatedEvent(fromAccountNumber == $number,
this after $t2, this before $t3 )
from entry-point TransactionStream)
$ai : AccountInfo(number == $number, eval($t1.amount.add(
$t2.amount).add($t3.amount).compareTo(BigDecimal.
valueOf(0.90).multiply(averageBalance)) > 0))
then
insert(new SuspiciousAccount($number,
SuspiciousAccountSeverity.MAJOR));
insert(new SuspiciousTransaction($t1.transactionUuid,
SuspiciousTransactionSeverity.MAJOR));
insert(new SuspiciousTransaction($t2.transactionUuid,
SuspiciousTransactionSeverity.MAJOR));
insert(new SuspiciousTransaction($t3.transactionUuid,
SuspiciousTransactionSeverity.MAJOR));
end
Thanks
Baskaran S
Yahoo! India has a new look. Take a sneak peek http://in.yahoo.com/trynew
16 years, 4 months
How to get parameter in a Human Task Handler specified while starting the process.
by Pardeep.Ruhil@lntinfotech.com
Hi,
I have doubt regarding accessing parameter specified when we start a
workFlow proccess.
Like as we do while starting a process in Drools Flow.
ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null,
env );
Map<String, Object> parameters = new HashMap<String, Object>();
parametes.put("objAppInfo",new AppInfo("Hello"));
WorkflowProcessInstance processInstance = (WorkflowProcessInstance)
ksession.startProcess("
DemoFlow",parameters);
Now I want to access this "objAppInfo" paramters in my Handler specified
for the HumanTask.
Please tell me the method. To retrieve the same.
Thanks & Regards
Pardeep Ruhil
______________________________________________________________________
16 years, 4 months
Guvnor Integration and Deployment
by Andrew Waterman
Hi All,
I've got a question about Guvnor integration into a build process.
I'm thinking that if I develop my rules within Guvnor; I can integrate
them into my unit testing part of my build process via a downloaded,
compiled package from Guvnor. My KnowledgeBase would be initialized
from this PKG file for local unit tests. Upon deployment of my
application to the server (an EAR file), I would then be able to use
two types of integration tests:
1. External integration tests for the full application that have
rules loaded from the Guvnor production server.
2. Guvnor scenario based tests.
So far, so good.
I have a few questions , though. I would like to put a reference to
the Guvnor WAR in my EAR file and have it simultaneously deployed with
my application. Of course, I would want to deploy my localized
package there as well, so I could use it at runtime.
Are there any suggestions on how to deploy an existing package into
Guvnor in a programmatic (maven-centric) fashion?
Is this the right approach to take for using Guvnor in a deployment
process?
Is there a way to remotely trigger Guvnor testing scenarios from the
build process?
best wishes,
Andrew
---------------------------------
Andrew Waterman
San Cristóbal de las Casas, Chiapas, Mexico
16 years, 4 months
Re: [rules-users] Need help in formulating rule (using list)
by psentosa
Hi Brody,
I have had similar situation several times, and each time I had to modify my
objects to avoid this, and it was really tedious.
I'd also would like to know whether it is possible to have a "real solution"
in this case without needing to change the base objects, but rather use the
rule language to formulate this kind of business rule
*why didn't I receive this mail through the mailing list? maybe you haven't
subscribed yet?*
Brody bach wrote:
>
> Hi all,
>
> I have an object which I use as main fact object, let's say "Schedule",
> which has a list of objects called "TimeEntry" --->
>
> class Schedule(){
> List<TimeEntry> entries;
> }
>
> class TimeEntry(){
> String type;
> Date start;
> Date end;
> Integer length;
> }
>
>
> Now, if I insert Schedule into the WM, and would like to iterate over the
> list of TimeEntry, due to the following business rule :
>
> For all time entries, if it is of type BREAK:
> check whether a time entry of type WORK exist,
> before and/or after this BREAK, which has only length of 10 minutes
>
> The content of the time entry list has been sorted before so they are all
> in correct time order, e.g
>
> 09:00 - 09:10 WORK (10 min)
> 09:10 - 09:30 BREAK (20 min)
> 09:30 - 10:30 WORK (60 min)
> --> in this case, the rule should fire
>
> How can I define this rule? Some questions which I have:
> - how do I check previous and next element of the current element?
> - the length of the list isn't fix; it may contain 1, 2, or more entries.
> So somehow in an attempt to access next element, it should take care of
> the bound of the list. But should this be really part of the rule
> definition?
>
> Many thanks in advance!
>
> Regards
>
>
>
>
--
View this message in context: http://old.nabble.com/Need-help-in-formulating-rule-%28using-list%29-tp26...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 4 months