Dear Dima! Thank you for your interest! (I was away for the weekend...)
remove_constraint takes as input the index of the constraint to be >> removed! It is unlikely, that add_constraint(variable==0) creates an >> indexed constraint, but perhaps I am mistaken. >> > > Somewhat naively, I'd just check that p.number_of_constraints() goes up > (p.number_of_constraints() calls backend's nrows()), and then remove > the constraint number p.remove_constraint()-1 > > (that is, assuming the backend does not do reordering of them, which is > hopefully the case) > I'll check whether this works. What I would expect however, is that having the constraint a+b <= 2, adding the constraint a == 0 I'd end up with b <= 2 a == 0 instead of a+b <= 2 a == 0. On the other hand, this all will be very slow, unless you do a warm > restart, i.e. you are able to save the state > of the solver before you add the constraint. > And indeed, how do you know that p.solve() will do the warm restart? > Well, apparently it did. > Do you mean to say that formerly you had this happening to you, now it > does not work? > exactly! > Anyhow, I have a problem understanding the code in the original sample > does. Doesn't an exception in the loop throws you out of the loop? > And what the objective function? Would it be more efficient to minimise > assignment[box, colour] rather than set it to 0 and try the feasibility(?) > problem? > If it's indeed a feasibility problem that you are solving, then you could > simply solve for the minimisation of assignment[box, colour], and > if this assignment is 0, then the constraint is OK, otherwise it is not... > > Yes, it's a feasability problem. I want to assign boxes colours, subject to various constraints. First I check whether there is a solution at all. If so, I go through all boxes in this solution, and modify the problem: I insist that the colour the box receives is different from "colour", by adding the constraint assignment[box, colour] == 0. If there still is a solution, I haven't learned anything useful (for my problem) However, if there is no solution, I know that box "box" *must* be coloured with colour "colour". Best, Martin -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.