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-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_abspower.c
26 * @ingroup DEFPLUGINS_CONS
27 * @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$
28 * @author Stefan Vigerske
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#include "scip/cons_abspower.h"
34#include "scip/cons_nonlinear.h"
35
36
37/** creates and captures an absolute power nonlinear constraint
38 *
39 * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
40 *
41 * @deprecated Use SCIPcreateConsNonlinear() instead.
42 */
44 SCIP* scip, /**< SCIP data structure */
45 SCIP_CONS** cons, /**< pointer to hold the created constraint */
46 const char* name, /**< name of constraint */
47 SCIP_VAR* x, /**< nonlinear variable x in constraint */
48 SCIP_VAR* z, /**< linear variable z in constraint */
49 SCIP_Real exponent, /**< exponent n of |x+offset|^n term in constraint */
50 SCIP_Real xoffset, /**< offset in |x+offset|^n term in constraint */
51 SCIP_Real zcoef, /**< coefficient of z in constraint */
52 SCIP_Real lhs, /**< left hand side of constraint */
53 SCIP_Real rhs, /**< right hand side of constraint */
54 SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
55 * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
56 SCIP_Bool separate, /**< should the constraint be separated during LP processing?
57 * Usually set to TRUE. */
58 SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
59 * TRUE for model constraints, FALSE for additional, redundant constraints. */
60 SCIP_Bool check, /**< should the constraint be checked for feasibility?
61 * TRUE for model constraints, FALSE for additional, redundant constraints. */
62 SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
63 * Usually set to TRUE. */
64 SCIP_Bool local, /**< is constraint only valid locally?
65 * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
66 SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
67 * Usually set to FALSE. In column generation applications, set to TRUE if pricing
68 * adds coefficients to this constraint. */
69 SCIP_Bool dynamic, /**< is constraint subject to aging?
70 * Usually set to FALSE. Set to TRUE for own cuts which
71 * are separated as constraints. */
72 SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
73 * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
74 SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
75 * if it may be moved to a more global node?
76 * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
77 )
78{
79 SCIP_CALL( SCIPcreateConsBasicSignpowerNonlinear(scip, cons, name, x, z, exponent, xoffset, zcoef, lhs, rhs) );
80
81 SCIP_CALL( SCIPsetConsInitial(scip, *cons, initial) );
82 SCIP_CALL( SCIPsetConsSeparated(scip, *cons, separate) );
83 SCIP_CALL( SCIPsetConsEnforced(scip, *cons, enforce) );
84 SCIP_CALL( SCIPsetConsChecked(scip, *cons, check) );
85 SCIP_CALL( SCIPsetConsPropagated(scip, *cons, propagate) );
86 SCIP_CALL( SCIPsetConsLocal(scip, *cons, local) );
87 SCIP_CALL( SCIPsetConsModifiable(scip, *cons, modifiable) );
88 SCIP_CALL( SCIPsetConsDynamic(scip, *cons, dynamic) );
89 SCIP_CALL( SCIPsetConsRemovable(scip, *cons, removable) );
90 SCIP_CALL( SCIPsetConsStickingAtNode(scip, *cons, stickingatnode) );
91
92 return SCIP_OKAY;
93}
94
95/** creates and captures an absolute power nonlinear constraint
96 * in its most basic version, i.e., all constraint flags are set to their basic value
97 *
98 * All flags can be set via SCIPconsSetFLAGNAME-methods.
99 *
100 * @see SCIPcreateConsAbspower() for information about the basic constraint flag configuration
101 *
102 * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
103 *
104 * @deprecated Use SCIPcreateConsBasicNonlinear() instead.
105 */
107 SCIP* scip, /**< SCIP data structure */
108 SCIP_CONS** cons, /**< pointer to hold the created constraint */
109 const char* name, /**< name of constraint */
110 SCIP_VAR* x, /**< nonlinear variable x in constraint */
111 SCIP_VAR* z, /**< linear variable z in constraint */
112 SCIP_Real exponent, /**< exponent n of |x+offset|^n term in constraint */
113 SCIP_Real xoffset, /**< offset in |x+offset|^n term in constraint */
114 SCIP_Real zcoef, /**< coefficient of z in constraint */
115 SCIP_Real lhs, /**< left hand side of constraint */
116 SCIP_Real rhs /**< right hand side of constraint */
117 )
118{
119 SCIP_CALL( SCIPcreateConsBasicSignpowerNonlinear(scip, cons, name, x, z, exponent, xoffset, zcoef, lhs, rhs) );
120
121 return SCIP_OKAY;
122}
123
124/** gets the absolute power constraint as a nonlinear row representation
125 *
126 * @deprecated Use SCIPgetNlRowNonlinear)_ instead.
127 */
129 SCIP* scip, /**< SCIP data structure */
130 SCIP_CONS* cons, /**< constraint */
131 SCIP_NLROW** nlrow /**< a buffer where to store pointer to nonlinear row */
132 )
133{
134 assert(cons != NULL);
135 assert(strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), "nonlinear") == 0);
136
137 SCIP_CALL( SCIPgetNlRowNonlinear(scip, cons, nlrow) );
138
139 return SCIP_OKAY;
140}
SCIP_VAR ** x
Definition: circlepacking.c:63
some API functions of removed constraint handler for absolute power constraints
constraint handler for nonlinear constraints specified by algebraic expressions
#define NULL
Definition: def.h:267
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:173
#define SCIP_CALL(x)
Definition: def.h:374
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 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)
SCIP_RETCODE SCIPgetNlRowNonlinear(SCIP *scip, SCIP_CONS *cons, SCIP_NLROW **nlrow)
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:43
SCIP_RETCODE SCIPgetNlRowAbspower(SCIP *scip, SCIP_CONS *cons, SCIP_NLROW **nlrow)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4197
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8234
SCIP_RETCODE SCIPsetConsStickingAtNode(SCIP *scip, SCIP_CONS *cons, SCIP_Bool stickingatnode)
Definition: scip_cons.c:1500
SCIP_RETCODE SCIPsetConsSeparated(SCIP *scip, SCIP_CONS *cons, SCIP_Bool separate)
Definition: scip_cons.c:1297
SCIP_RETCODE SCIPsetConsDynamic(SCIP *scip, SCIP_CONS *cons, SCIP_Bool dynamic)
Definition: scip_cons.c:1450
SCIP_RETCODE SCIPsetConsInitial(SCIP *scip, SCIP_CONS *cons, SCIP_Bool initial)
Definition: scip_cons.c:1272
SCIP_RETCODE SCIPsetConsEnforced(SCIP *scip, SCIP_CONS *cons, SCIP_Bool enforce)
Definition: scip_cons.c:1322
SCIP_RETCODE SCIPsetConsModifiable(SCIP *scip, SCIP_CONS *cons, SCIP_Bool modifiable)
Definition: scip_cons.c:1425
SCIP_RETCODE SCIPsetConsRemovable(SCIP *scip, SCIP_CONS *cons, SCIP_Bool removable)
Definition: scip_cons.c:1475
SCIP_RETCODE SCIPsetConsLocal(SCIP *scip, SCIP_CONS *cons, SCIP_Bool local)
Definition: scip_cons.c:1399
SCIP_RETCODE SCIPsetConsPropagated(SCIP *scip, SCIP_CONS *cons, SCIP_Bool propagate)
Definition: scip_cons.c:1372
SCIP_RETCODE SCIPsetConsChecked(SCIP *scip, SCIP_CONS *cons, SCIP_Bool check)
Definition: scip_cons.c:1347
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63