getBestSolution not returning the correct Solution?
by Charles
I displayed the score to console on hardConstraintsBroken rule.
rule "hardConstraintsBroken"
dialect "java"
salience -1 // Do the other rules first (optional, for performance)
when
$sd : ServiceRequest( $object : object );
$hardTotal : Number() from accumulate (
IntConstraintOccurrence( $weight : weight ),
sum( $weight ) );
then
System.out.println( $object.getId() + " : " + (- $hardTotal.intValue())
);
scoreHolder.setScore(- $hardTotal.intValue() );
end
I found that the getBestSolution() did not return the correct best solution
based on console output.
For example, in console output
Problem Entity:
O00010440201002 O00010440201003 O00010440201004 O00010440201009
O00010440201010 O00010440201011
Object: O00010440201002 : -5
Object: O00010440201002 : -5
Object: O00010440201010 : -4
Object: O00010440201003 : -5
Object: O00010440201004 : -5
Object: O00010440201011 : -4
Object: O00010440201009 : -1
Object: O00010440201004 : -5
Object: O00010440201010 : -4
Object: O00010440201002 : -5
Object: O00010440201003 : -5
Object: O00010440201011 : -4
Object: O00010440201002 : -5
Object: O00010440201003 : -5
Object: O00010440201004 : -5
Object: O00010440201009 : -1
Object: O00010440201011 : -4
Object: O00010440201003 : -5
Object: O00010440201011 : -4
Object: O00010440201004 : -5
Best Solution return by Solver
O00010440201011 : -1
My expectation
O00010440201009 : -1
Previous implementation in 5.3.0 doesn't have this problem.
Can explain where I might do wrongly?
--
View this message in context: http://drools.46999.n3.nabble.com/getBestSolution-not-returning-the-corre...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Is a single StatefulKnowledgeSession with Distributed Memory cache possible?
by chrisLi
Hi All,
I am working on a banking fraud detection project with Drools Fusion,
which will match a transaction against hunreds of rules to check whether the
transaction is suspicious.
In some rules, I use time-based sliding window to calculate the average
transaction amount of an account in the past 3 or 6 months. One possible
rule will be as below:
rule "Single Large Amount Transaction"
dialect "mvel"
when
$account : Account($number : number)
$averageAmount : BigDecimal() from accumulate(
TransactionCompletedEvent(fromAccountNumber == $account.number,
$amount : amount)
over window:time(90d)
from entry-point TransactionStream,
bigDecimalAverage($amount))
$t1 : TransactionCreatedEvent(fromAccountNumber == $account.number,
amount > $account.creditAmount * 0.5, amount > $averageAmount *
3.0)
from entry-point TransactionStream
then
end
In such cases, the Fusion Engine will hold TransactionCompletedEvent in
its memory for 90 days. And we have about 1 billion Accounts in total, so
the TransactionCompletedEvent will be huge, we will very soon run out of
memory.
I have been blocked here for a long time! Is it possible to distribute a
single StatefulKnowledgeSession in multiple JVMs or machines using
Distributed Memory cache such as Hazelcast? If yes, could you give me some
opinion on the solution? Or is this the problem the Drools Grid project try
to handle? Or there are other techonology to handle large numbers of facts
or events problem?
As far as I know, Drools Grid distribute multilple ksessions on multiple
machines in the Grid, each or several kseesions on one node? Is my
understandings right?
Any response or opinion from you will be appriciated! Thank you very
much!
--
View this message in context: http://drools.46999.n3.nabble.com/Is-a-single-StatefulKnowledgeSession-wi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
jsp, java and drl file
by Brajesh
Hi Friends
I am trying to create a web page with a form, so when we click on submit, we
are redirected to the result web page, but the content of this page will be
generated according to the rules i created in my drl file. Does anyone knows
the easiest way to do this? are they a way to call the drl file from the jsp
file, or the java file?
My Jsp file
<form:form method="post" action="login.htm" commandName="loginForm"
id="loginForm">
<table>
<tr>
<td>Enter username:</td>
<td><form:input path="UserName" style="width:250px"
maxlength="75"/></td>
</tr>
<tr>
<td>Enter password</td>
<td><form:password path="UserPassword" style="width:250px"
maxlength="75"/></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" >
<label>
<input type="submit" value="Save" />
</label>
<label>
<input type="reset" value="clear"/>
</label>
</td>
</tr>
</table>
</form:form>
My controller class
@RequestMapping(value="login.htm", method=RequestMethod.POST)
public String showAffilaiteform(Map<String, Object> model,login
loginform,BindingResult result) {
String target = AFFILIATE_REGISTRATION;
try{
testDAO.drools(loginform);
model.put("affiliateRegistrationForm", new AffiliateUserRegistration());
}catch(Exception e)
{
e.printStackTrace();
}
return target;
}
My TestDao class
public class TestDAO implements ITestDao {
public void drools(login loginform) {
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "myLog");
ksession.insert(loginform);
ksession.fireAllRules();
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("LoginRules.drl"),
ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse
knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
My DRL file
import com.ri.bean.login;
rule "b"
dialect "mvel"
when
login( userName == "" ||==null)
then
System.out.println("hello");
login lo = new login();
end
These are my files and my application runs without any error.Now I want to
show a message on my jsp page when the rule violates.can anybody provide me
a small piece of code.
Regards
Brajesh
--
View this message in context: http://drools.46999.n3.nabble.com/jsp-java-and-drl-file-tp4017955.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Trouble using java.util.List.size in constraints in 5.4.0.Final
by Alexis Brouard
Hi everyone,
I've tried to go from Drools 5.3.0.Final to 5.4.0.Final and some strange
errors appeared on constraints using the size of a list.
For instance, given the following object:
public class MyObject {
private List<String> param = new ArrayList<String>();
public MyObject() {
super();
}
public List<String> getParam() {
return param;
}
public void setParam(List<String> param) {
this.param = param;
}
}
This rule:
rule "Sample rule"
when
MyObject( param.size > 0 )
then
System.out.println( "Sample rule activated" );
end
Provokes the following error:
Unable to Analyse Expression param.size > 0:
[Error: Comparison operation requires compatible types. Found class
java.lang.String and class java.lang.Integer]
[Near : {... param.size > 0 ....}]
^ : [Rule name='Sample rule']
This worked very well in Drools 5.3.0.Final.
Is there some configuration specific to Drools 5.4.0.Final that I've missed
in the release notes?
Thanks in advance for your help.
Best,
Alexis
13 years, 8 months
Programatically filled Enum not getting loaded
by Sandjaja, Dominik
I use Guvnor 5.4.0 with the following Assets:
Enum:
'Enums.Modules' : (new de.itm.util.DroolsEnumHelper()).loadModules()
DSL:
[when]Testmodule {module:ENUM:Enums.Modules} is just for testing={module} : Cylinder()
DroolsEnumHelper-Class:
public List<String> loadModules() {
List<String> values = new ArrayList<String>();
for (Module module : Module.values()) {
values.add(module.getModuleName() + "=" + module.getDisplayName());
}
return values;
}
When running the "Source->Validate" in the Enum-Editor, I see the method getting called (being connected to the JBoss for Debugging). But if I use the DSL rule in the guided editor, I can select the rule but the dropdown field stays grayed out. The loadModules() method isn't even called, no getting stuck in my breakpoint!
Anyone an idea why and how this happens? Am I doing something totally wrong?
Thanks
Dominik
...........................................................................
mit freundlichen Grüßen / kind regards
Dominik Sandjaja
Fon: +49 (0) 203 60878 183
Mobil +49 (0) 162 2624490
Fax: +49 (0) 203 60878 22
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 <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
13 years, 8 months
Implementing complex operators in Decsion Table
by pratibhapandey
I need some help in implementing complex rules in decision table..
Following are the two queries that I need to implement in decision table.
1 ----------- ((UPPER(PRODUCT_TYPE_CODE) IN ('REO', 'TRM')) OR
(UPPER(INVESTMENT_GROUP_TYPE) = 'EQUITY' AND deal_ltv_nbi_ext_Debt <= .6))
AND UPPER(PRIMARY_COLLATERAL_TYPE) = 'HOTEL'
2 --------------(UPPER(INVESTMENT_GROUP_TYPE) = 'EQUITY' OR
UPPER(PRODUCT_TYPE_CODE) = 'LES') AND ((UPPER(NNN_LEASE) = 'Y' AND
DECODE(ENHANCED_ITV, NULL, DEAL_ITV_NBI_SPP_CURR_MKT_VAL, ENHANCED_ITV) >=
.95 AND Core_Property_Type_YN = 'Y') OR (UPPER(NNN_LEASE) = 'Y' AND
DECODE(ENHANCED_ITV, NULL, DEAL_ITV_NBI_SPP_CURR_MKT_VAL, ENHANCED_ITV) >=
.85 AND Core_Property_Type_YN = 'N'))
I need to use decision tables only. so how do I implement them. I have also
attached a decsion table in which I have to implement these queries.
http://drools.46999.n3.nabble.com/file/n4017943/LeverageRuleSheet1.xls
LeverageRuleSheet1.xls
--
View this message in context: http://drools.46999.n3.nabble.com/Implementing-complex-operators-in-Decsi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Implementing complex operators in Decision table
by pratibhapandey
I need some help in implementing complex rules in decision table..
Following are the two queries that I need to implement in decision table.
1 ----------- ((UPPER(PRODUCT_TYPE_CODE) IN ('REO', 'TRM')) OR
(UPPER(INVESTMENT_GROUP_TYPE) = 'EQUITY' AND
deal_ltv_nbi_ext_Debt <= .6)) AND
UPPER(PRIMARY_COLLATERAL_TYPE) = 'HOTEL'
2 --------------(UPPER(INVESTMENT_GROUP_TYPE) = 'EQUITY' OR
UPPER(PRODUCT_TYPE_CODE) = 'LES') AND
((UPPER(NNN_LEASE) = 'Y' AND
DECODE(ENHANCED_ITV,
NULL,
DEAL_ITV_NBI_SPP_CURR_MKT_VAL,
ENHANCED_ITV) >= .95 AND Core_Property_Type_YN = 'Y') OR
(UPPER(NNN_LEASE) = 'Y' AND
DECODE(ENHANCED_ITV,
NULL,
DEAL_ITV_NBI_SPP_CURR_MKT_VAL,
ENHANCED_ITV) >= .85 AND Core_Property_Type_YN = 'N'))
I need to use decision tables only. so do I implement them. I have attached
a decsion table in which I have to implement.
http://drools.46999.n3.nabble.com/file/n4017941/LeverageRuleSheet1.xls
LeverageRuleSheet1.xls
--
View this message in context: http://drools.46999.n3.nabble.com/Implementing-complex-operators-in-Decis...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months