Re: [rules-users] conways game of life

2007-04-16 Thread Michael Neale

Its interesting, Conways game of life was created to demonstrate a
"determinisitc universe" - if you think as the little "critters" as life
forms its pretty cool. A good example of how very very simple rules (and
only a small number) can create complex behaviour.



On 4/17/07, Mark Proctor <[EMAIL PROTECTED]> wrote:


I have just moved Jeff Brown's "Conways Game of Life" to a stateful
example, this is now the best place to look to understand jboss rules.
It's also good to compare this stateful implementation to the old
stateless version. Trunk introduces a new feature to help deal with
recursion "lock-on-active" which stops a rule being able to create
activations while it's agenda-group/rule-flow-group has focus - so it's
a much stronger no-loop. Probably the most important thing this example
shows is how to think relationally, the old example used nested
properties and sets to maintain the "neighbour" information; this
example shows how to achieve the same but expressing it relationally,
using the Neighbor relation class, further it shows how we can exploit
the the cross-product relational information to drive the engine without
us having to write loops. Currently the example is using agenda-groups
to drive execution flow, I'm now in the process of moving this to
rule-flow-groups.

You'll need trunk to be able to run this, so checkout:
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/
Make sure you have maven 2.0.6 installed and then type the following
from the root directory:
mvn clean install -Declipse=true
The eclipse plugin will now be built in the drools-eclipse/target
directory, so open that up and unzip into your eclipse install (make
sure you use -clean to start eclipse). Then import drools-examples and
"run as application" the ConwayGUI class.

I plan to do a blog or two on how this exampe works, and my next
challenge will be to migrate the pacman game to jboss rules.

Mark

--
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire,
SI4 1TE, United Kingdom.
Registered in UK and Wales under Company Registration No. 3798903
Directors: Michael Cunningham (USA), Charlie Peters (USA) and David
Owens (Ireland)



package org.drools.examples

import org.drools.examples.conway.Cell;
import org.drools.examples.conway.CellGrid;
import org.drools.examples.conway.Neighbor;
import org.drools.examples.conway.Phase;
import org.drools.examples.conway.CellState;

import org.drools.WorkingMemory;
import org.drools.common.InternalWorkingMemoryActions;
import org.drools.RuleBase;


rule "register north east"
agenda-group "register neighbor"
when
CellGrid( $numberOfColumns : numberOfColumns )
$cell: Cell( $row : row > 0, $col : col < ( $numberOfColumns - 1 )
)
$northEast : Cell( row  == ($row - 1), col == $col )
then
assert( new Neighbor( $cell, $northEast ) );
assert( new Neighbor( $northEast, $cell ) );
end

rule "register north"
agenda-group "register neighbor"
when
$cell: Cell( $row : row > 0, $col : col )
$north : Cell( row  == ($row - 1), col == $col )
then
assert( new Neighbor( $cell, $north ) );
assert( new Neighbor( $north, $cell ) );
end

rule "register north west"
agenda-group "register neighbor"
when
$cell: Cell( $row : row > 0, $col : col > 0 )
$northWest : Cell( row  == ($row - 1), col == ( $col - 1 ) )
then
assert( new Neighbor( $cell, $northWest ) );
assert( new Neighbor( $northWest, $cell ) );
end

rule "register west"
agenda-group "register neighbor"
when
$cell: Cell( $row : row > 0, $col : col > 0 )
$west : Cell( row  == $row, col == ( $col - 1 ) )
then
assert( new Neighbor( $cell, $west ) );
assert( new Neighbor( $west, $cell ) );
end

rule "Kill The Lonely"
agenda-group "evaluate"
no-loop
when
#   A live cell has fewer than 2 live neighbors
theCell: Cell(liveNeighbors < 2, cellState == CellState.LIVE,
phase == Phase.EVALUATE)
then
theCell.setPhase(Phase.KILL);
modify( theCell );
end

rule "Kill The Overcrowded"
agenda-group "evaluate"
no-loop
when
#   A live cell has more than 3 live neighbors
theCell: Cell(liveNeighbors > 3, cellState == CellState.LIVE,
phase == Phase.EVALUATE)
then
theCell.setPhase(Phase.KILL);
modify( theCell );
end

rule "Give Birth"
agenda-group "evaluate"
no-loop
when
#   A dead cell has 3 live neighbors
theCell: Cell(liveNeighbors == 3, cellState == CellState.DEAD,
phase == Phase.EVALUATE)
then
theCell.setPhase(Phase.BIRTH);
modify( theCell );
end

rule "reset calculate"
agenda-group "reset calculate"
when
then
WorkingMemory wm = drools.getWorkingMemory();
wm.getAgenda().clearAgendaGroup( "calculate" );
end

rule "kill"
agenda-group "kill"
no-loop
when
theCell: Cell(phase == Phase.KILL)
then

Re: [rules-users] JBoss Rules IDE 3.1-M1 - Validating all *.xls files in source path?

2007-04-16 Thread Michael Neale

Hi Bree.

