abdelkimo / python-zibopt

Automatically exported from code.google.com/p/python-zibopt
0 stars 0 forks source link

Constraint are wrongly translated #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
- Version 0.7 of python-zibopt
- SCIP 2.1.0
- Linux (Gentoo)

In the example sudoku.py, if I change the line 40-42:

    # Each cell takes on exactly one value
    for i, j in product(rows, cols):
        solver += sum(x[i][j][k] for k in vals) == 1

By:

    # Each cell takes on exactly one value
    for i, j in product(rows, cols):
        solver += sum(x[i][j][k] for k in vals[:4]) == 1-sum(x[i][j][k] for k in vals[4:])

I get output 'invalid'. But it should be OK since the constraint is the same.

However if I change it by:

    # Each cell takes on exactly one value
    for i, j in product(rows, cols):
        solver += sum(x[i][j][k] for k in vals[:4]) == -sum(x[i][j][k] for k in vals[4:])+1

Then it works... Do I miss something?
See the attached file.

Original issue reported on code.google.com by olivier....@gmail.com on 7 Dec 2011 at 5:10

Attachments:

GoogleCodeExporter commented 8 years ago
That looks like a bug alright.  Good catch!

Before being ported to Cython to support Python 2 and 3 (this winter, time 
permitting), I'm going to switch the expression and constraint handling over to 
python-algebraic (on GitHub).  This won't change the interface at all, as it's 
just extracted from the python-zibopt source directly.  However, I may fix this 
issue there first and then work on integrating the two packages.

Original comment by ryanjoneil on 13 Dec 2011 at 2:52

GoogleCodeExporter commented 8 years ago
Does it work in latest trunk?  I ported the fix from python-algebraic as it was 
not difficult.  Has to do with implementing __rsub__.

Original comment by ryanjoneil on 20 Dec 2011 at 5:34

GoogleCodeExporter commented 8 years ago
Thank you for the quick fix!
I did a test with the last version of the Trunk and it's OK!

Original comment by olivier....@gmail.com on 17 Jan 2012 at 8:35