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