ClassCastException and "from collect" keyword issue?
by Tan, Kevin
Hi rules users,
I am having a problem with Drools 5.1.1 recently. The exception we had is:
java.lang.ClassCastException:
d2.rules.state.EvaluateRule cannot be cast to d2.autorating.data.model.Account
org.drools.runtime.rule.ConsequenceException: rule: DERIVE_COLLAT_MECHANISM_PLEDGE
Our rules are listed as below:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rule "DERIVE_COLLAT_MECHANISM_PLEDGE"
no-loop true
salience 19991
when
$RatingData : RatingRuleFact()
$contract : Contract()
$csaDoc : Document(documentId == $contract.csaId && status == "Final/Signed")
(EvaluateRule(ruleName == "INSCOPE))
then
RuleProcessingOutput ruleOutput = $RatingData.getRuleOutput();
RuleResult result = new RuleResult(drools.getRule().getName(), $contract.getContractId(), $RatingData.getPrincipalPartyCountry());
ruleOutput.addRuleResult(result);
$contract.setCollateralMechanism(result.getRuleOutputText());
insertLogical(new EvaluateRule(drools.getRule().getName()));
end
rule "EXC_COLLAT_HOLDING_ARRANGEMENT"
no-loop true
salience 19985
when
$RatingData : RatingRuleFact()
$contract : Contract()
$noHoldingAgreementAccts : ArrayList()
from collect ( Account(collatNetId == $contract.contractId,
businessUnit not in ("COMM", "FID", "FX", "IED", "SECLENDING", "SWAPS")) from $contract.collatAccounts
)
EvaluateRule(ruleName == "INSCOPE")
then
RuleProcessingOutput ruleOutput = $RatingData.getRuleOutput();
for (Object obj : $noHoldingAgreementAccts) {
Account acct = (Account) obj;
if (acct.getDp2Account() != null) {
RuleResult result = new RuleResult(drools.getRule().getName(), $contract.getContractId(), $RatingData.getPrincipalPartyCountry());
result.setAccountId(acct.getDp2Account().getAccountId());
result.setRuleOutputText("BU has no Data");
ruleOutput.addRuleResult(result);
}
}
if ($noHoldingAgreementAccts.size() > 0) {
insertLogical(new EvaluateRule(drools.getRule().getName()));
}
end
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
* In object Account(), we did not have any EvaluateRule() object in it.
* We also noticed after the "from collect" key word there are EvaluateRule() object defined after it(but the purpose is just to determine if this object exist or not in the Working Memory), in the LHS of each rule file.
* In the variable $noHoldingAgreementAccts, we are not supposed to see the object - EvaluateRule (BUT the exception is showing it is trying to cast EvaluateRule into Account)
My question is are there any known problems/issues with the following
- Drools rule compilers
- Key word from collect
- Rules production memory
- Version 5.1.1
that can make this happen? Any ideas will be appreciated. Thanks.
Kevin Tan
Morgan Stanley | Enterprise Data & Services
700 Rue Wellington | Floor 04
Montreal, QC H3C 3S4
Phone: +1 514 876-5756
Kevin.Tan(a)morganstanley.com<mailto:Thanh.Dang@morganstanley.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
User specific packages for Guvnor
by riri
Hello everyone,
I am interested in working with Guvnor and would like to know if rule
packages can be user specific. For example I would need to have each user be
able to have his own rules to work on and have only these ones available the
next time he logs in. I think that would be the same as having a separate
knowledge base per user but I am not exactly sure what settings should be
configured so that the user only has access to his knowledge base.
Afterwards I need to recover the user specific packages separately using the
knowledge agent.
Has anyone ever used Guvnor in a similar manner? I am just starting with it
and would appreciate some input from more experienced users.
Best regards
--
View this message in context: http://drools.46999.n3.nabble.com/User-specific-packages-for-Guvnor-tp402...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Evaluator 'matches' does not support type 'ValueType = 'Object'
by CAK
Hello forum,
we currently encounter the following problem on Drools 5.1.1:
Evaluator 'matches' does not support type 'ValueType = 'Object' for the
following rule:
rule "Create_License"
when
StringCapability(name=="service", value=="service_v1")
StringCapability(name=="data.modelCode", value matches "^5G1.*")
then
License license = new License();
license.setDuration("30 years");
license.setName("30Years");
license.setState(State.NOTACTIVATED);
license.setType(Type.IMPLICIT);
license.setWarn(false);
insert(license);
end
StringCapability derives from a generic class and is defined as follows:
public class StringCapability extends Capability <String>
{
public StringCapability(String name, String value)
{
super(name, value);
}
}
whereas the superclass looks like this
public abstract class Capability<T>
{
private final String name;
private final T value;
protected Capability(String name, T value)
{
this.name = name;
this.value = value;
}
@Override
public boolean equals(Object object)
{
if (this == object)
{
return true;
}
if (object == null)
{
return false;
}
if (getClass() != object.getClass())
{
return false;
}
Capability <?> other = (Capability <?>) object;
if (name == null)
{
if (other.name != null)
{
return false;
}
}
else if (!name.equals(other.name))
{
return false;
}
if (value == null)
{
if (other.value != null)
{
return false;
}
}
else if (!value.equals(other.value))
{
return false;
}
return true;
}
public String getName()
{
return name;
}
public T getValue()
{
return value;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + getClass().hashCode();
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public String toString()
{
return new StringBuilder(getClass().getSimpleName()).append(" -
name:").append(name).append(", value:")
.append(String.valueOf(value)).toString();
}
The problem occurs when the rule is supposed to be compiled on
initialization of the knowledge base. So from my point of view, the value
returned by class StringCapability is of type String. Why do I get this
error? How can I workaround this problem without any code change (I just can
provide another rule file)
Any help appreciated!
Thank you,
CAK
--
View this message in context: http://drools.46999.n3.nabble.com/Evaluator-matches-does-not-support-type...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
XStreamAlias
by André Fróes
What is this @XStreamAlias(...) that i see in mostly of example pojos? I
did my pojos without it and worked the same way. Is it for performance?
11 years, 9 months
Confusion with using predicates in spreadsheets
by starfish15
Hello,
In Drools 5.2, Web Guided DTs, i have worked with calculation types as
*Predicate*. How can the same be used in a spreadsheet DT.
Just to give an idea, i need to compare values in 2 facts. So in the DT,
Condition was written as factA.attrib1 == factB.attrib1, Bt i am stuck as to
what should be written in the value for this condition.
In Web Guided DTs, this cud be done using predicates, where neither the
field nor the operator was required. Simply when penning down this condition
in the table we wrote the value as, factA.attrib1 == factB.attrib1
And that solved the condition thing, however am not sure how this should be
written in spread sheets
Kindly help with usual spread sheets how can this be handled.
Regards,
starfish
--
View this message in context: http://drools.46999.n3.nabble.com/Confusion-with-using-predicates-in-spre...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Drools rule [Planner]
by André Fróes
Is there a way to debug my project monitoring if it passes by my rule?
In my console i don't see the score of hard constraint of this rule:
----
rule "requiredWorktimeToFinish"
when
$engineer : Engineer($worktime : worktime)
$requiredWorktimeTotal : Number(intValue < $worktime) from accumulate(
WorkOrder (
engineer == $engineer,
$requiredWorktime : requiredWorktime),
sum($requiredWorktime)
)
then
insertLogical(new IntConstraintOccurrence("requiredWorktimeToFinish",
ConstraintType.NEGATIVE_HARD,
$requiredWorktimeTotal.intValue() - $worktime,
$engineer));
end
rule "hardConstraintsBroken"
salience -1
when
$hardTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType ==
ConstraintType.NEGATIVE_HARD, $weight : weight),
sum($weight)
)
then
scoreHolder.setHardConstraintsBroken($hardTotal.intValue());
end
----
in my console it points no score
----
17:02:49.009 [main] INFO o.d.p.core.solver.DefaultSolver - Solving
started: time spend (127), score (null), new best score (null), random seed
(0).
17:02:49.041 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -
Step index (0), time spend (164), score (0hard/0soft), initialized planning
entity ([WorkOrder-7]).
17:02:49.042 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -
Step index (1), time spend (165), score (0hard/0soft), initialized planning
entity ([WorkOrder-9]).
17:02:49.043 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -
Step index (2), time spend (166), score (0hard/0soft), initialized planning
entity ([WorkOrder-8]).
17:02:49.045 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -
Step index (3), time spend (168), score (0hard/0soft), initialized planning
entity ([WorkOrder-6]).
17:02:49.045 [main] INFO o.d.p.c.c.g.DefaultGreedyFitSolverPhase - Phase
constructionHeuristic ended: step total (4), time spend (168), best score
(0hard/0soft).
17:02:49.274 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -
Step index (0), time spend (397), score (0hard/0soft), best score
(0hard/0soft), accepted/selected move count (1000/1000) for picked step
([WorkOrder-7] => [Engineer-5]).
17:02:49.592 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -
Step index (1), time spend (715), score (0hard/0soft), best score
(0hard/0soft), accepted/selected move count (1000/1926) for picked step
([WorkOrder-8] => [Engineer-3]).
17:02:50.045 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -
Step index (2), time spend (1168), score (0hard/0soft), best score
(0hard/0soft), accepted/selected move count (1000/3686) for picked step
([WorkOrder-6] => [Engineer-2]).
17:02:50.464 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -
Step index (3), time spend (1587), score (0hard/0soft), best score
(0hard/0soft), accepted/selected move count (1000/7516) for picked step
([WorkOrder-9] => [Engineer-2]).
17:02:53.877 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -
Step index (4), time spend (5000), score (0hard/0soft), best score
(0hard/0soft), accepted/selected move count (0/350227) for picked step
([WorkOrder-7] => [Engineer-4]).
17:02:53.877 [main] INFO o.d.p.c.l.DefaultLocalSearchSolverPhase - Phase
localSearch ended: step total (5), time spend (5000), best score
(0hard/0soft).
17:02:53.878 [main] INFO o.d.p.core.solver.DefaultSolver - Solving ended:
time spend (5000), best score (0hard/0soft), average calculate count per
second (72872).
11 years, 9 months
Question about caching of MoveListFactory
by Michiel Vermandel
Hi,
Is it possible to use caching on a custom created MoveListFactory?
I mean, I created a custom MoveListFactory and configured it like this:
<moveListFactory>
<moveListFactoryClass>my.planner.solver.ProjectShiftFactory</moveListFactoryClass>
</moveListFactory>
I noticed that the createMoveList method is called upon every step.
Though, if I get things right, in the case that the step did not result in a better score, the solution will not be cloned and thus (in my case) the
calling of the createMoveList in the next step will result in exactly the same list containing the same object instances.
I think it would be OK if the createMoveListis only called when a better score is reached and a cloneSolution will be executed (and thus my object instances get obsolete).
1) I hope my theory makes sense end if so my question is: can I cache the list on the level as described?
2) One more question about steps: if a step does not result in a better score, what happens then?
- A new number of moves is launched up to the limit defined by minimalAcceptedSelection?
But what is the difference with the previous step?
Is it the fact that a "different" solution with the same score will be used as starting point of the new step (given that one uses tabu)?
Thanks,
Michiel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
11 years, 9 months
Re: [rules-users] [JBRULES-3703] Error parsing negative numbers in decision table
by metatech
Hi,
(Attempt #2 after registering to the mailing list ...).
For some reason, I do not have permission to add a comment in JIRA.
Please add this answer in a comment on the case JBRULES-3703. Thanks.
===============
The reason of the exception is because the number is treated as a float, ie
"-1.0".
The workaround is to add a single quote before the number and it will work.
===============
Lubos Pechac wrote
> Compiling attached .xls table results in exception, K12 column contains
> "-1". This worked in drools 5.0.1
> org.drools.template.parser.DecisionTableParseException: Priority is not an
> integer literal, in cell K12
> at
> org.drools.decisiontable.parser.DefaultRuleSheetListener.nextDataCell(DefaultRuleSheetListener.java:607)
--
View this message in context: http://drools.46999.n3.nabble.com/Re-JBRULES-3703-Error-parsing-negative-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
Heap space
by André Fróes
Hello! After trying cloudComputer example i'm trying to implement my own
schedule distributor, but now i'm facing heap space error, but i see that
it does distribute some work orders. Here's the console error:
-------------------
17:05:02.776 [main] INFO o.d.p.core.solver.DefaultSolver - Solving
started: time spend (255), score (null), new best score (null), random seed
(0).
17:05:02.821 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -
Step index (0), time spend (309), score (0hard/0soft), initialized planning
entity ([Engineer-5]).
17:05:02.822 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -
Step index (1), time spend (310), score (0hard/0soft), initialized planning
entity ([Engineer-4]).
17:05:02.824 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -
Step index (2), time spend (311), score (0hard/0soft), initialized planning
entity ([Engineer-3]).
17:05:02.824 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -
Step index (3), time spend (312), score (0hard/0soft), initialized planning
entity ([Engineer-2]).
17:05:02.825 [main] DEBUG o.d.p.c.c.g.DefaultGreedyFitSolverPhase -
Step index (4), time spend (313), score (0hard/0soft), initialized planning
entity ([Engineer-1]).
17:05:02.825 [main] INFO o.d.p.c.c.g.DefaultGreedyFitSolverPhase - Phase
constructionHeuristic ended: step total (5), time spend (313), best score
(0hard/0soft).
17:05:03.020 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -
Step index (0), time spend (508), score (0hard/0soft), best score
(0hard/0soft), accepted/selected move count (1000/1000) for picked step
([Engineer-3] => [WorkOrder-12]).
17:05:03.315 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -
Step index (1), time spend (803), score (0hard/0soft), best score
(0hard/0soft), accepted/selected move count (1000/1703) for picked step
([Engineer-4] => [WorkOrder-8]).
17:05:03.736 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -
Step index (2), time spend (1224), score (0hard/0soft), best score
(0hard/0soft), accepted/selected move count (1000/2657) for picked step
([Engineer-1] => [WorkOrder-8]).
17:05:03.951 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -
Step index (3), time spend (1439), score (0hard/0soft), best score
(0hard/0soft), accepted/selected move count (1000/4315) for picked step
([Engineer-5] => [WorkOrder-9]).
17:05:04.251 [main] DEBUG o.d.p.c.l.DefaultLocalSearchSolverPhase -
Step index (4), time spend (1739), score (0hard/0soft), best score
(0hard/0soft), accepted/selected move count (1000/9309) for picked step
([Engineer-2] => [WorkOrder-9]).
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.util.Arrays.copyOf(Unknown Source)
at java.util.ArrayList.grow(Unknown Source)
at java.util.ArrayList.ensureCapacityInternal(Unknown Source)
at java.util.ArrayList.add(Unknown Source)
at
org.drools.planner.core.localsearch.decider.forager.AcceptedForager.addToMaxScoreUnacceptedList(AcceptedForager.java:143)
at
org.drools.planner.core.localsearch.decider.forager.AcceptedForager.addMove(AcceptedForager.java:101)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.processMove(DefaultDecider.java:164)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.doMove(DefaultDecider.java:144)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.decideNextStep(DefaultDecider.java:116)
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolverPhase.solve(DefaultLocalSearchSolverPhase.java:62)
at
org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:190)
at
org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:155)
at com.swa.planner.domain.WorkOrderTest.main(WorkOrderTest.java:66)
------------------------
it does distribute some engineers to work orders, but after a while, it
just show the error.
The drl is very simple:
--------------------------
import
org.drools.planner.core.score.buildin.hardandsoft.HardAndSoftScoreHolder;
import org.drools.planner.core.score.constraint.IntConstraintOccurrence;
import org.drools.planner.core.score.constraint.ConstraintType;
import com.swa.planner.domain.Distributor;
import com.swa.planner.domain.Engineer;
import com.swa.planner.domain.WorkOrder;
global HardAndSoftScoreHolder scoreHolder;
rule "requiredTimeToFinish"
when
$workOrder : WorkOrder($time : time)
$requiredTimeTotal : Number(intValue > $time) from accumulate(
Engineer (
workOrder == $workOrder,
$requiredTime : worktime),
sum($requiredTime)
)
then
insertLogical(new IntConstraintOccurrence("requiredTimeToFinish",
ConstraintType.NEGATIVE_HARD,
$requiredTimeTotal.intValue() - $time,
$workOrder));
end
rule "hardConstraintBroken"
salience -1
when
$hardTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType == ConstraintType.NEGATIVE_HARD,
$weight : weight)
sum($weight)
)
then
scoreHolder.setHardConstraintsBroken($hardTotal.intValue());
end
--------------------------
i guess no error there, i believe that i'm missing when doing the strenght
and difficulty comparators dince i didn't really understood the
getMultiplicand thing of CloudComputer.
here's the implementation, also kept as simple as possible (and probably
wrong):
------------
public class WorkOrderStrengthComparator implements Comparator<WorkOrder> {
public int compare(WorkOrder a, WorkOrder b) {
return new CompareToBuilder().append(a.getTime(), b.getTime())
.append(b.getId(), a.getId())
.toComparison();
}
}
------------
public class EngineerDifficultyComparator implements Comparator<Engineer> {
public int compare(Engineer a, Engineer b) {
return new CompareToBuilder().append(a.getWorktime(), b.getWorktime())
.append(a.getId(), b.getId())
.toComparison();
}
}
------------
i'm missing something at these comparators ain't I?
11 years, 10 months