[SCIP] The strange behavior of the CONSENFOLP callback assertion

Mathieu Besançon mathieu.besancon at gmail.com
Sat Aug 5 17:02:23 CEST 2023


1. The assert is specific to the test and should not be used as a template
for a constraint handler.
If your check returns SCIP_FEASIBLE, the constraint handler has no reason
to enforce the constraint on the LP solution (aka to call consenflp),
because there is nothing to do to make the constraint feasible.

2. The priorities should be explained on the constraint handler page:
https://www.scipopt.org/doc/html/CONS.php

for 3, maybe check a realistic constraint handler, such as
PySCIPOpt/examples/finished/lotsizing_lazy.py


Hope this helps,
Mathieu





On Fri, Aug 4, 2023 at 8:27 PM Abbas Omidi <abb.omidi at gmail.com> wrote:

> Dear Mathieu,
>
> Thank you so much for your informative comments. Now, it makes sense to
> the *price-and-cut loop *and also, what is the difference between
> *consenfolp/**consenfops.*
>
> Is the solution feasible for your constraint? If yes, you can just use
>> SCIP_FEASIBLE as a result.
>
>
> Let me explain more on what I am trying to do. I have tried using a simple
> example and already mentioned the template here
> <https://github.com/scipopt/PySCIPOpt/blob/master/tests/test_conshdlr.py>
> to investigate how *conshdlr* works and how behaves again adding the
> custom constraints. The problem I am using has an optimal solution and also
> I defined SCIP_FEASIBLE as a result in both *conscheck *and *consenflp*.
> After declaring the optimization model, I added *writeProblem* method to
> see what exactly is added to the model. Then I called the following method
> to include *conshdlr* :
>
> conshdlr = MyConshdlr(shouldtrans=True, shouldcopy=False)
>> s.includeConshdlr(conshdlr, "PyCons", "custom constraint handler
>> implemented in python",
>> sepapriority= 1, enfopriority= 1, chckpriority= 1
>> )
>
>
> Then I created and added three custom constraint handlers still based on
> the original problem constraints by using:
>
> cons1 = s.createCons(conshdlr, "cons1name")
>> ids.append(id(cons1))
>
>
>> conshdlr.createData(cons1, 10, "cons1_anothername")
>
>
>> s.addPyCons(cons1)
>
>
> By running the code, it shows the assertion errors on --> 143 assert
> "consenfolp" in calls.
> Also, the write method shows the following rows added, but it cannot
> convert that into a readable format:
>
> constraint handler <PyCons> cannot print requested format
>> \   [PyCons] <cons1name>: ;
>> constraint handler <PyCons> cannot print requested format
>> \   [PyCons] <cons2name>: ;
>> constraint handler <PyCons> cannot print requested format
>> \   [PyCons] <cons3name>: ;
>
>
>
> My questions are:
> 1)  Why do I have an assertion error on *consenflp *while the problem has
> an optimal solution?
> 2) How can I find the priority numbers and their definitions of
> *sepapriority*, *enfopriority*, and *chckpriority*? (I cannot find
> related documents)
> 3) I am not sure why I need to redefine the constraints by createCons,
> createData, and addPyCons respectively. I just tried to use the
> template format, and this is why I asked about adding data. If I am doing
> wrong pleaes, correct me?
>
>
> All the best
> Regards
> Abbas
>
> On Thu, Aug 3, 2023 at 7:33 PM Mathieu Besançon <
> mathieu.besancon at gmail.com> wrote:
>
>> Dear Abbas,
>>
>> 1. The price-and-cut-loop happens before the constraint handler is
>> called, this corresponds to the step where the LP relaxation has been
>> solved, and the rounds of cuts (from separator plugins) have already
>> happened.
>>
>> 2. consenfoXYZ acts on a primal solution by adding a constraint, cut, or
>> something else. In contrast, the check function only computes whether a
>> violation of the constraint represented by the constraint handler is
>> present at the current solution, and returns whether the solution is
>> feasible or infeasible.
>> https://www.scipopt.org/doc/html/CONS.php
>>
>> 2 bis. I am not sure to understand what you mean by this one. Is the
>> solution feasible for your constraint? If yes, you can just use
>> SCIP_FEASIBLE as a result. If this solution is not feasible, then you can
>> do one of the actions detailed in the documentation page linked above. If
>> the only possible thing is determining the current solution as infeasible,
>> then the ENFO constraint can use a result SCIP_INFEASIBLE.
>>
>> 3. I don't think create data is necessary for a constraint handler but
>> not sure on this one.
>>
>> Best,
>> Mathieu
>>
>>
>> On Sat, Jul 29, 2023 at 9:05 AM Abbas Omidi <abb.omidi at gmail.com> wrote:
>>
>>> Dear support team,
>>>
>>> I am working on the problem, and I am willing to use SCIP's*onshdlr*
>>> callback, preferably PySCIPopt, to check how the constraints might be
>>> added to the model. The problem I have is a simple linear program, MILP,
>>> that is solved optimality. I sum up my questions as follows and am
>>> wondering if, you can advise me.
>>>
>>> 1) As the definition of *consenfolp/consenfops *is very specific and
>>> contains the term *price-and-cut loop*, What does the price-and-cut
>>> loop mean?
>>>
>>> 2) What is the difference between *consenfolp/consenfops *and
>>> *conscheck* when applied to the model?
>>>
>>> 2) As my problem has a primal feasible solution, actually optimal one,
>>> and already other callbacks seem to work fine, how is it possible to reject
>>> the constraints/solution by *consenfolp/consenfops*?
>>>
>>> 3) Is it still necessary to use *conshdlr.createData* when we want to
>>> add the constraint?
>>>
>>>
>>> (The link <http://listserv.zib.de/pipermail/scip/2023-July/004687.html>
>>> to my previous post)
>>> Best regards
>>> Abbas
>>> _______________________________________________
>>> Scip mailing list
>>> Scip at zib.de
>>> https://listserv.zib.de/mailman/listinfo/scip
>>>
>>
>>
>> --
>> Mathieu Besançon
>>
>

-- 
Mathieu Besançon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.zib.de/pipermail/scip/attachments/20230805/5e2e6af7/attachment.html>


More information about the Scip mailing list