Could not parse knowledge when using 'not contains' in a quote leading a '!'
by Miles Wen
hi all,
This code could not be parsed correctly:
rule "out"
when
Msg(!(set not contains "test"))
then
end
I tried a few simple situations and found that when using 'not contains'
operator in a '!' leading quote triggers this problem. If no '!' prefixing
the quote,the program works like a charm...
Is this a bug? I wish that I posted in the right forum(or I would go to
submit an issue?)..
The example above seemed so stupid(you can use a 'contains' operator
instead), but this is the simplest toy example.And this problem would be
looked more important if you want to write some logic like this:
Msg(!(set not contains "test" || !bool && string == "hello"))
So...
Is there anyone who also encountered this problem? I'm using drools 5.3.0
final.
Any help would appreciated.
Thanks!
--
Regards.
Miles. Wen
14 years, 3 months
Extracting management information from the content of the rules
by Henrique Lira
Hi,
I'm doing an evaluation of Guvnor tool, and one of the requirements that we
wish to be met is the ability to extract management reports from the content
of the rules. Let me explain better: assuming I have several rules that
define discounts for products depending on their characteristics, how can I
get, for example, which products have a discount of X%? I tried using the
search function of the Guvnor, but I found it very simple to more managerial
information like this? Is there any other functionality to generate more
complex queries?
Thanks in advance,
Henrique
--
View this message in context: http://drools.46999.n3.nabble.com/Extracting-management-information-from-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
MVEL optimization?!?
by ronalbury
I'm not sure how to explain this, other than it appears that MVEL is trying
to optimize the When conditions in my rules.
I have a utility class, Test, with a number of methods on it (including null
protected versions of Drools "in" and "matches"). Note that the valueInList
method can return null (e.g. if the product code is null), and the
getAgeAsInt method can also return null (if the age is null). I don't like
having to test if the result of the method is true, but I kept running into
null pointer errors in the Drools expression evaluation code and had to
adopt this convention.
Here are two example rules (one in Java dialect and one in MVEL dialect). I
realize that a list of one is a degenerate case for using 'inList', but it
should still work.
rule "Term 15Plus Max Age - Washington"
dialect "java"
when
$ea : EasyApp(
Test.valueInList($ea.getEaProductCode(), "L15P")==true
&& Test.valueInList($ea.getEaIssueState(), "WA")==true
&& $ea.getPriIns_xmPerson().getAgeAsInt() > 65
)
then
$ea.addError(drools.getRule().getName());
end
rule "Term 20 Max Age - New Jersey"
when
$ea : EasyApp(
Test.valueInList(eaProductCode, "L20")==true
&& Test.valueInList(eaIssueState, "NJ")==true
&& priIns_xmPerson.ageAsInt > 64
)
then
$ea.addError(drools.getRule().getName());
end
I have approximately 30 different rules similar to those above. When I have
the rules written in MVEL, it appears to be only be evaluating one rule per
EasyApp injection (I have a log message when ever valueInList is called),
and I get bogus results. However, when I shift to java dialect then it
appears that the methods are called for each rule I have defined (as I would
have expected).
Can anyone tell me if I am doing something wrong, and explain why Drools is
behaving as it is?
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/MVEL-optimization-tp3632072p3632072.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
urlResource, applyChangeset and authentication error
by kachaps4u
/Hello there, I was trying to do write a simple rule inside BRMS: When a car
model year is older than 1989, then destroy the car. Package was validated
and created the snapshot and copied the uri. Then I created a Drools Project
and was trying to access those resources through uri but I am not able to go
forward. Its showing 401 exception at the line I specified the uri in the
code, see below:/
package pop.blah.test;
import org.drools.KnowledgeBase;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.definition.type.FactType;
public class CarApp {
public static void main(String[] args) {
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(
"myAgent1" );
kagent.applyChangeSet(
ResourceFactory.newUrlResource("http://localhost:8080/jboss-brms/org.drools.guvnor.Guvnor/package/pop.bla..."));
KnowledgeBase kbase = kagent.getKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ResourceFactory.getResourceChangeScannerService().start();
try {
FactType carType = kbase.getFactType( "pop.blah.test", "Car" );
Object bmw = carType.newInstance();
carType.set( bmw,"name","My Car" );
carType.set( bmw,"make","BMW-x5" );
carType.set( bmw,"year", 1977);
ksession.insert( bmw );
ksession.fireAllRules();
boolean dest = (Boolean) carType.get( bmw, "destroy" );
if (dest==true) {
System.out.println("I am gona destroy that car!");
}
else {
System.out.println("I am happy with my car!");
}
}
catch (Exception E) {
E.printStackTrace();
}
finally {
ksession.dispose();
}
}
}
/and here is my Error:/
[2012:01:03 08:01:578:info] ResourceChangeNotification created
[2012:01:03 08:01:578:info] ResourceChangeScanner reconfigured with
interval=60
[2012:01:03 08:01:578:info] ResourceChangeScanner created with default
interval=60
[2012:01:03 08:01:578:debug] ResourceChangeNotification monitor added
monitor=org.drools.io.impl.ResourceChangeScannerImpl@1bd7848
[2012:01:03 08:01:593:debug] KnowledgeAgent building resource map
[2012:01:03 08:01:593:info] KnowledegAgent has started listening for
ChangeSet notifications
[2012:01:03 08:01:593:info] KnowledgeAgent created, with configuration:
monitorChangeSetEvents=true scanResources=true scanDirectories=true
newInstance=true
[2012:01:03 08:01:859:exception]
java.lang.RuntimeException: Unable to parse ChangeSet
at
org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:393)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168)
at pop.blah.test.CarApp.main(CarApp.java:16)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for
URL:
http://localhost:8080/jboss-brms/org.drools.guvnor.Guvnor/package/pop.bla...
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at org.drools.io.impl.UrlResource.grabStream(UrlResource.java:210)
at org.drools.io.impl.UrlResource.getInputStream(UrlResource.java:146)
at org.drools.io.impl.UrlResource.getReader(UrlResource.java:214)
at
org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:391)
... 2 more
[2012:01:03 08:01:859:exception]
java.lang.RuntimeException: Unable to parse ChangeSet
at
org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:397)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168)
at pop.blah.test.CarApp.main(CarApp.java:16)
[2012:01:03 08:01:859:info] KnowledgeAgent applying ChangeSet
Exception in thread "main" java.lang.NullPointerException
at
org.drools.agent.impl.KnowledgeAgentImpl.processChangeSet(KnowledgeAgentImpl.java:215)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:183)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168)
at pop.blah.test.CarApp.main(CarApp.java:16)
Please help me.
--
View this message in context: http://drools.46999.n3.nabble.com/urlResource-applyChangeset-and-authenti...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Using hashmap in guided decision table in Guvnor
by ankitmasrani
Hi,
I am new to Drools and Guvnor and I have the following query:
1. I have uploaded a pojo model jar which has a class A containing a
hashmap<String, String> attr1.
2. Then, I created a new rule- Guided decision table.
3. And i want to define a rule lets me select a key of the hashmap defined
using the drop-down pop-up and check the corresponding value in the second
column. Then perform an action.
Example: check Key= "Name" and value="Abc". then set an output string- "Name
ok" in action.
Please provide any suggestions.
Thank You
Ankit
--
View this message in context: http://drools.46999.n3.nabble.com/Using-hashmap-in-guided-decision-table-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Scheduling events with varying durations - corrupted score
by nickels
Hi, I am relatively new to the Drools space and I am working on a project
utilizing Drools planner (5.4.0.Beta1) for use in scheduling events. I have
a set of events of varying duration and a set of possible venues for the
events with varying availability. I read some previous comments relating to
similar problems and it seems that the best approach is to create time slots
for each of the venues and then assign the events to time slots based on the
availability similar to how the CloudBalancing example assigns tasks to
machines. The difference is that I need to know the actual start/end time of
each event for a given time slot during planning in order to make sure that
an event is not scheduled at the same time as another event from a previous
run of the solver for another schedule.
Here is how the problem is modeled (simplified to the important parts):
- Event (Planning entity) {venueTimeSlot, startDateTime, endDateTime,
duration}
- VenueTimeSlot (Planning Variable) {Venue, startDateTime, endDateTime,
duration}
- PreviousEvent (Constraint) {Venue, startDateTime, endDateTime}
And the pertinent rules:
// Rule that makes sure the time slot can fit the number of events scheduled
in it.
rule "minimalDurationTotal"
when
$venueTimeSlot : VenueTimeSlot($duration : duration)
$minimalDurationTotal : Number(intValue > $duration) from
accumulate(
Event(venueTimeSlot == $venueTimeSlot, $minimalDuration :
totalDuration),
sum($minimalDuration)
)
then
insertLogical(new IntConstraintOccurrence("minimalDurationTotal",
ConstraintType.NEGATIVE_HARD, $minimalDurationTotal.intValue() - $duration,
$venueTimeSlot));
end
// Rule that checks for any previous events that were already scheduled for
this venue
rule "previousEventConflict"
when
$e : Event($venue:venueTimeSlot.venue)
exists PreviousEvent(venue == $venue, startDateTime <= $e.endDateTime,
$e.startDateTime <= endDateTime)
then
insertLogical(new IntConstraintOccurrence("previousEventConflict",
ConstraintType.NEGATIVE_HARD, 1, $e));
end
// Rule that calculates the start/end date time for the event based on the
events in the time slot
rule "updateEventDateTime"
salience 10
when
$e : Event()
$eventList : LinkedList() from collect(
Event(venueTimeSlot == $e.venueTimeSlot)
)
then
$e.updateDateFromEventList($eventList); --> Loops through the events and
sets the startDateTime
end
Ok, so this rule that updates the date time is where I am not sure about, I
get an error about score corruption during the construction heuristic phase.
java.lang.IllegalStateException: Score corruption: the presumedScore
(0hard/0soft) is not the uncorruptedScore (-1hard/0soft):
The workingMemory has 0 ConstraintOccurrence(s) lacking:
previousEventConflict/NEGATIVE_HARD:[Event 75]=1
Check the score rules who created those ConstraintOccurrences. Verify that
each ConstraintOccurrence's causes and weight is correct.
Problem is I don't know what order the events were "added to the time slot"
so every time I call the updateDateFromEventList method the list of events
may be in a different order and therefore change the actual time they occur.
How is it that I set the position of the event when the time slot is set by
the construction heuristic? Or is there a better way altogether to model
this?
Any insight you can provide would be appreciated.
Best Regards,
Nick
--
View this message in context: http://drools.46999.n3.nabble.com/Scheduling-events-with-varying-duration...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Drools HA
by gboro54
Hi everyone. We are currently evaluating drools as a potential solution of a
high throughput billing system. As is such we are planning to have messages
read from a queue from 2 or more nodes. One thing we are trying to figure
out is best way to share state in drools. The situation we are facing is as
follow:
-Node 1 reads message 1
-Node 2 reads message 2
-Node1 begins execution of rules on message 1 with context information
-Node2 begins execution of rules on message 2 with context information
-Node 1 updates the context information such that rules being executed by
node2 should be reevaluated(i.e node 1 in the rules session executed an
update on the context object)
What is the best way to handle this situation?
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-HA-tp3619496p3619496.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months