[
https://issues.jboss.org/browse/JBRULES-2873?page=com.atlassian.jira.plug...
]
Wolfgang Laun updated JBRULES-2873:
-----------------------------------
Attachment: sudokubug.tgz
The bug can be reproduced with several Sudoku samples, e.g., "Medium". You can
[Step] towards the solution, and watch out for "But cell...matches" on standard
output. Many prints are enabled, and it's easy to see from the grid dump that the rule
should not fire in some cases. (Due to this, the data in the model becomes inconsistent.)
Also, execution is not deterministic. Running "Medium" repeatedly with [Solve]
results in different (invalid) final states, with different sets of cells remaining
empty.
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
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