Scippy

SCIP

Solving Constraint Integer Programs

nlhdlr_soc.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 nlhdlr_soc.h
26  * @ingroup NLHDLRS
27  * @brief soc nonlinear handler
28  *
29  * @author Benjamin Mueller
30  * @author Fabian Wegscheider
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #ifndef __SCIP_NLHDLR_SOC_H__
36 #define __SCIP_NLHDLR_SOC_H__
37 
38 #include "scip/scip.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /** includes SOC nonlinear handler in nonlinear constraint handler
45  *
46  * @ingroup NlhdlrIncludes
47  */
48 SCIP_EXPORT
50  SCIP* scip /**< SCIP data structure */
51  );
52 
53 /**@addtogroup NLHDLRS
54  *
55  * @{
56  *
57  * @name SOC nonlinear handler
58  *
59  * This nonlinear handler detects second-order cone constraints in the extended formulation and provides specialized separation functionality.
60  *
61  * @{
62  */
63 
64 /** checks whether constraint is SOC representable in original variables and returns the SOC representation
65  *
66  * The SOC representation has the form:
67  * \f$\sqrt{\sum_{i=1}^{n} (v_i^T x + \beta_i)^2} - v_{n+1}^T x - \beta_{n+1} \lessgtr 0\f$,
68  * where \f$n+1 = \text{nterms}\f$ and the inequality type is given by sidetype (`SCIP_SIDETYPE_RIGHT` if inequality
69  * is \f$\leq\f$, `SCIP_SIDETYPE_LEFT` if \f$\geq\f$).
70  *
71  * For each term (i.e. for each \f$i\f$ in the above notation as well as \f$n+1\f$), the constant \f$\beta_i\f$ is given by the
72  * corresponding element `offsets[i-1]` and `termbegins[i-1]` is the starting position of the term in arrays
73  * `transcoefs` and `transcoefsidx`. The overall number of nonzeros is `termbegins[nterms]`.
74  *
75  * Arrays `transcoefs` and `transcoefsidx` have size `termbegins[nterms]` and define the linear expressions \f$v_i^T x\f$
76  * for each term. For a term \f$i\f$ in the above notation, the nonzeroes are given by elements
77  * `termbegins[i-1]...termbegins[i]` of `transcoefs` and `transcoefsidx`. There may be no nonzeroes for some term (i.e.,
78  * constant terms are possible). `transcoefs` contains the coefficients \f$v_i\f$ and `transcoefsidx` contains positions of
79  * variables in the `vars` array.
80  *
81  * The `vars` array has size `nvars` and contains \f$x\f$ variables; each variable is included at most once.
82  *
83  * The arrays should be freed by calling SCIPfreeSOCArraysNonlinear().
84  *
85  * This function uses the methods that are used in the detection algorithm of the SOC nonlinear handler.
86  */
87 SCIP_EXPORT
89  SCIP* scip, /**< SCIP data structure */
90  SCIP_CONS* cons, /**< nonlinear constraint */
91  SCIP_Bool compeigenvalues, /**< whether eigenvalues should be computed to detect complex cases */
92  SCIP_Bool* success, /**< pointer to store whether SOC structure has been detected */
93  SCIP_SIDETYPE* sidetype, /**< pointer to store which side of cons is SOC representable; only
94  valid when success is TRUE */
95  SCIP_VAR*** vars, /**< variables (x) that appear on both sides; no duplicates are allowed */
96  SCIP_Real** offsets, /**< offsets of both sides (beta_i) */
97  SCIP_Real** transcoefs, /**< non-zeros of linear transformation vectors (v_i) */
98  int** transcoefsidx, /**< mapping of transformation coefficients to variable indices in vars */
99  int** termbegins, /**< starting indices of transcoefs for each term */
100  int* nvars, /**< total number of variables appearing (i.e. size of vars) */
101  int* nterms /**< number of summands in the SQRT +1 for RHS (n+1) */
102  );
103 
104 /** frees arrays created by SCIPisSOCNonlinear() */
105 SCIP_EXPORT
107  SCIP* scip, /**< SCIP data structure */
108  SCIP_VAR*** vars, /**< variables that appear on both sides (x) */
109  SCIP_Real** offsets, /**< offsets of both sides (beta_i) */
110  SCIP_Real** transcoefs, /**< non-zeros of linear transformation vectors (v_i) */
111  int** transcoefsidx, /**< mapping of transformation coefficients to variable indices in vars */
112  int** termbegins, /**< starting indices of transcoefs for each term */
113  int nvars, /**< total number of variables appearing */
114  int nterms /**< number of summands in the SQRT +1 for RHS (n+1) */
115  );
116 
117 /** @}
118  * @}
119  */
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* __SCIP_NLHDLR_SOC_H__ */
static volatile int nterms
Definition: interrupt.c:47
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
void SCIPfreeSOCArraysNonlinear(SCIP *scip, SCIP_VAR ***vars, SCIP_Real **offsets, SCIP_Real **transcoefs, int **transcoefsidx, int **termbegins, int nvars, int nterms)
Definition: nlhdlr_soc.c:3297
#define SCIP_Bool
Definition: def.h:91
SCIP_RETCODE SCIPincludeNlhdlrSoc(SCIP *scip)
Definition: nlhdlr_soc.c:3149
#define SCIP_Real
Definition: def.h:173
SCIP_RETCODE SCIPisSOCNonlinear(SCIP *scip, SCIP_CONS *cons, SCIP_Bool compeigenvalues, SCIP_Bool *success, SCIP_SIDETYPE *sidetype, SCIP_VAR ***vars, SCIP_Real **offsets, SCIP_Real **transcoefs, int **transcoefsidx, int **termbegins, int *nvars, int *nterms)
Definition: nlhdlr_soc.c:3207
SCIP callable library.
enum SCIP_SideType SCIP_SIDETYPE
Definition: type_lp.h:67