[SCIP] SCIP deleting constraints during solving process
Pierre Montalbano
pierre.montalbano at univ-tours.fr
Tue Nov 18 10:03:47 CET 2025
Dear Alexander and Marc,
Thanks for your quick answers !
>> I do not think that there is a direct way of changing the objective,
>> since this removes the power of the bounding step of branch-and-bound
>> (one cannot cut off nodes by objective value anymore).
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.
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 ?
In principle I only need to change the LP objective function. Maybe it is simpler than modifying the MILP objective function ?
Thanks for your advices !
Best regards,
Pierre Montalbano
De: "Alex Meiburg" <timeroot.alex at gmail.com>
À: "Marc Pfetsch" <pfetsch at mathematik.tu-darmstadt.de>
Cc: "scip" <scip at zib.de>
Envoyé: Lundi 17 Novembre 2025 17:12:45
Objet: [SPAM] Re: [SCIP] SCIP deleting constraints during solving process
Relatedly, maybe you can do add constraints for a *bound* on the constraint?
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.
This sounds kind of like what you're doing, but the important thing is that it's always an *outer* bound on the objective.
Cf subgradient methods, which are similar
-- Alexander Meiburg
On Mon, Nov 17, 2025, 11:01 Marc Pfetsch < [ mailto:pfetsch at mathematik.tu-darmstadt.de | pfetsch at mathematik.tu-darmstadt.de ] > wrote:
Dear Pierre,
I do not think that there is a direct way of changing the objective,
since this removes the power of the bounding step of branch-and-bound
(one cannot cut off nodes by objective value anymore).
The row is indeed still in the LP, because it would invalidate all basis
information, if you remove it without being redundant. I think it would
require major effort to change this within SCIP.
Some things that you might think about:
Is it possible to formulate your setting as a constraint for which you
can implement propagation or separation? Maybe the change of the
objective is only one way of achieving what you want to do?
Best
Marc
On 14/11/2025 18:26, Pierre Montalbano wrote:
> Dear SCIP users,
>
> 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.
> I disabled heuristics, separation, propagation and presolve. I also do a DFS.
>
> 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.
>
> 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.
> I also tested adding a row directly via SCIPaddRow, but it seems the row is inserted only after the LP is solved.
>
> I suspect that modifying the objective-constraint during an LP-solved event (instead of node-focused) will not behave correctly when backtracking.
>
> Is there a more appropriate or efficient way to modify a constraint or emulate objective changes during solving in SCIP?
>
> Here is part of my code where I delete/add objective constraint.
>
>
> // ----NODEFOCUSED event handler ----
> static
> SCIP_DECL_EVENTEXEC(eventExecNodeFocused)
> {
> ...
>
> SCIP_CALL( SCIPdelConsLocal(scip, oldobjcons));
>
> SCIP_Real* coefs = nullptr;
> SCIP_VAR** consvars = nullptr;
> SCIP_CONS* newobj = nullptr;
>
> SCIP_CALL( SCIPallocBufferArray(scip, &coefs, nvars) );
> SCIP_CALL( SCIPallocBufferArray(scip, &consvars, nvars) );
> for (int k = 0; k < nvars; ++k)
> {
> consvars[k] = vars[k];
> coefs[k] = redcosts[k];
> }
>
> char sname[256];
>
> snprintf(sname, sizeof(sname), "obj_%d", nodeNumber);
> SCIP_CALL( SCIPcreateConsBasicLinear(scip, &newobj,
> sname,
> nvars,
> consvars,
> coefs,
> -SCIPinfinity(scip),
> 0) );
>
>
> SCIP_CALL( SCIPaddConsNode(scip,node, newobj,nullptr) );
>
> SCIP_CALL( SCIPreleaseCons(scip, &newobj) );
>
> …
> }
>
>
> Thank you very much for your help, and I wish you a nice weekend.
>
> Best regards,
>
> Montalbano Pierre
>
> _______________________________________________
> Scip mailing list
> [ mailto:Scip at zib.de | Scip at zib.de ]
> [ https://listserv.zib.de/mailman/listinfo/scip | https://listserv.zib.de/mailman/listinfo/scip ]
_______________________________________________
Scip mailing list
[ mailto:Scip at zib.de | Scip at zib.de ]
[ https://listserv.zib.de/mailman/listinfo/scip | https://listserv.zib.de/mailman/listinfo/scip ]
_______________________________________________
Scip mailing list
Scip at zib.de
https://listserv.zib.de/mailman/listinfo/scip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.zib.de/pipermail/scip/attachments/20251118/c1707246/attachment.html>
More information about the Scip
mailing list