[rules-users] List wrongly coerced to Object

2012-03-20 Thread aitchnyu
I want to compare two List's if they have elements in common. I made
the following rule (actually two of them):

*rule*
rule "hardConflictIsIn"
when
$hc : HardConstraint(
$attribute  : attribute,
operator == "is in",
$values : strAttributeValue,
$period : period
)
$stp : SubjectTeacherPeriod(
period == $period,
//Collections.disjoint( 
$t.attributes["tags"], values_list)
eval( Collections.disjoint( 
*strAttributeMap.get($attribute)*,
$values) == false )
)
then
insertLogical(new IntConstraintOccurrence("hardConflictIsIn", 
ConstraintType.NEGATIVE_HARD,1,
$hc,$stp));
end

*rule*

But I get the following error:

*error*
Exception in thread "main" java.lang.IllegalStateException: There are errors
in the scoreDrl's:
Rule Compilation error : [Rule name='hardConflictNotIn']

in/co/technovia/timetabler/domain/Rule_hardConflictNotIn_8b50378322e744d883618db9941a8e66.java
(9:1204) : The method disjoint(Collection, Collection) in the type
Collections is not applicable for the arguments (*Object*, List)

Rule Compilation error : [Rule name='hardConflictIsIn']

in/co/technovia/timetabler/domain/Rule_hardConflictIsIn_d7f4ca0884754cf894e7cbdb96cee30e.java
(9:1203) : The method disjoint(Collection, Collection) in the type
Collections is not applicable for the arguments (Object, List)


at
org.drools.planner.config.solver.SolverConfig.buildRuleBase(SolverConfig.java:238)
at
org.drools.planner.config.solver.SolverConfig.buildSolver(SolverConfig.java:170)
at
org.drools.planner.config.XmlSolverConfigurer.buildSolver(XmlSolverConfigurer.java:103)
at
in.co.technovia.timetabler.TimeTableApp.createSolver(TimeTableApp.java:61)
at in.co.technovia.timetabler.TimeTableApp.main(TimeTableApp.java:45)
*error*

So something get'ted from the map SubjectTeacherPeriod.strAttributeMap is
wrongly coerced to an Object? I defined my SubjectTeacherPeriod class this
way:

*class snippet*