Well, thats a new thing Kris threw in - cause people were asking for it. It
should only validate ones in the rules project itself - I assume that is
what you mean?

If this is a problem for you, could you create a JIRA and state your case?
it may be a case of having an optional config dialog to setup where .xls may
live and where they dont.

Regards,

Michael.

On 4/17/07, Bree VanOss <[EMAIL PROTECTED]> wrote:


Hi,

I've started looking at the JBoss Rules 3.1-M1 Eclipse plugin to get an
idea of how much migration work I have to look forward to.

The first issue I ran into is that it appears the Drools Builder is
validating every Excel (.xls) file I have in my source path. Is this a
design decision and if so, how can I "hide" non-decision table .xls files
from the Drools builder? I've tried excluding them from the Eclipse Source
Path using a "source exclusion rule", but that didn't seem to work.

Thanks,

Bree



___
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] column contraint + java bean

2007-04-16 Thread Mark Proctor
with predicate or evals, or preferably try and write your information 
relationally not nested.


Mark
[EMAIL PROTECTED] wrote:

hi all,

having trouble with Drools 3.x syntax.

currently using one fact in working memory that is a aggregate of many
java beans. However when using the column constraint syntax it does not
seem to allow nested getXXX on the column constraint.

I have it working using predicate but it just seems verbose.

i would like to be able to fire rule when
the table object has a player count > 0  and the Table.getDealer.getFlop()
== null

how is this done on Drools 3.x?



ie.

public class Table{

int playerCount;
Dealer dealer;
Collection players;


}


rule "start"
no-loop true
when
table : Table( playerCount > 0 , dealerFlop :
dealer->(dealerFlop.getFlop() == null ) )
then
System.out.println( "start:" + table.getDealer().getFlop() );
end


many thanks

-lp


___
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] column contraint + java bean

2007-04-16 Thread lucio
hi all,

having trouble with Drools 3.x syntax.

currently using one fact in working memory that is a aggregate of many
java beans. However when using the column constraint syntax it does not
seem to allow nested getXXX on the column constraint.

I have it working using predicate but it just seems verbose.

i would like to be able to fire rule when
the table object has a player count > 0  and the Table.getDealer.getFlop()
== null

how is this done on Drools 3.x?



ie.

public class Table{

int playerCount;
Dealer dealer;
Collection players;


}


rule "start"
no-loop true
when
table : Table( playerCount > 0 , dealerFlop :
dealer->(dealerFlop.getFlop() == null ) )
then
System.out.println( "start:" + table.getDealer().getFlop() );
end


many thanks

-lp


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] JBoss Rules IDE 3.1-M1 - Validating all *.xls files in source path?

2007-04-16 Thread Bree VanOss

Hi,

I've started looking at the JBoss Rules 3.1-M1 Eclipse plugin to get an idea
of how much migration work I have to look forward to.

The first issue I ran into is that it appears the Drools Builder is
validating every Excel (.xls) file I have in my source path. Is this a
design decision and if so, how can I "hide" non-decision table .xls files
from the Drools builder? I've tried excluding them from the Eclipse Source
Path using a "source exclusion rule", but that didn't seem to work.

Thanks,

Bree
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] conways game of life

2007-04-16 Thread Mark Proctor

I have just moved Jeff Brown's "Conways Game of Life" to a stateful
example, this is now the best place to look to understand jboss rules.
It's also good to compare this stateful implementation to the old
stateless version. Trunk introduces a new feature to help deal with
recursion "lock-on-active" which stops a rule being able to create
activations while it's agenda-group/rule-flow-group has focus - so it's
a much stronger no-loop. Probably the most important thing this example
shows is how to think relationally, the old example used nested
properties and sets to maintain the "neighbour" information; this
example shows how to achieve the same but expressing it relationally,
using the Neighbor relation class, further it shows how we can exploit
the the cross-product relational information to drive the engine without
us having to write loops. Currently the example is using agenda-groups
to drive execution flow, I'm now in the process of moving this to
rule-flow-groups.

You'll need trunk to be able to run this, so checkout:
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/
Make sure you have maven 2.0.6 installed and then type the following
from the root directory:
mvn clean install -Declipse=true
The eclipse plugin will now be built in the drools-eclipse/target
directory, so open that up and unzip into your eclipse install (make
sure you use -clean to start eclipse). Then import drools-examples and
"run as application" the ConwayGUI class.

I plan to do a blog or two on how this exampe works, and my next
challenge will be to migrate the pacman game to jboss rules.

Mark

--
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod 
Street, Windsor, Berkshire,

SI4 1TE, United Kingdom.
Registered in UK and Wales under Company Registration No. 3798903
Directors: Michael Cunningham (USA), Charlie Peters (USA) and David 
Owens (Ireland)



package org.drools.examples
 
import org.drools.examples.conway.Cell;
import org.drools.examples.conway.CellGrid;
import org.drools.examples.conway.Neighbor;
import org.drools.examples.conway.Phase;
import org.drools.examples.conway.CellState;

import org.drools.WorkingMemory;
import org.drools.common.InternalWorkingMemoryActions;
import org.drools.RuleBase;


