On Friday, May 13, 2016 at 3:16:28 PM UTC+1, Martin R wrote:
>
> 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.
>

all the constraints are indexed, surely.
p.number_of_constraints() is the total number.
You can in fact see what happens at the backend:
p.get_backend().nrows() is the number of constraints as  known to the 
backend, and
p.remove_constraint() simply calls the corresponding backend function.

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)

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?
Do you mean to say that formerly you had this happening to you, now it does 
not work?

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...

Dima



> Am Freitag, 13. Mai 2016 15:25:17 UTC+2 schrieb Dima Pasechnik:
>>
>> On Friday, May 13, 2016 at 9:53:13 AM UTC+1, Martin R wrote:
>>>
>>>
>>> Yes, and then?  I don't think I can remove it again, can I?  
>>>
>>>>
>>>> sage: p.remove_constraint?
>>>> Docstring:
>>>>    Removes a constraint from self.
>>>>
>>>> I do not thing that this works, because a constraint may (and often 
>>> will be) subsumed by other constraints already there. 
>>>
>>
>> It either works, or else please do a bug report...
>> If you added a redundant constraint, its removal should have no effect, 
>> isn't it? 
>>
>>

-- 
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.

Reply via email to