KIE Workbench data model import
by rockford
Hello,
I am trying to import a data model from inside the Drools 6 KIE Workbench.
(I have used this functionality in the Guvnor.)
So far I have:
- Uploaded a jar containing a data model to the repository from the "Asset
repository" editor.
Now I am trying to see where to make the data model visible when using the
Guided Rules Editor. So far with no success.
Has anyone used this yet and can shed some light on this?
Ken Helmes
--
View this message in context: http://drools.46999.n3.nabble.com/KIE-Workbench-data-model-import-tp40265...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Drools server and knowledge agent functionality
by Manuel Ortiz
Hello everybody:
I am taking a look at Drools Integration documentation to understand how
Drools server works and how can be used, and have a doubt concerning, let's
say... 'KnowledgeAgent capabilities'. Does Drools server support on the fly
rule updating as when using KnowledgeAgent to create KnowledgeBase objects?
If it does, where can be configured 'KnowledgeAgent related' properties such
as newInstance or resource scanner interval?
Thank you in advance for your time.
Kind regards,
Manuel Ortiz.
12 years, 4 months
Problem with chained planning variables
by Juan Ignacio Barisich
Hi everybody.
I have a problem with chained planning variables.
I'm using optaplanner 5.5.0.Final.
I have a planning entity like:
@PlanningEntity()
public class Case implements Chained {
private Chained previous;
@PlanningVariable(chained = true)
@ValueRanges({
@ValueRange(type = ValueRangeType.FROM_SOLUTION_PROPERTY,
solutionProperty = "doctors"),
@ValueRange(type = ValueRangeType.FROM_SOLUTION_PROPERTY,
solutionProperty = "cases", excludeUninitializedPlanningEntity = true) })
public Chained getPrevious() {
return previous;
}
}
A fact class:
public class Doctor implements Chained {
...
}
An a solution class:
public class Plan extends implements Solution<HardAndSoftScore> {
private List<Doctor> doctors;
private List<Case> cases;
private HardAndSoftScore score;
@PlanningEntityCollectionProperty
public List<Case> getCases() {
return cases;
}
public Collection<? extends Object> getProblemFacts() {
return new ArrayList<Doctor>(doctors);
}
}
The equals / hashCode / clone methods are inspired on the
TravelingSalesmanTour example.
I want that Optaplanner generates chains like:
DoctorA <- Case1 <- Case2
DoctorB <- Case3
This model tries to represent a list of Cases assigned to each Doctor.
Suppose I build a solution like:
Plan plan = new Plan();
plan.setDoctors(DoctorA, DoctorB); //pseudo-code
plan.setCases(Case1, Case2); //pseudo-code
Then I build a solver:
Solver solver = getSolverFactory().buildSolver();
solver.setPlanningProblem(plan);
solver.solve();
Plan bestPlan = (Plan) solver.getBestSolution();
The problem is that, Optaplanner is not testing all the posible
combinations of chains. I mean, suppose that we know that the better
solution (based on the scoring rules) is:
DoctorA
DoctorB <- Case1 <- Case2
But Optaplanner seems to test only chains with DoctorA, so the result of
calling getBestSolution() is:
DoctorA <- Case1 <- Case2
I guess that Optaplanner only test chains whit DoctorA, becouse it logs
lines like:
...
DEBUG: org.drools.planner.core.localsearch.DefaultLocalSearchSolverPhase
- Step index (1), time spend (20002), score (1hard/2soft), best
score (1hard/2soft), accepted/selected move count (0/58187) for picked step
(Case [id=2, previous=Doctor [id=1]] => Case [id=1, previous=Case [id=2,
previous=Doctor [id=1]]]).
...
That is, no lines whith "DoctorB" are logged.
If the doctor list is inverted, the same problem happen (the DoctorA is no
processed). That is:
Plan plan = new Plan();
plan.setDoctors(DoctorB, DoctorA); //pseudo-code
plan.setCases(Case1, Case2); //pseudo-code
Solver solver = getSolverFactory().buildSolver();
solver.setPlanningProblem(plan);
solver.solve(); // DoctorA is not part of chains
I guess the problem is on the solver configuration, specifically on the
localSearch configuration:
<localSearch>
<unionMoveSelector>
<changeMoveSelector>
<valueSelector/>
</changeMoveSelector>
<swapMoveSelector />
<subChainChangeMoveSelector>
<selectReversingMoveToo>true</selectReversingMoveToo>
</subChainChangeMoveSelector>
<subChainSwapMoveSelector>
<selectReversingMoveToo>true</selectReversingMoveToo>
</subChainSwapMoveSelector>
</unionMoveSelector>
<acceptor>
<planningEntityTabuSize>9</planningEntityTabuSize>
</acceptor>
<forager>
<minimalAcceptedSelection>2000</minimalAcceptedSelection>
</forager>
</localSearch>
I tried some alternatives to this configuration, but with no success.
Do you know what I am doing wrong?
Thanks a lot.
Regards
12 years, 4 months
NPE in Event.attribute.getIntValue()
by Alexander Wolf
Version: 5.5.0 Drools Expert + Fusion
Stateful ksession in STREAM mode
In an integration test, I ___sometimes_____!!! (always the same variables... ) get the following Exception:
Exception in thread "Thread-1" java.lang.NullPointerException
at org.drools.base.com.myApp.model.Measurement1965915394$getValue.getIntValue(Unknown Source)
at org.drools.base.extractors.BaseIntClassFieldReader.getValue(BaseIntClassFieldReader.java:52)
at org.drools.base.ClassFieldReader.getValue(ClassFieldReader.java:87)
at org.drools.rule.Declaration.getValue(Declaration.java:233)
at org.drools.base.mvel.MVELCompilationUnit.updateFactory(MVELCompilationUnit.java:362)
at org.drools.base.mvel.MVELCompilationUnit.updateFactory(MVELCompilationUnit.java:289)
at org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:59)
at org.drools.rule.constraint.MvelConditionEvaluator.ensureBranchEvaluation(MvelConditionEvaluator.java:117)
at org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:101)
at org.drools.rule.constraint.MvelConditionEvaluator.ensureBranchEvaluation(MvelConditionEvaluator.java:120)
at org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:101)
at org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:90)
at org.drools.rule.constraint.MvelConditionEvaluator.getAnalyzedCondition(MvelConditionEvaluator.java:82)
at org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:270)
at org.drools.rule.constraint.MvelConstraint.access$200(MvelConstraint.java:51)
at org.drools.rule.constraint.MvelConstraint$ConditionJitter.run(MvelConstraint.java:250)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
Where Measurement is one of my custom model classes and an @event.
I tried to catch the exception but I don't know where it actually occurs. There is one rule that retracts Measurement in certain situations - the problem might be related to that (is it unwise to retract @event ?).
Any idea?
- Alex
12 years, 4 months
Unexpected behavior of accumulate() and insertLogical() when the result() goes from matching a constraint to not matching
by mikerod
This is a follow up from my original post @
http://drools.46999.n3.nabble.com/rules-users-Question-about-custom-accum...
Using Drools version 5.5.0.Final
I am experiencing behavior I did not expect, regarding Drools accumulate
functionality.
The following demonstrates:
With an example (contrived) rule such as:
file <<example.drl>>
package drools
rule "testing"
dialect "mvel"
when
$res : Long() from accumulate( $l : Long(),
init( Long highest = null; ),
action( highest = ((null == highest) || ($l > highest)) ? $l :
highest; ),
result( (highest < 10) ? highest : null; ))
then
insertLogical( new String("inserted " + $res.toString()) );
end
endfile <<example.drl>>
I have the following, simple test case:
file <<ExampleDroolsTest.java>>
package drools;
import java.io.IOException;
import org.drools.KnowledgeBase;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.junit.Test;
public class ExampleDroolsTest {
@Test
public void test() throws IOException {
final KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("drools/example.drl"),
ResourceType.DRL);
final KnowledgeBase kbase = kbuilder.newKnowledgeBase();
final StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
/** HERE the insertion order of these two facts, will result in
different outcomes for
* the rule "testing" in example.drl .
* In this order, I will get the RHS logic to insert the new
String("inserted" + $res.toString())
* The accumulate should be getting the max valued Long, in the end
and then the `result` of the
* `accumulate` should yield a null value.
*
* If I flip the inserts, no fact is inserted into the session.
*/
ksession.insert(new Long(5));
ksession.insert(new Long(15));
final int rulesFired = ksession.fireAllRules();
System.out.println("Rules fired: " + rulesFired);
System.out.println("Session objs:");
for (final Object o : ksession.getObjects()) {
System.out.println(o);
}
ksession.dispose();
}
}
endfile <<ExampleDroolsTest.java>>
As I note in the Java source comment above, the order of the insertions of
the Long's into the session, change the results of the rule execution. My
initial understanding of accumulate, would be that the LHS would be
invalidated once the highest Long value
was found to be 15 > 10, as the `result` portion of the `accumulate` tests.
Since the String object is inserted logically, I'd
expect the fact to be retracted from the working memory once the LHS of the
rule "testing" was found to be false.
If this were the case, the order of insertions above in the test case, would
result in the same working memory after rule execution.
Is this intended behavior of the accumulate node along with the
`insertLogical` operation?
Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Unexpected-behavior-of-accumulate-and-i...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Question about custom accumulation functions
by Bruno Freudensprung
Hi,
While testing my custom accumulation function I noticed an unexpected
behavior (th'ats of course a personal point of view).
It seems that Drools 5.1 calls accumulate(...) and getResult(...) as
many times as the number of accumulated facts (accumulate, getResult,
accumulate, getResult, etc...).
Is it supposed to work like this?
Best regards,
Bruno.
12 years, 4 months