[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2873) Rule fires unexpectedly - not CE fails

Wolfgang Laun (JIRA) jira-events at lists.jboss.org
Mon Jan 31 11:57:39 EST 2011


    [ https://issues.jboss.org/browse/JBRULES-2873?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12579113#comment-12579113 ] 

Wolfgang Laun commented on JBRULES-2873:
----------------------------------------

I have added rules (with low salience) ending one and two patterns earlier than the full rule "column elimination" and monitored their activation events. From this, it can be seen that the CE
    not Cell( this != $c, free contains $i, cellSqr == $cs, cellCol != $cc )
is indeed the "guilty" one: the (invalid) activation for the rule ending with this CE is created at the same time as the (also invalid) one for the full rule.

For the rule ending with
     $c: Cell( free contains $i, $cs: cellSqr, $cc: cellCol )
3 and 4 activations for cells $c = [3,0] and [5,0], respectively, are created correctly; all of them remain active until the end.


> 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