Hellooooooooooooo !!! It seems that Integer Programs solved with CPLEX sometimes have the wrong > bounds on binary variables. For instance, >
Well, as you say CPLEX defined a "binary" type. And does not associate bounds with such variables, because it knows it is binary. Anyway : sage: p=MixedIntegerLinearProgram(solver="cplex"); sage: b=p.new_variable(binary=True) sage: p.add_constraint(b[0] == 2) sage: p.solve() ... MIPSolverException: 'CPLEX: The primal has no feasible solution' Soooooo well. No problem. {0: 2.0, 1: 0.0} > > Note that x[0] has the solution 2, which shouldn't happen for a binary > variable. > > When I ran the example of code you gave (removing the comment before binary=True, I get the solution 0:1, 1:1, which is good. If you really get a variable equal to 2 on this example, something is dead wrong indeed. > In the output, the upper bound of the variable is not printed correctly, but > I'm not sure if that's a problem, since an upper bound should not need to be > explicitly set for a binary variable. > > Hmmmm... The trick is that Sage stores no information on the LP. Everything is stored in the backend. So if CPLEX does not store as "variable bounds" 0 and 1, then Sage does not know it and displays the bounds that are stored in CPLEX's data structure. Though it remembers that the variable is binary of course. > In other instances when using binary variables with CPLEX, they seem to > behave as they should. > > This issue is more problematic than it appears, since if CPLEX is installed > it becomes the default IP/LP solver, and other things can randomly fail. For > instance, > > sage.combinat.integer_vector.gale_ryser_theorem([2]*5,[5]*2) > > should give a 5x2 matrix of all 1's but instead gives > > [2 0] > [2 0] > [1 1] > [0 2] > [0 2] > > I am using Sage 5.12 and IBM ILOG CPLEX 12.5.1.0. I took a look in > cplex_backend.pyx, but nothing immediately jumped out as a problem. > > Well...Really, when I run this what I get is : sage: sage.combinat.integer_vector.gale_ryser_theorem([2]*5,[5]*2) [1 1] [1 1] [1 1] [1 1] [1 1] > Thanks for any insight that anyone has! > > Well, I would be glad to help but I would need to be able to reproduce one of the bugs for a start :-P Nathann -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.