public class SubjectTeacherPeriod{
...
private Map num_attribute_map = new HashMap();
private Map> str_attribute_map = new
HashMap>();
...
public Map> getStrAttributeMap(){
return this.str_attribute_map;
}
...

*class snippet*

How can I fix this?

--
View this message in context: 
http://drools.46999.n3.nabble.com/List-String-wrongly-coerced-to-Object-tp3844867p3844867.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] why java.util.Map doesn't work on RHS update

2012-03-20 Thread laune
Read the definition of lock-on-active: it inhibits the firing of your second
rule.

It is almost certainly a bad idea to use Map objects like this. Beans are
much better suited, as you could write rules such as

when
   MyType( year == 2012, state == null )
then
   modify(...)

-W

--
View this message in context: 
http://drools.46999.n3.nabble.com/why-java-util-Map-doesn-t-work-on-RHS-update-tp3831626p3844865.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Cant check complex boolean expressions with Collections.disjoint

2012-03-20 Thread aitchnyu
You are right. I have to wrap any expression that returns a boolean value
with eval(). Thanks.

eval(Collections.disjoint(strAttributeMap[$attribute], $values) == true)

--
View this message in context: 
http://drools.46999.n3.nabble.com/Cant-check-complex-boolean-expressions-with-Collections-disjoint-tp3842259p3844761.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] fireUntilHalt is doing busy wait and consuming 100% of one CPU core

2012-03-20 Thread prashant.badhe
Observed this on Drools 5.1.1 final when fireUntilHalt() is used.

The issue is reported as 'Resolved' in post:
"https://issues.jboss.org/browse/JBRULES-2756"; in Drools 5.2.0 M1.

So tried the same on Drools 5.2.0 final & 5.2.0 M1. Also when I try to make
the recommended code changes in drools-core in Jira-2756, the issue seems to
me as not fixed. In all these cases, the system consumes 100% resources of
one CPU core.

Please let me know does this issue is resolved or not in the latter versions
of Drools?

-Prashant Badhe



--
View this message in context: 
http://drools.46999.n3.nabble.com/fireUntilHalt-is-doing-busy-wait-and-consuming-100-of-one-CPU-core-tp3844714p3844714.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Trouble with the MVEL Map syntax

2012-03-20 Thread barnesjd
Correction I didn't paste the whole function the second time.  I do have
a return for the else...

/function int englishToInt(String englishNumber)
{
Map m = ["one":1, "two":2, "three":3, "four":4, "five":5];
Object obj = m.get(englishNumber.toLowerCase());

if(obj != null)
return Integer.parseInt(obj.toString());
else
return -1;
}/


--
View this message in context: 
http://drools.46999.n3.nabble.com/Trouble-with-the-MVEL-Map-syntax-tp3844609p3844617.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Trouble with the MVEL Map syntax

2012-03-20 Thread barnesjd
I'm interested in using the 
http://mvel.codehaus.org/Inline+List,+Maps+and+Arrays compact syntax
available for Maps in MVEL , but I can't quite get it right.  I am
attempting to write a simple function to convert English numbers (i.e.
"one", "two", etc) to the integer value.  This is how I would LIKE it to
work:

/function int englishToInt(String englishNumber)
{
return ["one":1, "two":2, "three":3, "four":4,
"five":5].get(englishNumber.toLowerCase());
}/

The closest I've gotten to having it work is this:

/function int englishToInt(String englishNumber)
{
Map m = ["one":1, "two":2, "three":3, "four":4, "five":5];
Object obj = m.get(englishNumber.toLowerCase());

if(obj != null)
return Integer.parseInt(obj.toString());
}/

But I get this rather unhelpful error message:
/
Error importing : 'defaultpkg.EnglishToInt.englishToInt'
[ function englishToIntenglishToInt (line:7): Syntax error on tokens, delete
these tokens
 ]/

... What tokens?? lol

Thanks,
Joe


--
View this message in context: 
http://drools.46999.n3.nabble.com/Trouble-with-the-MVEL-Map-syntax-tp3844609p3844609.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools silently fails when I screw up

2012-03-20 Thread barnesjd
Thanks again for the help!  But for future viewers of the thread, I believe
you meant KnowledgeBuilder not KnowledgeBase.  The latter does not have a
hasErrors() method whereas the former does.  It's also worth point out that
it has a getErrors() which you can call toString() on.

Joe


--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-silently-fails-when-I-screw-up-tp3839290p3844576.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] why java.util.Map doesn't work on RHS update

2012-03-20 Thread vadlam
additionally, a no-loop attribute =true might be required to avoid going into
a loop

-
Ram
--
View this message in context: 
http://drools.46999.n3.nabble.com/why-java-util-Map-doesn-t-work-on-RHS-update-tp3831626p3843833.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] why java.util.Map doesn't work on RHS update

2012-03-20 Thread vadlam
can you try modify instead of update in the first rule  as

modify($m); instead of update($m);

modify as I understand does update and insert.
 
without modify, the changes done in first rule are not visible to other
rules


--
View this message in context: 
http://drools.46999.n3.nabble.com/why-java-util-Map-doesn-t-work-on-RHS-update-tp3831626p3843778.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Doubt when modifying facts on an action

2012-03-20 Thread vadlam
when we had a similar need, we specified a condition pattern something like
Customer(nonnullfield!=null) in order to use that in the action part.

however, the updates done in the action part were not visible to subsequent
rules in the ruleflow.

so, we had to getObjects and insert the updated Customer back into the
rulessession for the other rules to see the updated values. 

the other option that might have worked ( we did not try it) would be to
specify modify in the action part  

--
View this message in context: 
http://drools.46999.n3.nabble.com/Doubt-when-modifying-facts-on-an-action-tp3831681p3843770.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Knowing which constraints are broken for final best solution in drools-planner

2012-03-20 Thread maraoz
Hi! I'm new to this forum so... my name is Manuel and I'm using drools
planner to solve an exam scheduling problem :) 

