Scippy

SCIP

Solving Constraint Integer Programs

cons_quadratic.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (c) 2002-2024 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file cons_quadratic.h
26  * @ingroup CONSHDLRS
27  * @brief some API functions of removed constraint handler for quadratic constraints \f$\textrm{lhs} \leq \sum_{i,j} a_{i,j} x_ix_j + \sum_i b_i x_i \leq \textrm{rhs}\f$
28  * @author Stefan Vigerske
29  *
30  */
31 
32 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
33 
34 #ifndef __SCIP_CONS_QUADRATIC_H__
35 #define __SCIP_CONS_QUADRATIC_H__
36 
37 #include "scip/def.h"
38 #include "scip/type_cons.h"
39 #include "scip/type_retcode.h"
40 #include "scip/type_scip.h"
41 #include "scip/type_var.h"
42 #include "scip/type_nlp.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /**@addtogroup CONSHDLRS
49  *
50  * @{
51  *
52  * @name Quadratic Constraints (deprecated)
53  *
54  * @{
55  */
56 
57 /** Creates and captures a quadratic nonlinear constraint.
58  *
59  * The constraint should be given in the form
60  * \f[
61  * \ell \leq \sum_{i=1}^n b_i x_i + \sum_{j=1}^m a_j y_j z_j \leq u,
62  * \f]
63  * where \f$x_i = y_j = z_k\f$ is possible.
64  *
65  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
66  *
67  * @deprecated Use SCIPcreateConsQuadraticNonlinear() instead.
68  */
69 SCIP_EXPORT
71  SCIP* scip, /**< SCIP data structure */
72  SCIP_CONS** cons, /**< pointer to hold the created constraint */
73  const char* name, /**< name of constraint */
74  int nlinvars, /**< number of linear terms (n) */
75  SCIP_VAR** linvars, /**< variables in linear part (x_i) or NULL if nlinvars == 0 */
76  SCIP_Real* lincoefs, /**< coefficients of variables in linear part (b_i) or NULL if nlinvars == 0 */
77  int nquadterms, /**< number of quadratic terms (m) */
78  SCIP_VAR** quadvars1, /**< array with first variables in quadratic terms (y_j) or NULL if nquadterms == 0 */
79  SCIP_VAR** quadvars2, /**< array with second variables in quadratic terms (z_j) or NULL if nquadterms == 0 */
80  SCIP_Real* quadcoeffs, /**< array with coefficients of quadratic terms (a_j) or NULL if nquadterms == 0 */
81  SCIP_Real lhs, /**< left hand side of quadratic equation (l) */
82  SCIP_Real rhs, /**< right hand side of quadratic equation (u) */
83  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
84  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
85  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
86  * Usually set to TRUE. */
87  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
88  * TRUE for model constraints, FALSE for additional, redundant constraints. */
89  SCIP_Bool check, /**< should the constraint be checked for feasibility?
90  * TRUE for model constraints, FALSE for additional, redundant constraints. */
91  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
92  * Usually set to TRUE. */
93  SCIP_Bool local, /**< is constraint only valid locally?
94  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
95  SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
96  * Usually set to FALSE. In column generation applications, set to TRUE if pricing
97  * adds coefficients to this constraint. */
98  SCIP_Bool dynamic, /**< is constraint subject to aging?
99  * Usually set to FALSE. Set to TRUE for own cuts which
100  * are separated as constraints. */
101  SCIP_Bool removable /**< should the relaxation be removed from the LP due to aging or cleanup?
102  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
103  );
104 
105 /** creates and captures a quadratic nonlinear constraint
106  * in its most basic variant, i.e., with all constraint flags set to their default values, which can be set
107  * afterwards using SCIPsetConsFLAGNAME()
108  *
109  * The constraint should be given in the form
110  * \f[
111  * \ell \leq \sum_{i=1}^n b_i x_i + \sum_{j=1}^m a_j y_jz_j \leq u,
112  * \f]
113  * where \f$x_i = y_j = z_k\f$ is possible.
114  *
115  * @see SCIPcreateConsQuadratic() for the default constraint flag configuration
116  *
117  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
118  *
119  * @deprecated Use SCIPcreateConsBasicQuadraticNonlinear instead.
120  */
121 SCIP_EXPORT
123  SCIP* scip, /**< SCIP data structure */
124  SCIP_CONS** cons, /**< pointer to hold the created constraint */
125  const char* name, /**< name of constraint */
126  int nlinvars, /**< number of linear terms (n) */
127  SCIP_VAR** linvars, /**< array with variables in linear part (x_i) */
128  SCIP_Real* lincoefs, /**< array with coefficients of variables in linear part (b_i) */
129  int nquadterms, /**< number of quadratic terms (m) */
130  SCIP_VAR** quadvars1, /**< array with first variables in quadratic terms (y_j) */
131  SCIP_VAR** quadvars2, /**< array with second variables in quadratic terms (z_j) */
132  SCIP_Real* quadcoefs, /**< array with coefficients of quadratic terms (a_j) */
133  SCIP_Real lhs, /**< left hand side of quadratic equation (ell) */
134  SCIP_Real rhs /**< right hand side of quadratic equation (u) */
135  );
136 
137 /** Adds a constant to the constraint function, that is, subtracts a constant from both sides
138  *
139  * @deprecated Use SCIPchgLhsNonlinear() and SCIPchgRhsNonlinear() instead.
140  */
141 SCIP_EXPORT
143  SCIP* scip, /**< SCIP data structure */
144  SCIP_CONS* cons, /**< constraint */
145  SCIP_Real constant /**< constant to subtract from both sides */
146  );
147 
148 /** Adds a linear variable with coefficient to a quadratic constraint.
149  *
150  * @deprecated Use SCIPaddLinearVarNonlinear() instead.
151  */
152 SCIP_EXPORT
154  SCIP* scip, /**< SCIP data structure */
155  SCIP_CONS* cons, /**< constraint */
156  SCIP_VAR* var, /**< variable */
157  SCIP_Real coef /**< coefficient of variable */
158  );
159 
160 /** Adds a quadratic variable with linear and square coefficient to a quadratic constraint.
161  *
162  * @deprecated Use SCIPaddLinearVarNonlinear() and SCIPaddExprNonlinear() instead.
163  */
164 SCIP_EXPORT
166  SCIP* scip, /**< SCIP data structure */
167  SCIP_CONS* cons, /**< constraint */
168  SCIP_VAR* var, /**< variable */
169  SCIP_Real lincoef, /**< linear coefficient of variable */
170  SCIP_Real sqrcoef /**< square coefficient of variable */
171  );
172 
173 /** Adds a linear coefficient for a quadratic variable.
174  *
175  * Variable will be added with square coefficient 0.0 if not existing yet.
176  *
177  * @deprecated Use SCIPaddLinearVarNonlinear() instead.
178  */
179 SCIP_EXPORT
181  SCIP* scip, /**< SCIP data structure */
182  SCIP_CONS* cons, /**< constraint */
183  SCIP_VAR* var, /**< variable */
184  SCIP_Real coef /**< value to add to linear coefficient of variable */
185  );
186 
187 /** Adds a square coefficient for a quadratic variable.
188  *
189  * Variable will be added with linear coefficient 0.0 if not existing yet.
190  *
191  * @deprecated Use SCIPaddExprNonlinear() instead.
192  */
193 SCIP_EXPORT
195  SCIP* scip, /**< SCIP data structure */
196  SCIP_CONS* cons, /**< constraint */
197  SCIP_VAR* var, /**< variable */
198  SCIP_Real coef /**< value to add to square coefficient of variable */
199  );
200 
201 /** Adds a bilinear term to a quadratic constraint.
202  *
203  * Variables will be added with linear and square coefficient 0.0 if not existing yet.
204  * If variables are equal, only the square coefficient of the variable is updated.
205  *
206  * @deprecated Use SCIPaddExprNonlinear() instead.
207  */
208 SCIP_EXPORT
210  SCIP* scip, /**< SCIP data structure */
211  SCIP_CONS* cons, /**< constraint */
212  SCIP_VAR* var1, /**< first variable */
213  SCIP_VAR* var2, /**< second variable */
214  SCIP_Real coef /**< coefficient of bilinear term */
215  );
216 
217 /** Gets the quadratic constraint as a nonlinear row representation.
218  *
219  * @deprecated Use SCIPgetNlRowNonlinear() instead.
220  */
221 SCIP_EXPORT
223  SCIP* scip, /**< SCIP data structure */
224  SCIP_CONS* cons, /**< constraint */
225  SCIP_NLROW** nlrow /**< pointer to store nonlinear row */
226  );
227 
228 /** sets the left hand side of a quadratic constraint
229  *
230  * @note This method may only be called during problem creation stage for an original constraint.
231  *
232  * @deprecated Use SCIPchgLhsNonlinear() instead.
233  */
234 SCIP_EXPORT
236  SCIP* scip, /**< SCIP data structure */
237  SCIP_CONS* cons, /**< constraint data */
238  SCIP_Real lhs /**< new left hand side */
239  );
240 
241 /** sets the right hand side of a quadratic constraint
242  *
243  * @note This method may only be called during problem creation stage for an original constraint.
244  *
245  * @deprecated Use SCIPchgRhsNonlinear() instead.
246  */
247 SCIP_EXPORT
249  SCIP* scip, /**< SCIP data structure */
250  SCIP_CONS* cons, /**< constraint data */
251  SCIP_Real rhs /**< new right hand side */
252  );
253 
254 /** @} */
255 /** @} */
256 
257 #ifdef __cplusplus
258 }
259 #endif
260 
261 #endif
SCIP_RETCODE SCIPaddQuadVarQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real lincoef, SCIP_Real sqrcoef)
void SCIPaddConstantQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_Real constant)
type definitions for NLP management
SCIP_RETCODE SCIPaddSquareCoefQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real coef)
SCIP_RETCODE SCIPchgRhsQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_Real rhs)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
type definitions for return codes for SCIP methods
SCIP_RETCODE SCIPcreateConsBasicQuadratic(SCIP *scip, SCIP_CONS **cons, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nquadterms, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoefs, SCIP_Real lhs, SCIP_Real rhs)
SCIP_RETCODE SCIPaddLinearVarQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real coef)
SCIP_RETCODE SCIPcreateConsQuadratic(SCIP *scip, SCIP_CONS **cons, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nquadterms, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoeffs, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable)
SCIP_RETCODE SCIPchgLhsQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_Real lhs)
type definitions for SCIP&#39;s main datastructure
SCIP_RETCODE SCIPgetNlRowQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_NLROW **nlrow)
type definitions for problem variables
SCIP_RETCODE SCIPaddBilinTermQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var1, SCIP_VAR *var2, SCIP_Real coef)
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:173
SCIP_RETCODE SCIPaddQuadVarLinearCoefQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real coef)
common defines and data types used in all packages of SCIP
type definitions for constraints and constraint handlers