Scippy

SCIP

Solving Constraint Integer Programs

cons_abspower.c
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-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file cons_abspower.c
17  * @ingroup DEFPLUGINS_CONS
18  * @brief some API functions of removed constraint handler for absolute power constraints \f$\textrm{lhs} \leq \textrm{sign}(x+a) |x+a|^n + c z \leq \textrm{rhs}\f$
19  * @author Stefan Vigerske
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include "scip/cons_abspower.h"
25 #include "scip/cons_nonlinear.h"
26 
27 
28 /** creates and captures an absolute power nonlinear constraint
29  *
30  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
31  *
32  * @deprecated Use SCIPcreateConsNonlinear() instead.
33  */
35  SCIP* scip, /**< SCIP data structure */
36  SCIP_CONS** cons, /**< pointer to hold the created constraint */
37  const char* name, /**< name of constraint */
38  SCIP_VAR* x, /**< nonlinear variable x in constraint */
39  SCIP_VAR* z, /**< linear variable z in constraint */
40  SCIP_Real exponent, /**< exponent n of |x+offset|^n term in constraint */
41  SCIP_Real xoffset, /**< offset in |x+offset|^n term in constraint */
42  SCIP_Real zcoef, /**< coefficient of z in constraint */
43  SCIP_Real lhs, /**< left hand side of constraint */
44  SCIP_Real rhs, /**< right hand side of constraint */
45  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
46  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
47  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
48  * Usually set to TRUE. */
49  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
50  * TRUE for model constraints, FALSE for additional, redundant constraints. */
51  SCIP_Bool check, /**< should the constraint be checked for feasibility?
52  * TRUE for model constraints, FALSE for additional, redundant constraints. */
53  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
54  * Usually set to TRUE. */
55  SCIP_Bool local, /**< is constraint only valid locally?
56  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
57  SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
58  * Usually set to FALSE. In column generation applications, set to TRUE if pricing
59  * adds coefficients to this constraint. */
60  SCIP_Bool dynamic, /**< is constraint subject to aging?
61  * Usually set to FALSE. Set to TRUE for own cuts which
62  * are separated as constraints. */
63  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
64  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
65  SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
66  * if it may be moved to a more global node?
67  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
68  )
69 {
70  SCIP_CALL( SCIPcreateConsBasicSignpowerNonlinear(scip, cons, name, x, z, exponent, xoffset, zcoef, lhs, rhs) );
71 
72  SCIP_CALL( SCIPsetConsInitial(scip, *cons, initial) );
73  SCIP_CALL( SCIPsetConsSeparated(scip, *cons, separate) );
74  SCIP_CALL( SCIPsetConsEnforced(scip, *cons, enforce) );
75  SCIP_CALL( SCIPsetConsChecked(scip, *cons, check) );
76  SCIP_CALL( SCIPsetConsPropagated(scip, *cons, propagate) );
77  SCIP_CALL( SCIPsetConsLocal(scip, *cons, local) );
78  SCIP_CALL( SCIPsetConsModifiable(scip, *cons, modifiable) );
79  SCIP_CALL( SCIPsetConsDynamic(scip, *cons, dynamic) );
80  SCIP_CALL( SCIPsetConsRemovable(scip, *cons, removable) );
81  SCIP_CALL( SCIPsetConsStickingAtNode(scip, *cons, stickingatnode) );
82 
83  return SCIP_OKAY;
84 }
85 
86 /** creates and captures an absolute power nonlinear constraint
87  * in its most basic version, i.e., all constraint flags are set to their basic value
88  *
89  * All flags can be set via SCIPconsSetFLAGNAME-methods.
90  *
91  * @see SCIPcreateConsAbspower() for information about the basic constraint flag configuration
92  *
93  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
94  *
95  * @deprecated Use SCIPcreateConsBasicNonlinear() instead.
96  */
98  SCIP* scip, /**< SCIP data structure */
99  SCIP_CONS** cons, /**< pointer to hold the created constraint */
100  const char* name, /**< name of constraint */
101  SCIP_VAR* x, /**< nonlinear variable x in constraint */
102  SCIP_VAR* z, /**< linear variable z in constraint */
103  SCIP_Real exponent, /**< exponent n of |x+offset|^n term in constraint */
104  SCIP_Real xoffset, /**< offset in |x+offset|^n term in constraint */
105  SCIP_Real zcoef, /**< coefficient of z in constraint */
106  SCIP_Real lhs, /**< left hand side of constraint */
107  SCIP_Real rhs /**< right hand side of constraint */
108  )
109 {
110  SCIP_CALL( SCIPcreateConsBasicSignpowerNonlinear(scip, cons, name, x, z, exponent, xoffset, zcoef, lhs, rhs) );
111 
112  return SCIP_OKAY;
113 }
114 
115 /** gets the absolute power constraint as a nonlinear row representation
116  *
117  * @deprecated Use SCIPgetNlRowNonlinear)_ instead.
118  */
120  SCIP* scip, /**< SCIP data structure */
121  SCIP_CONS* cons, /**< constraint */
122  SCIP_NLROW** nlrow /**< a buffer where to store pointer to nonlinear row */
123  )
124 {
125  assert(cons != NULL);
126  assert(strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), "nonlinear") == 0);
127 
128  SCIP_CALL( SCIPgetNlRowNonlinear(scip, cons, nlrow) );
129 
130  return SCIP_OKAY;
131 }
SCIP_RETCODE SCIPcreateConsBasicSignpowerNonlinear(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *x, SCIP_VAR *z, SCIP_Real exponent, SCIP_Real xoffset, SCIP_Real zcoef, SCIP_Real lhs, SCIP_Real rhs)
SCIP_RETCODE SCIPsetConsPropagated(SCIP *scip, SCIP_CONS *cons, SCIP_Bool propagate)
Definition: scip_cons.c:1308
SCIP_RETCODE SCIPgetNlRowNonlinear(SCIP *scip, SCIP_CONS *cons, SCIP_NLROW **nlrow)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_VAR ** x
Definition: circlepacking.c:54
SCIP_RETCODE SCIPcreateConsBasicAbspower(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *x, SCIP_VAR *z, SCIP_Real exponent, SCIP_Real xoffset, SCIP_Real zcoef, SCIP_Real lhs, SCIP_Real rhs)
Definition: cons_abspower.c:97
SCIP_RETCODE SCIPsetConsSeparated(SCIP *scip, SCIP_CONS *cons, SCIP_Bool separate)
Definition: scip_cons.c:1233
SCIP_RETCODE SCIPsetConsRemovable(SCIP *scip, SCIP_CONS *cons, SCIP_Bool removable)
Definition: scip_cons.c:1411
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4175
SCIP_RETCODE SCIPsetConsChecked(SCIP *scip, SCIP_CONS *cons, SCIP_Bool check)
Definition: scip_cons.c:1283
SCIP_RETCODE SCIPsetConsDynamic(SCIP *scip, SCIP_CONS *cons, SCIP_Bool dynamic)
Definition: scip_cons.c:1386
#define NULL
Definition: lpi_spx1.cpp:155
#define SCIP_CALL(x)
Definition: def.h:384
#define SCIP_Bool
Definition: def.h:84
SCIP_RETCODE SCIPsetConsLocal(SCIP *scip, SCIP_CONS *cons, SCIP_Bool local)
Definition: scip_cons.c:1335
constraint handler for nonlinear constraints specified by algebraic expressions
SCIP_RETCODE SCIPgetNlRowAbspower(SCIP *scip, SCIP_CONS *cons, SCIP_NLROW **nlrow)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8105
SCIP_RETCODE SCIPcreateConsAbspower(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *x, SCIP_VAR *z, SCIP_Real exponent, SCIP_Real xoffset, SCIP_Real zcoef, 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_Bool stickingatnode)
Definition: cons_abspower.c:34
some API functions of removed constraint handler for absolute power constraints
SCIP_RETCODE SCIPsetConsStickingAtNode(SCIP *scip, SCIP_CONS *cons, SCIP_Bool stickingatnode)
Definition: scip_cons.c:1436
SCIP_RETCODE SCIPsetConsEnforced(SCIP *scip, SCIP_CONS *cons, SCIP_Bool enforce)
Definition: scip_cons.c:1258
#define SCIP_Real
Definition: def.h:177
SCIP_RETCODE SCIPsetConsModifiable(SCIP *scip, SCIP_CONS *cons, SCIP_Bool modifiable)
Definition: scip_cons.c:1361
SCIP_RETCODE SCIPsetConsInitial(SCIP *scip, SCIP_CONS *cons, SCIP_Bool initial)
Definition: scip_cons.c:1208