I need to analyze which constraints are broken while the algorithm is
running and when the solver finishes also. Geoffrey pointed me to the
examples, where that is done. 

I copied the getScoreDetailList() idea from that example, and it works
perfectly fine for when the algorithm is running (constraints are found and
I can inspect them). The basic idea is that this method obtains the working
memory and obtains from it the objects of type ConstraintOccurrence. 

The thing is, when the solver finishes and I call this method, it returns no
constraints, even though I know by the score that some constraints are still
broken. Am I doing something wrong? Or is this the expected behaviour? It
seems as if working memory erases the ConstraintOccurrences when the solver
finishes, but I don't really know. In that case, how can I obtain the
constraints broken for the final solution? 

Hope I made myself clear! Thanks! 

--
View this message in context: 
http://drools.46999.n3.nabble.com/Knowing-which-constraints-are-broken-for-final-best-solution-in-drools-planner-tp3843765p3843765.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Knowing which constraints are broken for final best solution in drools-planner

2012-03-20 Thread Manuel Aráoz
Hi! I'm new to this forum so... my name is Manuel and I'm using drools
planner to solve an exam scheduling problem :)

I need to analyze which constraints are broken while the algorithm is
running and when the solver finishes also. Geoffrey pointed me to the
examples, where that is done.

I copied the getScoreDetailList() idea from that example, and it works
perfectly fine for when the algorithm is running (constraints are found and
I can inspect them). The basic idea is that this method obtains the working
memory and obtains from it the objects of type ConstraintOccurrence.

The thing is, when the solver finishes and I call this method, it returns
no constraints, even though I know by the score that some constraints are
still broken. Am I doing something wrong? Or is this the expected
behaviour? It seems as if working memory erases the ConstraintOccurrences
when the solver finishes, but I don't really know. In that case, how can I
obtain the constraints broken for the final solution?

Hope I made myself clear! Thanks!
Manuel
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Create a deep copy of KnowledgeAgent

2012-03-20 Thread srinivasasanda
Hi One and All,

To over come from 

Knowledge agent rebuilding knowledge base with scanner/notifier does not
work with declared fact caused
java.lang.ClassCastException when change rule condition and declarative
facts/events are used

1. I had a method which creates and loads the knowledge Agent.

2. I had a another method to execute rules which uses step 1 knowledge agent
(work on infinite loop)

3. Using knowledge Agent Event listener  for method afterChangeSetApplied()
again i newly create and load knowledge agent.

4. while loading again got same error.

Note:  Can u please help me to create deep copy of knowledge agent which
does not have references, i.e when i update rules the changes show not it
should not be affected it should run with old copy.
using java object clone method i can create deep copy  but clone is not
available for Knowledge agent.

Thanks & Regards
Srinivasa sanda

--
View this message in context: 
http://drools.46999.n3.nabble.com/Create-a-deep-copy-of-KnowledgeAgent-tp3842432p3842432.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Metadata in Guvnor-created rules

2012-03-20 Thread Michael Anstis
Hell yeah - we always like receiving Community Contributions :)

I had a quick look at the code and it'll probably be more than a couple of
days (especially as you'd need to presumably get up to speed too?)

Depending on what meta-data you want there are different steps, but the
gist is to expose org.drools.guvnor.client.rpc.MetaData (constructed from
an AssetItem, retrieved from the Repository, and normally only sent to the
client-side) to the ContentHandlers' compile method. We could use the
AssetItem direct, but alot of the meta-data (especially Categories) is more
easily accessed if we populate MetaData. ContentHandlers build the various
DRL's - these would all need changing too to accept MetaData and (depending
on whether the auto-inclusion is enabled) add the Metadata.

Feel free to come along to #guvnor IRC channel for a chat.

You'd probably need to read
thistoo.

With kind regards,

Mike

On 20 March 2012 12:07,  wrote:

