[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2873) Rule fires unexpectedly - not CE fails
Wolfgang Laun (JIRA)
jira-events at lists.jboss.org
Fri Jan 28 10:38:39 EST 2011
[ https://issues.jboss.org/browse/JBRULES-2873?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578740#comment-12578740 ]
Wolfgang Laun commented on JBRULES-2873:
----------------------------------------
After setting up an activation event listener for the rule "column elimination" and with specific cells, I see that the rule fires correctly, saying
column elimination due to [8,2]: remove 5 from [4,2]
This update creates two erroneous activations:
ActivationCreatedEventImpl: column elimination: $i=$i=5, $c=[5,0]: /$c.free=[3, 4, 5, 9], in org.drools.examples.sudoku.CellSqr at f70ee1 and in column 0, $cx: [2,0]: /$cx.free=[1, 2, 3, 4, 5], in org.drools.examples.sudoku.CellSqr at 1bbd583 and in column 0, not: [5,1]: /not.free=[4, 5, 9], in org.drools.examples.sudoku.CellSqr at f70ee1 and in column 1
ActivationCreatedEventImpl: column elimination: $i=$i=5, $c=[3,0]: /$c.free=[3, 5, 9], in org.drools.examples.sudoku.CellSqr at f70ee1 and in column 0, $cx: [2,0]: /$cx.free=[1, 2, 3, 4, 5], in org.drools.examples.sudoku.CellSqr at 1bbd583 and in column 0, not: [5,1]: /not.free=[4, 5, 9], in org.drools.examples.sudoku.CellSqr at f70ee1 and in column 1
The second one fires (this is the error):
BeforeActivationFiredEventImpl: column elimination: $i=$i=5, $c=[3,0]: /$c.free=[3, 5, 9], in org.drools.examples.sudoku.CellSqr at f70ee1 and in column 0, $cx: [2,0]: /$cx.free=[1, 2, 3, 4, 5], in org.drools.examples.sudoku.CellSqr at 1bbd583 and in column 0, not: [5,1]: /not.free=[4, 5, 9], in org.drools.examples.sudoku.CellSqr at f70ee1 and in column 1
This firing removes the other activation.
> Rule fires unexpectedly - not CE fails
> --------------------------------------
>
> Key: JBRULES-2873
> URL: https://issues.jboss.org/browse/JBRULES-2873
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-core
> Affects Versions: 5.1.1.FINAL
> Reporter: Wolfgang Laun
> Assignee: Mark Proctor
> Priority: Critical
> Attachments: sudokubug.tgz, sudokubug1.tgz, sudokubug2.tgz
>
>
> The rule shown below fires, and then the code on the RHS prints "But cell ... matches" which is only possible when there is a Cell according to the constraints in the "not" CE. - The full Sudoku code is available.
> rule "column elimination"
> when
> not Setting()
> $i: Integer()
> # occurs in a Cell
> $c: Cell( free contains $i, $cs: cellSqr, $cc: cellCol )
> # but not in another cell of the same square and a different column
> not Cell( this != $c, free contains $i, cellSqr == $cs, cellCol != $cc )
>
> ## not ( $oc: Cell( this != $c )
> ## and
> ## eval( $oc.getFree().contains( $i ) &&
> ## $oc.getCellSqr().equals( $cs ) &&
> ## ! $oc.getCellCol().equals( $cc ) ) )
> # but there is a cell in the same column and another square containing this value
> $cx: Cell( freeCount > 1, free contains $i, cellCol == $cc, cellSqr != $cs )
> then
> # remove the value from that other cell
> System.out.println( "column elimination due to " + $c.posAsString() +
> ": remove " + $i + " from " + $cx.posAsString() );
>
> for( int iRow = 0; iRow < 9; iRow++ ){
> for( int iCol = 0; iCol < 9; iCol++ ){
> Cell cell = Sudoku.sudoku.cells[iRow][iCol];
> if( ! cell.equals( $c ) &&
> cell.getCellSqr().equals( $cs ) &&
> ! cell.getCellCol().equals( $cc ) &&
> cell.getFree().contains( $i ) ){
> System.out.println( "But cell " + cell.toString() + " matches!" );
> }
> }
> }
>
> for( Cell c: $cs.getCells() ){
> System.out.print( c.posAsString() + ": " + c.getFree() +
> " cc="+c.getCellCol() + " cs="+c.getCellSqr() + "; " );
> }
> System.out.println();
>
> modify( $cx ){ blockValue( $i ) }
> end
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list