setting global variables in session : the Command interface VS the RuleContext. What is the difference ?
by bardelman
hi ,
i m new in drools, i m reading the Drools-JBoss-Rules-5.0-Developers-Guide
book in which i found a validation rule example on its chapter 3. In this
exemple, global variables were set into the session with two methods shown
in this code :
...
session = knowledgeBase.newStatelessKnowledgeSession();
session.setGlobal("reportFactory", reportFactory);
session.setGlobal("inquiryService", inquiryService);
...
and these variables qualified as immutables, were called from the
RuleContext
public static void error(RuleContext drools,
Object... context) {
KnowledgeRuntime knowledgeRuntime = drools
.getKnowledgeRuntime();
ValidationReport validationReport = (ValidationReport)
knowledgeRuntime.getGlobal("validationReport");
ReportFactory reportFactory = (ReportFactory)
knowledgeRuntime.getGlobal("reportFactory");
...
and for other variables(or facts ) the Command interface was used instead :
List<Command> commands = new ArrayList<Command>();
commands.add(CommandFactory.newSetGlobal(
"validationReport", report));
commands.add(CommandFactory
.newInsertElements(getFacts(customer)));
session.execute(CommandFactory
.newBatchExecution(commands));
i m looking for accuracy in understanding when and which to use each method.
thanks for help
--
View this message in context: http://drools.46999.n3.nabble.com/setting-global-variables-in-session-the...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Performace Issues drools
by sanal
Hi,
Iam trying to use Drools for implementing some of the business logic
in hospital billing senario.My senario is as given.Iam implementing the
concept of a packge. A package is a set of services or items are put
together based on some contions. Only the packge is to be charged not the
individal services or items in the package.
Eg: A Health Package is defined with name ExecutiveHealthCheckUp, which
have a condition say,quntity limit 2 for Laboratory tests.So if more than 2
test is ordered for a patient the 3rd ordered test should not be part of
package.
A ordered service is considered to be part of a package if the
packageChargeRecordId property of the service
Using Drools iam trying to find out each of the ordered services(
$orderedComponent) for the patient to be part of package or not. Each of
the ordered service have quntity field.So i need to sum the quntity field of
same services ordered multiple times which is already part of the same
package and compare it with the quntity limit defined in the package
definition.
If a service is part of package iam setting packageChargeRecordId property
of ordered service to the packageId.
For implementing the same i have 2 set of collecton.
1st collection has got list of ordered services for the
patient.($objOrderedComponents.getOrderedComponentList() )
2nd collection list of condition for the services to be part of package.
($packageDefinition.getPackageComponentList())
rule "Package Rate_21"
salience 65515
when
/*package defanition object */
$packageDefinition:PackageDefinition($packageId:packageId)
/*Gets the list of services ordered */
$orderedComponent:OrderedComponent($id1:componentKey,$qty:componentQty)
from $objOrderedComponents.getOrderedComponentList() and
/*trying to get the accumulated quantity for the services
which are already part of package */
$accumulatedQty:Number()
from accumulate (
$accQtyComponent:OrderedComponent(packageChargeRecordId==$packageId,componentKey==$id1,
$AccQty : componentQty) from
$objOrderedComponents.getOrderedComponentList(),sum($AccQty ) )
and
/*Comparing withe packakage definition rule */
$pkgComps:PackageComponent(componentKey==$id1,(quantityLmt
>=($qty+$accumulatedQty.intValue()))) from
$packageDefinition.getPackageComponentList()
then
/*setting the packagechargerecordId for the ordered services
which satisfies above conditions */
$orderedComponent.setPackageChargeRecordId($packageId);
/*The changes have happened in facts so updating in the working
memory so the rule get executed once again*/
modify ($objOrderedComponents){};
end
The problem i am facing here is of performance. This way of
implementation is taking much time compared to that of java code.If iam
not using accumulate function and iam executing the rules for each item
seperatly instead of passing entire collection,it is working much better.
Can anbody suggest a better way to implement it using drools.
Regards
Sanal.P
--
View this message in context: http://drools.46999.n3.nabble.com/Performace-Issues-drools-tp3902270p3902...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Explanation of a decision
by Maxim Kolchin
Hi,
I'm working on expert system, automating one of the stages of optical
design.
Now, we're testing the system and we need a function, eхplaining a decision
of the system: which rules has been fired, why they has been fired and so
on. And I'm looking for a way to implement this feature.
Has someone had an experience in implementing this kind of features? Or
does someone know how it can be implemented?
Thank you,
Maxim Kolchin
Laboratory of Intellectual Systems,
National Research University ITMO,
http://en.ifmo.ru
12 years, 7 months
Trying to make drools-debugging (Eclipse) work in "FIT for rules"
by ingo_mytoys
Hi folks,
I'm happy that I recently discovered both the Eclipse debugging views for
Drools (working memory, agenda) and the FIT for rules framework. Since our
development project itself can't be tested as Drools-Application I'd like to
use FIT for acceptance-tests and debugging. Might be a smooth solution.
However, I don't manage to make drl-file-breakpoint-debugging work in the
fit-project, being run as Drools-application. It just won't stop the program
flow. With the parallelly installed drools-example-project however
everything works just fine.
Do you have an idea, what I might have to change in the project settings or
the code to get breakpoints work in the fit-project?
Facts for both, drools-examples and fit:
Eclipse Indigo
Drools 5.3.Final
Eclipse-Tools from Drools 5.4.BETA (because audit-view has a bug in 5.3)
Breakpoint is set only at then-part of rules :-)
Thanks a lot for your help!
Cu,
Ingo
--
View this message in context: http://drools.46999.n3.nabble.com/Trying-to-make-drools-debugging-Eclipse...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
setting global variables in session : the Command interface VS the RuleContext. What is the difference ?
by Ahmed Feki
hi ,
i m new in drools, i m reading the Drools-JBoss-Rules-5.0-Developers-Guide
book in which i found a validation rule example on its chapter 3. In this
exemple, global variables were set into the session with two methods shown
in this code :
...
session = knowledgeBase.newStatelessKnowledgeSession();
session.setGlobal("reportFactory", reportFactory);
session.setGlobal("inquiryService", inquiryService);
...
and these variables qualified as immutables, were called from the
RuleContext
public static void error(RuleContext drools,
Object... context) {
KnowledgeRuntime knowledgeRuntime = drools
.getKnowledgeRuntime();
ValidationReport validationReport = (ValidationReport)
knowledgeRuntime.getGlobal("validationReport");
ReportFactory reportFactory = (ReportFactory)
knowledgeRuntime.getGlobal("reportFactory");
...
and for other variables(or facts ) the Command interface was used instead :
List<Command> commands = new ArrayList<Command>();
commands.add(CommandFactory.newSetGlobal(
"validationReport", report));
commands.add(CommandFactory
.newInsertElements(getFacts(customer)));
session.execute(CommandFactory
.newBatchExecution(commands));
i m looking for accuracy in understanding when and which to use each
method.
12 years, 7 months
Drools Performance and Maintanability
by dollanitri
Hello,
Recently i started playing out with Drools Guvnor GUI and created couple of
rules based on DecisionTable
GUI Editor and also ruleflows in eclipse.
Then integrated Drools with Java Custom Web Application and tried out
executing rules on front end by changing rules on the drools guvnor at run
time. All seems to be working fine as per expected.
But i have couple questions would like to ask related to performance and
maintainability of the drools.
Questions:
1) does drools guvnor provides any option to make revisions for the decision
tables ?
(Eg. If more than single developer working on the same decisiontable and
making modifications to it then
it should allow to merge all the changes into main one.....)
2) how to measure performance of the drools to make it work and available
for the large rule datasets?
3) There are options to store data in a different formats like repository
(default one), Oracle, mysql.....etc
which one is better if i want to make my data backup very easily and import
it back whenever i need ?
4) is it drools is good one to replace with Yasu?
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Performance-and-Maintanability-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Unable to view drls in guvnor
by arup
Hi all,
I have my guvnor deployed in WAS. Now i added the POJO model and drls from
RAD(rational app developer) to my guvnor. I'm able to fire the rules from
guvnor by using url for package source. But the problem is i'm not able to
view any rules inside technical rule asset. but if i open the url for
package source i can view the imports and rules inside them. Any idea about
why this is happening?
Thanks a lot in advance... :) :) :)
--
View this message in context: http://drools.46999.n3.nabble.com/Unable-to-view-drls-in-guvnor-tp3919043...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Planner 5.3.0 Final - Issue with Local Search / Move
by duggal
I am solving a resource allocation problem using the Planner and have run
into a few issues with the use of Local Search.
The objective is to assign tasks to a set of resources. Each task has a
start and end time and NO task should overlap each other for the same
resource. There are other rules for preference and mandate of certain tasks
to certain resources.
I am using the FIRST_FIT construction heuristic which works fine.
I have implemented a Resource Change Move which assigns a new planning
variable to my planning entity. There seem to be issues with this phase.
**Problem** -
1. While looking at the solution created at the end of the local search
phase AND comparing to the moves output in the log file. I see that there
are several instances where the log file shows a move BUT the output
solution has the entity still on the previous planning variable.
This is happening only towards the end of the phase (about last 8 steps) of
the time terminated phase.
2. I have a rule in the DRL score file which prevents overlap of allocations
of the task for the same resource. I have instances where the construction
heuristic violated this constraint. The local search solver then moved one
of the overlapping entity to another resource. However the final output
shows the constraint still EXISTS between the two entities (even though the
overlap is no longer present). As a result even though the constraints are
actually removed, the score is NOT going down as the planner constraints
still exist.
The rule used by me is as follows (Allocation is the planning entity and
resource is the variable) -
rule "noOverlapAllocations"
when
$allocation1 : Allocation($id : id, $resource : resource, $task :
task, resource != null)
$allocation2 : Allocation(id > $id, resource == $resource,
isOverlap($task), $id2 : id)
then
insertLogical(new IntConstraintOccurrence("overlapAllocation",
ConstraintType.NEGATIVE_HARD, 1, $allocation1, $allocation2));
end
Please help me resolve these issues.
Thanks
Vikram
--
View this message in context: http://drools.46999.n3.nabble.com/Planner-5-3-0-Final-Issue-with-Local-Se...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months