> So you might be up for adding the functionality to the platform if I build
> it? I don't suppose you have any vague guesses at how long it might take
> for me to develop this functionality, given that I haven't contributed
> anything to the project yet? If you reckon it could be just 2 or 3 days
> effort then it sounds like I should be able to log project time to build
> it, as it would be valuable to my current client.
>
> Steve
>
>
> On Mar 19, 2012, at 10:02 PM, Michael Anstis 
> wrote:
>
> The "Metadata" under the "Attributes" tab is stored in the JCR repository
> and does not form part of the KnowledgeBase.
>
> You can add metadata that is part of the KnowledgeBase using using the
> "Show options" at the bottom of the Guided Rule Editor and adding metadata.
>
> This metadata appears in rules as (for example) @mymetadata and AFAIK is
> part of the rule metadata accessible from the droolsjbpm-knowledge API.
>
> Unfortunately there is no way to link the two; however it is a reasonably
> simple requirement and I'll happily mentor you to help with a Pull Request.
>
> With kind regards,
>
> Mike
>
> On 19 March 2012 17:30, Stephen Masters  wrote:
>
>> Hi folks,
>>
>> I'm curious about what metadata should be on a rule when created in
>> Guvnor. I was assuming that any of the metadata fields shown under the
>> "Attributes" tab should be available as metadata items when the rule gets
>> activated. i.e. Title, categories, Created date, etc...
>>
>> However, when I call event.getActivation().getRule().getMetaData() on an
>> AfterActivationFiredEvent, the map returned is completely empty.
>>
>> Or is the "metadata" for a rule in Guvnor not the same thing? I was
>> rather hoping to be able to take note of the categories of each rule that
>> fires.
>>
>> fyi ... I'm using 5.3.0.Final.
>>
>> Thanks for any assistance you can provide.
>>
>> Steve
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Cant check complex boolean expressions with Collections.disjoint

2012-03-20 Thread Wolfgang Laun
If it's a Java boolean expression you must use eval(), s.th. like this

   eval( ! Collections.disjoint($stp.getStrAttributeMap()[$attribute],
$values) )

Note that you'll have write this expression as in Java; I don't know
how the getter for attribute map works.

-W



On 20/03/2012, aitchnyu  wrote:
> I have a `SubjectTeacherPeriod` object which has a property
> `strAttributeMap`
> which is a map of `String` and `List`. I want to check if
> `HardConstraint.strAttributeValue` and
> `SubjectTeacherPeriod.strAttributeMap[$attribute]` *intersect*. Here is the
> rule:
>
> rule "hardConflictIsIn"
> when
>   $hc : HardConstraint(
>   $attribute  : attribute,
>   operator == "is in",
>   $values : strAttributeValue,
>   $period : period
>   )
>   $stp : SubjectTeacherPeriod(
>   period == $period,
>   //ERROR IN FOLLOWING LINE
>   
> Collections.disjoint(strAttributeMap[$attribute], $values) ==
> false
>   )
> then
>   insertLogical(new IntConstraintOccurrence("hardConflictIsIn",
>   ConstraintType.NEGATIVE_HARD,1,
> $hc,$stp));
> end
>
> But the rule (actually two of them) throws the error:
>
> Exception in thread "main" java.lang.IllegalStateException: There are errors
> in the scoreDrl's:
> Unable to Analyse Expression
> Collections.disjoint(strAttributeMap[$attribute], $values) == false:
> sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast
> to java.lang.Class : [Rule name='hardConflictIsIn']
>
> Unable to Analyse Expression
> Collections.disjoint(strAttributeMap[$attribute], $values) == true:
> sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast
> to java.lang.Class : [Rule name='hardConflictNotIn']
>
>
>   at
> org.drools.planner.config.solver.SolverConfig.buildRuleBase(SolverConfig.java:238)
>   at
> org.drools.planner.config.solver.SolverConfig.buildSolver(SolverConfig.java:170)
>   at
> org.drools.planner.config.XmlSolverConfigurer.buildSolver(XmlSolverConfigurer.java:103)
>   at
> in.co.technovia.timetabler.TimeTableApp.createSolver(TimeTableApp.java:61)
>   at in.co.technovia.timetabler.TimeTableApp.main(TimeTableApp.java:45)
>
> I got it from an answer from my own question at
> http://stackoverflow.com/a/9241089/604511 . Is this a bug in Drools itself?
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Cant-check-complex-boolean-expressions-with-Collections-disjoint-tp3842259p3842259.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Cant check complex boolean expressions with Collections.disjoint

