1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /*                                                                           */
3 /*                  This file is part of the program and library             */
4 /*         SCIP --- Solving Constraint Integer Programs                      */
5 /*                                                                           */
6 /*    Copyright (C) 2002-2021 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   scip_cons.c
17  * @ingroup OTHER_CFILES
18  * @brief  public methods for constraint handler plugins and constraints
19  * @author Tobias Achterberg
20  * @author Timo Berthold
21  * @author Gerald Gamrath
22  * @author Leona Gottwald
23  * @author Stefan Heinz
24  * @author Gregor Hendel
25  * @author Thorsten Koch
26  * @author Alexander Martin
27  * @author Marc Pfetsch
28  * @author Michael Winkler
29  * @author Kati Wolter
30  *
31  * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
32  */
33 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 
36 #include "scip/cons.h"
37 #include "scip/debug.h"
38 #include "scip/prob.h"
39 #include "scip/pub_cons.h"
40 #include "scip/pub_message.h"
41 #include "scip/pub_misc.h"
42 #include "scip/scip_cons.h"
43 #include "scip/scip_general.h"
44 #include "scip/scip_mem.h"
45 #include "scip/set.h"
46 #include "scip/struct_cons.h"
47 #include "scip/struct_mem.h"
48 #include "scip/struct_scip.h"
49 #include "scip/struct_set.h"
50 
51 /* In debug mode, the following methods are implemented as function calls to ensure
52  * type validity.
53  * In optimized mode, the methods are implemented as defines to improve performance.
54  * However, we want to have them in the library anyways, so we have to undef the defines.
55  */
56 
57 #undef SCIPmarkConsPropagate
58 
59 /** creates a constraint handler and includes it in SCIP.
60  *
61  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
62  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
63  *
64  *  @pre This method can be called if SCIP is in one of the following stages:
65  *       - \ref SCIP_STAGE_INIT
66  *       - \ref SCIP_STAGE_PROBLEM
67  *
68  *  @note method has all constraint handler callbacks as arguments and is thus changed every time a new
69  *        callback is added
70  *        in future releases; consider using SCIPincludeConshdlrBasic() and setter functions
71  *        if you seek for a method which is less likely to change in future releases
72  */
SCIPincludeConshdlr(SCIP * scip,const char * name,const char * desc,int sepapriority,int enfopriority,int chckpriority,int sepafreq,int propfreq,int eagerfreq,int maxprerounds,SCIP_Bool delaysepa,SCIP_Bool delayprop,SCIP_Bool needscons,SCIP_PROPTIMING proptiming,SCIP_PRESOLTIMING presoltiming,SCIP_DECL_CONSHDLRCOPY ((* conshdlrcopy)),SCIP_DECL_CONSFREE ((* consfree)),SCIP_DECL_CONSINIT ((* consinit)),SCIP_DECL_CONSEXIT ((* consexit)),SCIP_DECL_CONSINITPRE ((* consinitpre)),SCIP_DECL_CONSEXITPRE ((* consexitpre)),SCIP_DECL_CONSINITSOL ((* consinitsol)),SCIP_DECL_CONSEXITSOL ((* consexitsol)),SCIP_DECL_CONSDELETE ((* consdelete)),SCIP_DECL_CONSTRANS ((* constrans)),SCIP_DECL_CONSINITLP ((* consinitlp)),SCIP_DECL_CONSSEPALP ((* conssepalp)),SCIP_DECL_CONSSEPASOL ((* conssepasol)),SCIP_DECL_CONSENFOLP ((* consenfolp)),SCIP_DECL_CONSENFORELAX ((* consenforelax)),SCIP_DECL_CONSENFOPS ((* consenfops)),SCIP_DECL_CONSCHECK ((* conscheck)),SCIP_DECL_CONSPROP ((* consprop)),SCIP_DECL_CONSPRESOL ((* conspresol)),SCIP_DECL_CONSRESPROP ((* consresprop)),SCIP_DECL_CONSLOCK ((* conslock)),SCIP_DECL_CONSACTIVE ((* consactive)),SCIP_DECL_CONSDEACTIVE ((* consdeactive)),SCIP_DECL_CONSENABLE ((* consenable)),SCIP_DECL_CONSDISABLE ((* consdisable)),SCIP_DECL_CONSDELVARS ((* consdelvars)),SCIP_DECL_CONSPRINT ((* consprint)),SCIP_DECL_CONSCOPY ((* conscopy)),SCIP_DECL_CONSPARSE ((* consparse)),SCIP_DECL_CONSGETVARS ((* consgetvars)),SCIP_DECL_CONSGETNVARS ((* consgetnvars)),SCIP_DECL_CONSGETDIVEBDCHGS ((* consgetdivebdchgs)),SCIP_CONSHDLRDATA * conshdlrdata)73 SCIP_RETCODE SCIPincludeConshdlr(
74    SCIP*                 scip,               /**< SCIP data structure */
75    const char*           name,               /**< name of constraint handler */
76    const char*           desc,               /**< description of constraint handler */
77    int                   sepapriority,       /**< priority of the constraint handler for separation */
78    int                   enfopriority,       /**< priority of the constraint handler for constraint enforcing */
79    int                   chckpriority,       /**< priority of the constraint handler for checking feasibility (and propagation) */
80    int                   sepafreq,           /**< frequency for separating cuts; zero means to separate only in the root node */
81    int                   propfreq,           /**< frequency for propagating domains; zero means only preprocessing propagation */
82    int                   eagerfreq,          /**< frequency for using all instead of only the useful constraints in separation,
83                                               *   propagation and enforcement, -1 for no eager evaluations, 0 for first only */
84    int                   maxprerounds,       /**< maximal number of presolving rounds the constraint handler participates in (-1: no limit) */
85    SCIP_Bool             delaysepa,          /**< should separation method be delayed, if other separators found cuts? */
86    SCIP_Bool             delayprop,          /**< should propagation method be delayed, if other propagators found reductions? */
87    SCIP_Bool             needscons,          /**< should the constraint handler be skipped, if no constraints are available? */
88    SCIP_PROPTIMING       proptiming,         /**< positions in the node solving loop where propagation method of constraint handlers should be executed */
89    SCIP_PRESOLTIMING     presoltiming,       /**< timing mask of the constraint handler's presolving method */
90    SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)),  /**< copy method of constraint handler or NULL if you don't want to copy your plugin into sub-SCIPs */
91    SCIP_DECL_CONSFREE    ((*consfree)),      /**< destructor of constraint handler */
92    SCIP_DECL_CONSINIT    ((*consinit)),      /**< initialize constraint handler */
93    SCIP_DECL_CONSEXIT    ((*consexit)),      /**< deinitialize constraint handler */
94    SCIP_DECL_CONSINITPRE ((*consinitpre)),   /**< presolving initialization method of constraint handler */
95    SCIP_DECL_CONSEXITPRE ((*consexitpre)),   /**< presolving deinitialization method of constraint handler */
96    SCIP_DECL_CONSINITSOL ((*consinitsol)),   /**< solving process initialization method of constraint handler */
97    SCIP_DECL_CONSEXITSOL ((*consexitsol)),   /**< solving process deinitialization method of constraint handler */
98    SCIP_DECL_CONSDELETE  ((*consdelete)),    /**< free specific constraint data */
99    SCIP_DECL_CONSTRANS   ((*constrans)),     /**< transform constraint data into data belonging to the transformed problem */
100    SCIP_DECL_CONSINITLP  ((*consinitlp)),    /**< initialize LP with relaxations of "initial" constraints */
101    SCIP_DECL_CONSSEPALP  ((*conssepalp)),    /**< separate cutting planes for LP solution */
102    SCIP_DECL_CONSSEPASOL ((*conssepasol)),   /**< separate cutting planes for arbitrary primal solution */
103    SCIP_DECL_CONSENFOLP  ((*consenfolp)),    /**< enforcing constraints for LP solutions */
104    SCIP_DECL_CONSENFORELAX ((*consenforelax)), /**< enforcing constraints for relaxation solutions */
105    SCIP_DECL_CONSENFOPS  ((*consenfops)),    /**< enforcing constraints for pseudo solutions */
106    SCIP_DECL_CONSCHECK   ((*conscheck)),     /**< check feasibility of primal solution */
107    SCIP_DECL_CONSPROP    ((*consprop)),      /**< propagate variable domains */
108    SCIP_DECL_CONSPRESOL  ((*conspresol)),    /**< presolving method */
109    SCIP_DECL_CONSRESPROP ((*consresprop)),   /**< propagation conflict resolving method */
110    SCIP_DECL_CONSLOCK    ((*conslock)),      /**< variable rounding lock method */
111    SCIP_DECL_CONSACTIVE  ((*consactive)),    /**< activation notification method */
112    SCIP_DECL_CONSDEACTIVE((*consdeactive)),  /**< deactivation notification method */
113    SCIP_DECL_CONSENABLE  ((*consenable)),    /**< enabling notification method */
114    SCIP_DECL_CONSDISABLE ((*consdisable)),   /**< disabling notification method */
115    SCIP_DECL_CONSDELVARS ((*consdelvars)),   /**< variable deletion method */
116    SCIP_DECL_CONSPRINT   ((*consprint)),     /**< constraint display method */
117    SCIP_DECL_CONSCOPY    ((*conscopy)),      /**< constraint copying method */
118    SCIP_DECL_CONSPARSE   ((*consparse)),     /**< constraint parsing method */
119    SCIP_DECL_CONSGETVARS ((*consgetvars)),   /**< constraint get variables method */
120    SCIP_DECL_CONSGETNVARS((*consgetnvars)),  /**< constraint get number of variable method */
121    SCIP_DECL_CONSGETDIVEBDCHGS((*consgetdivebdchgs)), /**< constraint handler diving solution enforcement method */
122    SCIP_CONSHDLRDATA*    conshdlrdata        /**< constraint handler data */
123    )
124 {
125    SCIP_CONSHDLR* conshdlr;
126 
127    SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeConshdlr", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
128 
129    /* check whether constraint handler is already present */
130    if( SCIPfindConshdlr(scip, name) != NULL )
131    {
132       SCIPerrorMessage("constraint handler <%s> already included.\n", name);
133       return SCIP_INVALIDDATA;
134    }
135 
136    SCIP_CALL( SCIPconshdlrCreate(&conshdlr, scip->set, scip->messagehdlr, scip->mem->setmem,
137          name, desc, sepapriority, enfopriority, chckpriority, sepafreq, propfreq, eagerfreq, maxprerounds,
138          delaysepa, delayprop, needscons, proptiming, presoltiming, conshdlrcopy,
139          consfree, consinit, consexit, consinitpre, consexitpre, consinitsol, consexitsol,
140          consdelete, constrans, consinitlp, conssepalp, conssepasol, consenfolp, consenforelax, consenfops, conscheck, consprop,
141          conspresol, consresprop, conslock, consactive, consdeactive, consenable, consdisable, consdelvars, consprint,
142          conscopy, consparse, consgetvars, consgetnvars, consgetdivebdchgs, conshdlrdata) );
143    SCIP_CALL( SCIPsetIncludeConshdlr(scip->set, conshdlr) );
144 
145    return SCIP_OKAY;
146 }
147 
148 /** creates a constraint handler and includes it in SCIP. All non-fundamental (or optional) callbacks will be set to NULL.
149  *  Optional callbacks can be set via specific setter functions, see SCIPsetConshdlrInit(), SCIPsetConshdlrExit(),
150  *  SCIPsetConshdlrCopy(), SCIPsetConshdlrFree(), SCIPsetConshdlrInitsol(), SCIPsetConshdlrExitsol(),
151  *  SCIPsetConshdlrInitpre(), SCIPsetConshdlrExitpre(), SCIPsetConshdlrPresol(), SCIPsetConshdlrDelete(),
152  *  SCIPsetConshdlrDelvars(), SCIPsetConshdlrInitlp(), SCIPsetConshdlrActive(), SCIPsetConshdlrDeactive(),
153  *  SCIPsetConshdlrEnable(), SCIPsetConshdlrDisable(), SCIPsetConshdlrResprop(), SCIPsetConshdlrTrans(),
154  *  SCIPsetConshdlrPrint(), SCIPsetConshdlrParse(), SCIPsetConshdlrGetVars(), SCIPsetConshdlrGetNVars(), and
155  *  SCIPsetConshdlrGetDiveBdChgs().
156  *
157  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
158  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
159  *
160  *  @pre This method can be called if SCIP is in one of the following stages:
161  *       - \ref SCIP_STAGE_INIT
162  *       - \ref SCIP_STAGE_PROBLEM
163  *
164  *  @note if you want to set all callbacks with a single method call, consider using SCIPincludeConshdlr() instead
165  */
SCIPincludeConshdlrBasic(SCIP * scip,SCIP_CONSHDLR ** conshdlrptr,const char * name,const char * desc,int enfopriority,int chckpriority,int eagerfreq,SCIP_Bool needscons,SCIP_DECL_CONSENFOLP ((* consenfolp)),SCIP_DECL_CONSENFOPS ((* consenfops)),SCIP_DECL_CONSCHECK ((* conscheck)),SCIP_DECL_CONSLOCK ((* conslock)),SCIP_CONSHDLRDATA * conshdlrdata)166 SCIP_RETCODE SCIPincludeConshdlrBasic(
167    SCIP*                 scip,               /**< SCIP data structure */
168    SCIP_CONSHDLR**       conshdlrptr,        /**< reference to a constraint handler pointer, or NULL */
169    const char*           name,               /**< name of constraint handler */
170    const char*           desc,               /**< description of constraint handler */
171    int                   enfopriority,       /**< priority of the constraint handler for constraint enforcing */
172    int                   chckpriority,       /**< priority of the constraint handler for checking feasibility (and propagation) */
173    int                   eagerfreq,          /**< frequency for using all instead of only the useful constraints in separation,
174                                               *   propagation and enforcement, -1 for no eager evaluations, 0 for first only */
175    SCIP_Bool             needscons,          /**< should the constraint handler be skipped, if no constraints are available? */
176    SCIP_DECL_CONSENFOLP  ((*consenfolp)),    /**< enforcing constraints for LP solutions */
177    SCIP_DECL_CONSENFOPS  ((*consenfops)),    /**< enforcing constraints for pseudo solutions */
178    SCIP_DECL_CONSCHECK   ((*conscheck)),     /**< check feasibility of primal solution */
179    SCIP_DECL_CONSLOCK    ((*conslock)),      /**< variable rounding lock method */
180    SCIP_CONSHDLRDATA*    conshdlrdata        /**< constraint handler data */
181    )
182 {
183    SCIP_CONSHDLR* conshdlr;
184 
185    SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeConshdlrBasic", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
186 
187    /* check whether constraint handler is already present */
188    if( SCIPfindConshdlr(scip, name) != NULL )
189    {
190       SCIPerrorMessage("constraint handler <%s> already included.\n", name);
191       return SCIP_INVALIDDATA;
192    }
193 
194    SCIP_CALL( SCIPconshdlrCreate(&conshdlr, scip->set, scip->messagehdlr, scip->mem->setmem,
195          name, desc, 0, enfopriority, chckpriority, -1, -1, eagerfreq, 0,
196          FALSE, FALSE, needscons,
197          SCIP_PROPTIMING_BEFORELP, SCIP_PRESOLTIMING_ALWAYS,
198          NULL,
199          NULL, NULL, NULL, NULL, NULL, NULL, NULL,
200          NULL, NULL, NULL, NULL, NULL, consenfolp, NULL, consenfops, conscheck, NULL,
201          NULL, NULL, conslock, NULL, NULL, NULL, NULL, NULL, NULL,
202          NULL, NULL, NULL, NULL, NULL, conshdlrdata) );
203    SCIP_CALL( SCIPsetIncludeConshdlr(scip->set, conshdlr) );
204 
205    if( conshdlrptr != NULL )
206       *conshdlrptr = conshdlr;
207 
208    return SCIP_OKAY;
209 }
210 
211 /** sets all separation related callbacks/parameters of the constraint handler
212  *
213  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
214  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
215  *
216  *  @pre This method can be called if SCIP is in one of the following stages:
217  *       - \ref SCIP_STAGE_INIT
218  *       - \ref SCIP_STAGE_PROBLEM
219  */
SCIPsetConshdlrSepa(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSSEPALP ((* conssepalp)),SCIP_DECL_CONSSEPASOL ((* conssepasol)),int sepafreq,int sepapriority,SCIP_Bool delaysepa)220 SCIP_RETCODE SCIPsetConshdlrSepa(
221    SCIP*                 scip,               /**< SCIP data structure */
222    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
223    SCIP_DECL_CONSSEPALP  ((*conssepalp)),    /**< separate cutting planes for LP solution */
224    SCIP_DECL_CONSSEPASOL ((*conssepasol)),   /**< separate cutting planes for arbitrary primal solution */
225    int                   sepafreq,           /**< frequency for separating cuts; zero means to separate only in the root node */
226    int                   sepapriority,       /**< priority of the constraint handler for separation */
227    SCIP_Bool             delaysepa           /**< should separation method be delayed, if other separators found cuts? */
228    )
229 {
230    int oldsepapriority;
231    const char* name;
232    char paramname[SCIP_MAXSTRLEN];
233 
234    assert(scip != NULL);
235    assert(conshdlr != NULL);
236 
237    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrSepa", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
238 
239    oldsepapriority = SCIPconshdlrGetSepaPriority(conshdlr);
240    SCIPconshdlrSetSepa(conshdlr, conssepalp, conssepasol, sepafreq, sepapriority, delaysepa);
241 
242    /* change the position of the constraint handler in the constraint handler array w.r.t. its new sepa priority */
243    if( oldsepapriority != sepapriority )
244       SCIPsetReinsertConshdlrSepaPrio(scip->set, conshdlr, oldsepapriority);
245 
246    name = SCIPconshdlrGetName(conshdlr);
247 
248    (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/sepafreq", name);
249    SCIP_CALL( SCIPsetSetDefaultIntParam(scip->set, paramname, sepafreq) );
250 
251    (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/delaysepa", name);
252    SCIP_CALL( SCIPsetSetDefaultBoolParam(scip->set, paramname, delaysepa) );
253 
254    return SCIP_OKAY;
255 }
256 
257 /** sets both the propagation callback and the propagation frequency of the constraint handler
258  *
259  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
260  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
261  *
262  *  @pre This method can be called if SCIP is in one of the following stages:
263  *       - \ref SCIP_STAGE_INIT
264  *       - \ref SCIP_STAGE_PROBLEM
265  */
SCIPsetConshdlrProp(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSPROP ((* consprop)),int propfreq,SCIP_Bool delayprop,SCIP_PROPTIMING proptiming)266 SCIP_RETCODE SCIPsetConshdlrProp(
267    SCIP*                 scip,               /**< SCIP data structure */
268    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
269    SCIP_DECL_CONSPROP    ((*consprop)),      /**< propagate variable domains */
270    int                   propfreq,           /**< frequency for propagating domains; zero means only preprocessing propagation */
271    SCIP_Bool             delayprop,          /**< should propagation method be delayed, if other propagators found reductions? */
272    SCIP_PROPTIMING       proptiming          /**< positions in the node solving loop where propagation should be executed */
273    )
274 {
275    const char* name;
276    char paramname[SCIP_MAXSTRLEN];
277 
278    assert(scip != NULL);
279    assert(conshdlr != NULL);
280 
281    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrProp", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
282 
283    SCIPconshdlrSetProp(conshdlr, consprop, propfreq, delayprop, proptiming);
284 
285    name = SCIPconshdlrGetName(conshdlr);
286 
287    (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/propfreq", name);
288    SCIP_CALL( SCIPsetSetDefaultIntParam(scip->set, paramname, propfreq) );
289 
290    (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/proptiming", name);
291    SCIP_CALL( SCIPsetSetDefaultIntParam(scip->set, paramname, (int) proptiming) );
292 
293    (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/delayprop", name);
294    SCIP_CALL( SCIPsetSetDefaultBoolParam(scip->set, paramname, delayprop) );
295 
296    return SCIP_OKAY;
297 }
298 
299 /** sets relaxation enforcement method of the constraint handler
300  *
301  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
302  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
303  *
304  *  @pre This method can be called if SCIP is in one of the following stages:
305  *       - \ref SCIP_STAGE_INIT
306  *       - \ref SCIP_STAGE_PROBLEM
307  */
SCIPsetConshdlrEnforelax(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSENFORELAX ((* consenforelax)))308 SCIP_RETCODE SCIPsetConshdlrEnforelax(
309    SCIP*                 scip,               /**< SCIP data structure */
310    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
311    SCIP_DECL_CONSENFORELAX ((*consenforelax)) /**< enforcement method for relaxation solution of constraint handler (might be NULL) */
312    )
313 {
314    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrEnforelax", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
315 
316    assert(conshdlr != NULL);
317 
318    SCIPconshdlrSetEnforelax(conshdlr, consenforelax);
319 
320    return SCIP_OKAY;
321 }
322 
323 /** sets copy method of both the constraint handler and each associated constraint
324  *
325  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
326  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
327  *
328  *  @pre This method can be called if SCIP is in one of the following stages:
329  *       - \ref SCIP_STAGE_INIT
330  *       - \ref SCIP_STAGE_PROBLEM
331  */
SCIPsetConshdlrCopy(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSHDLRCOPY ((* conshdlrcopy)),SCIP_DECL_CONSCOPY ((* conscopy)))332 SCIP_RETCODE SCIPsetConshdlrCopy(
333    SCIP*                 scip,               /**< SCIP data structure */
334    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
335    SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)),  /**< copy method of constraint handler or NULL if you don't want to copy your plugin into sub-SCIPs */
336    SCIP_DECL_CONSCOPY    ((*conscopy))       /**< constraint copying method */
337    )
338 {
339    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrCopy", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
340 
341    assert(conshdlr != NULL);
342 
343    SCIPconshdlrSetCopy(conshdlr, conshdlrcopy, conscopy);
344 
345    return SCIP_OKAY;
346 }
347 
348 /** sets destructor method of constraint handler
349  *
350  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
351  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
352  *
353  *  @pre This method can be called if SCIP is in one of the following stages:
354  *       - \ref SCIP_STAGE_INIT
355  *       - \ref SCIP_STAGE_PROBLEM
356  */
SCIPsetConshdlrFree(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSFREE ((* consfree)))357 SCIP_RETCODE SCIPsetConshdlrFree(
358    SCIP*                 scip,               /**< SCIP data structure */
359    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
360    SCIP_DECL_CONSFREE    ((*consfree))       /**< destructor of constraint handler */
361    )
362 {
363    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrFree", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
364 
365    assert(conshdlr != NULL);
366 
367    SCIPconshdlrSetFree(conshdlr, consfree);
368 
369    return SCIP_OKAY;
370 }
371 
372 /** sets initialization method of constraint handler
373  *
374  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
375  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
376  *
377  *  @pre This method can be called if SCIP is in one of the following stages:
378  *       - \ref SCIP_STAGE_INIT
379  *       - \ref SCIP_STAGE_PROBLEM
380  */
SCIPsetConshdlrInit(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSINIT ((* consinit)))381 SCIP_RETCODE SCIPsetConshdlrInit(
382    SCIP*                 scip,               /**< SCIP data structure */
383    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
384    SCIP_DECL_CONSINIT    ((*consinit))       /**< initialize constraint handler */
385    )
386 {
387    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrInit", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
388 
389    assert(conshdlr != NULL);
390 
391    SCIPconshdlrSetInit(conshdlr, consinit);
392 
393    return SCIP_OKAY;
394 }
395 
396 /** sets deinitialization method of constraint handler
397  *
398  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
399  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
400  *
401  *  @pre This method can be called if SCIP is in one of the following stages:
402  *       - \ref SCIP_STAGE_INIT
403  *       - \ref SCIP_STAGE_PROBLEM
404  */
SCIPsetConshdlrExit(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSEXIT ((* consexit)))405 SCIP_RETCODE SCIPsetConshdlrExit(
406    SCIP*                 scip,               /**< SCIP data structure */
407    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
408    SCIP_DECL_CONSEXIT    ((*consexit))       /**< deinitialize constraint handler */
409    )
410 {
411    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrExit", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
412 
413    assert(conshdlr != NULL);
414 
415    SCIPconshdlrSetExit(conshdlr, consexit);
416 
417    return SCIP_OKAY;
418 }
419 
420 /** sets solving process initialization method of constraint handler
421  *
422  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
423  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
424  *
425  *  @pre This method can be called if SCIP is in one of the following stages:
426  *       - \ref SCIP_STAGE_INIT
427  *       - \ref SCIP_STAGE_PROBLEM
428  */
SCIPsetConshdlrInitsol(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSINITSOL ((* consinitsol)))429 SCIP_RETCODE SCIPsetConshdlrInitsol(
430    SCIP*                 scip,               /**< SCIP data structure */
431    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
432    SCIP_DECL_CONSINITSOL((*consinitsol))     /**< solving process initialization method of constraint handler */
433    )
434 {
435    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrInitsol", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
436 
437    assert(conshdlr != NULL);
438 
439    SCIPconshdlrSetInitsol(conshdlr, consinitsol);
440 
441    return SCIP_OKAY;
442 }
443 
444 /** sets solving process deinitialization method of constraint handler
445  *
446  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
447  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
448  *
449  *  @pre This method can be called if SCIP is in one of the following stages:
450  *       - \ref SCIP_STAGE_INIT
451  *       - \ref SCIP_STAGE_PROBLEM
452  */
SCIPsetConshdlrExitsol(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSEXITSOL ((* consexitsol)))453 SCIP_RETCODE SCIPsetConshdlrExitsol(
454    SCIP*                 scip,               /**< SCIP data structure */
455    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
456    SCIP_DECL_CONSEXITSOL ((*consexitsol))/**< solving process deinitialization method of constraint handler */
457    )
458 {
459    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrExitsol", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
460 
461    assert(conshdlr != NULL);
462 
463    SCIPconshdlrSetExitsol(conshdlr, consexitsol);
464 
465    return SCIP_OKAY;
466 }
467 
468 /** sets preprocessing initialization method of constraint handler
469  *
470  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
471  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
472  *
473  *  @pre This method can be called if SCIP is in one of the following stages:
474  *       - \ref SCIP_STAGE_INIT
475  *       - \ref SCIP_STAGE_PROBLEM
476  */
SCIPsetConshdlrInitpre(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSINITPRE ((* consinitpre)))477 SCIP_RETCODE SCIPsetConshdlrInitpre(
478    SCIP*                 scip,               /**< SCIP data structure */
479    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
480    SCIP_DECL_CONSINITPRE((*consinitpre))     /**< preprocessing initialization method of constraint handler */
481    )
482 {
483    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrInitpre", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
484 
485    assert(conshdlr != NULL);
486 
487    SCIPconshdlrSetInitpre(conshdlr, consinitpre);
488 
489    return SCIP_OKAY;
490 }
491 
492 /** sets preprocessing deinitialization method of constraint handler
493  *
494  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
495  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
496  *
497  *  @pre This method can be called if SCIP is in one of the following stages:
498  *       - \ref SCIP_STAGE_INIT
499  *       - \ref SCIP_STAGE_PROBLEM
500  */
SCIPsetConshdlrExitpre(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSEXITPRE ((* consexitpre)))501 SCIP_RETCODE SCIPsetConshdlrExitpre(
502    SCIP*                 scip,               /**< SCIP data structure */
503    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
504    SCIP_DECL_CONSEXITPRE((*consexitpre))     /**< preprocessing deinitialization method of constraint handler */
505    )
506 {
507    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrExitpre", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
508 
509    assert(conshdlr != NULL);
510 
511    SCIPconshdlrSetExitpre(conshdlr, consexitpre);
512 
513    return SCIP_OKAY;
514 }
515 
516 /** sets presolving method of constraint handler
517  *
518  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
519  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
520  *
521  *  @pre This method can be called if SCIP is in one of the following stages:
522  *       - \ref SCIP_STAGE_INIT
523  *       - \ref SCIP_STAGE_PROBLEM
524  */
SCIPsetConshdlrPresol(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSPRESOL ((* conspresol)),int maxprerounds,SCIP_PRESOLTIMING presoltiming)525 SCIP_RETCODE SCIPsetConshdlrPresol(
526    SCIP*                 scip,               /**< SCIP data structure */
527    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
528    SCIP_DECL_CONSPRESOL  ((*conspresol)),    /**< presolving method of constraint handler */
529    int                   maxprerounds,       /**< maximal number of presolving rounds the constraint handler participates in (-1: no limit) */
530    SCIP_PRESOLTIMING     presoltiming        /**< timing mask of the constraint handler's presolving method */
531    )
532 {
533    const char* name;
534    char paramname[SCIP_MAXSTRLEN];
535 
536    assert(scip != NULL);
537    assert(conshdlr != NULL);
538 
539    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrPresol", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
540 
541    SCIP_CALL( SCIPconshdlrSetPresol(conshdlr, conspresol, maxprerounds, presoltiming) );
542 
543    name = SCIPconshdlrGetName(conshdlr);
544 
545    (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/maxprerounds", name);
546    SCIP_CALL( SCIPsetSetDefaultIntParam(scip->set, paramname, maxprerounds) );
547 
548    (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/presoltiming", name);
549    SCIP_CALL( SCIPsetSetDefaultIntParam(scip->set, paramname, (int) presoltiming) );
550 
551    return SCIP_OKAY;
552 }
553 
554 /** sets method of constraint handler to free specific constraint data
555  *
556  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
557  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
558  *
559  *  @pre This method can be called if SCIP is in one of the following stages:
560  *       - \ref SCIP_STAGE_INIT
561  *       - \ref SCIP_STAGE_PROBLEM
562  */
SCIPsetConshdlrDelete(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSDELETE ((* consdelete)))563 SCIP_RETCODE SCIPsetConshdlrDelete(
564    SCIP*                 scip,               /**< SCIP data structure */
565    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
566    SCIP_DECL_CONSDELETE  ((*consdelete))     /**< free specific constraint data */
567    )
568 {
569    assert(scip != NULL);
570    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrDelete", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
571 
572    SCIPconshdlrSetDelete(conshdlr, consdelete);
573 
574    return SCIP_OKAY;
575 }
576 
577 /** sets method of constraint handler to transform constraint data into data belonging to the transformed problem
578  *
579  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
580  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
581  *
582  *  @pre This method can be called if SCIP is in one of the following stages:
583  *       - \ref SCIP_STAGE_INIT
584  *       - \ref SCIP_STAGE_PROBLEM
585  */
SCIPsetConshdlrTrans(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSTRANS ((* constrans)))586 SCIP_RETCODE SCIPsetConshdlrTrans(
587    SCIP*                 scip,               /**< SCIP data structure */
588    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
589    SCIP_DECL_CONSTRANS   ((*constrans))      /**< transform constraint data into data belonging to the transformed problem */
590    )
591 {
592    assert(scip != NULL);
593    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrTrans", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
594 
595    SCIPconshdlrSetTrans(conshdlr, constrans);
596 
597    return SCIP_OKAY;
598 }
599 
600 /** sets method of constraint handler to initialize LP with relaxations of "initial" constraints
601  *
602  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
603  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
604  *
605  *  @pre This method can be called if SCIP is in one of the following stages:
606  *       - \ref SCIP_STAGE_INIT
607  *       - \ref SCIP_STAGE_PROBLEM
608  */
SCIPsetConshdlrInitlp(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSINITLP ((* consinitlp)))609 SCIP_RETCODE SCIPsetConshdlrInitlp(
610    SCIP*                 scip,               /**< SCIP data structure */
611    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
612    SCIP_DECL_CONSINITLP  ((*consinitlp))     /**< initialize LP with relaxations of "initial" constraints */
613    )
614 {
615    assert(scip != NULL);
616    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrInitlp", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
617 
618    SCIPconshdlrSetInitlp(conshdlr, consinitlp);
619 
620    return SCIP_OKAY;
621 }
622 
623 /** sets propagation conflict resolving method of constraint handler
624  *
625  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
626  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
627  *
628  *  @pre This method can be called if SCIP is in one of the following stages:
629  *       - \ref SCIP_STAGE_INIT
630  *       - \ref SCIP_STAGE_PROBLEM
631  */
SCIPsetConshdlrResprop(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSRESPROP ((* consresprop)))632 SCIP_RETCODE SCIPsetConshdlrResprop(
633    SCIP*                 scip,               /**< SCIP data structure */
634    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
635    SCIP_DECL_CONSRESPROP ((*consresprop))    /**< propagation conflict resolving method */
636    )
637 {
638    assert(scip != NULL);
639    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrResprop", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
640 
641    SCIPconshdlrSetResprop(conshdlr, consresprop);
642 
643    return SCIP_OKAY;
644 }
645 
646 /** sets activation notification method of constraint handler
647  *
648  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
649  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
650  *
651  *  @pre This method can be called if SCIP is in one of the following stages:
652  *       - \ref SCIP_STAGE_INIT
653  *       - \ref SCIP_STAGE_PROBLEM
654  */
SCIPsetConshdlrActive(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSACTIVE ((* consactive)))655 SCIP_RETCODE SCIPsetConshdlrActive(
656    SCIP*                 scip,               /**< SCIP data structure */
657    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
658    SCIP_DECL_CONSACTIVE  ((*consactive))     /**< activation notification method */
659    )
660 {
661    assert(scip != NULL);
662    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrActive", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
663 
664    SCIPconshdlrSetActive(conshdlr, consactive);
665 
666    return SCIP_OKAY;
667 }
668 
669 /** sets deactivation notification method of constraint handler
670  *
671  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
672  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
673  *
674  *  @pre This method can be called if SCIP is in one of the following stages:
675  *       - \ref SCIP_STAGE_INIT
676  *       - \ref SCIP_STAGE_PROBLEM
677  */
SCIPsetConshdlrDeactive(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSDEACTIVE ((* consdeactive)))678 SCIP_RETCODE SCIPsetConshdlrDeactive(
679    SCIP*                 scip,               /**< SCIP data structure */
680    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
681    SCIP_DECL_CONSDEACTIVE((*consdeactive))   /**< deactivation notification method */
682    )
683 {
684    assert(scip != NULL);
685    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrDeactive", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
686 
687    SCIPconshdlrSetDeactive(conshdlr, consdeactive);
688 
689    return SCIP_OKAY;
690 }
691 
692 /** sets enabling notification method of constraint handler
693  *
694  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
695  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
696  *
697  *  @pre This method can be called if SCIP is in one of the following stages:
698  *       - \ref SCIP_STAGE_INIT
699  *       - \ref SCIP_STAGE_PROBLEM
700  */
SCIPsetConshdlrEnable(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSENABLE ((* consenable)))701 SCIP_RETCODE SCIPsetConshdlrEnable(
702    SCIP*                 scip,               /**< SCIP data structure */
703    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
704    SCIP_DECL_CONSENABLE  ((*consenable))     /**< enabling notification method */
705    )
706 {
707    assert(scip != NULL);
708    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrEnable", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
709 
710    SCIPconshdlrSetEnable(conshdlr, consenable);
711 
712    return SCIP_OKAY;
713 }
714 
715 /** sets disabling notification method of constraint handler
716  *
717  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
718  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
719  *
720  *  @pre This method can be called if SCIP is in one of the following stages:
721  *       - \ref SCIP_STAGE_INIT
722  *       - \ref SCIP_STAGE_PROBLEM
723  */
SCIPsetConshdlrDisable(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSDISABLE ((* consdisable)))724 SCIP_RETCODE SCIPsetConshdlrDisable(
725    SCIP*                 scip,               /**< SCIP data structure */
726    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
727    SCIP_DECL_CONSDISABLE ((*consdisable))    /**< disabling notification method */
728    )
729 {
730    assert(scip != NULL);
731    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrDisable", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
732 
733    SCIPconshdlrSetDisable(conshdlr, consdisable);
734 
735    return SCIP_OKAY;
736 }
737 
738 /** sets variable deletion method of constraint handler
739  *
740  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
741  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
742  *
743  *  @pre This method can be called if SCIP is in one of the following stages:
744  *       - \ref SCIP_STAGE_INIT
745  *       - \ref SCIP_STAGE_PROBLEM
746  */
SCIPsetConshdlrDelvars(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSDELVARS ((* consdelvars)))747 SCIP_RETCODE SCIPsetConshdlrDelvars(
748    SCIP*                 scip,               /**< SCIP data structure */
749    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
750    SCIP_DECL_CONSDELVARS ((*consdelvars))    /**< variable deletion method */
751    )
752 {
753    assert(scip != NULL);
754    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrDelvars", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
755 
756    SCIPconshdlrSetDelvars(conshdlr, consdelvars);
757 
758    return SCIP_OKAY;
759 }
760 
761 /** sets constraint display method of constraint handler
762  *
763  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
764  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
765  *
766  *  @pre This method can be called if SCIP is in one of the following stages:
767  *       - \ref SCIP_STAGE_INIT
768  *       - \ref SCIP_STAGE_PROBLEM
769  */
SCIPsetConshdlrPrint(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSPRINT ((* consprint)))770 SCIP_RETCODE SCIPsetConshdlrPrint(
771    SCIP*                 scip,               /**< SCIP data structure */
772    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
773    SCIP_DECL_CONSPRINT   ((*consprint))      /**< constraint display method */
774    )
775 {
776    assert(scip != NULL);
777    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrPrint", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
778 
779    SCIPconshdlrSetPrint(conshdlr, consprint);
780 
781    return SCIP_OKAY;
782 }
783 
784 /** sets constraint parsing method of constraint handler
785  *
786  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
787  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
788  *
789  *  @pre This method can be called if SCIP is in one of the following stages:
790  *       - \ref SCIP_STAGE_INIT
791  *       - \ref SCIP_STAGE_PROBLEM
792  */
SCIPsetConshdlrParse(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSPARSE ((* consparse)))793 SCIP_RETCODE SCIPsetConshdlrParse(
794    SCIP*                 scip,               /**< SCIP data structure */
795    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
796    SCIP_DECL_CONSPARSE   ((*consparse))      /**< constraint parsing method */
797    )
798 {
799    assert(scip != NULL);
800    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrParse", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
801 
802    SCIPconshdlrSetParse(conshdlr, consparse);
803 
804    return SCIP_OKAY;
805 }
806 
807 /** sets constraint variable getter method of constraint handler
808  *
809  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
810  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
811  *
812  *  @pre This method can be called if SCIP is in one of the following stages:
813  *       - \ref SCIP_STAGE_INIT
814  *       - \ref SCIP_STAGE_PROBLEM
815  */
SCIPsetConshdlrGetVars(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSGETVARS ((* consgetvars)))816 SCIP_RETCODE SCIPsetConshdlrGetVars(
817    SCIP*                 scip,               /**< SCIP data structure */
818    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
819    SCIP_DECL_CONSGETVARS ((*consgetvars))    /**< constraint variable getter method */
820    )
821 {
822    assert(scip != NULL);
823    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrGetVars", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
824 
825    SCIPconshdlrSetGetVars(conshdlr, consgetvars);
826 
827    return SCIP_OKAY;
828 }
829 
830 /** sets constraint variable number getter method of constraint handler
831  *
832  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
833  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
834  *
835  *  @pre This method can be called if SCIP is in one of the following stages:
836  *       - \ref SCIP_STAGE_INIT
837  *       - \ref SCIP_STAGE_PROBLEM
838  */
SCIPsetConshdlrGetNVars(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSGETNVARS ((* consgetnvars)))839 SCIP_RETCODE SCIPsetConshdlrGetNVars(
840    SCIP*                 scip,               /**< SCIP data structure */
841    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
842    SCIP_DECL_CONSGETNVARS((*consgetnvars))   /**< constraint variable number getter method */
843    )
844 {
845    assert(scip != NULL);
846    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrGetNVars", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
847 
848    SCIPconshdlrSetGetNVars(conshdlr, consgetnvars);
849 
850    return SCIP_OKAY;
851 }
852 
853 /** sets diving bound change method of constraint handler
854  *
855  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
856  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
857  *
858  *  @pre This method can be called if SCIP is in one of the following stages:
859  *       - \ref SCIP_STAGE_INIT
860  *       - \ref SCIP_STAGE_PROBLEM
861  */
SCIPsetConshdlrGetDiveBdChgs(SCIP * scip,SCIP_CONSHDLR * conshdlr,SCIP_DECL_CONSGETDIVEBDCHGS ((* consgetdivebdchgs)))862 SCIP_RETCODE SCIPsetConshdlrGetDiveBdChgs(
863    SCIP*                 scip,               /**< SCIP data structure */
864    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler */
865    SCIP_DECL_CONSGETDIVEBDCHGS((*consgetdivebdchgs)) /**< constraint handler diving solution enforcement method */
866    )
867 {
868    assert(scip != NULL);
869    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConshdlrGetDiveBdChgs", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
870 
871    SCIPconshdlrSetGetDiveBdChgs(conshdlr, consgetdivebdchgs);
872 
873    return SCIP_OKAY;
874 }
875 /** returns the constraint handler of the given name, or NULL if not existing */
876 /** returns the constraint handler of the given name, or NULL if not existing */
SCIPfindConshdlr(SCIP * scip,const char * name)877 SCIP_CONSHDLR* SCIPfindConshdlr(
878    SCIP*                 scip,               /**< SCIP data structure */
879    const char*           name                /**< name of constraint handler */
880    )
881 {
882    assert(scip != NULL);
883    assert(scip->set != NULL);
884    assert(name != NULL);
885 
886    return SCIPsetFindConshdlr(scip->set, name);
887 }
888 
889 /** returns the array of currently available constraint handlers */
SCIPgetConshdlrs(SCIP * scip)890 SCIP_CONSHDLR** SCIPgetConshdlrs(
891    SCIP*                 scip                /**< SCIP data structure */
892    )
893 {
894    assert(scip != NULL);
895    assert(scip->set != NULL);
896 
897    return scip->set->conshdlrs;
898 }
899 
900 /** returns the number of currently available constraint handlers */
SCIPgetNConshdlrs(SCIP * scip)901 int SCIPgetNConshdlrs(
902    SCIP*                 scip                /**< SCIP data structure */
903    )
904 {
905    assert(scip != NULL);
906    assert(scip->set != NULL);
907 
908    return scip->set->nconshdlrs;
909 }
910 
911 /** creates and captures a constraint of the given constraint handler
912  *
913  *  @warning If a constraint is marked to be checked for feasibility but not to be enforced, a LP or pseudo solution may
914  *           be declared feasible even if it violates this particular constraint.  This constellation should only be
915  *           used, if no LP or pseudo solution can violate the constraint -- e.g. if a local constraint is redundant due
916  *           to the variable's local bounds.
917  *
918  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
919  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
920  *
921  *  @pre This method can be called if @p scip is in one of the following stages:
922  *       - \ref SCIP_STAGE_PROBLEM
923  *       - \ref SCIP_STAGE_TRANSFORMING
924  *       - \ref SCIP_STAGE_INITPRESOLVE
925  *       - \ref SCIP_STAGE_PRESOLVING
926  *       - \ref SCIP_STAGE_EXITPRESOLVE
927  *       - \ref SCIP_STAGE_PRESOLVED
928  *       - \ref SCIP_STAGE_INITSOLVE
929  *       - \ref SCIP_STAGE_SOLVING
930  *       - \ref SCIP_STAGE_EXITSOLVE
931  *
932  *  @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
933  */
SCIPcreateCons(SCIP * scip,SCIP_CONS ** cons,const char * name,SCIP_CONSHDLR * conshdlr,SCIP_CONSDATA * consdata,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)934 SCIP_RETCODE SCIPcreateCons(
935    SCIP*                 scip,               /**< SCIP data structure */
936    SCIP_CONS**           cons,               /**< pointer to constraint */
937    const char*           name,               /**< name of constraint */
938    SCIP_CONSHDLR*        conshdlr,           /**< constraint handler for this constraint */
939    SCIP_CONSDATA*        consdata,           /**< data for this specific constraint */
940    SCIP_Bool             initial,            /**< should the LP relaxation of constraint be in the initial LP?
941                                               *   Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
942    SCIP_Bool             separate,           /**< should the constraint be separated during LP processing?
943                                               *   Usually set to TRUE. */
944    SCIP_Bool             enforce,            /**< should the constraint be enforced during node processing?
945                                               *   TRUE for model constraints, FALSE for additional, redundant constraints. */
946    SCIP_Bool             check,              /**< should the constraint be checked for feasibility?
947                                               *   TRUE for model constraints, FALSE for additional, redundant constraints. */
948    SCIP_Bool             propagate,          /**< should the constraint be propagated during node processing?
949                                               *   Usually set to TRUE. */
950    SCIP_Bool             local,              /**< is constraint only valid locally?
951                                               *   Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
952    SCIP_Bool             modifiable,         /**< is constraint modifiable (subject to column generation)?
953                                               *   Usually set to FALSE. In column generation applications, set to TRUE if pricing
954                                               *   adds coefficients to this constraint. */
955    SCIP_Bool             dynamic,            /**< is constraint subject to aging?
956                                               *   Usually set to FALSE. Set to TRUE for own cuts which
957                                               *   are separated as constraints. */
958    SCIP_Bool             removable,          /**< should the relaxation be removed from the LP due to aging or cleanup?
959                                               *   Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
960    SCIP_Bool             stickingatnode      /**< should the constraint always be kept at the node where it was added, even
961                                               *   if it may be moved to a more global node?
962                                               *   Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
963    )
964 {
965    assert(cons != NULL);
966    assert(name != NULL);
967    assert(conshdlr != NULL);
968 
969    SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateCons", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE) );
970 
971    switch( scip->set->stage )
972    {
973    case SCIP_STAGE_PROBLEM:
974       SCIP_CALL( SCIPconsCreate(cons, scip->mem->probmem, scip->set, name, conshdlr, consdata,
975             initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, TRUE, TRUE) );
976       return SCIP_OKAY;
977 
978    case SCIP_STAGE_TRANSFORMING:
979    case SCIP_STAGE_TRANSFORMED:
980    case SCIP_STAGE_INITPRESOLVE:
981    case SCIP_STAGE_PRESOLVING:
982    case SCIP_STAGE_EXITPRESOLVE:
983    case SCIP_STAGE_PRESOLVED:
984    case SCIP_STAGE_INITSOLVE:
985    case SCIP_STAGE_SOLVING:
986    case SCIP_STAGE_EXITSOLVE:
987       SCIP_CALL( SCIPconsCreate(cons, scip->mem->probmem, scip->set, name, conshdlr, consdata,
988             initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, FALSE, TRUE) );
989       return SCIP_OKAY;
990 
991    default:
992       SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
993       return SCIP_INVALIDCALL;
994    }  /*lint !e788*/
995 }
996 
997 /** parses constraint information (in cip format) out of a string; if the parsing process was successful a constraint is
998  *  creates and captures;
999  *
1000  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1001  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1002  *
1003  *  @pre This method can be called if @p scip is in one of the following stages:
1004  *       - \ref SCIP_STAGE_PROBLEM
1005  *       - \ref SCIP_STAGE_TRANSFORMING
1006  *       - \ref SCIP_STAGE_INITPRESOLVE
1007  *       - \ref SCIP_STAGE_PRESOLVING
1008  *       - \ref SCIP_STAGE_EXITPRESOLVE
1009  *       - \ref SCIP_STAGE_PRESOLVED
1010  *       - \ref SCIP_STAGE_SOLVING
1011  *       - \ref SCIP_STAGE_EXITSOLVE
1012  *
1013  *  @warning If a constraint is marked to be checked for feasibility but not to be enforced, a LP or pseudo solution may
1014  *           be declared feasible even if it violates this particular constraint.  This constellation should only be
1015  *           used, if no LP or pseudo solution can violate the constraint -- e.g. if a local constraint is redundant due
1016  *           to the variable's local bounds.
1017  */
SCIPparseCons(SCIP * scip,SCIP_CONS ** cons,const char * str,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,SCIP_Bool * success)1018 SCIP_RETCODE SCIPparseCons(
1019    SCIP*                 scip,               /**< SCIP data structure */
1020    SCIP_CONS**           cons,               /**< pointer to store constraint */
1021    const char*           str,                /**< string to parse for constraint */
1022    SCIP_Bool             initial,            /**< should the LP relaxation of constraint be in the initial LP?
1023                                               *   Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
1024    SCIP_Bool             separate,           /**< should the constraint be separated during LP processing?
1025                                               *   Usually set to TRUE. */
1026    SCIP_Bool             enforce,            /**< should the constraint be enforced during node processing?
1027                                               *   TRUE for model constraints, FALSE for additional, redundant constraints. */
1028    SCIP_Bool             check,              /**< should the constraint be checked for feasibility?
1029                                               *   TRUE for model constraints, FALSE for additional, redundant constraints. */
1030    SCIP_Bool             propagate,          /**< should the constraint be propagated during node processing?
1031                                               *   Usually set to TRUE. */
1032    SCIP_Bool             local,              /**< is constraint only valid locally?
1033                                               *   Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
1034    SCIP_Bool             modifiable,         /**< is constraint modifiable (subject to column generation)?
1035                                               *   Usually set to FALSE. In column generation applications, set to TRUE if pricing
1036                                               *   adds coefficients to this constraint. */
1037    SCIP_Bool             dynamic,            /**< is constraint subject to aging?
1038                                               *   Usually set to FALSE. Set to TRUE for own cuts which
1039                                               *   are separated as constraints. */
1040    SCIP_Bool             removable,          /**< should the relaxation be removed from the LP due to aging or cleanup?
1041                                               *   Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
1042    SCIP_Bool             stickingatnode,     /**< should the constraint always be kept at the node where it was added, even
1043                                               *   if it may be moved to a more global node?
1044                                               *   Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
1045    SCIP_Bool*            success             /**< pointer to store if the paring process was successful */
1046    )
1047 {
1048    assert(cons != NULL);
1049 
1050    SCIP_CALL( SCIPcheckStage(scip, "SCIPparseCons", FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
1051 
1052    SCIP_CALL( SCIPconsParse(cons, scip->set, scip->messagehdlr, str,
1053          initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, success) );
1054 
1055    return SCIP_OKAY;
1056 }
1057 
1058 /** increases usage counter of constraint
1059  *
1060  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1061  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1062  *
1063  *  @pre This method can be called if @p scip is in one of the following stages:
1064  *       - \ref SCIP_STAGE_PROBLEM
1065  *       - \ref SCIP_STAGE_TRANSFORMING
1066  *       - \ref SCIP_STAGE_TRANSFORMED
1067  *       - \ref SCIP_STAGE_INITPRESOLVE
1068  *       - \ref SCIP_STAGE_PRESOLVING
1069  *       - \ref SCIP_STAGE_EXITPRESOLVE
1070  *       - \ref SCIP_STAGE_PRESOLVED
1071  *       - \ref SCIP_STAGE_INITSOLVE
1072  *       - \ref SCIP_STAGE_SOLVING
1073  *       - \ref SCIP_STAGE_SOLVED
1074  */
SCIPcaptureCons(SCIP * scip,SCIP_CONS * cons)1075 SCIP_RETCODE SCIPcaptureCons(
1076    SCIP*                 scip,               /**< SCIP data structure */
1077    SCIP_CONS*            cons                /**< constraint to capture */
1078    )
1079 {
1080    SCIP_CALL( SCIPcheckStage(scip, "SCIPcaptureCons", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1081 
1082    assert( cons->scip == scip );
1083 
1084    SCIPconsCapture(cons);
1085 
1086    return SCIP_OKAY;
1087 }
1088 
1089 /** decreases usage counter of constraint, if the usage pointer reaches zero the constraint gets freed
1090  *
1091  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1092  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1093  *
1094  *  @pre This method can be called if @p scip is in one of the following stages:
1095  *       - \ref SCIP_STAGE_PROBLEM
1096  *       - \ref SCIP_STAGE_TRANSFORMING
1097  *       - \ref SCIP_STAGE_TRANSFORMED
1098  *       - \ref SCIP_STAGE_INITPRESOLVE
1099  *       - \ref SCIP_STAGE_PRESOLVING
1100  *       - \ref SCIP_STAGE_EXITPRESOLVE
1101  *       - \ref SCIP_STAGE_PRESOLVED
1102  *       - \ref SCIP_STAGE_INITSOLVE
1103  *       - \ref SCIP_STAGE_SOLVING
1104  *       - \ref SCIP_STAGE_SOLVED
1105  *       - \ref SCIP_STAGE_EXITSOLVE
1106  *       - \ref SCIP_STAGE_FREETRANS
1107  *
1108  *  @note the pointer of the constraint will be NULLed
1109  */
SCIPreleaseCons(SCIP * scip,SCIP_CONS ** cons)1110 SCIP_RETCODE SCIPreleaseCons(
1111    SCIP*                 scip,               /**< SCIP data structure */
1112    SCIP_CONS**           cons                /**< pointer to constraint */
1113    )
1114 {
1115    assert(cons != NULL);
1116    assert(*cons != NULL);
1117 
1118    SCIP_CALL( SCIPcheckStage(scip, "SCIPreleaseCons", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1119 
1120    switch( scip->set->stage )
1121    {
1122    case SCIP_STAGE_PROBLEM:
1123       SCIP_CALL( SCIPconsRelease(cons, scip->mem->probmem, scip->set) );
1124       return SCIP_OKAY;
1125 
1126    case SCIP_STAGE_TRANSFORMING:
1127    case SCIP_STAGE_TRANSFORMED:
1128    case SCIP_STAGE_INITPRESOLVE:
1129    case SCIP_STAGE_PRESOLVING:
1130    case SCIP_STAGE_EXITPRESOLVE:
1131    case SCIP_STAGE_PRESOLVED:
1132    case SCIP_STAGE_INITSOLVE:
1133    case SCIP_STAGE_SOLVING:
1134    case SCIP_STAGE_SOLVED:
1135    case SCIP_STAGE_EXITSOLVE:
1136    case SCIP_STAGE_FREETRANS:
1137       if( SCIPconsIsOriginal(*cons) && (*cons)->nuses == 1 )
1138       {
1139          SCIPerrorMessage("cannot release last use of original constraint while the transformed problem exists\n");
1140          return SCIP_INVALIDCALL;
1141       }
1142       SCIP_CALL( SCIPconsRelease(cons, scip->mem->probmem, scip->set) );
1143       return SCIP_OKAY;
1144 
1145    default:
1146       SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
1147       return SCIP_INVALIDCALL;
1148    }  /*lint !e788*/
1149 }
1150 
1151 /** change constraint name
1152  *
1153  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1154  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1155  *
1156  *  @pre This method can be called if @p scip is in one of the following stages:
1157  *       - \ref SCIP_STAGE_PROBLEM
1158  *
1159  *  @note to get the current name of a constraint, use SCIPconsGetName() from pub_cons.h
1160  */
SCIPchgConsName(SCIP * scip,SCIP_CONS * cons,const char * name)1161 SCIP_RETCODE SCIPchgConsName(
1162    SCIP*                 scip,               /**< SCIP data structure */
1163    SCIP_CONS*            cons,               /**< constraint */
1164    const char*           name                /**< new name of constraint */
1165    )
1166 {
1167    SCIP_CALL( SCIPcheckStage(scip, "SCIPchgConsName", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE , FALSE, FALSE, FALSE) );
1168 
1169    assert( cons->scip == scip );
1170 
1171    if( SCIPgetStage(scip) != SCIP_STAGE_PROBLEM )
1172    {
1173       SCIPerrorMessage("constraint names can only be changed in problem creation stage\n");
1174       SCIPABORT();
1175       return SCIP_INVALIDCALL; /*lint !e527*/
1176    }
1177 
1178    /* remove constraint's name from the namespace if the constraint was already added */
1179    if( SCIPconsIsAdded(cons) )
1180    {
1181       SCIP_CALL( SCIPprobRemoveConsName(scip->origprob, cons) );
1182    }
1183 
1184    /* change constraint name */
1185    SCIP_CALL( SCIPconsChgName(cons, SCIPblkmem(scip), name) );
1186 
1187    /* add constraint's name to the namespace if the constraint was already added */
1188    if( SCIPconsIsAdded(cons) )
1189    {
1190       SCIP_CALL( SCIPprobAddConsName(scip->origprob, cons) );
1191    }
1192 
1193    return SCIP_OKAY;
1194 }
1195 
1196 /** sets the initial flag of the given constraint
1197  *
1198  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1199  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1200  *
1201  *  @pre This method can be called if @p scip is in one of the following stages:
1202  *       - \ref SCIP_STAGE_PROBLEM
1203  *       - \ref SCIP_STAGE_TRANSFORMING
1204  *       - \ref SCIP_STAGE_PRESOLVING
1205  *       - \ref SCIP_STAGE_PRESOLVED
1206  *       - \ref SCIP_STAGE_SOLVING
1207  */
SCIPsetConsInitial(SCIP * scip,SCIP_CONS * cons,SCIP_Bool initial)1208 SCIP_RETCODE SCIPsetConsInitial(
1209    SCIP*                 scip,               /**< SCIP data structure */
1210    SCIP_CONS*            cons,               /**< constraint */
1211    SCIP_Bool             initial             /**< new value */
1212    )
1213 {
1214    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConsInitial", FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1215 
1216    SCIP_CALL( SCIPconsSetInitial(cons, scip->set, scip->stat, initial) );
1217 
1218    return SCIP_OKAY;
1219 }
1220 
1221 /** sets the separate flag of the given constraint
1222  *
1223  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1224  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1225  *
1226  *  @pre This method can be called if @p scip is in one of the following stages:
1227  *       - \ref SCIP_STAGE_PROBLEM
1228  *       - \ref SCIP_STAGE_TRANSFORMING
1229  *       - \ref SCIP_STAGE_PRESOLVING
1230  *       - \ref SCIP_STAGE_PRESOLVED
1231  *       - \ref SCIP_STAGE_SOLVING
1232  */
SCIPsetConsSeparated(SCIP * scip,SCIP_CONS * cons,SCIP_Bool separate)1233 SCIP_RETCODE SCIPsetConsSeparated(
1234    SCIP*                 scip,               /**< SCIP data structure */
1235    SCIP_CONS*            cons,               /**< constraint */
1236    SCIP_Bool             separate            /**< new value */
1237    )
1238 {
1239    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConsSeparated", FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1240 
1241    SCIP_CALL( SCIPconsSetSeparated(cons, scip->set, separate) );
1242 
1243    return SCIP_OKAY;
1244 }
1245 
1246 /** sets the enforce flag of the given constraint
1247  *
1248  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1249  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1250  *
1251  *  @pre This method can be called if @p scip is in one of the following stages:
1252  *       - \ref SCIP_STAGE_PROBLEM
1253  *       - \ref SCIP_STAGE_TRANSFORMING
1254  *       - \ref SCIP_STAGE_PRESOLVING
1255  *       - \ref SCIP_STAGE_PRESOLVED
1256  *       - \ref SCIP_STAGE_SOLVING
1257  */
SCIPsetConsEnforced(SCIP * scip,SCIP_CONS * cons,SCIP_Bool enforce)1258 SCIP_RETCODE SCIPsetConsEnforced(
1259    SCIP*                 scip,               /**< SCIP data structure */
1260    SCIP_CONS*            cons,               /**< constraint */
1261    SCIP_Bool             enforce             /**< new value */
1262    )
1263 {
1264    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConsEnforced", FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1265 
1266    SCIP_CALL( SCIPconsSetEnforced(cons, scip->set, enforce) );
1267 
1268    return SCIP_OKAY;
1269 }
1270 
1271 /** sets the check flag of the given constraint
1272  *
1273  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1274  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1275  *
1276  *  @pre This method can be called if @p scip is in one of the following stages:
1277  *       - \ref SCIP_STAGE_PROBLEM
1278  *       - \ref SCIP_STAGE_TRANSFORMING
1279  *       - \ref SCIP_STAGE_PRESOLVING
1280  *       - \ref SCIP_STAGE_PRESOLVED
1281  *       - \ref SCIP_STAGE_SOLVING
1282  */
SCIPsetConsChecked(SCIP * scip,SCIP_CONS * cons,SCIP_Bool check)1283 SCIP_RETCODE SCIPsetConsChecked(
1284    SCIP*                 scip,               /**< SCIP data structure */
1285    SCIP_CONS*            cons,               /**< constraint */
1286    SCIP_Bool             check               /**< new value */
1287    )
1288 {
1289    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConsChecked", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1290 
1291    SCIP_CALL( SCIPconsSetChecked(cons, scip->set, check) );
1292 
1293    return SCIP_OKAY;
1294 }
1295 
1296 /** sets the propagate flag of the given constraint
1297  *
1298  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1299  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1300  *
1301  *  @pre This method can be called if @p scip is in one of the following stages:
1302  *       - \ref SCIP_STAGE_PROBLEM
1303  *       - \ref SCIP_STAGE_TRANSFORMING
1304  *       - \ref SCIP_STAGE_PRESOLVING
1305  *       - \ref SCIP_STAGE_PRESOLVED
1306  *       - \ref SCIP_STAGE_SOLVING
1307  */
SCIPsetConsPropagated(SCIP * scip,SCIP_CONS * cons,SCIP_Bool propagate)1308 SCIP_RETCODE SCIPsetConsPropagated(
1309    SCIP*                 scip,               /**< SCIP data structure */
1310    SCIP_CONS*            cons,               /**< constraint */
1311    SCIP_Bool             propagate           /**< new value */
1312    )
1313 {
1314    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConsPropagated", FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1315 
1316    SCIP_CALL( SCIPconsSetPropagated(cons, scip->set, propagate) );
1317 
1318    return SCIP_OKAY;
1319 }
1320 
1321 /** sets the local flag of the given constraint
1322  *
1323  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1324  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1325  *
1326  *  @pre This method can be called if @p scip is in one of the following stages:
1327  *       - \ref SCIP_STAGE_PROBLEM
1328  *       - \ref SCIP_STAGE_TRANSFORMING
1329  *       - \ref SCIP_STAGE_INITPRESOLVE
1330  *       - \ref SCIP_STAGE_PRESOLVING
1331  *       - \ref SCIP_STAGE_PRESOLVED
1332  *       - \ref SCIP_STAGE_INITSOLVE
1333  *       - \ref SCIP_STAGE_SOLVING
1334  */
SCIPsetConsLocal(SCIP * scip,SCIP_CONS * cons,SCIP_Bool local)1335 SCIP_RETCODE SCIPsetConsLocal(
1336    SCIP*                 scip,               /**< SCIP data structure */
1337    SCIP_CONS*            cons,               /**< constraint */
1338    SCIP_Bool             local               /**< new value */
1339    )
1340 {
1341    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConsLocal", FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1342 
1343    SCIPconsSetLocal(cons, local);
1344 
1345    return SCIP_OKAY;
1346 }
1347 
1348 /** sets the modifiable flag of the given constraint
1349  *
1350  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1351  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1352  *
1353  *  @pre This method can be called if @p scip is in one of the following stages:
1354  *       - \ref SCIP_STAGE_PROBLEM
1355  *       - \ref SCIP_STAGE_TRANSFORMING
1356  *       - \ref SCIP_STAGE_PRESOLVING
1357  *       - \ref SCIP_STAGE_PRESOLVED
1358  *       - \ref SCIP_STAGE_SOLVING
1359  *       - \ref SCIP_STAGE_EXITSOLVE
1360  */
SCIPsetConsModifiable(SCIP * scip,SCIP_CONS * cons,SCIP_Bool modifiable)1361 SCIP_RETCODE SCIPsetConsModifiable(
1362    SCIP*                 scip,               /**< SCIP data structure */
1363    SCIP_CONS*            cons,               /**< constraint */
1364    SCIP_Bool             modifiable          /**< new value */
1365    )
1366 {
1367    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConsModifiable", FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
1368 
1369    SCIPconsSetModifiable(cons, modifiable);
1370 
1371    return SCIP_OKAY;
1372 }
1373 
1374 /** sets the dynamic flag of the given constraint
1375  *
1376  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1377  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1378  *
1379  *  @pre This method can be called if @p scip is in one of the following stages:
1380  *       - \ref SCIP_STAGE_PROBLEM
1381  *       - \ref SCIP_STAGE_TRANSFORMING
1382  *       - \ref SCIP_STAGE_PRESOLVING
1383  *       - \ref SCIP_STAGE_PRESOLVED
1384  *       - \ref SCIP_STAGE_SOLVING
1385  */
SCIPsetConsDynamic(SCIP * scip,SCIP_CONS * cons,SCIP_Bool dynamic)1386 SCIP_RETCODE SCIPsetConsDynamic(
1387    SCIP*                 scip,               /**< SCIP data structure */
1388    SCIP_CONS*            cons,               /**< constraint */
1389    SCIP_Bool             dynamic             /**< new value */
1390    )
1391 {
1392    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConsDynamic", FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1393 
1394    SCIPconsSetDynamic(cons, dynamic);
1395 
1396    return SCIP_OKAY;
1397 }
1398 
1399 /** sets the removable flag of the given constraint
1400  *
1401  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1402  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1403  *
1404  *  @pre This method can be called if @p scip is in one of the following stages:
1405  *       - \ref SCIP_STAGE_PROBLEM
1406  *       - \ref SCIP_STAGE_TRANSFORMING
1407  *       - \ref SCIP_STAGE_PRESOLVING
1408  *       - \ref SCIP_STAGE_PRESOLVED
1409  *       - \ref SCIP_STAGE_SOLVING
1410  */
SCIPsetConsRemovable(SCIP * scip,SCIP_CONS * cons,SCIP_Bool removable)1411 SCIP_RETCODE SCIPsetConsRemovable(
1412    SCIP*                 scip,               /**< SCIP data structure */
1413    SCIP_CONS*            cons,               /**< constraint */
1414    SCIP_Bool             removable           /**< new value */
1415    )
1416 {
1417    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConsRemovable", FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1418 
1419    SCIPconsSetRemovable(cons, removable);
1420 
1421    return SCIP_OKAY;
1422 }
1423 
1424 /** sets the stickingatnode flag of the given constraint
1425  *
1426  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1427  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1428  *
1429  *  @pre This method can be called if @p scip is in one of the following stages:
1430  *       - \ref SCIP_STAGE_PROBLEM
1431  *       - \ref SCIP_STAGE_TRANSFORMING
1432  *       - \ref SCIP_STAGE_PRESOLVING
1433  *       - \ref SCIP_STAGE_PRESOLVED
1434  *       - \ref SCIP_STAGE_SOLVING
1435  */
SCIPsetConsStickingAtNode(SCIP * scip,SCIP_CONS * cons,SCIP_Bool stickingatnode)1436 SCIP_RETCODE SCIPsetConsStickingAtNode(
1437    SCIP*                 scip,               /**< SCIP data structure */
1438    SCIP_CONS*            cons,               /**< constraint */
1439    SCIP_Bool             stickingatnode      /**< new value */
1440    )
1441 {
1442    SCIP_CALL( SCIPcheckStage(scip, "SCIPsetConsStickingAtNode", FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1443 
1444    SCIPconsSetStickingAtNode(cons, stickingatnode);
1445 
1446    return SCIP_OKAY;
1447 }
1448 
1449 /** updates the flags of the first constraint according to the ones of the second constraint
1450  *
1451  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1452  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1453  *
1454  *  @pre This method can be called if @p scip is in one of the following stages:
1455  *       - \ref SCIP_STAGE_PROBLEM
1456  *       - \ref SCIP_STAGE_TRANSFORMING
1457  *       - \ref SCIP_STAGE_PRESOLVING
1458  *       - \ref SCIP_STAGE_PRESOLVED
1459  *       - \ref SCIP_STAGE_SOLVING
1460  */
SCIPupdateConsFlags(SCIP * scip,SCIP_CONS * cons0,SCIP_CONS * cons1)1461 SCIP_RETCODE SCIPupdateConsFlags(
1462    SCIP*                 scip,               /**< SCIP data structure */
1463    SCIP_CONS*            cons0,              /**< constraint that should stay */
1464    SCIP_CONS*            cons1               /**< constraint that should be deleted */
1465    )
1466 {
1467    SCIP_CALL( SCIPcheckStage(scip, "SCIPupdateConsFlags", FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1468 
1469    if( SCIPconsIsInitial(cons1) )
1470    {
1471       SCIP_CALL( SCIPsetConsInitial(scip, cons0, TRUE) );
1472    }
1473    if( SCIPconsIsSeparated(cons1) )
1474    {
1475       SCIP_CALL( SCIPsetConsSeparated(scip, cons0, TRUE) );
1476    }
1477    if( SCIPconsIsEnforced(cons1) )
1478    {
1479       SCIP_CALL( SCIPsetConsEnforced(scip, cons0, TRUE) );
1480    }
1481    if( SCIPconsIsChecked(cons1) )
1482    {
1483       SCIP_CALL( SCIPsetConsChecked(scip, cons0, TRUE) );
1484    }
1485    if( SCIPconsIsPropagated(cons1) )
1486    {
1487       SCIP_CALL( SCIPsetConsPropagated(scip, cons0, TRUE) );
1488    }
1489    if( !SCIPconsIsDynamic(cons1) )
1490    {
1491       SCIP_CALL( SCIPsetConsDynamic(scip, cons0, FALSE) );
1492    }
1493    if( !SCIPconsIsRemovable(cons1) )
1494    {
1495       SCIP_CALL( SCIPsetConsRemovable(scip, cons0, FALSE) );
1496    }
1497    if( SCIPconsIsStickingAtNode(cons1) )
1498    {
1499       SCIP_CALL( SCIPsetConsStickingAtNode(scip, cons0, TRUE) );
1500    }
1501 
1502    return SCIP_OKAY;
1503 }
1504 
1505 /** gets and captures transformed constraint of a given constraint; if the constraint is not yet transformed,
1506  *  a new transformed constraint for this constraint is created
1507  *
1508  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1509  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1510  *
1511  *  @pre This method can be called if @p scip is in one of the following stages:
1512  *       - \ref SCIP_STAGE_TRANSFORMING
1513  *       - \ref SCIP_STAGE_TRANSFORMED
1514  *       - \ref SCIP_STAGE_INITPRESOLVE
1515  *       - \ref SCIP_STAGE_PRESOLVING
1516  *       - \ref SCIP_STAGE_EXITPRESOLVE
1517  *       - \ref SCIP_STAGE_PRESOLVED
1518  *       - \ref SCIP_STAGE_INITSOLVE
1519  *       - \ref SCIP_STAGE_SOLVING
1520  */
SCIPtransformCons(SCIP * scip,SCIP_CONS * cons,SCIP_CONS ** transcons)1521 SCIP_RETCODE SCIPtransformCons(
1522    SCIP*                 scip,               /**< SCIP data structure */
1523    SCIP_CONS*            cons,               /**< constraint to get/create transformed constraint for */
1524    SCIP_CONS**           transcons           /**< pointer to store the transformed constraint */
1525    )
1526 {
1527    assert(transcons != NULL);
1528    assert(cons->scip == scip);
1529 
1530    SCIP_CALL( SCIPcheckStage(scip, "SCIPtransformCons", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1531 
1532    if( SCIPconsIsTransformed(cons) )
1533    {
1534       *transcons = cons;
1535       SCIPconsCapture(*transcons);
1536    }
1537    else
1538    {
1539       SCIP_CALL( SCIPconsTransform(cons, scip->mem->probmem, scip->set, transcons) );
1540    }
1541 
1542    return SCIP_OKAY;
1543 }
1544 
1545 /** gets and captures transformed constraints for an array of constraints;
1546  *  if a constraint in the array is not yet transformed, a new transformed constraint for this constraint is created;
1547  *  it is possible to call this method with conss == transconss
1548  *
1549  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1550  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1551  *
1552  *  @pre This method can be called if @p scip is in one of the following stages:
1553  *       - \ref SCIP_STAGE_TRANSFORMING
1554  *       - \ref SCIP_STAGE_TRANSFORMED
1555  *       - \ref SCIP_STAGE_INITPRESOLVE
1556  *       - \ref SCIP_STAGE_PRESOLVING
1557  *       - \ref SCIP_STAGE_EXITPRESOLVE
1558  *       - \ref SCIP_STAGE_PRESOLVED
1559  *       - \ref SCIP_STAGE_INITSOLVE
1560  *       - \ref SCIP_STAGE_SOLVING
1561  */
SCIPtransformConss(SCIP * scip,int nconss,SCIP_CONS ** conss,SCIP_CONS ** transconss)1562 SCIP_RETCODE SCIPtransformConss(
1563    SCIP*                 scip,               /**< SCIP data structure */
1564    int                   nconss,             /**< number of constraints to get/create transformed constraints for */
1565    SCIP_CONS**           conss,              /**< array with constraints to get/create transformed constraints for */
1566    SCIP_CONS**           transconss          /**< array to store the transformed constraints */
1567    )
1568 {
1569    int c;
1570 
1571    assert(nconss == 0 || conss != NULL);
1572    assert(nconss == 0 || transconss != NULL);
1573 
1574    SCIP_CALL( SCIPcheckStage(scip, "SCIPtransformConss", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1575 
1576    for( c = 0; c < nconss; ++c )
1577    {
1578       if( SCIPconsIsTransformed(conss[c]) )
1579       {
1580          transconss[c] = conss[c];
1581          SCIPconsCapture(transconss[c]);
1582       }
1583       else
1584       {
1585          SCIP_CALL( SCIPconsTransform(conss[c], scip->mem->probmem, scip->set, &transconss[c]) );
1586       }
1587    }
1588 
1589    return SCIP_OKAY;
1590 }
1591 
1592 /** gets corresponding transformed constraint of a given constraint;
1593  *  returns NULL as transcons, if transformed constraint is not yet existing
1594  *
1595  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1596  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1597  *
1598  *  @pre This method can be called if @p scip is in one of the following stages:
1599  *       - \ref SCIP_STAGE_TRANSFORMING
1600  *       - \ref SCIP_STAGE_TRANSFORMED
1601  *       - \ref SCIP_STAGE_INITPRESOLVE
1602  *       - \ref SCIP_STAGE_PRESOLVING
1603  *       - \ref SCIP_STAGE_EXITPRESOLVE
1604  *       - \ref SCIP_STAGE_PRESOLVED
1605  *       - \ref SCIP_STAGE_INITSOLVE
1606  *       - \ref SCIP_STAGE_SOLVING
1607  *       - \ref SCIP_STAGE_SOLVED
1608  *       - \ref SCIP_STAGE_EXITSOLVE
1609  *       - \ref SCIP_STAGE_FREETRANS
1610  */
SCIPgetTransformedCons(SCIP * scip,SCIP_CONS * cons,SCIP_CONS ** transcons)1611 SCIP_RETCODE SCIPgetTransformedCons(
1612    SCIP*                 scip,               /**< SCIP data structure */
1613    SCIP_CONS*            cons,               /**< constraint to get the transformed constraint for */
1614    SCIP_CONS**           transcons           /**< pointer to store the transformed constraint */
1615    )
1616 {
1617    assert(transcons != NULL);
1618    assert(cons->scip == scip);
1619 
1620    SCIP_CALL( SCIPcheckStage(scip, "SCIPgetTransformedCons", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1621 
1622    if( SCIPconsIsTransformed(cons) )
1623       *transcons = cons;
1624    else
1625       *transcons = SCIPconsGetTransformed(cons);
1626 
1627    return SCIP_OKAY;
1628 }
1629 
1630 /** gets corresponding transformed constraints for an array of constraints;
1631  *  stores NULL in a transconss slot, if the transformed constraint is not yet existing;
1632  *  it is possible to call this method with conss == transconss, but remember that constraints that are not
1633  *  yet transformed will be replaced with NULL
1634  *
1635  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1636  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1637  *
1638  *  @pre This method can be called if @p scip is in one of the following stages:
1639  *       - \ref SCIP_STAGE_TRANSFORMING
1640  *       - \ref SCIP_STAGE_TRANSFORMED
1641  *       - \ref SCIP_STAGE_INITPRESOLVE
1642  *       - \ref SCIP_STAGE_PRESOLVING
1643  *       - \ref SCIP_STAGE_EXITPRESOLVE
1644  *       - \ref SCIP_STAGE_PRESOLVED
1645  *       - \ref SCIP_STAGE_INITSOLVE
1646  *       - \ref SCIP_STAGE_SOLVING
1647  *       - \ref SCIP_STAGE_SOLVED
1648  *       - \ref SCIP_STAGE_EXITSOLVE
1649  *       - \ref SCIP_STAGE_FREETRANS
1650  */
SCIPgetTransformedConss(SCIP * scip,int nconss,SCIP_CONS ** conss,SCIP_CONS ** transconss)1651 SCIP_RETCODE SCIPgetTransformedConss(
1652    SCIP*                 scip,               /**< SCIP data structure */
1653    int                   nconss,             /**< number of constraints to get the transformed constraints for */
1654    SCIP_CONS**           conss,              /**< constraints to get the transformed constraints for */
1655    SCIP_CONS**           transconss          /**< array to store the transformed constraints */
1656    )
1657 {
1658    int c;
1659 
1660    assert(nconss == 0 || conss != NULL);
1661    assert(nconss == 0 || transconss != NULL);
1662 
1663    SCIP_CALL( SCIPcheckStage(scip, "SCIPgetTransformedConss", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1664 
1665    for( c = 0; c < nconss; ++c )
1666    {
1667       if( SCIPconsIsTransformed(conss[c]) )
1668          transconss[c] = conss[c];
1669       else
1670          transconss[c] = SCIPconsGetTransformed(conss[c]);
1671    }
1672 
1673    return SCIP_OKAY;
1674 }
1675 
1676 /** adds given value to age of constraint, but age can never become negative;
1677  *  should be called
1678  *   - in constraint separation, if no cut was found for this constraint,
1679  *   - in constraint enforcing, if constraint was feasible, and
1680  *   - in constraint propagation, if no domain reduction was deduced;
1681  *
1682  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1683  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1684  *
1685  *  @pre This method can be called if @p scip is in one of the following stages:
1686  *       - \ref SCIP_STAGE_TRANSFORMED
1687  *       - \ref SCIP_STAGE_PRESOLVING
1688  *       - \ref SCIP_STAGE_PRESOLVED
1689  *       - \ref SCIP_STAGE_SOLVING
1690  *       - \ref SCIP_STAGE_SOLVED
1691  */
SCIPaddConsAge(SCIP * scip,SCIP_CONS * cons,SCIP_Real deltaage)1692 SCIP_RETCODE SCIPaddConsAge(
1693    SCIP*                 scip,               /**< SCIP data structure */
1694    SCIP_CONS*            cons,               /**< constraint */
1695    SCIP_Real             deltaage            /**< value to add to the constraint's age */
1696    )
1697 {
1698    SCIP_CALL( SCIPcheckStage(scip, "SCIPaddConsAge", FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1699 
1700    SCIP_CALL( SCIPconsAddAge(cons, scip->mem->probmem, scip->set, scip->stat, scip->transprob, deltaage, scip->reopt) );
1701 
1702    return SCIP_OKAY;
1703 }
1704 
1705 /** increases age of constraint by 1.0;
1706  *  should be called
1707  *   - in constraint separation, if no cut was found for this constraint,
1708  *   - in constraint enforcing, if constraint was feasible, and
1709  *   - in constraint propagation, if no domain reduction was deduced;
1710  *
1711  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1712  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1713  *
1714  *  @pre This method can be called if @p scip is in one of the following stages:
1715  *       - \ref SCIP_STAGE_TRANSFORMED
1716  *       - \ref SCIP_STAGE_PRESOLVING
1717  *       - \ref SCIP_STAGE_PRESOLVED
1718  *       - \ref SCIP_STAGE_SOLVING
1719  *       - \ref SCIP_STAGE_SOLVED
1720  */
SCIPincConsAge(SCIP * scip,SCIP_CONS * cons)1721 SCIP_RETCODE SCIPincConsAge(
1722    SCIP*                 scip,               /**< SCIP data structure */
1723    SCIP_CONS*            cons                /**< constraint */
1724    )
1725 {
1726    SCIP_CALL( SCIPcheckStage(scip, "SCIPincConsAge", FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1727 
1728    SCIP_CALL( SCIPconsIncAge(cons, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->reopt) );
1729 
1730    return SCIP_OKAY;
1731 }
1732 
1733 /** resets age of constraint to zero;
1734  *  should be called
1735  *   - in constraint separation, if a cut was found for this constraint,
1736  *   - in constraint enforcing, if the constraint was violated, and
1737  *   - in constraint propagation, if a domain reduction was deduced;
1738  *
1739  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1740  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1741  *
1742  *  @pre This method can be called if @p scip is in one of the following stages:
1743  *       - \ref SCIP_STAGE_TRANSFORMED
1744  *       - \ref SCIP_STAGE_PRESOLVING
1745  *       - \ref SCIP_STAGE_PRESOLVED
1746  *       - \ref SCIP_STAGE_SOLVING
1747  *       - \ref SCIP_STAGE_SOLVED
1748  */
SCIPresetConsAge(SCIP * scip,SCIP_CONS * cons)1749 SCIP_RETCODE SCIPresetConsAge(
1750    SCIP*                 scip,               /**< SCIP data structure */
1751    SCIP_CONS*            cons                /**< constraint */
1752    )
1753 {
1754    SCIP_CALL( SCIPcheckStage(scip, "SCIPresetConsAge", FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1755 
1756    SCIP_CALL( SCIPconsResetAge(cons, scip->set) );
1757 
1758    return SCIP_OKAY;
1759 }
1760 
1761 /** enables constraint's separation, propagation, and enforcing capabilities
1762  *
1763  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1764  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1765  *
1766  *  @pre This method can be called if @p scip is in one of the following stages:
1767  *       - \ref SCIP_STAGE_TRANSFORMED
1768  *       - \ref SCIP_STAGE_PRESOLVING
1769  *       - \ref SCIP_STAGE_PRESOLVED
1770  *       - \ref SCIP_STAGE_INITSOLVE
1771  *       - \ref SCIP_STAGE_SOLVING
1772  *       - \ref SCIP_STAGE_SOLVED
1773  */
SCIPenableCons(SCIP * scip,SCIP_CONS * cons)1774 SCIP_RETCODE SCIPenableCons(
1775    SCIP*                 scip,               /**< SCIP data structure */
1776    SCIP_CONS*            cons                /**< constraint */
1777    )
1778 {
1779    SCIP_CALL( SCIPcheckStage(scip, "SCIPenableCons", FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1780 
1781    SCIP_CALL( SCIPconsEnable(cons, scip->set, scip->stat) );
1782 
1783    return SCIP_OKAY;
1784 }
1785 
1786 /** disables constraint's separation, propagation, and enforcing capabilities, s.t. the constraint is not propagated,
1787  *  separated, and enforced anymore until it is enabled again with a call to SCIPenableCons();
1788  *  in contrast to SCIPdelConsLocal() and SCIPdelConsNode(), the disabling is not associated to a node in the tree and
1789  *  does not consume memory; therefore, the constraint is neither automatically enabled on leaving the node nor
1790  *  automatically disabled again on entering the node again;
1791  *  note that the constraints enforcing capabilities are necessary for the solution's feasibility, if the constraint
1792  *  is a model constraint; that means, you must be sure that the constraint cannot be violated in the current subtree,
1793  *  and you have to enable it again manually by calling SCIPenableCons(), if this subtree is left (e.g. by using
1794  *  an appropriate event handler that watches the corresponding variables' domain changes)
1795  *
1796  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1797  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1798  *
1799  *  @pre This method can be called if @p scip is in one of the following stages:
1800  *       - \ref SCIP_STAGE_TRANSFORMED
1801  *       - \ref SCIP_STAGE_INITPRESOLVE
1802  *       - \ref SCIP_STAGE_PRESOLVING
1803  *       - \ref SCIP_STAGE_PRESOLVED
1804  *       - \ref SCIP_STAGE_INITSOLVE
1805  *       - \ref SCIP_STAGE_SOLVING
1806  *       - \ref SCIP_STAGE_SOLVED
1807  */
SCIPdisableCons(SCIP * scip,SCIP_CONS * cons)1808 SCIP_RETCODE SCIPdisableCons(
1809    SCIP*                 scip,               /**< SCIP data structure */
1810    SCIP_CONS*            cons                /**< constraint */
1811    )
1812 {
1813    SCIP_CALL( SCIPcheckStage(scip, "SCIPdisableCons", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1814 
1815    SCIP_CALL( SCIPconsDisable(cons, scip->set, scip->stat) );
1816 
1817    return SCIP_OKAY;
1818 }
1819 
1820 /** enables constraint's separation capabilities
1821  *
1822  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1823  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1824  *
1825  *  @pre This method can be called if @p scip is in one of the following stages:
1826  *       - \ref SCIP_STAGE_TRANSFORMED
1827  *       - \ref SCIP_STAGE_PRESOLVING
1828  *       - \ref SCIP_STAGE_PRESOLVED
1829  *       - \ref SCIP_STAGE_INITSOLVE
1830  *       - \ref SCIP_STAGE_SOLVING
1831  *       - \ref SCIP_STAGE_SOLVED
1832  */
SCIPenableConsSeparation(SCIP * scip,SCIP_CONS * cons)1833 SCIP_RETCODE SCIPenableConsSeparation(
1834    SCIP*                 scip,               /**< SCIP data structure */
1835    SCIP_CONS*            cons                /**< constraint */
1836    )
1837 {
1838    SCIP_CALL( SCIPcheckStage(scip, "SCIPenableConsSeparation", FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1839 
1840    SCIP_CALL( SCIPconsEnableSeparation(cons, scip->set) );
1841 
1842    return SCIP_OKAY;
1843 }
1844 
1845 /** disables constraint's separation capabilities s.t. the constraint is not separated anymore until the separation
1846  *  is enabled again with a call to SCIPenableConsSeparation(); in contrast to SCIPdelConsLocal() and SCIPdelConsNode(),
1847  *  the disabling is not associated to a node in the tree and does not consume memory; therefore, the constraint
1848  *  is neither automatically enabled on leaving the node nor automatically disabled again on entering the node again
1849  *
1850  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1851  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1852  *
1853  *  @pre This method can be called if @p scip is in one of the following stages:
1854  *       - \ref SCIP_STAGE_TRANSFORMED
1855  *       - \ref SCIP_STAGE_PRESOLVING
1856  *       - \ref SCIP_STAGE_PRESOLVED
1857  *       - \ref SCIP_STAGE_INITSOLVE
1858  *       - \ref SCIP_STAGE_SOLVING
1859  *       - \ref SCIP_STAGE_SOLVED
1860  */
SCIPdisableConsSeparation(SCIP * scip,SCIP_CONS * cons)1861 SCIP_RETCODE SCIPdisableConsSeparation(
1862    SCIP*                 scip,               /**< SCIP data structure */
1863    SCIP_CONS*            cons                /**< constraint */
1864    )
1865 {
1866    SCIP_CALL( SCIPcheckStage(scip, "SCIPdisableConsSeparation", FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1867 
1868    SCIP_CALL( SCIPconsDisableSeparation(cons, scip->set) );
1869 
1870    return SCIP_OKAY;
1871 }
1872 
1873 /** enables constraint's propagation capabilities
1874  *
1875  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1876  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1877  *
1878  *  @pre This method can be called if @p scip is in one of the following stages:
1879  *       - \ref SCIP_STAGE_TRANSFORMED
1880  *       - \ref SCIP_STAGE_INITPRESOLVE
1881  *       - \ref SCIP_STAGE_PRESOLVING
1882  *       - \ref SCIP_STAGE_EXITPRESOLVE
1883  *       - \ref SCIP_STAGE_PRESOLVED
1884  *       - \ref SCIP_STAGE_INITSOLVE
1885  *       - \ref SCIP_STAGE_SOLVING
1886  *       - \ref SCIP_STAGE_SOLVED
1887  */
SCIPenableConsPropagation(SCIP * scip,SCIP_CONS * cons)1888 SCIP_RETCODE SCIPenableConsPropagation(
1889    SCIP*                 scip,               /**< SCIP data structure */
1890    SCIP_CONS*            cons                /**< constraint */
1891    )
1892 {
1893    SCIP_CALL( SCIPcheckStage(scip, "SCIPenableConsPropagation", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1894 
1895    SCIP_CALL( SCIPconsEnablePropagation(cons, scip->set) );
1896 
1897    return SCIP_OKAY;
1898 }
1899 
1900 /** disables constraint's propagation capabilities s.t. the constraint is not propagated anymore until the propagation
1901  *  is enabled again with a call to SCIPenableConsPropagation(); in contrast to SCIPdelConsLocal() and SCIPdelConsNode(),
1902  *  the disabling is not associated to a node in the tree and does not consume memory; therefore, the constraint
1903  *  is neither automatically enabled on leaving the node nor automatically disabled again on entering the node again
1904  *
1905  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1906  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1907  *
1908  *  @pre This method can be called if @p scip is in one of the following stages:
1909  *       - \ref SCIP_STAGE_TRANSFORMED
1910  *       - \ref SCIP_STAGE_INITPRESOLVE
1911  *       - \ref SCIP_STAGE_PRESOLVING
1912  *       - \ref SCIP_STAGE_EXITPRESOLVE
1913  *       - \ref SCIP_STAGE_PRESOLVED
1914  *       - \ref SCIP_STAGE_INITSOLVE
1915  *       - \ref SCIP_STAGE_SOLVING
1916  *       - \ref SCIP_STAGE_SOLVED
1917  */
SCIPdisableConsPropagation(SCIP * scip,SCIP_CONS * cons)1918 SCIP_RETCODE SCIPdisableConsPropagation(
1919    SCIP*                 scip,               /**< SCIP data structure */
1920    SCIP_CONS*            cons                /**< constraint */
1921    )
1922 {
1923    SCIP_CALL( SCIPcheckStage(scip, "SCIPdisableConsPropagation", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1924 
1925    SCIP_CALL( SCIPconsDisablePropagation(cons, scip->set) );
1926 
1927    return SCIP_OKAY;
1928 }
1929 
1930 #undef SCIPmarkConsPropagate
1931 
1932 /** marks constraint to be propagated
1933  *
1934  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1935  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1936  *
1937  *  @pre This method can be called if @p scip is in one of the following stages:
1938  *       - \ref SCIP_STAGE_TRANSFORMING
1939  *       - \ref SCIP_STAGE_TRANSFORMED
1940  *       - \ref SCIP_STAGE_INITPRESOLVE
1941  *       - \ref SCIP_STAGE_PRESOLVING
1942  *       - \ref SCIP_STAGE_EXITPRESOLVE
1943  *       - \ref SCIP_STAGE_PRESOLVED
1944  *       - \ref SCIP_STAGE_INITSOLVE
1945  *       - \ref SCIP_STAGE_SOLVING
1946  *       - \ref SCIP_STAGE_SOLVED
1947  *       - \ref SCIP_STAGE_EXITSOLVE
1948  *
1949  *  @note if a constraint is marked to be propagated, the age of the constraint will be ignored for propagation
1950  */
SCIPmarkConsPropagate(SCIP * scip,SCIP_CONS * cons)1951 SCIP_RETCODE SCIPmarkConsPropagate(
1952    SCIP*                 scip,               /**< SCIP data structure */
1953    SCIP_CONS*            cons                /**< constraint */
1954    )
1955 {
1956    SCIP_CALL( SCIPcheckStage(scip, "SCIPmarkConsPropagate", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
1957 
1958    SCIP_CALL( SCIPconsMarkPropagate(cons, scip->set) );
1959 
1960    assert(!SCIPconsIsEnabled(cons) || SCIPconsIsMarkedPropagate(cons));
1961 
1962    return SCIP_OKAY;
1963 }
1964 
1965 /** unmarks the constraint to be propagated
1966  *
1967  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1968  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1969  *
1970  *  @pre This method can be called if @p scip is in one of the following stages:
1971  *       - \ref SCIP_STAGE_TRANSFORMED
1972  *       - \ref SCIP_STAGE_PRESOLVING
1973  *       - \ref SCIP_STAGE_EXITPRESOLVE
1974  *       - \ref SCIP_STAGE_PRESOLVED
1975  *       - \ref SCIP_STAGE_INITSOLVE
1976  *       - \ref SCIP_STAGE_SOLVING
1977  *       - \ref SCIP_STAGE_SOLVED
1978  */
SCIPunmarkConsPropagate(SCIP * scip,SCIP_CONS * cons)1979 SCIP_RETCODE SCIPunmarkConsPropagate(
1980    SCIP*                 scip,               /**< SCIP data structure */
1981    SCIP_CONS*            cons                /**< constraint */
1982    )
1983 {
1984    SCIP_CALL( SCIPcheckStage(scip, "SCIPunmarkConsPropagate", FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1985 
1986    SCIP_CALL( SCIPconsUnmarkPropagate(cons, scip->set) );
1987 
1988    assert(!SCIPconsIsEnabled(cons) || !SCIPconsIsMarkedPropagate(cons));
1989 
1990    return SCIP_OKAY;
1991 }
1992 
1993 /** adds given values to lock status of type @p locktype of the constraint and updates the rounding locks of the involved variables
1994  *
1995  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1996  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1997  *
1998  *  @pre This method can be called if @p scip is in one of the following stages:
1999  *       - \ref SCIP_STAGE_PROBLEM
2000  *       - \ref SCIP_STAGE_TRANSFORMING
2001  *       - \ref SCIP_STAGE_INITPRESOLVE
2002  *       - \ref SCIP_STAGE_PRESOLVING
2003  *       - \ref SCIP_STAGE_EXITPRESOLVE
2004  *       - \ref SCIP_STAGE_INITSOLVE
2005  *       - \ref SCIP_STAGE_SOLVING
2006  *       - \ref SCIP_STAGE_EXITSOLVE
2007  *       - \ref SCIP_STAGE_FREETRANS
2008  */
SCIPaddConsLocksType(SCIP * scip,SCIP_CONS * cons,SCIP_LOCKTYPE locktype,int nlockspos,int nlocksneg)2009 SCIP_RETCODE SCIPaddConsLocksType(
2010    SCIP*                 scip,               /**< SCIP data structure */
2011    SCIP_CONS*            cons,               /**< constraint */
2012    SCIP_LOCKTYPE         locktype,           /**< type of the variable locks */
2013    int                   nlockspos,          /**< increase in number of rounding locks for constraint */
2014    int                   nlocksneg           /**< increase in number of rounding locks for constraint's negation */
2015    )
2016 {
2017    SCIP_CALL( SCIPcheckStage(scip, "SCIPaddConsLocksType", FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE) );
2018 
2019    SCIP_CALL( SCIPconsAddLocks(cons, scip->set, locktype, nlockspos, nlocksneg) );
2020 
2021    return SCIP_OKAY;
2022 }
2023 
2024 /** adds given values to lock status of the constraint and updates the rounding locks of the involved variables
2025  *
2026  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2027  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2028  *
2029  *  @pre This method can be called if @p scip is in one of the following stages:
2030  *       - \ref SCIP_STAGE_PROBLEM
2031  *       - \ref SCIP_STAGE_TRANSFORMING
2032  *       - \ref SCIP_STAGE_INITPRESOLVE
2033  *       - \ref SCIP_STAGE_PRESOLVING
2034  *       - \ref SCIP_STAGE_EXITPRESOLVE
2035  *       - \ref SCIP_STAGE_INITSOLVE
2036  *       - \ref SCIP_STAGE_SOLVING
2037  *       - \ref SCIP_STAGE_EXITSOLVE
2038  *       - \ref SCIP_STAGE_FREETRANS
2039  *
2040  *  @note This methods always adds locks of type model
2041  */
SCIPaddConsLocks(SCIP * scip,SCIP_CONS * cons,int nlockspos,int nlocksneg)2042 SCIP_RETCODE SCIPaddConsLocks(
2043    SCIP*                 scip,               /**< SCIP data structure */
2044    SCIP_CONS*            cons,               /**< constraint */
2045    int                   nlockspos,          /**< increase in number of rounding locks for constraint */
2046    int                   nlocksneg           /**< increase in number of rounding locks for constraint's negation */
2047    )
2048 {
2049    SCIP_CALL( SCIPcheckStage(scip, "SCIPaddConsLocks", FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE) );
2050 
2051    SCIP_CALL( SCIPaddConsLocksType(scip, cons, SCIP_LOCKTYPE_MODEL, nlockspos, nlocksneg) );
2052 
2053    return SCIP_OKAY;
2054 }
2055 
2056 /** checks single constraint for feasibility of the given solution
2057  *
2058  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2059  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2060  *
2061  *  @pre This method can be called if @p scip is in one of the following stages:
2062  *       - \ref SCIP_STAGE_PROBLEM
2063  *       - \ref SCIP_STAGE_TRANSFORMED
2064  *       - \ref SCIP_STAGE_INITPRESOLVE
2065  *       - \ref SCIP_STAGE_PRESOLVING
2066  *       - \ref SCIP_STAGE_EXITPRESOLVE
2067  *       - \ref SCIP_STAGE_PRESOLVED
2068  *       - \ref SCIP_STAGE_INITSOLVE
2069  *       - \ref SCIP_STAGE_SOLVING
2070  *       - \ref SCIP_STAGE_SOLVED
2071  */
SCIPcheckCons(SCIP * scip,SCIP_CONS * cons,SCIP_SOL * sol,SCIP_Bool checkintegrality,SCIP_Bool checklprows,SCIP_Bool printreason,SCIP_RESULT * result)2072 SCIP_RETCODE SCIPcheckCons(
2073    SCIP*                 scip,               /**< SCIP data structure */
2074    SCIP_CONS*            cons,               /**< constraint to check */
2075    SCIP_SOL*             sol,                /**< primal CIP solution */
2076    SCIP_Bool             checkintegrality,   /**< Has integrality to be checked? */
2077    SCIP_Bool             checklprows,        /**< Do constraints represented by rows in the current LP have to be checked? */
2078    SCIP_Bool             printreason,        /**< Should the reason for the violation be printed? */
2079    SCIP_RESULT*          result              /**< pointer to store the result of the callback method */
2080    )
2081 {
2082    SCIP_CALL( SCIPcheckStage(scip, "SCIPcheckCons", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2083 
2084    SCIP_CALL( SCIPconsCheck(cons, scip->set, sol, checkintegrality, checklprows, printreason, result) );
2085 
2086    return SCIP_OKAY;
2087 }
2088 
2089 /** enforces single constraint for a given pseudo solution
2090  *
2091  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2092  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2093  *
2094  *  @pre This method can be called if @p scip is in one of the following stages:
2095  *       - \ref SCIP_STAGE_SOLVING
2096  *
2097  *  @note This is an advanced method and should be used with caution.  It may only be called for constraints that were not
2098  *        added to SCIP beforehand.
2099  */
SCIPenfopsCons(SCIP * scip,SCIP_CONS * cons,SCIP_Bool solinfeasible,SCIP_Bool objinfeasible,SCIP_RESULT * result)2100 SCIP_RETCODE SCIPenfopsCons(
2101    SCIP*                 scip,               /**< SCIP data structure */
2102    SCIP_CONS*            cons,               /**< constraint to enforce */
2103    SCIP_Bool             solinfeasible,      /**< was the solution already declared infeasible by a constraint handler? */
2104    SCIP_Bool             objinfeasible,      /**< is the solution infeasible anyway due to violating lower objective bound? */
2105    SCIP_RESULT*          result              /**< pointer to store the result of the callback method */
2106    )
2107 {
2108    assert(scip != NULL);
2109    assert(cons != NULL);
2110    assert(!SCIPconsIsAdded(cons));
2111    assert(result != NULL);
2112 
2113    SCIP_CALL( SCIPcheckStage(scip, "SCIPenfopsCons", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2114 
2115    SCIP_CALL( SCIPconsEnfops(cons, scip->set, solinfeasible, objinfeasible, result) );
2116 
2117    return SCIP_OKAY;
2118 }
2119 
2120 /** enforces single constraint for a given LP solution
2121  *
2122  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2123  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2124  *
2125  *  @pre This method can be called if @p scip is in one of the following stages:
2126  *       - \ref SCIP_STAGE_SOLVING
2127  *
2128  *  @note This is an advanced method and should be used with caution.  It may only be called for constraints that were not
2129  *        added to SCIP beforehand.
2130  */
SCIPenfolpCons(SCIP * scip,SCIP_CONS * cons,SCIP_Bool solinfeasible,SCIP_RESULT * result)2131 SCIP_RETCODE SCIPenfolpCons(
2132    SCIP*                 scip,               /**< SCIP data structure */
2133    SCIP_CONS*            cons,               /**< constraint to enforce */
2134    SCIP_Bool             solinfeasible,      /**< was the solution already declared infeasible by a constraint handler? */
2135    SCIP_RESULT*          result              /**< pointer to store the result of the callback method */
2136    )
2137 {
2138    assert(scip != NULL);
2139    assert(cons != NULL);
2140    assert(!SCIPconsIsAdded(cons));
2141    assert(result != NULL);
2142 
2143    SCIP_CALL( SCIPcheckStage(scip, "SCIPenfolpCons", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2144 
2145    SCIP_CALL( SCIPconsEnfolp(cons, scip->set, solinfeasible, result) );
2146 
2147    return SCIP_OKAY;
2148 }
2149 
2150 /** enforces single constraint for a given relaxation solution
2151  *
2152  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2153  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2154  *
2155  *  @pre This method can be called if @p scip is in one of the following stages:
2156  *       - \ref SCIP_STAGE_SOLVING
2157  *
2158  *  @note This is an advanced method and should be used with caution.  It may only be called for constraints that were not
2159  *        added to SCIP beforehand.
2160  */
SCIPenforelaxCons(SCIP * scip,SCIP_CONS * cons,SCIP_SOL * sol,SCIP_Bool solinfeasible,SCIP_RESULT * result)2161 SCIP_RETCODE SCIPenforelaxCons(
2162    SCIP*                 scip,               /**< SCIP data structure */
2163    SCIP_CONS*            cons,               /**< constraint to enforce */
2164    SCIP_SOL*             sol,                /**< solution to enforce */
2165    SCIP_Bool             solinfeasible,      /**< was the solution already declared infeasible by a constraint handler? */
2166    SCIP_RESULT*          result              /**< pointer to store the result of the callback method */
2167    )
2168 {
2169    assert(scip != NULL);
2170    assert(cons != NULL);
2171    assert(!SCIPconsIsAdded(cons));
2172    assert(sol != NULL);
2173    assert(result != NULL);
2174 
2175    SCIP_CALL( SCIPcheckStage(scip, "SCIPenforelaxCons", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2176 
2177    SCIP_CALL( SCIPconsEnforelax(cons, scip->set, sol, solinfeasible, result) );
2178 
2179    return SCIP_OKAY;
2180 }
2181 
2182 /** calls LP initialization method for single constraint
2183  *
2184  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2185  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2186  *
2187  *  @pre This method can be called if @p scip is in one of the following stages:
2188  *       - \ref SCIP_STAGE_SOLVING
2189  *
2190  *  @note This is an advanced method and should be used with caution.  It may only be called for constraints that were not
2191  *        added to SCIP beforehand.
2192  */
SCIPinitlpCons(SCIP * scip,SCIP_CONS * cons,SCIP_Bool * infeasible)2193 SCIP_RETCODE SCIPinitlpCons(
2194    SCIP*                 scip,               /**< SCIP data structure */
2195    SCIP_CONS*            cons,               /**< constraint to initialize */
2196    SCIP_Bool*            infeasible          /**< pointer to store whether infeasibility was detected while building the LP */
2197    )
2198 {
2199    assert(scip != NULL);
2200    assert(cons != NULL);
2201    assert(!SCIPconsIsAdded(cons));
2202 
2203    SCIP_CALL( SCIPcheckStage(scip, "SCIPinitlpCons", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2204 
2205    SCIP_CALL( SCIPconsInitlp(cons, scip->set, infeasible) );
2206 
2207    return SCIP_OKAY;
2208 }
2209 
2210 /** calls separation method of single constraint for LP solution
2211  *
2212  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2213  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2214  *
2215  *  @pre This method can be called if @p scip is in one of the following stages:
2216  *       - \ref SCIP_STAGE_SOLVING
2217  *
2218  *  @note This is an advanced method and should be used with caution.
2219  */
SCIPsepalpCons(SCIP * scip,SCIP_CONS * cons,SCIP_RESULT * result)2220 SCIP_RETCODE SCIPsepalpCons(
2221    SCIP*                 scip,               /**< SCIP data structure */
2222    SCIP_CONS*            cons,               /**< constraint to separate */
2223    SCIP_RESULT*          result              /**< pointer to store the result of the separation call */
2224    )
2225 {
2226    assert(scip != NULL);
2227    assert(cons != NULL);
2228    assert(result != NULL);
2229 
2230    SCIP_CALL( SCIPcheckStage(scip, "SCIPsepalpCons", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2231 
2232    SCIP_CALL( SCIPconsSepalp(cons, scip->set, result) );
2233 
2234    return SCIP_OKAY;
2235 }
2236 
2237 /** calls separation method of single constraint for given primal solution
2238  *
2239  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2240  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2241  *
2242  *  @pre This method can be called if @p scip is in one of the following stages:
2243  *       - \ref SCIP_STAGE_SOLVING
2244  *
2245  *  @note This is an advanced method and should be used with caution.
2246  */
SCIPsepasolCons(SCIP * scip,SCIP_CONS * cons,SCIP_SOL * sol,SCIP_RESULT * result)2247 SCIP_RETCODE SCIPsepasolCons(
2248    SCIP*                 scip,               /**< SCIP data structure */
2249    SCIP_CONS*            cons,               /**< constraint to separate */
2250    SCIP_SOL*             sol,                /**< primal solution that should be separated*/
2251    SCIP_RESULT*          result              /**< pointer to store the result of the separation call */
2252    )
2253 {
2254    assert(scip != NULL);
2255    assert(cons != NULL);
2256    assert(sol != NULL);
2257    assert(result != NULL);
2258 
2259    SCIP_CALL( SCIPcheckStage(scip, "SCIPsepasolCons", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2260 
2261    SCIP_CALL( SCIPconsSepasol(cons, scip->set, sol, result) );
2262 
2263    return SCIP_OKAY;
2264 }
2265 
2266 /** calls domain propagation method of single constraint
2267  *
2268  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2269  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2270  *
2271  *  @pre This method can be called if @p scip is in one of the following stages:
2272  *       - \ref SCIP_STAGE_PRESOLVING
2273  *       - \ref SCIP_STAGE_SOLVING
2274  *
2275  *  @note This is an advanced method and should be used with caution.
2276  */
SCIPpropCons(SCIP * scip,SCIP_CONS * cons,SCIP_PROPTIMING proptiming,SCIP_RESULT * result)2277 SCIP_RETCODE SCIPpropCons(
2278    SCIP*                 scip,               /**< SCIP data structure */
2279    SCIP_CONS*            cons,               /**< constraint to propagate */
2280    SCIP_PROPTIMING       proptiming,         /**< current point in the node solving loop */
2281    SCIP_RESULT*          result              /**< pointer to store the result of the callback method */
2282    )
2283 {
2284    assert(scip != NULL);
2285    assert(cons != NULL);
2286    assert(result != NULL);
2287 
2288    SCIP_CALL( SCIPcheckStage(scip, "SCIPpropCons", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2289 
2290    SCIP_CALL( SCIPconsProp(cons, scip->set, proptiming, result) );
2291 
2292    return SCIP_OKAY;
2293 }
2294 
2295 /** resolves propagation conflict of single constraint
2296  *
2297  *
2298  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2299  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2300  *
2301  *  @pre This method can be called if @p scip is in one of the following stages:
2302  *       - \ref SCIP_STAGE_PRESOLVING
2303  *       - \ref SCIP_STAGE_SOLVING
2304  *
2305  *  @note This is an advanced method and should be used with caution.  It may only be called for constraints that were not
2306  *        added to SCIP beforehand.
2307  */
SCIPrespropCons(SCIP * scip,SCIP_CONS * cons,SCIP_VAR * infervar,int inferinfo,SCIP_BOUNDTYPE boundtype,SCIP_BDCHGIDX * bdchgidx,SCIP_Real relaxedbd,SCIP_RESULT * result)2308 SCIP_RETCODE SCIPrespropCons(
2309    SCIP*                 scip,               /**< SCIP data structure */
2310    SCIP_CONS*            cons,               /**< constraint to resolve conflict for */
2311    SCIP_VAR*             infervar,           /**< the conflict variable whose bound change has to be resolved */
2312    int                   inferinfo,          /**< the user information passed to the corresponding SCIPinferVarLbCons() or SCIPinferVarUbCons() call */
2313    SCIP_BOUNDTYPE        boundtype,          /**< the type of the changed bound (lower or upper bound) */
2314    SCIP_BDCHGIDX*        bdchgidx,           /**< the index of the bound change, representing the point of time where the change took place */
2315    SCIP_Real             relaxedbd,          /**< the relaxed bound which is sufficient to be explained */
2316    SCIP_RESULT*          result              /**< pointer to store the result of the callback method */
2317    )
2318 {
2319    assert(scip != NULL);
2320    assert(cons != NULL);
2321    assert(!SCIPconsIsAdded(cons));
2322    assert(infervar != NULL);
2323    assert(bdchgidx != NULL);
2324    assert(result != NULL);
2325 
2326    SCIP_CALL( SCIPcheckStage(scip, "SCIPrespropCons", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2327 
2328    SCIP_CALL( SCIPconsResprop(cons, scip->set, infervar, inferinfo, boundtype, bdchgidx, relaxedbd, result) );
2329 
2330    return SCIP_OKAY;
2331 }
2332 
2333 /** presolves of single constraint
2334  *
2335  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2336  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2337  *
2338  *  @pre This method can be called if @p scip is in one of the following stages:
2339  *       - \ref SCIP_STAGE_PRESOLVING
2340  *
2341  *  @note This is an advanced method and should be used with caution.
2342  */
SCIPpresolCons(SCIP * scip,SCIP_CONS * cons,int nrounds,SCIP_PRESOLTIMING presoltiming,int nnewfixedvars,int nnewaggrvars,int nnewchgvartypes,int nnewchgbds,int nnewholes,int nnewdelconss,int nnewaddconss,int nnewupgdconss,int nnewchgcoefs,int nnewchgsides,int * nfixedvars,int * naggrvars,int * nchgvartypes,int * nchgbds,int * naddholes,int * ndelconss,int * naddconss,int * nupgdconss,int * nchgcoefs,int * nchgsides,SCIP_RESULT * result)2343 SCIP_RETCODE SCIPpresolCons(
2344    SCIP*                 scip,               /**< SCIP data structure */
2345    SCIP_CONS*            cons,               /**< constraint to presolve */
2346    int                   nrounds,            /**< number of presolving rounds already done */
2347    SCIP_PRESOLTIMING     presoltiming,       /**< presolving timing(s) to be performed */
2348    int                   nnewfixedvars,      /**< number of variables fixed since the last call to the presolving method */
2349    int                   nnewaggrvars,       /**< number of variables aggregated since the last call to the presolving method */
2350    int                   nnewchgvartypes,    /**< number of variable type changes since the last call to the presolving method */
2351    int                   nnewchgbds,         /**< number of variable bounds tightened since the last call to the presolving method */
2352    int                   nnewholes,          /**< number of domain holes added since the last call to the presolving method */
2353    int                   nnewdelconss,       /**< number of deleted constraints since the last call to the presolving method */
2354    int                   nnewaddconss,       /**< number of added constraints since the last call to the presolving method */
2355    int                   nnewupgdconss,      /**< number of upgraded constraints since the last call to the presolving method */
2356    int                   nnewchgcoefs,       /**< number of changed coefficients since the last call to the presolving method */
2357    int                   nnewchgsides,       /**< number of changed left or right hand sides since the last call to the presolving method */
2358    int*                  nfixedvars,         /**< pointer to count total number of variables fixed of all presolvers */
2359    int*                  naggrvars,          /**< pointer to count total number of variables aggregated of all presolvers */
2360    int*                  nchgvartypes,       /**< pointer to count total number of variable type changes of all presolvers */
2361    int*                  nchgbds,            /**< pointer to count total number of variable bounds tightened of all presolvers */
2362    int*                  naddholes,          /**< pointer to count total number of domain holes added of all presolvers */
2363    int*                  ndelconss,          /**< pointer to count total number of deleted constraints of all presolvers */
2364    int*                  naddconss,          /**< pointer to count total number of added constraints of all presolvers */
2365    int*                  nupgdconss,         /**< pointer to count total number of upgraded constraints of all presolvers */
2366    int*                  nchgcoefs,          /**< pointer to count total number of changed coefficients of all presolvers */
2367    int*                  nchgsides,          /**< pointer to count total number of changed left/right hand sides of all presolvers */
2368    SCIP_RESULT*          result              /**< pointer to store the result of the callback method */
2369    )
2370 {
2371    assert(scip != NULL);
2372    assert(cons != NULL);
2373    assert(nfixedvars != NULL);
2374    assert(naggrvars != NULL);
2375    assert(nchgvartypes != NULL);
2376    assert(nchgbds != NULL);
2377    assert(naddholes != NULL);
2378    assert(ndelconss != NULL);
2379    assert(naddconss != NULL);
2380    assert(nupgdconss != NULL);
2381    assert(nchgcoefs != NULL);
2382    assert(nchgsides != NULL);
2383    assert(result != NULL);
2384 
2385    SCIP_CALL( SCIPcheckStage(scip, "SCIPpresolCons", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
2386 
2387    SCIP_CALL( SCIPconsPresol(cons, scip->set, nrounds, presoltiming, nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
2388          nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, nfixedvars, naggrvars, nchgvartypes,
2389          nchgbds, naddholes, ndelconss, naddconss, nupgdconss, nchgcoefs, nchgsides , result) );
2390 
2391    return SCIP_OKAY;
2392 }
2393 
2394 /** calls constraint activation notification method of single constraint
2395  *
2396  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2397  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2398  *
2399  *  @pre This method can be called if @p scip is in one of the following stages:
2400  *       - \ref SCIP_STAGE_TRANSFORMING
2401  *
2402  *  @note This is an advanced method and should be used with caution.  It may only be called for constraints that were not
2403  *      added to SCIP beforehand.
2404  */
SCIPactiveCons(SCIP * scip,SCIP_CONS * cons)2405 SCIP_RETCODE SCIPactiveCons(
2406    SCIP*                 scip,               /**< SCIP data structure */
2407    SCIP_CONS*            cons                /**< constraint to notify */
2408    )
2409 {
2410    assert(scip != NULL);
2411    assert(cons != NULL);
2412    assert(!SCIPconsIsAdded(cons));
2413    assert(!SCIPconsIsDeleted(cons));
2414 
2415    SCIP_CALL( SCIPcheckStage(scip, "SCIPactiveCons", FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
2416 
2417    SCIP_CALL( SCIPconsActive(cons, scip->set) );
2418 
2419    return SCIP_OKAY;
2420 }
2421 
2422 /** calls constraint deactivation notification method of single constraint
2423  *
2424  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2425  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2426  *
2427  *  @pre This method can be called if @p scip is in one of the following stages:
2428  *       - \ref SCIP_STAGE_PRESOLVING
2429  *       - \ref SCIP_STAGE_SOLVING
2430  *
2431  *  @note This is an advanced method and should be used with caution. It may only be called for constraints that were not
2432  *        added to SCIP beforehand.
2433  */
SCIPdeactiveCons(SCIP * scip,SCIP_CONS * cons)2434 SCIP_RETCODE SCIPdeactiveCons(
2435    SCIP*                 scip,               /**< SCIP data structure */
2436    SCIP_CONS*            cons                /**< constraint to notify */
2437    )
2438 {
2439    assert(scip != NULL);
2440    assert(cons != NULL);
2441    assert(!SCIPconsIsAdded(cons));
2442 
2443    SCIP_CALL( SCIPcheckStage(scip, "SCIPdeactiveCons", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2444 
2445    SCIP_CALL( SCIPconsDeactive(cons, scip->set) );
2446 
2447    return SCIP_OKAY;
2448 }
2449 
2450 /** outputs constraint information to file stream via the message handler system
2451  *
2452  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2453  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2454  *
2455  *  @pre This method can be called if @p scip is in one of the following stages:
2456  *       - \ref SCIP_STAGE_PROBLEM
2457  *       - \ref SCIP_STAGE_TRANSFORMING
2458  *       - \ref SCIP_STAGE_TRANSFORMED
2459  *       - \ref SCIP_STAGE_INITPRESOLVE
2460  *       - \ref SCIP_STAGE_PRESOLVING
2461  *       - \ref SCIP_STAGE_EXITPRESOLVE
2462  *       - \ref SCIP_STAGE_PRESOLVED
2463  *       - \ref SCIP_STAGE_INITSOLVE
2464  *       - \ref SCIP_STAGE_SOLVING
2465  *       - \ref SCIP_STAGE_SOLVED
2466  *       - \ref SCIP_STAGE_EXITSOLVE
2467  *       - \ref SCIP_STAGE_FREETRANS
2468  *
2469  *  @note If the message handler is set to a NULL pointer nothing will be printed.
2470  *  @note The file stream will not be flushed directly, this can be achieved by calling SCIPinfoMessage() printing a
2471  *        newline character.
2472  */
SCIPprintCons(SCIP * scip,SCIP_CONS * cons,FILE * file)2473 SCIP_RETCODE SCIPprintCons(
2474    SCIP*                 scip,               /**< SCIP data structure */
2475    SCIP_CONS*            cons,               /**< constraint */
2476    FILE*                 file                /**< output file (or NULL for standard output) */
2477    )
2478 {
2479    SCIP_CALL( SCIPcheckStage(scip, "SCIPprintCons", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2480 
2481    SCIP_CALL( SCIPconsPrint(cons, scip->set, scip->messagehdlr, file) );
2482 
2483    return SCIP_OKAY;
2484 }
2485 
2486 /** method to collect the variables of a constraint
2487  *
2488  *  If the number of variables is greater than the available slots in the variable array, nothing happens except that
2489  *  the success point is set to FALSE. With the method SCIPgetConsNVars() it is possible to get the number of variables
2490  *  a constraint has in its scope.
2491  *
2492  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2493  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2494  *
2495  *  @pre This method can be called if @p scip is in one of the following stages:
2496  *       - \ref SCIP_STAGE_PROBLEM
2497  *       - \ref SCIP_STAGE_TRANSFORMING
2498  *       - \ref SCIP_STAGE_TRANSFORMED
2499  *       - \ref SCIP_STAGE_INITPRESOLVE
2500  *       - \ref SCIP_STAGE_PRESOLVING
2501  *       - \ref SCIP_STAGE_EXITPRESOLVE
2502  *       - \ref SCIP_STAGE_PRESOLVED
2503  *       - \ref SCIP_STAGE_INITSOLVE
2504  *       - \ref SCIP_STAGE_SOLVING
2505  *       - \ref SCIP_STAGE_SOLVED
2506  *       - \ref SCIP_STAGE_EXITSOLVE
2507  *       - \ref SCIP_STAGE_FREETRANS
2508  *
2509  *  @note The success pointer indicates if all variables were copied into the vars arrray.
2510  *
2511  *  @note It might be that a constraint handler does not support this functionality, in that case the success pointer is
2512  *        set to FALSE.
2513  */
SCIPgetConsVars(SCIP * scip,SCIP_CONS * cons,SCIP_VAR ** vars,int varssize,SCIP_Bool * success)2514 SCIP_RETCODE SCIPgetConsVars(
2515    SCIP*                 scip,               /**< SCIP data structure */
2516    SCIP_CONS*            cons,               /**< constraint for which the variables are wanted */
2517    SCIP_VAR**            vars,               /**< array to store the involved variable of the constraint */
2518    int                   varssize,           /**< available slots in vars array which is needed to check if the array is large enough */
2519    SCIP_Bool*            success             /**< pointer to store whether the variables are successfully copied */
2520    )
2521 {
2522    SCIP_CALL( SCIPcheckStage(scip, "SCIPgetConsVars", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2523 
2524    assert(scip != NULL);
2525    assert(cons != NULL);
2526    assert(vars != NULL);
2527    assert(success != NULL);
2528 
2529    SCIP_CALL( SCIPconsGetVars(cons, scip->set, vars, varssize, success) );
2530 
2531    return SCIP_OKAY;
2532 }
2533 
2534 /** method to collect the number of variables of a constraint
2535  *
2536  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2537  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2538  *
2539  *  @pre This method can be called if @p scip is in one of the following stages:
2540  *       - \ref SCIP_STAGE_PROBLEM
2541  *       - \ref SCIP_STAGE_TRANSFORMING
2542  *       - \ref SCIP_STAGE_TRANSFORMED
2543  *       - \ref SCIP_STAGE_INITPRESOLVE
2544  *       - \ref SCIP_STAGE_PRESOLVING
2545  *       - \ref SCIP_STAGE_EXITPRESOLVE
2546  *       - \ref SCIP_STAGE_PRESOLVED
2547  *       - \ref SCIP_STAGE_INITSOLVE
2548  *       - \ref SCIP_STAGE_SOLVING
2549  *       - \ref SCIP_STAGE_SOLVED
2550  *       - \ref SCIP_STAGE_EXITSOLVE
2551  *       - \ref SCIP_STAGE_FREETRANS
2552  *
2553  *  @note The success pointer indicates if the contraint handler was able to return the number of variables
2554  *
2555  *  @note It might be that a constraint handler does not support this functionality, in that case the success pointer is
2556  *        set to FALSE
2557  */
SCIPgetConsNVars(SCIP * scip,SCIP_CONS * cons,int * nvars,SCIP_Bool * success)2558 SCIP_RETCODE SCIPgetConsNVars(
2559    SCIP*                 scip,               /**< SCIP data structure */
2560    SCIP_CONS*            cons,               /**< constraint for which the number of variables is wanted */
2561    int*                  nvars,              /**< pointer to store the number of variables */
2562    SCIP_Bool*            success             /**< pointer to store whether the constraint successfully returned the number of variables */
2563    )
2564 {
2565    SCIP_CALL( SCIPcheckStage(scip, "SCIPgetConsNVars", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2566 
2567    assert(scip != NULL);
2568    assert(cons != NULL);
2569    assert(nvars != NULL);
2570    assert(success != NULL);
2571 
2572    SCIP_CALL( SCIPconsGetNVars(cons, scip->set, nvars, success) );
2573 
2574    return SCIP_OKAY;
2575 }
2576