Scippy

SCIP

Solving Constraint Integer Programs

cons_varbound.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file cons_varbound.c
26  * @ingroup DEFPLUGINS_CONS
27  * @brief Constraint handler for variable bound constraints \f$lhs \le x + c y \le rhs\f$.
28  * @author Tobias Achterberg
29  * @author Timo Berthold
30  * @author Michael Winkler
31  * @author Gerald Gamrath
32  * @author Stefan Heinz
33  *
34  * This constraint handler handles a special type of linear constraints, namely variable bound constraints.
35  * A variable bound constraint has the form
36  * \f[
37  * lhs \leq x + c y \leq rhs
38  * \f]
39  * with coefficient \f$c \in Q\f$, \f$lhs\in Q \cup \{-\infty\}\f$, \f$rhs\in Q \cup \{\infty\}\f$,
40  * and decision variables \f$x\f$ (non-binary) and \f$y\f$ (binary or integer).
41  *
42  * @note Although x must be non-binary when the constraint is created, it can happen that x is upgraded to a binary
43  * variable, e.g. due to aggregations or bound changes in presolving.
44  */
45 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
46 
47 #include <ctype.h>
48 #include "blockmemshell/memory.h"
49 #include "scip/cons_linear.h"
50 #include "scip/cons_setppc.h"
51 #include "scip/cons_varbound.h"
52 #include "scip/pub_cons.h"
53 #include "scip/pub_event.h"
54 #include "scip/pub_lp.h"
55 #include "scip/pub_message.h"
56 #include "scip/pub_misc.h"
57 #include "scip/pub_misc_sort.h"
58 #include "scip/pub_var.h"
59 #include "scip/scip_conflict.h"
60 #include "scip/scip_cons.h"
61 #include "scip/scip_cut.h"
62 #include "scip/scip_event.h"
63 #include "scip/scip_general.h"
64 #include "scip/scip_lp.h"
65 #include "scip/scip_mem.h"
66 #include "scip/scip_message.h"
67 #include "scip/scip_nlp.h"
68 #include "scip/scip_numerics.h"
69 #include "scip/scip_param.h"
70 #include "scip/scip_prob.h"
71 #include "scip/scip_probing.h"
72 #include "scip/scip_sol.h"
73 #include "scip/scip_tree.h"
74 #include "scip/scip_var.h"
75 #include "scip/dbldblarith.h"
76 
77 
78 /**@name Constraint handler properties
79  *
80  * @{
81  */
82 
83 /* constraint handler properties */
84 #define CONSHDLR_NAME "varbound"
85 #define CONSHDLR_DESC "variable bounds lhs <= x + c*y <= rhs, x non-binary, y non-continuous"
86 #define CONSHDLR_SEPAPRIORITY +900000 /**< priority of the constraint handler for separation */
87 #define CONSHDLR_ENFOPRIORITY -500000 /**< priority of the constraint handler for constraint enforcing */
88 #define CONSHDLR_CHECKPRIORITY -500000 /**< priority of the constraint handler for checking feasibility */
89 #define CONSHDLR_SEPAFREQ 0 /**< frequency for separating cuts; zero means to separate only in the root node */
90 #define CONSHDLR_PROPFREQ 1 /**< frequency for propagating domains; zero means only preprocessing propagation */
91 #define CONSHDLR_EAGERFREQ 100 /**< frequency for using all instead of only the useful constraints in separation,
92  * propagation and enforcement, -1 for no eager evaluations, 0 for first only */
93 #define CONSHDLR_MAXPREROUNDS -1 /**< maximal number of presolving rounds the constraint handler participates in (-1: no limit) */
94 #define CONSHDLR_DELAYSEPA FALSE /**< should separation method be delayed, if other separators found cuts? */
95 #define CONSHDLR_DELAYPROP FALSE /**< should propagation method be delayed, if other propagators found reductions? */
96 #define CONSHDLR_NEEDSCONS TRUE /**< should the constraint handler be skipped, if no constraints are available? */
97 
98 #define CONSHDLR_PRESOLTIMING (SCIP_PRESOLTIMING_FAST | SCIP_PRESOLTIMING_MEDIUM)
99 #define CONSHDLR_PROP_TIMING SCIP_PROPTIMING_BEFORELP
101 #define EVENTHDLR_NAME "varbound"
102 #define EVENTHDLR_DESC "bound change event handler for variable bound constraints"
104 #define LINCONSUPGD_PRIORITY +50000 /**< priority of the constraint handler for upgrading of linear constraints */
106 /**@} */
107 
108 /**@name Default parameter values
109  *
110  * @{
111  */
112 
113 #define DEFAULT_PRESOLPAIRWISE TRUE /**< should pairwise constraint comparison be performed in presolving? */
114 #define DEFAULT_MAXLPCOEF 1e+09 /**< maximum coefficient in varbound constraint to be added as a row into LP */
115 #define DEFAULT_USEBDWIDENING TRUE /**< should bound widening be used to initialize conflict analysis? */
117 
118 #define MAXSCALEDCOEF 1000LL /**< maximal coefficient value after scaling */
120 /**@} */
121 
122 /** variable bound constraint data */
123 struct SCIP_ConsData
124 {
125  SCIP_Real vbdcoef; /**< coefficient c of bounding variable y */
126  SCIP_Real lhs; /**< left hand side of variable bound inequality */
127  SCIP_Real rhs; /**< right hand side of variable bound inequality */
128  SCIP_VAR* var; /**< variable x that has variable bound */
129  SCIP_VAR* vbdvar; /**< binary, integer or implicit integer bounding variable y */
130  SCIP_ROW* row; /**< LP row, if constraint is already stored in LP row format */
131  SCIP_NLROW* nlrow; /**< NLP row, if constraint has been added to NLP relaxation */
132  unsigned int presolved:1; /**< is the variable bound constraint already presolved? */
133  unsigned int varboundsadded:1; /**< are the globally valid variable bounds added? */
134  unsigned int changed:1; /**< was constraint changed since last aggregation round in preprocessing? */
135  unsigned int tightened:1; /**< were the vbdcoef and all sides already tightened? */
136 };
137 
138 /** constraint handler data */
139 struct SCIP_ConshdlrData
140 {
141  SCIP_EVENTHDLR* eventhdlr; /**< event handler for bound change events */
142  SCIP_Bool presolpairwise; /**< should pairwise constraint comparison be performed in presolving? */
143  SCIP_Real maxlpcoef; /**< maximum coefficient in varbound constraint to be added as a row into LP */
144  SCIP_Bool usebdwidening; /**< should bound widening be used to in conflict analysis? */
145 };
146 
147 /** Propagation rules */
148 enum Proprule
149 {
150  PROPRULE_1, /**< left hand side and bounds on y -> lower bound on x */
151  PROPRULE_2, /**< left hand side and upper bound on x -> bound on y */
152  PROPRULE_3, /**< right hand side and bounds on y -> upper bound on x */
153  PROPRULE_4 /**< right hand side and lower bound on x -> bound on y */
154 };
155 typedef enum Proprule PROPRULE;
157 
158 /**@name Local methods
159  *
160  * @{
161  */
162 
163 /** compares two varbound constraints cons1: \f$ lhs1 \le x1 + c1 y1 \le rhs1 \f$ and cons2: \f$ lhs2 \le x2 + c2 y2 \le rhs2 \f$
164  * w.r.t. the indices of the contained variables
165  *
166  * returns -1 if:
167  * - the index of x1 is smaller than the index of x2 or
168  * - x1 = x2 and the index of y1 is smaller than the index of y2 or
169  * - x1 = x2 and y1 = y2 and cons2 was recently changed, but cons1 not
170  *
171  * returns 0 if x1 = x2, y1 = y2, and the changed status of both constraints is the same
172  *
173  * and returns +1 otherwise
174  */
175 static
176 SCIP_DECL_SORTPTRCOMP(consVarboundComp)
177 {
178  SCIP_CONSDATA* consdata1;
179  SCIP_CONSDATA* consdata2;
180 
181  assert(elem1 != NULL);
182  assert(elem2 != NULL);
183 
184  consdata1 = SCIPconsGetData((SCIP_CONS*) elem1);
185  consdata2 = SCIPconsGetData((SCIP_CONS*) elem2);
186 
187  assert(consdata1 != NULL);
188  assert(consdata2 != NULL);
189 
190  /* comparison is done over 3 ordered criteria:
191  * (i) variable index of variable 1
192  * (ii) variable index of variable 2.
193  * (iii) changed status
194  */
195  if( SCIPvarGetIndex(consdata1->var) < SCIPvarGetIndex(consdata2->var)
196  || (SCIPvarGetIndex(consdata1->var) == SCIPvarGetIndex(consdata2->var)
197  && SCIPvarGetIndex(consdata1->vbdvar) < SCIPvarGetIndex(consdata2->vbdvar))
198  || (SCIPvarGetIndex(consdata1->var) == SCIPvarGetIndex(consdata2->var)
199  && SCIPvarGetIndex(consdata1->vbdvar) == SCIPvarGetIndex(consdata2->vbdvar)
200  && !consdata1->changed && consdata2->changed) )
201  return -1;
202  else if( SCIPvarGetIndex(consdata1->var) == SCIPvarGetIndex(consdata2->var)
203  && SCIPvarGetIndex(consdata1->vbdvar) == SCIPvarGetIndex(consdata2->vbdvar)
204  && (consdata1->changed == consdata2->changed) )
205  return 0;
206  else
207  return +1;
208 }
209 
210 /** creates constraint handler data for varbound constraint handler */
211 static
213  SCIP* scip, /**< SCIP data structure */
214  SCIP_CONSHDLRDATA** conshdlrdata, /**< pointer to store the constraint handler data */
215  SCIP_EVENTHDLR* eventhdlr /**< event handler */
216  )
217 {
218  assert(scip != NULL);
219  assert(conshdlrdata != NULL);
220 
221  SCIP_CALL( SCIPallocBlockMemory(scip, conshdlrdata) );
222 
223  /* set event handler for bound change events */
224  (*conshdlrdata)->eventhdlr = eventhdlr;
225 
226  return SCIP_OKAY;
227 }
228 
229 /** frees constraint handler data for varbound constraint handler */
230 static
231 void conshdlrdataFree(
232  SCIP* scip, /**< SCIP data structure */
233  SCIP_CONSHDLRDATA** conshdlrdata /**< pointer to the constraint handler data */
234  )
235 {
236  assert(scip != NULL);
237  assert(conshdlrdata != NULL);
238  assert(*conshdlrdata != NULL);
239 
240  SCIPfreeBlockMemory(scip, conshdlrdata);
241 }
242 
243 /** catches events for variables
244  *
245  * @todo if lhs or rhs is infinite, catch only changes of the bound that could lead to propagation
246  */
247 static
249  SCIP* scip, /**< SCIP data structure */
250  SCIP_CONS* cons, /**< variable bound constraint */
251  SCIP_EVENTHDLR* eventhdlr /**< event handler */
252  )
253 {
254  SCIP_CONSDATA* consdata;
255  assert(cons != NULL);
256  assert(eventhdlr != NULL);
257  consdata = SCIPconsGetData(cons);
258  assert(consdata != NULL);
259 
262 
263  return SCIP_OKAY;
264 }
265 
266 /** drops events for variables */
267 static
269  SCIP* scip, /**< SCIP data structure */
270  SCIP_CONS* cons, /**< variable bound constraint */
271  SCIP_EVENTHDLR* eventhdlr /**< event handler */
272  )
273 {
274  SCIP_CONSDATA* consdata;
275  assert(cons != NULL);
276  assert(eventhdlr != NULL);
277  consdata = SCIPconsGetData(cons);
278  assert(consdata != NULL);
279 
280  SCIP_CALL( SCIPdropVarEvent(scip, consdata->var, SCIP_EVENTTYPE_BOUNDTIGHTENED | SCIP_EVENTTYPE_VARFIXED, eventhdlr, (SCIP_EVENTDATA*)cons, -1) );
281  SCIP_CALL( SCIPdropVarEvent(scip, consdata->vbdvar, SCIP_EVENTTYPE_BOUNDTIGHTENED | SCIP_EVENTTYPE_VARFIXED, eventhdlr, (SCIP_EVENTDATA*)cons, -1) );
282 
283  return SCIP_OKAY;
284 }
285 
286 /** creates a variable bound constraint data object */
287 static
289  SCIP* scip, /**< SCIP data structure */
290  SCIP_CONSDATA** consdata, /**< pointer to store the variable bound constraint data */
291  SCIP_VAR* var, /**< variable x that has variable bound */
292  SCIP_VAR* vbdvar, /**< binary, integer or implicit integer bounding variable y */
293  SCIP_Real vbdcoef, /**< coefficient c of bounding variable y */
294  SCIP_Real lhs, /**< left hand side of variable bound inequality */
295  SCIP_Real rhs /**< right hand side of variable bound inequality */
296  )
297 {
298  assert(consdata != NULL);
299  assert(SCIPvarGetType(vbdvar) != SCIP_VARTYPE_CONTINUOUS);
300 
301  SCIP_CALL( SCIPallocBlockMemory(scip, consdata) );
302 
303  if( SCIPisInfinity(scip, rhs) )
304  rhs = SCIPinfinity(scip);
305  else if( SCIPisInfinity(scip, -rhs) )
306  rhs = -SCIPinfinity(scip);
307 
308  if( SCIPisInfinity(scip, -lhs) )
309  lhs = -SCIPinfinity(scip);
310  else if( SCIPisInfinity(scip, lhs) )
311  lhs = SCIPinfinity(scip);
312 
313  if( SCIPisGT(scip, lhs, rhs) )
314  {
315  SCIPerrorMessage("left hand side of varbound constraint greater than right hand side\n");
316  SCIPerrorMessage(" -> lhs=%g, rhs=%g\n", lhs, rhs);
317  return SCIP_INVALIDDATA;
318  }
319 
320  if( SCIPisZero(scip, vbdcoef) )
321  {
322  SCIPerrorMessage("varbound coefficient must be different to zero.\n");
323  return SCIP_INVALIDDATA;
324  }
325 
326  if( SCIPisInfinity(scip, vbdcoef) )
327  vbdcoef = SCIPinfinity(scip);
328  else if( SCIPisInfinity(scip, -vbdcoef) )
329  vbdcoef = -SCIPinfinity(scip);
330 
331  (*consdata)->var = var;
332  (*consdata)->vbdvar = vbdvar;
333  (*consdata)->vbdcoef = vbdcoef;
334  (*consdata)->lhs = lhs;
335  (*consdata)->rhs = rhs;
336  (*consdata)->row = NULL;
337  (*consdata)->nlrow = NULL;
338  (*consdata)->presolved = FALSE;
339  (*consdata)->varboundsadded = FALSE;
340  (*consdata)->changed = TRUE;
341  (*consdata)->tightened = FALSE;
342 
343  /* if we are in the transformed problem, get transformed variables, add variable bound information, and catch events */
344  if( SCIPisTransformed(scip) )
345  {
346  SCIP_CALL( SCIPgetTransformedVar(scip, (*consdata)->var, &(*consdata)->var) );
347  SCIP_CALL( SCIPgetTransformedVar(scip, (*consdata)->vbdvar, &(*consdata)->vbdvar) );
348 
349 #ifndef NDEBUG
350  assert(SCIPvarGetStatus(SCIPvarGetProbvar((*consdata)->var)) != SCIP_VARSTATUS_MULTAGGR);
351  assert(SCIPvarGetStatus(SCIPvarGetProbvar((*consdata)->vbdvar)) != SCIP_VARSTATUS_MULTAGGR);
352 #endif
353  }
354 
355  /* capture variables */
356  SCIP_CALL( SCIPcaptureVar(scip, (*consdata)->var) );
357  SCIP_CALL( SCIPcaptureVar(scip, (*consdata)->vbdvar) );
358 
359  return SCIP_OKAY;
360 }
361 
362 /** frees a variable bound constraint data */
363 static
365  SCIP* scip, /**< SCIP data structure */
366  SCIP_CONSDATA** consdata /**< pointer to the variable bound constraint */
367  )
368 {
369  assert(consdata != NULL);
370  assert(*consdata != NULL);
371 
372  /* release the row */
373  if( (*consdata)->row != NULL )
374  {
375  SCIP_CALL( SCIPreleaseRow(scip, &(*consdata)->row) );
376  }
377 
378  /* release the nlrow */
379  if( (*consdata)->nlrow != NULL )
380  {
381  SCIP_CALL( SCIPreleaseNlRow(scip, &(*consdata)->nlrow) );
382  }
383 
384  /* release variables */
385  SCIP_CALL( SCIPreleaseVar(scip, &(*consdata)->var) );
386  SCIP_CALL( SCIPreleaseVar(scip, &(*consdata)->vbdvar) );
387 
388  SCIPfreeBlockMemory(scip, consdata);
389 
390  return SCIP_OKAY;
391 }
392 
393 /** creates LP row corresponding to variable bound constraint */
394 static
396  SCIP* scip, /**< SCIP data structure */
397  SCIP_CONS* cons /**< variable bound constraint */
398  )
399 {
400  SCIP_CONSDATA* consdata;
401 
402  consdata = SCIPconsGetData(cons);
403  assert(consdata != NULL);
404  assert(consdata->row == NULL);
405 
406  SCIP_CALL( SCIPcreateEmptyRowCons(scip, &consdata->row, cons, SCIPconsGetName(cons), consdata->lhs, consdata->rhs,
408  SCIP_CALL( SCIPaddVarToRow(scip, consdata->row, consdata->var, 1.0) );
409  SCIP_CALL( SCIPaddVarToRow(scip, consdata->row, consdata->vbdvar, consdata->vbdcoef) );
410 
411  return SCIP_OKAY;
412 }
413 
414 /** adds linear relaxation of variable bound constraint to the LP */
415 static
417  SCIP* scip, /**< SCIP data structure */
418  SCIP_CONS* cons, /**< variable bound constraint */
419  SCIP_Bool* infeasible /**< pointer to store whether infeasibility was detected */
420  )
421 {
422  SCIP_CONSHDLR* conshdlr;
423  SCIP_CONSHDLRDATA* conshdlrdata;
424  SCIP_CONSDATA* consdata;
425 
426  consdata = SCIPconsGetData(cons);
427  assert(consdata != NULL);
428 
429  /* find the variable bound constraint handler */
430  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
431  if( conshdlr == NULL )
432  {
433  SCIPerrorMessage("variable bound constraint handler not found\n");
434  return SCIP_PLUGINNOTFOUND;
435  }
436 
437  conshdlrdata = SCIPconshdlrGetData(conshdlr);
438  assert(conshdlrdata != NULL);
439 
440  assert(SCIPvarGetType(consdata->vbdvar) != SCIP_VARTYPE_CONTINUOUS);
441 
442  /* check whether the coefficient is too large to put the row into the LP */
443  if( SCIPisGT(scip, REALABS(consdata->vbdcoef), conshdlrdata->maxlpcoef) )
444  return SCIP_OKAY;
445 
446  if( consdata->row == NULL )
447  {
448  SCIP_CALL( createRelaxation(scip, cons) );
449  }
450  assert(consdata->row != NULL);
451 
452  if( !SCIProwIsInLP(consdata->row) )
453  {
454  SCIPdebugMsg(scip, "adding relaxation of variable bound constraint <%s>: ", SCIPconsGetName(cons));
455  SCIPdebug( SCIP_CALL( SCIPprintRow(scip, consdata->row, NULL)) );
456  SCIP_CALL( SCIPaddRow(scip, consdata->row, FALSE, infeasible) );
457  }
458 
459  return SCIP_OKAY;
460 }
461 
462 /** adds varbound constraint as row to the NLP, if not added yet */
463 static
465  SCIP* scip, /**< SCIP data structure */
466  SCIP_CONS* cons /**< varbound constraint */
467  )
468 {
469  SCIP_CONSDATA* consdata;
470 
471  assert(SCIPisNLPConstructed(scip));
472 
473  /* skip deactivated, redundant, or local constraints (the NLP does not allow for local rows at the moment) */
474  if( !SCIPconsIsActive(cons) || !SCIPconsIsChecked(cons) || SCIPconsIsLocal(cons) )
475  return SCIP_OKAY;
476 
477  consdata = SCIPconsGetData(cons);
478  assert(consdata != NULL);
479 
480  if( consdata->nlrow == NULL )
481  {
482  SCIP_VAR* vars[2];
483  SCIP_Real coefs[2];
484 
485  assert(consdata->lhs <= consdata->rhs);
486 
487  vars[0] = consdata->var;
488  vars[1] = consdata->vbdvar;
489 
490  coefs[0] = 1.0;
491  coefs[1] = consdata->vbdcoef;
492 
493  SCIP_CALL( SCIPcreateNlRow(scip, &consdata->nlrow, SCIPconsGetName(cons),
494  0.0, 2, vars, coefs, NULL, consdata->lhs, consdata->rhs, SCIP_EXPRCURV_LINEAR) );
495 
496  assert(consdata->nlrow != NULL);
497  }
498 
499  if( !SCIPnlrowIsInNLP(consdata->nlrow) )
500  {
501  SCIP_CALL( SCIPaddNlRow(scip, consdata->nlrow) );
502  }
503 
504  return SCIP_OKAY;
505 }
506 
507 /** returns whether the given solution is feasible for the given variable bound constraint */
508 static
510  SCIP* scip, /**< SCIP data structure */
511  SCIP_CONS* cons, /**< variable bound constraint */
512  SCIP_SOL* sol, /**< solution to check, NULL for current solution */
513  SCIP_Bool checklprows /**< Do constraints represented by rows in the current LP have to be checked? */
514  )
515 {
516  SCIP_CONSDATA* consdata;
517  SCIP_Real absviol;
518  SCIP_Real relviol;
519 
520  consdata = SCIPconsGetData(cons);
521  assert(consdata != NULL);
522 
523  SCIPdebugMsg(scip, "checking variable bound constraint <%s> for feasibility of solution %p (lprows=%u)\n",
524  SCIPconsGetName(cons), (void*)sol, checklprows);
525 
526  if( checklprows || consdata->row == NULL || !SCIProwIsInLP(consdata->row) )
527  {
528  SCIP_Real sum;
529  SCIP_Real lhsrelviol;
530  SCIP_Real rhsrelviol;
531 
532  sum = SCIPgetSolVal(scip, sol, consdata->var) + consdata->vbdcoef * SCIPgetSolVal(scip, sol, consdata->vbdvar);
533 
534  /* calculate constraint violation and update it in solution */
535  absviol = MAX(consdata->lhs - sum, sum - consdata->rhs);
536  lhsrelviol = SCIPrelDiff(consdata->lhs, sum);
537  rhsrelviol = SCIPrelDiff(sum, consdata->rhs);
538  relviol = MAX(lhsrelviol, rhsrelviol);
539  if( sol != NULL )
540  SCIPupdateSolLPConsViolation(scip, sol, absviol, relviol);
541 
542  return (SCIPisInfinity(scip, -consdata->lhs) || SCIPisFeasGE(scip, sum, consdata->lhs))
543  && (SCIPisInfinity(scip, consdata->rhs) || SCIPisFeasLE(scip, sum, consdata->rhs));
544  }
545  else
546  return TRUE;
547 }
548 
549 
550 /** resolves a propagation on the given variable by supplying the variables needed for applying the corresponding
551  * propagation rule (see propagateCons()):
552  * (1) left hand side and bounds on y -> lower bound on x
553  * (2) left hand side and upper bound on x -> bound on y
554  * (3) right hand side and bounds on y -> upper bound on x
555  * (4) right hand side and lower bound on x -> bound on y
556  */
557 static
559  SCIP* scip, /**< SCIP data structure */
560  SCIP_CONS* cons, /**< constraint that inferred the bound change */
561  SCIP_VAR* infervar, /**< variable that was deduced */
562  PROPRULE proprule, /**< propagation rule that deduced the bound change */
563  SCIP_BOUNDTYPE boundtype, /**< the type of the changed bound (lower or upper bound) */
564  SCIP_BDCHGIDX* bdchgidx, /**< bound change index (time stamp of bound change), or NULL for current time */
565  SCIP_Real inferbd, /**< inference bound which needs to be explained */
566  SCIP_Bool usebdwidening /**< should bound widening be used to in conflict analysis? */
567  )
568 {
569  SCIP_CONSDATA* consdata;
570  SCIP_VAR* vbdvar;
571  SCIP_VAR* var;
572  SCIP_Real vbdcoef;
573 
574  consdata = SCIPconsGetData(cons);
575  assert(consdata != NULL);
576  assert(!SCIPisZero(scip, consdata->vbdcoef));
577 
578  var = consdata->var;
579  assert(var != NULL);
580 
581  vbdvar = consdata->vbdvar;
582  assert(vbdvar != NULL);
583 
584  vbdcoef = consdata->vbdcoef;
585  assert(!SCIPisZero(scip, vbdcoef));
586 
587  switch( proprule )
588  {
589  case PROPRULE_1:
590  /* lhs <= x + c*y: left hand side and bounds on y -> lower bound on x */
591  assert(infervar == var);
592  assert(boundtype == SCIP_BOUNDTYPE_LOWER);
593  assert(!SCIPisInfinity(scip, -consdata->lhs));
594 
595  if( usebdwidening )
596  {
597  SCIP_Real QUAD(relaxedbd);
598 
599  /* For integer variables, we can reduce the inferbound by 1 - z * eps, because this will be adjusted
600  * to the bound we need; however, we need to choose z large enough to prevent numerical troubles due to
601  * too small and too large vbdcoef values.
602  * If inferbound has a large value, adding z*eps might be lost due to fixed precision floating point
603  * arithmetics, so we explicitly check this here.
604  */
605  if( SCIPvarIsIntegral(var) && inferbd < SCIPgetHugeValue(scip) * SCIPfeastol(scip)
606  && REALABS(consdata->lhs) < SCIPgetHugeValue(scip) * SCIPfeastol(scip) )
607  {
608  SCIP_Real QUAD(tmp);
609 
610  QUAD_ASSIGN(tmp, 2.0);
611  SCIPquadprecProdQD(tmp, tmp, SCIPfeastol(scip));
612 
613  SCIPquadprecSumDD(relaxedbd, inferbd, -1.0);
614 
615  SCIPquadprecSumQQ(relaxedbd, relaxedbd, tmp);
616  SCIPquadprecSumQD(relaxedbd, -relaxedbd, consdata->lhs);
617 
618  SCIPquadprecDivQD(relaxedbd, relaxedbd, vbdcoef);
619  }
620  else
621  {
622  SCIPquadprecSumDD(relaxedbd, consdata->lhs, -inferbd);
623  SCIPquadprecDivQD(relaxedbd, relaxedbd, vbdcoef);
624  }
625 
626 #ifndef NDEBUG
627  {
628  /* check the computed relaxed lower/upper bound is a proper reason for the inference bound which has to be explained */
629  SCIP_Real QUAD(tmp);
630 
631  SCIPquadprecProdQD(tmp, relaxedbd, vbdcoef);
632  SCIPquadprecSumQD(tmp, -tmp, consdata->lhs);
633 
634  assert(SCIPisEQ(scip, inferbd, SCIPadjustedVarLb(scip, var, QUAD_TO_DBL(tmp))));
635  }
636 #endif
637  if( vbdcoef > 0.0 )
638  {
639  /* decrease the computed relaxed upper bound by an epsilon; this ensures that we get the actual
640  * inference bound due to the integrality condition of the variable bound variable
641  */
642  SCIPquadprecSumQD(relaxedbd, relaxedbd, -SCIPfeastol(scip));
643  SCIP_CALL( SCIPaddConflictRelaxedUb(scip, vbdvar, bdchgidx, QUAD_TO_DBL(relaxedbd)) );
644  }
645  else
646  {
647  /* increase the computed relaxed lower bound by an epsilon; this ensures that we get the actual inference
648  * bound due to the integrality condition of the variable bound variable
649  */
650  SCIPquadprecSumQD(relaxedbd, relaxedbd, SCIPfeastol(scip));
651  SCIP_CALL( SCIPaddConflictRelaxedLb(scip, vbdvar, bdchgidx, QUAD_TO_DBL(relaxedbd)) );
652  }
653  }
654  else
655  {
656  if( vbdcoef > 0.0 )
657  {
658  SCIP_CALL( SCIPaddConflictUb(scip, vbdvar, bdchgidx) );
659  }
660  else
661  {
662  SCIP_CALL( SCIPaddConflictLb(scip, vbdvar, bdchgidx) );
663  }
664  }
665 
666  break;
667 
668  case PROPRULE_2:
669  /* lhs <= x + c*y: left hand side and upper bound on x -> bound on y */
670  assert(infervar == vbdvar);
671  assert(SCIPvarGetType(vbdvar) != SCIP_VARTYPE_CONTINUOUS);
672  assert(!SCIPisInfinity(scip, -consdata->lhs));
673 
674  if( usebdwidening )
675  {
676  SCIP_Real QUAD(relaxedub);
677 
678  /* compute the relaxed upper bound of the variable which would be sufficient to reach one less (greater) than the
679  * inference bound
680  */
681  if( vbdcoef > 0.0 )
682  {
683  /* For integer variables, we can reduce the inferbound by 1-z*eps, because this will be adjusted
684  * to the bound we need; however, we need to choose z large enough to prevent numerical troubles due to
685  * too small and too large vbdcoef values.
686  * If inferbound has a large value, adding z*eps might be lost due to fixed precision floating point
687  * arithmetics, so we explicitly check this here.
688  */
689  if( SCIPvarIsIntegral(var) && inferbd < SCIPgetHugeValue(scip) * SCIPfeastol(scip)
690  && REALABS(consdata->rhs) < SCIPgetHugeValue(scip) * SCIPfeastol(scip) )
691  {
692  SCIP_Real QUAD(tmp);
693 
694  QUAD_ASSIGN(tmp, 2.0);
695  SCIPquadprecProdQD(tmp, tmp, SCIPfeastol(scip));
696 
697  SCIPquadprecSumDD(relaxedub, inferbd, -1.0);
698 
699  SCIPquadprecSumQQ(relaxedub, relaxedub, tmp);
700  SCIPquadprecProdQD(relaxedub, relaxedub, vbdcoef);
701 
702  SCIPquadprecSumQD(relaxedub, -relaxedub, consdata->lhs);
703  }
704  else
705  {
706  SCIPquadprecProdDD(relaxedub, inferbd, vbdcoef);
707  SCIPquadprecSumQD(relaxedub, -relaxedub, consdata->lhs);
708  }
709 
710 #ifndef NDEBUG
711  {
712  /* check the computed relaxed upper bound is a proper reason for the inference bound which has to be explained */
713  SCIP_Real QUAD(tmp);
714 
715  SCIPquadprecSumQD(tmp, -relaxedub, consdata->lhs);
716  SCIPquadprecDivQD(tmp, tmp, vbdcoef);
717 
718  assert(SCIPisEQ(scip, inferbd, SCIPadjustedVarLb(scip, vbdvar, QUAD_TO_DBL(tmp))));
719  }
720 #endif
721  }
722  else
723  {
724  /* For integer variables, we can reduce the inferbound by 1-z*eps, because this will be adjusted
725  * to the bound we need; however, we need to choose z large enough to prevent numerical troubles due to
726  * too small and too large vbdcoef values.
727  * If inferbound has a large value, adding z*eps might be lost due to fixed precision floating point
728  * arithmetics, so we explicitly check this here.
729  */
730  if( SCIPvarIsIntegral(var) && inferbd < SCIPgetHugeValue(scip) * SCIPfeastol(scip)
731  && REALABS(consdata->lhs) < SCIPgetHugeValue(scip) * SCIPfeastol(scip) )
732  {
733  SCIP_Real QUAD(tmp);
734 
735  QUAD_ASSIGN(tmp, 2.0);
736  SCIPquadprecProdQD(tmp, tmp, SCIPfeastol(scip));
737 
738  SCIPquadprecSumDD(relaxedub, inferbd, 1.0);
739 
740  SCIPquadprecSumQQ(relaxedub, relaxedub, -tmp);
741  SCIPquadprecProdQD(relaxedub, relaxedub, vbdcoef);
742 
743  SCIPquadprecSumQD(relaxedub, -relaxedub, consdata->lhs);
744  }
745  else
746  {
747  SCIPquadprecProdDD(relaxedub, inferbd, vbdcoef);
748  SCIPquadprecSumQD(relaxedub, -relaxedub, consdata->lhs);
749  }
750 
751 #ifndef NDEBUG
752  {
753  /* check the computed relaxed upper bound is a proper reason for the inference bound which has to be explained */
754  SCIP_Real QUAD(tmp);
755 
756  SCIPquadprecSumQD(tmp, -relaxedub, consdata->lhs);
757  SCIPquadprecDivQD(tmp, tmp, vbdcoef);
758 
759  assert(SCIPisEQ(scip, inferbd, SCIPadjustedVarUb(scip, vbdvar, QUAD_TO_DBL(tmp))));
760  }
761 #endif
762  }
763 
764  /* decrease the computed relaxed upper bound by an epsilon; this ensures that we get the actual inference bound due
765  * to the integrality condition of the variable bound variable
766  */
767  SCIPquadprecSumQD(relaxedub, relaxedub, -SCIPfeastol(scip));
768  SCIP_CALL( SCIPaddConflictRelaxedUb(scip, var, bdchgidx, QUAD_TO_DBL(relaxedub)) );
769  }
770  else
771  {
772  SCIP_CALL( SCIPaddConflictUb(scip, var, bdchgidx) );
773  }
774 
775  break;
776 
777  case PROPRULE_3:
778  /* x + c*y <= rhs: right hand side and bounds on y -> upper bound on x */
779  assert(infervar == var);
780  assert(boundtype == SCIP_BOUNDTYPE_UPPER);
781  assert(!SCIPisInfinity(scip, consdata->rhs));
782 
783  if( usebdwidening )
784  {
785  SCIP_Real QUAD(relaxedbd);
786 
787  /* For integer variables, we can reduce the inferbound by 1-z*eps, because this will be adjusted
788  * to the bound we need; however, we need to choose z large enough to prevent numerical troubles due to
789  * too small and too large vbdcoef values.
790  * If inferbound has a large value, adding z*eps might be lost due to fixed precision floating point
791  * arithmetics, so we explicitly check this here.
792  */
793  if( SCIPvarIsIntegral(var) && inferbd < SCIPgetHugeValue(scip) * SCIPfeastol(scip)
794  && REALABS(consdata->rhs) < SCIPgetHugeValue(scip) * SCIPfeastol(scip) )
795  {
796  SCIP_Real QUAD(tmp);
797 
798  QUAD_ASSIGN(tmp, 2.0);
799 
800  SCIPquadprecProdQD(tmp, tmp, SCIPfeastol(scip));
801  SCIPquadprecSumDD(relaxedbd, inferbd, 1.0);
802 
803  SCIPquadprecSumQQ(relaxedbd, relaxedbd, -tmp);
804  SCIPquadprecSumQD(relaxedbd, relaxedbd, -consdata->rhs);
805 
806  SCIPquadprecDivQD(relaxedbd, relaxedbd, -vbdcoef);
807  }
808  else
809  {
810  SCIPquadprecSumDD(relaxedbd, consdata->rhs, -inferbd);
811  SCIPquadprecDivQD(relaxedbd, relaxedbd, vbdcoef);
812  }
813 #ifndef NDEBUG
814  {
815  /* check the computed relaxed lower/upper bound is a proper reason for the inference bound which has to be explained */
816  SCIP_Real QUAD(tmp);
817 
818  SCIPquadprecProdQD(tmp, relaxedbd, -vbdcoef);
819  SCIPquadprecSumQD(tmp, tmp, consdata->rhs);
820 
821  assert(SCIPisEQ(scip, inferbd, SCIPadjustedVarUb(scip, var, QUAD_TO_DBL(tmp))));
822  }
823 #endif
824  if( vbdcoef > 0.0 )
825  {
826  /* increase the computed relaxed lower bound by an epsilon; this ensures that we get the actual inference bound due
827  * to the integrality condition of the variable bound variable
828  */
829  SCIPquadprecSumQD(relaxedbd, relaxedbd, SCIPfeastol(scip));
830  SCIP_CALL( SCIPaddConflictRelaxedLb(scip, vbdvar, bdchgidx, QUAD_TO_DBL(relaxedbd)) );
831  }
832  else
833  {
834  /* decrease the computed relaxed upper bound by an epsilon; this ensures that we get the actual inference bound due
835  * to the integrality condition of the variable bound variable
836  */
837  SCIPquadprecSumQD(relaxedbd, relaxedbd, -SCIPfeastol(scip));
838  SCIP_CALL( SCIPaddConflictRelaxedUb(scip, vbdvar, bdchgidx, QUAD_TO_DBL(relaxedbd)) );
839  }
840  }
841  else
842  {
843  if( vbdcoef > 0.0 )
844  {
845  SCIP_CALL( SCIPaddConflictLb(scip, vbdvar, bdchgidx) );
846  }
847  else
848  {
849  SCIP_CALL( SCIPaddConflictUb(scip, vbdvar, bdchgidx) );
850  }
851  }
852 
853  break;
854 
855  case PROPRULE_4:
856  /* x + c*y <= rhs: right hand side and lower bound on x -> bound on y */
857  assert(infervar == vbdvar);
858  assert(SCIPvarGetType(vbdvar) != SCIP_VARTYPE_CONTINUOUS);
859  assert(!SCIPisInfinity(scip, consdata->rhs));
860 
861  if( usebdwidening )
862  {
863  SCIP_Real QUAD(relaxedlb);
864 
865  /* compute the relaxed lower bound of the variable which would be sufficient to reach one greater (less) than the
866  * inference bound
867  */
868  if( vbdcoef > 0.0 )
869  {
870  /* For integer variables, we can reduce the inferbound by 1-z*eps, because this will be adjusted
871  * to the bound we need; however, we need to choose z large enough to prevent numerical troubles due to
872  * too small and too large vbdcoef values.
873  * If inferbound has a large value, adding z*eps might be lost due to fixed precision floating point
874  * arithmetics, so we explicitly check this here.
875  */
876  if( SCIPvarIsIntegral(var) && inferbd < SCIPgetHugeValue(scip) * SCIPfeastol(scip)
877  && REALABS(consdata->rhs) < SCIPgetHugeValue(scip) * SCIPfeastol(scip) )
878  {
879  SCIP_Real QUAD(tmp);
880 
881  QUAD_ASSIGN(tmp, 2.0);
882  SCIPquadprecProdQD(tmp, tmp, SCIPfeastol(scip));
883 
884  SCIPquadprecSumDD(relaxedlb, inferbd, 1.0);
885  SCIPquadprecSumQQ(relaxedlb, relaxedlb, -tmp);
886 
887  SCIPquadprecProdQD(relaxedlb, relaxedlb, vbdcoef);
888 
889  SCIPquadprecSumQD(relaxedlb, -relaxedlb, consdata->rhs);
890  }
891  else
892  {
893  SCIPquadprecProdDD(relaxedlb, inferbd, vbdcoef);
894  SCIPquadprecSumQD(relaxedlb, -relaxedlb, consdata->rhs);
895  }
896 #ifndef NDEBUG
897  {
898  /* check the computed relaxed lower bound is a proper reason for the inference bound which has to be explained */
899 
900  SCIP_Real QUAD(tmp);
901 
902  QUAD_ASSIGN(tmp, consdata->rhs);
903  SCIPquadprecSumQQ(tmp, tmp, -relaxedlb);
904  SCIPquadprecDivQD(tmp, tmp, vbdcoef);
905 
906  assert(SCIPisEQ(scip, inferbd, SCIPadjustedVarUb(scip, vbdvar, QUAD_TO_DBL(tmp))));
907  }
908 #endif
909  }
910  else
911  {
912  /* For integer variables, we can reduce the inferbound by 1-z*eps, because this will be adjusted
913  * to the bound we need; however, we need to choose z large enough to prevent numerical troubles due to
914  * too small and too large vbdcoef values.
915  * If inferbound has a large value, adding z*eps might be lost due to fixed precision floating point
916  * arithmetics, so we explicitly check this here.
917  */
918  if( SCIPvarIsIntegral(var) && inferbd < SCIPgetHugeValue(scip) * SCIPfeastol(scip)
919  && REALABS(consdata->lhs) < SCIPgetHugeValue(scip) * SCIPfeastol(scip) )
920  {
921  SCIP_Real QUAD(tmp);
922 
923  QUAD_ASSIGN(tmp, 2.0);
924  SCIPquadprecProdQD(tmp, tmp, SCIPfeastol(scip));
925 
926  SCIPquadprecSumDD(relaxedlb, inferbd, -1.0);
927  SCIPquadprecSumQQ(relaxedlb, relaxedlb, tmp);
928 
929  SCIPquadprecProdQD(relaxedlb, relaxedlb, vbdcoef);
930 
931  SCIPquadprecSumQD(relaxedlb, -relaxedlb, consdata->rhs);
932  }
933  else
934  {
935  SCIPquadprecProdDD(relaxedlb, inferbd, vbdcoef);
936  SCIPquadprecSumQD(relaxedlb, -relaxedlb, consdata->rhs);
937  }
938 
939 #ifndef NDEBUG
940  {
941  /* check the computed relaxed lower bound is a proper reason for the inference bound which has to be explained */
942 
943  SCIP_Real QUAD(tmp);
944 
945  QUAD_ASSIGN(tmp, consdata->rhs);
946  SCIPquadprecSumQQ(tmp, tmp, -relaxedlb);
947  SCIPquadprecDivQD(tmp, tmp, vbdcoef);
948 
949  assert(SCIPisEQ(scip, inferbd, SCIPadjustedVarLb(scip, vbdvar, QUAD_TO_DBL(tmp))));
950  }
951 #endif
952  }
953 
954  /* increase the computed relaxed lower bound by an epsilon; this ensures that we get the actual inference bound due
955  * to the integrality condition of the variable bound variable
956  */
957  SCIPquadprecSumQD(relaxedlb, relaxedlb, SCIPfeastol(scip));
958  SCIP_CALL( SCIPaddConflictRelaxedLb(scip, var, bdchgidx, QUAD_TO_DBL(relaxedlb)) );
959  }
960  else
961  {
962  SCIP_CALL( SCIPaddConflictLb(scip, var, bdchgidx) );
963  }
964 
965  break;
966 
967  default:
968  SCIPerrorMessage("invalid inference information %d in variable bound constraint <%s>\n", proprule, SCIPconsGetName(cons));
969  return SCIP_INVALIDDATA;
970  }
971 
972  return SCIP_OKAY;
973 }
974 
975 /** analyze infeasibility */
976 static
978  SCIP* scip, /**< SCIP data structure */
979  SCIP_CONS* cons, /**< variable bound constraint */
980  SCIP_VAR* infervar, /**< variable that was deduced */
981  SCIP_Real inferbd, /**< bound which led to infeasibility */
982  PROPRULE proprule, /**< propagation rule that deduced the bound change */
983  SCIP_BOUNDTYPE boundtype, /**< the type of the changed bound (lower or upper bound) */
984  SCIP_Bool usebdwidening /**< should bound widening be used to in conflict analysis? */
985  )
986 {
987  /* conflict analysis can only be applied in solving stage and if it is applicable */
989  return SCIP_OKAY;
990 
991  /* initialize conflict analysis, and add all variables of infeasible constraint to conflict candidate queue */
993 
994  /* add the bound which got violated */
995  if( boundtype == SCIP_BOUNDTYPE_LOWER )
996  {
997  if( usebdwidening )
998  {
999  SCIP_Real relaxedub;
1000 
1001  /* adjust lower bound */
1002  inferbd = SCIPadjustedVarLb(scip, infervar, inferbd);
1003 
1004  /* compute a relaxed upper bound which would be sufficient to be still infeasible */
1005  if( SCIPvarIsIntegral(infervar) )
1006  relaxedub = inferbd - 1.0;
1007  else
1008  {
1009  SCIP_CONSDATA* consdata;
1010  SCIP_Real abscoef;
1011 
1012  consdata = SCIPconsGetData(cons);
1013  assert(consdata != NULL);
1014 
1015  /* vbdvar can never be of non-integral type */
1016  assert(infervar == consdata->var);
1017 
1018  abscoef = REALABS(consdata->vbdcoef);
1019 
1020  /* due to resolving a the propagation and dividing by the vbdcoef we need to make sure the the relaxed bound
1021  * is big enough, therefore we multiply here with the vbdcoef
1022  *
1023  * @note it does not matter if we deceed the current local upper bound, because SCIPaddConflictRelaxedUb()
1024  * is correcting the bound afterwards
1025  */
1026  /* coverity[copy_paste_error] */
1027  relaxedub = inferbd - 2*SCIPfeastol(scip) * MAX(1, abscoef);
1028  }
1029 
1030  /* try to relax inference variable upper bound such that the infeasibility is still given */
1031  SCIP_CALL( SCIPaddConflictRelaxedUb(scip, infervar, NULL, relaxedub) );
1032 
1033  /* collect the upper bound which is reported to the conflict analysis */
1034  inferbd = SCIPgetConflictVarUb(scip, infervar);
1035 
1036  /* adjust inference bound with respect to the upper bound reported to the conflict analysis */
1037  if( SCIPvarIsIntegral(infervar) )
1038  inferbd = inferbd + 1.0;
1039  else
1040  {
1041  SCIP_CONSDATA* consdata;
1042  SCIP_Real abscoef;
1043 
1044  consdata = SCIPconsGetData(cons);
1045  assert(consdata != NULL);
1046 
1047  /* vbdvar can never be of non-integral type */
1048  assert(infervar == consdata->var);
1049 
1050  abscoef = REALABS(consdata->vbdcoef);
1051 
1052  /* due to resolving a the propagation and dividing by the vbdcoef we need to make sure the the relaxed bound
1053  * is big enough, therefore we multiply here with the vbdcoef
1054  */
1055  inferbd = inferbd + 2*SCIPfeastol(scip) * MAX(1, abscoef);
1056  }
1057  }
1058  else
1059  {
1060  SCIP_CALL( SCIPaddConflictUb(scip, infervar, NULL) );
1061  }
1062  }
1063  else
1064  {
1065  if( usebdwidening )
1066  {
1067  SCIP_Real relaxedlb;
1068 
1069  assert(boundtype == SCIP_BOUNDTYPE_UPPER);
1070 
1071  /* adjust upper bound */
1072  inferbd = SCIPadjustedVarUb(scip, infervar, inferbd);
1073 
1074  /* compute a relaxed lower bound which would be sufficient to be still infeasible */
1075  if( SCIPvarIsIntegral(infervar) )
1076  relaxedlb = inferbd + 1.0;
1077  else
1078  {
1079  SCIP_CONSDATA* consdata;
1080  SCIP_Real abscoef;
1081 
1082  consdata = SCIPconsGetData(cons);
1083  assert(consdata != NULL);
1084 
1085  /* vbdvar can never be of non-integral type */
1086  assert(infervar == consdata->var);
1087 
1088  abscoef = REALABS(consdata->vbdcoef);
1089 
1090  /* due to resolving a the propagation and dividing by the vbdcoef we need to make sure the the relaxed bound
1091  * is big enough, therefore we multiply here with the vbdcoef
1092  *
1093  * @note it does not matter if we exceed the current local lower bound, because SCIPaddConflictRelaxedLb()
1094  * is correcting the bound afterwards
1095  */
1096  /* coverity[copy_paste_error] */
1097  relaxedlb = inferbd + 2*SCIPfeastol(scip) * MAX(1, abscoef);
1098  }
1099 
1100  /* try to relax inference variable upper bound such that the infeasibility is still given */
1101  SCIP_CALL( SCIPaddConflictRelaxedLb(scip, infervar, NULL, relaxedlb) );
1102 
1103  /* collect the lower bound which is reported to the conflict analysis */
1104  inferbd = SCIPgetConflictVarLb(scip, infervar);
1105 
1106  /* adjust inference bound with respect to the lower bound reported to the conflict analysis */
1107  if( SCIPvarIsIntegral(infervar) )
1108  inferbd = inferbd - 1.0;
1109  else
1110  {
1111  SCIP_CONSDATA* consdata;
1112  SCIP_Real abscoef;
1113 
1114  consdata = SCIPconsGetData(cons);
1115  assert(consdata != NULL);
1116 
1117  /* vbdvar can never be of non-integral type */
1118  assert(infervar == consdata->var);
1119 
1120  abscoef = REALABS(consdata->vbdcoef);
1121 
1122  /* due to resolving a the propagation and dividing by the vbdcoef we need to make sure the the relaxed bound
1123  * is big enough, therefore we multiply here with the vbdcoef
1124  */
1125  inferbd = inferbd - 2*SCIPfeastol(scip) * MAX(1, abscoef);
1126  }
1127  }
1128  else
1129  {
1130  SCIP_CALL( SCIPaddConflictLb(scip, infervar, NULL) );
1131  }
1132  }
1133 
1134  /* add the reason for the violated of the bound */
1135  SCIP_CALL( resolvePropagation(scip, cons, infervar, proprule, boundtype, NULL, inferbd, usebdwidening) );
1136 
1137  /* analyze the conflict */
1138  SCIP_CALL( SCIPanalyzeConflictCons(scip, cons, NULL) );
1139 
1140  return SCIP_OKAY;
1141 }
1142 
1143 /** separates the given variable bound constraint */
1144 static
1146  SCIP* scip, /**< SCIP data structure */
1147  SCIP_CONS* cons, /**< variable bound constraint */
1148  SCIP_Bool usebdwidening, /**< should bound widening be used to in conflict analysis? */
1149  SCIP_SOL* sol, /**< primal CIP solution, NULL for current LP solution */
1150  SCIP_RESULT* result /**< pointer to store the result of the separation call */
1151  )
1152 {
1153  SCIP_CONSHDLR* conshdlr;
1154  SCIP_CONSDATA* consdata;
1155  SCIP_VAR* vbdvar;
1156  SCIP_VAR* var;
1157  SCIP_Real vbdcoef;
1158  SCIP_Real feasibility;
1159 
1160  assert(cons != NULL);
1161  assert(result != NULL);
1162 
1163  consdata = SCIPconsGetData(cons);
1164  assert(consdata != NULL);
1165 
1166  /* find the variable bound constraint handler */
1167  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1168  if( conshdlr == NULL )
1169  {
1170  SCIPerrorMessage("variable bound constraint handler not found\n");
1171  return SCIP_PLUGINNOTFOUND;
1172  }
1173 
1174  SCIPdebugMsg(scip, "separating variable bound constraint <%s>\n", SCIPconsGetName(cons));
1175 
1176  var = consdata->var;
1177  vbdvar = consdata->vbdvar;
1178  vbdcoef = consdata->vbdcoef;
1179  assert(SCIPvarGetType(vbdvar) != SCIP_VARTYPE_CONTINUOUS);
1180 
1181  /* if x is not multiaggregated and y is fixed, propagate bounds on x */
1182  if( SCIPvarGetStatus(var) != SCIP_VARSTATUS_MULTAGGR && SCIPvarGetLbLocal(vbdvar) + 0.5 > SCIPvarGetUbLocal(vbdvar) )
1183  {
1184  assert(SCIPisFeasEQ(scip, SCIPvarGetLbLocal(vbdvar), SCIPvarGetUbLocal(vbdvar)));
1185 
1186  if( !SCIPisInfinity(scip, -consdata->lhs) )
1187  {
1188  SCIP_Real newlb;
1189  SCIP_Real QUAD(tmp);
1190  SCIP_Bool cutoff;
1191  SCIP_Bool tightened;
1192 
1193  SCIPquadprecProdDD(tmp, vbdcoef, SCIPvarGetLbLocal(vbdvar)); /*lint !e666*/
1194  SCIPquadprecSumQD(tmp, -tmp, consdata->lhs);
1195 
1196  newlb = QUAD_TO_DBL(tmp);
1197 
1198  SCIP_CALL( SCIPinferVarLbCons(scip, var, newlb, cons, (int)PROPRULE_1, TRUE,
1199  &cutoff, &tightened) );
1200 
1201  if( cutoff )
1202  {
1203  assert(SCIPisGT(scip, newlb, SCIPvarGetUbLocal(var)));
1204 
1205  /* analyze infeasibility */
1206  SCIP_CALL( analyzeConflict(scip, cons, var, newlb, PROPRULE_1, SCIP_BOUNDTYPE_LOWER, usebdwidening) );
1207  *result = SCIP_CUTOFF;
1208 
1209  return SCIP_OKAY;
1210  }
1211  else if( tightened )
1212  {
1213  *result = SCIP_REDUCEDDOM;
1214  }
1215  }
1216 
1217  if( !SCIPisInfinity(scip, consdata->rhs) )
1218  {
1219  SCIP_Real newub;
1220  SCIP_Real QUAD(tmp);
1221  SCIP_Bool cutoff;
1222  SCIP_Bool tightened;
1223 
1224  SCIPquadprecProdDD(tmp, vbdcoef, SCIPvarGetLbLocal(vbdvar)); /*lint !e666*/
1225  SCIPquadprecSumQD(tmp, -tmp, consdata->rhs);
1226 
1227  newub = QUAD_TO_DBL(tmp);
1228 
1229  SCIP_CALL( SCIPinferVarUbCons(scip, var, newub, cons, (int)PROPRULE_3, TRUE,
1230  &cutoff, &tightened) );
1231 
1232  if( cutoff )
1233  {
1234  assert(SCIPisLT(scip, newub, SCIPvarGetLbLocal(var)));
1235 
1236  /* analyze infeasibility */
1237  SCIP_CALL( analyzeConflict(scip, cons, var, newub, PROPRULE_3, SCIP_BOUNDTYPE_UPPER, usebdwidening) );
1238  *result = SCIP_CUTOFF;
1239 
1240  return SCIP_OKAY;
1241  }
1242  else if( tightened )
1243  {
1244  *result = SCIP_REDUCEDDOM;
1245  }
1246  }
1247  }
1248 
1249  /* if we already changed a bound or the coefficient is too large to put the row into the LP, stop here */
1250  if( *result == SCIP_REDUCEDDOM )
1251  return SCIP_OKAY;
1252 
1253  /* check constraint for feasibility and create row if constraint is violated */
1254  if( !checkCons(scip, cons, sol, (sol != NULL)) )
1255  {
1256  /* create LP relaxation if not yet existing */
1257  if( consdata->row == NULL )
1258  {
1259  SCIP_CALL( createRelaxation(scip, cons) );
1260  }
1261  assert(consdata->row != NULL);
1262 
1263  /* check non-LP rows for feasibility and add them as cut, if violated */
1264  if( !SCIProwIsInLP(consdata->row) )
1265  {
1266  feasibility = SCIPgetRowSolFeasibility(scip, consdata->row, sol);
1267  if( SCIPisFeasNegative(scip, feasibility) )
1268  {
1269  SCIP_Bool infeasible;
1270 
1271  SCIP_CALL( SCIPaddRow(scip, consdata->row, FALSE, &infeasible) );
1272  if ( infeasible )
1273  *result = SCIP_CUTOFF;
1274  else
1275  *result = SCIP_SEPARATED;
1276  }
1277  }
1278  }
1279 
1280  return SCIP_OKAY;
1281 }
1282 
1283 /** sets left hand side of varbound constraint */
1284 static
1286  SCIP* scip, /**< SCIP data structure */
1287  SCIP_CONS* cons, /**< linear constraint */
1288  SCIP_Real lhs /**< new left hand side */
1289  )
1290 {
1291  SCIP_CONSDATA* consdata;
1292 
1293  assert(scip != NULL);
1294  assert(cons != NULL);
1295  assert(!SCIPisInfinity(scip, lhs));
1296 
1297  /* adjust value to not be smaller than -inf */
1298  if( SCIPisInfinity(scip, -lhs) )
1299  lhs = -SCIPinfinity(scip);
1300 
1301  consdata = SCIPconsGetData(cons);
1302  assert(consdata != NULL);
1303  assert(consdata->var != NULL && consdata->vbdvar != NULL);
1304  assert(!SCIPisInfinity(scip, consdata->lhs));
1305 
1306  /* check whether the side is not changed */
1307  if( SCIPisEQ(scip, consdata->lhs, lhs) )
1308  return SCIP_OKAY;
1309 
1310  assert(consdata->row == NULL);
1311 
1312  /* ensure that rhs >= lhs is satisfied without numerical tolerance */
1313  if( SCIPisEQ(scip, lhs, consdata->rhs) )
1314  consdata->rhs = lhs;
1315 
1316  /* update the rounding locks of variables */
1317 
1318  /* the left hand side switched from -infinity to a non-infinite value -> install rounding locks */
1319  if( SCIPisInfinity(scip, -consdata->lhs) && !SCIPisInfinity(scip, -lhs) )
1320  {
1321  SCIP_CALL( SCIPlockVarCons(scip, consdata->var, cons, TRUE, FALSE) );
1322 
1323  if( SCIPisPositive(scip, consdata->vbdcoef) )
1324  {
1325  SCIP_CALL( SCIPlockVarCons(scip, consdata->vbdvar, cons, TRUE, FALSE) );
1326  }
1327  else
1328  {
1329  SCIP_CALL( SCIPlockVarCons(scip, consdata->vbdvar, cons, FALSE, TRUE) );
1330  }
1331  }
1332  /* the left hand side switched from a non-infinite value to -infinity -> remove rounding locks */
1333  else if( !SCIPisInfinity(scip, -consdata->lhs) && SCIPisInfinity(scip, -lhs) )
1334  {
1335  SCIP_CALL( SCIPunlockVarCons(scip, consdata->var, cons, TRUE, FALSE) );
1336 
1337  if( SCIPisPositive(scip, consdata->vbdcoef) )
1338  {
1339  SCIP_CALL( SCIPunlockVarCons(scip, consdata->vbdvar, cons, TRUE, FALSE) );
1340  }
1341  else
1342  {
1343  SCIP_CALL( SCIPunlockVarCons(scip, consdata->vbdvar, cons, FALSE, TRUE) );
1344  }
1345  }
1346 
1347  /* if left hand side got tighter, we want to do additional presolving on this constraint */
1348  if( SCIPisLT(scip, consdata->lhs, lhs) )
1349  {
1350  consdata->varboundsadded = FALSE;
1351  consdata->tightened = FALSE;
1352 
1353  SCIP_CALL( SCIPmarkConsPropagate(scip, cons) );
1354  }
1355 
1356  consdata->presolved = FALSE;
1357  consdata->lhs = lhs;
1358  consdata->changed = TRUE;
1359 
1360  return SCIP_OKAY;
1361 }
1362 
1363 /** sets right hand side of varbound constraint */
1364 static
1366  SCIP* scip, /**< SCIP data structure */
1367  SCIP_CONS* cons, /**< linear constraint */
1368  SCIP_Real rhs /**< new right hand side */
1369  )
1370 {
1371  SCIP_CONSDATA* consdata;
1372 
1373  assert(scip != NULL);
1374  assert(cons != NULL);
1375  assert(!SCIPisInfinity(scip, -rhs));
1376 
1377  /* adjust value to not be larger than inf */
1378  if( SCIPisInfinity(scip, rhs) )
1379  rhs = SCIPinfinity(scip);
1380 
1381  consdata = SCIPconsGetData(cons);
1382  assert(consdata != NULL);
1383  assert(consdata->var != NULL && consdata->vbdvar != NULL);
1384  assert(!SCIPisInfinity(scip, -consdata->rhs));
1385 
1386  /* check whether the side is not changed */
1387  if( SCIPisEQ(scip, consdata->rhs, rhs) )
1388  return SCIP_OKAY;
1389 
1390  assert(consdata->row == NULL);
1391 
1392  /* ensure that rhs >= lhs is satisfied without numerical tolerance */
1393  if( SCIPisEQ(scip, rhs, consdata->lhs) )
1394  consdata->lhs = rhs;
1395 
1396  /* update the locks of variables */
1397  assert(SCIPconsIsTransformed(cons));
1398 
1399  /* the right hand side switched from infinity to a non-infinite value -> install locks */
1400  if( SCIPisInfinity(scip, consdata->rhs) && !SCIPisInfinity(scip, rhs) )
1401  {
1402  SCIP_CALL( SCIPlockVarCons(scip, consdata->var, cons, FALSE, TRUE) );
1403 
1404  if( SCIPisPositive(scip, consdata->vbdcoef) )
1405  {
1406  SCIP_CALL( SCIPlockVarCons(scip, consdata->vbdvar, cons, FALSE, TRUE) );
1407  }
1408  else
1409  {
1410  SCIP_CALL( SCIPlockVarCons(scip, consdata->vbdvar, cons, TRUE, FALSE) );
1411  }
1412  }
1413  /* the right hand side switched from a non-infinite value to infinity -> remove locks */
1414  else if( !SCIPisInfinity(scip, consdata->rhs) && SCIPisInfinity(scip, rhs) )
1415  {
1416  SCIP_CALL( SCIPunlockVarCons(scip, consdata->var, cons, FALSE, TRUE) );
1417 
1418  if( SCIPisPositive(scip, consdata->vbdcoef) )
1419  {
1420  SCIP_CALL( SCIPunlockVarCons(scip, consdata->vbdvar, cons, FALSE, TRUE) );
1421  }
1422  else
1423  {
1424  SCIP_CALL( SCIPunlockVarCons(scip, consdata->vbdvar, cons, TRUE, FALSE) );
1425  }
1426  }
1427 
1428  /* if right hand side got tighter, we want to do additional presolving on this constraint */
1429  if( SCIPisGT(scip, consdata->rhs, rhs) )
1430  {
1431  consdata->varboundsadded = FALSE;
1432  consdata->tightened = FALSE;
1433 
1434  SCIP_CALL( SCIPmarkConsPropagate(scip, cons) );
1435  }
1436 
1437  consdata->presolved = FALSE;
1438  consdata->rhs = rhs;
1439  consdata->changed = TRUE;
1440 
1441  return SCIP_OKAY;
1442 }
1443 
1444 /** propagation method for variable bound constraint */
1445 static
1447  SCIP* scip, /**< SCIP data structure */
1448  SCIP_CONS* cons, /**< variable bound constraint */
1449  SCIP_Bool usebdwidening, /**< should bound widening be used to in conflict analysis? */
1450  SCIP_Bool* cutoff, /**< pointer to store whether the node can be cut off */
1451  int* nchgbds, /**< pointer to count number of bound changes */
1452  int* nchgsides, /**< pointer to count number of side changes */
1453  int* ndelconss /**< pointer to count number of deleted constraints, or NULL */
1454  )
1455 {
1456  SCIP_CONSDATA* consdata;
1457  SCIP_Real xlb;
1458  SCIP_Real xub;
1459  SCIP_Real ylb;
1460  SCIP_Real yub;
1461  SCIP_Real newlb;
1462  SCIP_Real newub;
1463  SCIP_Bool tightened;
1464  SCIP_Bool tightenedround;
1465 
1466  assert(cutoff != NULL);
1467  assert(nchgbds != NULL);
1468 
1469  consdata = SCIPconsGetData(cons);
1470  assert(consdata != NULL);
1471 
1472  SCIPdebugMsg(scip, "propagating variable bound constraint <%s>: %.15g <= <%s>[%.9g, %.9g] + %.15g<%s>[%.9g, %.9g] <= %.15g\n",
1473  SCIPconsGetName(cons), consdata->lhs, SCIPvarGetName(consdata->var), SCIPvarGetLbLocal(consdata->var),
1474  SCIPvarGetUbLocal(consdata->var), consdata->vbdcoef, SCIPvarGetName(consdata->vbdvar),
1475  SCIPvarGetLbLocal(consdata->vbdvar), SCIPvarGetUbLocal(consdata->vbdvar), consdata->rhs);
1476 
1477  *cutoff = FALSE;
1478 
1479  /* increase age of constraint; age is reset to zero, if a conflict or a propagation was found */
1480  if( !SCIPinRepropagation(scip) )
1481  {
1482  SCIP_CALL( SCIPincConsAge(scip, cons) );
1483  }
1484 
1485  /* get current bounds of variables */
1486  xlb = SCIPvarGetLbLocal(consdata->var);
1487  xub = SCIPvarGetUbLocal(consdata->var);
1488  ylb = SCIPvarGetLbLocal(consdata->vbdvar);
1489  yub = SCIPvarGetUbLocal(consdata->vbdvar);
1490 
1491  /* it can happen that constraint is of form lhs <= x <= rhs */
1492  if( SCIPisZero(scip, consdata->vbdcoef) && SCIPisEQ(scip, consdata->lhs, consdata->rhs) )
1493  {
1494  SCIP_Bool infeasible;
1495  SCIP_Bool fixed;
1496 
1497  SCIP_CALL( SCIPfixVar(scip, consdata->var, consdata->lhs, &infeasible, &fixed) );
1498 
1499  if( infeasible )
1500  {
1501  SCIPdebugMsg(scip, "> constraint <%s> is infeasible.\n", SCIPconsGetName(cons));
1502  *cutoff = TRUE;
1503  return SCIP_OKAY;
1504  }
1505  }
1506 
1507  /* tighten bounds of variables as long as possible */
1508  do
1509  {
1510  tightenedround = FALSE;
1511 
1512  /* propagate left hand side inequality: lhs <= x + c*y */
1513  if( !SCIPisInfinity(scip, -consdata->lhs) )
1514  {
1515  assert(!(*cutoff));
1516 
1517  /* propagate bounds on x:
1518  * (1) left hand side and bounds on y -> lower bound on x
1519  */
1520  if( SCIPvarGetStatus(consdata->var) != SCIP_VARSTATUS_MULTAGGR ) /* cannot change bounds of multaggr vars */
1521  {
1522  if( consdata->vbdcoef > 0.0 )
1523  {
1524  if( !SCIPisInfinity(scip, yub) )
1525  {
1526  SCIP_Real QUAD(tmp);
1527 
1528  SCIPquadprecProdDD(tmp, consdata->vbdcoef, yub);
1529  SCIPquadprecSumQD(tmp, -tmp, consdata->lhs);
1530 
1531  newlb = SCIPadjustedVarLb(scip, consdata->var, QUAD_TO_DBL(tmp));
1532  }
1533  else
1534  {
1535  newlb = -SCIPinfinity(scip);
1536  }
1537  }
1538  else
1539  {
1540  if( !SCIPisInfinity(scip, -ylb) )
1541  {
1542  SCIP_Real QUAD(tmp);
1543 
1544  SCIPquadprecProdDD(tmp, consdata->vbdcoef, ylb);
1545  SCIPquadprecSumQD(tmp, -tmp, consdata->lhs);
1546 
1547  newlb = SCIPadjustedVarLb(scip, consdata->var, QUAD_TO_DBL(tmp));
1548  }
1549  else
1550  {
1551  newlb = -SCIPinfinity(scip);
1552  }
1553  }
1554 
1555  SCIP_CALL( SCIPinferVarLbCons(scip, consdata->var, newlb, cons, (int)PROPRULE_1, yub < ylb + 0.5, cutoff, &tightened) );
1556 
1557  if( *cutoff )
1558  {
1559  SCIPdebugMsg(scip, "cutoff while tightening <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->var), xlb, xub, newlb, xub);
1560  assert( SCIPisInfinity(scip, newlb) || SCIPisGT(scip, newlb, SCIPvarGetUbLocal(consdata->var)) );
1561 
1562  SCIP_CALL( SCIPresetConsAge(scip, cons) );
1563 
1564  /* analyze infeasibility */
1565  SCIP_CALL( analyzeConflict(scip, cons, consdata->var, newlb, PROPRULE_1, SCIP_BOUNDTYPE_LOWER, usebdwidening) );
1566  break;
1567  }
1568 
1569  if( tightened )
1570  {
1571  SCIPdebugMsg(scip, " -> tighten <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->var), xlb, xub, newlb, xub);
1572  tightenedround = TRUE;
1573  (*nchgbds)++;
1574  SCIP_CALL( SCIPresetConsAge(scip, cons) );
1575  }
1576  xlb = SCIPvarGetLbLocal(consdata->var);
1577  }
1578 
1579  assert(!*cutoff);
1580 
1581  /* propagate bounds on y:
1582  * (2) left hand side and upper bound on x -> bound on y
1583  */
1584  if( SCIPvarGetStatus(consdata->vbdvar) != SCIP_VARSTATUS_MULTAGGR && !SCIPisInfinity(scip, xub) ) /* cannot change bounds of multaggr vars */
1585  {
1586  if( consdata->vbdcoef > 0.0 )
1587  {
1588  SCIP_Real QUAD(tmp);
1589 
1590  SCIPquadprecSumDD(tmp, consdata->lhs, -xub);
1591  SCIPquadprecDivQD(tmp, tmp, consdata->vbdcoef);
1592 
1593  newlb = SCIPadjustedVarLb(scip, consdata->vbdvar, QUAD_TO_DBL(tmp));
1594  if( newlb > ylb + 0.5 )
1595  {
1596  SCIP_CALL( SCIPinferVarLbCons(scip, consdata->vbdvar, newlb, cons, (int)PROPRULE_2, FALSE, cutoff, &tightened) );
1597 
1598  if( *cutoff )
1599  {
1600  SCIPdebugMsg(scip, "cutoff while tightening <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->vbdvar), ylb, yub, newlb, yub);
1601  assert( SCIPisInfinity(scip, newlb) || SCIPisGT(scip, newlb, SCIPvarGetUbLocal(consdata->vbdvar)) );
1602 
1603  /* analyze infeasibility */
1604  SCIP_CALL( analyzeConflict(scip, cons, consdata->vbdvar, newlb, PROPRULE_2, SCIP_BOUNDTYPE_LOWER, usebdwidening) );
1605  break;
1606  }
1607 
1608  if( tightened )
1609  {
1610  SCIPdebugMsg(scip, " -> tighten <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->vbdvar), ylb, yub, newlb, yub);
1611  tightenedround = TRUE;
1612  (*nchgbds)++;
1613  }
1614  ylb = SCIPvarGetLbLocal(consdata->vbdvar);
1615  }
1616  }
1617  else
1618  {
1619  SCIP_Real QUAD(tmp);
1620 
1621  SCIPquadprecSumDD(tmp, consdata->lhs, -xub);
1622  SCIPquadprecDivQD(tmp, tmp, consdata->vbdcoef);
1623 
1624  newub = SCIPadjustedVarUb(scip, consdata->vbdvar, QUAD_TO_DBL(tmp));
1625 
1626  if( newub < yub - 0.5 )
1627  {
1628  SCIP_CALL( SCIPinferVarUbCons(scip, consdata->vbdvar, newub, cons, (int)PROPRULE_2, FALSE, cutoff, &tightened) );
1629 
1630  if( *cutoff )
1631  {
1632  SCIPdebugMsg(scip, "cutoff while tightening <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->vbdvar), ylb, yub, ylb, newub);
1633  assert( SCIPisInfinity(scip, -newub) || SCIPisLT(scip, newub, SCIPvarGetLbLocal(consdata->vbdvar)) );
1634 
1635  SCIP_CALL( SCIPresetConsAge(scip, cons) );
1636 
1637  /* analyze infeasibility */
1638  SCIP_CALL( analyzeConflict(scip, cons, consdata->vbdvar, newub, PROPRULE_2, SCIP_BOUNDTYPE_UPPER, usebdwidening) );
1639  break;
1640  }
1641 
1642  if( tightened )
1643  {
1644  SCIPdebugMsg(scip, " -> tighten <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->vbdvar), ylb, yub, ylb, newub);
1645  tightenedround = TRUE;
1646  (*nchgbds)++;
1647  SCIP_CALL( SCIPresetConsAge(scip, cons) );
1648  }
1649  yub = SCIPvarGetUbLocal(consdata->vbdvar);
1650  }
1651  }
1652  }
1653  }
1654 
1655  assert(!*cutoff);
1656 
1657  /* propagate right hand side inequality: x + c*y <= rhs */
1658  if( !SCIPisInfinity(scip, consdata->rhs) )
1659  {
1660  /* propagate bounds on x:
1661  * (3) right hand side and bounds on y -> upper bound on x
1662  */
1663  if( SCIPvarGetStatus(consdata->var) != SCIP_VARSTATUS_MULTAGGR ) /* cannot change bounds of multaggr vars */
1664  {
1665  if( consdata->vbdcoef > 0.0 )
1666  {
1667  if( !SCIPisInfinity(scip, -ylb) )
1668  {
1669  SCIP_Real QUAD(tmp);
1670 
1671  SCIPquadprecProdDD(tmp, consdata->vbdcoef, ylb);
1672  SCIPquadprecSumQD(tmp, -tmp, consdata->rhs);
1673 
1674  newub = SCIPadjustedVarUb(scip, consdata->var, QUAD_TO_DBL(tmp));
1675  }
1676  else
1677  {
1678  newub = SCIPinfinity(scip);
1679  }
1680  }
1681  else
1682  {
1683  if( !SCIPisInfinity(scip, yub) )
1684  {
1685  SCIP_Real QUAD(tmp);
1686 
1687  SCIPquadprecProdDD(tmp, consdata->vbdcoef, yub);
1688  SCIPquadprecSumQD(tmp, -tmp, consdata->rhs);
1689 
1690  newub = SCIPadjustedVarUb(scip, consdata->var, QUAD_TO_DBL(tmp));
1691  }
1692  else
1693  {
1694  newub = SCIPinfinity(scip);
1695  }
1696  }
1697 
1698  SCIP_CALL( SCIPinferVarUbCons(scip, consdata->var, newub, cons, (int)PROPRULE_3, yub < ylb + 0.5, cutoff, &tightened) );
1699 
1700  if( *cutoff )
1701  {
1702  SCIPdebugMsg(scip, "cutoff while tightening <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->var), xlb, xub, xlb, newub);
1703  assert( SCIPisInfinity(scip, -newub) || SCIPisLT(scip, newub, SCIPvarGetLbLocal(consdata->var)) );
1704 
1705  SCIP_CALL( SCIPresetConsAge(scip, cons) );
1706 
1707  /* analyze infeasibility */
1708  SCIP_CALL( analyzeConflict(scip, cons, consdata->var, newub, PROPRULE_3, SCIP_BOUNDTYPE_UPPER, usebdwidening) );
1709  break;
1710  }
1711 
1712  if( tightened )
1713  {
1714  SCIPdebugMsg(scip, " -> tighten <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->var), xlb, xub, xlb, newub);
1715  tightenedround = TRUE;
1716  (*nchgbds)++;
1717  SCIP_CALL( SCIPresetConsAge(scip, cons) );
1718  }
1719  xub = SCIPvarGetUbLocal(consdata->var);
1720  }
1721 
1722  assert(!*cutoff);
1723 
1724  /* propagate bounds on y:
1725  * (4) right hand side and lower bound on x -> bound on y
1726  */
1727  if( SCIPvarGetStatus(consdata->vbdvar) != SCIP_VARSTATUS_MULTAGGR && !SCIPisInfinity(scip, -xlb) ) /* cannot change bounds of multaggr vars */
1728  {
1729  if( consdata->vbdcoef > 0.0 )
1730  {
1731  SCIP_Real QUAD(tmp);
1732 
1733  SCIPquadprecSumDD(tmp, consdata->rhs, -xlb);
1734  SCIPquadprecDivQD(tmp, tmp, consdata->vbdcoef);
1735 
1736  newub = SCIPadjustedVarUb(scip, consdata->vbdvar, QUAD_TO_DBL(tmp));
1737  if( newub < yub - 0.5 )
1738  {
1739  SCIP_CALL( SCIPinferVarUbCons(scip, consdata->vbdvar, newub, cons, (int)PROPRULE_4, FALSE, cutoff, &tightened) );
1740 
1741  if( *cutoff )
1742  {
1743  SCIPdebugMsg(scip, "cutoff while tightening <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->vbdvar), ylb, yub, ylb, newub);
1744  assert(SCIPisLT(scip, newub, SCIPvarGetLbLocal(consdata->vbdvar)));
1745 
1746  SCIP_CALL( SCIPresetConsAge(scip, cons) );
1747 
1748  /* analyze infeasibility */
1749  SCIP_CALL( analyzeConflict(scip, cons, consdata->vbdvar, newub, PROPRULE_4, SCIP_BOUNDTYPE_UPPER, usebdwidening) );
1750  break;
1751  }
1752 
1753  if( tightened )
1754  {
1755  SCIPdebugMsg(scip, " -> tighten <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->vbdvar), ylb, yub, ylb, newub);
1756  tightenedround = TRUE;
1757  (*nchgbds)++;
1758  SCIP_CALL( SCIPresetConsAge(scip, cons) );
1759  }
1760  yub = SCIPvarGetUbLocal(consdata->vbdvar);
1761  }
1762  }
1763  else
1764  {
1765  SCIP_Real QUAD(tmp);
1766 
1767  SCIPquadprecSumDD(tmp, consdata->rhs, -xlb);
1768  SCIPquadprecDivQD(tmp, tmp, consdata->vbdcoef);
1769 
1770  newlb = SCIPadjustedVarLb(scip, consdata->vbdvar, QUAD_TO_DBL(tmp));
1771  if( newlb > ylb + 0.5 )
1772  {
1773  SCIP_CALL( SCIPinferVarLbCons(scip, consdata->vbdvar, newlb, cons, (int)PROPRULE_4, FALSE, cutoff, &tightened) );
1774 
1775  if( *cutoff )
1776  {
1777  SCIPdebugMsg(scip, "cutoff while tightening <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->vbdvar), ylb, yub, newlb, yub);
1778  assert(SCIPisGT(scip, newlb, SCIPvarGetUbLocal(consdata->vbdvar)));
1779 
1780  SCIP_CALL( SCIPresetConsAge(scip, cons) );
1781 
1782  /* analyze infeasibility */
1783  SCIP_CALL( analyzeConflict(scip, cons, consdata->vbdvar, newlb, PROPRULE_4, SCIP_BOUNDTYPE_LOWER, usebdwidening) );
1784  break;
1785  }
1786 
1787  if( tightened )
1788  {
1789  SCIPdebugMsg(scip, " -> tighten <%s>[%.15g,%.15g] -> [%.15g,%.15g]\n", SCIPvarGetName(consdata->vbdvar), ylb, yub, newlb, yub);
1790  tightenedround = TRUE;
1791  (*nchgbds)++;
1792  SCIP_CALL( SCIPresetConsAge(scip, cons) );
1793  }
1794  ylb = SCIPvarGetLbLocal(consdata->vbdvar);
1795  }
1796  }
1797  }
1798  }
1799  assert(!(*cutoff));
1800  }
1801  while( tightenedround );
1802 
1803  /* check for redundant sides */
1804  if( !(*cutoff) && SCIPgetStage(scip) == SCIP_STAGE_PRESOLVING && !SCIPinProbing(scip) )
1805  {
1806  /* check left hand side for redundancy */
1807  if( !SCIPisInfinity(scip, -consdata->lhs) &&
1808  ((consdata->vbdcoef > 0.0 && SCIPisGE(scip, xlb + consdata->vbdcoef * ylb, consdata->lhs))
1809  || (consdata->vbdcoef < 0.0 && SCIPisGE(scip, xlb + consdata->vbdcoef * yub, consdata->lhs))) )
1810  {
1811  SCIPdebugMsg(scip, "left hand side of variable bound constraint <%s> is redundant\n", SCIPconsGetName(cons));
1812 
1813  SCIP_CALL( chgLhs(scip, cons, -SCIPinfinity(scip)) );
1814  ++(*nchgsides);
1815  }
1816 
1817  /* check right hand side for redundancy */
1818  if( !SCIPisInfinity(scip, consdata->rhs) &&
1819  ((consdata->vbdcoef > 0.0 && SCIPisLE(scip, xub + consdata->vbdcoef * yub, consdata->rhs))
1820  || (consdata->vbdcoef < 0.0 && SCIPisLE(scip, xub + consdata->vbdcoef * ylb, consdata->rhs))) )
1821  {
1822  SCIPdebugMsg(scip, "right hand side of variable bound constraint <%s> is redundant\n", SCIPconsGetName(cons));
1823 
1824  SCIP_CALL( chgRhs(scip, cons, SCIPinfinity(scip)) );
1825  ++(*nchgsides);
1826  }
1827  }
1828  /* check varbound constraint for redundancy */
1829  if( !(*cutoff) && (SCIPisInfinity(scip, -consdata->lhs)
1830  || (consdata->vbdcoef > 0.0 && SCIPisGE(scip, xlb + consdata->vbdcoef * ylb, consdata->lhs))
1831  || (consdata->vbdcoef < 0.0 && SCIPisGE(scip, xlb + consdata->vbdcoef * yub, consdata->lhs)))
1832  && (SCIPisInfinity(scip, consdata->rhs)
1833  || (consdata->vbdcoef > 0.0 && SCIPisLE(scip, xub + consdata->vbdcoef * yub, consdata->rhs))
1834  || (consdata->vbdcoef < 0.0 && SCIPisLE(scip, xub + consdata->vbdcoef * ylb, consdata->rhs))) )
1835  {
1836  SCIPdebugMsg(scip, "variable bound constraint <%s> is redundant: <%s>[%.15g,%.15g], <%s>[%.15g,%.15g]\n",
1837  SCIPconsGetName(cons),
1838  SCIPvarGetName(consdata->var), SCIPvarGetLbLocal(consdata->var), SCIPvarGetUbLocal(consdata->var),
1839  SCIPvarGetName(consdata->vbdvar), SCIPvarGetLbLocal(consdata->vbdvar), SCIPvarGetUbLocal(consdata->vbdvar));
1840  SCIP_CALL( SCIPdelConsLocal(scip, cons) );
1841 
1842  /* this did not seem to help but should be tested again, there might also still be a bug in there */
1843 #ifdef SCIP_DISABLED_CODE
1844  /* local duality fixing of variables in the constraint */
1845  if( !SCIPisNegative(scip, SCIPvarGetObj(consdata->vbdvar))
1846  && SCIPvarGetNLocksDownType(consdata->vbdvar, SCIP_LOCKTYPE_MODEL) == 1
1847  && !SCIPisInfinity(scip, -SCIPvarGetLbLocal(consdata->vbdvar))
1848  && SCIPisFeasLT(scip, SCIPvarGetLbLocal(consdata->vbdvar), SCIPvarGetUbLocal(consdata->vbdvar))
1849  && ((consdata->vbdcoef > 0.0 && !SCIPisInfinity(scip, -consdata->lhs))
1850  || (consdata->vbdcoef < 0.0 && !SCIPisInfinity(scip, consdata->rhs))) )
1851  {
1852  SCIPdebugMsg(scip, " --> fixing <%s>[%.15g,%.15g] to %.15g\n", SCIPvarGetName(consdata->vbdvar),
1853  SCIPvarGetLbLocal(consdata->vbdvar), SCIPvarGetUbLocal(consdata->vbdvar), SCIPvarGetLbLocal(consdata->vbdvar));
1854  SCIP_CALL( SCIPchgVarUb(scip, consdata->vbdvar, SCIPvarGetLbLocal(consdata->vbdvar)) );
1855  }
1856  else if( !SCIPisPositive(scip, SCIPvarGetObj(consdata->vbdvar))
1857  && SCIPvarGetNLocksUpType(consdata->vbdvar, SCIP_LOCKTYPE_MODEL) == 1
1858  && !SCIPisInfinity(scip, SCIPvarGetUbLocal(consdata->vbdvar))
1859  && SCIPisFeasLT(scip, SCIPvarGetLbLocal(consdata->vbdvar), SCIPvarGetUbLocal(consdata->vbdvar))
1860  && ((consdata->vbdcoef < 0.0 && !SCIPisInfinity(scip, -consdata->lhs))
1861  || (consdata->vbdcoef > 0.0 && !SCIPisInfinity(scip, consdata->rhs))) )
1862  {
1863  SCIPdebugMsg(scip, " --> fixing <%s>[%.15g,%.15g] to %.15g\n", SCIPvarGetName(consdata->vbdvar),
1864  SCIPvarGetLbLocal(consdata->vbdvar), SCIPvarGetUbLocal(consdata->vbdvar), SCIPvarGetUbLocal(consdata->vbdvar));
1865  SCIP_CALL( SCIPchgVarLb(scip, consdata->vbdvar, SCIPvarGetUbLocal(consdata->vbdvar)) );
1866  }
1867  if( !SCIPisNegative(scip, SCIPvarGetObj(consdata->var))
1868  && SCIPvarGetNLocksDownType(consdata->var, SCIP_LOCKTYPE_MODEL) == 1
1869  && !SCIPisInfinity(scip, -SCIPvarGetLbLocal(consdata->var))
1870  && SCIPisFeasLT(scip, SCIPvarGetLbLocal(consdata->var), SCIPvarGetUbLocal(consdata->var))
1871  && !SCIPisInfinity(scip, -consdata->lhs) )
1872  {
1873  SCIPdebugMsg(scip, " --> fixing <%s>[%.15g,%.15g] to %.15g\n", SCIPvarGetName(consdata->var),
1874  SCIPvarGetLbLocal(consdata->var), SCIPvarGetUbLocal(consdata->var), SCIPvarGetLbLocal(consdata->var));
1875  SCIP_CALL( SCIPchgVarUb(scip, consdata->var, SCIPvarGetLbLocal(consdata->var)) );
1876  }
1877  else if( !SCIPisPositive(scip, SCIPvarGetObj(consdata->var))
1878  && SCIPvarGetNLocksUpType(consdata->var, SCIP_LOCKTYPE_MODEL) == 1
1879  && !SCIPisInfinity(scip, SCIPvarGetUbLocal(consdata->var))
1880  && SCIPisFeasLT(scip, SCIPvarGetLbLocal(consdata->var), SCIPvarGetUbLocal(consdata->var))
1881  && !SCIPisInfinity(scip, consdata->rhs) )
1882  {
1883  SCIPdebugMsg(scip, " --> fixing <%s>[%.15g,%.15g] to %.15g\n", SCIPvarGetName(consdata->var),
1884  SCIPvarGetLbLocal(consdata->var), SCIPvarGetUbLocal(consdata->var), SCIPvarGetUbLocal(consdata->var));
1885  SCIP_CALL( SCIPchgVarLb(scip, consdata->var, SCIPvarGetUbLocal(consdata->var)) );
1886  }
1887 #endif
1888  if( ndelconss != NULL )
1889  (*ndelconss)++;
1890  }
1891 
1892  SCIP_CALL( SCIPunmarkConsPropagate(scip, cons) );
1893 
1894  return SCIP_OKAY;
1895 }
1896 
1897 /* check whether one constraints side is redundant to another constraints side by calculating extreme values for
1898  * variables
1899  */
1900 static
1901 void checkRedundancySide(
1902  SCIP* scip, /**< SCIP data structure */
1903  SCIP_VAR* var, /**< variable x that has variable bound */
1904  SCIP_VAR* vbdvar, /**< binary, integer or implicit integer bounding variable y */
1905  SCIP_Real coef0, /**< coefficient c0 of bounding variable y for constraint 0 */
1906  SCIP_Real coef1, /**< coefficient c1 of bounding variable y for constraint 1 */
1907  SCIP_Real side0, /**< one side of variable bound inequality for constraint 0 */
1908  SCIP_Real side1, /**< one side of variable bound inequality for constraint 1 */
1909  SCIP_Bool* sideequal, /**< pointer to store if both constraints have the same redundancy on the
1910  * given side */
1911  SCIP_Bool* cons0sidered, /**< pointer to store if side of constraint 0 is redundant */
1912  SCIP_Bool* cons1sidered, /**< pointer to store if side of constraint 1 is redundant */
1913  SCIP_Bool islhs /**< do we check the left or the right hand side */
1914  )
1915 {
1916  SCIP_Real lbvar;
1917  SCIP_Real ubvar;
1918  SCIP_Real lbvbdvar;
1919  SCIP_Real ubvbdvar;
1920  SCIP_Real boundxlb1;
1921  SCIP_Real boundxlb2;
1922  SCIP_Real boundylb1;
1923  SCIP_Real boundylb2;
1924  SCIP_Real boundxub1;
1925  SCIP_Real boundxub2;
1926  SCIP_Real boundyub1;
1927  SCIP_Real boundyub2;
1928  SCIP_Real boundvaluex1;
1929  SCIP_Real boundvaluex2;
1930  SCIP_Real boundvaluey1;
1931  SCIP_Real boundvaluey2;
1932  SCIP_Real valuex1;
1933  SCIP_Real valuex2;
1934  SCIP_Real valuey1;
1935  SCIP_Real valuey2;
1936  SCIP_Bool* redundant0;
1937  SCIP_Bool* redundant1;
1938  SCIP_Real eps = SCIPepsilon(scip);
1939 
1940  assert(scip != NULL);
1941  assert(var != NULL);
1942  assert(vbdvar != NULL);
1943  assert(sideequal != NULL);
1944  assert(cons0sidered != NULL);
1945  assert(cons1sidered != NULL);
1946 
1947  *cons0sidered = SCIPisInfinity(scip, REALABS(side0));
1948  *cons1sidered = SCIPisInfinity(scip, REALABS(side1));
1949  *sideequal = FALSE;
1950 
1951  if( islhs )
1952  {
1953  redundant0 = cons1sidered;
1954  redundant1 = cons0sidered;
1955  }
1956  else
1957  {
1958  redundant0 = cons0sidered;
1959  redundant1 = cons1sidered;
1960  }
1961 
1962  lbvar = SCIPvarGetLbGlobal(var);
1963  ubvar = SCIPvarGetUbGlobal(var);
1964  lbvbdvar = SCIPvarGetLbGlobal(vbdvar);
1965  ubvbdvar = SCIPvarGetUbGlobal(vbdvar);
1966 
1967  /* if both constraint have this side */
1968  if( !*redundant0 && !*redundant1 )
1969  {
1970  /* calculate extreme values, which are reached by setting the other variable to their lower/upper bound */
1971  boundxlb1 = side0 - lbvbdvar*coef0;
1972  boundxlb2 = side1 - lbvbdvar*coef1;
1973  boundylb1 = (side0 - lbvar)/coef0;
1974  boundylb2 = (side1 - lbvar)/coef1;
1975 
1976  boundxub1 = side0 - ubvbdvar*coef0;
1977  boundxub2 = side1 - ubvbdvar*coef1;
1978  boundyub1 = (side0 - ubvar)/coef0;
1979  boundyub2 = (side1 - ubvar)/coef1;
1980 
1981  if( islhs )
1982  {
1983  boundvaluex1 = MAX(boundxlb1, boundxlb2);
1984  boundvaluex2 = MAX(boundxub1, boundxub2);
1985  }
1986  else
1987  {
1988  boundvaluex1 = MIN(boundxlb1, boundxlb2);
1989  boundvaluex2 = MIN(boundxub1, boundxub2);
1990  }
1991 
1992  /* calculate important values for variables */
1993  if( SCIPisPositive(scip, coef0) )
1994  {
1995  valuex1 = MIN(boundvaluex1, ubvar);
1996  valuex1 = MAX(valuex1, lbvar);
1997  valuex2 = MAX(boundvaluex2, lbvar);
1998  valuex2 = MIN(valuex2, ubvar);
1999 
2000  /* if variable is of integral type make values integral too */
2002  {
2003  if( !SCIPisFeasIntegral(scip, valuex1) )
2004  valuex1 = SCIPfeasFloor(scip, valuex1);
2005  if( !SCIPisFeasIntegral(scip, valuex2) )
2006  valuex2 = SCIPfeasCeil(scip, valuex2);
2007  }
2008  }
2009  else
2010  {
2011  valuex1 = MAX(boundvaluex1, lbvar);
2012  valuex1 = MIN(valuex1, ubvar);
2013  valuex2 = MIN(boundvaluex2, ubvar);
2014  valuex2 = MAX(valuex2, lbvar);
2015 
2016  /* if variable is of integral type make values integral too */
2018  {
2019  if( !SCIPisFeasIntegral(scip, valuex1) )
2020  valuex1 = SCIPfeasCeil(scip, valuex1);
2021  if( !SCIPisFeasIntegral(scip, valuex2) )
2022  valuex2 = SCIPfeasFloor(scip, valuex2);
2023  }
2024  }
2025 
2026  /* calculate resulting values of variable y by setting x to valuex1 */
2027  valuey1 = (side0 - valuex1)/coef0;
2028  valuey2 = (side1 - valuex1)/coef1;
2029 
2030  /* determine redundancy of one constraints side */
2031  if( valuey1 - valuey2 <= eps )
2032  *sideequal = TRUE;
2033  else if( SCIPisPositive(scip, coef0) )
2034  {
2035  if( valuey1 < valuey2 )
2036  *redundant1 = TRUE;
2037  else
2038  *redundant0 = TRUE;
2039  }
2040  else
2041  {
2042  if( valuey1 < valuey2 )
2043  *redundant0 = TRUE;
2044  else
2045  *redundant1 = TRUE;
2046  }
2047 
2048  /* calculate resulting values of variable y by setting x to valuex2 */
2049  valuey1 = (side0 - valuex2)/coef0;
2050  valuey2 = (side1 - valuex2)/coef1;
2051 
2052  /* determine redundancy of one constraints side by checking for the first valuex2 */
2053  if( SCIPisPositive(scip, coef0) )
2054  {
2055  /* if both constraints are weaker than the other on one value, we have no redundancy */
2056  if( (*redundant1 && valuey1 > valuey2) || (*redundant0 && valuey1 < valuey2) )
2057  {
2058  *sideequal = FALSE;
2059  *redundant0 = FALSE;
2060  *redundant1 = FALSE;
2061  return;
2062  }
2063  else if( *sideequal )
2064  {
2065  if( valuey1 + eps < valuey2 )
2066  {
2067  *sideequal = FALSE;
2068  *redundant1 = TRUE;
2069  }
2070  else if( valuey1 + eps > valuey2 )
2071  {
2072  *sideequal = FALSE;
2073  *redundant0 = TRUE;
2074  }
2075  }
2076  }
2077  else
2078  {
2079  /* if both constraints are weaker than the other one on one value, we have no redundancy */
2080  if( (*redundant1 && valuey1 < valuey2) || (*redundant0 && valuey1 > valuey2) )
2081  {
2082  *sideequal = FALSE;
2083  *redundant0 = FALSE;
2084  *redundant1 = FALSE;
2085  return;
2086  }
2087  else if( *sideequal )
2088  {
2089  if( valuey1 + eps < valuey2 )
2090  {
2091  *sideequal = FALSE;
2092  *redundant0 = TRUE;
2093  }
2094  else if( valuey1 + eps > valuey2 )
2095  {
2096  *sideequal = FALSE;
2097  *redundant1 = TRUE;
2098  }
2099  }
2100  }
2101  assert(*sideequal || *redundant0 || *redundant1);
2102 
2103  /* calculate feasibility domain values for variable y concerning these both constraints */
2104  if( SCIPisPositive(scip, coef0) )
2105  {
2106  if( islhs )
2107  {
2108  boundvaluey1 = MAX(boundylb1, boundylb2);
2109  boundvaluey2 = MAX(boundyub1, boundyub2);
2110  }
2111  else
2112  {
2113  boundvaluey1 = MIN(boundylb1, boundylb2);
2114  boundvaluey2 = MIN(boundyub1, boundyub2);
2115  }
2116 
2117  valuey1 = MIN(boundvaluey1, ubvbdvar);
2118  valuey1 = MAX(valuey1, lbvbdvar);
2119  valuey2 = MAX(boundvaluey2, lbvbdvar);
2120  valuey2 = MIN(valuey2, ubvbdvar);
2121 
2122  if( !SCIPisFeasIntegral(scip, valuey1) )
2123  valuey1 = SCIPfeasFloor(scip, valuey1);
2124  if( !SCIPisFeasIntegral(scip, valuey2) )
2125  valuey2 = SCIPfeasCeil(scip, valuey2);
2126  }
2127  else
2128  {
2129  if( islhs )
2130  {
2131  boundvaluey1 = MIN(boundylb1, boundylb2);
2132  boundvaluey2 = MIN(boundyub1, boundyub2);
2133  }
2134  else
2135  {
2136  boundvaluey1 = MAX(boundylb1, boundylb2);
2137  boundvaluey2 = MAX(boundyub1, boundyub2);
2138  }
2139 
2140  valuey1 = MAX(boundvaluey1, lbvbdvar);
2141  valuey1 = MIN(valuey1, ubvbdvar);
2142  valuey2 = MIN(boundvaluey2, ubvbdvar);
2143  valuey2 = MAX(valuey2, lbvbdvar);
2144 
2145  /* if variable is of integral type make values integral too */
2146  if( !SCIPisFeasIntegral(scip, valuey1) )
2147  valuey1 = SCIPfeasCeil(scip, valuey1);
2148  if( !SCIPisFeasIntegral(scip, valuey2) )
2149  valuey2 = SCIPfeasFloor(scip, valuey2);
2150  }
2151 
2152  /* calculate resulting values of variable x by setting y to valuey1 */
2153  valuex1 = side0 - valuey1*coef0;
2154  valuex2 = side1 - valuey1*coef1;
2155 
2156  /* determine redundancy of one constraints side by checking for the first valuey1 */
2157  if( (*redundant1 && valuex1 > valuex2) || (*redundant0 && valuex1 < valuex2) )
2158  {
2159  *sideequal = FALSE;
2160  *redundant0 = FALSE;
2161  *redundant1 = FALSE;
2162  return;
2163  }
2164  if( *sideequal )
2165  {
2166  if( valuex1 + eps < valuex2 )
2167  {
2168  *sideequal = FALSE;
2169  *redundant1 = TRUE;
2170  }
2171  else if( valuex1 + eps > valuex2 )
2172  {
2173  *sideequal = FALSE;
2174  *redundant0 = TRUE;
2175  }
2176  }
2177 
2178  /* calculate resulting values of variable x by setting y to valuey2 */
2179  valuex1 = side0 - valuey2*coef0;
2180  valuex2 = side1 - valuey2*coef1;
2181 
2182  /* determine redundancy of one constraints side by checking for the first valuey1 */
2183  if( (*redundant1 && valuex1 > valuex2) || (*redundant0 && valuex1 < valuex2) )
2184  {
2185  *sideequal = FALSE;
2186  *redundant0 = FALSE;
2187  *redundant1 = FALSE;
2188  return;
2189  }
2190  if( *sideequal )
2191  {
2192  if( valuex1 + eps < valuex2 )
2193  {
2194  *sideequal = FALSE;
2195  *redundant1 = TRUE;
2196  }
2197  else if( valuex1 + eps > valuex2 )
2198  {
2199  *sideequal = FALSE;
2200  *redundant0 = TRUE;
2201  }
2202  }
2203  assert(*redundant0 || *redundant1 || *sideequal);
2204  }
2205 }
2206 
2207 /** compares each constraint with all other constraints for possible redundancy and removes or changes constraint
2208  *
2209  * we will order all constraint to have constraints with same variables next to each other to speed up presolving
2210  *
2211  * consider two constraints like lhs1 <= x + b1*y <= rhs1 and lhs2 <= x + b2*y <= rhs2
2212  * we are doing the following presolving steps:
2213  *
2214  * if( b1 == b2 )
2215  * newlhs = MAX(lhs1, lhs2)
2216  * newrhs = MIN(rhs1, rhs2)
2217  * updateSides
2218  * delete one constraint
2219  * else if( ((b1 > 0) == (b2 > 0)) && (lhs1 != -inf && lhs2 != -inf) || (rhs1 != inf && rhs2 != inf) )
2220  *
2221  * (i.e. both constraint have either a valid lhs or a valid rhs and infinity is on the same side and the
2222  * coeffcients have the same size )
2223  *
2224  * if( y is binary )
2225  * if( lhs1 != -inf )
2226  * newlhs = MAX(lhs1, lhs2)
2227  * newb = newlhs - MAX(lhs1 - b1, lhs2 - b2)
2228  * else
2229  * newrhs = MIN(lhs1, lhs2)
2230  * newb = newrhs - MIN(rhs1 - b1, rhs2 - b2)
2231  * updateSidesAndCoef
2232  * delete one constraint
2233  * else
2234  * we calculate possible values for both variables and check which constraint is tighter
2235  * else
2236  * nothing possible
2237  *
2238  * We also try to tighten bounds in the case of two constraints lhs1 <= x + b1*y <= rhs1 and lhs2 <= y + b2*x <= rhs2.
2239  * Eliminiating one variable and inserting into the second yields the following bounds:
2240  * If b2 > 0:
2241  * (1 - b1 * b2) * y >= lhs2 - b2 * rhs1
2242  * (1 - b1 * b2) * y <= rhs2 - b2 * lhs1
2243  * If b2 < 0:
2244  * (1 - b1 * b2) * y >= lhs2 - b2 * lhs1
2245  * (1 - b1 * b2) * y <= rhs2 - b2 * rhs1
2246  * The case of x is similar.
2247  */
2248 static
2250  SCIP* scip, /**< SCIP data structure */
2251  SCIP_CONS** conss, /**< constraint set */
2252  int nconss, /**< number of constraints in constraint set */
2253  SCIP_Bool* cutoff, /**< pointer to store TRUE, if a cutoff was found */
2254  int* nchgbds, /**< pointer to count number of bound changes */
2255  int* ndelconss, /**< pointer to count number of deleted constraints */
2256  int* nchgcoefs, /**< pointer to count the number of changed coefficients */
2257  int* nchgsides /**< pointer to count number of changed left/right hand sides */
2258  )
2259 {
2260  SCIP_CONS** sortedconss;
2261  int c;
2262  int s;
2263 
2264  assert(scip != NULL);
2265  assert(conss != NULL);
2266  assert(cutoff != NULL);
2267  assert(nchgbds != NULL);
2268  assert(ndelconss != NULL);
2269  assert(nchgcoefs != NULL);
2270  assert(nchgsides != NULL);
2271 
2272  /* create our temporary working array */
2273  SCIP_CALL( SCIPduplicateBufferArray(scip, &sortedconss, conss, nconss) );
2274 
2275  /* sort all constraints, so that all constraints with same variables stand next to each other */
2276  SCIPsortPtr((void**)sortedconss, consVarboundComp, nconss);
2277 
2278  /* check all constraints for redundancy */
2279  for( c = nconss - 1; c > 0 && !(*cutoff); --c )
2280  {
2281  SCIP_CONS* cons0;
2282  SCIP_CONSDATA* consdata0;
2283 
2284  cons0 = sortedconss[c];
2285 
2286  if( !SCIPconsIsActive(cons0) || SCIPconsIsModifiable(cons0) )
2287  continue;
2288 
2289  consdata0 = SCIPconsGetData(cons0);
2290  assert(consdata0 != NULL);
2291  assert(consdata0->var != NULL);
2292  assert(consdata0->vbdvar != NULL);
2293 
2294  /* do not check for already redundant constraints */
2295  assert(!SCIPisZero(scip, consdata0->vbdcoef));
2296  assert(!SCIPisInfinity(scip, -consdata0->lhs) || !SCIPisInfinity(scip, consdata0->rhs));
2297 
2298  if( !consdata0->changed )
2299  continue;
2300 
2301  consdata0->changed = FALSE;
2302 
2303  for( s = c - 1; s >= 0; --s )
2304  {
2305  SCIP_CONS* cons1;
2306  SCIP_CONSDATA* consdata1;
2307  SCIP_Real lhs;
2308  SCIP_Real rhs;
2309  SCIP_Real coef;
2310  SCIP_Bool deletecons1;
2311 
2312  cons1 = sortedconss[s];
2313 
2314  if( !SCIPconsIsActive(cons1) || SCIPconsIsModifiable(cons1) )
2315  continue;
2316 
2317  consdata1 = SCIPconsGetData(cons1);
2318  assert(consdata1 != NULL);
2319  assert(consdata1->var != NULL);
2320  assert(consdata1->vbdvar != NULL);
2321 
2322  /* do not check for already redundant constraints */
2323  assert(!SCIPisZero(scip, consdata1->vbdcoef));
2324  assert(!SCIPisInfinity(scip, -consdata1->lhs) || !SCIPisInfinity(scip, consdata1->rhs));
2325 
2326  lhs = consdata0->lhs;
2327  rhs = consdata0->rhs;
2328  coef = consdata0->vbdcoef;
2329 
2330  /* check for propagation in the case: lhs1 <= x + b1*y <= rhs1 and lhs2 <= y + b2*x <= rhs2. */
2331  if ( consdata0->var == consdata1->vbdvar && consdata0->vbdvar == consdata1->var &&
2332  !SCIPisFeasZero(scip, 1.0 - coef * consdata1->vbdcoef) )
2333  {
2334  SCIP_Bool tightened = FALSE;
2335  SCIP_Real bnd = SCIP_UNKNOWN;
2336  SCIP_Real scalar;
2337  SCIP_Real newbnd;
2338 
2339  scalar = (1.0 - coef * consdata1->vbdcoef);
2340 
2341  assert( ! SCIPisInfinity(scip, REALABS(scalar)) );
2342  assert( ! SCIPisZero(scip, consdata0->vbdcoef) );
2343  assert( ! SCIPisZero(scip, consdata1->vbdcoef) );
2344 
2345  /* lower bounds for consdata0->var */
2346  if ( ! SCIPisInfinity(scip, -lhs) )
2347  {
2348  if ( SCIPisPositive(scip, coef) )
2349  {
2350  if ( ! SCIPisInfinity(scip, consdata1->rhs) )
2351  bnd = (lhs - coef * consdata1->rhs)/scalar;
2352  }
2353  else
2354  {
2355  assert( SCIPisNegative(scip, coef) );
2356  if ( ! SCIPisInfinity(scip, consdata1->lhs) )
2357  bnd = (lhs - coef * consdata1->lhs)/scalar;
2358  }
2359 
2360  if ( bnd != SCIP_UNKNOWN ) /*lint !e777*/
2361  {
2362  if ( SCIPisFeasPositive(scip, scalar) )
2363  {
2364  newbnd = SCIPadjustedVarLb(scip, consdata0->var, bnd);
2365  SCIP_CALL( SCIPtightenVarLb(scip, consdata0->var, newbnd, FALSE, cutoff, &tightened) );
2366  if ( tightened )
2367  {
2368  SCIPdebugMsg(scip, "<%s>, <%s> -> tightened lower bound: <%s> >= %.15g\n", SCIPconsGetName(cons0), SCIPconsGetName(cons1),
2369  SCIPvarGetName(consdata0->var), SCIPvarGetLbGlobal(consdata0->var));
2370  (*nchgbds)++;
2371  }
2372  }
2373  else if ( SCIPisFeasNegative(scip, scalar) )
2374  {
2375  newbnd = SCIPadjustedVarUb(scip, consdata0->var, bnd);
2376  SCIP_CALL( SCIPtightenVarUb(scip, consdata0->var, newbnd, FALSE, cutoff, &tightened) );
2377  if ( tightened )
2378  {
2379  SCIPdebugMsg(scip, "<%s>, <%s> -> tightened upper bound: <%s> >= %.15g\n", SCIPconsGetName(cons0), SCIPconsGetName(cons1),
2380  SCIPvarGetName(consdata0->var), SCIPvarGetUbGlobal(consdata0->var));
2381  (*nchgbds)++;
2382  }
2383  }
2384  }
2385  }
2386 
2387  /* upper bound for consdata0>var */
2388  if ( ! SCIPisInfinity(scip, rhs) )
2389  {
2390  bnd = SCIP_UNKNOWN;
2391  if ( SCIPisPositive(scip, coef) )
2392  {
2393  if ( ! SCIPisInfinity(scip, consdata1->lhs) )
2394  bnd = (rhs - coef * consdata1->lhs)/scalar;
2395  }
2396  else
2397  {
2398  assert( SCIPisNegative(scip, coef) );
2399  if ( ! SCIPisInfinity(scip, consdata1->rhs) )
2400  bnd = (rhs - coef * consdata1->rhs)/scalar;
2401  }
2402 
2403  if ( bnd != SCIP_UNKNOWN ) /*lint !e777*/
2404  {
2405  if ( SCIPisFeasPositive(scip, scalar) )
2406  {
2407  newbnd = SCIPadjustedVarUb(scip, consdata0->var, bnd);
2408  SCIP_CALL( SCIPtightenVarUb(scip, consdata0->var, newbnd, FALSE, cutoff, &tightened) );
2409  if ( tightened )
2410  {
2411  SCIPdebugMsg(scip, "<%s>, <%s> -> tightened upper bound: <%s> >= %.15g\n", SCIPconsGetName(cons0), SCIPconsGetName(cons1),
2412  SCIPvarGetName(consdata0->var), SCIPvarGetUbGlobal(consdata0->var));
2413  (*nchgbds)++;
2414  }
2415  }
2416  else if ( SCIPisFeasNegative(scip, scalar) )
2417  {
2418  newbnd = SCIPadjustedVarLb(scip, consdata0->var, bnd);
2419  SCIP_CALL( SCIPtightenVarLb(scip, consdata0->var, newbnd, FALSE, cutoff, &tightened) );
2420  if ( tightened )
2421  {
2422  SCIPdebugMsg(scip, "<%s>, <%s> -> tightened lower bound: <%s> >= %.15g\n", SCIPconsGetName(cons0), SCIPconsGetName(cons1),
2423  SCIPvarGetName(consdata0->var), SCIPvarGetLbGlobal(consdata0->var));
2424  (*nchgbds)++;
2425  }
2426  }
2427  }
2428  }
2429 
2430  /* lower bounds for consdata1->var */
2431  if ( ! SCIPisInfinity(scip, -consdata1->lhs) )
2432  {
2433  bnd = SCIP_UNKNOWN;
2434  if ( SCIPisPositive(scip, consdata1->vbdcoef) )
2435  {
2436  if ( ! SCIPisInfinity(scip, rhs) )
2437  bnd = (consdata1->lhs - consdata1->vbdcoef * rhs)/scalar;
2438  }
2439  else
2440  {
2441  assert( SCIPisNegative(scip, consdata1->vbdcoef) );
2442  if ( ! SCIPisInfinity(scip, lhs) )
2443  bnd = (consdata1->lhs - consdata1->vbdcoef * lhs)/scalar;
2444  }
2445 
2446  if ( bnd != SCIP_UNKNOWN ) /*lint !e777*/
2447  {
2448  if ( SCIPisFeasPositive(scip, scalar) )
2449  {
2450  newbnd = SCIPadjustedVarLb(scip, consdata1->var, bnd);
2451  SCIP_CALL( SCIPtightenVarLb(scip, consdata1->var, newbnd, FALSE, cutoff, &tightened) );
2452  if ( tightened )
2453  {
2454  SCIPdebugMsg(scip, "<%s>, <%s> -> tightened lower bound: <%s> >= %.15g\n", SCIPconsGetName(cons0), SCIPconsGetName(cons1),
2455  SCIPvarGetName(consdata1->var), SCIPvarGetLbGlobal(consdata1->var));
2456  (*nchgbds)++;
2457  }
2458  }
2459  else if ( SCIPisFeasNegative(scip, scalar) )
2460  {
2461  newbnd = SCIPadjustedVarUb(scip, consdata1->var, bnd);
2462  SCIP_CALL( SCIPtightenVarUb(scip, consdata1->var, newbnd, FALSE, cutoff, &tightened) );
2463  if ( tightened )
2464  {
2465  SCIPdebugMsg(scip, "<%s>, <%s> -> tightened upper bound: <%s> >= %.15g\n", SCIPconsGetName(cons0), SCIPconsGetName(cons1),
2466  SCIPvarGetName(consdata1->var), SCIPvarGetUbGlobal(consdata1->var));
2467  (*nchgbds)++;
2468  }
2469  }
2470  }
2471  }
2472 
2473  /* upper bound for consdata1->var */
2474  if ( ! SCIPisInfinity(scip, consdata1->rhs) )
2475  {
2476  bnd = SCIP_UNKNOWN;
2477  if ( SCIPisPositive(scip, consdata1->vbdcoef) )
2478  {
2479  if ( ! SCIPisInfinity(scip, lhs) )
2480  bnd = (consdata1->rhs - consdata1->vbdcoef * lhs)/scalar;
2481  }
2482  else
2483  {
2484  assert( SCIPisNegative(scip, consdata1->vbdcoef) );
2485  if ( ! SCIPisInfinity(scip, rhs) )
2486  bnd = (consdata1->rhs - consdata1->vbdcoef * rhs)/scalar;
2487  }
2488 
2489  if ( bnd != SCIP_UNKNOWN ) /*lint !e777*/
2490  {
2491  if ( SCIPisFeasPositive(scip, scalar) )
2492  {
2493  newbnd = SCIPadjustedVarUb(scip, consdata1->var, bnd);
2494  SCIP_CALL( SCIPtightenVarUb(scip, consdata1->var, newbnd, FALSE, cutoff, &tightened) );
2495  if ( tightened )
2496  {
2497  SCIPdebugMsg(scip, "<%s>, <%s> -> tightened upper bound: <%s> >= %.15g\n", SCIPconsGetName(cons0), SCIPconsGetName(cons1),
2498  SCIPvarGetName(consdata1->var), SCIPvarGetUbGlobal(consdata1->var));
2499  (*nchgbds)++;
2500  }
2501  }
2502  else if ( SCIPisFeasNegative(scip, scalar) )
2503  {
2504  newbnd = SCIPadjustedVarLb(scip, consdata1->var, bnd);
2505  SCIP_CALL( SCIPtightenVarLb(scip, consdata1->var, newbnd, FALSE, cutoff, &tightened) );
2506  if ( tightened )
2507  {
2508  SCIPdebugMsg(scip, "<%s>, <%s> -> tightened lower bound: <%s> >= %.15g\n", SCIPconsGetName(cons0), SCIPconsGetName(cons1),
2509  SCIPvarGetName(consdata1->var), SCIPvarGetLbGlobal(consdata1->var));
2510  (*nchgbds)++;
2511  }
2512  }
2513  }
2514  }
2515  }
2516 
2517  /* check for equal variables */
2518  if( consdata0->var != consdata1->var || consdata0->vbdvar != consdata1->vbdvar )
2519  break;
2520 
2521  /* mark constraint1 for deletion if possible */
2522  deletecons1 = TRUE;
2523 
2524  /* the coefficients of both constraints are equal */
2525  if( SCIPisEQ(scip, coef, consdata1->vbdcoef) )
2526  {
2527  lhs = MAX(consdata1->lhs, lhs);
2528  rhs = MIN(consdata1->rhs, rhs);
2529  }
2530  /* now only one side and in both constraints the same side should be infinity and the vbdvar should be binary
2531  * then we neither do not need to have the same side nor the same coefficient
2532  */
2533  else if( SCIPvarIsBinary(consdata0->vbdvar)
2534  && (SCIPisInfinity(scip, -lhs) || SCIPisInfinity(scip, rhs))
2535  && (SCIPisInfinity(scip, -consdata1->lhs) || SCIPisInfinity(scip, consdata1->rhs))
2536  && (SCIPisInfinity(scip, -lhs) == SCIPisInfinity(scip, -consdata1->lhs)) )
2537  {
2538  /* lhs <= x + b*y <= +inf */
2539  if( !SCIPisInfinity(scip, -lhs) )
2540  {
2541  lhs = MAX(consdata1->lhs, lhs);
2542  coef = lhs - MAX(consdata1->lhs - consdata1->vbdcoef, consdata0->lhs - coef);
2543  }
2544  /* -inf <= x + b*y <= rhs */
2545  else
2546  {
2547  rhs = MIN(consdata1->rhs, rhs);
2548  coef = rhs - MIN(consdata1->rhs - consdata1->vbdcoef, consdata0->rhs - coef);
2549  }
2550 
2551  SCIP_CALL( SCIPmarkConsPropagate(scip, cons0) );
2552  }
2553  else if( SCIPisPositive(scip, coef) == SCIPisPositive(scip, consdata1->vbdcoef)
2554  && ((!SCIPisInfinity(scip, -lhs) && !SCIPisInfinity(scip, -consdata1->lhs))
2555  || (!SCIPisInfinity(scip, rhs) && !SCIPisInfinity(scip, consdata1->rhs))) )
2556  {
2557  SCIP_Bool cons0lhsred;
2558  SCIP_Bool cons0rhsred;
2559  SCIP_Bool cons1lhsred;
2560  SCIP_Bool cons1rhsred;
2561  SCIP_Bool lhsequal;
2562  SCIP_Bool rhsequal;
2563 
2564  assert(!SCIPisInfinity(scip, lhs));
2565  assert(!SCIPisInfinity(scip, consdata1->lhs));
2566  assert(!SCIPisInfinity(scip, -rhs));
2567  assert(!SCIPisInfinity(scip, -consdata1->rhs));
2568 
2569  /* check if a left hand side of one constraints is redundant */
2570  checkRedundancySide(scip, consdata0->var, consdata0->vbdvar, coef, consdata1->vbdcoef, lhs, consdata1->lhs, &lhsequal, &cons0lhsred, &cons1lhsred, TRUE);
2571 
2572  /* check if a right hand side of one constraints is redundant */
2573  checkRedundancySide(scip, consdata0->var, consdata0->vbdvar, coef, consdata1->vbdcoef, rhs, consdata1->rhs, &rhsequal, &cons0rhsred, &cons1rhsred, FALSE);
2574 
2575  /* if cons0 is redundant, update cons1 and delete cons0 */
2576  if( (lhsequal || cons0lhsred) && (rhsequal || cons0rhsred) )
2577  {
2578  /* update flags of constraint which caused the redundancy s.t. nonredundant information doesn't get lost */
2579  SCIP_CALL( SCIPupdateConsFlags(scip, cons1, cons0) );
2580 
2581  SCIPdebugMsg(scip, "constraint: ");
2582  SCIPdebugPrintCons(scip, cons0, NULL);
2583  SCIPdebugMsg(scip, "is redundant to constraint: ");
2584  SCIPdebugPrintCons(scip, cons1, NULL);
2585 
2586  SCIP_CALL( SCIPdelCons(scip, cons0) );
2587  ++(*ndelconss);
2588 
2589  /* get next cons0 */
2590  break;
2591  }
2592  /* if cons1 is redundant, update cons0 and delete cons1 */
2593  else if( cons1lhsred && cons1rhsred )
2594  {
2595  /* update flags of constraint which caused the redundancy s.t. nonredundant information doesn't get lost */
2596  SCIP_CALL( SCIPupdateConsFlags(scip, cons0, cons1) );
2597 
2598  SCIPdebugMsg(scip, "constraint: ");
2599  SCIPdebugPrintCons(scip, cons1, NULL);
2600  SCIPdebugMsg(scip, "is redundant to constraint: ");
2601  SCIPdebugPrintCons(scip, cons0, NULL);
2602 
2603  SCIP_CALL( SCIPdelCons(scip, cons1) );
2604  ++(*ndelconss);
2605 
2606  /* get next cons1 */
2607  continue;
2608  }
2609  /* if left hand side of cons0 is redundant set it to -infinity */
2610  else if( (lhsequal || cons0lhsred) && !SCIPisInfinity(scip, -lhs) )
2611  {
2612  lhs = -SCIPinfinity(scip);
2613 
2614  /* if right hand side of cons1 is redundant too, set it to infinity */
2615  if( cons1rhsred && !SCIPisInfinity(scip, consdata1->rhs) )
2616  {
2617  SCIP_CALL( chgRhs(scip, cons1, SCIPinfinity(scip)) );
2618  ++(*nchgsides);
2619 
2620  SCIPdebugMsg(scip, "deleted rhs of constraint: ");
2621  SCIPdebugPrintCons(scip, cons1, NULL);
2622  SCIPdebugMsg(scip, "due to constraint: ");
2623  SCIPdebugPrintCons(scip, cons0, NULL);
2624  }
2625 
2626  /* later on we cannot not want to delete cons1 */
2627  deletecons1 = FALSE;
2628  }
2629  /* if right hand side of cons0 is redundant set it to infinity */
2630  else if( (rhsequal || cons0rhsred) && !SCIPisInfinity(scip, rhs) )
2631  {
2632  rhs = SCIPinfinity(scip);
2633 
2634  /* if left hand side of cons1 is redundant too, set it to -infinity */
2635  if( cons1lhsred && !SCIPisInfinity(scip, -consdata1->lhs) )
2636  {
2637  SCIP_CALL( chgLhs(scip, cons1, -SCIPinfinity(scip)) );
2638  ++(*nchgsides);
2639 
2640  SCIPdebugMsg(scip, "deleted lhs of constraint: ");
2641  SCIPdebugPrintCons(scip, cons1, NULL);
2642  SCIPdebugMsg(scip, "due to constraint: ");
2643  SCIPdebugPrintCons(scip, cons0, NULL);
2644  }
2645 
2646  /* later on we cannot not want to delete cons1 */
2647  deletecons1 = FALSE;
2648  }
2649  /* if left hand side of cons1 is redundant set it to -infinity */
2650  else if( cons1lhsred && !SCIPisInfinity(scip, -consdata1->lhs) )
2651  {
2652  SCIP_CALL( chgLhs(scip, cons1, -SCIPinfinity(scip)) );
2653  ++(*nchgsides);
2654 
2655  SCIPdebugMsg(scip, "deleted lhs of constraint: ");
2656  SCIPdebugPrintCons(scip, cons1, NULL);
2657  SCIPdebugMsg(scip, "due to constraint: ");
2658  SCIPdebugPrintCons(scip, cons0, NULL);
2659 
2660  continue;
2661  }
2662  /* if right hand side of cons1 is redundant set it to infinity */
2663  else if( cons1rhsred && !SCIPisInfinity(scip, consdata1->rhs) )
2664  {
2665  SCIP_CALL( chgRhs(scip, cons1, SCIPinfinity(scip)) );
2666  ++(*nchgsides);
2667 
2668  SCIPdebugMsg(scip, "deleted rhs of constraint: ");
2669  SCIPdebugPrintCons(scip, cons1, NULL);
2670  SCIPdebugMsg(scip, "due to constraint: ");
2671  SCIPdebugPrintCons(scip, cons0, NULL);
2672 
2673  continue;
2674  }
2675  else /* nothing was redundant */
2676  continue;
2677  }
2678  else
2679  {
2680  /* there is no redundancy in both constraints with same variables */
2681  continue;
2682  }
2683 
2684  if( SCIPisFeasLT(scip, rhs, lhs) )
2685  {
2686  SCIPdebugMsg(scip, "constraint <%s> and <%s> lead to infeasibility due to their sides\n", SCIPconsGetName(cons0), SCIPconsGetName(cons1));
2687  *cutoff = TRUE;
2688  break;
2689  }
2690 
2691  /* ensure that lhs <= rhs holds without tolerances as we only allow such rows to enter the LP */
2692  if( lhs > rhs )
2693  {
2694  rhs = (lhs + rhs)/2;
2695  lhs = rhs;
2696  }
2697 
2698  /* we decide to let constraint cons0 stay, so update data structure consdata0 */
2699 
2700  /* update coefficient of cons0 */
2701 
2702  /* special case if new coefficient becomes zero, both constraints are redundant but we may tighten the bounds */
2703  if( SCIPisZero(scip, coef) )
2704  {
2705  SCIP_Bool infeasible;
2706  SCIP_Bool tightened;
2707 
2708  SCIPdebugMsg(scip, "constraint: ");
2709  SCIPdebugPrintCons(scip, cons1, NULL);
2710  SCIPdebugMsg(scip, "and constraint: ");
2711  SCIPdebugPrintCons(scip, cons0, NULL);
2712  SCIPdebugMsg(scip, "are both redundant and lead to bounding of <%s> in [%g, %g]\n", SCIPvarGetName(consdata0->var), lhs, rhs);
2713 
2714  /* delete cons1 */
2715  SCIP_CALL( SCIPdelCons(scip, cons1) );
2716  ++(*ndelconss);
2717 
2718  /* update upper bound if possible
2719  *
2720  * @note we need to force the bound change since we are deleting the constraint afterwards
2721  */
2722  SCIP_CALL( SCIPtightenVarUb(scip, consdata0->var, rhs, TRUE, &infeasible, &tightened) );
2723  if( infeasible )
2724  {
2725  *cutoff = TRUE;
2726  break;
2727  }
2728  if( tightened )
2729  ++(*nchgbds);
2730 
2731  /* update lower bound if possible
2732  *
2733  * @note we need to force the bound change since we are deleting the constraint afterwards
2734  */
2735  SCIP_CALL( SCIPtightenVarLb(scip, consdata0->var, lhs, TRUE, &infeasible, &tightened) );
2736  if( infeasible )
2737  {
2738  *cutoff = TRUE;
2739  break;
2740  }
2741  if( tightened )
2742  ++(*nchgbds);
2743 
2744  /* delete cons0 */
2745  SCIP_CALL( SCIPdelCons(scip, cons0) );
2746  ++(*ndelconss);
2747 
2748  /* get next cons0 */
2749  break;
2750  }
2751 
2752  SCIPdebugMsg(scip, "constraint: ");
2753  SCIPdebugPrintCons(scip, cons1, NULL);
2754  SCIPdebugMsg(scip, "and constraint: ");
2755  SCIPdebugPrintCons(scip, cons0, NULL);
2756 
2757  /* if sign of coefficient switches, update the locks of the variable */
2758  if( consdata0->vbdcoef * coef < 0.0 )
2759  {
2760  assert(SCIPconsIsTransformed(cons0));
2761 
2762  /* remove locks for variable with old coefficient and install locks for variable with new
2763  * coefficient
2764  */
2765  if( SCIPisPositive(scip, consdata0->vbdcoef) )
2766  {
2767  SCIP_CALL( SCIPunlockVarCons(scip, consdata0->vbdvar, cons0, !SCIPisInfinity(scip, -consdata0->lhs),
2768  !SCIPisInfinity(scip, consdata0->rhs)) );
2769  SCIP_CALL( SCIPlockVarCons(scip, consdata0->vbdvar, cons0, !SCIPisInfinity(scip, consdata0->rhs),
2770  !SCIPisInfinity(scip, -consdata0->lhs)) );
2771  }
2772  else
2773  {
2774  SCIP_CALL( SCIPunlockVarCons(scip, consdata0->vbdvar, cons0, !SCIPisInfinity(scip, consdata0->rhs),
2775  !SCIPisInfinity(scip, -consdata0->lhs)) );
2776  SCIP_CALL( SCIPlockVarCons(scip, consdata0->vbdvar, cons0, !SCIPisInfinity(scip, -consdata0->lhs),
2777  !SCIPisInfinity(scip, consdata0->rhs)) );
2778  }
2779  }
2780 
2781  /* now change the coefficient */
2782  if( !SCIPisEQ(scip, consdata0->vbdcoef, coef) )
2783  {
2784  ++(*nchgcoefs);
2785 
2786  /* mark to add new varbound information */
2787  consdata0->varboundsadded = FALSE;
2788  consdata0->tightened = FALSE;
2789  consdata0->presolved = FALSE;
2790  consdata0->changed = FALSE;
2791 
2792  consdata0->vbdcoef = coef;
2793 
2794  SCIP_CALL( SCIPmarkConsPropagate(scip, cons0) );
2795  }
2796 
2797  /* update lhs and rhs of cons0 */
2798  if( !SCIPisEQ(scip, consdata0->lhs, lhs) )
2799  {
2800  SCIP_CALL( chgLhs(scip, cons0, lhs) );
2801  ++(*nchgsides);
2802  }
2803  if( !SCIPisEQ(scip, consdata0->rhs, rhs) )
2804  {
2805  SCIP_CALL( chgRhs(scip, cons0, rhs) );
2806  ++(*nchgsides);
2807  }
2808 
2809  /* update flags of constraint which caused the redundancy s.t. nonredundant information doesn't get lost */
2810  SCIP_CALL( SCIPupdateConsFlags(scip, cons0, cons1) );
2811 
2812  SCIPdebugMsg(scip, "lead to new constraint: ");
2813  SCIPdebugPrintCons(scip, cons0, NULL);
2814 
2815  /* if cons1 is still marked for deletion, delete it */
2816  if( deletecons1 )
2817  {
2818  /* delete cons1 */
2819  SCIP_CALL( SCIPdelCons(scip, cons1) );
2820  ++(*ndelconss);
2821  }
2822 
2823  assert(SCIPconsIsActive(cons0));
2824  }
2825  }
2826 
2827  /* free temporary memory */
2828  SCIPfreeBufferArray(scip, &sortedconss);
2829 
2830  return SCIP_OKAY;
2831 }
2832 
2833 /** for all varbound constraints with two integer variables make the coefficients integral */
2834 static
2835 void prettifyConss(
2836  SCIP* scip, /**< SCIP data structure */
2837  SCIP_CONS** conss, /**< constraint set */
2838  int nconss, /**< number of constraints in constraint set */
2839  int* nchgcoefs, /**< pointer to count the number of changed coefficients */
2840  int* nchgsides /**< pointer to count number of changed left/right hand sides */
2841  )
2842 {
2843  SCIP_CONSDATA* consdata;
2844  int c;
2845 
2846  assert(scip != NULL);
2847  assert(conss != NULL || nconss == 0);
2848  assert(nchgcoefs != NULL);
2849  assert(nchgsides != NULL);
2850 
2851  /* if we cannot find any constraint for prettifying, stop */
2852  if( SCIPgetNIntVars(scip) + SCIPgetNImplVars(scip) < 1 )
2853  return;
2854 
2855  for( c = nconss - 1; c >= 0; --c )
2856  {
2857  assert(conss != NULL);
2858 
2859  if( SCIPconsIsDeleted(conss[c]) )
2860  continue;
2861 
2862  consdata = SCIPconsGetData(conss[c]);
2863  assert(consdata != NULL);
2864 
2865  /* check for integer variables and one coefficient with an absolute value smaller than 1 */
2866  /* @note: we allow that the variable type of the bounded variable can be smaller than the variable type of the
2867  * bounding variable
2868  */
2869  if( (SCIPvarGetType(consdata->var) == SCIP_VARTYPE_BINARY || SCIPvarGetType(consdata->var) == SCIP_VARTYPE_INTEGER
2870  || SCIPvarGetType(consdata->var) == SCIP_VARTYPE_IMPLINT)
2871  && (SCIPvarGetType(consdata->vbdvar) == SCIP_VARTYPE_INTEGER || SCIPvarGetType(consdata->vbdvar) == SCIP_VARTYPE_IMPLINT)
2872  && SCIPisLT(scip, REALABS(consdata->vbdcoef), 1.0) )
2873  {
2874  SCIP_Real epsilon;
2875  SCIP_Longint nominator;
2876  SCIP_Longint denominator;
2877  SCIP_Longint maxmult;
2878  SCIP_Bool success;
2879 
2880  maxmult = (SCIP_Longint)(SCIPfeastol(scip)/SCIPepsilon(scip) + SCIPfeastol(scip));
2881  maxmult = MIN(maxmult, MAXSCALEDCOEF);
2882 
2883  /* this ensures that one coefficient in the scaled constraint will be one as asserted below; 0.9 to be safe */
2884  epsilon = SCIPepsilon(scip) / (SCIP_Real)maxmult;
2885  epsilon *= 0.9;
2886 
2887  success = SCIPrealToRational(consdata->vbdcoef, -epsilon, epsilon , maxmult, &nominator, &denominator);
2888 
2889  if( success )
2890  {
2891  /* it is possible that the dominator is a multiple of the nominator */
2892  if( SCIPisIntegral(scip, (SCIP_Real) denominator / (SCIP_Real) nominator) )
2893  {
2894  denominator /= nominator;
2895  nominator = 1;
2896  }
2897 
2898  success = success && (denominator <= maxmult);
2899 
2900  /* scale the constraint denominator/nominator */
2901  if( success && ABS(denominator) > 1 && nominator == 1 )
2902  {
2903  SCIP_VAR* swapvar;
2904 
2905  /* print constraint before scaling */
2906  SCIPdebugPrintCons(scip, conss[c], NULL);
2907 
2908  assert(SCIPisEQ(scip, consdata->vbdcoef * denominator, 1.0));
2909 
2910  /* need to switch sides if coefficient is smaller then 0 */
2911  if( consdata->vbdcoef < 0 )
2912  {
2913  assert(denominator < 0);
2914 
2915  /* compute new sides */
2916 
2917  /* only right hand side exists */
2918  if( SCIPisInfinity(scip, -consdata->lhs) )
2919  {
2920  consdata->lhs = consdata->rhs * denominator;
2921  assert(!SCIPisInfinity(scip, -consdata->lhs) && !SCIPisInfinity(scip, consdata->lhs));
2922 
2923  consdata->rhs = SCIPinfinity(scip);
2924  }
2925  /* only left hand side exists */
2926  else if( SCIPisInfinity(scip, consdata->rhs) )
2927  {
2928  consdata->rhs = consdata->lhs * denominator;
2929  assert(!SCIPisInfinity(scip, consdata->rhs) && !SCIPisInfinity(scip, -consdata->rhs));
2930 
2931  consdata->lhs = -SCIPinfinity(scip);
2932  }
2933  /* both sides exist */
2934  else
2935  {
2936  SCIP_Real tmp;
2937 
2938  tmp = consdata->lhs;
2939  consdata->lhs = consdata->rhs * denominator;
2940  consdata->rhs = tmp * denominator;
2941  consdata->tightened = FALSE;
2942 
2943  assert(!SCIPisInfinity(scip, consdata->lhs) && !SCIPisInfinity(scip, -consdata->lhs));
2944  assert(SCIPisGE(scip, consdata->rhs, consdata->lhs) && !SCIPisInfinity(scip, consdata->rhs));
2945  }
2946  *nchgsides += 2;
2947  }
2948  /* coefficient > 0 */
2949  else
2950  {
2951  assert(denominator > 0);
2952 
2953  /* compute new left hand side */
2954  if( !SCIPisInfinity(scip, -consdata->lhs) )
2955  {
2956  consdata->lhs *= denominator;
2957  assert(!SCIPisInfinity(scip, consdata->lhs) && !SCIPisInfinity(scip, -consdata->lhs));
2958  ++(*nchgsides);
2959  }
2960 
2961  /* compute new right hand side */
2962  if( !SCIPisInfinity(scip, consdata->rhs) )
2963  {
2964  consdata->rhs *= denominator;
2965  assert(!SCIPisInfinity(scip, consdata->rhs) && !SCIPisInfinity(scip, -consdata->rhs));
2966  ++(*nchgsides);
2967  }
2968 
2969  assert(SCIPisGE(scip, consdata->rhs, consdata->lhs));
2970  }
2971 
2972  /* swap both variables */
2973  swapvar = consdata->var;
2974  consdata->var = consdata->vbdvar;
2975  consdata->vbdvar = swapvar;
2976 
2977  /* swap coefficient */
2978  consdata->vbdcoef = (SCIP_Real)denominator;
2979  ++(*nchgcoefs);
2980 
2981  /* mark to add new varbound information */
2982  consdata->varboundsadded = FALSE;
2983  consdata->tightened = FALSE;
2984 
2985  /* print constraint after scaling */
2986  SCIPdebugMsg(scip, "transformed into:");
2987  SCIPdebugPrintCons(scip, conss[c], NULL);
2988  }
2989  }
2990  }
2991  }
2992 }
2993 
2994 /** replaces fixed and aggregated variables in variable bound constraint by active problem variables */
2995 static
2997  SCIP* scip, /**< SCIP data structure */
2998  SCIP_CONS* cons, /**< variable bound constraint */
2999  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
3000  SCIP_Bool* cutoff, /**< pointer to store whether an infeasibility was detected */
3001  int* nchgbds, /**< pointer to count number of bound changes */
3002  int* ndelconss, /**< pointer to count number of deleted constraints */
3003  int* naddconss /**< pointer to count number of added constraints */
3004  )
3005 {
3006  SCIP_CONSDATA* consdata;
3007  SCIP_VAR* var;
3008  SCIP_Real varscalar;
3009  SCIP_Real varconstant;
3010  SCIP_VAR* vbdvar;
3011  SCIP_Real vbdvarscalar;
3012  SCIP_Real vbdvarconstant;
3013  SCIP_Bool varschanged;
3014  SCIP_Bool redundant;
3015 
3016  assert(scip != NULL);
3017  assert(cons != NULL);
3018  assert(cutoff != NULL);
3019  assert(nchgbds != NULL);
3020  assert(ndelconss != NULL);
3021  assert(naddconss != NULL);
3022 
3023  *cutoff = FALSE;
3024  redundant = FALSE;
3025 
3026  /* the variable bound constraint is: lhs <= x + c*y <= rhs */
3027  consdata = SCIPconsGetData(cons);
3028  assert(consdata != NULL);
3029 
3030  /* get active problem variables of x and y */
3031  var = consdata->var;
3032  varscalar = 1.0;
3033  varconstant = 0.0;
3034  SCIP_CALL( SCIPgetProbvarSum(scip, &var, &varscalar, &varconstant) );
3035  vbdvar = consdata->vbdvar;
3036  vbdvarscalar = 1.0;
3037  vbdvarconstant = 0.0;
3038  SCIP_CALL( SCIPgetProbvarSum(scip, &vbdvar, &vbdvarscalar, &vbdvarconstant) );
3039  varschanged = (var != consdata->var || vbdvar != consdata->vbdvar);
3040 
3041  /* if the variables are equal, the variable bound constraint reduces to standard bounds on the single variable */
3042  if( var == vbdvar && SCIPvarGetStatus(var) != SCIP_VARSTATUS_MULTAGGR )
3043  {
3044  SCIP_Real scalar;
3045  SCIP_Real constant;
3046 
3047  SCIPdebugMsg(scip, "variable bound constraint <%s> has equal variable and vbd variable <%s>\n",
3048  SCIPconsGetName(cons), SCIPvarGetName(var));
3049 
3050  /* lhs <= a1*z + b1 + c(a2*z + b2) <= rhs
3051  * <=> lhs <= (a1 + c*a2)z + (b1 + c*b2) <= rhs
3052  */
3053  scalar = varscalar + consdata->vbdcoef * vbdvarscalar;
3054  constant = varconstant + consdata->vbdcoef * vbdvarconstant;
3055  if( SCIPisZero(scip, scalar) )
3056  {
3057  /* no variable is left: the constraint is redundant or infeasible */
3058  if( SCIPisFeasLT(scip, constant, consdata->lhs) || SCIPisFeasGT(scip, constant, consdata->rhs) )
3059  *cutoff = TRUE;
3060  }
3061  else if( scalar > 0.0 )
3062  {
3063  if( !SCIPisInfinity(scip, -consdata->lhs) && !(*cutoff) )
3064  {
3065  SCIP_Bool tightened;
3066 
3067  SCIP_CALL( SCIPtightenVarLb(scip, var, (consdata->lhs - constant)/scalar, TRUE, cutoff, &tightened) );
3068  if( tightened )
3069  {
3070  SCIPdebugMsg(scip, " -> tightened lower bound: <%s> >= %.15g\n", SCIPvarGetName(var), SCIPvarGetLbGlobal(var));
3071  (*nchgbds)++;
3072  }
3073  }
3074  if( !SCIPisInfinity(scip, consdata->rhs) && !(*cutoff) )
3075  {
3076  SCIP_Bool tightened;
3077 
3078  SCIP_CALL( SCIPtightenVarUb(scip, var, (consdata->rhs - constant)/scalar, TRUE, cutoff, &tightened) );
3079  if( tightened )
3080  {
3081  SCIPdebugMsg(scip, " -> tightened upper bound: <%s> <= %.15g\n", SCIPvarGetName(var), SCIPvarGetUbGlobal(var));
3082  (*nchgbds)++;
3083  }
3084  }
3085  }
3086  else
3087  {
3088  if( !SCIPisInfinity(scip, -consdata->lhs) && !(*cutoff) )
3089  {
3090  SCIP_Bool tightened;
3091 
3092  SCIP_CALL( SCIPtightenVarUb(scip, var, (consdata->lhs - constant)/scalar, TRUE, cutoff, &tightened) );
3093  if( tightened )
3094  {
3095  SCIPdebugMsg(scip, " -> tightened upper bound: <%s> <= %.15g\n", SCIPvarGetName(var), SCIPvarGetUbGlobal(var));
3096  (*nchgbds)++;
3097  }
3098  }
3099  if( !SCIPisInfinity(scip, consdata->rhs) && !(*cutoff) )
3100  {
3101  SCIP_Bool tightened;
3102 
3103  SCIP_CALL( SCIPtightenVarLb(scip, var, (consdata->rhs - constant)/scalar, TRUE, cutoff, &tightened) );
3104  if( tightened )
3105  {
3106  SCIPdebugMsg(scip, " -> tightened lower bound: <%s> >= %.15g\n", SCIPvarGetName(var), SCIPvarGetLbGlobal(var));
3107  (*nchgbds)++;
3108  }
3109  }
3110  }
3111  redundant = TRUE;
3112  }
3113  else
3114  {
3115  /* if the variables should be replaced, drop the events and catch the events on the new variables afterwards */
3116  if( varschanged )
3117  {
3118  SCIP_CALL( dropEvents(scip, cons, eventhdlr) );
3119  }
3120 
3121  /* apply aggregation on x */
3122  if( SCIPisZero(scip, varscalar) )
3123  {
3124  SCIPdebugMsg(scip, "variable bound constraint <%s>: variable <%s> is fixed to %.15g\n",
3125  SCIPconsGetName(cons), SCIPvarGetName(consdata->var), varconstant);
3126 
3127  /* cannot change bounds on multi-aggregated variables */
3128  if( SCIPvarGetStatus(vbdvar) != SCIP_VARSTATUS_MULTAGGR )
3129  {
3130  /* x is fixed to varconstant: update bounds of y and delete the variable bound constraint */
3131  if( !SCIPisInfinity(scip, -consdata->lhs) && !(*cutoff) )
3132  {
3133  if( consdata->vbdcoef > 0.0 )
3134  {
3135  SCIP_Bool tightened;
3136 
3137  SCIP_CALL( SCIPtightenVarLb(scip, consdata->vbdvar, (consdata->lhs - varconstant)/consdata->vbdcoef,
3138  TRUE, cutoff, &tightened) );
3139  if( tightened )
3140  {
3141  SCIPdebugMsg(scip, " -> tightened lower bound: <%s> >= %.15g\n", SCIPvarGetName(consdata->vbdvar), SCIPvarGetLbGlobal(consdata->vbdvar));
3142  (*nchgbds)++;
3143  }
3144  }
3145  else
3146  {
3147  SCIP_Bool tightened;
3148 
3149  SCIP_CALL( SCIPtightenVarUb(scip, consdata->vbdvar, (consdata->lhs - varconstant)/consdata->vbdcoef,
3150  TRUE, cutoff, &tightened) );
3151  if( tightened )
3152  {
3153  SCIPdebugMsg(scip, " -> tightened upper bound: <%s> <= %.15g\n", SCIPvarGetName(consdata->vbdvar), SCIPvarGetUbGlobal(consdata->vbdvar));
3154  (*nchgbds)++;
3155  }
3156  }
3157  }
3158  if( !SCIPisInfinity(scip, consdata->rhs) && !(*cutoff) )
3159  {
3160  if( consdata->vbdcoef > 0.0 )
3161  {
3162  SCIP_Bool tightened;
3163 
3164  SCIP_CALL( SCIPtightenVarUb(scip, consdata->vbdvar, (consdata->rhs - varconstant)/consdata->vbdcoef,
3165  TRUE, cutoff, &tightened) );
3166  if( tightened )
3167  {
3168  SCIPdebugMsg(scip, " -> tightened upper bound: <%s> <= %.15g\n", SCIPvarGetName(consdata->vbdvar), SCIPvarGetUbGlobal(consdata->vbdvar));
3169  (*nchgbds)++;
3170  }
3171  }
3172  else
3173  {
3174  SCIP_Bool tightened;
3175 
3176  SCIP_CALL( SCIPtightenVarLb(scip, consdata->vbdvar, (consdata->rhs - varconstant)/consdata->vbdcoef,
3177  TRUE, cutoff, &tightened) );
3178  if( tightened )
3179  {
3180  SCIPdebugMsg(scip, " -> tightened lower bound: <%s> >= %.15g\n", SCIPvarGetName(consdata->vbdvar), SCIPvarGetLbGlobal(consdata->vbdvar));
3181  (*nchgbds)++;
3182  }
3183  }
3184  }
3185  redundant = TRUE;
3186  }
3187  }
3188  else if( var != consdata->var )
3189  {
3190  /* release and unlock old variable */
3191  SCIP_CALL( SCIPunlockVarCons(scip, consdata->var, cons, !SCIPisInfinity(scip, -consdata->lhs),
3192  !SCIPisInfinity(scip, consdata->rhs)) );
3193  SCIP_CALL( SCIPreleaseVar(scip, &(consdata->var)) );
3194 
3195  /* replace aggregated variable x in the constraint by its aggregation */
3196  if( varscalar > 0.0 )
3197  {
3198  /* lhs := (lhs - varconstant) / varscalar
3199  * rhs := (rhs - varconstant) / varscalar
3200  * c := c / varscalar
3201  */
3202  if( !SCIPisInfinity(scip, -consdata->lhs) )
3203  consdata->lhs = (consdata->lhs - varconstant)/varscalar;
3204  if( !SCIPisInfinity(scip, consdata->rhs) )
3205  consdata->rhs = (consdata->rhs - varconstant)/varscalar;
3206  consdata->vbdcoef /= varscalar;
3207 
3208  /* try to avoid numerical troubles */
3209  if( SCIPisIntegral(scip, consdata->vbdcoef) )
3210  consdata->vbdcoef = SCIPround(scip, consdata->vbdcoef);
3211 
3212  consdata->tightened = FALSE;
3213  }
3214  else
3215  {
3216  SCIP_Real lhs;
3217 
3218  assert(varscalar != 0.0);
3219 
3220  /* lhs := (rhs - varconstant) / varscalar
3221  * rhs := (lhs - varconstant) / varscalar
3222  * c := c / varscalar
3223  */
3224  lhs = consdata->lhs;
3225  consdata->lhs = -consdata->rhs;
3226  consdata->rhs = -lhs;
3227  if( !SCIPisInfinity(scip, -consdata->lhs) )
3228  consdata->lhs = (consdata->lhs + varconstant)/(-varscalar);
3229  if( !SCIPisInfinity(scip, consdata->rhs) )
3230  consdata->rhs = (consdata->rhs + varconstant)/(-varscalar);
3231  consdata->vbdcoef /= varscalar;
3232 
3233  /* try to avoid numerical troubles */
3234  if( SCIPisIntegral(scip, consdata->vbdcoef) )
3235  consdata->vbdcoef = SCIPround(scip, consdata->vbdcoef);
3236 
3237  consdata->tightened = FALSE;
3238  }
3239 
3240  consdata->var = var;
3241 
3242  /* capture and lock new variable */
3243  SCIP_CALL( SCIPcaptureVar(scip, consdata->var) );
3244  SCIP_CALL( SCIPlockVarCons(scip, consdata->var, cons, !SCIPisInfinity(scip, -consdata->lhs),
3245  !SCIPisInfinity(scip, consdata->rhs)) );
3246  }
3247 
3248  /* apply aggregation on y */
3249  if( SCIPisZero(scip, vbdvarscalar) )
3250  {
3251  SCIPdebugMsg(scip, "variable bound constraint <%s>: vbd variable <%s> is fixed to %.15g\n",
3252  SCIPconsGetName(cons), SCIPvarGetName(consdata->vbdvar), vbdvarconstant);
3253 
3254  /* cannot change bounds on multi-aggregated variables */
3256  {
3257  /* y is fixed to vbdvarconstant: update bounds of x and delete the variable bound constraint */
3258  if( !SCIPisInfinity(scip, -consdata->lhs) && !(*cutoff) )
3259  {
3260  SCIP_Bool tightened;
3261 
3262  SCIP_CALL( SCIPtightenVarLb(scip, consdata->var, consdata->lhs - consdata->vbdcoef * vbdvarconstant,
3263  TRUE, cutoff, &tightened) );
3264  if( tightened )
3265  {
3266  SCIPdebugMsg(scip, " -> tightened lower bound: <%s> >= %.15g\n", SCIPvarGetName(consdata->var), SCIPvarGetLbGlobal(consdata->var));
3267  (*nchgbds)++;
3268  }
3269  }
3270  if( !SCIPisInfinity(scip, consdata->rhs) && !(*cutoff) )
3271  {
3272  SCIP_Bool tightened;
3273 
3274  SCIP_CALL( SCIPtightenVarUb(scip, consdata->var, consdata->rhs - consdata->vbdcoef * vbdvarconstant,
3275  TRUE, cutoff, &tightened) );
3276  if( tightened )
3277  {
3278  SCIPdebugMsg(scip, " -> tightened upper bound: <%s> <= %.15g\n", SCIPvarGetName(consdata->var), SCIPvarGetUbGlobal(consdata->var));
3279  (*nchgbds)++;
3280  }
3281  }
3282  redundant = TRUE;
3283  }
3284  }
3285  else if( vbdvar != consdata->vbdvar )
3286  {
3287  /* replace aggregated variable y in the constraint by its aggregation:
3288  * lhs := lhs - c * vbdvarconstant
3289  * rhs := rhs - c * vbdvarconstant
3290  * c := c * vbdvarscalar
3291  */
3292  if( !SCIPisInfinity(scip, -consdata->lhs) )
3293  consdata->lhs -= consdata->vbdcoef * vbdvarconstant;
3294  if( !SCIPisInfinity(scip, consdata->rhs) )
3295  consdata->rhs -= consdata->vbdcoef * vbdvarconstant;
3296 
3297  consdata->tightened = FALSE;
3298 
3299  /* release and unlock old variable */
3300  if( SCIPisPositive(scip, consdata->vbdcoef) )
3301  {
3302  SCIP_CALL( SCIPunlockVarCons(scip, consdata->vbdvar, cons, !SCIPisInfinity(scip, -consdata->lhs),
3303  !SCIPisInfinity(scip, consdata->rhs)) );
3304  }
3305  else
3306  {
3307  SCIP_CALL( SCIPunlockVarCons(scip, consdata->vbdvar, cons, !SCIPisInfinity(scip, consdata->rhs),
3308  !SCIPisInfinity(scip, -consdata->lhs)) );
3309  }
3310  SCIP_CALL( SCIPreleaseVar(scip, &(consdata->vbdvar)) );
3311 
3312  consdata->vbdcoef *= vbdvarscalar;
3313  consdata->vbdvar = vbdvar;
3314 
3315  /* capture and lock new variable */
3316  SCIP_CALL( SCIPcaptureVar(scip, consdata->vbdvar) );
3317  if( SCIPisPositive(scip, consdata->vbdcoef) )
3318  {
3319  SCIP_CALL( SCIPlockVarCons(scip, consdata->vbdvar, cons, !SCIPisInfinity(scip, -consdata->lhs),
3320  !SCIPisInfinity(scip, consdata->rhs)) );
3321  }
3322  else
3323  {
3324  SCIP_CALL( SCIPlockVarCons(scip, consdata->vbdvar, cons, !SCIPisInfinity(scip, consdata->rhs),
3325  !SCIPisInfinity(scip, -consdata->lhs)) );
3326  }
3327  }
3328 
3329  /* catch the events again on the new variables */
3330  if( varschanged )
3331  {
3332  SCIP_CALL( catchEvents(scip, cons, eventhdlr) );
3333  }
3334  }
3335 
3336  /* mark constraint changed, if a variable was exchanged */
3337  if( varschanged )
3338  {
3339  consdata->changed = TRUE;
3340  }
3341 
3342  /* active multi aggregations are now resolved by creating a new linear constraint */
3343  if( !(*cutoff) && !redundant && (SCIPvarGetStatus(var) == SCIP_VARSTATUS_MULTAGGR || SCIPvarGetStatus(vbdvar) == SCIP_VARSTATUS_MULTAGGR) )
3344  {
3345  SCIP_CONS* newcons;
3346  SCIP_Real lhs;
3347  SCIP_Real rhs;
3348 
3349  lhs = consdata->lhs;
3350  rhs = consdata->rhs;
3351 
3352  /* create upgraded linear constraint */
3353  SCIP_CALL( SCIPcreateConsLinear(scip, &newcons, SCIPconsGetName(cons), 0, NULL, NULL, lhs, rhs,
3358 
3359  /* if var was fixed, then the case that vbdvar was multi-aggregated, was not yet resolved */
3360  if( var != consdata->var )
3361  {
3362  assert(SCIPvarGetStatus(vbdvar) == SCIP_VARSTATUS_MULTAGGR);
3363  assert(SCIPisZero(scip, varscalar)); /* this means that var was fixed */
3364 
3365  /* add offset that results from the fixed variable */
3366  if( ! SCIPisZero(scip, varconstant) )
3367  {
3368  if( !SCIPisInfinity(scip, rhs) )
3369  {
3370  SCIP_CALL( SCIPchgRhsLinear(scip, newcons, rhs - varconstant) );
3371  }
3372  if( !SCIPisInfinity(scip, -lhs) )
3373  {
3374  SCIP_CALL( SCIPchgLhsLinear(scip, newcons, lhs - varconstant) );
3375  }
3376  }
3377  }
3378  else
3379  {
3380  assert(var == consdata->var);
3381 
3382  SCIP_CALL( SCIPaddCoefLinear(scip, newcons, consdata->var, 1.0) );
3383  }
3384 
3385  /* if vbdvar was fixed, then the case that var was multi-aggregated, was not yet resolved */
3386  if( vbdvar != consdata->vbdvar )
3387  {
3388  assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_MULTAGGR);
3389  assert(SCIPisZero(scip, vbdvarscalar)); /* this means that var was fixed */
3390 
3391  /* add offset that results from the fixed variable */
3392  if( ! SCIPisZero(scip, vbdvarconstant) )
3393  {
3394  if( !SCIPisInfinity(scip, rhs) )
3395  {
3396  SCIP_CALL( SCIPchgRhsLinear(scip, newcons, rhs - consdata->vbdcoef * vbdvarconstant) );
3397  }
3398  if( !SCIPisInfinity(scip, -lhs) )
3399  {
3400  SCIP_CALL( SCIPchgLhsLinear(scip, newcons, lhs - consdata->vbdcoef * vbdvarconstant) );
3401  }
3402  }
3403  }
3404  else
3405  {
3406  assert(vbdvar == consdata->vbdvar);
3407 
3408  SCIP_CALL( SCIPaddCoefLinear(scip, newcons, consdata->vbdvar, consdata->vbdcoef) );
3409  }
3410 
3411  SCIP_CALL( SCIPaddCons(scip, newcons) );
3412 
3413  SCIPdebugMsg(scip, "resolved multi aggregation in varbound constraint <%s> by creating a new linear constraint\n", SCIPconsGetName(cons));
3414  SCIPdebugPrintCons(scip, newcons, NULL);
3415 
3416  SCIP_CALL( SCIPreleaseCons(scip, &newcons) );
3417 
3418  redundant = TRUE;
3419  ++(*naddconss);
3420  }
3421 
3422  /* delete a redundant constraint */
3423  if( !(*cutoff) && redundant )
3424  {
3425  SCIPdebugMsg(scip, " -> variable bound constraint <%s> is redundant\n", SCIPconsGetName(cons));
3426  SCIP_CALL( SCIPdelCons(scip, cons) );
3427  (*ndelconss)++;
3428  }
3429 
3430  return SCIP_OKAY;
3431 }
3432 
3433 /** tightens variable bound coefficient by inspecting the global bounds of the involved variables; note: this is also
3434  * performed by the linear constraint handler - only necessary if the user directly creates variable bound constraints
3435  */
3436 static
3438  SCIP* scip, /**< SCIP data structure */
3439  SCIP_CONS* cons, /**< variable bound constraint */
3440  int* nchgcoefs, /**< pointer to count the number of changed coefficients */
3441  int* nchgsides, /**< pointer to count the number of left and right hand sides */
3442  int* ndelconss, /**< pointer to count number of deleted constraints */
3443  SCIP_Bool* cutoff, /**< pointer to store whether the node can be cut off */
3444  int* nchgbds /**< pointer to count number of bound changes */
3445  )
3446 {
3447  SCIP_CONSDATA* consdata;
3448  SCIP_Real xlb;
3449  SCIP_Real xub;
3450  SCIP_Real oldcoef;
3451  int oldnchgcoefs;
3452  int oldnchgsides;
3453 
3454  assert(nchgcoefs != NULL);
3455  assert(nchgsides != NULL);
3456  assert(ndelconss != NULL);
3457 
3458  consdata = SCIPconsGetData(cons);
3459  assert(consdata != NULL);
3460 
3461  /* tightening already done */
3462  if( consdata->tightened )
3463  return SCIP_OKAY;
3464 
3465  SCIPdebugMsg(scip, "tightening coefficients on variable bound constraint <%s>\n", SCIPconsGetName(cons));
3466 
3467  consdata->tightened = TRUE;
3468 
3469  /* if values and variable are integral the sides should it be too */
3470  if( SCIPvarGetType(consdata->var) <= SCIP_VARTYPE_IMPLINT
3471  && SCIPvarGetType(consdata->vbdvar) <= SCIP_VARTYPE_IMPLINT
3472  && SCIPisIntegral(scip, consdata->vbdcoef) )
3473  {
3474  if( !SCIPisIntegral(scip, consdata->lhs) )
3475  {
3476  consdata->lhs = SCIPfeasCeil(scip, consdata->lhs);
3477  ++(*nchgsides);
3478  consdata->changed = TRUE;
3479  }
3480  if( !SCIPisIntegral(scip, consdata->rhs) )
3481  {
3482  consdata->rhs = SCIPfeasFloor(scip, consdata->rhs);
3483  ++(*nchgsides);
3484  consdata->changed = TRUE;
3485  }
3486  }
3487 
3488  /* coefficient tightening only works for binary bound variable */
3489  if( !SCIPvarIsBinary(consdata->vbdvar) )
3490  return SCIP_OKAY;
3491 
3492  oldnchgcoefs = *nchgcoefs;
3493  oldnchgsides = *nchgsides;
3494  oldcoef = consdata->vbdcoef;
3495 
3496  /* coefficients tightening when all variables are integer */
3497  /* we consider the following varbound constraint: lhs <= x + b*y <= rhs (sides are possibly infinity)
3498  * y should always be binary and x of integral type and b not integral, we also need at least one side with infinity
3499  * or not integral value.
3500  *
3501  * 1. if( (lhs is integral and not -infinity) and ((rhs is infinity) or (b - floor(b) <= rhs - floor(rhs))) ):
3502  *
3503  * lhs <= x + b*y <= rhs => lhs <= x + floor(b)*y <= floor(rhs)
3504  *
3505  * 2. if( (rhs is integral and not infinity) and ((lhs is -infinity) or (b - floor(b) >= lhs - floor(lhs))) ):
3506  *
3507  * lhs <= x + b*y <= rhs => ceil(lhs) <= x + ceil(b)*y <= rhs
3508  *
3509  * 3. if( ((lhs is -infinity) or (b - floor(b) >= lhs - floor(lhs)))
3510  * and ((rhs is infinity) or (b - floor(b) > rhs - floor(rhs))) ):
3511  *
3512  * lhs <= x + b*y <= rhs => ceil(lhs) <= x + ceil(b)*y <= floor(rhs)
3513  *
3514  * 4. if( ((lhs is -infinity) or (b - floor(b) < lhs - floor(lhs)))
3515  * and ((rhs is infinity) or (b - floor(b) <= rhs - floor(rhs))) ):
3516  *
3517  * lhs <= x + b*y <= rhs => ceil(lhs) <= x + floor(b)*y <= floor(rhs)
3518  *
3519  * 5. if( (lhs is not integral) or (rhs is not integral) )
3520  *
3521  * if (lhs is not -infinity)
3522  * if (b - floor(b) < lhs - floor(lhs)):
3523  *
3524  * lhs <= x + b*y => ceil(lhs) <= x + b*y
3525  *
3526  * else if (b - floor(b) > lhs - floor(lhs)):
3527  *
3528  * lhs <= x + b*y => floor(lhs) + b - floor(b) <= x + b*y
3529  *
3530  * if (rhs is not infinity)
3531  * if (b - floor(b) < rhs - floor(rhs)):
3532  *
3533  * x + b*y <= rhs => x + b*y <= floor(rhs) + b - floor(b)
3534  *
3535  * else if (b - floor(b) > rhs - floor(rhs)):
3536  *
3537  * x + b*y <= rhs => x + b*y <= floor(rhs)
3538  */
3539  if( (SCIPvarGetType(consdata->var) == SCIP_VARTYPE_INTEGER || SCIPvarGetType(consdata->var) == SCIP_VARTYPE_IMPLINT || SCIPvarGetType(consdata->var) == SCIP_VARTYPE_BINARY)
3540  && !SCIPisIntegral(scip, consdata->vbdcoef)
3541  && (!SCIPisIntegral(scip, consdata->lhs) || SCIPisInfinity(scip, -consdata->lhs)
3542  || !SCIPisIntegral(scip, consdata->rhs) || SCIPisInfinity(scip, consdata->rhs)) )
3543  {
3544  /* infinity should be an integral value */
3545  assert(!SCIPisInfinity(scip, -consdata->lhs) || SCIPisIntegral(scip, consdata->lhs));
3546  assert(!SCIPisInfinity(scip, consdata->rhs) || SCIPisIntegral(scip, consdata->rhs));
3547 
3548  /* should not be a redundant constraint */
3549  assert(!SCIPisInfinity(scip, consdata->rhs) || !SCIPisInfinity(scip, -consdata->lhs));
3550 
3551  /* case 1 */
3552  if( SCIPisIntegral(scip, consdata->lhs) && !SCIPisInfinity(scip, -consdata->lhs) &&
3553  (SCIPisInfinity(scip, consdata->rhs) || SCIPisFeasLE(scip, consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef), consdata->rhs - SCIPfeasFloor(scip, consdata->rhs))) )
3554  {
3555  consdata->vbdcoef = SCIPfeasFloor(scip, consdata->vbdcoef);
3556  ++(*nchgcoefs);
3557 
3558  if( !SCIPisInfinity(scip, consdata->rhs) )
3559  {
3560  consdata->rhs = SCIPfeasFloor(scip, consdata->rhs);
3561  ++(*nchgsides);
3562  }
3563  }
3564  /* case 2 */
3565  else if( SCIPisIntegral(scip, consdata->rhs) && !SCIPisInfinity(scip, consdata->rhs) &&
3566  (SCIPisInfinity(scip, -consdata->lhs) || SCIPisFeasGE(scip, consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef), consdata->lhs - SCIPfeasFloor(scip, consdata->lhs))) )
3567 
3568  {
3569  consdata->vbdcoef = SCIPfeasCeil(scip, consdata->vbdcoef);
3570  ++(*nchgcoefs);
3571 
3572  if( !SCIPisInfinity(scip, -consdata->lhs) )
3573  {
3574  if( !SCIPisIntegral(scip, consdata->lhs) )
3575  ++(*nchgsides);
3576 
3577  consdata->lhs = SCIPfeasCeil(scip, consdata->lhs);
3578  }
3579  }
3580  /* case 3 */
3581  else if( (SCIPisInfinity(scip, -consdata->lhs) || SCIPisFeasGE(scip, consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef), consdata->lhs - SCIPfeasFloor(scip, consdata->lhs))) && (SCIPisInfinity(scip, consdata->rhs) || SCIPisFeasGT(scip, consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef), consdata->rhs - SCIPfeasFloor(scip, consdata->rhs))) )
3582  {
3583  consdata->vbdcoef = SCIPfeasCeil(scip, consdata->vbdcoef);
3584  ++(*nchgcoefs);
3585 
3586  if( !SCIPisInfinity(scip, -consdata->lhs) )
3587  {
3588  if( !SCIPisIntegral(scip, consdata->lhs) )
3589  ++(*nchgsides);
3590 
3591  consdata->lhs = SCIPfeasCeil(scip, consdata->lhs);
3592  }
3593  if( !SCIPisInfinity(scip, consdata->rhs) )
3594  {
3595  if( !SCIPisIntegral(scip, consdata->rhs) )
3596  ++(*nchgsides);
3597 
3598  consdata->rhs = SCIPfeasFloor(scip, consdata->rhs);
3599  }
3600  }
3601  /* case 4 */
3602  else if( (SCIPisInfinity(scip, -consdata->lhs) || SCIPisFeasLT(scip, consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef), consdata->lhs - SCIPfeasFloor(scip, consdata->lhs))) && (SCIPisInfinity(scip, consdata->rhs) || SCIPisFeasLE(scip, consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef), consdata->rhs - SCIPfeasFloor(scip, consdata->rhs))) )
3603  {
3604  consdata->vbdcoef = SCIPfeasFloor(scip, consdata->vbdcoef);
3605  ++(*nchgcoefs);
3606 
3607  if( !SCIPisInfinity(scip, -consdata->lhs) )
3608  {
3609  if( !SCIPisIntegral(scip, consdata->lhs) )
3610  ++(*nchgsides);
3611 
3612  consdata->lhs = SCIPfeasCeil(scip, consdata->lhs);
3613  }
3614  if( !SCIPisInfinity(scip, consdata->rhs) )
3615  {
3616  if( !SCIPisIntegral(scip, consdata->rhs) )
3617  ++(*nchgsides);
3618 
3619  consdata->rhs = SCIPfeasFloor(scip, consdata->rhs);
3620  }
3621  }
3622  /* case 5 */
3623  if( !SCIPisFeasIntegral(scip, consdata->lhs) || !SCIPisFeasIntegral(scip, consdata->rhs) )
3624  {
3625  if( !SCIPisInfinity(scip, -consdata->lhs) )
3626  {
3627  if( SCIPisFeasLT(scip, consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef), consdata->lhs - SCIPfeasFloor(scip, consdata->lhs)) )
3628  {
3629  consdata->lhs = SCIPfeasCeil(scip, consdata->lhs);
3630  ++(*nchgsides);
3631  }
3632  else if( SCIPisFeasGT(scip, consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef), consdata->lhs - SCIPfeasFloor(scip, consdata->lhs)) )
3633  {
3634  consdata->lhs = SCIPfeasFloor(scip, consdata->lhs) + (consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef));
3635  ++(*nchgsides);
3636  }
3637  }
3638  if( !SCIPisInfinity(scip, consdata->rhs) )
3639  {
3640  if( SCIPisFeasLT(scip, consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef), consdata->rhs - SCIPfeasFloor(scip, consdata->rhs)) )
3641  {
3642  consdata->rhs = SCIPfeasFloor(scip, consdata->rhs) + (consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef));
3643  ++(*nchgsides);
3644  }
3645  else if( SCIPisFeasGT(scip, consdata->vbdcoef - SCIPfeasFloor(scip, consdata->vbdcoef), consdata->rhs - SCIPfeasFloor(scip, consdata->rhs)) )
3646  {
3647  consdata->rhs = SCIPfeasFloor(scip, consdata->rhs);
3648  ++(*nchgsides);
3649  }
3650  }
3651  }
3652  }
3653 
3654  /* check if due to tightening the constraint got redundant */
3655  if( SCIPisZero(scip, consdata->vbdcoef) )
3656  {
3657  /* we have to make sure that the induced bound(s) is (are) actually applied;
3658  * if the relative change is too small, this may have been skipped in propagation
3659  */
3660  if( SCIPisLT(scip, SCIPvarGetLbGlobal(consdata->var), consdata->lhs) )
3661  {
3662  SCIP_Bool tightened;
3663 
3664  SCIP_CALL( SCIPtightenVarLbGlobal(scip, consdata->var, consdata->lhs, TRUE, cutoff, &tightened) );
3665 
3666  if( tightened )
3667  {
3668  SCIPdebugMsg(scip, " -> tighten domain of <%s> to [%.15g,%.15g]\n", SCIPvarGetName(consdata->var),
3669  SCIPvarGetLbGlobal(consdata->var), SCIPvarGetUbGlobal(consdata->var));
3670  (*nchgbds)++;
3671  }
3672  }
3673  if( SCIPisGT(scip, SCIPvarGetUbGlobal(consdata->var), consdata->rhs) )
3674  {
3675  SCIP_Bool tightened;
3676 
3677  SCIP_CALL( SCIPtightenVarUbGlobal(scip, consdata->var, consdata->rhs, TRUE, cutoff, &tightened) );
3678 
3679  if( tightened )
3680  {
3681  SCIPdebugMsg(scip, " -> tighten domain of <%s> to [%.15g,%.15g]\n", SCIPvarGetName(consdata->var),
3682  SCIPvarGetLbGlobal(consdata->var), SCIPvarGetUbGlobal(consdata->var));
3683  (*nchgbds)++;
3684  }
3685  }
3686 
3687  SCIPdebugMsg(scip, " -> variable bound constraint <%s> is redundant\n", SCIPconsGetName(cons));
3688 
3689  /* in order to correctly update the rounding locks, we need the coefficient to have the same sign as before the
3690  * coefficient tightening
3691  */
3692  consdata->vbdcoef = oldcoef;
3693 
3694  SCIP_CALL( SCIPdelCons(scip, cons) );
3695  ++(*ndelconss);
3696 
3697  return SCIP_OKAY;
3698  }
3699 
3700  /* get bounds of variable x */
3701  xlb = SCIPvarGetLbGlobal(consdata->var);
3702  xub = SCIPvarGetUbGlobal(consdata->var);
3703 
3704  /* it can happen that var is not of varstatus SCIP_VARSTATUS_FIXED but the bounds are equal, in this case we need to
3705  * stop
3706  */
3707  if( SCIPisEQ(scip, xlb, xub) )
3708  return SCIP_OKAY;
3709 
3710  /* modification of coefficient checking for slack in constraints */
3711  if( !SCIPisInfinity(scip, -consdata->lhs) && !SCIPisInfinity(scip, consdata->rhs) )
3712  {
3713  /* lhs <= x + c*y <= rhs => lhs - c*y <= x <= rhs - c*y */
3714  if( consdata->vbdcoef > 0.0 && SCIPisFeasGT(scip, xlb, consdata->lhs - consdata->vbdcoef) && SCIPisFeasLT(scip, xub, consdata->rhs) )
3715  {
3716  SCIP_Real newcoef;
3717  SCIP_Real newrhs;
3718  SCIP_Real oldrhs;
3719 
3720  oldrhs = consdata->rhs;
3721 
3722  /* constraint has positive slack for both non-restricting cases y = 0, or y = 1, respectively
3723  * -> modify coefficients such that constraint is tight in at least one of the non-restricting cases
3724  * -> c' = MAX(c - rhs + xub, lhs - xlb), rhs' = rhs - c + c'
3725  */
3726  newcoef = MAX(consdata->vbdcoef - consdata->rhs + xub, consdata->lhs - xlb);
3727 
3728  /* in this case both sides are redundant and the constraint can be removed */
3729  if( SCIPisLE(scip, newcoef, 0.0) )
3730  {
3731  assert(SCIPisFeasGE(scip, xlb, consdata->lhs) && SCIPisFeasGE(scip, xlb + consdata->vbdcoef, consdata->lhs));
3732  assert(SCIPisFeasLE(scip, xub, consdata->rhs) && SCIPisFeasLE(scip, xub + consdata->vbdcoef, consdata->rhs));
3733 
3734  SCIPdebugMsg(scip, "delete cons <%s>\n", SCIPconsGetName(cons));
3735  SCIP_CALL( SCIPdelCons(scip, cons) );
3736  ++(*ndelconss);
3737  }
3738  else
3739  {
3740  newrhs = consdata->rhs - consdata->vbdcoef + newcoef;
3741 
3742  SCIPdebugMsg(scip,
3743  "tighten varbound %.15g <= <%s>[%.15g,%.15g] %+.15g<%s> <= %.15g to %.15g <= <%s> %+.15g<%s> <= %.15g\n",
3744  consdata->lhs, SCIPvarGetName(consdata->var), xlb, xub, consdata->vbdcoef,
3745  SCIPvarGetName(consdata->vbdvar), consdata->rhs,
3746  consdata->lhs, SCIPvarGetName(consdata->var), newcoef, SCIPvarGetName(consdata->vbdvar),
3747  newrhs);
3748 
3749  /* we cannot allow that the coefficient changes the sign because of the rounding locks */
3750  assert(consdata->vbdcoef * newcoef > 0);
3751 
3752  consdata->vbdcoef = newcoef;
3753  consdata->rhs = MAX(newrhs, consdata->lhs);
3754  (*nchgcoefs)++;
3755  (*nchgsides)++;
3756 
3757  /* some of the cases 1. to 5. might be applicable after changing the rhs to an integral value; one example is
3758  * the varbound constraint 0.225 <= x - 1.225 y <= 0.775 for which none of the above cases apply but after
3759  * tightening the lhs to 0.0 it is possible to reduce the rhs by applying the 1. reduction
3760  */
3761  if( !SCIPisFeasIntegral(scip, oldrhs) && SCIPisFeasIntegral(scip, newrhs))
3762  {
3763  consdata->tightened = FALSE;
3764  SCIP_CALL(tightenCoefs(scip, cons, nchgcoefs, nchgsides, ndelconss, cutoff, nchgbds));
3765  assert(consdata->tightened);
3766  }
3767  else
3768  consdata->tightened = (SCIPisIntegral(scip, consdata->vbdcoef) && SCIPisIntegral(scip, consdata->rhs));
3769  }
3770  }
3771  else if( consdata->vbdcoef < 0.0 && SCIPisFeasGT(scip, xlb, consdata->lhs) && SCIPisFeasLT(scip, xub, consdata->rhs - consdata->vbdcoef) )
3772  {
3773  SCIP_Real newcoef;
3774  SCIP_Real newlhs;
3775  SCIP_Real oldlhs;
3776 
3777  oldlhs = consdata->lhs;
3778 
3779  /* constraint has positive slack for both non-restricting cases y = 0, or y = 1, respectively
3780  * -> modify coefficients such that constraint is tight in at least one of the non-restricting cases
3781  * -> c' = MIN(c - lhs + xlb, rhs - xub), lhs' = lhs - c + c'
3782  */
3783  newcoef = MIN(consdata->vbdcoef - consdata->lhs + xlb, consdata->rhs - xub);
3784 
3785  /* in this case both sides are redundant and the constraint can be removed */
3786  if( SCIPisGE(scip, newcoef, 0.0) )
3787  {
3788  assert(SCIPisFeasGE(scip, xlb, consdata->lhs) && SCIPisFeasGE(scip, xlb + consdata->vbdcoef, consdata->lhs));
3789  assert(SCIPisFeasLE(scip, xub, consdata->rhs) && SCIPisFeasLE(scip, xub + consdata->vbdcoef, consdata->rhs));
3790 
3791  SCIPdebugMsg(scip, "delete cons <%s>\n", SCIPconsGetName(cons));
3792  SCIP_CALL( SCIPdelCons(scip, cons) );
3793  ++(*ndelconss);
3794  }
3795  else
3796  {
3797  newlhs = consdata->lhs - consdata->vbdcoef + newcoef;
3798 
3799  SCIPdebugMsg(scip,
3800  "tighten varbound %.15g <= <%s>[%.15g,%.15g] %+.15g<%s> <= %.15g to %.15g <= <%s> %+.15g<%s> <= %.15g\n",
3801  consdata->lhs, SCIPvarGetName(consdata->var), xlb, xub, consdata->vbdcoef,
3802  SCIPvarGetName(consdata->vbdvar), consdata->rhs,
3803  newlhs, SCIPvarGetName(consdata->var), newcoef, SCIPvarGetName(consdata->vbdvar),
3804  consdata->rhs);
3805 
3806  /* we cannot allow that the coefficient changes the sign because of the rounding locks */
3807  assert(consdata->vbdcoef * newcoef > 0);
3808 
3809  consdata->vbdcoef = newcoef;
3810  consdata->lhs = MIN(newlhs, consdata->rhs);
3811  (*nchgcoefs)++;
3812  (*nchgsides)++;
3813 
3814  /* some of the cases 1. to 5. might be applicable after changing the rhs to an integral value; one example is
3815  * the varbound constraint 0.225 <= x - 1.225 y <= 0.775 for which none of the above cases apply but after
3816  * tightening the lhs to 0.0 it is possible to reduce the rhs by applying the 1. reduction
3817  */
3818  if( !SCIPisFeasIntegral(scip, oldlhs) && SCIPisFeasIntegral(scip, newlhs))
3819  {
3820  consdata->tightened = FALSE;
3821  SCIP_CALL(tightenCoefs(scip, cons, nchgcoefs, nchgsides, ndelconss, cutoff, nchgbds));
3822  assert(consdata->tightened);
3823  }
3824  else
3825  consdata->tightened = (SCIPisIntegral(scip, consdata->vbdcoef) && SCIPisIntegral(scip, consdata->lhs));
3826  }
3827  }
3828  }
3829  else if( !SCIPisInfinity(scip, -consdata->lhs) && SCIPisInfinity(scip, consdata->rhs) )
3830  {
3831  /* lhs <= x + c*y => x >= lhs - c*y */
3832  if( consdata->vbdcoef > 0.0 && SCIPisFeasGT(scip, xlb, consdata->lhs - consdata->vbdcoef) )
3833  {
3834  SCIP_Real newcoef;
3835 
3836  /* constraint has positive slack for the non-restricting case y = 1
3837  * -> modify coefficients such that constraint is tight in the non-restricting case y = 1 and equivalent in the restricting case y = 0
3838  * -> c' = lhs - xlb
3839  */
3840  newcoef = consdata->lhs - xlb;
3841 
3842  /* in this case the constraint is redundant and can be removed */
3843  if( SCIPisLE(scip, newcoef, 0.0) )
3844  {
3845  assert(SCIPisFeasGE(scip, xlb, consdata->lhs) && SCIPisFeasGE(scip, xlb + consdata->vbdcoef, consdata->lhs));
3846 
3847  SCIPdebugMsg(scip, "delete cons <%s>\n", SCIPconsGetName(cons));
3848  SCIP_CALL( SCIPdelCons(scip, cons) );
3849  ++(*ndelconss);
3850  }
3851  else
3852  {
3853  SCIPdebugMsg(scip, "tighten binary VLB <%s>[%.15g,%.15g] %+.15g<%s> >= %.15g to <%s> %+.15g<%s> >= %.15g\n",
3854  SCIPvarGetName(consdata->var), xlb, xub, consdata->vbdcoef, SCIPvarGetName(consdata->vbdvar),
3855  consdata->lhs,
3856  SCIPvarGetName(consdata->var), consdata->lhs - xlb, SCIPvarGetName(consdata->vbdvar),
3857  consdata->lhs);
3858 
3859  /* we cannot allow that the coefficient changes the sign because of the rounding locks */
3860  assert(consdata->vbdcoef * newcoef > 0);
3861 
3862  consdata->vbdcoef = newcoef;
3863  (*nchgcoefs)++;
3864  }
3865  }
3866  else if( consdata->vbdcoef < 0.0 && SCIPisFeasGT(scip, xlb, consdata->lhs) )
3867  {
3868  SCIP_Real newcoef;
3869 
3870  /* constraint has positive slack for the non-restricting case y = 0
3871  * -> modify coefficients such that constraint is tight in the non-restricting case y = 0 and equivalent in the restricting case y = 1
3872  * -> c' = c - lhs + xlb, lhs' = xlb
3873  */
3874  newcoef = consdata->vbdcoef - consdata->lhs + xlb;
3875 
3876  /* in this case the constraint is redundant and can be removed */
3877  if( SCIPisGE(scip, newcoef, 0.0) )
3878  {
3879  assert(SCIPisFeasGE(scip, xlb, consdata->lhs) && SCIPisFeasGE(scip, xlb + consdata->vbdcoef, consdata->lhs));
3880 
3881  SCIPdebugMsg(scip, "delete cons <%s>\n", SCIPconsGetName(cons));
3882  SCIP_CALL( SCIPdelCons(scip, cons) );
3883  ++(*ndelconss);
3884  }
3885  else
3886  {
3887  SCIPdebugMsg(scip, "tighten binary VLB <%s>[%.15g,%.15g] %+.15g<%s> >= %.15g to <%s> %+.15g<%s> >= %.15g\n",
3888  SCIPvarGetName(consdata->var), xlb, xub, consdata->vbdcoef, SCIPvarGetName(consdata->vbdvar),
3889  consdata->lhs,
3890  SCIPvarGetName(consdata->var), consdata->vbdcoef - consdata->lhs + xlb,
3891  SCIPvarGetName(consdata->vbdvar), xlb);
3892 
3893  /* we cannot allow that the coefficient changes the sign because of the rounding locks */
3894  assert(consdata->vbdcoef * newcoef > 0);
3895 
3896  consdata->vbdcoef = newcoef;
3897  consdata->lhs = xlb;
3898  (*nchgcoefs)++;
3899  (*nchgsides)++;
3900  }
3901  }
3902  }
3903  else if( SCIPisInfinity(scip, -consdata->lhs) && !SCIPisInfinity(scip, consdata->rhs) )
3904  {
3905  /* x + c*y <= rhs => x <= rhs - c*y */
3906  if( consdata->vbdcoef > 0.0 && SCIPisFeasLT(scip, xub, consdata->rhs) )
3907  {
3908  SCIP_Real newcoef;
3909 
3910  /* constraint has positive slack for the non-restricting case y = 0
3911  * -> modify coefficients such that constraint is tight in the non-restricting case y = 0 and equivalent in the restricting case y = 1
3912  * -> c' = c - rhs + xub, rhs' = xub
3913  */
3914  newcoef = consdata->vbdcoef - consdata->rhs + xub;
3915 
3916  /* in this case the constraint is redundant and can be removed */
3917  if( SCIPisLE(scip, newcoef, 0.0) )
3918  {
3919  assert(SCIPisFeasLE(scip, xub, consdata->rhs) && SCIPisFeasLE(scip, xub + consdata->vbdcoef, consdata->rhs));
3920 
3921  SCIPdebugMsg(scip, "delete cons <%s>\n", SCIPconsGetName(cons));
3922  SCIP_CALL( SCIPdelCons(scip, cons) );
3923  ++(*ndelconss);
3924  }
3925  else
3926  {
3927  SCIPdebugMsg(scip, "tighten binary VUB <%s>[%.15g,%.15g] %+.15g<%s> <= %.15g to <%s> %+.15g<%s> <= %.15g\n",
3928  SCIPvarGetName(consdata->var), xlb, xub, consdata->vbdcoef, SCIPvarGetName(consdata->vbdvar),
3929  consdata->rhs,
3930  SCIPvarGetName(consdata->var), consdata->vbdcoef - consdata->rhs + xub,
3931  SCIPvarGetName(consdata->vbdvar), xub);
3932 
3933  /* we cannot allow that the coefficient changes the sign because of the rounding locks */
3934  assert(consdata->vbdcoef * newcoef > 0);
3935 
3936  consdata->vbdcoef = newcoef;
3937  consdata->rhs = xub;
3938  (*nchgcoefs)++;
3939  (*nchgsides)++;
3940  }
3941  }
3942  else if( consdata->vbdcoef < 0.0 && SCIPisFeasLT(scip, xub, consdata->rhs - consdata->vbdcoef) )
3943  {
3944  SCIP_Real newcoef;
3945 
3946  /* constraint has positive slack for the non-restricting case y = 1
3947  * -> modify coefficients such that constraint is tight in the non-restricting case y = 1 and equivalent in the restricting case y = 0
3948  * -> c' = rhs - xub
3949  */
3950  newcoef = consdata->rhs - xub;
3951 
3952  /* in this case the constraint is redundant and can be removed */
3953  if( SCIPisGE(scip, newcoef, 0.0) )
3954  {
3955  assert(SCIPisFeasLE(scip, xub, consdata->rhs) && SCIPisFeasLE(scip, xub + consdata->vbdcoef, consdata->rhs));
3956 
3957  SCIPdebugMsg(scip, "delete cons <%s>\n", SCIPconsGetName(cons));
3958  SCIP_CALL( SCIPdelCons(scip, cons) );
3959  ++(*ndelconss);
3960  }
3961  else
3962  {
3963  SCIPdebugMsg(scip, "tighten binary VUB <%s>[%.15g,%.15g] %+.15g<%s> <= %.15g to <%s> %+.15g<%s> <= %.15g\n",
3964  SCIPvarGetName(consdata->var), xlb, xub, consdata->vbdcoef, SCIPvarGetName(consdata->vbdvar), consdata->rhs,
3965  SCIPvarGetName(consdata->var), consdata->rhs - xub, SCIPvarGetName(consdata->vbdvar), consdata->rhs);
3966 
3967  /* we cannot allow that the coefficient changes the sign because of the rounding locks */
3968  assert(consdata->vbdcoef * newcoef > 0);
3969 
3970  consdata->vbdcoef = newcoef;
3971  (*nchgcoefs)++;
3972  }
3973  }
3974  }
3975 
3976  /* if something a coefficient or side of the varbound constraint was changed, ensure that the variable lower or
3977  * upper bounds of the variables are informed
3978  */
3979  if( *nchgcoefs > oldnchgcoefs || *nchgsides > oldnchgsides )
3980  {
3981  consdata->varboundsadded = FALSE;
3982  consdata->changed = TRUE;
3983  }
3984 
3985  return SCIP_OKAY;
3986 }
3987 
3988 /** check if we can upgrade to a set-packing constraint */
3989 static
3991  SCIP* scip, /**< SCIP data structure */
3992  SCIP_CONSHDLRDATA* conshdlrdata, /**< constraint handler data */
3993  SCIP_CONS** conss, /**< constraint set */
3994  int nconss, /**< number of constraints in constraint set */
3995  SCIP_Bool* cutoff, /**< pointer to store whether the node can be cut off */
3996  int* naggrvars, /**< pointer to count the number of aggregated variables */
3997  int* nchgbds, /**< pointer to count number of bound changes */
3998  int* nchgcoefs, /**< pointer to count the number of changed coefficients */
3999  int* nchgsides, /**< pointer to count the number of left and right hand sides */
4000  int* ndelconss, /**< pointer to count the number of deleted constraints */
4001  int* naddconss /**< pointer to count the number of added constraints */
4002  )
4003 {
4004  SCIP_VAR* vars[2];
4005  SCIP_CONS* newcons;
4006  SCIP_CONS* cons;
4007  SCIP_CONSDATA* consdata;
4008  int c;
4009 
4010  assert(scip != NULL);
4011  assert(conshdlrdata != NULL);
4012  assert(conss != NULL || nconss == 0);
4013  assert(cutoff != NULL);
4014  assert(naggrvars != NULL);
4015  assert(nchgbds != NULL);
4016  assert(nchgcoefs != NULL);
4017  assert(nchgsides != NULL);
4018  assert(ndelconss != NULL);
4019  assert(naddconss != NULL);
4020 
4021  /* if we cannot find any constraint for upgrading, stop */
4022  if( SCIPgetNBinVars(scip) + SCIPgetNImplVars(scip) <= 1 )
4023  return SCIP_OKAY;
4024 
4025  if( nconss == 0 )
4026  return SCIP_OKAY;
4027 
4028  assert(conss != NULL);
4029 
4030  for( c = nconss - 1; c >= 0; --c )
4031  {
4032  cons = conss[c];
4033  assert(cons != NULL);
4034 
4035  if( !SCIPconsIsActive(cons) )
4036  continue;
4037 
4038  consdata = SCIPconsGetData(cons);
4039  assert(consdata != NULL);
4040  assert(SCIPisLE(scip, consdata->lhs, consdata->rhs));
4041 
4042  if( !consdata->presolved )
4043  {
4044  /* incorporate fixings and aggregations in constraint */
4045  SCIP_CALL( applyFixings(scip, cons, conshdlrdata->eventhdlr, cutoff, nchgbds, ndelconss, naddconss) );
4046 
4047  if( *cutoff )
4048  return SCIP_OKAY;
4049  if( !SCIPconsIsActive(cons) )
4050  continue;
4051  }
4052 
4053  if( SCIPconsIsMarkedPropagate(cons) )
4054  {
4055  /* propagate constraint */
4056  SCIP_CALL( propagateCons(scip, cons, conshdlrdata->usebdwidening, cutoff, nchgbds, nchgsides, ndelconss) );
4057 
4058  if( *cutoff )
4059  return SCIP_OKAY;
4060  if( !SCIPconsIsActive(cons) )
4061  continue;
4062  }
4063 
4064  if( !consdata->tightened )
4065  {
4066  /* tighten variable bound coefficient */
4067  SCIP_CALL( tightenCoefs(scip, cons, nchgcoefs, nchgsides, ndelconss, cutoff, nchgbds) );
4068 
4069  if( *cutoff )
4070  return SCIP_OKAY;
4071  if( !SCIPconsIsActive(cons) )
4072  continue;
4073 
4074  assert(SCIPisLE(scip, consdata->lhs, consdata->rhs));
4075  }
4076 
4077  /* check if both variables are of binary type */
4078  if( SCIPvarIsBinary(consdata->vbdvar) && SCIPvarIsBinary(consdata->var) )
4079  {
4080  /* coefficient and sides should be tightened and we assume that the constraint is not redundant */
4081  assert(SCIPisEQ(scip, REALABS(consdata->vbdcoef), 1.0));
4082  assert(SCIPisZero(scip, consdata->rhs) || SCIPisEQ(scip, consdata->rhs, 1.0) || SCIPisInfinity(scip, consdata->rhs));
4083  assert(SCIPisZero(scip, consdata->lhs) || SCIPisEQ(scip, consdata->lhs, 1.0) || SCIPisInfinity(scip, -consdata->lhs));
4084  assert(!SCIPisInfinity(scip, consdata->rhs) || !SCIPisInfinity(scip, -consdata->lhs));
4085 
4086  /* the case x + y <= 1 or x + y >= 1 */
4087  if( consdata->vbdcoef > 0.0 )
4088  {
4089  if( SCIPisEQ(scip, consdata->rhs, 1.0) )
4090  {
4091  /* check for aggregations like x + y == 1 */
4092  if( SCIPisEQ(scip, consdata->lhs, 1.0) )
4093  {
4094  SCIP_Bool infeasible;
4095  SCIP_Bool redundant;
4096  SCIP_Bool aggregated;
4097 
4098  SCIPdebugMsg(scip, "varbound constraint <%s>: aggregate <%s> + <%s> == 1\n",
4099  SCIPconsGetName(cons), SCIPvarGetName(consdata->var), SCIPvarGetName(consdata->vbdvar));
4100 
4101  /* aggregate both variables */
4102  SCIP_CALL( SCIPaggregateVars(scip, consdata->var, consdata->vbdvar, 1.0, 1.0, 1.0, &infeasible, &redundant, &aggregated) );
4103  assert(!infeasible);
4104  ++(*naggrvars);
4105 
4106  SCIP_CALL( SCIPdelCons(scip, cons) );
4107  ++(*ndelconss);
4108 
4109  continue;
4110  }
4111  assert(consdata->lhs < 0.5);
4112 
4113  vars[0] = consdata->var;
4114  vars[1] = consdata->vbdvar;
4115  }
4116  else
4117  {
4118  assert(SCIPisEQ(scip, consdata->lhs, 1.0));
4119 
4120  SCIP_CALL( SCIPgetNegatedVar(scip, consdata->var, &vars[0]) );
4121  SCIP_CALL( SCIPgetNegatedVar(scip, consdata->vbdvar, &vars[1]) );
4122  }
4123  }
4124  /* the case x - y <= 0 or x - y >= 0 */
4125  else
4126  {
4127  /* the case x - y <= 0 */
4128  if( SCIPisZero(scip, consdata->rhs) )
4129  {
4130  /* check for aggregations like x - y == 0 */
4131  if( SCIPisZero(scip, consdata->lhs) )
4132  {
4133  SCIP_Bool infeasible;
4134  SCIP_Bool redundant;
4135  SCIP_Bool aggregated;
4136 
4137  SCIPdebugMsg(scip, "varbound constraint <%s>: aggregate <%s> - <%s> == 0\n",
4138  SCIPconsGetName(cons), SCIPvarGetName(consdata->var), SCIPvarGetName(consdata->vbdvar));
4139 
4140  /* aggregate both variables */
4141  SCIP_CALL( SCIPaggregateVars(scip, consdata->var, consdata->vbdvar, 1.0, -1.0, 0.0, &infeasible, &redundant, &aggregated) );
4142  assert(!infeasible);
4143  ++(*naggrvars);
4144 
4145  SCIP_CALL( SCIPdelCons(scip, cons) );
4146  ++(*ndelconss);
4147 
4148  continue;
4149  }
4150  assert(consdata->lhs < -0.5);
4151 
4152  vars[0] = consdata->var;
4153  SCIP_CALL( SCIPgetNegatedVar(scip, consdata->vbdvar, &vars[1]) );
4154  }
4155  /* the case x - y >= 0 */
4156  else
4157  {
4158  assert(SCIPisZero(scip, consdata->lhs));
4159 
4160  SCIP_CALL( SCIPgetNegatedVar(scip, consdata->var, &vars[0]) );
4161  vars[1] = consdata->vbdvar;
4162  }
4163  }
4164 
4165  SCIP_CALL( SCIPcreateConsSetpack(scip, &newcons, SCIPconsGetName(cons), 2, vars,
4170 
4171  SCIP_CALL( SCIPaddCons(scip, newcons) );
4172  SCIPdebugMsg(scip, "upgraded varbound constraint <%s> to a set-packing constraint\n", SCIPconsGetName(cons));
4173  SCIPdebugPrintCons(scip, newcons, NULL);
4174 
4175  SCIP_CALL( SCIPreleaseCons(scip, &newcons) );
4176  ++(*naddconss);
4177 
4178  SCIP_CALL( SCIPdelCons(scip, cons) );
4179  ++(*ndelconss);
4180  }
4181  }
4182 
4183  return SCIP_OKAY;
4184 }
4185 
4186 /**@} */
4187 
4188 
4189 /**@name Linear constraint upgrading
4190  *
4191  * @{
4192  */
4193 
4194 /** tries to upgrade a linear constraint into a variable bound constraint */
4195 static
4196 SCIP_DECL_LINCONSUPGD(linconsUpgdVarbound)
4197 { /*lint --e{715}*/
4198  SCIP_Bool upgrade;
4199 
4200  assert(upgdcons != NULL);
4201 
4202  /* check, if linear constraint can be upgraded to a variable bound constraint lhs <= x + a*y <= rhs
4203  * - there are exactly two variables
4204  * - one of the variables is non-binary (called the bounded variable x)
4205  * - one of the variables is non-continuous (called the bounding variable y)
4206  */
4207  upgrade = (nvars == 2) && (nposbin + nnegbin <= 1) && (nposcont + nnegcont <= 1);
4208 
4209  if( upgrade )
4210  {
4211  SCIP_VAR* var;
4212  SCIP_VAR* vbdvar;
4213  SCIP_Real vbdcoef;
4214  SCIP_Real vbdlhs;
4215  SCIP_Real vbdrhs;
4216  int vbdind;
4217 
4218  /* decide which variable we want to use as bounding variable y */
4219  if( SCIPvarGetType(vars[0]) < SCIPvarGetType(vars[1]) )
4220  vbdind = 0;
4221  else if( SCIPvarGetType(vars[0]) > SCIPvarGetType(vars[1]) )
4222  vbdind = 1;
4223  else if( SCIPisIntegral(scip, vals[0]) && !SCIPisIntegral(scip, vals[1]) )
4224  vbdind = 0;
4225  else if( !SCIPisIntegral(scip, vals[0]) && SCIPisIntegral(scip, vals[1]) )
4226  vbdind = 1;
4227  else if( REALABS(REALABS(vals[0]) - 1.0) < REALABS(REALABS(vals[1]) - 1.0) )
4228  vbdind = 1;
4229  else
4230  vbdind = 0;
4231 
4232  /* do not upgrade when it is numerical unstable */
4233  if( SCIPisZero(scip, vals[vbdind]/vals[1-vbdind]) )
4234  return SCIP_OKAY;
4235 
4236  SCIPdebugMsg(scip, "upgrading constraint <%s> to variable bound constraint\n", SCIPconsGetName(cons));
4237 
4238  var = vars[1-vbdind];
4239  vbdvar = vars[vbdind];
4240 
4241  assert(!SCIPisZero(scip, vals[1-vbdind]));
4242  vbdcoef = vals[vbdind]/vals[1-vbdind];
4243 
4244  if( vals[1-vbdind] > 0.0 )
4245  {
4246  vbdlhs = SCIPisInfinity(scip, -lhs) ? -SCIPinfinity(scip) : lhs/vals[1-vbdind];
4247  vbdrhs = SCIPisInfinity(scip, rhs) ? SCIPinfinity(scip) : rhs/vals[1-vbdind];
4248  }
4249  else
4250  {
4251  vbdlhs = SCIPisInfinity(scip, rhs) ? -SCIPinfinity(scip) : rhs/vals[1-vbdind];
4252  vbdrhs = SCIPisInfinity(scip, -lhs) ? SCIPinfinity(scip) : lhs/vals[1-vbdind];
4253  }
4254 
4255  /* create the bin variable bound constraint (an automatically upgraded constraint is always unmodifiable) */
4256  assert(!SCIPconsIsModifiable(cons));
4257  SCIP_CALL( SCIPcreateConsVarbound(scip, upgdcons, SCIPconsGetName(cons), var, vbdvar, vbdcoef, vbdlhs, vbdrhs,
4260  SCIPconsIsLocal(cons), SCIPconsIsModifiable(cons),
4262  }
4263 
4264  return SCIP_OKAY;
4265 }
4266 
4267 /**@} */
4268 
4269 
4270 /**@name Callback methods
4271  *
4272  * @{
4273  */
4274 
4275 /** copy method for constraint handler plugins (called when SCIP copies plugins) */
4276 static
4277 SCIP_DECL_CONSHDLRCOPY(conshdlrCopyVarbound)
4278 { /*lint --e{715}*/
4279  assert(scip != NULL);
4280  assert(conshdlr != NULL);
4281  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
4282 
4283  /* call inclusion method of constraint handler */
4285 
4286  *valid = TRUE;
4287 
4288  return SCIP_OKAY;
4289 }
4290 
4291 /** destructor of constraint handler to free constraint handler data (called when SCIP is exiting) */
4292 static
4293 SCIP_DECL_CONSFREE(consFreeVarbound)
4294 { /*lint --e{715}*/
4295  SCIP_CONSHDLRDATA* conshdlrdata;
4296 
4297  assert(scip != NULL);
4298  assert(conshdlr != NULL);
4299  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
4300 
4301  /* free constraint handler data */
4302  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4303  assert(conshdlrdata != NULL);
4304 
4305  conshdlrdataFree(scip, &conshdlrdata);
4306 
4307  SCIPconshdlrSetData(conshdlr, NULL);
4308 
4309  return SCIP_OKAY;
4310 }
4311 
4312 /** solving process initialization method of constraint handler */
4313 static
4314 SCIP_DECL_CONSINITSOL(consInitsolVarbound)
4315 { /*lint --e{715}*/
4316 
4317  /* add nlrow representation to NLP, if NLP had been constructed */
4318  if( SCIPisNLPConstructed(scip) )
4319  {
4320  int c;
4321  for( c = 0; c < nconss; ++c )
4322  {
4323  SCIP_CALL( addNlrow(scip, conss[c]) );
4324  }
4325  }
4326 
4327  return SCIP_OKAY;
4328 }
4329 
4330 /** solving process deinitialization method of constraint handler (called before branch and bound process data is freed) */
4331 static
4332 SCIP_DECL_CONSEXITSOL(consExitsolVarbound)
4333 { /*lint --e{715}*/
4334  SCIP_CONSDATA* consdata;
4335  int c;
4336 
4337  /* release the rows and nlrows of all constraints */
4338  for( c = 0; c < nconss; ++c )
4339  {
4340  consdata = SCIPconsGetData(conss[c]);
4341  assert(consdata != NULL);
4342 
4343  if( consdata->row != NULL )
4344  {
4345  SCIP_CALL( SCIPreleaseRow(scip, &consdata->row) );
4346  }
4347 
4348  if( consdata->nlrow != NULL )
4349  {
4350  SCIP_CALL( SCIPreleaseNlRow(scip, &consdata->nlrow) );
4351  }
4352  }
4353 
4354  return SCIP_OKAY;
4355 }
4356 
4357 
4358 /** frees specific constraint data */
4359 static
4360 SCIP_DECL_CONSDELETE(consDeleteVarbound)
4361 { /*lint --e{715}*/
4362  SCIP_CONSHDLRDATA* conshdlrdata;
4363 
4364  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4365  assert(conshdlrdata != NULL);
4366 
4367  /* drop events */
4368  if( SCIPisTransformed(scip) )
4369  {
4370  SCIP_CALL( dropEvents(scip, cons, conshdlrdata->eventhdlr) );
4371  }
4372 
4373  SCIP_CALL( consdataFree(scip, consdata) );
4374 
4375  return SCIP_OKAY;
4376 }
4377 
4378 
4379 /** transforms constraint data into data belonging to the transformed problem */
4380 static
4381 SCIP_DECL_CONSTRANS(consTransVarbound)
4382 { /*lint --e{715}*/
4383  SCIP_CONSHDLRDATA* conshdlrdata;
4384  SCIP_CONSDATA* sourcedata;
4385  SCIP_CONSDATA* targetdata;
4386 
4387  assert(conshdlr != NULL);
4388 
4389  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4390  assert(conshdlrdata != NULL);
4391 
4392  sourcedata = SCIPconsGetData(sourcecons);
4393  assert(sourcedata != NULL);
4394 
4395  /* create target constraint data */
4396  SCIP_CALL( consdataCreate(scip, &targetdata,
4397  sourcedata->var, sourcedata->vbdvar, sourcedata->vbdcoef, sourcedata->lhs, sourcedata->rhs) );
4398 
4399  /* create target constraint */
4400  SCIP_CALL( SCIPcreateCons(scip, targetcons, SCIPconsGetName(sourcecons), conshdlr, targetdata,
4401  SCIPconsIsInitial(sourcecons), SCIPconsIsSeparated(sourcecons), SCIPconsIsEnforced(sourcecons),
4402  SCIPconsIsChecked(sourcecons), SCIPconsIsPropagated(sourcecons),
4403  SCIPconsIsLocal(sourcecons), SCIPconsIsModifiable(sourcecons),
4404  SCIPconsIsDynamic(sourcecons), SCIPconsIsRemovable(sourcecons), SCIPconsIsStickingAtNode(sourcecons)) );
4405 
4406  /* catch events for variables */
4407  SCIP_CALL( catchEvents(scip, *targetcons, conshdlrdata->eventhdlr) );
4408 
4409  return SCIP_OKAY;
4410 }
4411 
4412 
4413 /** LP initialization method of constraint handler (called before the initial LP relaxation at a node is solved) */
4414 static
4415 SCIP_DECL_CONSINITLP(consInitlpVarbound)
4416 { /*lint --e{715}*/
4417  int i;
4418 
4419  *infeasible = FALSE;
4420 
4421  for( i = 0; i < nconss && !(*infeasible); i++ )
4422  {
4423  assert(SCIPconsIsInitial(conss[i]));
4424  SCIP_CALL( addRelaxation(scip, conss[i], infeasible) );
4425  }
4426 
4427  return SCIP_OKAY;
4428 }
4429 
4430 
4431 /** separation method of constraint handler for LP solutions */
4432 static
4433 SCIP_DECL_CONSSEPALP(consSepalpVarbound)
4434 { /*lint --e{715}*/
4435  SCIP_CONSHDLRDATA* conshdlrdata;
4436  int i;
4437 
4438  assert(conshdlr != NULL);
4439 
4440  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4441  assert(conshdlrdata != NULL);
4442 
4443  *result = SCIP_DIDNOTFIND;
4444 
4445  /* separate useful constraints */
4446  for( i = 0; i < nusefulconss; ++i )
4447  {
4448  SCIP_CALL( separateCons(scip, conss[i], conshdlrdata->usebdwidening, NULL, result) );
4449  }
4450 
4451  /* separate remaining constraints */
4452  for( i = nusefulconss; i < nconss && *result == SCIP_DIDNOTFIND; ++i )
4453  {
4454  SCIP_CALL( separateCons(scip, conss[i], conshdlrdata->usebdwidening, NULL, result) );
4455  }
4456 
4457  return SCIP_OKAY;
4458 }
4459 
4460 
4461 /** separation method of constraint handler for arbitrary primal solutions */
4462 static
4463 SCIP_DECL_CONSSEPASOL(consSepasolVarbound)
4464 { /*lint --e{715}*/
4465  SCIP_CONSHDLRDATA* conshdlrdata;
4466  int i;
4467 
4468  assert(conshdlr != NULL);
4469 
4470  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4471  assert(conshdlrdata != NULL);
4472 
4473  *result = SCIP_DIDNOTFIND;
4474 
4475  /* separate useful constraints */
4476  for( i = 0; i < nusefulconss; ++i )
4477  {
4478  SCIP_CALL( separateCons(scip, conss[i], conshdlrdata->usebdwidening, sol, result) );
4479  }
4480 
4481  /* separate remaining constraints */
4482  for( i = nusefulconss; i < nconss && *result == SCIP_DIDNOTFIND; ++i )
4483  {
4484  SCIP_CALL( separateCons(scip, conss[i], conshdlrdata->usebdwidening, sol, result) );
4485  }
4486 
4487  return SCIP_OKAY;
4488 }
4489 
4490 
4491 /** constraint enforcing method of constraint handler for LP solutions */
4492 static
4493 SCIP_DECL_CONSENFOLP(consEnfolpVarbound)
4494 { /*lint --e{715}*/
4495  SCIP_CONSHDLRDATA* conshdlrdata;
4496  int i;
4497 
4498  assert(conshdlr != NULL);
4499 
4500  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4501  assert(conshdlrdata != NULL);
4502 
4503  *result = SCIP_FEASIBLE;
4504 
4505  for( i = 0; i < nconss; i++ )
4506  {
4507  if( !checkCons(scip, conss[i], NULL, FALSE) )
4508  {
4509  assert((*result) == SCIP_INFEASIBLE || (*result) == SCIP_FEASIBLE);
4510  (*result) = SCIP_INFEASIBLE;
4511 
4512  SCIP_CALL( SCIPresetConsAge(scip, conss[i]) );
4513 
4514  SCIP_CALL( separateCons(scip, conss[i], conshdlrdata->usebdwidening, NULL, result) );
4515  assert((*result) != SCIP_FEASIBLE);
4516 
4517  if( (*result) != SCIP_INFEASIBLE )
4518  break;
4519  }
4520  else
4521  {
4522  /* increase age of constraint */
4523  SCIP_CALL( SCIPincConsAge(scip, conss[i]) );
4524  }
4525  }
4526 
4527  return SCIP_OKAY;
4528 }
4529 
4530 
4531 /** constraint enforcing method of constraint handler for relaxation solutions */
4532 static
4533 SCIP_DECL_CONSENFORELAX(consEnforelaxVarbound)
4534 { /*lint --e{715}*/
4535  SCIP_CONSHDLRDATA* conshdlrdata;
4536  int i;
4537 
4538  assert(conshdlr != NULL);
4539 
4540  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4541  assert(conshdlrdata != NULL);
4542 
4543  *result = SCIP_FEASIBLE;
4544 
4545  for( i = 0; i < nconss; i++ )
4546  {
4547  if( !checkCons(scip, conss[i], sol, FALSE) )
4548  {
4549  assert((*result) == SCIP_INFEASIBLE || (*result) == SCIP_FEASIBLE);
4550  (*result) = SCIP_INFEASIBLE;
4551 
4552  SCIP_CALL( SCIPresetConsAge(scip, conss[i]) );
4553 
4554  SCIP_CALL( separateCons(scip, conss[i], conshdlrdata->usebdwidening, sol, result) );
4555  assert((*result) != SCIP_FEASIBLE);
4556 
4557  if( (*result) != SCIP_INFEASIBLE )
4558  break;
4559  }
4560  else
4561  {
4562  /* increase age of constraint */
4563  SCIP_CALL( SCIPincConsAge(scip, conss[i]) );
4564  }
4565  }
4566 
4567  return SCIP_OKAY;
4568 }
4569 
4570 
4571 /** constraint enforcing method of constraint handler for pseudo solutions */
4572 static
4573 SCIP_DECL_CONSENFOPS(consEnfopsVarbound)
4574 { /*lint --e{715}*/
4575  int i;
4576 
4577  for( i = 0; i < nconss; i++ )
4578  {
4579  if( !checkCons(scip, conss[i], NULL, TRUE) )
4580  {
4581  SCIP_CALL( SCIPresetConsAge(scip, conss[i]) );
4582 
4583  *result = SCIP_INFEASIBLE;
4584  return SCIP_OKAY;
4585  }
4586  else
4587  {
4588  /* increase age of constraint */
4589  SCIP_CALL( SCIPincConsAge(scip, conss[i]) );
4590  }
4591  }
4592  *result = SCIP_FEASIBLE;
4593 
4594  return SCIP_OKAY;
4595 }
4596 
4597 
4598 /** feasibility check method of constraint handler for integral solutions */
4599 static
4600 SCIP_DECL_CONSCHECK(consCheckVarbound)
4601 { /*lint --e{715}*/
4602  int i;
4603 
4604  *result = SCIP_FEASIBLE;
4605 
4606  for( i = 0; i < nconss && (*result == SCIP_FEASIBLE || completely); i++ )
4607  {
4608  if( !checkCons(scip, conss[i], sol, checklprows) )
4609  {
4610  *result = SCIP_INFEASIBLE;
4611 
4612  if( printreason )
4613  {
4614  SCIP_CONSDATA* consdata;
4615  SCIP_Real sum;
4616 
4617  consdata = SCIPconsGetData(conss[i]);
4618  assert( consdata != NULL );
4619 
4620  sum = SCIPgetSolVal(scip, sol, consdata->var) + consdata->vbdcoef * SCIPgetSolVal(scip, sol, consdata->vbdvar);
4621 
4622  SCIP_CALL( SCIPprintCons(scip, conss[i], NULL) );
4623  SCIPinfoMessage(scip, NULL, ";\n");
4624 
4625  if( !SCIPisFeasGE(scip, sum, consdata->lhs) )
4626  {
4627  SCIPinfoMessage(scip, NULL, "violation: left hand side is violated by %.15g\n", consdata->lhs - sum);
4628  }
4629  if( !SCIPisFeasLE(scip, sum, consdata->rhs) )
4630  {
4631  SCIPinfoMessage(scip, NULL, "violation: right hand side is violated by %.15g\n", sum - consdata->rhs);
4632  }
4633  }
4634  }
4635  }
4636 
4637  return SCIP_OKAY;
4638 }
4639 
4640 
4641 /** domain propagation method of constraint handler */
4642 static
4643 SCIP_DECL_CONSPROP(consPropVarbound)
4644 { /*lint --e{715}*/
4645  SCIP_CONSHDLRDATA* conshdlrdata;
4646  SCIP_Bool cutoff;
4647  int nchgbds = 0;
4648  int nchgsides = 0;
4649  int i;
4650 
4651  assert(conshdlr != NULL);
4652 
4653  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4654  assert(conshdlrdata != NULL);
4655 
4656  cutoff = FALSE;
4657 
4658  SCIPdebugMsg(scip, "propagating %d variable bound constraints\n", nmarkedconss);
4659 
4660  /* process constraints marked for propagation */
4661  for( i = 0; i < nmarkedconss && !cutoff; i++ )
4662  {
4663  SCIP_CALL( propagateCons(scip, conss[i], conshdlrdata->usebdwidening, &cutoff, &nchgbds, &nchgsides, NULL) );
4664  }
4665 
4666  if( cutoff )
4667  *result = SCIP_CUTOFF;
4668  else if( nchgbds > 0 )
4669  *result = SCIP_REDUCEDDOM;
4670  else
4671  *result = SCIP_DIDNOTFIND;
4672 
4673  return SCIP_OKAY;
4674 }
4675 
4676 
4677 /** presolving method of constraint handler */
4678 static
4679 SCIP_DECL_CONSPRESOL(consPresolVarbound)
4680 { /*lint --e{715}*/
4681  SCIP_CONSHDLRDATA* conshdlrdata;
4682  SCIP_CONS* cons;
4683  SCIP_CONSDATA* consdata;
4684  SCIP_Bool cutoff;
4685  int oldnchgbds;
4686  int oldndelconss;
4687  int oldnaddconss;
4688  int oldnchgcoefs;
4689  int oldnchgsides;
4690  int oldnaggrvars;
4691  int i;
4692 
4693  assert(scip != NULL);
4694  assert(conshdlr != NULL);
4695  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
4696  assert(result != NULL);
4697 
4698  /* get constraint handler data */
4699  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4700  assert(conshdlrdata != NULL);
4701 
4702  cutoff = FALSE;
4703  oldnchgbds = *nchgbds;
4704  oldndelconss = *ndelconss;
4705  oldnaddconss = *naddconss;
4706  oldnchgcoefs = *nchgcoefs;
4707  oldnchgsides = *nchgsides;
4708  oldnaggrvars = *naggrvars;
4709 
4710  for( i = 0; i < nconss; i++ )
4711  {
4712  cons = conss[i];
4713  assert(cons != NULL);
4714 
4715  assert(!SCIPconsIsModifiable(cons));
4716 
4717  consdata = SCIPconsGetData(cons);
4718  assert(consdata != NULL);
4719 
4720  if( i % 1000 == 0 && SCIPisStopped(scip) )
4721  break;
4722 
4723  /* force presolving the constraint in the initial round */
4724  if( nrounds == 0 )
4725  consdata->presolved = FALSE;
4726 
4727  if( consdata->presolved )
4728  continue;
4729  consdata->presolved = TRUE;
4730 
4731  /* incorporate fixings and aggregations in constraint */
4732  SCIP_CALL( applyFixings(scip, cons, conshdlrdata->eventhdlr, &cutoff, nchgbds, ndelconss, naddconss) );
4733 
4734  if( cutoff )
4735  break;
4736  if( !SCIPconsIsActive(cons) )
4737  continue;
4738 
4739  /* propagate constraint */
4740  SCIP_CALL( propagateCons(scip, cons, conshdlrdata->usebdwidening, &cutoff, nchgbds, nchgsides, ndelconss) );
4741 
4742  if( cutoff )
4743  break;
4744  if( !SCIPconsIsActive(cons) )
4745  continue;
4746 
4747  /* tighten variable bound coefficient */
4748  SCIP_CALL( tightenCoefs(scip, cons, nchgcoefs, nchgsides, ndelconss, &cutoff, nchgbds) );
4749  if( cutoff )
4750  break;
4751  if( !SCIPconsIsActive(cons) )
4752  continue;
4753 
4754  /* informs once variable x about a globally valid variable lower or upper bound */
4755  if( !consdata->varboundsadded )
4756  {
4757  SCIP_Bool infeasible;
4758  int nlocalchgbds;
4759  int localoldnchgbds;
4760 
4761  localoldnchgbds = *nchgbds;
4762 
4763  /* if lhs is finite, we have a variable lower bound: lhs <= x + c*y => x >= -c*y + lhs */
4764  if( !SCIPisInfinity(scip, -consdata->lhs) )
4765  {
4766  SCIPdebugMsg(scip, "adding variable lower bound <%s> >= %g<%s> + %g (and potentially also <%s> %s %g<%s> + %g)\n",
4767  SCIPvarGetName(consdata->var), -consdata->vbdcoef, SCIPvarGetName(consdata->vbdvar), consdata->lhs,
4768  SCIPvarGetName(consdata->vbdvar), (consdata->vbdcoef > 0 ? ">=" : "<="), 1.0/-consdata->vbdcoef,
4769  SCIPvarGetName(consdata->var), consdata->lhs/consdata->vbdcoef);
4770 
4771  SCIP_CALL( SCIPaddVarVlb(scip, consdata->var, consdata->vbdvar, -consdata->vbdcoef, consdata->lhs,
4772  &infeasible, &nlocalchgbds) );
4773  assert(!infeasible);
4774 
4775  *nchgbds += nlocalchgbds;
4776  }
4777 
4778  /* if rhs is finite, we have a variable upper bound: x + c*y <= rhs => x <= -c*y + rhs */
4779  if( !SCIPisInfinity(scip, consdata->rhs) )
4780  {
4781  SCIPdebugMsg(scip, "adding variable upper bound <%s> <= %g<%s> + %g (and potentially also <%s> %s %g<%s> + %g)\n",
4782  SCIPvarGetName(consdata->var), -consdata->vbdcoef, SCIPvarGetName(consdata->vbdvar), consdata->rhs,
4783  SCIPvarGetName(consdata->vbdvar), (consdata->vbdcoef > 0 ? "<=" : ">="), 1.0/-consdata->vbdcoef,
4784  SCIPvarGetName(consdata->var), consdata->rhs/consdata->vbdcoef);
4785 
4786  SCIP_CALL( SCIPaddVarVub(scip, consdata->var, consdata->vbdvar, -consdata->vbdcoef, consdata->rhs,
4787  &infeasible, &nlocalchgbds) );
4788  assert(!infeasible);
4789 
4790  *nchgbds += nlocalchgbds;
4791  }
4792  consdata->varboundsadded = TRUE;
4793 
4794  if( *nchgbds > localoldnchgbds )
4795  {
4796  /* tighten variable bound coefficient */
4797  SCIP_CALL( tightenCoefs(scip, cons, nchgcoefs, nchgsides, ndelconss, &cutoff, nchgbds) );
4798  if( cutoff )
4799  break;
4800  }
4801  }
4802  }
4803 
4804  if( !cutoff )
4805  {
4806  /* for varbound constraint with two integer variables make coefficients integral */
4807  prettifyConss(scip, conss, nconss, nchgcoefs, nchgsides);
4808 
4809  /* check if we can upgrade to a set-packing constraint */
4810  SCIP_CALL( upgradeConss(scip, conshdlrdata, conss, nconss, &cutoff, naggrvars, nchgbds, nchgcoefs, nchgsides, ndelconss, naddconss) );
4811 
4812  if( !cutoff && conshdlrdata->presolpairwise && (presoltiming & SCIP_PRESOLTIMING_MEDIUM) != 0 )
4813  {
4814  /* preprocess pairs of variable bound constraints */
4815  SCIP_CALL( preprocessConstraintPairs(scip, conss, nconss, &cutoff, nchgbds, ndelconss, nchgcoefs, nchgsides) );
4816  }
4817  }
4818 
4819  /* return the correct result code */
4820  if( cutoff )
4821  *result = SCIP_CUTOFF;
4822  else if( *nchgbds > oldnchgbds || *ndelconss > oldndelconss || *naddconss > oldnaddconss
4823  || *nchgcoefs > oldnchgcoefs || *nchgsides > oldnchgsides || *naggrvars > oldnaggrvars )
4824  *result = SCIP_SUCCESS;
4825  else
4826  *result = SCIP_DIDNOTFIND;
4827 
4828  return SCIP_OKAY;
4829 }
4830 
4831 
4832 /** propagation conflict resolving method of constraint handler */
4833 static
4834 SCIP_DECL_CONSRESPROP(consRespropVarbound)
4835 { /*lint --e{715}*/
4836  SCIP_CONSHDLRDATA* conshdlrdata;
4837 
4838  assert(conshdlr != NULL);
4839 
4840  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4841  assert(conshdlrdata != NULL);
4842 
4843  SCIP_CALL( resolvePropagation(scip, cons, infervar, (PROPRULE)inferinfo, boundtype, bdchgidx, relaxedbd, conshdlrdata->usebdwidening) );
4844 
4845  *result = SCIP_SUCCESS;
4846 
4847  return SCIP_OKAY;
4848 }
4849 
4850 
4851 /** variable rounding lock method of constraint handler */
4852 static
4853 SCIP_DECL_CONSLOCK(consLockVarbound)
4854 { /*lint --e{715}*/
4855  SCIP_CONSDATA* consdata;
4856 
4857  consdata = SCIPconsGetData(cons);
4858  assert(consdata != NULL);
4859 
4860  if( !SCIPisInfinity(scip, -consdata->lhs) )
4861  {
4862  SCIP_CALL( SCIPaddVarLocksType(scip, consdata->var, locktype, nlockspos, nlocksneg) );
4863  if( consdata->vbdcoef > 0.0 )
4864  {
4865  SCIP_CALL( SCIPaddVarLocksType(scip, consdata->vbdvar, locktype, nlockspos, nlocksneg) );
4866  }
4867  else
4868  {
4869  SCIP_CALL( SCIPaddVarLocksType(scip, consdata->vbdvar, locktype, nlocksneg, nlockspos) );
4870  }
4871  }
4872 
4873  if( !SCIPisInfinity(scip, consdata->rhs) )
4874  {
4875  SCIP_CALL( SCIPaddVarLocksType(scip, consdata->var, locktype, nlocksneg, nlockspos) );
4876  if( consdata->vbdcoef > 0.0 )
4877  {
4878  SCIP_CALL( SCIPaddVarLocksType(scip, consdata->vbdvar, locktype, nlocksneg, nlockspos) );
4879  }
4880  else
4881  {
4882  SCIP_CALL( SCIPaddVarLocksType(scip, consdata->vbdvar, locktype, nlockspos, nlocksneg) );
4883  }
4884  }
4885 
4886  return SCIP_OKAY;
4887 }
4888 
4889 /** constraint activation notification method of constraint handler */
4890 static
4891 SCIP_DECL_CONSACTIVE(consActiveVarbound)
4892 { /*lint --e{715}*/
4893 
4894  if( SCIPgetStage(scip) == SCIP_STAGE_SOLVING && SCIPisNLPConstructed(scip) )
4895  {
4896  SCIP_CALL( addNlrow(scip, cons) );
4897  }
4898 
4899  return SCIP_OKAY;
4900 }
4901 
4902 /** constraint deactivation notification method of constraint handler */
4903 static
4904 SCIP_DECL_CONSDEACTIVE(consDeactiveVarbound)
4905 { /*lint --e{715}*/
4906  SCIP_CONSDATA* consdata;
4907 
4908  assert(cons != NULL);
4909 
4910  consdata = SCIPconsGetData(cons);
4911  assert(consdata != NULL);
4912 
4913  /* remove row from NLP, if still in solving
4914  * if we are in exitsolve, the whole NLP will be freed anyway
4915  */
4916  if( SCIPgetStage(scip) == SCIP_STAGE_SOLVING && consdata->nlrow != NULL )
4917  {
4918  SCIP_CALL( SCIPdelNlRow(scip, consdata->nlrow) );
4919  }
4920 
4921  return SCIP_OKAY;
4922 }
4923 
4924 /** constraint display method of constraint handler */
4925 static
4926 SCIP_DECL_CONSPRINT(consPrintVarbound)
4927 { /*lint --e{715}*/
4928  SCIP_CONSDATA* consdata;
4929 
4930  assert(scip != NULL);
4931  assert(conshdlr != NULL);
4932  assert(cons != NULL);
4933 
4934  consdata = SCIPconsGetData(cons);
4935  assert(consdata != NULL);
4936 
4937  /* print left hand side for ranged rows */
4938  if( !SCIPisInfinity(scip, -consdata->lhs)
4939  && !SCIPisInfinity(scip, consdata->rhs)
4940  && !SCIPisEQ(scip, consdata->lhs, consdata->rhs) )
4941  SCIPinfoMessage(scip, file, "%.15g <= ", consdata->lhs);
4942 
4943  /* print coefficients and variables */
4944  SCIPinfoMessage(scip, file, "<%s>[%c] %+.15g<%s>[%c]", SCIPvarGetName(consdata->var),
4948  consdata->vbdcoef, SCIPvarGetName(consdata->vbdvar),
4951  SCIPvarGetType(consdata->vbdvar) == SCIP_VARTYPE_IMPLINT ? SCIP_VARTYPE_IMPLINT_CHAR : SCIP_VARTYPE_CONTINUOUS_CHAR);
4952 
4953  /* print right hand side */
4954  if( SCIPisEQ(scip, consdata->lhs, consdata->rhs) )
4955  SCIPinfoMessage(scip, file, " == %.15g", consdata->rhs);
4956  else if( !SCIPisInfinity(scip, consdata->rhs) )
4957  SCIPinfoMessage(scip, file, " <= %.15g", consdata->rhs);
4958  else if( !SCIPisInfinity(scip, -consdata->lhs) )
4959  SCIPinfoMessage(scip, file, " >= %.15g", consdata->lhs);
4960  else
4961  SCIPinfoMessage(scip, file, " [free]");
4962 
4963  return SCIP_OKAY;
4964 }
4965 
4966 /** constraint copying method of constraint handler */
4967 static
4968 SCIP_DECL_CONSCOPY(consCopyVarbound)
4969 { /*lint --e{715}*/
4970  SCIP_VAR** vars;
4971  SCIP_Real* coefs;
4972  const char* consname;
4973 
4974  SCIP_CALL( SCIPallocBufferArray(scip, &vars, 2) );
4975  SCIP_CALL( SCIPallocBufferArray(scip, &coefs, 2) );
4976 
4977  vars[0] = SCIPgetVarVarbound(sourcescip, sourcecons);
4978  vars[1] = SCIPgetVbdvarVarbound(sourcescip, sourcecons);
4979 
4980  coefs[0] = 1.0;
4981  coefs[1] = SCIPgetVbdcoefVarbound(sourcescip, sourcecons);
4982 
4983  if( name != NULL )
4984  consname = name;
4985  else
4986  consname = SCIPconsGetName(sourcecons);
4987 
4988  /* copy the varbound using the linear constraint copy method */
4989  SCIP_CALL( SCIPcopyConsLinear(scip, cons, sourcescip, consname, 2, vars, coefs,
4990  SCIPgetLhsVarbound(sourcescip, sourcecons), SCIPgetRhsVarbound(sourcescip, sourcecons), varmap, consmap,
4991  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, global, valid) );
4992 
4993  SCIPfreeBufferArray(scip, &coefs);
4994  SCIPfreeBufferArray(scip, &vars);
4995 
4996  return SCIP_OKAY;
4997 }
4998 
4999 /** constraint parsing method of constraint handler */
5000 static
5001 SCIP_DECL_CONSPARSE(consParseVarbound)
5002 { /*lint --e{715}*/
5003  SCIP_VAR** vars;
5004  SCIP_Real* coefs;
5005  SCIP_Real lhs;
5006  SCIP_Real rhs;
5007  char* endstr;
5008  int requiredsize;
5009  int nvars;
5010 
5011  assert(scip != NULL);
5012  assert(success != NULL);
5013  assert(str != NULL);
5014  assert(name != NULL);
5015  assert(cons != NULL);
5016 
5017  /* set left and right hand side to their default values */
5018  lhs = -SCIPinfinity(scip);
5019  rhs = SCIPinfinity(scip);
5020 
5021  (*success) = FALSE;
5022 
5023  /* return of string empty */
5024  if( !*str )
5025  return SCIP_OKAY;
5026 
5027  /* ignore whitespace */
5028  SCIP_CALL( SCIPskipSpace((char**)&str) );
5029 
5030  if( isdigit(str[0]) || ((str[0] == '-' || str[0] == '+') && isdigit(str[1])) )
5031  {
5032  if( !SCIPparseReal(scip, str, &lhs, &endstr) )
5033  {
5034  SCIPerrorMessage("error parsing left hand side\n");
5035  return SCIP_OKAY;
5036  }
5037 
5038  /* ignore whitespace */
5039  SCIP_CALL( SCIPskipSpace(&endstr) );
5040 
5041  if( endstr[0] != '<' || endstr[1] != '=' )
5042  {
5043  SCIPerrorMessage("missing \"<=\" after left hand side(, found %c%c)\n", endstr[0], endstr[1]);
5044  return SCIP_OKAY;
5045  }
5046 
5047  SCIPdebugMsg(scip, "found left hand side <%g>\n", lhs);
5048 
5049  /* it was indeed a left-hand-side, so continue parsing after it */
5050  str = endstr + 2;
5051  }
5052 
5053  /* pares x + c*y as linear sum */
5054  SCIP_CALL( SCIPallocBufferArray(scip, &vars, 2) );
5055  SCIP_CALL( SCIPallocBufferArray(scip, &coefs, 2) );
5056 
5057  /* parse linear sum to get variables and coefficients */
5058  SCIP_CALL( SCIPparseVarsLinearsum(scip, str, vars, coefs, &nvars, 2, &requiredsize, &endstr, success) );
5059 
5060  if( requiredsize == 2 && *success )
5061  {
5062  SCIP_Real value;
5063 
5064  assert(nvars == 2);
5065  assert(SCIPisEQ(scip, coefs[0], 1.0));
5066 
5067  SCIPdebugMsg(scip, "found linear sum <%s> + %g <%s>\n", SCIPvarGetName(vars[0]), coefs[1], SCIPvarGetName(vars[1]));
5068 
5069  /* ignore whitespace */
5070  SCIP_CALL( SCIPskipSpace(&endstr) );
5071 
5072  str = endstr;
5073 
5074  if( *str != '\0' && *(str+1) != '\0' && SCIPparseReal(scip, str+2, &value, &endstr) )
5075  {
5076  /* search for end of linear sum: either '<=', '>=', '==', or '[free]' */
5077  switch( *str )
5078  {
5079  case '<':
5080  assert(str[1] == '=');
5081  rhs = value;
5082  break;
5083  case '=':
5084  assert(str[1] == '=');
5085  assert(SCIPisInfinity(scip, -lhs));
5086  lhs = value;
5087  rhs = value;
5088  break;
5089  case '>':
5090  assert(str[1] == '=');
5091  assert(SCIPisInfinity(scip, -lhs));
5092  lhs = value;
5093  break;
5094  default:
5095  SCIPerrorMessage("missing relation symbol after linear sum\n");
5096  *success = FALSE;
5097  }
5098  }
5099  else if( strncmp(str, "[free]", 6) != 0 )
5100  *success = FALSE;
5101  }
5102 
5103  if( *success )
5104  {
5105  SCIP_CALL( SCIPcreateConsVarbound(scip, cons, name, vars[0], vars[1], coefs[1], lhs, rhs,
5106  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode) );
5107  }
5108 
5109  /* free buffer arrays */
5110  SCIPfreeBufferArray(scip, &coefs);
5111  SCIPfreeBufferArray(scip, &vars);
5112 
5113  return SCIP_OKAY;
5114 }
5115 
5116 /** constraint method of constraint handler which returns the variables (if possible) */
5117 static
5118 SCIP_DECL_CONSGETVARS(consGetVarsVarbound)
5119 { /*lint --e{715}*/
5120  assert( success != NULL );
5121 
5122  if( varssize < 2 )
5123  (*success) = FALSE;
5124  else
5125  {
5126  SCIP_CONSDATA* consdata;
5127  assert(cons != NULL);
5128  assert(vars != NULL);
5129 
5130  consdata = SCIPconsGetData(cons);
5131  assert(consdata != NULL);
5132 
5133  vars[0] = consdata->var;
5134  vars[1] = consdata->vbdvar;
5135  (*success) = TRUE;
5136  }
5137 
5138  return SCIP_OKAY;
5139 }
5140 
5141 /** constraint method of constraint handler which returns the number of variables (if possible) */
5142 static
5143 SCIP_DECL_CONSGETNVARS(consGetNVarsVarbound)
5144 { /*lint --e{715}*/
5145  (*nvars) = 2;
5146  (*success) = TRUE;
5147 
5148  return SCIP_OKAY;
5149 }
5150 
5151 /*
5152  * Event Handler
5153  */
5154 
5155 /** execution method of bound change event handler */
5156 static
5157 SCIP_DECL_EVENTEXEC(eventExecVarbound)
5158 { /*lint --e{715}*/
5159  SCIP_CONS* cons;
5160  SCIP_CONSDATA* consdata;
5161 
5162  assert(event != NULL);
5163  cons = (SCIP_CONS*)eventdata;
5164  assert(cons != NULL);
5165  consdata = SCIPconsGetData(cons);
5166  assert(consdata != NULL);
5167 
5169  {
5170  consdata->presolved = FALSE;
5171  }
5172  else
5173  {
5174  assert((SCIPeventGetType(event) & SCIP_EVENTTYPE_BOUNDTIGHTENED) != 0);
5175 
5176  consdata->presolved = FALSE;
5177  consdata->tightened = FALSE;
5178 
5179  SCIP_CALL( SCIPmarkConsPropagate(scip, cons) );
5180  }
5181 
5182  return SCIP_OKAY;
5183 }
5184 
5185 /**@} */
5186 
5187 
5188 /** creates the handler for variable bound constraints and includes it in SCIP */
5190  SCIP* scip /**< SCIP data structure */
5191  )
5192 {
5193  SCIP_CONSHDLRDATA* conshdlrdata;
5194  SCIP_EVENTHDLR* eventhdlr;
5195  SCIP_CONSHDLR* conshdlr;
5196 
5197  /* include event handler for bound change events */
5199  eventExecVarbound, NULL) );
5200 
5201  /* create variable bound constraint handler data */
5202  SCIP_CALL( conshdlrdataCreate(scip, &conshdlrdata, eventhdlr) );
5203 
5204  /* include constraint handler */
5207  consEnfolpVarbound, consEnfopsVarbound, consCheckVarbound, consLockVarbound,
5208  conshdlrdata) );
5209  assert(conshdlr != NULL);
5210 
5211  /* set non-fundamental callbacks via specific setter functions */
5212  SCIP_CALL( SCIPsetConshdlrCopy(scip, conshdlr, conshdlrCopyVarbound, consCopyVarbound) );
5213  SCIP_CALL( SCIPsetConshdlrActive(scip, conshdlr, consActiveVarbound) );
5214  SCIP_CALL( SCIPsetConshdlrDeactive(scip, conshdlr, consDeactiveVarbound) );
5215  SCIP_CALL( SCIPsetConshdlrDelete(scip, conshdlr, consDeleteVarbound) );
5216  SCIP_CALL( SCIPsetConshdlrInitsol(scip, conshdlr, consInitsolVarbound) );
5217  SCIP_CALL( SCIPsetConshdlrExitsol(scip, conshdlr, consExitsolVarbound) );
5218  SCIP_CALL( SCIPsetConshdlrFree(scip, conshdlr, consFreeVarbound) );
5219  SCIP_CALL( SCIPsetConshdlrGetVars(scip, conshdlr, consGetVarsVarbound) );
5220  SCIP_CALL( SCIPsetConshdlrGetNVars(scip, conshdlr, consGetNVarsVarbound) );
5221  SCIP_CALL( SCIPsetConshdlrInitlp(scip, conshdlr, consInitlpVarbound) );
5222  SCIP_CALL( SCIPsetConshdlrParse(scip, conshdlr, consParseVarbound) );
5223  SCIP_CALL( SCIPsetConshdlrPresol(scip, conshdlr, consPresolVarbound, CONSHDLR_MAXPREROUNDS, CONSHDLR_PRESOLTIMING) );
5224  SCIP_CALL( SCIPsetConshdlrPrint(scip, conshdlr, consPrintVarbound) );
5225  SCIP_CALL( SCIPsetConshdlrProp(scip, conshdlr, consPropVarbound, CONSHDLR_PROPFREQ, CONSHDLR_DELAYPROP,
5227  SCIP_CALL( SCIPsetConshdlrResprop(scip, conshdlr, consRespropVarbound) );
5228  SCIP_CALL( SCIPsetConshdlrSepa(scip, conshdlr, consSepalpVarbound, consSepasolVarbound, CONSHDLR_SEPAFREQ,
5230  SCIP_CALL( SCIPsetConshdlrTrans(scip, conshdlr, consTransVarbound) );
5231  SCIP_CALL( SCIPsetConshdlrEnforelax(scip, conshdlr, consEnforelaxVarbound) );
5232 
5233  if( SCIPfindConshdlr(scip,"linear") != NULL )
5234  {
5235  /* include the linear constraint to varbound constraint upgrade in the linear constraint handler */
5237  }
5238 
5239  /* add varbound constraint handler parameters */
5241  "constraints/" CONSHDLR_NAME "/presolpairwise",
5242  "should pairwise constraint comparison be performed in presolving?",
5243  &conshdlrdata->presolpairwise, TRUE, DEFAULT_PRESOLPAIRWISE, NULL, NULL) );
5245  "constraints/" CONSHDLR_NAME "/maxlpcoef",
5246  "maximum coefficient in varbound constraint to be added as a row into LP",
5247  &conshdlrdata->maxlpcoef, TRUE, DEFAULT_MAXLPCOEF, 0.0, 1e+20, NULL, NULL) );
5249  "constraints/" CONSHDLR_NAME "/usebdwidening", "should bound widening be used in conflict analysis?",
5250  &conshdlrdata->usebdwidening, FALSE, DEFAULT_USEBDWIDENING, NULL, NULL) );
5251 
5252  return SCIP_OKAY;
5253 }
5254 
5255 /** creates and captures a variable bound constraint: lhs <= x + c*y <= rhs
5256  *
5257  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
5258  */
5260  SCIP* scip, /**< SCIP data structure */
5261  SCIP_CONS** cons, /**< pointer to hold the created constraint */
5262  const char* name, /**< name of constraint */
5263  SCIP_VAR* var, /**< variable x that has variable bound */
5264  SCIP_VAR* vbdvar, /**< binary, integer or implicit integer bounding variable y */
5265  SCIP_Real vbdcoef, /**< coefficient c of bounding variable y */
5266  SCIP_Real lhs, /**< left hand side of variable bound inequality */
5267  SCIP_Real rhs, /**< right hand side of variable bound inequality */
5268  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
5269  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
5270  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
5271  * Usually set to TRUE. */
5272  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
5273  * TRUE for model constraints, FALSE for additional, redundant constraints. */
5274  SCIP_Bool check, /**< should the constraint be checked for feasibility?
5275  * TRUE for model constraints, FALSE for additional, redundant constraints. */
5276  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
5277  * Usually set to TRUE. */
5278  SCIP_Bool local, /**< is constraint only valid locally?
5279  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
5280  SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
5281  * Usually set to FALSE. In column generation applications, set to TRUE if pricing
5282  * adds coefficients to this constraint. */
5283  SCIP_Bool dynamic, /**< is constraint subject to aging?
5284  * Usually set to FALSE. Set to TRUE for own cuts which
5285  * are separated as constraints. */
5286  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
5287  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
5288  SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
5289  * if it may be moved to a more global node?
5290  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
5291  )
5292 {
5293  SCIP_CONSHDLR* conshdlr;
5294  SCIP_CONSHDLRDATA* conshdlrdata;
5295  SCIP_CONSDATA* consdata;
5296 
5297  /* find the variable bound constraint handler */
5298  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5299  if( conshdlr == NULL )
5300  {
5301  SCIPerrorMessage("variable bound constraint handler not found\n");
5302  return SCIP_PLUGINNOTFOUND;
5303  }
5304 
5305  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5306  assert(conshdlrdata != NULL);
5307 
5308  /* create constraint data */
5309  SCIP_CALL( consdataCreate(scip, &consdata, var, vbdvar, vbdcoef, lhs, rhs) );
5310 
5311  /* create constraint */
5312  SCIP_CALL( SCIPcreateCons(scip, cons, name, conshdlr, consdata, initial, separate, enforce, check, propagate,
5313  local, modifiable, dynamic, removable, stickingatnode) );
5314 
5315  if( SCIPisTransformed(scip) )
5316  {
5317  /* catch events for variables */
5318  SCIP_CALL( catchEvents(scip, *cons, conshdlrdata->eventhdlr) );
5319  }
5320 
5321  return SCIP_OKAY;
5322 }
5323 
5324 /** creates and captures a variable bound constraint: lhs <= x + c*y <= rhs
5325  * with all constraint flags set to their default values
5326  *
5327  * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
5328  */
5330  SCIP* scip, /**< SCIP data structure */
5331  SCIP_CONS** cons, /**< pointer to hold the created constraint */
5332  const char* name, /**< name of constraint */
5333  SCIP_VAR* var, /**< variable x that has variable bound */
5334  SCIP_VAR* vbdvar, /**< binary, integer or implicit integer bounding variable y */
5335  SCIP_Real vbdcoef, /**< coefficient c of bounding variable y */
5336  SCIP_Real lhs, /**< left hand side of variable bound inequality */
5337  SCIP_Real rhs /**< right hand side of variable bound inequality */
5338  )
5339 {
5340  SCIP_CALL( SCIPcreateConsVarbound(scip, cons, name, var, vbdvar,vbdcoef, lhs, rhs,
5341  TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
5342 
5343  return SCIP_OKAY;
5344 }
5345 
5346 /** gets left hand side of variable bound constraint lhs <= x + c*y <= rhs */
5348  SCIP* scip, /**< SCIP data structure */
5349  SCIP_CONS* cons /**< constraint data */
5350  )
5351 {
5352  SCIP_CONSDATA* consdata;
5353 
5354  assert(scip != NULL);
5355 
5356  if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), CONSHDLR_NAME) != 0 )
5357  {
5358  SCIPerrorMessage("constraint is not a variable bound constraint\n");
5359  SCIPABORT();
5360  return SCIP_INVALID; /*lint !e527*/
5361  }
5362 
5363  consdata = SCIPconsGetData(cons);
5364  assert(consdata != NULL);
5365 
5366  return consdata->lhs;
5367 }
5368 
5369 /** gets right hand side of variable bound constraint lhs <= x + c*y <= rhs */
5371  SCIP* scip, /**< SCIP data structure */
5372  SCIP_CONS* cons /**< constraint data */
5373  )
5374 {
5375  SCIP_CONSDATA* consdata;
5376 
5377  assert(scip != NULL);
5378 
5379  if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), CONSHDLR_NAME) != 0 )
5380  {
5381  SCIPerrorMessage("constraint is not a variable bound constraint\n");
5382  SCIPABORT();
5383  return SCIP_INVALID; /*lint !e527*/
5384  }
5385 
5386  consdata = SCIPconsGetData(cons);
5387  assert(consdata != NULL);
5388 
5389  return consdata->rhs;
5390 }
5391 
5392 /** gets bounded variable x of variable bound constraint lhs <= x + c*y <= rhs */
5394  SCIP* scip, /**< SCIP data structure */
5395  SCIP_CONS* cons /**< constraint data */
5396  )
5397 {
5398  SCIP_CONSDATA* consdata;
5399 
5400  assert(scip != NULL);
5401 
5402  if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), CONSHDLR_NAME) != 0 )
5403  {
5404  SCIPerrorMessage("constraint is not a variable bound constraint\n");
5405  SCIPABORT();
5406  return NULL; /*lint !e527*/
5407  }
5408 
5409  consdata = SCIPconsGetData(cons);
5410  assert(consdata != NULL);
5411 
5412  return consdata->var;
5413 }
5414 
5415 /** gets bounding variable y of variable bound constraint lhs <= x + c*y <= rhs */
5417  SCIP* scip, /**< SCIP data structure */
5418  SCIP_CONS* cons /**< constraint data */
5419  )
5420 {
5421  SCIP_CONSDATA* consdata;
5422 
5423  assert(scip != NULL);
5424 
5425  if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), CONSHDLR_NAME) != 0 )
5426  {
5427  SCIPerrorMessage("constraint is not a variable bound constraint\n");
5428  SCIPABORT();
5429  return NULL; /*lint !e527*/
5430  }
5431 
5432  consdata = SCIPconsGetData(cons);
5433  assert(consdata != NULL);
5434 
5435  return consdata->vbdvar;
5436 }
5437 
5438 /** gets bound coefficient c of variable bound constraint lhs <= x + c*y <= rhs */
5440  SCIP* scip, /**< SCIP data structure */
5441  SCIP_CONS* cons /**< constraint data */
5442  )
5443 {
5444  SCIP_CONSDATA* consdata;
5445 
5446  assert(scip != NULL);
5447 
5448  if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), CONSHDLR_NAME) != 0 )
5449  {
5450  SCIPerrorMessage("constraint is not a variable bound constraint\n");
5451  SCIPABORT();
5452  return SCIP_INVALID; /*lint !e527*/
5453  }
5454 
5455  consdata = SCIPconsGetData(cons);
5456  assert(consdata != NULL);
5457 
5458  return consdata->vbdcoef;
5459 }
5460 
5461 /** gets the dual solution of the variable bound constraint in the current LP */
5463  SCIP* scip, /**< SCIP data structure */
5464  SCIP_CONS* cons /**< constraint data */
5465  )
5466 {
5467  SCIP_CONSDATA* consdata;
5468 
5469  assert(scip != NULL);
5470 
5471  if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), CONSHDLR_NAME) != 0 )
5472  {
5473  SCIPerrorMessage("constraint is not a variable bound constraint\n");
5474  SCIPABORT();
5475  return SCIP_INVALID; /*lint !e527*/
5476  }
5477 
5478  consdata = SCIPconsGetData(cons);
5479  assert(consdata != NULL);
5480 
5481  if( consdata->row != NULL )
5482  return SCIProwGetDualsol(consdata->row);
5483  else
5484  return 0.0;
5485 }
5486 
5487 /** gets the dual Farkas value of the variable bound constraint in the current infeasible LP */
5489  SCIP* scip, /**< SCIP data structure */
5490  SCIP_CONS* cons /**< constraint data */
5491  )
5492 {
5493  SCIP_CONSDATA* consdata;
5494 
5495  assert(scip != NULL);
5496 
5497  if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), CONSHDLR_NAME) != 0 )
5498  {
5499  SCIPerrorMessage("constraint is not a variable bound constraint\n");
5500  SCIPABORT();
5501  return SCIP_INVALID; /*lint !e527*/
5502  }
5503 
5504  consdata = SCIPconsGetData(cons);
5505  assert(consdata != NULL);
5506 
5507  if( consdata->row != NULL )
5508  return SCIProwGetDualfarkas(consdata->row);
5509  else
5510  return 0.0;
5511 }
5512 
5513 /** returns the linear relaxation of the given variable bound constraint; may return NULL if no LP row was yet created;
5514  * the user must not modify the row!
5515  */
5517  SCIP* scip, /**< SCIP data structure */
5518  SCIP_CONS* cons /**< constraint data */
5519  )
5520 {
5521  SCIP_CONSDATA* consdata;
5522 
5523  assert(scip != NULL);
5524 
5525  if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), CONSHDLR_NAME) != 0 )
5526  {
5527  SCIPerrorMessage("constraint is not a variable bound constraint\n");
5528  SCIPABORT();
5529  return NULL; /*lint !e527*/
5530  }
5531 
5532  consdata = SCIPconsGetData(cons);
5533  assert(consdata != NULL);
5534 
5535  return consdata->row;
5536 }
5537 
5538 /** cleans up (multi-)aggregations and fixings from varbound constraints */
5540  SCIP* scip, /**< SCIP data structure */
5541  SCIP_Bool onlychecked, /**< should only checked constraints be cleaned up? */
5542  SCIP_Bool* infeasible, /**< pointer to return whether the problem was detected to be infeasible */
5543  int* naddconss, /**< pointer to count number of added (linear) constraints */
5544  int* ndelconss, /**< pointer to count number of deleted (varbound) constraints */
5545  int* nchgbds /**< pointer to count number of bound changes */
5546  )
5547 {
5548  SCIP_CONSHDLR* conshdlr;
5549  SCIP_CONSHDLRDATA* conshdlrdata;
5550  SCIP_EVENTHDLR* eventhdlr;
5551  SCIP_CONS** conss;
5552  int nconss;
5553  int i;
5554 
5555  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5556  if( conshdlr == NULL )
5557  return SCIP_OKAY;
5558 
5559  assert(infeasible != NULL);
5560  *infeasible = FALSE;
5561 
5562  assert(naddconss != NULL);
5563  assert(ndelconss != NULL);
5564  assert(nchgbds != NULL);
5565 
5566  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5567  assert(conshdlrdata != NULL);
5568 
5569  eventhdlr = conshdlrdata->eventhdlr;
5570  nconss = onlychecked ? SCIPconshdlrGetNCheckConss(conshdlr) : SCIPconshdlrGetNActiveConss(conshdlr);
5571  conss = onlychecked ? SCIPconshdlrGetCheckConss(conshdlr) : SCIPconshdlrGetConss(conshdlr);
5572 
5573  /* loop backwards since then deleted constraints do not interfere with the loop */
5574  for( i = nconss - 1; i > 0; --i )
5575  {
5576  SCIP_CALL( applyFixings(scip, conss[i], eventhdlr, infeasible, nchgbds, ndelconss, naddconss) );
5577 
5578  if( *infeasible )
5579  break;
5580  }
5581 
5582  return SCIP_OKAY;
5583 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
static void prettifyConss(SCIP *scip, SCIP_CONS **conss, int nconss, int *nchgcoefs, int *nchgsides)
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:59
void SCIPconshdlrSetData(SCIP_CONSHDLR *conshdlr, SCIP_CONSHDLRDATA *conshdlrdata)
Definition: cons.c:4212
int SCIPgetNIntVars(SCIP *scip)
Definition: scip_prob.c:2090
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
#define CONSHDLR_PROP_TIMING
SCIP_RETCODE SCIPincConsAge(SCIP *scip, SCIP_CONS *cons)
Definition: scip_cons.c:1730
SCIP_RETCODE SCIPcreateEmptyRowCons(SCIP *scip, SCIP_ROW **row, SCIP_CONS *cons, const char *name, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool removable)
Definition: scip_lp.c:1422
SCIP_RETCODE SCIPsetConshdlrDelete(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDELETE((*consdelete)))
Definition: scip_cons.c:572
SCIP_Bool SCIPinRepropagation(SCIP *scip)
Definition: scip_tree.c:146
static SCIP_RETCODE separateCons(SCIP *scip, SCIP_CONS *cons, SCIP_Bool usebdwidening, SCIP_SOL *sol, SCIP_RESULT *result)
static void conshdlrdataFree(SCIP *scip, SCIP_CONSHDLRDATA **conshdlrdata)
SCIP_Real SCIPfeastol(SCIP *scip)
SCIP_RETCODE SCIPskipSpace(char **s)
Definition: misc.c:10777
static SCIP_DECL_CONSPROP(consPropVarbound)
SCIP_Bool SCIPisNLPConstructed(SCIP *scip)
Definition: scip_nlp.c:110
SCIP_RETCODE SCIPtightenVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:5203
enum Proprule PROPRULE
#define CONSHDLR_DELAYSEPA
Definition: cons_varbound.c:95
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
public methods for SCIP parameter handling
int SCIPvarGetNLocksDownType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:3299
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:365
static SCIP_RETCODE chgLhs(SCIP *scip, SCIP_CONS *cons, SCIP_Real lhs)
#define SCIP_EVENTTYPE_VARFIXED
Definition: type_event.h:72
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
Definition: cons.c:8349
#define CONSHDLR_DESC
Definition: cons_varbound.c:85
SCIP_RETCODE SCIPsetConshdlrTrans(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSTRANS((*constrans)))
Definition: scip_cons.c:595
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static SCIP_RETCODE consdataCreate(SCIP *scip, SCIP_CONSDATA **consdata, SCIP_VAR *var, SCIP_VAR *vbdvar, SCIP_Real vbdcoef, SCIP_Real lhs, SCIP_Real rhs)
Constraint handler for variable bound constraints .
#define SCIPquadprecSumQD(r, a, b)
Definition: dbldblarith.h:62
static SCIP_RETCODE resolvePropagation(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *infervar, PROPRULE proprule, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Real inferbd, SCIP_Bool usebdwidening)
public methods for memory management
SCIP_RETCODE SCIPcatchVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition: scip_event.c:354
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip_cons.c:886
SCIP_Real SCIPgetLhsVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17923
static SCIP_DECL_CONSSEPALP(consSepalpVarbound)
SCIP_RETCODE SCIPsetConshdlrGetVars(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSGETVARS((*consgetvars)))
Definition: scip_cons.c:825
SCIP_RETCODE SCIPcopyConsLinear(SCIP *scip, SCIP_CONS **cons, SCIP *sourcescip, const char *name, int nvars, SCIP_VAR **sourcevars, SCIP_Real *sourcecoefs, SCIP_Real lhs, SCIP_Real rhs, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, 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 global, SCIP_Bool *valid)
static SCIP_DECL_CONSINITLP(consInitlpVarbound)
int SCIPvarGetNLocksUpType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:3357
SCIP_Bool SCIPparseReal(SCIP *scip, const char *str, SCIP_Real *value, char **endptr)
static SCIP_RETCODE chgRhs(SCIP *scip, SCIP_CONS *cons, SCIP_Real rhs)
public methods for conflict handler plugins and conflict analysis
static SCIP_DECL_CONSENFOLP(consEnfolpVarbound)
SCIP_RETCODE SCIPsetConshdlrEnforelax(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSENFORELAX((*consenforelax)))
Definition: scip_cons.c:317
#define SCIP_VARTYPE_INTEGER_CHAR
Definition: def.h:158
SCIP_RETCODE SCIPresetConsAge(SCIP *scip, SCIP_CONS *cons)
Definition: scip_cons.c:1758
SCIP_RETCODE SCIPdelCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2851
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
Definition: scip_lp.c:1698
#define CONSHDLR_SEPAFREQ
Definition: cons_varbound.c:89
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17979
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPsetConshdlrDeactive(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDEACTIVE((*consdeactive)))
Definition: scip_cons.c:687
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
Definition: scip_event.c:104
SCIP_RETCODE SCIPgetTransformedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **transvar)
Definition: scip_var.c:1439
SCIP_RETCODE SCIPupdateConsFlags(SCIP *scip, SCIP_CONS *cons0, SCIP_CONS *cons1)
Definition: scip_cons.c:1470
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1248
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:17444
#define CONSHDLR_MAXPREROUNDS
Definition: cons_varbound.c:94
SCIP_Bool SCIPisFeasNegative(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE addNlrow(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static SCIP_DECL_CONSTRANS(consTransVarbound)
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4554
#define FALSE
Definition: def.h:96
SCIP_Real SCIPadjustedVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real ub)
Definition: scip_var.c:4645
SCIP_Real SCIPgetDualsolVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
Definition: misc.c:11096
SCIP_RETCODE 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)
Definition: scip_cons.c:175
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
#define TRUE
Definition: def.h:95
#define SCIPdebug(x)
Definition: pub_message.h:93
SCIP_RETCODE SCIPunmarkConsPropagate(SCIP *scip, SCIP_CONS *cons)
Definition: scip_cons.c:1988
SCIP_Real SCIPgetConflictVarUb(SCIP *scip, SCIP_VAR *var)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
SCIP_RETCODE SCIPaddConflictUb(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx)
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
Definition: cons.c:8369
static SCIP_DECL_CONSGETVARS(consGetVarsVarbound)
static SCIP_RETCODE conshdlrdataCreate(SCIP *scip, SCIP_CONSHDLRDATA **conshdlrdata, SCIP_EVENTHDLR *eventhdlr)
SCIP_RETCODE SCIPcleanupConssVarbound(SCIP *scip, SCIP_Bool onlychecked, SCIP_Bool *infeasible, int *naddconss, int *ndelconss, int *nchgbds)
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
Definition: cons.c:8399
public methods for problem variables
SCIP_RETCODE SCIPaddConflictRelaxedLb(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Real relaxedlb)
SCIP_RETCODE SCIPinitConflictAnalysis(SCIP *scip, SCIP_CONFTYPE conftype, SCIP_Bool iscutoffinvolved)
SCIP_RETCODE SCIPtightenVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:5320
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:108
SCIP_RETCODE SCIPsetConshdlrSepa(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSSEPALP((*conssepalp)), SCIP_DECL_CONSSEPASOL((*conssepasol)), int sepafreq, int sepapriority, SCIP_Bool delaysepa)
Definition: scip_cons.c:229
#define CONSHDLR_NAME
Definition: cons_varbound.c:84
#define DEFAULT_PRESOLPAIRWISE
#define SCIPduplicateBufferArray(scip, ptr, source, num)
Definition: scip_mem.h:132
SCIP_ROW * SCIPgetRowVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPchgVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip_var.c:4676
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPaddVarVlb(SCIP *scip, SCIP_VAR *var, SCIP_VAR *vlbvar, SCIP_Real vlbcoef, SCIP_Real vlbconstant, SCIP_Bool *infeasible, int *nbdchgs)
Definition: scip_var.c:6661
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:136
#define QUAD_ASSIGN(a, constant)
Definition: dbldblarith.h:51
SCIP_VAR * SCIPgetVarVarbound(SCIP *scip, SCIP_CONS *cons)
defines macros for basic operations in double-double arithmetic giving roughly twice the precision of...
SCIP_Real SCIPadjustedVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real lb)
Definition: scip_var.c:4613
Constraint handler for the set partitioning / packing / covering constraints .
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip_mem.h:89
static SCIP_DECL_LINCONSUPGD(linconsUpgdVarbound)
#define SCIPdebugPrintCons(x, y, z)
Definition: pub_message.h:102
SCIP_Bool SCIPisTransformed(SCIP *scip)
Definition: scip_general.c:575
SCIP_RETCODE SCIPaddVarVub(SCIP *scip, SCIP_VAR *var, SCIP_VAR *vubvar, SCIP_Real vubcoef, SCIP_Real vubconstant, SCIP_Bool *infeasible, int *nbdchgs)
Definition: scip_var.c:6720
public methods for SCIP variables
SCIP_RETCODE SCIPcreateConsBasicVarbound(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *var, SCIP_VAR *vbdvar, SCIP_Real vbdcoef, SCIP_Real lhs, SCIP_Real rhs)
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
Definition: cons.c:8359
SCIP_RETCODE SCIPsetConshdlrInitlp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSINITLP((*consinitlp)))
Definition: scip_cons.c:618
SCIP_Real SCIProwGetDualsol(SCIP_ROW *row)
Definition: lp.c:17315
#define SCIPdebugMsg
Definition: scip_message.h:78
static SCIP_DECL_CONSPARSE(consParseVarbound)
SCIP_RETCODE SCIPsetConshdlrParse(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPARSE((*consparse)))
Definition: scip_cons.c:802
#define SCIPquadprecDivQD(r, a, b)
Definition: dbldblarith.h:65
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
Definition: cons.c:8151
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:208
SCIP_RETCODE 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)
Definition: scip_cons.c:943
SCIP_Real SCIPepsilon(SCIP *scip)
SCIP_RETCODE SCIPparseVarsLinearsum(SCIP *scip, const char *str, SCIP_VAR **vars, SCIP_Real *vals, int *nvars, int varssize, int *requiredsize, char **endptr, SCIP_Bool *success)
Definition: scip_var.c:704
SCIP_RETCODE SCIPaddConflictLb(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx)
#define QUAD_TO_DBL(x)
Definition: dbldblarith.h:49
real eps
SCIP_Real SCIPfeasCeil(SCIP *scip, SCIP_Real val)
public methods for numerical tolerances
SCIP_RETCODE SCIPcreateConsVarbound(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *var, SCIP_VAR *vbdvar, SCIP_Real vbdcoef, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
Definition: lp.c:17526
#define CONSHDLR_SEPAPRIORITY
Definition: cons_varbound.c:86
SCIP_RETCODE SCIPaddVarLocksType(SCIP *scip, SCIP_VAR *var, SCIP_LOCKTYPE locktype, int nlocksdown, int nlocksup)
Definition: scip_var.c:4259
SCIP_Bool SCIPisConflictAnalysisApplicable(SCIP *scip)
public methods for the branch-and-bound tree
SCIP_Bool SCIPrealToRational(SCIP_Real val, SCIP_Real mindelta, SCIP_Real maxdelta, SCIP_Longint maxdnom, SCIP_Longint *nominator, SCIP_Longint *denominator)
Definition: misc.c:9305
static SCIP_DECL_CONSEXITSOL(consExitsolVarbound)
static SCIP_DECL_EVENTEXEC(eventExecVarbound)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17933
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
Definition: var.c:12230
SCIP_RETCODE SCIPsetConshdlrInitsol(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSINITSOL((*consinitsol)))
Definition: scip_cons.c:438
public methods for managing constraints
SCIP_Real SCIPgetRhsVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPnlrowIsInNLP(SCIP_NLROW *nlrow)
Definition: nlp.c:1872
#define SCIP_PRESOLTIMING_MEDIUM
Definition: type_timing.h:53
SCIP_RETCODE SCIPsetConshdlrCopy(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), SCIP_DECL_CONSCOPY((*conscopy)))
Definition: scip_cons.c:341
SCIP_Real SCIPgetDualfarkasVarbound(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE preprocessConstraintPairs(SCIP *scip, SCIP_CONS **conss, int nconss, SCIP_Bool *cutoff, int *nchgbds, int *ndelconss, int *nchgcoefs, int *nchgsides)
#define SCIPerrorMessage
Definition: pub_message.h:64
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4182
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2778
#define CONSHDLR_PRESOLTIMING
Definition: cons_varbound.c:99
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static SCIP_DECL_CONSHDLRCOPY(conshdlrCopyVarbound)
SCIP_RETCODE SCIPaddNlRow(SCIP *scip, SCIP_NLROW *nlrow)
Definition: scip_nlp.c:363
SCIP_RETCODE SCIPdelConsLocal(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:3482
public methods for event handler plugins and event handlers
static SCIP_DECL_SORTPTRCOMP(consVarboundComp)
SCIP_RETCODE SCIPreleaseNlRow(SCIP *scip, SCIP_NLROW **nlrow)
Definition: scip_nlp.c:1025
SCIP_RETCODE SCIPgetProbvarSum(SCIP *scip, SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
Definition: scip_var.c:1794
#define EVENTHDLR_NAME
SCIP_Real SCIPgetConflictVarLb(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPunlockVarCons(SCIP *scip, SCIP_VAR *var, SCIP_CONS *cons, SCIP_Bool lockdown, SCIP_Bool lockup)
Definition: scip_var.c:4437
#define QUAD(x)
Definition: dbldblarith.h:47
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8090
SCIP_RETCODE SCIPchgVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip_var.c:4766
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
Definition: cons.c:8309
struct SCIP_EventData SCIP_EVENTDATA
Definition: type_event.h:173
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17264
SCIP_RETCODE SCIPsetConshdlrFree(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSFREE((*consfree)))
Definition: scip_cons.c:366
SCIP_CONSHDLRDATA * SCIPconshdlrGetData(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4202
SCIP_RETCODE SCIPtightenVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:6228
#define NULL
Definition: lpi_spx1.cpp:164
SCIP_RETCODE SCIPmarkConsPropagate(SCIP *scip, SCIP_CONS *cons)
Definition: scip_cons.c:1960
static SCIP_DECL_CONSCHECK(consCheckVarbound)
#define REALABS(x)
Definition: def.h:210
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
#define SCIP_CALL(x)
Definition: def.h:394
#define EVENTHDLR_DESC
enum Proprule PROPRULE
Definition: cons_and.c:177
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
void SCIPupdateSolLPConsViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: scip_sol.c:285
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static SCIP_RETCODE propagateCons(SCIP *scip, SCIP_CONS *cons, SCIP_Bool usebdwidening, SCIP_Bool *cutoff, int *nchgbds, int *nchgsides, int *ndelconss)
SCIP_RETCODE SCIPanalyzeConflictCons(SCIP *scip, SCIP_CONS *cons, SCIP_Bool *success)
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
Definition: cons.c:8329
#define DEFAULT_MAXLPCOEF
SCIP_RETCODE SCIPaddRow(SCIP *scip, SCIP_ROW *row, SCIP_Bool forcecut, SCIP_Bool *infeasible)
Definition: scip_cut.c:250
SCIP_RETCODE SCIPsetConshdlrResprop(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSRESPROP((*consresprop)))
Definition: scip_cons.c:641
static void checkRedundancySide(SCIP *scip, SCIP_VAR *var, SCIP_VAR *vbdvar, SCIP_Real coef0, SCIP_Real coef1, SCIP_Real side0, SCIP_Real side1, SCIP_Bool *sideequal, SCIP_Bool *cons0sidered, SCIP_Bool *cons1sidered, SCIP_Bool islhs)
#define SCIPquadprecProdDD(r, a, b)
Definition: dbldblarith.h:58
struct SCIP_ConsData SCIP_CONSDATA
Definition: type_cons.h:65
#define SCIP_EVENTTYPE_BOUNDTIGHTENED
Definition: type_event.h:123
#define CONSHDLR_DELAYPROP
Definition: cons_varbound.c:96
public methods for constraint handler plugins and constraints
SCIP_VAR * SCIPgetVbdvarVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPcreateConsSetpack(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
Definition: cons_setppc.c:9280
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:124
#define SCIP_UNKNOWN
Definition: def.h:207
public data structures and miscellaneous methods
static SCIP_DECL_CONSFREE(consFreeVarbound)
#define SCIP_Bool
Definition: def.h:93
int SCIPgetNImplVars(SCIP *scip)
Definition: scip_prob.c:2135
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
Definition: event.c:1030
#define CONSHDLR_CHECKPRIORITY
Definition: cons_varbound.c:88
static SCIP_RETCODE analyzeConflict(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *infervar, SCIP_Real inferbd, PROPRULE proprule, SCIP_BOUNDTYPE boundtype, SCIP_Bool usebdwidening)
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
Definition: scip_cons.c:2482
#define MAX(x, y)
Definition: tclique_def.h:92
static SCIP_RETCODE addRelaxation(SCIP *scip, SCIP_CONS *cons, SCIP_Bool *infeasible)
static SCIP_DECL_CONSRESPROP(consRespropVarbound)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8110
SCIP_RETCODE SCIPaddConflictRelaxedUb(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Real relaxedub)
public methods for LP management
SCIP_Bool SCIPconsIsDeleted(SCIP_CONS *cons)
Definition: cons.c:8219
public methods for cuts and aggregation rows
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8289
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
Definition: cons.c:8259
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17771
SCIP_RETCODE SCIPdropVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
Definition: scip_event.c:400
SCIP_RETCODE SCIPcreateNlRow(SCIP *scip, SCIP_NLROW **nlrow, const char *name, SCIP_Real constant, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, SCIP_EXPR *expr, SCIP_Real lhs, SCIP_Real rhs, SCIP_EXPRCURV curvature)
Definition: scip_nlp.c:921
#define SCIPquadprecProdQD(r, a, b)
Definition: dbldblarith.h:63
SCIP_Real SCIPgetVbdcoefVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition: scip_var.c:8276
SCIP_Real SCIProwGetDualfarkas(SCIP_ROW *row)
Definition: lp.c:17328
SCIP_RETCODE SCIPlockVarCons(SCIP *scip, SCIP_VAR *var, SCIP_CONS *cons, SCIP_Bool lockdown, SCIP_Bool lockup)
Definition: scip_var.c:4351
#define DEFAULT_USEBDWIDENING
SCIP_RETCODE SCIPsetConshdlrPrint(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRINT((*consprint)))
Definition: scip_cons.c:779
#define CONSHDLR_PROPFREQ
Definition: cons_varbound.c:90
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPchgRhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real rhs)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
#define MAXSCALEDCOEF
SCIP_RETCODE SCIPinferVarLbCons(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_CONS *infercons, int inferinfo, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:5501
#define SCIPquadprecSumQQ(r, a, b)
Definition: dbldblarith.h:67
#define LINCONSUPGD_PRIORITY
int SCIPgetNBinVars(SCIP *scip)
Definition: scip_prob.c:2045
int SCIPconshdlrGetNActiveConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4631
SCIP_Bool SCIPinProbing(SCIP *scip)
Definition: scip_probing.c:97
static SCIP_RETCODE applyFixings(SCIP *scip, SCIP_CONS *cons, SCIP_EVENTHDLR *eventhdlr, SCIP_Bool *cutoff, int *nchgbds, int *ndelconss, int *naddconss)
public methods for the LP relaxation, rows and columns
SCIP_RETCODE SCIPincludeLinconsUpgrade(SCIP *scip, SCIP_DECL_LINCONSUPGD((*linconsupgd)), int priority, const char *conshdlrname)
SCIP_RETCODE SCIPdelNlRow(SCIP *scip, SCIP_NLROW *nlrow)
Definition: scip_nlp.c:391
public methods for nonlinear relaxation
methods for sorting joint arrays of various types
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPreleaseRow(SCIP *scip, SCIP_ROW **row)
Definition: scip_lp.c:1562
#define SCIP_VARTYPE_IMPLINT_CHAR
Definition: def.h:159
public methods for managing events
general public methods
static SCIP_RETCODE tightenCoefs(SCIP *scip, SCIP_CONS *cons, int *nchgcoefs, int *nchgsides, int *ndelconss, SCIP_Bool *cutoff, int *nchgbds)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
public methods for solutions
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)
Definition: cons.c:8120
SCIP_RETCODE SCIPinferVarUbCons(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_CONS *infercons, int inferinfo, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:5615
static SCIP_DECL_CONSCOPY(consCopyVarbound)
SCIP_CONS ** SCIPconshdlrGetCheckConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4574
SCIP_Real SCIPgetHugeValue(SCIP *scip)
#define SCIP_VARTYPE_CONTINUOUS_CHAR
Definition: def.h:160
public methods for the probing mode
static SCIP_DECL_CONSSEPASOL(consSepasolVarbound)
static SCIP_DECL_CONSENFOPS(consEnfopsVarbound)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1119
SCIP_RETCODE SCIPsetConshdlrPresol(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRESOL((*conspresol)), int maxprerounds, SCIP_PRESOLTIMING presoltiming)
Definition: scip_cons.c:534
public methods for message output
SCIP_Bool SCIPisFeasPositive(SCIP *scip, SCIP_Real val)
static SCIP_DECL_CONSENFORELAX(consEnforelaxVarbound)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:17383
SCIP_RETCODE SCIPaggregateVars(SCIP *scip, SCIP_VAR *varx, SCIP_VAR *vary, SCIP_Real scalarx, SCIP_Real scalary, SCIP_Real rhs, SCIP_Bool *infeasible, SCIP_Bool *redundant, SCIP_Bool *aggregated)
Definition: scip_var.c:8401
SCIP_RETCODE SCIPcaptureVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_var.c:1214
#define SCIP_Real
Definition: def.h:186
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
Definition: cons.c:8339
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip_general.c:703
SCIP_RETCODE SCIPsetConshdlrGetNVars(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSGETNVARS((*consgetnvars)))
Definition: scip_cons.c:848
#define CONSHDLR_NEEDSCONS
Definition: cons_varbound.c:97
int SCIPconshdlrGetNCheckConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4617
public methods for message handling
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
Definition: cons.c:8279
static SCIP_Bool checkCons(SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_Bool checklprows)
#define SCIP_INVALID
Definition: def.h:206
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
Definition: cons.c:8269
Proprule
Definition: cons_and.c:169
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
Definition: scip_lp.c:2209
#define SCIPquadprecSumDD(r, a, b)
Definition: dbldblarith.h:60
static SCIP_DECL_CONSDELETE(consDeleteVarbound)
#define CONSHDLR_ENFOPRIORITY
Definition: cons_varbound.c:87
#define SCIP_Longint
Definition: def.h:171
int SCIPvarGetIndex(SCIP_VAR *var)
Definition: var.c:17603
SCIP_Real SCIPgetRowSolFeasibility(SCIP *scip, SCIP_ROW *row, SCIP_SOL *sol)
Definition: scip_lp.c:2164
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17429
#define SCIP_VARTYPE_BINARY_CHAR
Definition: def.h:157
static SCIP_RETCODE consdataFree(SCIP *scip, SCIP_CONSDATA **consdata)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
struct SCIP_ConshdlrData SCIP_CONSHDLRDATA
Definition: type_cons.h:64
SCIP_RETCODE SCIPchgLhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real lhs)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17989
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPconsIsMarkedPropagate(SCIP_CONS *cons)
Definition: cons.c:8299
SCIP_RETCODE SCIPtightenVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:6348
static SCIP_RETCODE upgradeConss(SCIP *scip, SCIP_CONSHDLRDATA *conshdlrdata, SCIP_CONS **conss, int nconss, SCIP_Bool *cutoff, int *naggrvars, int *nchgbds, int *nchgcoefs, int *nchgsides, int *ndelconss, int *naddconss)
static SCIP_RETCODE createRelaxation(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPsetConshdlrActive(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSACTIVE((*consactive)))
Definition: scip_cons.c:664
static SCIP_DECL_CONSLOCK(consLockVarbound)
static SCIP_DECL_CONSPRESOL(consPresolVarbound)
static SCIP_RETCODE dropEvents(SCIP *scip, SCIP_CONS *cons, SCIP_EVENTHDLR *eventhdlr)
static SCIP_DECL_CONSPRINT(consPrintVarbound)
SCIP_RETCODE SCIPsetConshdlrExitsol(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSEXITSOL((*consexitsol)))
Definition: scip_cons.c:462
#define SCIPABORT()
Definition: def.h:366
public methods for global and local (sub)problems
SCIP_Real SCIPround(SCIP *scip, SCIP_Real val)
static SCIP_DECL_CONSACTIVE(consActiveVarbound)
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:17455
static SCIP_DECL_CONSDEACTIVE(consDeactiveVarbound)
static SCIP_RETCODE catchEvents(SCIP *scip, SCIP_CONS *cons, SCIP_EVENTHDLR *eventhdlr)
#define CONSHDLR_EAGERFREQ
Definition: cons_varbound.c:91
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip_sol.c:1361
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:139
SCIP_RETCODE SCIPgetNegatedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **negvar)
Definition: scip_var.c:1527
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:57
static SCIP_DECL_CONSGETNVARS(consGetNVarsVarbound)
SCIP_RETCODE SCIPsetConshdlrProp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPROP((*consprop)), int propfreq, SCIP_Bool delayprop, SCIP_PROPTIMING proptiming)
Definition: scip_cons.c:275
static SCIP_DECL_CONSINITSOL(consInitsolVarbound)
memory allocation routines
SCIP_RETCODE SCIPincludeConshdlrVarbound(SCIP *scip)