rule "register north east"
agenda-group "register neighbor"
when
CellGrid( $numberOfColumns : numberOfColumns )
$cell: Cell( $row : row > 0, $col : col < ( $numberOfColumns - 1 ) )

$northEast : Cell( row  == ($row - 1), col == $col )
then
assert( new Neighbor( $cell, $northEast ) );
assert( new Neighbor( $northEast, $cell ) );
end

rule "register north"
agenda-group "register neighbor"
when
$cell: Cell( $row : row > 0, $col : col )   
$north : Cell( row  == ($row - 1), col == $col )
then
assert( new Neighbor( $cell, $north ) );
assert( new Neighbor( $north, $cell ) );
end

rule "register north west"
agenda-group "register neighbor"
when
$cell: Cell( $row : row > 0, $col : col > 0 )   
$northWest : Cell( row  == ($row - 1), col == ( $col - 1 ) )

then
assert( new Neighbor( $cell, $northWest ) );
assert( new Neighbor( $northWest, $cell ) );
end

rule "register west"
agenda-group "register neighbor"
when
$cell: Cell( $row : row > 0, $col : col > 0 )   
$west : Cell( row  == $row, col == ( $col - 1 ) )   

then
assert( new Neighbor( $cell, $west ) );
assert( new Neighbor( $west, $cell ) ); 
end

rule "Kill The Lonely"
agenda-group "evaluate"
no-loop
when
#   A live cell has fewer than 2 live neighbors
theCell: Cell(liveNeighbors < 2, cellState == CellState.LIVE, phase == 
Phase.EVALUATE)
then
theCell.setPhase(Phase.KILL);
modify( theCell );
end

rule "Kill The Overcrowded"
agenda-group "evaluate"
no-loop
when
#   A live cell has more than 3 live neighbors
theCell: Cell(liveNeighbors > 3, cellState == CellState.LIVE, phase == 
Phase.EVALUATE)
then
theCell.setPhase(Phase.KILL);
modify( theCell );
end

rule "Give Birth"
agenda-group "evaluate"
no-loop
when
#   A dead cell has 3 live neighbors
theCell: Cell(liveNeighbors == 3, cellState == CellState.DEAD, phase == 
Phase.EVALUATE)
then
theCell.setPhase(Phase.BIRTH);
modify( theCell );
end

rule "reset calculate"
agenda-group "reset calculate"
when
then
WorkingMemory wm = drools.getWorkingMemory();
wm.getAgenda().clearAgendaGroup( "calculate" );
end

rule "kill"
agenda-group "kill"
no-loop
when
theCell: Cell(phase == Phase.KILL)
then
 

RE: [rules-users] many response

2007-04-16 Thread Anstis, Michael \(M.\)
You need to remember that a rule runs every time the patterns are matched. 
 
For example:-
 
rule "example"
when
$a : ObjectA()
$b : ObjectB()
then
System.out.println("Rule 'example' ran");
end
 
Working Memory:-
 
1 - ObjectA
2 - ObjectA
3 - ObjectB
4 - ObjectB
 
The rule will run four times; once for each combination of ObjectA and ObjectB 
(1, 3) (1, 4) (2, 3) and (2, 4).
 
Object models are flattened in Working Memory so if you need to impose a 
relationship you need to add this to the rule. For example:-
 
[one-to-one mapping] ObjectA has one child ObjectB.
Method suggestion (returns an instance of ObjectB): ObjectA.getObjectB();
 
rule "example"
when
$b : ObjectB()
$a : ObjectA(objectB == $b)
then
System.out.println("Rule 'example' ran");
end
 
[one-to-many mapping] ObjectA has many child ObjectB.
Method suggestion (returns a List): ObjectA.getObjectBs(); 
 
rule "example"
when
$b : ObjectB()
$a : ObjectA(objectBs contains $b)
then
System.out.println("Rule 'example' ran");
end
 
Check that this is not the cause of your multiple unexpected executions.
 
With kind regards,
 
Mike
 




From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of fakhfakh 
ismail
Sent: 13 April 2007 18:22
To: jboss rules
Subject: [rules-users] many response


Hello,
First sorry for my bad english
when I execute a regle I get many response I don't know why?
Example:

rule "userrole"


when

user1: BnUserValue(nameuser : name)
and
Role : BnRoleValue()
and
ActiviteOut : BnNodeValue(bnRole == Role,executor == nameuser )
and
ActiviteIn : BnNodeValue(bnRole == Role )
and 
lien: BnEdgeValue(outBnNode == ActiviteOut,inBnNode ==ActiviteIn )

then

System.out.println("cette personne "+user1.getName()+ " ne peut pas 
executer cette activiter");

end
 
the execution result

cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
 
 
 
so the result is repeat 6 I don't know why?
thank for your help
Ismail
 
 
 
 
 




Découvrez une nouvelle façon d'obtenir des réponses à toutes vos 
questions ! Profitez des connaissances, des opinions et des expériences des 
internautes sur Yahoo! Questions/Réponses 
 .

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users