<div dir="ltr">Hi,<div><br></div><div>I'm trying to understand the minimal requirements for adding constraints during search to SCIP. </div><div><br></div><div>My toy problem is to try to enforce that two variables x1, x2, both integral with domains {1,2}, add up to 3, only by using lazy constraints.</div><div><br></div><div>To this I created a constraint handler, and implemented:</div><div><br></div>* SCIP_DECL_CONSCHECK : Checks if x1 + x2 == 3, returning SCIP_FEASIBLE, or SCIP_INFEASIBLE accordingly.<div><br></div><div>* SCIP_DECL_CONSENFOLP : Adds x1 + x2 == 3 to the model using SCIPcreateConsBasicLinear and SCIPaddCons and returning SCIP_CONSADDED.</div><div><br></div>* SCIP_DECL_CONSLOCK : Calls SCIPaddVarLocks() for both x1 and x2.<div><br></div>* SCIP_DECL_CONSENFOPS : Do nothing (only return SCIP_OKAY). I don't know what to do here and it seems this never gets called in my example anyway.<div><br></div>* SCIP_DECL_CONSTRANS: Just return SCIP_OKAY.<div><br></div><div>Then I add this constraint handler using needscons=false, since if I understand correctly, this way it will run even if I don't associate any constraints with it.</div><div><br></div><div>Besides adding the constraint handler, I do not add any constraints, and simply call minimize x1.</div><div><br></div><div>I get this trace:</div><div><br></div><div><div style="line-height:19px">Called CHECK with values x1=1, x2=1 (which returns false)<br>(repeats 6 times)<br>Called ENFOLP with values x1=1, x2=1 (which adds the x1+x2==3 and returns CONSADDED)<br></div></div><div style="line-height:19px"><br></div><div style="line-height:19px">and then SCIP stops with state "infeasible".</div><div style="line-height:19px"><br></div><div style="line-height:19px">I was expecting  instead to see SCIP branching and eventually finding x1=1, x2=2.</div><div style="line-height:19px"><br></div><div style="line-height:19px">I have the feeling I'm missing something obvious. I can't find a simple enough example in the documentation, all examples there seem to require that constraints are added to the constraint handler, and are much more involved. I am essentially looking for something as simple as the gurobi callback mechanism: just call a function at each node that can add global constraints to the search tree.</div><div style="line-height:19px"><br></div><div style="line-height:19px">Any hints?</div><div style="line-height:19px"><br></div><div style="line-height:19px">As a second question, why is CHECK called 7 times with the same variable values? Is SCIP expecting that CHECK is non-deterministic?</div><div style="line-height:19px"><br></div><div style="line-height:19px">Thanks!</div><div style="line-height:19px">Marco</div></div>