<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>Dear Alexander and Marc,<br><br>Thanks for your quick answers !<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>More precisely, I am using the reduced costs to reformulate the objective function into an equivalent one. This changes the objective coefficients, but the objective value for every feasible solution remains the same. Because of this equivalence, the bounding step is still valid. I am designing a new learning procedure, and currently, this step seems to be necessary.<br><br>I have not yet tried modifying SCIP’s internal functions. Would enabling modification of the objective function (assuming that I keep equivalence) only require to make sure that the LP is updated and heurisitcs correctly notified ? or they are more subtil things I need to keep in mind ?<br><br>In principle I only need to change the LP objective function. Maybe it is simpler than modifying the MILP objective function ? <br><br><br>Thanks for your advices !<br><br>Best regards,<br><br>Pierre Montalbano</div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><b>De: </b>"Alex Meiburg" <timeroot.alex@gmail.com><br><b>À: </b>"Marc Pfetsch" <pfetsch@mathematik.tu-darmstadt.de><br><b>Cc: </b>"scip" <scip@zib.de><br><b>Envoyé: </b>Lundi 17 Novembre 2025 17:12:45<br><b>Objet: </b>[SPAM] Re: [SCIP] SCIP deleting constraints during solving process<br></div><div><br></div><div data-marker="__QUOTED_TEXT__"><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><br><div><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" target="_blank" rel="nofollow noopener noreferrer">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" rel="noreferrer nofollow noopener noreferrer" target="_blank">Scip@zib.de</a><br>
> <a href="https://listserv.zib.de/mailman/listinfo/scip" rel="noreferrer noreferrer nofollow noopener noreferrer" target="_blank">https://listserv.zib.de/mailman/listinfo/scip</a><br>
<br>
_______________________________________________<br>
Scip mailing list<br>
<a href="mailto:Scip@zib.de" rel="noreferrer nofollow noopener noreferrer" target="_blank">Scip@zib.de</a><br>
<a href="https://listserv.zib.de/mailman/listinfo/scip" rel="noreferrer noreferrer nofollow noopener noreferrer" target="_blank">https://listserv.zib.de/mailman/listinfo/scip</a><br>
</blockquote></div>
<br>_______________________________________________<br>Scip mailing list<br>Scip@zib.de<br>https://listserv.zib.de/mailman/listinfo/scip<br></div></div></body></html>