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

Wolfgang Laun (JIRA) jira-events at lists.jboss.org
Mon Jan 24 07:36:49 EST 2011


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


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