Ticket #14395: trac_14395.patch

File trac_14395.patch, 1.7 KB (added by ncohen, 6 years ago)
  • sage/numerical/mip.pyx

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1364835434 -7200
    # Node ID 8d64e8397fcfddd103cc5c8f93319e04c991a234
    # Parent  9eed6547213ea0120b727ed497db3d98d99c29c9
    Bug in MixedIntegerLinearProgram.polyhedron
    
    diff --git a/sage/numerical/mip.pyx b/sage/numerical/mip.pyx
    a b  
    792792            sage: P = p.polyhedron(); P
    793793            A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 3 vertices and 3 rays
    794794
     795        A square (see :trac:`14395`) ::
     796
     797            sage: p = MixedIntegerLinearProgram()
     798            sage: x,y = p['x'], p['y']
     799            sage: p.set_min(x,None)
     800            sage: p.set_min(y,None)
     801            sage: p.add_constraint( x <= 1 )
     802            sage: p.add_constraint( x >= -1 )
     803            sage: p.add_constraint( y <= 1 )
     804            sage: p.add_constraint( y >= -1 )
     805            sage: p.polyhedron()
     806            A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 4 vertices
     807
    795808        """
    796809        from sage.geometry.polyhedron.constructor import Polyhedron
    797810        from copy import copy
     
    809822            coeffs = dict(zip(indices, values))
    810823
    811824            # Equalities
    812             if lb == ub:
     825            if (not lb is None) and lb == ub:
    813826                linear_function = []
    814827                linear_function = [coeffs.get(i,0) for i in range(nvar)]
    815828                linear_function.insert(0,-lb)
     
    837850            lb, ub = b.col_bounds(i)
    838851
    839852            # Fixed variable
    840             if lb == ub:
     853            if (not lb is None) and lb == ub:
    841854                linear_function = copy(zero)
    842855                linear_function[i] = 1
    843856                linear_function.insert(0,-lb)