[SCIP] Quadratic Constraint Modification
Stefan Vigerske
svigerske at gams.com
Tue Jul 16 15:24:04 CEST 2024
Hi,
SCIPcreateConsBasicQuadraticNonlinear() is correct. This is a wrapper
around SCIPcreateConsBasicNonlinear(), which makes it easier to create
nonlinear constraints that are quadratic.
There is no SCIPchgLinearCoefQuadratic() in current SCIP versions anymore.
Since SCIP 8, quadratic constraints are no longer distinguished from
other nonlinear constraints. The function of a quadratic constraint is
stored as an expression that is a sum of variables, squares of
variables, and products of two variables, each term in the sum can have
a coefficient. If you just want to change a coefficient in the sum, then
you can get the expression of the constraint (SCIPgetExprNonlinear()),
check with SCIPisExprSum() that it is indeed a sum, and use
SCIPgetCoefsExprSum() to get the coefficients vector. I think it should
be ok to change this vector when SCIP is in problem stage. To get the
expressions that make up the terms of sum, use SCIPexprGetChildren().
For the number of terms, use SCIPexprGetNChildren().
To change the problem after a solve, call SCIPfreeTransform(). That
should bring SCIP back into problem stage.
Hope that helps,
Stefan
On 15/07/2024 14:59, Enrico Calandrini wrote:
> Hi everyone,
> First of all, thank you all for your amazing work!
> 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.
> 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?
> I'm a little bit confused, so thank you in advance for your support!
> Enrico Calandrini
>
>
> _______________________________________________
> Scip mailing list
> Scip at zib.de
> https://listserv.zib.de/mailman/listinfo/scip
More information about the Scip
mailing list