Find out order of insert in RHS
by Sandjaja, Dominik
Hi everybody,
short: is there a way to have an automatic counter for the RHS of a rule when inserting several objects in one rule?
Long:
I use drools with a DSL to insert items for a frontend dropdown box. The generated rule is e.g. like the following one:
rule "testRule_H"
dialect "mvel"
when
SomePartOfMyModel( someField == "H" )
then
DropDownItem fact1 = new DropDownItem(); fact1.setLabel( "My Label 1" ); fact1.setValue( "B" );
insert (fact1);
DropDownItem fact1 = new DropDownItem(); fact1.setLabel( "My Label 2" ); fact1.setValue( "A" );
insert (fact1);
This works nicely and I get all the items. The problem I have is with the sorting. Users use Guvnor to edit the available items for the dropdown box, so they add and remove items from the RHS. Since I retrieve those objects from the knowledge base in my java code like this:
Collection<FactHandle> handles = statefulKnowledgeSession.getFactHandles(new ClassObjectFilter(DropDownItem.class));
for (FactHandle handle : handles) {
DropDownItem selectItem = (DropDownItem) statefulKnowledgeSession.getObject(handle);
...
I think I cannot be sure about the order the objects are retrieved (it's a collection, no guaranteed sorting!). So, I sort the DropDownItems alphabetically by their value.
My question now is, as stated above: How can I implement a counter which I can use in the facts being inserted to keep my inserted facts (DropDownItems) in the same order as they are inserted?
Thanks in advance
Dominik
…………………………………………………………………
mit freundlichen Grüßen / kind regards
Dominik Sandjaja
Fon: +49 (0) 203 60878 183
Fax: +49 (0) 203 60878 222
e-mail: dominik.sandjaja(a)it-motive.de
it-motive AG
Zum Walkmüller 10-12
47269 Duisburg
info(a)it-motive.de
http://www.it-motive.de
……………………………………………………………………
Vorsitzender des Aufsichtsrats: Dipl.-Ing. Klaus Straub
Vorstand: Horst-Dieter Deelmann (Vors.), Matthias Heming, Christoph Tim Klose
HRB 9207, Amtsgericht Duisburg
11 years, 9 months
Question on Model in Guvnor
by IPatel
I have 2 sets of model created in Guvnor: Model1 and Model2.
In Model1: I have LoanApplication and Amount Facts each containing some
variables. I imported this via Jar from Java
In Model2: I have Person and BankAccount Facts each containing some
variables. I created this facts using Guvnor and Added Fields to it.
I have a simple rule
rule "Approve the appliocation for a Person whoes Age is ngreather than 18"
dialect "mvel"
when
Person ( age > 18)
then
LoanApplication fact3 = new LoanApplication( );
fact3.setApproved(true);
insert( fact3 );
end
I am testing this rule using "New Test Scenario" option on Guvnor. Test case
does not pass even though i have valid input. Is this happening because i
have one fact created in Model1 and another fact created in Model2?
Thank you
--
View this message in context: http://drools.46999.n3.nabble.com/Question-on-Model-in-Guvnor-tp4022140.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
ambition = ThreadPoolExecutor delegating to KBPool(s) & KSPools(s)
by Cotton, Ben
Let's say that a start-of-day, every day, we generate a giant 2,000+ rule .DRL, that we then use to construct into a single run-time KnowledgeBase reference. We then construct a single run-time KnowledgeSession reference (also at start of day). Throughout the day, all day, facts "arrive" asynchronously into our expert system. When a fact "arrives", we synchronously place the fact onto our single KS and call .fireAllRules(), which in turn synchronously outputs answers that satisfy our "what's the next step?" decision requirements.
We have this working very well, but we have the ambition to achieve more.
We want to attempt to scale this solution to accommodate the high-frequency simultaneous "arrival" of many facts. We have at our disposal a 24xCPU 128 gb Linux-based compute resource (nice, right?) ... so, ideally, we have the ambition to potentially accommodate the simultaneous arrival of 24 facts into our expert system.
Assuming that all of our 2,000+ rules are completely isolated (i.e. no rule i ever depends on any rule j, for all i,j) we want to consider building (at start of day) a KSPool (size 24) , KBPool (size 24), and a ThreadPoolExecutor (size 24, backed by BlockingQueue). As facts arrive throughout the day, those that arrive simultaneously are Queue'd to the TPE, that then delegates the fact's need for service to a task Runnable, which in turn calls a KSPool[i].fireAllRules() (with isolation to KBPool[i]). In such a scheme, we would potentially be able to render decisions concurrently when facts arrive simultaneously ( capacity 24).
Is this design ambition common w/in current DROOLs use cases? Does the current (or future) DROOLS offering include any in-place capability to Pool KS or Pool KB? If not, are there any potential DROOLs concerns or "gotchas" wrt to our pursuing this ambition (in a "let's build this now!" prototype)?
As always, tremendous thanks to all in this community forum.
Ben D Cotton III
Morgan Stanley & Co.
OTC Derivatives Clearing Technology
1221 AOTA Rockefeller Ctr - Flr 27
New York, NY 10020
(212)762.9094
ben.cotton(a)ms.com<mailto:ben.cotton@ms.com>
________________________________
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.
11 years, 9 months
Can someone help me understand a java rule?
by Aijin Nakanishi
I'm trying to understand when is proccess assigned to a computer by that
java example.
----------------
public HardAndSoftScore calculateScore(CloudBalance cloudBalance) {
int hardScore = 0;
int softScore = 0;
for (CloudComputer computer : cloudBalance.getComputerList()) {
int cpuPowerUsage = 0;
int memoryUsage = 0;
int networkBandwidthUsage = 0;
boolean used = false;
// Calculate usage
for (CloudProcess process : cloudBalance.getProcessList()) {
if (computer.equals(process.getComputer())) {
cpuPowerUsage += process.getRequiredCpuPower();
memoryUsage += process.getRequiredMemory();
networkBandwidthUsage +=
process.getRequiredNetworkBandwidth();
used = true;
}
}
// Hard constraints
int cpuPowerAvailable = computer.getCpuPower() - cpuPowerUsage;
if (cpuPowerAvailable < 0) {
hardScore += cpuPowerAvailable;
}
int memoryAvailable = computer.getMemory() - memoryUsage;
if (memoryAvailable < 0) {
hardScore += memoryAvailable;
}
int networkBandwidthAvailable = computer.getNetworkBandwidth()
- networkBandwidthUsage;
if (networkBandwidthAvailable < 0) {
hardScore += networkBandwidthAvailable;
}
// Soft constraints
if (used) {
softScore -= computer.getCost();
}
}
return DefaultHardAndSoftScore.valueOf(hardScore, softScore);
}
--------------------
I didn't understand how the cloudcomputers received it
11 years, 9 months
Hard constraint on selecting a skill
by André Fróes
Hello!
I'm still not getting good with drools rules, i'm trying several examples
and basic ones. Some i did without any problem and understood plenty well,
but when I try to make an approach to what i'm aiming, I'm not able to.
Right now I'm trying to compose this:
When
there's an workorder with skill
and there's and engineer with the skill and capable of doing that
workorder
then
the engineer should do it
So i tried something like this:
rule "assignSkillWOToSkilledEngineer"
when
$wo : WorkOrder( $requiredSkill : requiredSkill )
$engineer : Engineer(skill == $requiredSkill)
then
insertLogical(new IntConstraintOccurrence("assignSkillWOToSkilledEngineer",
ConstraintType.NEGATIVE_HARD,
1, $engineer));
end
i get no exceptions, but the sort is not working properly
11 years, 9 months
Guvnor 5.5 - Empty Inbox
by droolist
Here is my setup:
Guvnor 5.5.0 Final
Tomcat 7
Oracle 11g DB for repository
Jackrabbit clustering enabled
Custom Authenticator
Fine grained authorization enabled
Accessing Guvnor on Firefox
I created 2 users and granted "package.admin" to the same package with some
rules.
These 2 users are not Administrators.
Now, when these 2 users edit the same rule, I was hoping to see something in
the Inbox - Incoming Changes for each user. Both the users' inbox are empty.
I had the users different kind of rule updates - comments, category, actual
rule.
I see the list growing in "Recently Opened", but "Recently Edited" and
"Incoming changes" is always empty.
Anybody know if there is any other setting for this feature to work per the
documentation?
thank you
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-5-5-Empty-Inbox-tp4022106.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months