2012-03-20 Thread aitchnyu
I have a `SubjectTeacherPeriod` object which has a property `strAttributeMap`
which is a map of `String` and `List`. I want to check if
`HardConstraint.strAttributeValue` and
`SubjectTeacherPeriod.strAttributeMap[$attribute]` *intersect*. Here is the
rule:

rule "hardConflictIsIn"
when
$hc : HardConstraint(
$attribute  : attribute,
operator == "is in",
$values : strAttributeValue,
$period : period
)
$stp : SubjectTeacherPeriod(
period == $period,
//ERROR IN FOLLOWING LINE

Collections.disjoint(strAttributeMap[$attribute], $values) ==
false
)
then
insertLogical(new IntConstraintOccurrence("hardConflictIsIn", 
ConstraintType.NEGATIVE_HARD,1,
$hc,$stp));
end

But the rule (actually two of them) throws the error:

Exception in thread "main" java.lang.IllegalStateException: There are errors
in the scoreDrl's:
Unable to Analyse Expression
Collections.disjoint(strAttributeMap[$attribute], $values) == false:
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast
to java.lang.Class : [Rule name='hardConflictIsIn']

Unable to Analyse Expression
Collections.disjoint(strAttributeMap[$attribute], $values) == true:
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast
to java.lang.Class : [Rule name='hardConflictNotIn']


at
org.drools.planner.config.solver.SolverConfig.buildRuleBase(SolverConfig.java:238)
at
org.drools.planner.config.solver.SolverConfig.buildSolver(SolverConfig.java:170)
at
org.drools.planner.config.XmlSolverConfigurer.buildSolver(XmlSolverConfigurer.java:103)
at
in.co.technovia.timetabler.TimeTableApp.createSolver(TimeTableApp.java:61)
at in.co.technovia.timetabler.TimeTableApp.main(TimeTableApp.java:45)

I got it from an answer from my own question at
http://stackoverflow.com/a/9241089/604511 . Is this a bug in Drools itself?

--
View this message in context: 
http://drools.46999.n3.nabble.com/Cant-check-complex-boolean-expressions-with-Collections-disjoint-tp3842259p3842259.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Metadata in Guvnor-created rules

2012-03-20 Thread stephen . masters
So you might be up for adding the functionality to the platform if I build it? I don't suppose you have any vague guesses at how long it might take for me to develop this functionality, given that I haven't contributed anything to the project yet? If you reckon it could be just 2 or 3 days effort then it sounds like I should be able to log project time to build it, as it would be valuable to my current client.SteveOn Mar 19, 2012, at 10:02 PM, Michael Anstis  wrote:The "Metadata" under the "Attributes" tab is stored in the JCR repository and does not form part of the KnowledgeBase.You can add metadata that is part of the KnowledgeBase using using the "Show options" at the bottom of the Guided Rule Editor and adding metadata. This metadata appears in rules as (for example) @mymetadata and AFAIK is part of the rule metadata accessible from the droolsjbpm-knowledge API.Unfortunately there is no way to link the two; however it is a reasonably simple requirement and I'll happily mentor you to help with a Pull Request. With kind regards,MikeOn 19 March 2012 17:30, Stephen Masters  wrote:Hi folks,I'm curious about what metadata should be on a rule when created in Guvnor. I was assuming that any of the metadata fields shown under the "Attributes" tab should be available as metadata items when the rule gets activated. i.e. Title, categories, Created date, etc...However, when I call event.getActivation().getRule().getMetaData() on an AfterActivationFiredEvent, the map returned is completely empty.Or is the "metadata" for a rule in Guvnor not the same thing? I was rather hoping to be able to take note of the categories of each rule that fires.fyi ... I'm using 5.3.0.Final.Thanks for any assistance you can provide.Steve___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users