Scippy

SCIP

Solving Constraint Integer Programs

expr_pow.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-2023 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 expr_pow.h
26  * @ingroup EXPRHDLRS
27  * @brief power and signed power expression handlers
28  * @author Benjamin Mueller
29  */
30 
31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32 
33 #ifndef __SCIP_EXPR_POW_H__
34 #define __SCIP_EXPR_POW_H__
35 
36 #include "scip/scip.h"
37 #include "scip/type_expr.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /**@addtogroup EXPRHDLRS
44  *
45  * @{
46  *
47  * @name Power and signed power expression
48  *
49  * These expression handlers provide the power function, that is,
50  * \f[
51  * x \mapsto \begin{cases}
52  * x^e & \textrm{if}\; x \geq 0\; \textrm{or}\; e\in\mathbb{Z}, \\
53  * \textrm{undefined}, & \textrm{otherwise}.
54  * \end{cases}
55  * \f]
56  * and the signed power function, that is,
57  * \f[
58  * x \mapsto \textrm{sign}(x) |x|^e
59  * \f]
60  * for some exponent \f$e\f$.
61  *
62  * @{
63  */
64 
65 /** creates a power expression */
66 SCIP_EXPORT
68  SCIP* scip, /**< SCIP data structure */
69  SCIP_EXPR** expr, /**< pointer where to store expression */
70  SCIP_EXPR* child, /**< single child */
71  SCIP_Real exponent, /**< exponent of the power expression */
72  SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), /**< function to call to create ownerdata */
73  void* ownercreatedata /**< data to pass to ownercreate */
74  );
75 
76 /** creates a signpower expression */
77 SCIP_EXPORT
79  SCIP* scip, /**< SCIP data structure */
80  SCIP_EXPR** expr, /**< pointer where to store expression */
81  SCIP_EXPR* child, /**< single child */
82  SCIP_Real exponent, /**< exponent of the power expression */
83  SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), /**< function to call to create ownerdata */
84  void* ownercreatedata /**< data to pass to ownercreate */
85  );
86 
87 /** indicates whether expression is of signpower-type */
88 SCIP_EXPORT
90  SCIP* scip, /**< SCIP data structure */
91  SCIP_EXPR* expr /**< expression */
92  );
93 
94 /** @}
95  * @}
96  */
97 
98 /** creates the handler for power expression and includes it into SCIP
99  *
100  * @ingroup ExprhdlrIncludes
101  */
102 SCIP_EXPORT
104  SCIP* scip /**< SCIP data structure */
105  );
106 
107 /** creates the handler for signed power expression and includes it into SCIP
108  *
109  * @ingroup ExprhdlrIncludes
110  */
111 SCIP_EXPORT
113  SCIP* scip /**< SCIP data structure */
114  );
115 
116 /** computes coefficients of linearization of a square term in a reference point */
117 SCIP_EXPORT
119  SCIP* scip, /**< SCIP data structure */
120  SCIP_Real sqrcoef, /**< coefficient of square term */
121  SCIP_Real refpoint, /**< point where to linearize */
122  SCIP_Bool isint, /**< whether corresponding variable is a discrete variable, and thus linearization could be moved */
123  SCIP_Real* lincoef, /**< buffer to add coefficient of linearization */
124  SCIP_Real* linconstant, /**< buffer to add constant of linearization */
125  SCIP_Bool* success /**< buffer to set to FALSE if linearization has failed due to large numbers */
126  );
127 
128 /** computes coefficients of secant of a square term */
129 SCIP_EXPORT
131  SCIP* scip, /**< SCIP data structure */
132  SCIP_Real sqrcoef, /**< coefficient of square term */
133  SCIP_Real lb, /**< lower bound on variable */
134  SCIP_Real ub, /**< upper bound on variable */
135  SCIP_Real* lincoef, /**< buffer to add coefficient of secant */
136  SCIP_Real* linconstant, /**< buffer to add constant of secant */
137  SCIP_Bool* success /**< buffer to set to FALSE if secant has failed due to large numbers or unboundedness */
138  );
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* __SCIP_EXPR_POW_H__ */
void SCIPaddSquareLinearization(SCIP *scip, SCIP_Real sqrcoef, SCIP_Real refpoint, SCIP_Bool isint, SCIP_Real *lincoef, SCIP_Real *linconstant, SCIP_Bool *success)
Definition: expr_pow.c:3235
SCIP_RETCODE SCIPcreateExprPow(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_Real exponent, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
Definition: expr_pow.c:3175
SCIP_RETCODE SCIPcreateExprSignpower(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_Real exponent, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
Definition: expr_pow.c:3199
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
#define SCIP_Bool
Definition: def.h:93
#define SCIP_DECL_EXPR_OWNERCREATE(x)
Definition: type_expr.h:140
SCIP_RETCODE SCIPincludeExprhdlrSignpower(SCIP *scip)
Definition: expr_pow.c:3146
void SCIPaddSquareSecant(SCIP *scip, SCIP_Real sqrcoef, SCIP_Real lb, SCIP_Real ub, SCIP_Real *lincoef, SCIP_Real *linconstant, SCIP_Bool *success)
Definition: expr_pow.c:3303
type and macro definitions related to algebraic expressions
SCIP_Bool SCIPisExprSignpower(SCIP *scip, SCIP_EXPR *expr)
Definition: expr_pow.c:3224
#define SCIP_Real
Definition: def.h:186
SCIP_RETCODE SCIPincludeExprhdlrPow(SCIP *scip)
Definition: expr_pow.c:3111
SCIP callable library.