solution equals and hashcode are never called.
by Michiel Vermandel
Hi,
I am still struggling to find why my simple unit test cannot be solved to a zero score solution.
It is easily to see the solution on sight and if I feed it with the prepared solution (in a custom solver phase) it "finds" the optimal solution right away.
I'm trying everything and try to review everything I have written.
It is during that review that I noticed that the equals and hashcode methods of my solution implementation class are never called.
Obviously the solutionEquals and solutionHashCode methods of my planning entity are never called either.
What should I conclude out of that?
Is this a crucial issue? If so, what should I check/change?
I am running Drools Planner 5.5.0.Final on java 1.7.0 on a Windows 7 64bit machine.
Thanks,
Michiel Vermandel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
13 years, 5 months
detecting score traps
by Michiel Vermandel
Hi,
Is there any deterministic way for detecting a score trap in Drools Planner?
I have read about the hill-climbing issue and the ways to reduce the possibility of this but I think it is still possible to encounter, right?
So it would be great to have some red-light flashing when it happens after all :-)
Thanks,
Michiel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
13 years, 5 months
can't copy files to guvnor using webdav
by Yuri
Hi Everyone,
I am having to move assets from one repository to another, and if WebDav
would work for me, I believe that it would be the easiest solution.
I have the default security setup that comes with guvnor 5.5.0 and JBoss AS
7, and I absolutely could not figure out any way to connect from Windows 7.
I was finally able to connect to webDav with BitKinex, however, I cannot
upload anything - I can download files just fine, but when I try to upload,
I get the following error on my server. Am I missing something?
Thanks,
Yuri
Error:
12:08:00,344 ERROR [org.drools.repository.RulesRepository]
(http--127.0.0.1-8080-7) Unable to load a module. :
javax.jcr.PathNotFoundException: *MyNewAsset.txt*
at org.apache.jackrabbit.core.NodeImpl$8.perform(NodeImpl.java:2135)
[jackrabbit-core-2.2.8.jar:2.2.8]
at org.apache.jackrabbit.core.NodeImpl$8.perform(NodeImpl.java:2129)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:200)
[jackrabbit-core-2.2.8.jar:2.2.8]
at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91)
[jackrabbit-core-2.2.8.jar:2.2.8]
at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2129)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.drools.repository.RulesRepository.loadModule(RulesRepository.java:435)
[guvnor-repository-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.repository.RulesRepository$Proxy$_$$_WeldClientProxy.loadModule(RulesRepository$Proxy$_$$_WeldClientProxy.java)
[guvnor-repository-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.files.WebDAVImpl.loadPackageFromRepository(WebDAVImpl.java:912)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.files.WebDAVImpl.getStoredObjectForReadOnlyPackages(WebDAVImpl.java:473)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.files.WebDAVImpl.getStoredObject(WebDAVImpl.java:409)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.files.WebDAVImpl$Proxy$_$$_WeldClientProxy.getStoredObject(WebDAVImpl$Proxy$_$$_WeldClientProxy.java)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at net.sf.webdav.methods.DoPut.execute(DoPut.java:101)
[webdav-servlet-2.0.1.jar:]
at net.sf.webdav.WebDavServletBean.service(WebDavServletBean.java:129)
[webdav-servlet-2.0.1.jar:]
at
org.drools.guvnor.server.files.WebdavServlet.service(WebdavServlet.java:73)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
[solder-impl-3.1.1.Final.jar:3.1.1.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)
[solder-impl-3.1.1.Final.jar:3.1.1.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
[jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
[jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
[jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_35]
13 years, 5 months
Drools 5.4.0.FINAL and OSGI. Unable to instantiate service for Class 'org.drools.concurrent.ExecutorProvider'
by Per Sterner
Hello,
I have been using Drools 5.3.0.FINAL until now. I am upgrading my
running system with 5.4.0.FINAL. The bundles are all runing. I got some
error messages and tried to reduce the problem and created a simple bundle.
The code only inserts facts and after 20 facts I get the following error:
[ERROR] [System] - Exception in thread "Thread-8"
java.lang.ExceptionInInitializerError
[ERROR] [System] - at
org.drools.concurrent.ExecutorProviderFactory.getExecutorProvider(ExecutorProviderFactory.java:12)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint$ExecutorHolder.<clinit>(MvelConstraint.java:208)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint.jitEvaluator(MvelConstraint.java:199)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:164)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:124)
[ERROR] [System] - at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
[ERROR] [System] - at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
[ERROR] [System] - at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
[ERROR] [System] - at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:337)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:123)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:53)
[ERROR] [System] - at
de.pelle7.drools.test1.simpletest.SimpleTestDrools$1.run(SimpleTestDrools.java:74)
[ERROR] [System] - Caused by: java.lang.IllegalArgumentException: Unable
to instantiate service for Class 'org.drools.concurrent.ExecutorProvider'
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:162)
[ERROR] [System] - at
org.drools.concurrent.ExecutorProviderFactory$ExecutorProviderHolder.<clinit>(ExecutorProviderFactory.java:8)
[ERROR] [System] - ... 14 more
[ERROR] [System] - Caused by: java.lang.IllegalArgumentException: Unable
to instantiate 'org.drools.concurrent.ExecutorProviderImpl'
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.newInstance(ServiceRegistryImpl.java:213)
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.call(ServiceRegistryImpl.java:205)
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:160)
[ERROR] [System] - ... 15 more
[ERROR] [System] - Caused by: java.lang.ClassNotFoundException:
org.drools.concurrent.ExecutorProviderImpl
[ERROR] [System] - at
org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
[ERROR] [System] - at
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
[ERROR] [System] - at
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
[ERROR] [System] - at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
[ERROR] [System] - at java.lang.ClassLoader.loadClass(Unknown Source)
[ERROR] [System] - at java.lang.Class.forName0(Native Method)
[ERROR] [System] - at java.lang.Class.forName(Unknown Source)
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.newInstance(ServiceRegistryImpl.java:210)
[ERROR] [System] - ... 17 more
The Rule file:
package de.pelle7.drools.test1.users.rules.impl;
import de.pelle7.drools.test1.simpletest.*;
import org.jbpm.ruleflow.instance.*;
rule "Funny Rule #1"
dialect "java"
when
$testObject : TestObjectA( value == 0 ) from entry-point "my_entry"
then
System.err.println("New Item: " + $testObject);
retract($testObject);
end
If I change the line
--> $testObject : TestObjectA( value == 0 ) from entry-point "my_entry"
to
--> $testObject : TestObjectA( ) from entry-point "my_entry"
there is no problem.
In the java code i initialize a Drools Session programatically and add
one rule file:
package de.pelle7.drools.test1.simpletest;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactoryService;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderConfiguration;
import org.drools.builder.KnowledgeBuilderFactoryService;
import org.drools.builder.ResourceType;
import org.drools.definition.KnowledgePackage;
import org.drools.io.ResourceFactory;
import org.drools.io.ResourceFactoryService;
import org.drools.runtime.StatefulKnowledgeSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SimpleTestDrools {
public static final String DEFAULT_ENTRY = "my_entry";
private static Logger logger =
LoggerFactory.getLogger(SimpleTestDrools.class);
private StatefulKnowledgeSession droolsSession;
private KnowledgeBuilderFactoryService
droolsKnowledgeBuilderFactoryService;
private ResourceFactoryService droolsResourceFactoryService;
private KnowledgeBaseFactoryService droolsKnowledgeBaseFactoryService;
public static Logger getLogger() {
return logger;
}
public StatefulKnowledgeSession getDroolsSession() {
return droolsSession;
}
public void start() {
KnowledgeBuilder kbuilder =
getDroolsKnowledgeBuilderFactoryService().newKnowledgeBuilder();
KnowledgeBaseConfiguration config =
getDroolsKnowledgeBaseFactoryService().newKnowledgeBaseConfiguration();
//config.setOption( MBeansOption.ENABLED );
KnowledgeBase knowledgeBase =
getDroolsKnowledgeBaseFactoryService().newKnowledgeBase(config);
droolsSession = knowledgeBase.newStatefulKnowledgeSession();
LinkedList<URI> resourcesList = new LinkedList<URI>();
try {
resourcesList.add(
getClass().getResource("MyDrools.drl").toURI() );
addResources(droolsSession,
getDroolsKnowledgeBuilderFactoryService(),
resourcesList);
} catch (Exception e) {
e.printStackTrace();
}
new Thread() {
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
System.out.println("Go 1");
for (int i = 0; i< 1000; i++) {
System.out.println(i);
getDroolsSession().getWorkingMemoryEntryPoint(DEFAULT_ENTRY).insert(new
TestObjectA());
getDroolsSession().fireAllRules();
try {
Thread.sleep(1);
} catch (InterruptedException e) {
}
}
System.out.println("Go 2");
};
}.start();
System.err.println("wait");
//getDroolsSession().fireUntilHalt();
}
public static void addResources(
StatefulKnowledgeSession droolsSession,
KnowledgeBuilderFactoryService
droolsKnowledgeBuilderFactoryService,
List<URI> resources
) throws MyDroolsException {
getLogger().debug("Drools: Register: " + resources);
MyDroolsException exception = null;
KnowledgeBuilderConfiguration lnowledgeBuilderConfiguration =
droolsKnowledgeBuilderFactoryService.newKnowledgeBuilderConfiguration();
HashSet<URI> defects = new HashSet<URI>();
KnowledgeBuilder kbuilder = null;
while (true) {
URI uriError = null;
kbuilder =
droolsKnowledgeBuilderFactoryService.newKnowledgeBuilder(lnowledgeBuilderConfiguration);
try {
Iterator<URI> it = resources.iterator();
while (it.hasNext()) {
URI uri = (URI) it.next();
if (defects.contains(uri)) {
continue;
}
StringBuilder builder = new StringBuilder();
builder.append("Adding drools file '" +
uri.toString() + "'");
URL url = uri.toURL();
InputStream iStream = url.openStream();
ResourceType resourceType;
String path = uri.getPath().toLowerCase();
resourceType =
ResourceType.determineResourceType(path);
getLogger().debug(builder.toString());
kbuilder.add(ResourceFactory.newInputStreamResource(iStream), resourceType);
// Check the builder for errors
if (kbuilder.hasErrors()) {
uriError = uri;
//getLogger().error(kbuilder.getErrors().toString());
String errorMessage =
kbuilder.getErrors().toString();
kbuilder.getErrors().clear();
throw new MyDroolsException(errorMessage);
}
try {
iStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Throwable e) {
if (uriError != null) {
defects.add(uriError);
}
String msg = "Error in Resource '" + uriError + "'";
getLogger().error(msg);
e.printStackTrace();
if (exception != null) {
exception = new MyDroolsException(msg, exception);
} else {
exception = new MyDroolsException(msg);
}
exception = new MyDroolsException(e.getMessage(),
exception);
continue;
}
// All done!
break;
}
final Collection<KnowledgePackage> pkgs =
kbuilder.getKnowledgePackages();
droolsSession.getKnowledgeBase().addKnowledgePackages(pkgs);
if (exception != null) {
throw new MyDroolsException("Error while adding
resources!", exception);
}
}
public KnowledgeBuilderFactoryService
getDroolsKnowledgeBuilderFactoryService() {
return droolsKnowledgeBuilderFactoryService;
}
public void setDroolsKnowledgeBuilderFactoryService(
KnowledgeBuilderFactoryService
droolsKnowledgeBuilderFactoryService) {
this.droolsKnowledgeBuilderFactoryService =
droolsKnowledgeBuilderFactoryService;
}
public ResourceFactoryService getDroolsResourceFactoryService() {
return droolsResourceFactoryService;
}
public void setDroolsResourceFactoryService(
ResourceFactoryService droolsResourceFactoryService) {
this.droolsResourceFactoryService = droolsResourceFactoryService;
}
public KnowledgeBaseFactoryService
getDroolsKnowledgeBaseFactoryService() {
return droolsKnowledgeBaseFactoryService;
}
public void setDroolsKnowledgeBaseFactoryService(
KnowledgeBaseFactoryService
droolsKnowledgeBaseFactoryService) {
this.droolsKnowledgeBaseFactoryService =
droolsKnowledgeBaseFactoryService;
}
}
Some of the bundles in my runtime are:
39 ACTIVE org.drools.core_5.4.0.Final
66 ACTIVE org.drools.compiler_5.4.0.Final
78 ACTIVE org.drools.templates_5.4.0.Final
94 ACTIVE org.drools.internalapi_5.4.0.Final
136 ACTIVE org.drools.decisiontables_5.4.0.Final
189 ACTIVE org.drools.api_5.4.0.Final
191 ACTIVE org.mvel2_2.1.0.drools16
6 ACTIVE org.jbpm.flow.core_5.3.0.Final
13 ACTIVE org.jbpm.bpmn2_5.3.0.Final
71 ACTIVE org.jbpm.flow.builder_5.3.0.Final
142 ACTIVE org.jbpm.flow-persistence-jpa_5.3.0.FINAL
regards,
Per Sterner
13 years, 5 months
Implementation example
by André Fróes
Hello everyone. Is there anywhere I can get a full example of simplest
planner implementation, such as nqueens? (apart of example folder)
Thanks
13 years, 5 months
Drools Expert does not sort integers correctly
by John Smith
I am new to Drools and am trying to get the sample program to work. This
sample is given in the drools documentation
http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_....
This drool rule is expected to sort integers. I just changed the numbers
from what are given in the sample and they do not get sorted as expected.
Tried using drools version 5.5.0, 5.5.1 and the master 6.0.0, but got the
same wrong results.
Following is the main code:
package com.sample;
public class Example2 {
public static void main(String[] args) throws Exception {
Number[] numbers = new Number[] { wrap(5), wrap(6), wrap(4),
wrap(1), wrap(2) };
new RuleRunner().runRules(new String[] { "Example3.drl" }, numbers);
}
private static Integer wrap(int i) {
return new Integer(i);
}
}
The RuleRunner class is the same as given in the example and I do not think
I should give that here, since it will clutter the question. It simply
creates the KnowledgeBase, stateful session, inserts the facts as given in
the 'numbers' array above and then calls fireAllRules method on the session.
The rule file (Example3.drl) is:
rule "Rule 04"
dialect "mvel"
when
$number : Number()
not Number(intValue < $number.intValue)
then
System.out.println("Number found with value: " + $number.intValue());
retract($number);
end
The output I get is as follows:
Loading file: Example3.drl
Inserting fact: 5
Inserting fact: 6
Inserting fact: 4
Inserting fact: 1
Inserting fact: 2
Number found with value: 1
Number found with value: 4
Number found with value: 2
Number found with value: 5
Number found with value: 6
Not the correct expected ascending sorted order.
What might I be doing wrong? I cannot imagine that the drools rule engine
would be broken at this basic level.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Expert-does-not-sort-integers-co...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months
Re: [rules-users] [BAD Bug] incorrect evaluation of LHS using Integer/Number intValue
by Wolfgang Laun
[Sorry - the previous email "escaped" before I was complete.]
This is a self-contained DRL demonstrating the erroneous handling of
a condition involving Integer.intValue (same: Number.intValue), not
and retract, which is meant to sort the integers. This fails with 5.5.0,
but works correctly with 5.4.0 and previous versions.
rule init
salience 9999
when
then
insert( Integer.valueOf( 10 ) );
insert( Integer.valueOf( 50 ) );
insert( Integer.valueOf( 60 ) );
insert( Integer.valueOf( 40 ) );
insert( Integer.valueOf( 20 ) );
end
rule "Rule 04"
when
$number : Integer( $i: intValue )
not Integer(intValue < $i)
then
System.out.println("Number found with value: " + $number.intValue());
retract($number);
end
>
> On 17/01/2013, Wolfgang Laun <wolfgang.laun(a)gmail.com> wrote:
>> This BAD bug was introduced on the way from 5.4.0 to 5.5.0 (and seems
>> to have sneaked into 6.0.0 as well).
>>
>> Only 5.4.0 and predecessors work as expected.
>>
>> Damage control? How far can 5.5.0 be trusted?
>>
>>
>> On 17/01/2013, John Smith <ffirstt.llastt(a)gmail.com> wrote:
>>> I am new to Drools and am trying to get the sample program to work. This
>>> sample is given in the drools documentation
>>> http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_....
>>> This drool rule is expected to sort integers. I just changed the numbers
>>> from what are given in the sample and they do not get sorted as
>>> expected.
>>> Tried using drools version 5.5.0, 5.5.1 and the master 6.0.0, but got
>>> the
>>> same wrong results.
>>>
>>> Following is the main code:
>>> package com.sample;
>>>
>>> public class Example2 {
>>> public static void main(String[] args) throws Exception {
>>> Number[] numbers = new Number[] { wrap(5), wrap(6), wrap(4),
>>> wrap(1), wrap(2) };
>>> new RuleRunner().runRules(new String[] { "Example3.drl" },
>>> numbers);
>>> }
>>>
>>> private static Integer wrap(int i) {
>>> return new Integer(i);
>>> }
>>> }
>>>
>>> The RuleRunner class is the same as given in the example and I do not
>>> think
>>> I should give that here, since it will clutter the question. It simply
>>> creates the KnowledgeBase, stateful session, inserts the facts as given
>>> in
>>> the 'numbers' array above and then calls fireAllRules method on the
>>> session.
>>>
>>> The rule file (Example3.drl) is:
>>>
>>>
>>> rule "Rule 04"
>>> dialect "mvel"
>>> when
>>> $number : Number()
>>> not Number(intValue < $number.intValue)
>>> then
>>> System.out.println("Number found with value: " +
>>> $number.intValue());
>>> retract($number);
>>> end
>>>
>>>
>>> The output I get is as follows:
>>> Loading file: Example3.drl
>>> Inserting fact: 5
>>> Inserting fact: 6
>>> Inserting fact: 4
>>> Inserting fact: 1
>>> Inserting fact: 2
>>> Number found with value: 1
>>> Number found with value: 4
>>> Number found with value: 2
>>> Number found with value: 5
>>> Number found with value: 6
>>>
>>> Not the correct expected ascending sorted order.
>>>
>>> What might I be doing wrong? I cannot imagine that the drools rule
>>> engine
>>> would be broken at this basic level.
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://drools.46999.n3.nabble.com/Drools-Expert-does-not-sort-integers-co...
>>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>
>
13 years, 5 months
[BAD
by Wolfgang Laun
rule init
salience 9999
when
then
insert( Integer.valueOf( 10 ) );
insert( Integer.valueOf( 50 ) );
insert( Integer.valueOf( 60 ) );
insert( Integer.valueOf( 40 ) );
insert( Integer.valueOf( 20 ) );
end
rule "Rule 04"
## dialect "mvel"
when
$number : Integer( $i: intValue )
not Integer(intValue < $i)
then
System.out.println("Number found with value: " + $number.intValue());
retract($number);
end
On 17/01/2013, Wolfgang Laun <wolfgang.laun(a)gmail.com> wrote:
> This BAD bug was introduced on the way from 5.4.0 to 5.5.0 (and seems
> to have sneaked into 6.0.0 as well).
>
> Only 5.4.0 and predecessors work as expected.
>
> Damage control? How far can 5.5.0 be trusted?
>
>
> On 17/01/2013, John Smith <ffirstt.llastt(a)gmail.com> wrote:
>> I am new to Drools and am trying to get the sample program to work. This
>> sample is given in the drools documentation
>> http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_....
>> This drool rule is expected to sort integers. I just changed the numbers
>> from what are given in the sample and they do not get sorted as expected.
>> Tried using drools version 5.5.0, 5.5.1 and the master 6.0.0, but got the
>> same wrong results.
>>
>> Following is the main code:
>> package com.sample;
>>
>> public class Example2 {
>> public static void main(String[] args) throws Exception {
>> Number[] numbers = new Number[] { wrap(5), wrap(6), wrap(4),
>> wrap(1), wrap(2) };
>> new RuleRunner().runRules(new String[] { "Example3.drl" },
>> numbers);
>> }
>>
>> private static Integer wrap(int i) {
>> return new Integer(i);
>> }
>> }
>>
>> The RuleRunner class is the same as given in the example and I do not
>> think
>> I should give that here, since it will clutter the question. It simply
>> creates the KnowledgeBase, stateful session, inserts the facts as given
>> in
>> the 'numbers' array above and then calls fireAllRules method on the
>> session.
>>
>> The rule file (Example3.drl) is:
>>
>>
>> rule "Rule 04"
>> dialect "mvel"
>> when
>> $number : Number()
>> not Number(intValue < $number.intValue)
>> then
>> System.out.println("Number found with value: " +
>> $number.intValue());
>> retract($number);
>> end
>>
>>
>> The output I get is as follows:
>> Loading file: Example3.drl
>> Inserting fact: 5
>> Inserting fact: 6
>> Inserting fact: 4
>> Inserting fact: 1
>> Inserting fact: 2
>> Number found with value: 1
>> Number found with value: 4
>> Number found with value: 2
>> Number found with value: 5
>> Number found with value: 6
>>
>> Not the correct expected ascending sorted order.
>>
>> What might I be doing wrong? I cannot imagine that the drools rule engine
>> would be broken at this basic level.
>>
>>
>>
>> --
>> View this message in context:
>> http://drools.46999.n3.nabble.com/Drools-Expert-does-not-sort-integers-co...
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
13 years, 5 months
Need explanation for activation-group attributes.
by suddeb
Hi,
Suppose I have the below rules:
*Rule "A"
salience 100
When
then
end
Rule "B"
activation-group "AC1"
salience 100
when
then
end
Rule "C"
activation-group "AC2"
salience 100
when
then
end
Rule "D"
activation-group "AC1"
activation-group "AC2"
salience 90
when
then
end*//
Now the scenarios are:
*If B, then no D*, which is happening correctly
*If C, then no D*, which is happening correctly
*If A, then D*, /This is what is not happening./
Could you please let me know how can I achieve this?
If more information required, please let me know. Thanks.
Regards,
Sudipta Deb.
--
View this message in context: http://drools.46999.n3.nabble.com/Need-explanation-for-activation-group-a...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months
rule validates in guvnor but errors when running
by kurrent93
Hi
I'm trying to understand what is wrong with this rule. It validates in
guvnor, but when running it throws an error.
I am trying to write a rule that will fire if there have been less than ten
trades in ten minutes.
This is the rule:
1. | rule "Trade Count"
2. | dialect "mvel"
3. | when
4. | Number( trades : intValue < 10 )
5. | from accumulate(
6. | e: TradeOrder( )
7. | over window:size(10m),
8. | count(e) )
9. | then
10. | TradeOrder silverTrade = new TradeOrder();
11. | silverTrade.setMt4username( "4002642" );
12. | silverTrade.setOperation( "OP_BUY" );
13. | silverTrade.setStatus( OrderStatus.OPENING );
14. | silverTrade.setSymbol( "SILVER" );
15. | silverTrade.setVolume( 1 );
16. | silverTrade.setOrderLots( 2 );
17. | insert( silverTrade );
18. |
19. |
20. | modifiedOrderList.add(silverTrade);
21. | end
What I assume to be the relevant portion of the stack trace is here:
Caused by: java.lang.NoSuchMethodError:
org.mvel2.compiler.CompiledExpression.getParserConfiguration()Lorg/mvel2/ParserConfiguration;
at
org.drools.rule.constraint.MvelConstraint.createMvelConditionEvaluator(MvelConstraint.java:207)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:190)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:157)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:651)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.reteoo.ReteooWorkingMemory$EvaluateResultConstraints.execute(ReteooWorkingMemory.java:590)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.common.PropagationContextImpl.evaluateActionQueue(PropagationContextImpl.java:350)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:355)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.switchyard.component.rules.exchange.drools.DroolsRulesExchangeHandler.handleMessage(DroolsRulesExchangeHandler.java:280)
[switchyard-component-rules-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
at
org.switchyard.bus.camel.ProviderProcessor.process(CamelExchangeBus.java:216)
at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
[camel-core-2.10.0.jar:2.10.0]
... 153 more
--
View this message in context: http://drools.46999.n3.nabble.com/rule-validates-in-guvnor-but-errors-whe...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months