[rules-users] Problems Extending the Golfer example - Cartesian joins ??

Mark Proctor mproctor at codehaus.org
Fri Jul 20 10:12:00 EDT 2007


we'll look into this to see where the memory is going. but won't be for 
another week or so - I'm currently on holiday.

Mark
Simon French wrote:
> Hi,
> After attending a session with Mark Proctor in London I was inspired 
> to play around with Drools in a slightly different way than we use it 
> for in the workplace, and try and solve a puzzle.
> Unfortunately I couldn't get Drools to solve it as I kept getting 
> memory problems (I believe are cartesian joins being the problem),
> so I decided to extend the golfer example to see if I got the same problem
> I added two new names and a new integer property, club
>
>         // create all possible Golfer objects
>                 String[] names = new String[] { "Fred", "Joe", "Bob", 
> "Tom", "Des", "Terry" };
>                 String[] colors = new String[] { "red", "blue", 
> "plaid", "orange","black", "white" };
>                 int[] positions = new int[] { 1, 2, 3, 4, 5, 6 };
>                 int[] clubs = new int[] {9,8,7,4,5,5};
>                
>                 for ( int n = 0; n < names.length; n++ ) {
>                    for ( int c = 0; c < colors.length; c++ ) {
>                           for ( int p = 0; p < positions.length; p++ ) {
>                               for ( int q = 0; q < clubs.length; q++ ) {
>                                   session.insert(new Golfer( names[n], 
> colors[c], positions[p], clubs[q]) );
>
> ....
>
>
> Then changed the golder.drl to:
>
> package com.sample
>
> import com.sample.Golfer;
>
>
> rule "Golfer Riddle"
>     when
>         // A golfer named Fred,
>        
>         Golfer( name == "Fred",
>                 $fredsPosition : position, $fredsColor : color, 
> $fredsClub : club   )
>
>         // Der Golfer hinter Fred trägt blau
>         Golfer( $unknownsName : name != "Fred",
>                 $unknownsPosition :  position == ( $fredsPosition + 1 ),
>                 $unknownsColor : color == "blue", color != $fredsColor,
>                 $unknownsClub : club == 5 )
>
>         // Joe steht an zweiter Stelle               
>         Golfer( name == "Joe", $joesPosition : position == 2,
>                 position != $fredsPosition,
>                 $joesColor : color != $fredsColor,
>                 $joesClub : club == 5 )
>
>         // Bob traegt Karo       
>         Golfer( name == "Bob",
>                 name != $unknownsName,
>                 $bobsPosition : position != $fredsPosition,
>                 position != $unknownsPosition, position != 
> $joesPosition,                                                 
>                 $bobsColor : color == "plaid",
>                 color != $fredsColor, color != $joesColor,
>                 color != $unknownsColor,
>                 $bobsClub : club < $joesClub )
>
>         // Tom ist nicht 1. oder 4., traegt kein Orange
>         Golfer( $tomsName : name == "Tom",
>                 $tomsPosition : position != 1, position != 4,
>                 position != $fredsPosition, position != $joesPosition,
>                 position != $bobsPosition,                               
>                 $tomsColor : color != "orange", color != "blue",
>                 color != $fredsColor, color != $joesColor,
>                 color != $bobsColor ) 
>
>         Golfer ( $des : name == "Des", $desPosition : position < 
> $fredsPosition, $desColor : color != "blue",
>                 color != $fredsColor, color != $joesColor,
>                 color != $bobsColor )
>         Golfer ( $terry : name == "Terry", $terryPosition : position < 
> $desPosition, $terryColor : color != "blue",
>                 color != $fredsColor, color != $joesColor,
>                 color != $bobsColor )
>     then
>         System.out.println( "Fred " + $fredsPosition + " " + 
> $fredsColor );
>         System.out.println( "Joe " + $joesPosition + " " + $joesColor );
>         System.out.println( "Bob " + $bobsPosition + " " + $bobsColor );
>         System.out.println( "Tom " + $tomsPosition + " " + $tomsColor 
> );  
>         System.out.println ( "Des " + $desPosition + " " + $desColor );  
>         System.out.println( "terry " + $terryPosition + " " + 
> $terryColor );  
> end
>
>
> After a couple of minutes of processing I got:-
>
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
>
> I also changed java memory allocation with -Xms1640M -Xmx1640M (The 
> most I can allocate on my PC), and tried running it as a stateless  
> session too.
>
> Is there anything else I can do, or is this simply pushing drools too 
> far (surely not!!) ?
>
> I'm very keen on pushing this technology as much as possible in our 
> workplace and I'd really appreciate any help.
>
> Thanks in advance
>
> Simon
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070720/aa9ea1de/attachment.html 


More information about the rules-users mailing list