#1 a minor bug: Count.satisfied() incorrectly returns 'false'

closed-fixed
nobody
None
2
2010-10-05
2010-10-05
No

Hello,

this piece of code probably has a minor fault in it:

<< Count.java >> (from 3.0RC2, but the same code is in 2.4.1 that I'm using)

@Override
public boolean satisfied() {

int countAll = 0;

if (counter.singleton(value)) {

for (IntVar v : list)
if (v.singleton(value))
countAll++;
return (countAll == counter.min());
} else
return false;
}

This works only if the count is the same as the value that is being counted.
The underscored line should perhaps be:
" if (counter.singleton()) { "

For a demonstration please see the attached file, with the printout:

"After consistency:

*** Store
a=1
b=2
c=3
count=1

*** Constraints for evaluation:
{SimpleHashSet[]
SimpleHashSet[]
SimpleHashSet[]
SimpleHashSet[]
SimpleHashSet[]
}
Count satisfied: false" (this is wrong)

Best regards,
Pavol

Discussion

  • Pavol Mederly

    Pavol Mederly - 2010-10-05

    source file to demonstrate the bug (used with JaCoP 2.4.1)

     
  • Pavol Mederly

    Pavol Mederly - 2010-10-05
    • priority: 5 --> 2
     
  • kris

    kris - 2010-10-05

    Yes, you are right. The if statement should be

    if (counter.singleton()) {

    I have updated svn repository with correct code.

    /Kris

     
  • kris

    kris - 2010-10-05
    • status: open --> closed-fixed
     
  • kris

    kris - 2010-10-05

    Hej!

    I have fixed this bug and updated svn.

    /Kris

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks