<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="margin-top: 1em; margin-bottom: 1em; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Stefan,</div>
<div style="margin-top: 1em; margin-bottom: 1em; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thank you very much for your reply! That is exactly what I was looking for!</div>
<div style="margin-top: 1em; margin-bottom: 1em; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I just have a quick follow-up question on what you mentioned. Let's say I have an expression like x + 2xy + 3y². Following your procedure, I should be able to retrieve all the terms of the sum (x, xy, y²) using SCIPexprGetChildren(). However, I'm now wondering
 how I can directly access the individual expressions to determine which variables are active within each one. Is there a method to retrieve the indices of the active variables in the expression?</div>
<div style="margin-top: 1em; margin-bottom: 1em; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Assuming this is possible, if I retrieve the vector of coefficients with SCIPgetCoefsExprSum() and modify it, is it sufficient to make the change active in SCIP? Do I need to "provide back" the new vector to SCIP in any way?</div>
<div style="margin-top: 1em; margin-bottom: 1em; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thank you very much for your time!</div>
<div style="margin-top: 1em; margin-bottom: 1em; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Enrico</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Da:</b> Stefan Vigerske <svigerske@gams.com><br>
<b>Inviato:</b> martedì 16 luglio 2024 15:24<br>
<b>A:</b> Enrico Calandrini <e.calandrini@studenti.unipi.it>; scip@zib.de <scip@zib.de><br>
<b>Oggetto:</b> Re: [SCIP] Quadratic Constraint Modification</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hi,<br>
<br>
SCIPcreateConsBasicQuadraticNonlinear() is correct. This is a wrapper <br>
around SCIPcreateConsBasicNonlinear(), which makes it easier to create <br>
nonlinear constraints that are quadratic.<br>
<br>
There is no SCIPchgLinearCoefQuadratic() in current SCIP versions anymore.<br>
<br>
Since SCIP 8, quadratic constraints are no longer distinguished from <br>
other nonlinear constraints. The function of a quadratic constraint is <br>
stored as an expression that is a sum of variables, squares of <br>
variables, and products of two variables, each term in the sum can have <br>
a coefficient. If you just want to change a coefficient in the sum, then <br>
you can get the expression of the constraint (SCIPgetExprNonlinear()), <br>
check with SCIPisExprSum() that it is indeed a sum, and use <br>
SCIPgetCoefsExprSum() to get the coefficients vector. I think it should <br>
be ok to change this vector when SCIP is in problem stage. To get the <br>
expressions that make up the terms of sum, use SCIPexprGetChildren(). <br>
For the number of terms, use SCIPexprGetNChildren().<br>
<br>
To change the problem after a solve, call SCIPfreeTransform(). That <br>
should bring SCIP back into problem stage.<br>
<br>
Hope that helps,<br>
Stefan<br>
<br>
On 15/07/2024 14:59, Enrico Calandrini wrote:<br>
> Hi everyone,<br>
> First of all, thank you all for your amazing work!<br>
> I was wondering if someone could help me understand how to properly modify a quadratic constraint, if this is possible. Specifically, I'm adding a quadratic constraint using the function SCIPcreateConsBasicQuadraticNonlinear. Firstly, is this method the correct
 one in the current version of SCIP? Additionally, it is possible that after the model has been solved, I may need to modify that constraint.<br>
> I have noticed that in the constraint handler for quadratic constraints (cons_quadratic.h), there are functions like SCIPchgLinearCoefQuadratic() to modify both linear and quadratic coefficients. However, I'm unsure whether these methods can be used for a
 constraint created as described above. Moreover, I have seen in the documentation that these changes are allowed only in the problem creation stage, meaning that after a call to SCIPsolve, this constraint can't be modified anymore?<br>
> I'm a little bit confused, so thank you in advance for your support!<br>
> Enrico Calandrini<br>
> <br>
> <br>
> _______________________________________________<br>
> Scip mailing list<br>
> Scip@zib.de<br>
> <a href="https://listserv.zib.de/mailman/listinfo/scip">https://listserv.zib.de/mailman/listinfo/scip</a><br>
<br>
</div>
</span></font></div>
</body>
</html>