<div dir="auto"><div>Relatedly, maybe you can do add constraints for a *bound* on the constraint? </div><div dir="auto"><br></div><div dir="auto">e.g. for a nonlinear objective sin(x), you set the objective to a quantity t, and then at each node you get the bounds B on x and add (or update) a constraint saying that t is between min(sin(B)) and max(sin(B)). You can make it better by taking inequalities linear in x to bound t.</div><div dir="auto"><br></div><div dir="auto">This sounds kind of like what you're doing, but the important thing is that it's always an *outer* bound on the objective.</div><div dir="auto"><br></div><div dir="auto">Cf subgradient methods, which are similar</div><div><br></div><div data-smartmail="gmail_signature"><div dir="ltr">-- Alexander Meiburg<br></div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Nov 17, 2025, 11:01 Marc Pfetsch <<a href="mailto:pfetsch@mathematik.tu-darmstadt.de">pfetsch@mathematik.tu-darmstadt.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
Dear Pierre,<br>
<br>
I do not think that there is a direct way of changing the objective, <br>
since this removes the power of the bounding step of branch-and-bound <br>
(one cannot cut off nodes by objective value anymore).<br>
<br>
The row is indeed still in the LP, because it would invalidate all basis <br>
information, if you remove it without being redundant. I think it would <br>
require major effort to change this within SCIP.<br>
<br>
Some things that you might think about:<br>
Is it possible to formulate your setting as a constraint for which you <br>
can implement propagation or separation? Maybe the change of the <br>
objective is only one way of achieving what you want to do?<br>
<br>
Best<br>
<br>
Marc<br>
<br>
<br>
<br>
On 14/11/2025 18:26, Pierre Montalbano wrote:<br>
> Dear SCIP users,<br>
> <br>
> I am trying to design a new mechanism in SCIP, and for this I need to modify the objective function at each node of the search tree.<br>
> I disabled heuristics, separation, propagation and presolve. I also do a DFS.<br>
> <br>
> As far as I know, it is not possible to change the objective function during the solving process. Therefore, I model the objective as a constraint (i.e., myobj <= z with z minimized). I would like to replace this “objective constraint” at each node before the LP is solved. Currently, I attempt to do this inside a node-focused callback.<br>
> <br>
> Adding a constraint with SCIPaddConsNode works. However, SCIPdelConsLocal removes the constraint only from the transformed problem (it no longer appears in SCIPwriteTransProblem), but not from the LP rows. Thus, the LP solution is incorrect.<br>
> I also tested adding a row directly via SCIPaddRow, but it seems the row is inserted only after the LP is solved.<br>
> <br>
> I suspect that modifying the objective-constraint during an LP-solved event (instead of node-focused) will not behave correctly when backtracking.<br>
> <br>
> Is there a more appropriate or efficient way to modify a constraint or emulate objective changes during solving in SCIP?<br>
> <br>
> Here is part of my code where I delete/add objective constraint.<br>
> <br>
> <br>
> // ----NODEFOCUSED event handler ----<br>
> static<br>
> SCIP_DECL_EVENTEXEC(eventExecNodeFocused)<br>
> {<br>
> ...<br>
> <br>
>       SCIP_CALL( SCIPdelConsLocal(scip, oldobjcons));<br>
> <br>
>          SCIP_Real* coefs = nullptr;<br>
>          SCIP_VAR** consvars = nullptr;<br>
>          SCIP_CONS* newobj = nullptr;<br>
>          <br>
>          SCIP_CALL( SCIPallocBufferArray(scip, &coefs, nvars) );<br>
>          SCIP_CALL( SCIPallocBufferArray(scip, &consvars, nvars) );<br>
>          for (int k = 0; k < nvars; ++k)<br>
>          {<br>
>              consvars[k] = vars[k];<br>
>              coefs[k] = redcosts[k];<br>
>          }<br>
> <br>
>          char sname[256];<br>
>          <br>
>          snprintf(sname, sizeof(sname), "obj_%d", nodeNumber);<br>
>          SCIP_CALL( SCIPcreateConsBasicLinear(scip, &newobj,<br>
>              sname,<br>
>              nvars,<br>
>              consvars,<br>
>              coefs,<br>
>              -SCIPinfinity(scip),<br>
>              0) );<br>
>          <br>
>          <br>
>          SCIP_CALL( SCIPaddConsNode(scip,node, newobj,nullptr) );<br>
> <br>
>          SCIP_CALL( SCIPreleaseCons(scip, &newobj) );<br>
> <br>
> …<br>
> }<br>
> <br>
> <br>
> Thank you very much for your help, and I wish you a nice weekend.<br>
> <br>
> Best regards,<br>
> <br>
> Montalbano Pierre<br>
> <br>
> _______________________________________________<br>
> Scip mailing list<br>
> <a href="mailto:Scip@zib.de" target="_blank" rel="noreferrer">Scip@zib.de</a><br>
> <a href="https://listserv.zib.de/mailman/listinfo/scip" rel="noreferrer noreferrer" target="_blank">https://listserv.zib.de/mailman/listinfo/scip</a><br>
<br>
_______________________________________________<br>
Scip mailing list<br>
<a href="mailto:Scip@zib.de" target="_blank" rel="noreferrer">Scip@zib.de</a><br>
<a href="https://listserv.zib.de/mailman/listinfo/scip" rel="noreferrer noreferrer" target="_blank">https://listserv.zib.de/mailman/listinfo/scip</a><br>
</blockquote></div>