#12091: bug in add_constraint to MixedIntegerLinearProgram
----------------------------------+-----------------------------------------
Reporter: dimpase | Owner: ncohen
Type: defect | Status: new
Priority: critical | Milestone: sage-5.0
Component: linear programming | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
----------------------------------+-----------------------------------------
Description changed by ppurka:
Old description:
> constraints with 0 on one size of an inequality get lost, somehow:
> {{{
> sage: p = MixedIntegerLinearProgram(maximization=True)
> sage: A = p.new_variable()
> sage: p.add_constraint(A[0]==1)
> sage: p.add_constraint(0<= A[1]-A[0])
> sage: p.show()
> Maximization:
>
> Constraints:
> 1.0 <= x_0 <= 1.0
> Variables:
> x_0 is a continuous variable (min=0.0, max=+oo)
> x_1 is a continuous variable (min=0.0, max=+oo)
> }}}
>
> homogenizing the constraint fixes this problem:
> {{{
> sage: p.add_constraint(0*A[0]<= A[1]-A[0])
> sage: p.show()
> Maximization:
>
> Constraints:
> 1.0 <= x_0 <= 1.0
> x_0 -x_1 <= 0.0
> Variables:
> x_0 is a continuous variable (min=0.0, max=+oo)
> x_1 is a continuous variable (min=0.0, max=+oo)
> }}}
New description:
constraints with 0 on one size of an inequality get lost, somehow:
{{{
sage: p = MixedIntegerLinearProgram(maximization=True)
sage: A = p.new_variable()
sage: p.add_constraint(A[0]==1)
sage: p.add_constraint(0<= A[1]-A[0])
sage: p.show()
Maximization:
Constraints:
1.0 <= x_0 <= 1.0
Variables:
x_0 is a continuous variable (min=0.0, max=+oo)
x_1 is a continuous variable (min=0.0, max=+oo)
}}}
homogenizing the constraint fixes this problem:
{{{
sage: p.add_constraint(0*A[0]<= A[1]-A[0])
sage: p.show()
Maximization:
Constraints:
1.0 <= x_0 <= 1.0
x_0 -x_1 <= 0.0
Variables:
x_0 is a continuous variable (min=0.0, max=+oo)
x_1 is a continuous variable (min=0.0, max=+oo)
}}}
The bug is in `sage.numerical.mip.LinearConstraint` and
`sage.numerical.mip.LinearFunction`. More examples:
{{{
sage: p = MixedIntegerLinearProgram()
sage: b = p.new_variable()
sage: b[0] <= b[1] <= 2 # This is not ok
x_1 <= 2
sage: (b[0] <= b[1] <= 2).constraints # Not ok
[x_1, 2]
sage: b[0] >= b[1] # This is ok
x_1 <= x_0
sage: 1 >= b[1] # This is not since it starts with a constant
False
sage: 1 >= b[1] >= 2*b[0] # Not ok
False
sage: b[2] >= b[1] >= 2*b[0] # Not ok
2 x_0 <= x_1
}}}
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12091#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.