Help needed - how to get Number and intValue in Guvnor
by Praveen
Hello,
I am new to Drools and trying to write rules using Guvnor GUI.
I have uploaded POJO's that are required for my rules.
I am facing issue trying to get Number()(the one in Bold-Italics) and
intValue in the Guvnor GUI.
Below is the rule for reference, its taken from one of the examples provided
in Drools Planner.
// Accumulate hard constraints
rule "hardConstraintsBroken"
salience -1 // Do the other rules first (optional, for performance)
when
$hardTotal : */Number(/)* from accumulate(
IntConstraintOccurrence(constraintType ==
ConstraintType.NEGATIVE_HARD, $weight : weight),
sum($weight) // Vote for
http://jira.jboss.com/jira/browse/JBRULES-1075
)
then
scoreCalculator.setHardConstraintsBroken($hardTotal.intValue());
end
--
View this message in context: http://drools.46999.n3.nabble.com/Help-needed-how-to-get-Number-and-intVa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
Rules from Multiple DRLs use the same namespace
by rajee.sakthi
Hi,
I am a newbie to DROOLs. I want to cross check with you for any potential
issues that you see about my DROOLs usage.
I have a requirement to create multiple DRLs that use the same namespace.
Hence, I am adding rules from DRL1, DRL2, DRL3 to a package named
"com.myproj.pkg".
And at some point I am removing rules of DRL1 from the knowledge package
leaving rest of the rules.
When all the rules from the package are removed, then I am removing the
knowledge package.
This is all done with StatefulSession.
So my rules removal code looks like this:
String pkgName = kpkg.getName();
Collection<Rule> rules = kpkg.getRules();
for(Rule rule : rules) {
knowledgeBase.removeRule(pkgName, rule.getName());
}
KnowledgePackage pkgAfterRemove =
knowledgeBase.getKnowledgePackage(pkgName);
Collection<Rule> rulesAfterCleanup = pkgAfterRemove.getRules()
if(rulesAfterCleanup == null || rulesAfterCleanup.isEmpty()) {
knowledgeBase.removeKnowledgePackage(pkgName);
}
I tested this logic and it works fine but does anyone see any side effects
of such logic?
I did a short search in the forum and couldnt find any similar posts.
Thanks a bunch,
Rajee
--
View this message in context: http://drools.46999.n3.nabble.com/Rules-from-Multiple-DRLs-use-the-same-n...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
compiled processes in PKG removed by knowledge agent after first change scan
by Jiang Zhu
hi,
I'm having trouble with scanning changed knowledge from Guvnor. I found out
that compiled processes from Guvnor are missing after resource change
scanner scan for changes first time (event there is no changes).
I wrote a simple test to reproduce this.
public class KnowledgeAgentTest {
@Test
public void should_load_processes() throws Exception {
ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
// Scan change every 2 seconds
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("agent");
// Changeset points to a PKG contains 12 processes on Guvnor
kagent.applyChangeSet(ResourceFactory.newClassPathResource("test/drools-changeset.xml"));
// Everything is still ok now
System.out.println("Processes before scan: " +
kagent.getKnowledgeBase().getProcesses().size());
Assert.assertFalse(kagent.getKnowledgeBase().getProcesses().isEmpty());
// Scan change every 2 seconds
sconf.setProperty("drools.resource.scanner.interval", "2");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();
// Wait long enough
Thread.sleep(5000);
// Processes are gone somehow
System.out.println("Processes after scan: " +
kagent.getKnowledgeBase().getProcesses().size());
Assert.assertFalse(kagent.getKnowledgeBase().getProcesses().isEmpty());
}
}
Here is what I'm getting when run the test.
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running test.KnowledgeAgentTest
Processes before scan: 12
Processes after scan: 0
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.802 sec
<<< FAILURE!
Results :
Failed tests: should_load_processes(test.KnowledgeAgentTest)
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
Thanks,
Jiang
--
View this message in context: http://drools.46999.n3.nabble.com/compiled-processes-in-PKG-removed-by-kn...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
Help! Activations firing out of salience order
by Swindells, Thomas
In our project we have been experiencing a large number of intermittent unit test failures when we are testing our rules (on drools 5.1.1).
After a lot of debugging, examining our rules for logic errors, experimenting and generally scratching our head trying to work out what is wrong, we have noticed that sometimes (but very intermittently) activations are firing in the wrong order.
In our rulebase we have two rules, Rule A salience 80 and Rule B salience 70. Whilst debugging we made Rule A and B are identical other than rule B having some additional constraints on the end.
Dumping out the agenda events we have observed the following actions occurring:
BEFORE_FIRED rule X
CREATED_ACTIVATION Rule A
CREATED_ACTIVATION Rule B
AFTER_FIRED rule X
... (no references to either rule/activation)
BEFORE_FIRED Rule B
CANCELLED Rule A
AFTER_FIRED Rule B
How can Rule B be firing before Rule A when both activations exist?
Does anybody know of any bugs in 5.1.1 that may be causing this?
We have a branch of code on 5.3 and that also has had intermittent unit test failures, we've not had chance to examine whether this is the same pattern or just a different logic issue.
Please help,
Thomas
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
14 years, 5 months
Drools Guvnor -- Not seeing Model Correctly
by johnz
I'm new to Drools. Want to play with Guvnor to see if it will be applicable
for my application.
I have Guvnor running thru Eclipse/Jboss. I can get into Guvnor and create
categories and packages.
I create a real simple domain model (see below). I then upload the jar file
to create a model in Guvnor.
After uploading i don't see anything appear on the model tab. i was
expecting to see the classes and attributes. when i try creating a new rule
using the model i only see the class, but don't see any of the attributes.
what am i doing wrong?
here is the code for the domain model
public class Driver {
private String name;
private int age;
private Vehicle car;
public Driver() {}
public Driver(String name, int age, Vehicle car) {
this.name = name;
this.age = age;
this.car = car;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Vehicle getCar() {
return car;
}
public void setCar(Vehicle car) {
this.car = car;
}
}
public class Vehicle {
private Long id;
private String make;
private String model;
private String VIN;
private String damageType;
public Vehicle()
{
}
public Vehicle(Long id, String make, String model, String VIN, String
damageType)
{
this.id = id;
this.make = make;
this.model = model;
this.VIN = VIN;
this.damageType = damageType;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getVIN() {
return VIN;
}
public void setVIN(String vIN) {
VIN = vIN;
}
public String getDamageType() {
return damageType;
}
public void setDamageType(String damageType) {
this.damageType = damageType;
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Guvnor-Not-seeing-Model-Correctl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
[planner] The presumed score is corrupted
by Guilherme Kunigami
Hi,
I've implemented a very simple application using drools planner consisting
of a bunch of activities. My rule file is very simple too and just counts
the number of activities not assigned. When I run Solver.solve(), I get the
following error message:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: The
presumedScore (-10hard/0soft) is corrupted because it is not the realScore
(0hard/0soft).
Presumed workingMemory:
Score rule (remainingActivitiesCount) has count (1) and weight total (11).
Real workingMemory:
Score rule (remainingActivitiesCount) has count (1) and weight total (0).
I've tracked down this message and found this piece of code
@DefaultLocalSearchSolver.solveImplementation():
// there is no need to recalculate the score, but we still need to set it
localSearchSolverScope.getWorkingSolution().setScore(localSearchStepScope.getScore());
if (assertStepScoreIsUncorrupted) {
localSearchSolverScope.assertWorkingScore(localSearchStepScope.getScore());
}
It seems that the working score is never updated along the algorithm, but
the score in the working memory changes. Thus, when we use the DEBUG
environment, assertStepScoreIsUncorrupted is turned on and the assertion
fails.
Should the score be updated or am I using the library incorrectly?
Thanks,
14 years, 5 months
[planner] Problem setting configuration file
by Guilherme Kunigami
Hi,
I'm trying to load a configuration file (namely SolverConf.xml) into
XmlSolver with the code below:
XmlSolverConfigurer configurer = new XmlSolverConfigurer();
configurer.configure(SOLVER_CONFIG);
Solver solver = configurer.buildSolver();
If I bundle SolverConf.xml file with the application .jar file, then using
SOLVER_CONFIG as /path/to/xml/file/SolverConf.xml works fine.
But I want to use SolverConf.xml outside the .jar, so I can easiliy edit it,
but I don't know what path should I pass to it.
I know it's a Java related question, but I was wondering if anyone had a
similar problem when configuring drools planner. (I've asked on
stackoverflow, but none of the answers worked for me:
http://stackoverflow.com/questions/7718807/can-getresourceasstream-find-f...
)
(Supposing my .jar is in /some/path and the SolverConf.xml will be on
/some/path/conf for example)
Thanks,
14 years, 5 months