Scippy

SCIP

Solving Constraint Integer Programs

sepa_cgmip.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-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 /* #define SCIP_WRITEPROB */
16 /* #define SCIP_OUTPUT */
17 /**@file sepa_cgmip.c
18  * @brief Chvatal-Gomory cuts computed via a sub-MIP
19  * @author Marc Pfetsch
20  *
21  * Separate Chvátal-Gomory cuts using a sub-MIP. The approach is based on the following papers.
22  *
23  * M. Fischetti and A. Lodi@n
24  * Optimizing over the first Chvátal closure,@n
25  * in: M. Jünger and V. Kaibel (eds.) Integer Programming and Combinatorial Optimization IPCO 2005,@n
26  * LNCS 3509, pp. 12-22. Springer, Berlin Heidelberg New York (2005)
27  *
28  * M. Fischetti and A. Lodi@n
29  * Optimizing over the first Chvátal closure,@n
30  * Mathematical Programming 110, 3-20 (2007)
31  *
32  * P. Bonami, G. Cornuéjols, S. Dash, M. Fischetti, and A. Lodi@n
33  * Projected Chvátal-Gomory cuts for mixed integer linear programs,@n
34  * Mathematical Programming 113, No. 2 (2008)
35  *
36  *
37  * There are several versions to generate the final cut:
38  *
39  * - The CMIR-routines of SCIP can be used (if @p usecmir is true). One can determine which bound is
40  * used in the rounding operation (if cmirownbounds is true) or let SCIP choose the best. This
41  * version is generally numerically the most stable.
42  * - If @p usestrongcg is true, we try to generate Strong-CG cuts (as done in sepa_strongcg.c).
43  * - One can directly generate the CG-cut as computed (if @p usecmir and @p usestrongcg are
44  * false). The cut is not take from the solution of the MIP, but is recomputed, and some care (but
45  * not as much as in the first version) has been taken to create a valid cut.
46  *
47  * The computation time of the separation MIP is limited as follows:
48  * - There is a node limit (parameters @a minnodelimit and @a maxnodelimit).
49  * - There is a time limit (parameter @a timelimit).
50  * - If paramter @a earlyterm is true, the separation is run until the first cut that is violated is
51  * found. (Note that these cuts are not necessarily added to the LP, because here also the norm of
52  * the cuts are taken into account - which cannot easily be included into the separation subscip.)
53  * Then the solution is continued for a certain number of nodes.
54  *
55  * @todo Check whether one can weaken the conditions on the continuous variables.
56  * @todo Use pointers to originating separators to sort out cuts that should not be used.
57  *
58  * @warning This separator should be used carefully - it may require a long separation time.
59  */
60 
61 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
62 
63 #include "blockmemshell/memory.h"
64 #include "scip/cons_linear.h"
65 #include "scip/cuts.h"
66 #include "scip/pub_cons.h"
67 #include "scip/pub_lp.h"
68 #include "scip/pub_message.h"
69 #include "scip/pub_misc.h"
70 #include "scip/pub_sepa.h"
71 #include "scip/pub_var.h"
72 #include "scip/scip_branch.h"
73 #include "scip/scip_cons.h"
74 #include "scip/scip_copy.h"
75 #include "scip/scip_cut.h"
76 #include "scip/scip_general.h"
77 #include "scip/scip_lp.h"
78 #include "scip/scip_mem.h"
79 #include "scip/scip_message.h"
80 #include "scip/scip_numerics.h"
81 #include "scip/scip_param.h"
82 #include "scip/scip_prob.h"
83 #include "scip/scip_randnumgen.h"
84 #include "scip/scip_sepa.h"
85 #include "scip/scip_sol.h"
86 #include "scip/scip_solve.h"
87 #include "scip/scip_solvingstats.h"
88 #include "scip/scip_timing.h"
89 #include "scip/scip_tree.h"
90 #include "scip/scip_var.h"
91 #include "scip/scipdefplugins.h"
92 #include "scip/sepa_cgmip.h"
93 #include <string.h>
94 
95 
96 #define SEPA_NAME "cgmip"
97 #define SEPA_DESC "Chvatal-Gomory cuts via MIPs separator"
98 #define SEPA_PRIORITY -1000
99 #define SEPA_FREQ -1
100 #define SEPA_MAXBOUNDDIST 0.0
101 #define SEPA_USESSUBSCIP TRUE /**< does the separator use a secondary SCIP instance? */
102 #define SEPA_DELAY FALSE /**< should separation method be delayed, if other separators found cuts? */
103 
104 #define DEFAULT_MAXROUNDS 5 /**< maximal number of separation rounds per node (-1: unlimited) */
105 #define DEFAULT_MAXROUNDSROOT 50 /**< maximal number of separation rounds in the root node (-1: unlimited) */
106 #define DEFAULT_MAXDEPTH -1 /**< maximal depth at which the separator is applied */
107 #define DEFAULT_DECISIONTREE FALSE /**< Use decision tree to turn separation on/off? */
108 #define DEFAULT_TIMELIMIT 1e20 /**< time limit for sub-MIP (set to infinity in order to be deterministic) */
109 #define DEFAULT_MEMORYLIMIT 1e20 /**< memory limit for sub-MIP */
110 #define DEFAULT_CUTCOEFBND 1000.0 /**< bounds on the values of the coefficients in the CG-cut */
111 #define DEFAULT_MINNODELIMIT 500LL /**< minimum number of nodes considered for sub-MIP (-1: unlimited) */
112 #define DEFAULT_MAXNODELIMIT 5000LL /**< maximum number of nodes considered for sub-MIP (-1: unlimited) */
113 #define DEFAULT_ONLYACTIVEROWS FALSE /**< Use only active rows to generate cuts? */
114 #define DEFAULT_MAXROWAGE -1 /**< maximal age of rows to consider if onlyactiverows is false */
115 #define DEFAULT_ONLYRANKONE FALSE /**< Separate rank 1 inequalities w.r.t. CG-MIP separator? */
116 #define DEFAULT_ONLYINTVARS FALSE /**< Generate cuts for problems with only integer variables? */
117 #define DEFAULT_CONTCONVERT FALSE /**< Convert some integral variables to be continuous to reduce the size of the sub-MIP? */
118 #define DEFAULT_CONTCONVFRAC 0.1 /**< fraction of integral variables converted to be continuous (if contconvert) */
119 #define DEFAULT_CONTCONVMIN 100 /**< minimum number of integral variables before some are converted to be continuous */
120 #define DEFAULT_INTCONVERT FALSE /**< Convert some integral variables attaining fractional values to have integral value? */
121 #define DEFAULT_INTCONVFRAC 0.1 /**< fraction of fractional integral variables converted to have integral value (if intconvert) */
122 #define DEFAULT_INTCONVMIN 100 /**< minimum number of integral variables before some are converted to have integral value */
123 #define DEFAULT_SKIPMULTBOUNDS TRUE /**< Skip the upper bounds on the multipliers in the sub-MIP? */
124 #define DEFAULT_OBJLONE FALSE /**< Should the objective of the sub-MIP only minimize the l1-norm of the multipliers? */
125 #define DEFAULT_OBJWEIGHT 1e-03 /**< objective weight for artificial variables */
126 #define DEFAULT_OBJWEIGHTSIZE TRUE /**< Weight each row by its size? */
127 #define DEFAULT_DYNAMICCUTS TRUE /**< Should generated cuts be removed from the LP if they are no longer tight? */
128 #define DEFAULT_USECMIR TRUE /**< Use CMIR-generator (otherwise add cut directly)? */
129 #define DEFAULT_USESTRONGCG FALSE /**< Use strong CG-function to strengthen cut? */
130 #define DEFAULT_CMIROWNBOUNDS FALSE /**< Tell CMIR-generator which bounds to used in rounding? */
131 #define DEFAULT_USECUTPOOL TRUE /**< Use cutpool to store CG-cuts even if the are not efficient? */
132 #define DEFAULT_PRIMALSEPARATION TRUE /**< Only separate cuts that are tight for the best feasible solution? */
133 #define DEFAULT_EARLYTERM TRUE /**< Terminate separation if a violated (but possibly sub-optimal) cut has been found? */
134 #define DEFAULT_ADDVIOLATIONCONS FALSE /**< Add constraint to subscip that only allows violated cuts (otherwise add obj. limit)?*/
135 #define DEFAULT_ADDVIOLCONSHDLR FALSE /**< Add constraint handler to filter out violated cuts? */
136 #define DEFAULT_CONSHDLRUSENORM TRUE /**< Should the violation constraint handler use the norm of a cut to check for feasibility? */
137 #define DEFAULT_USEOBJUB FALSE /**< Use upper bound on objective function (via primal solution)? */
138 #define DEFAULT_USEOBJLB FALSE /**< Use lower bound on objective function (via lower bound)? */
139 #define DEFAULT_SUBSCIPFAST TRUE /**< Should the settings for the sub-MIP be optimized for speed? */
140 #define DEFAULT_OUTPUT FALSE /**< Should information about the sub-MIP and cuts be displayed? */
141 #define DEFAULT_RANDSEED 101 /**< start random seed for random number generation */
142 
143 #define NROWSTOOSMALL 5 /**< only separate if the number of rows is larger than this number */
144 #define NCOLSTOOSMALL 5 /**< only separate if the number of columns is larger than this number */
145 
146 #define EPSILONVALUE 1e-03 /**< epsilon value needed to model strict-inequalities */
147 #define BETAEPSILONVALUE 1e-02 /**< epsilon value for fracbeta - is larger than EPSILONVALUE for numerical stability */
148 #define STALLNODELIMIT 1000LL /**< number of stalling nodes if earlyterm is true */
149 #define CONSHDLRFULLNORM FALSE /**< compute real cut and compute norm for this (if addviolconshdlr and conshdlrusenorm are true) */
150 #define MINEFFICACY 0.05 /**< minimum efficacy of a cut - compare set.c */
151 #define MAXNSOLS 1000 /**< maximal number of solutions stored in sub-SCIP */
152 #define OBJWEIGHTRANGE 0.01 /**< maximal range of scaling of objective w.r.t. size of rows */
153 
154 /* parameters used for CMIR-generation (taken from sepa_gomory) */
155 #define BOUNDSWITCH 0.9999
156 #define USEVBDS TRUE
157 #define POSTPROCESS TRUE
158 #define MINFRAC 0.0009 /* to allow a deviation of the same size as EPSILONVALUE */
159 #define MAXFRAC 0.9991 /* to allow a deviation of the same size as EPSILONVALUE */
160 #define FIXINTEGRALRHS FALSE
161 #define MAKECONTINTEGRAL FALSE
162 #define MAXWEIGHTRANGE 1e+05 /**< maximal valid range max(|weights|)/min(|weights|) of row weights */
163 
164 #define MAXAGGRLEN(nvars) nvars /**< currently very large to allow any generation; an alternative would be (0.1*(nvars)+1000) */
165 
166 /** separator data */
167 struct SCIP_SepaData
168 {
169  SCIP_RANDNUMGEN* randnumgen; /**< random number generator */
170  int maxrounds; /**< maximal number of separation rounds per node (-1: unlimited) */
171  int maxroundsroot; /**< maximal number of separation rounds in the root node (-1: unlimited) */
172  int maxdepth; /**< maximal depth at which the separator is applied */
173  SCIP_Bool decisiontree; /**< Use decision tree to turn separation on/off? */
174  SCIP_Real timelimit; /**< time limit for subscip */
175  SCIP_Real memorylimit; /**< memory limit for subscip */
176  SCIP_Longint minnodelimit; /**< minimum number of nodes considered for sub-MIP (-1: unlimited) */
177  SCIP_Longint maxnodelimit; /**< maximum number of nodes considered for sub-MIP (-1: unlimited) */
178  SCIP_Real cutcoefbnd; /**< bounds on the values of the coefficients in the CG-cut */
179  SCIP_Bool onlyactiverows; /**< Use only active rows to generate cuts? */
180  int maxrowage; /**< maximal age of rows to consider if onlyactiverows is false */
181  SCIP_Bool onlyrankone; /**< Separate only rank 1 inequalities w.r.t. CG-MIP separator? */
182  SCIP_Bool onlyintvars; /**< Generate cuts for problems with only integer variables? */
183  SCIP_Bool allowlocal; /**< Allow local cuts? */
184  SCIP_Bool contconvert; /**< Convert some integral variables to be continuous to reduce the size of the sub-MIP? */
185  SCIP_Real contconvfrac; /**< fraction of integral variables converted to be continuous (if contconvert) */
186  int contconvmin; /**< minimum number of integral variables before some are converted to be continuous */
187  SCIP_Bool intconvert; /**< Convert some integral variables attaining fractional values to have integral value? */
188  SCIP_Real intconvfrac; /**< fraction of frac. integral variables converted to have integral value (if intconvert) */
189  int intconvmin; /**< minimum number of integral variables before some are converted to have integral value */
190  SCIP_Bool skipmultbounds; /**< Skip the upper bounds on the multipliers in the sub-MIP? */
191  SCIP_Bool objlone; /**< Should the objective of the sub-MIP only minimize the l1-norm of the multipliers? */
192  SCIP_Real objweight; /**< objective weight for artificial variables */
193  SCIP_Bool objweightsize; /**< Weight each row by its size? */
194  SCIP_Bool dynamiccuts; /**< Should generated cuts be removed from the LP if they are no longer tight? */
195  SCIP_Bool usecmir; /**< Use CMIR-generator (otherwise add cut directly)? */
196  SCIP_Bool usestrongcg; /**< Use strong CG-function to strengthen cut? */
197  SCIP_Bool cmirownbounds; /**< Tell CMIR-generator which bounds to used in rounding? */
198  SCIP_Bool usecutpool; /**< Use cutpool to store CG-cuts even if the are not efficient? */
199  SCIP_Bool primalseparation; /**< Only separate cuts that are tight for the best feasible solution? */
200  SCIP_Bool earlyterm; /**< Terminate separation if a violated (but possibly sub-optimal) cut has been found? */
201  SCIP_Bool addviolationcons; /**< Add constraint to subscip that only allows violated cuts? */
202  SCIP_Bool addviolconshdlr; /**< Add constraint handler to filter out violated cuts? */
203  SCIP_Bool conshdlrusenorm; /**< Should the violation constraint handler use the cut-norm to check for feasibility? */
204  SCIP_Bool useobjub; /**< Use upper bound on objective function (via primal solution)? */
205  SCIP_Bool useobjlb; /**< Use lower bound on objective function (via lower bound)? */
206  SCIP_Bool subscipfast; /**< Should the settings for the sub-MIP be optimized for speed? */
207  SCIP_Bool output; /**< Should information about the sub-MIP and cuts be displayed? */
208 };
209 
210 
211 /** what happens for columns in the LP */
213 {
214  colPresent = 0, /**< column is present in the separating MIP */
215  colContinuous = 1, /**< column corresponds to a continuous variable */
216  colConverted = 2, /**< column is converted to be continuous */
217  colAtUb = 3, /**< variable corresponding to column was at it's upper bound and was complemented */
218  colAtLb = 4 /**< variable corresponding to column was at it's lower bound (possibly complemented) */
219 };
221 
222 
223 /** data for the sub-MIP */
224 struct CGMIP_MIPData
225 {
226  SCIP* subscip; /**< pointer to (sub)SCIP data structure containing the auxiliary IP */
227  unsigned int m; /**< number of constraints of subscip */
228  unsigned int n; /**< number of variables of subscip */
229  unsigned int nrows; /**< number of rows of original LP */
230  unsigned int ncols; /**< number of columns of original LP */
231  unsigned int ntotalrows; /**< number of total rows used (possibly including objective rows) */
232 
233  SCIP_VAR** alpha; /**< cut coefficient variable (NULL if not in separating MIP) */
234  SCIP_VAR* beta; /**< rhs of cut */
235  SCIP_VAR** fracalpha; /**< fractional part of lhs of cut (NULL if not present) */
236  SCIP_VAR* fracbeta; /**< fractional part of rhs of cut */
237  CGMIP_COLTYPE* coltype; /**< type for the columns */
238  SCIP_Bool* iscomplemented; /**< whether the variable was complemented */
239  SCIP_Bool* isshifted; /**< whether the variable was shifted to have 0 lower bound */
240 
241  SCIP_VAR** ylhs; /**< auxiliary row variables for lhs (NULL if not present) */
242  SCIP_VAR** yrhs; /**< auxiliary row variables for rhs (NULL if not present) */
243 
244  SCIP_VAR** z; /**< auxiliary variables for upper bounds (NULL if not present) */
245 
246  char normtype; /**< type of norm to use for efficacy norm calculation */
247 
248  /* additional redundant data */
249  SCIP_Bool conshdlrusenorm; /**< copy from sepadata */
250  SCIP_Bool conshdlrfullnorm; /**< compute real cut and compute norm for this (if addviolconshdlr and conshdlrusenorm are true) */
251  SCIP* scip; /**< original SCIP */
252  SCIP_SEPA* sepa; /**< CG-cut separator */
253  SCIP_SEPADATA* sepadata; /**< CG-cut separator data */
254 };
255 typedef struct CGMIP_MIPData CGMIP_MIPDATA;
256 
257 
258 /*
259  * constraint handler to filter out violated cuts
260  */
261 
262 /* constraint handler properties */
263 #define CONSHDLR_NAME "violatedCuts"
264 #define CONSHDLR_DESC "only allow solutions corresponding to violated cuts"
265 
266 /** constraint handler data */
267 struct SCIP_ConshdlrData
268 {
269  CGMIP_MIPDATA* mipdata; /**< data of separating sub-MIP */
270 };
271 
272 /* temporary forward declaration */
273 static
275  SCIP* scip, /**< original scip */
276  SCIP_SEPA* sepa, /**< separator */
277  CGMIP_MIPDATA* mipdata, /**< data for sub-MIP */
278  SCIP_SEPADATA* sepadata, /**< separator data */
279  SCIP_SOL* sol, /**< current solution for sub-MIP */
280  SCIP_Real* cutcoefs, /**< coefficients of the cut */
281  SCIP_Real* cutrhs, /**< rhs of the cut */
282  SCIP_Bool* localrowsused, /**< pointer to store whether local rows were used in summation */
283  SCIP_Bool* localboundsused, /**< pointer to store whether local bounds were used in summation */
284  int * cutrank, /**< pointer to store the cut rank */
285  SCIP_Bool* success /**< whether we produced a valid cut */
286  );
287 
288 /** check whether cut corresponding to solution is violated */
289 static
291  SCIP* scip, /**< SCIP data structure */
292  CGMIP_MIPDATA* mipdata, /**< data of separating sub-MIP */
293  SCIP_SOL* sol, /**< solution to be checked */
294  SCIP_Bool* violated /**< pointer to store if the cut is violated */
295  )
296 {
297  SCIP_Real cutsqrnorm = 0.0;
298  SCIP* subscip;
299  SCIP_Real act;
300  SCIP_Real norm;
301  SCIP_Real val;
302  SCIP_VAR* var;
303  SCIP_Real rhs;
304  unsigned int j;
305  int len = 0;
306 
307  assert( mipdata != NULL );
308  subscip = mipdata->subscip;
309  assert( subscip != NULL );
310  assert( violated != NULL );
311 
312  /* initialize activity and norm */
313  act = 0.0;
314  norm = 1.0;
315  *violated = FALSE;
316 
317  /* compute activity and norm */
318  if ( mipdata->conshdlrusenorm )
319  {
320  /* check whether we should compute the full cut and then compute the norm */
321  if ( mipdata->conshdlrfullnorm )
322  {
323  SCIP_Real* cutcoefs;
324  SCIP_Bool localrowsused;
325  SCIP_Bool localboundsused;
326  SCIP_Bool success;
327  SCIP_VAR** vars;
328  int cutrank = 0;
329  int nvars;
330 
331  /* get data */
332  SCIP_CALL( SCIPgetVarsData(mipdata->scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
333  assert(nvars >= 0);
334  SCIP_CALL( SCIPallocBufferArray(scip, &cutcoefs, nvars) );
335 
336  /* compute coefficients */
337  SCIP_CALL( computeCut(mipdata->scip, mipdata->sepa, mipdata, mipdata->sepadata, sol, cutcoefs, &rhs, &localrowsused, &localboundsused, &cutrank, &success) );
338 
339 #ifdef SCIP_MORE_DEBUG
340  for (j = 0; j < (unsigned int) nvars; ++j)
341  {
342  if ( ! SCIPisZero(scip, cutcoefs[j]) )
343  SCIPinfoMessage(scip, NULL, "+ %f x%d", cutcoefs[j], j);
344  }
345  SCIPinfoMessage(scip, NULL, "\n");
346 #endif
347 
348  /* ignore solution if cut was not valid */
349  if ( ! success )
350  return SCIP_OKAY;
351 
352  /* compute activity and Euclidean norm (todo: use arbitrary norm) */
353  cutsqrnorm = 0.0;
354  for (j = 0; j < (unsigned int) nvars; ++j)
355  {
356  if ( ! SCIPisZero(scip, cutcoefs[j]) )
357  {
358  act += cutcoefs[j] * SCIPvarGetLPSol(vars[j]);
359  cutsqrnorm += SQR(cutcoefs[j]);
360  }
361  }
362  norm = SQRT(cutsqrnorm);
363 
364  SCIPfreeBufferArray(scip, &cutcoefs);
365  }
366  else
367  {
368  switch ( mipdata->normtype )
369  {
370  case 'e':
371  cutsqrnorm = 0.0;
372  for (j = 0; j < mipdata->ncols; ++j)
373  {
374  var = mipdata->alpha[j];
375  if ( var == NULL )
376  continue;
377 
378  val = SCIPgetSolVal(subscip, sol, var);
379  if ( !SCIPisZero(scip, val) )
380  {
381  act += val * SCIPvarGetObj(var);
382  cutsqrnorm += SQR(val);
383  }
384  }
385  norm = SQRT(cutsqrnorm);
386  break;
387  case 'm':
388  for (j = 0; j < mipdata->ncols; ++j)
389  {
390  var = mipdata->alpha[j];
391  if ( var == NULL )
392  continue;
393 
394  val = SCIPgetSolVal(subscip, sol, var);
395  if ( !SCIPisZero(scip, val) )
396  {
397  act += val * SCIPvarGetObj(var);
398  if ( REALABS(val) > norm )
399  norm = REALABS(val);
400  }
401  }
402  break;
403  case 's':
404  for (j = 0; j < mipdata->ncols; ++j)
405  {
406  var = mipdata->alpha[j];
407  if ( var == NULL )
408  continue;
409 
410  val = SCIPgetSolVal(subscip, sol, var);
411  if ( !SCIPisZero(scip, val) )
412  {
413  act += val * SCIPvarGetObj(var);
414  norm += REALABS(val);
415  }
416  }
417  break;
418  case 'd':
419  for (j = 0; j < mipdata->ncols; ++j)
420  {
421  var = mipdata->alpha[j];
422  if ( var == NULL )
423  continue;
424 
425  val = SCIPgetSolVal(subscip, sol, var);
426  if ( !SCIPisZero(scip, val) )
427  {
428  act += val * SCIPvarGetObj(var);
429  ++len;
430  }
431  }
432  if ( len > 0 )
433  norm = 1.0;
434  break;
435  default:
436  SCIPerrorMessage("invalid efficacy norm parameter '%c'\n", mipdata->normtype);
437  return SCIP_INVALIDDATA;
438  }
439  /* get rhs */
440  rhs = SCIPgetSolVal(subscip, sol, mipdata->beta);
441  }
442 
443  /* if norm is 0, the cut is trivial */
444  if ( SCIPisZero(subscip, norm) )
445  return SCIP_OKAY;
446  }
447  else
448  {
449  for (j = 0; j < mipdata->ncols; ++j)
450  {
451  var = mipdata->alpha[j];
452  if ( var == NULL )
453  continue;
454 
455  val = SCIPgetSolVal(subscip, sol, var);
456  if ( !SCIPisZero(subscip, val) )
457  act += SCIPvarGetObj(var) * val;
458  }
459 
460  /* get rhs */
461  rhs = SCIPgetSolVal(subscip, sol, mipdata->beta);
462  }
463 
464 #ifdef SCIP_DEBUG
465  if ( SCIPisEfficacious(subscip, (act - rhs)/norm) )
466  {
467  SCIPdebugMsg(scip, "Violated cut from solution - act: %f, rhs: %f, norm: %f, eff.: %f\n", act, rhs, norm, (act-rhs)/norm);
468  }
469  else
470  {
471  SCIPdebugMsg(scip, "Rejected cut from solution - act: %f, rhs: %f, norm: %f, eff.: %f\n", act, rhs, norm, (act-rhs)/norm);
472  }
473 #endif
474 
475  *violated = SCIPisEfficacious(subscip, (act - rhs)/norm);
476 
477  return SCIP_OKAY;
478 }
479 
480 
481 /** destructor of constraint handler to free constraint handler data (called when SCIP is exiting) */
482 static
483 SCIP_DECL_CONSFREE(consFreeViolatedCuts)
484 { /*lint --e{715}*/
485  SCIP_CONSHDLRDATA* conshdlrdata;
486 
487  assert( scip != NULL );
488  assert( conshdlr != NULL );
489  conshdlrdata = SCIPconshdlrGetData(conshdlr);
490  assert( conshdlrdata != NULL );
491 
492  SCIPfreeBlockMemory(scip, &conshdlrdata);
493 
494  return SCIP_OKAY;
495 }
496 
497 
498 /** constraint enforcing method of constraint handler for LP solutions */
499 static
500 SCIP_DECL_CONSENFOLP(consEnfolpViolatedCuts)
501 { /*lint --e{715}*/
502  SCIP_CONSHDLRDATA* conshdlrdata;
503  SCIP_Bool violated;
504 
505  assert( scip != NULL );
506  assert( conshdlr != NULL );
507  assert( result != NULL );
508 
509  assert( SCIPgetNLPBranchCands(scip) == 0 );
510 
511  conshdlrdata = SCIPconshdlrGetData(conshdlr);
512  assert( conshdlrdata != NULL );
513 
514  SCIP_CALL( solCutIsViolated(scip, conshdlrdata->mipdata, NULL, &violated) );
515 
516  if ( violated )
517  *result = SCIP_FEASIBLE;
518  else
519  *result = SCIP_CUTOFF; /* cutoff, since all integer variables are integer, but the solution is not feasible */
520 
521  return SCIP_OKAY;
522 }
523 
524 
525 /** constraint enforcing method of constraint handler for pseudo solutions */
526 static
527 SCIP_DECL_CONSENFOPS(consEnfopsViolatedCuts)
528 { /*lint --e{715}*/
529  assert( result != NULL );
530 
531  /* this function should better not be called, since we need an LP solution for the sub-MIP to
532  * make sense, because of the multiplier variables. We therefore return SCIP_FEASIBLE. */
533  *result = SCIP_FEASIBLE;
534 
535  return SCIP_OKAY;
536 }
537 
538 
539 /** feasibility check method of constraint handler for integral solutions */
540 static
541 SCIP_DECL_CONSCHECK(consCheckViolatedCuts)
542 { /*lint --e{715}*/
543  SCIP_CONSHDLRDATA* conshdlrdata;
544  SCIP_Bool violated;
545 
546  assert( scip != NULL );
547  assert( conshdlr != NULL );
548  assert( sol != NULL );
549  assert( result != NULL );
550 
551  conshdlrdata = SCIPconshdlrGetData(conshdlr);
552  assert( conshdlrdata != NULL );
553 
554  SCIP_CALL( solCutIsViolated(scip, conshdlrdata->mipdata, sol, &violated) );
555 
556  if ( violated )
557  *result = SCIP_FEASIBLE;
558  else
559  *result = SCIP_INFEASIBLE;
560 
561  return SCIP_OKAY;
562 }
563 
564 
565 /** variable rounding lock method of constraint handler */
566 static
567 SCIP_DECL_CONSLOCK(consLockViolatedCuts)
568 { /*lint --e{715}*/
569  /* do not lock variables */
570  return SCIP_OKAY;
571 }
572 
573 
574 /** creates the violated CG-cut constraint handler and includes it in SCIP */
575 static
577  SCIP* scip, /**< SCIP data structure */
578  CGMIP_MIPDATA* mipdata /**< data of separating sub-MIP */
579  )
580 {
581  SCIP_CONSHDLRDATA* conshdlrdata;
582  SCIP_CONSHDLR* conshdlr;
583 
584  SCIP_CALL( SCIPallocBlockMemory(scip, &conshdlrdata) );
585  conshdlrdata->mipdata = mipdata;
586 
587  /* include constraint handler */
589  -1000000, -1000000, 100, FALSE,
590  consEnfolpViolatedCuts, consEnfopsViolatedCuts, consCheckViolatedCuts, consLockViolatedCuts,
591  conshdlrdata) );
592 
593  assert(conshdlr != NULL);
594 
595  /* set non-fundamental callbacks via specific setter functions */
596  SCIP_CALL( SCIPsetConshdlrFree(scip, conshdlr, consFreeViolatedCuts) );
597 
598  return SCIP_OKAY;
599 }
600 
601 
602 /*
603  * local methods
604  */
605 
606 
607 /** stores nonzero elements of dense coefficient vector as sparse vector and calculates activity and norm
608  *
609  * copied from sepa_gomory.c
610  */
611 static
613  SCIP* scip, /**< SCIP data structure */
614  int nvars, /**< number of problem variables */
615  SCIP_Real* cutcoefs, /**< dense coefficient vector */
616  SCIP_Real* varsolvals, /**< dense variable LP solution vector */
617  char normtype, /**< type of norm to use for efficacy norm calculation */
618  int* cutinds, /**< array to store variables of sparse cut vector */
619  SCIP_Real* cutvals, /**< array to store coefficients of sparse cut vector */
620  int* cutlen, /**< pointer to store number of nonzero entries in cut */
621  SCIP_Real* cutact, /**< pointer to store activity of cut */
622  SCIP_Real* cutnorm /**< pointer to store norm of cut vector */
623  )
624 {
625  SCIP_Real val;
626  SCIP_Real cutsqrnorm;
627  SCIP_Real act;
628  SCIP_Real norm;
629  int len;
630  int v;
631 
632  assert( nvars == 0 || cutcoefs != NULL );
633  assert( nvars == 0 || varsolvals != NULL );
634  assert( cutinds != NULL );
635  assert( cutvals != NULL );
636  assert( cutlen != NULL );
637  assert( cutact != NULL );
638  assert( cutnorm != NULL );
639 
640  len = 0;
641  act = 0.0;
642  norm = 0.0;
643  switch ( normtype )
644  {
645  case 'e':
646  cutsqrnorm = 0.0;
647  for (v = 0; v < nvars; ++v)
648  {
649  val = cutcoefs[v];
650  if ( !SCIPisZero(scip, val) )
651  {
652  act += val * varsolvals[v];
653  cutsqrnorm += SQR(val);
654  cutinds[len] = v;
655  cutvals[len++] = val;
656  }
657  }
658  norm = SQRT(cutsqrnorm);
659  break;
660  case 'm':
661  for (v = 0; v < nvars; ++v)
662  {
663  val = cutcoefs[v];
664  if ( !SCIPisZero(scip, val) )
665  {
666  act += val * varsolvals[v];
667  if ( REALABS(val) > norm )
668  norm = REALABS(val);
669  cutinds[len] = v;
670  cutvals[len++] = val;
671  }
672  }
673  break;
674  case 's':
675  for (v = 0; v < nvars; ++v)
676  {
677  val = cutcoefs[v];
678  if ( !SCIPisZero(scip, val) )
679  {
680  act += val * varsolvals[v];
681  norm += REALABS(val);
682  cutinds[len] = v;
683  cutvals[len++] = val;
684  }
685  }
686  break;
687  case 'd':
688  for (v = 0; v < nvars; ++v)
689  {
690  val = cutcoefs[v];
691  if ( !SCIPisZero(scip, val) )
692  {
693  act += val * varsolvals[v];
694  cutinds[len] = v;
695  cutvals[len++] = val;
696  }
697  }
698  if ( len > 0 )
699  norm = 1.0;
700  break;
701  default:
702  SCIPerrorMessage("invalid efficacy norm parameter '%c'\n", normtype);
703  return SCIP_INVALIDDATA;
704  }
705 
706  *cutlen = len;
707  *cutact = act;
708  *cutnorm = norm;
709 
710  return SCIP_OKAY;
711 }
712 
713 
714 /** Compute lhs/rhs for transformed column
715  *
716  * Consider a variable \f$x_j\f$ and some row of the original system:
717  * \f[
718  * \gamma \leq a^T x \leq \delta, \quad \ell_j \leq x_j \leq u_j.
719  * \f]
720  * We perform the transformation
721  * \f[
722  * x_i' = \left\{
723  * \begin{array}{ll}
724  * s + \frac{1}{\sigma}\, x_j & \mbox{if }i = j\\
725  * x_i & \mbox{otherwise},
726  * \end{array}
727  * \right.
728  * \f]
729  * where \f$s\f$ is the offset value and \f$\sigma\f$ is a scaling factor. The new system is
730  * \f[
731  * \gamma + \sigma\, a_j\,s \leq \sum_{i \neq j} a_i\, x_i' + \sigma a_j\, x_j' \leq \delta + \sigma\, a_j\, s
732  * \f]
733  * with bounds
734  * \f[
735  * \frac{1}{\sigma} \ell_j + s \leq x_j' \leq \frac{1}{\sigma} u_j + s, \qquad \mbox{ if }\sigma > 0
736  * \f]
737  * and
738  * \f[
739  * \frac{1}{\sigma} u_j + s \leq x_j' \leq \frac{1}{\sigma} \ell_j + s, \qquad \mbox{ if }\sigma < 0.
740  * \f]
741  *
742  * This can be used as follows:
743  *
744  * - If \f$x_j \geq \ell_j\f$ has a (nonzero) lower bound, one can use \f$s = -\ell_j\f$, \f$\sigma = 1\f$,
745  * and obtain \f$\gamma - a_j\,\ell_j \leq a^T x' \leq \delta - a_j\,\ell_j\f$, \f$0 \leq x_j' \leq u_j - \ell_j\f$.
746  *
747  * - If \f$x_j \leq u_j\f$ has a (nonzero) upper bound, one can use \f$s = u_j\f$, \f$\sigma = -1\f$,
748  * and obtain \f$\gamma - a_j\,u_j \leq \sum_{i \neq j} a_i\, x_i' - a_j\, x_j' \leq \delta - a_j\, u_j\f$,
749  * \f$0 \leq x_j' \leq u_j - \ell_j\f$.
750  */
751 static
753  SCIP* scip, /**< SCIP data structure */
754  SCIP_SEPADATA* sepadata, /**< separator data */
755  CGMIP_MIPDATA* mipdata, /**< data for sub-MIP */
756  SCIP_COL* col, /**< column that should be complemented */
757  SCIP_Real offset, /**< offset by which column should be shifted */
758  SCIP_Real sigma, /**< scaling factor */
759  SCIP_Real* lhs, /**< array of lhs of rows */
760  SCIP_Real* rhs, /**< array rhs of rows */
761  SCIP_Real* lb, /**< pointer to lb of column */
762  SCIP_Real* ub, /**< pointer to ub of column */
763  SCIP_Real* primsol /**< pointer to solution value */
764  )
765 {
766  SCIP_ROW** colrows;
767  SCIP_Real* colvals;
768  int pos, i;
769 
770  assert( scip != NULL );
771  assert( lhs != NULL );
772  assert( rhs != NULL );
773  assert( col != NULL );
774 
775  colrows = SCIPcolGetRows(col);
776  colvals = SCIPcolGetVals(col);
777  assert( SCIPcolGetNLPNonz(col) == 0 || colrows != NULL );
778  assert( SCIPcolGetNLPNonz(col) == 0 || colvals != NULL );
779  assert( ! SCIPisZero(scip, sigma) );
780 
781  /* loop through rows that contain column */
782  for (i = 0; i < SCIPcolGetNLPNonz(col); ++i)
783  {
784  SCIP_ROW* row;
785 
786  row = colrows[i];
787  assert( row != NULL );
788 
789  /* skip modifiable rows and local rows, unless allowed */
790  if ( SCIProwIsModifiable(row) || (SCIProwIsLocal(row) && !sepadata->allowlocal) )
791  continue;
792 
793  pos = SCIProwGetLPPos(row);
794  assert( 0 <= pos && pos < (int) mipdata->nrows );
795 
796  assert( ! SCIPisInfinity(scip, lhs[pos]) );
797  if ( ! SCIPisInfinity(scip, -lhs[pos]) )
798  lhs[pos] += sigma * colvals[i] * offset;
799 
800  assert( ! SCIPisInfinity(scip, -rhs[pos]) );
801  if ( ! SCIPisInfinity(scip, rhs[pos]) )
802  rhs[pos] += sigma * colvals[i] * offset;
803  }
804 
805  /* check objective function */
806  if ( sepadata->useobjub || sepadata->useobjlb )
807  {
808  assert( SCIPisEQ(scip, SCIPcolGetObj(col), SCIPvarGetObj(SCIPcolGetVar(col))) );
809  assert( mipdata->ntotalrows == mipdata->nrows + 1 );
810 
811  if ( ! SCIPisInfinity(scip, -lhs[mipdata->nrows]) )
812  lhs[mipdata->nrows] += sigma * SCIPcolGetObj(col) * offset;
813 
814  if ( ! SCIPisInfinity(scip, rhs[mipdata->nrows]) )
815  rhs[mipdata->nrows] += sigma * SCIPcolGetObj(col) * offset;
816  }
817 
818  /* correct lower and upper bounds and solution */
819  if ( SCIPisNegative(scip, sigma) )
820  {
821  SCIP_Real l;
822 
823  assert( ! SCIPisInfinity(scip, -*ub) );
824  if ( ! SCIPisInfinity(scip, *ub) )
825  l = *ub/sigma + offset;
826  else
827  l = -SCIPinfinity(scip);
828 
829  assert( ! SCIPisInfinity(scip, *lb) );
830  if ( ! SCIPisInfinity(scip, -*lb) )
831  *ub = *lb/sigma + offset;
832  else
833  *ub = SCIPinfinity(scip);
834  *lb = l;
835  }
836  else
837  {
838  assert( ! SCIPisInfinity(scip, *lb) );
839  if ( ! SCIPisInfinity(scip, -*lb) )
840  *lb = *lb/sigma + offset;
841  assert( ! SCIPisInfinity(scip, -*ub) );
842  if ( ! SCIPisInfinity(scip, *ub) )
843  *ub = *ub/sigma + offset;
844  }
845  *primsol = *primsol/sigma + offset;
846 
847  return SCIP_OKAY;
848 }
849 
850 
851 /** compute objective coefficient for rows that are weighted by size
852  *
853  * The objective is computed by multiplying a default value by
854  * \f[
855  * 1 - (r_{\mbox{max}} - r) \frac{1 - a}{r_{\mbox{max}} - r_{\mbox{min}}},
856  * \f]
857  * where \f$r\f$ is the size of the current row, \f$a \in [0,1]\f$ is a parameter, and \f$r_{\mbox{max}}\f$ and
858  * \f$r_{\mbox{min}}\f$ are the maximal and minimal size of a row, respectively.
859  *
860  * Thus, if \f$r = r_{\mbox{max}}\f$, we get 1 and if \f$r = r_{\mbox{min}}\f$, we get \f$a\f$.
861  */
862 static
864  int rowsize, /**< size of current row */
865  int minrowsize, /**< maximal size of rows */
866  int maxrowsize /**< minimal size of rows */
867  )
868 {
869  SCIP_Real a;
870 
871  assert( maxrowsize > 0 );
872  assert( minrowsize < INT_MAX );
873  assert( minrowsize <= maxrowsize );
874  assert( minrowsize <= rowsize && rowsize <= maxrowsize );
875 
876  if ( minrowsize == maxrowsize )
877  return 1.0;
878 
879  a = (1.0 - OBJWEIGHTRANGE)/((SCIP_Real) (maxrowsize - minrowsize));
880 
881  return 1.0 - a * ((SCIP_Real) (maxrowsize - rowsize));
882 }
883 
884 
885 /** Creates a subscip representing the separating MIP.
886  *
887  * Let the constraints of the original MIP be of the following form:
888  * \f[
889  * \begin{array}{l@{\;}ll}
890  * a \leq A x + & C r & \leq b\\
891  * \ell \leq x & & \leq u\\
892  * c \leq & r & \leq d\\
893  * x \in Z^n.
894  * \end{array}
895  * \f]
896  * Here, some of the bounds may have value \f$\infty\f$ or \f$-\infty\f$. Written in
897  * \f$\leq\f$-form this becomes:
898  * \f[
899  * \begin{array}{r@{\;}l}
900  * \tilde{A} x + \tilde{C} r & \leq \tilde{b}\\
901  * -x & \leq -\ell\\
902  * x & \leq u\\
903  * -r & \leq -c\\
904  * r & \leq d\\
905  * x \in Z^n,
906  * \end{array}
907  * \f]
908  * where we use
909  * \f[
910  * \tilde{A} =
911  * \left[
912  * \begin{array}{r}
913  * -A \\
914  * A
915  * \end{array}
916  * \right],
917  * \quad
918  * \tilde{C} =
919  * \left[
920  * \begin{array}{r}
921  * - C\\
922  * C
923  * \end{array}
924  * \right]
925  * \qquad\mbox{ and }\qquad
926  * \tilde{b} =
927  * \left[
928  * \begin{array}{r}
929  * -a\\
930  * b
931  * \end{array}
932  * \right].
933  * \f]
934  * For the moment we assume that \f$c = 0\f$, i.e., the lower bounds on the continuous variables
935  * are 0. To obtain a Chv&aacute;tal-Gomory cut we have to find nonnegative multipliers \f$y\f$,
936  * \f$\underline{z}\f$, and \f$\overline{z}\f$ such that
937  * \f[
938  * y^T \tilde{A} - \underline{z}^T + \overline{z}^T \in Z \qquad\mbox{ and }\qquad
939  * y^T \tilde{C} \geq 0.
940  * \f]
941  * Note that we use zero multipliers for the bounds on the continuous variables \f$r\f$. Moreover,
942  * if some bounds are infinity, the corresponding multipliers are assumed to be 0. From these
943  * conditions, we obtain
944  * \f[
945  * (y^T \tilde{A} - \underline{z}^T + \overline{z}^T)\, x +
946  * y^T \tilde{C} \, r \leq
947  * y^T \tilde{b} - \underline{z}^T \ell + \overline{z}^T u.
948  * \f]
949  * Because \f$r \geq 0\f$, we can ignore the term \f$y^T \tilde{C} \, r \geq 0\f$ and obtain the
950  * following cut:
951  * \f[
952  * (y^T \tilde{A} - \underline{z}^T + \overline{z}^T )\, x \leq
953  * \lfloor y^T \tilde{b} - \underline{z}^T \ell + \overline{z}^T u \rfloor.
954  * \f]
955  * Assume that \f$\ell = 0\f$ for the meantime. Then the cut can be written as:
956  * \f[
957  * \lfloor y^T \tilde{A} + \overline{z}^T \rfloor \, x \leq
958  * \lfloor y^T \tilde{b} + \overline{z}^T u \rfloor.
959  * \f]
960  *
961  * Following Fischetti and Lodi [2005], let \f$(x^*,r^*)\f$ be a fractional solution of the above
962  * original system. The separating MIP created below is
963  * \f[
964  * \begin{array}{rlr@{\;}l}
965  * \max & \multicolumn{2}{@{}l}{(x^*)^T \alpha - \beta - w^T y} &\\
966  * & f = & \tilde{A}^T y + \overline{z} - \alpha & \\
967  * & \tilde{f} = & \tilde{b}^T y + u^T \overline{z} - \beta &\\
968  * & & \tilde{C}^T y & \geq 0\\
969  * & & 0 \leq f & \leq 1 - \epsilon \\
970  * & & 0 \leq \tilde{f} & \leq 1 - \epsilon\\
971  * & & 0 \leq y, \overline{z} & \leq 1 - \epsilon.\\
972  * & & \alpha \in Z^m, \beta & \in Z.
973  * \end{array}
974  * \f]
975  * Here, \f$w\f$ is a weight vector; it's idea is to make the sum over all components of \f$y\f$ as
976  * small as possible, in order to generate sparse cuts.
977  *
978  * We perform the following additional computations:
979  *
980  * - If the lower bounds on \f$x_i\f$ or \f$r_j\f$ are finite, we shift the variable to have a zero
981  * lower bound, i.e., we replace it by \f$x_i - \ell_i\f$ (or \f$r_j - u_j\f$). This is helpful in
982  * several ways: As seen above, the resulting inequalities/formulations simplify. Moreover, it
983  * allows to drop a variable if \f$x^*_i = 0\f$, see the next comment. If the lower bounds are not
984  * finite, but the upper bounds are finite, we can complement the variable. If the variables are
985  * free, the above formulation changes as follows: For free continuous variables, we require
986  * \f$\tilde{C}^T y = 0\f$. For a free integer variable \f$x_j\f$ (which rarely occurs in
987  * practice), we require \f$f_j = 0\f$, i.e., we force that \f$(\tilde{A}^T y + \overline{z})_j =
988  * \alpha_j\f$.
989  *
990  * - If \f$x^*_j = 0 = \ell_j\f$ (after the above preprocessing), we drop variable \f$\alpha_j\f$
991  * from the formulation. Let \f$(\alpha^*, \beta^*, y^*, \overline{z}^*)\f$ be an
992  * optimal solution to the separating MIP. Then we can compute \f$\alpha_j =
993  * \lfloor(\tilde{A}_j^T y^* + \overline{z}^*)\rfloor\f$.
994  *
995  * - If \f$x^*_i = u_i\f$, we complement the variable and drop it from the formulation, since the
996  * lower bound is 0 afterwards.
997  *
998  * - If a variable has been shifted or complemented, we have to recompute \f$\beta\f$ with the
999  * original lhs/rhs.
1000  *
1001  * - If a continuous variable \f$r_j\f$ is free, we have to force equality for the corresponding components in
1002  * \f$y^T \tilde{C} \, r \geq 0\f$.
1003  *
1004  * - If an integer variable \f$x_i\f$ is free, we are not allowed to round the cut down. In this
1005  * case, the combintation of rows and bounds has to be integral. We force this by requiring that
1006  * \f$f_i = 0\f$.
1007  *
1008  * - If @p contconvert is true some integral variables are randomly treated as if they were
1009  * continuous. This has the effect that in the resulting cut the corresponding coefficient has
1010  * value 0. This makes the cuts more sparse. Moreover, the separation problems should become
1011  * easier.
1012  *
1013  * - If required, i.e., parameter @p primalseparation is true, we force a primal separation step. For
1014  * this we require that the cut is tight at the currently best solution. To get reliable solutions
1015  * we relax equality by EPSILONVALUE.
1016  *
1017  * - If required (via parameters @p useobjub or @p useobjlb), we add a row corresponding to the objective function with
1018  * respect to the current lower and upper bounds.
1019  */
1020 static
1022  SCIP* scip, /**< SCIP data structure */
1023  SCIP_SEPA* sepa, /**< separator */
1024  SCIP_SEPADATA* sepadata, /**< separator data */
1025  CGMIP_MIPDATA* mipdata /**< data for sub-MIP */
1026  )
1027 {
1028  SCIP* subscip;
1029  SCIP_COL** cols;
1030  SCIP_ROW** rows;
1031  SCIP_Real* lhs;
1032  SCIP_Real* rhs;
1033  SCIP_Real* lb;
1034  SCIP_Real* ub;
1035  SCIP_Real* primsol;
1036  SCIP_Real multvarub;
1037 
1038  unsigned int cnt;
1039  unsigned int ucnt;
1040  unsigned int nshifted;
1041  unsigned int ncomplemented;
1042  unsigned int ncontconverted;
1043  unsigned int nintconverted;
1044  unsigned int nlbounds;
1045  unsigned int nubounds;
1046 
1047  SCIP_VAR** consvars;
1048  SCIP_Real* consvals;
1049  SCIP_CONS* cons;
1050  int nconsvars;
1051  char name[SCIP_MAXSTRLEN];
1052 
1053  int ncols;
1054  int nrows;
1055  int ntotalrows;
1056  int maxrowsize = 0;
1057  int minrowsize = INT_MAX;
1058  int i, j;
1059 
1060  assert( scip != NULL );
1061  assert( sepadata != NULL );
1062 
1063  assert( mipdata->subscip == NULL );
1064 
1065  SCIP_CALL( SCIPgetLPColsData(scip, &cols, &ncols) );
1066  SCIP_CALL( SCIPgetLPRowsData(scip, &rows, &nrows) );
1067  assert( ncols > 0 && nrows > 0 );
1068 
1069  mipdata->m = 0;
1070  mipdata->n = 0;
1071  mipdata->nrows = (unsigned int) nrows;
1072  mipdata->ncols = (unsigned int) ncols;
1073  mipdata->ntotalrows = mipdata->nrows;
1074 
1075  if ( sepadata->useobjub || sepadata->useobjlb )
1076  mipdata->ntotalrows = mipdata->nrows + 1;
1077 
1078  assert(mipdata->ntotalrows <= INT_MAX);
1079  ntotalrows = (int) mipdata->ntotalrows;
1080 
1081  /* copy value */
1082  mipdata->conshdlrusenorm = sepadata->conshdlrusenorm;
1083 
1084  /* create subscip */
1085  SCIP_CALL( SCIPcreate( &(mipdata->subscip) ) );
1086  subscip = mipdata->subscip;
1088 
1089  /* add violation constraint handler if requested */
1090  if ( sepadata->addviolconshdlr )
1091  {
1092  SCIP_CALL( SCIPincludeConshdlrViolatedCut(subscip, mipdata) );
1093  }
1094 
1095  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "sepa_cgmip separating MIP (%s)", SCIPgetProbName(scip));
1096  SCIP_CALL( SCIPcreateProb(subscip, name, NULL, NULL , NULL , NULL , NULL , NULL , NULL) );
1098 
1099  /* alloc memory for subscipdata elements */
1100  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(mipdata->alpha), ncols) );
1101  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(mipdata->fracalpha), ncols) );
1102  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(mipdata->coltype), ncols) );
1103  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(mipdata->iscomplemented), ncols) );
1104  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(mipdata->isshifted), ncols) );
1105  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(mipdata->ylhs), ntotalrows) );
1106  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(mipdata->yrhs), ntotalrows) );
1107  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(mipdata->z), 2*ncols) );
1108 
1109  /* get temporary storage */
1110  SCIP_CALL( SCIPallocBufferArray(scip, &lhs, ntotalrows) );
1111  SCIP_CALL( SCIPallocBufferArray(scip, &rhs, ntotalrows) );
1112  SCIP_CALL( SCIPallocBufferArray(scip, &lb, ncols) );
1113  SCIP_CALL( SCIPallocBufferArray(scip, &ub, ncols) );
1114  SCIP_CALL( SCIPallocBufferArray(scip, &primsol, ncols) );
1115 
1116  /* store lhs/rhs for complementing (see below) and compute maximal nonzeros of candidate rows */
1117  for (i = 0; i < nrows; ++i)
1118  {
1119  SCIP_Real val;
1120  SCIP_ROW* row;
1121 
1122  row = rows[i];
1123  assert( row != NULL );
1124 
1125  val = SCIProwGetLhs(row) - SCIProwGetConstant(row);
1126  if ( SCIProwIsIntegral(row) )
1127  val = SCIPfeasCeil(scip, val); /* row is integral: round left hand side up */
1128  lhs[i] = val;
1129 
1130  val = SCIProwGetRhs(row) - SCIProwGetConstant(row);
1131  if ( SCIProwIsIntegral(row) )
1132  val = SCIPfeasFloor(scip, val); /* row is integral: round right hand side down */
1133  rhs[i] = val;
1134 
1135  /* skip modifiable rows and local rows, unless allowed */
1136  if ( SCIProwIsModifiable(row) || (SCIProwIsLocal(row) && !sepadata->allowlocal) )
1137  continue;
1138 
1139  /* skip rows that not have been active for a longer time */
1140  if ( ! sepadata->onlyactiverows && sepadata->maxrowage > 0 && SCIProwGetAge(row) > sepadata->maxrowage )
1141  continue;
1142 
1143  /* check whether we want to skip cut produced by the CGMIP separator */
1144  if ( sepadata->onlyrankone )
1145  {
1146  if ( SCIProwGetOriginSepa(row) == sepa )
1147  continue;
1148  }
1149 
1150  /* determine maximal row size: */
1151  val = SCIPgetRowLPActivity(scip, row);
1152  if ( ! SCIPisInfinity(scip, REALABS(lhs[i])) )
1153  {
1154  if ( ! sepadata->onlyactiverows || SCIPisFeasEQ(scip, val, SCIProwGetLhs(row)) )
1155  {
1156  if ( SCIProwGetNLPNonz(row) > maxrowsize )
1157  maxrowsize = SCIProwGetNLPNonz(row);
1158  if ( SCIProwGetNLPNonz(row) < minrowsize )
1159  minrowsize = SCIProwGetNLPNonz(row);
1160  }
1161  }
1162  else
1163  {
1164  if ( ! SCIPisInfinity(scip, rhs[i]) )
1165  {
1166  if ( ! sepadata->onlyactiverows || SCIPisFeasEQ(scip, val, SCIProwGetRhs(row)) )
1167  {
1168  if ( SCIProwGetNLPNonz(row) > maxrowsize )
1169  maxrowsize = SCIProwGetNLPNonz(row);
1170  if ( SCIProwGetNLPNonz(row) < minrowsize )
1171  minrowsize = SCIProwGetNLPNonz(row);
1172  }
1173  }
1174  }
1175  }
1176  assert( maxrowsize > 0 );
1177  assert( minrowsize < INT_MAX );
1178 
1179  /* add cuts for objective function if required */
1180  if ( sepadata->useobjub )
1181  {
1182  assert( mipdata->ntotalrows == mipdata->nrows + 1 );
1183  rhs[mipdata->nrows] = SCIPgetUpperbound(scip);
1184  assert( ! SCIPisObjIntegral(scip) || SCIPisFeasIntegral(scip, SCIPgetUpperbound(scip)) );
1185 
1186  if ( ! SCIPisInfinity(scip, SCIPgetUpperbound(scip)) && SCIPgetNObjVars(scip) > maxrowsize )
1187  maxrowsize = SCIPgetNObjVars(scip);
1188  if ( ! SCIPisInfinity(scip, SCIPgetUpperbound(scip)) && SCIPgetNObjVars(scip) < minrowsize )
1189  minrowsize = SCIPgetNObjVars(scip);
1190  }
1191  if ( sepadata->useobjlb )
1192  {
1193  assert( mipdata->ntotalrows == mipdata->nrows + 1 );
1194 
1195  if ( SCIPisObjIntegral(scip) )
1196  lhs[mipdata->nrows] = SCIPfeasCeil(scip, SCIPgetLowerbound(scip));
1197  else
1198  lhs[mipdata->nrows] = SCIPgetLowerbound(scip);
1199 
1200  if ( ! SCIPisInfinity(scip, -SCIPgetLowerbound(scip)) && SCIPgetNObjVars(scip) > maxrowsize )
1201  maxrowsize = SCIPgetNObjVars(scip);
1202  if ( ! SCIPisInfinity(scip, -SCIPgetLowerbound(scip)) && SCIPgetNObjVars(scip) < minrowsize )
1203  minrowsize = SCIPgetNObjVars(scip);
1204  }
1205 
1206  /* store lb/ub for complementing and perform preprocessing */
1207  nshifted = 0;
1208  ncomplemented = 0;
1209  ncontconverted = 0;
1210  nintconverted = 0;
1211  nlbounds = 0;
1212  nubounds = 0;
1213  for (j = 0; j < ncols; ++j)
1214  {
1215  SCIP_COL* col;
1216  SCIP_VAR* var;
1217 
1218  col = cols[j];
1219  assert( col != NULL );
1220  var = SCIPcolGetVar(col);
1221  assert( var != NULL );
1222 
1223  primsol[j] = SCIPcolGetPrimsol(col);
1224  assert( SCIPisEQ(scip, SCIPgetVarSol(scip, var), primsol[j]) );
1225 
1226  lb[j] = SCIPvarGetLbGlobal(var);
1227  assert( SCIPisEQ(scip, SCIPvarGetLbLocal(var), SCIPcolGetLb(col)) );
1228 
1229  /* if allowed, try to use stronger local bound */
1230  if ( sepadata->allowlocal && SCIPisGT(scip, SCIPvarGetLbLocal(var), lb[j]) )
1231  lb[j] = SCIPvarGetLbLocal(var);
1232 
1233  ub[j] = SCIPvarGetUbGlobal(var);
1234  assert( SCIPisEQ(scip, SCIPvarGetUbLocal(var), SCIPcolGetUb(col)) );
1235 
1236  /* if allowed, try to use stronger local bound */
1237  if ( sepadata->allowlocal && SCIPisLT(scip, SCIPvarGetUbLocal(var), ub[j]) )
1238  ub[j] = SCIPvarGetUbLocal(var);
1239 
1240  mipdata->coltype[j] = colPresent;
1241  mipdata->iscomplemented[j] = FALSE;
1242  mipdata->isshifted[j] = FALSE;
1243 
1244  /* check status of column/variable */
1245  if ( SCIPcolIsIntegral(col) )
1246  {
1247  /* integral variables taking integral values are not interesting - will be substituted out below */
1248  if ( ! SCIPisFeasIntegral(scip, primsol[j]) )
1249  {
1250  /* possibly convert fractional integral variables to take integral values */
1251  if ( sepadata->intconvert && ncols >= sepadata->intconvmin )
1252  {
1253  /* randomly convert variables */
1254  if ( SCIPrandomGetReal(sepadata->randnumgen, 0.0, 1.0) <= sepadata->intconvfrac )
1255  {
1256  assert( ! SCIPisInfinity(scip, ub[j]) || ! SCIPisInfinity(scip, -lb[j]) );
1257 
1258  /* if both bounds are finite, take the closer one */
1259  if ( ! SCIPisInfinity(scip, ub[j]) && ! SCIPisInfinity(scip, -lb[j]) )
1260  {
1261  assert( SCIPisFeasIntegral(scip, ub[j]) );
1262  assert( SCIPisFeasIntegral(scip, lb[j]) );
1263  assert( SCIPisFeasLT(scip, primsol[j], ub[j]) );
1264  assert( SCIPisFeasGT(scip, primsol[j], lb[j]) );
1265  if ( ub[j] - primsol[j] < primsol[j] - lb[j] )
1266  primsol[j] = ub[j];
1267  else
1268  primsol[j] = lb[j];
1269  ++nintconverted;
1270  }
1271  else
1272  {
1273  /* if only lower bound is finite */
1274  if ( ! SCIPisInfinity(scip, -lb[j]) )
1275  {
1276  assert( SCIPisFeasIntegral(scip, lb[j]) );
1277  primsol[j] = lb[j];
1278  ++nintconverted;
1279  }
1280  else
1281  {
1282  assert( ! SCIPisInfinity(scip, ub[j]) );
1283  assert( SCIPisFeasIntegral(scip, ub[j]) );
1284  primsol[j] = ub[j];
1285  ++nintconverted;
1286  }
1287  }
1288  }
1289  }
1290  }
1291 
1292  /* integral variables taking integral values are not interesting - will be substituted out below */
1293  if ( ! SCIPisFeasIntegral(scip, primsol[j]) )
1294  {
1295  /* possibly convert integral variables to be continuous */
1296  if ( sepadata->contconvert && ncols >= sepadata->contconvmin )
1297  {
1298  /* randomly convert variables */
1299  if ( SCIPrandomGetReal(sepadata->randnumgen, 0.0, 1.0) <= sepadata->contconvfrac )
1300  {
1301  /* preprocessing is also performed for converted columns */
1302  mipdata->coltype[j] = colConverted;
1303  ++ncontconverted;
1304  }
1305  }
1306  }
1307  }
1308  else
1309  {
1310  /* detect continuous variables, but perform preprocessing for them */
1311  mipdata->coltype[j] = colContinuous;
1312  }
1313 
1314  /* if integer variable is at its upper bound -> complementing (this also generates a 0 lower bound) */
1315  if ( mipdata->coltype[j] == colPresent && SCIPisFeasEQ(scip, primsol[j], ub[j]) )
1316  {
1317  assert( ! SCIPisInfinity(scip, ub[j]) );
1318  SCIP_CALL( transformColumn(scip, sepadata, mipdata, col, ub[j], -1.0, lhs, rhs, &(lb[j]), &(ub[j]), &(primsol[j])) );
1319  mipdata->iscomplemented[j] = TRUE;
1320  mipdata->coltype[j] = colAtUb;
1321  ++nubounds;
1322  }
1323  else
1324  {
1325  /* if a variable has a finite nonzero lower bound -> shift */
1326  if ( ! SCIPisInfinity(scip, -lb[j]) )
1327  {
1328  if ( ! SCIPisZero(scip, lb[j]) )
1329  {
1330  SCIP_CALL( transformColumn(scip, sepadata, mipdata, col, -lb[j], 1.0, lhs, rhs, &(lb[j]), &(ub[j]), &(primsol[j])) );
1331  assert( SCIPisZero(scip, lb[j]) );
1332  mipdata->isshifted[j] = TRUE;
1333  ++nshifted;
1334  }
1335 
1336  /* if integer variable is at its lower bound */
1337  if ( mipdata->coltype[j] == colPresent && SCIPisZero(scip, primsol[j]) )
1338  {
1339  mipdata->coltype[j] = colAtLb;
1340  ++nlbounds;
1341  }
1342  }
1343  else
1344  {
1345  /* lower bound is minus-infinity -> check whether upper bound is finite */
1346  if ( ! SCIPisInfinity(scip, ub[j]) )
1347  {
1348  /* complement variable */
1349  SCIP_CALL( transformColumn(scip, sepadata, mipdata, col, ub[j], -1.0, lhs, rhs, &(lb[j]), &(ub[j]), &(primsol[j])) );
1350  assert( SCIPisZero(scip, lb[j]) );
1351  mipdata->iscomplemented[j] = TRUE;
1352  ++ncomplemented;
1353 
1354  /* if integer variable is at its lower bound */
1355  if ( mipdata->coltype[j] == colPresent && SCIPisZero(scip, primsol[j]) )
1356  {
1357  mipdata->coltype[j] = colAtLb;
1358  ++nlbounds;
1359  }
1360  }
1361  }
1362  }
1363 
1364  assert( SCIPisFeasLE(scip, lb[j], primsol[j]) );
1365  assert( SCIPisFeasLE(scip, primsol[j], ub[j]) );
1366  }
1367 
1368 #ifndef NDEBUG
1369  if ( sepadata->intconvert && ncols >= sepadata->intconvmin )
1370  {
1371  SCIPdebugMsg(scip, "Converted %u fractional integral variables to have integral value.\n", nintconverted);
1372  }
1373  if ( sepadata->contconvert && ncols >= sepadata->contconvmin )
1374  {
1375  SCIPdebugMsg(scip, "Converted %u integral variables to be continuous.\n", ncontconverted);
1376  }
1377 #endif
1378  SCIPdebugMsg(scip, "original variables: %d integral, %d continuous, %u shifted, %u complemented, %u at lb, %u at ub\n",
1380  nshifted, ncomplemented, nlbounds, nubounds);
1381 
1382  /* prepare upper bound on y-variables */
1383  if ( sepadata->skipmultbounds )
1384  multvarub = SCIPinfinity(scip);
1385  else
1386  multvarub = 1.0-EPSILONVALUE;
1387 
1388  /* create artificial variables for row combinations (y-variables) */
1389  cnt = 0;
1390  for (i = 0; i < nrows; ++i)
1391  {
1392  SCIP_ROW* row;
1393 
1394  row = rows[i];
1395  assert( row != NULL );
1396 
1397  mipdata->ylhs[i] = NULL;
1398  mipdata->yrhs[i] = NULL;
1399 
1400  /* skip modifiable rows and local rows, unless allowed */
1401  if ( SCIProwIsModifiable(row) || (SCIProwIsLocal(row) && !sepadata->allowlocal) )
1402  continue;
1403 
1404  /* skip rows that not have been active for a longer time */
1405  if ( ! sepadata->onlyactiverows && sepadata->maxrowage > 0 && SCIProwGetAge(row) > sepadata->maxrowage )
1406  continue;
1407 
1408  /* check whether we want to skip cut produced by the CGMIP separator */
1409  if ( sepadata->onlyrankone )
1410  {
1411  if ( SCIProwGetOriginSepa(row) == sepa )
1412  continue;
1413  }
1414 
1415  /* if we have an equation */
1416  if ( SCIPisEQ(scip, lhs[i], rhs[i]) )
1417  {
1418  SCIP_Real weight = -sepadata->objweight;
1419 
1420  assert( ! SCIPisInfinity(scip, rhs[i]) );
1421  assert( SCIPisFeasEQ(scip, SCIPgetRowLPActivity(scip, row), SCIProwGetLhs(row)) ); /* equations should always be active */
1422  assert( SCIPisFeasEQ(scip, SCIPgetRowLPActivity(scip, row), SCIProwGetRhs(row)) );
1423 
1424  if ( sepadata->objweightsize )
1425  weight = - sepadata->objweight * computeObjWeightSize(SCIProwGetNLPNonz(row), minrowsize, maxrowsize);
1426 
1427  /* create two variables for each equation */
1428  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "yeq1_%d", i);
1429  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->ylhs[i]), name, 0.0, multvarub,
1431  SCIP_CALL( SCIPaddVar(subscip, mipdata->ylhs[i]) );
1432  ++cnt;
1433 
1434 #ifdef SCIP_MORE_DEBUG
1435  SCIPdebugMsg(scip, "Created variable <%s> for equation <%s>.\n", name, SCIProwGetName(row));
1436 #endif
1437 
1438  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "yeq2_%d", i);
1439  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->yrhs[i]), name, 0.0, multvarub,
1441  SCIP_CALL( SCIPaddVar(subscip, mipdata->yrhs[i]) );
1442  ++cnt;
1443 
1444 #ifdef SCIP_MORE_DEBUG
1445  SCIPdebugMsg(scip, "Created variable <%s> for equation <%s>.\n", name, SCIProwGetName(row));
1446 #endif
1447  }
1448  else
1449  {
1450  /* create variable for lhs of row if necessary */
1451  if ( ! SCIPisInfinity(scip, -lhs[i]) )
1452  {
1453  SCIP_Bool isactive = FALSE;
1454  SCIP_Real weight = 0.0;
1455 
1456  /* if the row is active, use objective weight equal to -sepadata->objweight */
1457  if ( SCIPisFeasEQ(scip, SCIPgetRowLPActivity(scip, row), SCIProwGetLhs(row)) )
1458  {
1459  isactive = TRUE;
1460  if ( sepadata->objweightsize )
1461  weight = -sepadata->objweight * computeObjWeightSize(SCIProwGetNLPNonz(row), minrowsize, maxrowsize);
1462  else
1463  weight = -sepadata->objweight;
1464  }
1465 
1466  if ( ! sepadata->onlyactiverows || isactive )
1467  {
1468  /* add variable */
1469  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "ylhs_%d", i);
1470  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->ylhs[i]), name, 0.0, multvarub,
1472  SCIP_CALL( SCIPaddVar(subscip, mipdata->ylhs[i]) );
1473  ++cnt;
1474 
1475 #ifdef SCIP_MORE_DEBUG
1476  SCIPdebugMsg(scip, "Created variable <%s> for >= inequality <%s> (weight: %f).\n", name, SCIProwGetName(row), weight);
1477 #endif
1478  }
1479  }
1480 
1481  /* create variable for rhs of row if necessary */
1482  if ( ! SCIPisInfinity(scip, rhs[i]) )
1483  {
1484  SCIP_Bool isactive = FALSE;
1485  SCIP_Real weight = 0.0;
1486 
1487  /* if the row is active, use objective weight equal to -sepadata->objweight */
1488  if ( SCIPisFeasEQ(scip, SCIPgetRowLPActivity(scip, row), SCIProwGetRhs(row)) )
1489  {
1490  isactive = TRUE;
1491  if ( sepadata->objweightsize )
1492  weight = -sepadata->objweight * computeObjWeightSize(SCIProwGetNLPNonz(row), minrowsize, maxrowsize);
1493  else
1494  weight = -sepadata->objweight;
1495  }
1496 
1497  if ( ! sepadata->onlyactiverows || isactive )
1498  {
1499  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "yrhs_%d", i);
1500  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->yrhs[i]), name, 0.0, multvarub,
1502  SCIP_CALL( SCIPaddVar(subscip, mipdata->yrhs[i]) );
1503  ++cnt;
1504 
1505 #ifdef SCIP_MORE_DEBUG
1506  SCIPdebugMsg(scip, "Created variable <%s> for <= inequality <%s> (weight: %f).\n", name, SCIProwGetName(row), weight);
1507 #endif
1508  }
1509  }
1510  }
1511  }
1512  assert( (int) cnt <= 2 * nrows );
1513  mipdata->n += cnt;
1514 
1515  /* create artificial variables for objective function (if required) (y-variables) */
1516  if ( sepadata->useobjub || sepadata->useobjlb )
1517  {
1518  SCIP_Real weight = 0.0;
1519 
1520  assert( mipdata->ntotalrows == mipdata->nrows + 1 );
1521  mipdata->ylhs[mipdata->nrows] = NULL;
1522  mipdata->yrhs[mipdata->nrows] = NULL;
1523  cnt = 0;
1524 
1525  if ( sepadata->objweightsize )
1526  weight = -sepadata->objweight * computeObjWeightSize(SCIPgetNObjVars(scip), minrowsize, maxrowsize);
1527  else
1528  weight = -sepadata->objweight;
1529 
1530  /* create variable for upper objective bound if necessary */
1531  if ( sepadata->useobjub && ! SCIPisInfinity(scip, rhs[mipdata->nrows]) )
1532  {
1533  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "yobjub");
1534  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->yrhs[mipdata->nrows]), name, 0.0, multvarub,
1536  SCIP_CALL( SCIPaddVar(subscip, mipdata->yrhs[mipdata->nrows]) );
1537  ++cnt;
1538 
1539 #ifdef SCIP_MORE_DEBUG
1540  SCIPdebugMsg(scip, "Created variable <%s> for upper bound on objective (weight: %f).\n", name, weight);
1541 #endif
1542  }
1543 
1544  /* create variable for lower bound objective if necessary */
1545  if ( sepadata->useobjlb && ! SCIPisInfinity(scip, -lhs[mipdata->nrows]) )
1546  {
1547  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "yobjlb");
1548  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->ylhs[mipdata->nrows]), name, 0.0, multvarub,
1550  SCIP_CALL( SCIPaddVar(subscip, mipdata->ylhs[mipdata->nrows]) );
1551  ++cnt;
1552 
1553 #ifdef SCIP_MORE_DEBUG
1554  SCIPdebugMsg(scip, "Created variable <%s> for lower bound on objective (weight: %f).\n", name, weight);
1555 #endif
1556  }
1557 
1558  assert( (int) cnt <= 2 * ntotalrows );
1559  mipdata->n += cnt;
1560  }
1561 
1562  /* create alpha, bound, and fractional variables */
1563  cnt = 0;
1564  ucnt = 0;
1565  for (j = 0; j < ncols; ++j)
1566  {
1567  mipdata->z[j] = NULL;
1568  mipdata->alpha[j] = NULL;
1569  mipdata->fracalpha[j] = NULL;
1570 
1571  if ( mipdata->coltype[j] == colPresent )
1572  {
1573  SCIP_Real obj;
1574 
1575  if ( sepadata->objlone )
1576  obj = 0.0;
1577  else
1578  obj = primsol[j];
1579 
1580  /* create alpha variables */
1581  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "alpha_%d", j);
1582  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->alpha[j]), name, -sepadata->cutcoefbnd, sepadata->cutcoefbnd, obj,
1584  SCIP_CALL( SCIPaddVar(subscip, mipdata->alpha[j]) );
1585  ++cnt;
1586 
1587  /* create fractional variables */
1588  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "f_%d", j);
1589  if ( SCIPisInfinity(scip, -lb[j]) && SCIPisInfinity(scip, ub[j]) )
1590  {
1591  /* fix fractional value to be zero for free original variables */
1592  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->fracalpha[j]), name, 0.0, 0.0, 0.0,
1594  }
1595  else
1596  {
1597  /* fractional value in [0, 1) for variables with finite bounds */
1598  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->fracalpha[j]), name, 0.0, 1.0-EPSILONVALUE, 0.0,
1600  }
1601  SCIP_CALL( SCIPaddVar(subscip, mipdata->fracalpha[j]) );
1602  ++cnt;
1603 
1604  /* create variables for upper bounds */
1605  if ( ! SCIPisInfinity(scip, ub[j]) )
1606  {
1607  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "zub_%d", j);
1608  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->z[j]), name, 0.0, multvarub,
1610  SCIP_CALL( SCIPaddVar(subscip, mipdata->z[j]) );
1611  ++ucnt;
1612  }
1613  }
1614  }
1615  assert( (int) cnt <= 2 * ncols );
1616  assert( (int) ucnt <= ncols );
1617 
1618  /* create variable for the rhs of the cut */
1619  if ( sepadata->objlone )
1620  {
1621  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->beta), "beta", -sepadata->cutcoefbnd, sepadata->cutcoefbnd, 0.0,
1623  }
1624  else
1625  {
1626  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->beta), "beta", -sepadata->cutcoefbnd, sepadata->cutcoefbnd, -1.0,
1628  }
1629  SCIP_CALL( SCIPaddVar(subscip, mipdata->beta) );
1630 
1631  /* create fractional variable for the rhs */
1632  SCIP_CALL( SCIPcreateVar(subscip, &(mipdata->fracbeta), "fracbeta", 0.0, 1.0-BETAEPSILONVALUE, 0.0,
1634  SCIP_CALL( SCIPaddVar(subscip, mipdata->fracbeta) );
1635  mipdata->n += cnt + ucnt + 2;
1636 
1637  /* get temporary storage */
1638  SCIP_CALL( SCIPallocBufferArray(scip, &consvals, (int) mipdata->n) );
1639  SCIP_CALL( SCIPallocBufferArray(scip, &consvars, (int) mipdata->n) );
1640 
1641  /* create constraints for alpha variables of CG-cut */
1642  cnt = 0;
1643  for (j = 0; j < ncols; ++j)
1644  {
1645  SCIP_ROW** colrows;
1646  SCIP_Real* colvals;
1647 
1648  /* create ordinary part for all selected variables */
1649  if ( mipdata->coltype[j] == colPresent )
1650  {
1651  SCIP_Real sigma;
1652 
1653  assert( cols[j] != NULL );
1654  colrows = SCIPcolGetRows(cols[j]);
1655  colvals = SCIPcolGetVals(cols[j]);
1656  nconsvars = 0;
1657 
1658  if ( mipdata->iscomplemented[j] )
1659  sigma = -1.0;
1660  else
1661  sigma = 1.0;
1662 
1663  /* add part for columns */
1664  for (i = 0; i < SCIPcolGetNLPNonz(cols[j]); ++i)
1665  {
1666  SCIP_ROW* row;
1667  int pos;
1668 
1669  row = colrows[i];
1670  assert( row != NULL );
1671 
1672  /* skip modifiable rows and local rows, unless allowed */
1673  if ( SCIProwIsModifiable(row) || (SCIProwIsLocal(row) && !sepadata->allowlocal) )
1674  continue;
1675 
1676  pos = SCIProwGetLPPos(row);
1677  assert( 0 <= pos && pos < nrows );
1678 
1679  if ( mipdata->ylhs[pos] != NULL )
1680  {
1681  consvars[nconsvars] = mipdata->ylhs[pos];
1682  consvals[nconsvars] = -sigma * colvals[i];
1683  ++nconsvars;
1684  }
1685  if ( mipdata->yrhs[pos] != NULL )
1686  {
1687  consvars[nconsvars] = mipdata->yrhs[pos];
1688  consvals[nconsvars] = sigma * colvals[i];
1689  ++nconsvars;
1690  }
1691  assert( nconsvars <= (int) mipdata->n );
1692  }
1693  /* add part for upper bounds */
1694  if ( mipdata->z[j] != NULL )
1695  {
1696  assert( ! SCIPisInfinity(scip, ub[j]) );
1697  consvars[nconsvars] = mipdata->z[j];
1698  consvals[nconsvars] = 1.0;
1699  ++nconsvars;
1700  }
1701  assert( nconsvars <= (int) mipdata->n );
1702 
1703  /* add alpha variable */
1704  consvars[nconsvars] = mipdata->alpha[j];
1705  consvals[nconsvars] = -1.0;
1706  ++nconsvars;
1707  assert( nconsvars <= (int) mipdata->n );
1708 
1709  /* add fractional-alpha variable */
1710  consvars[nconsvars] = mipdata->fracalpha[j];
1711  consvals[nconsvars] = -1.0;
1712  ++nconsvars;
1713  assert( nconsvars <= (int) mipdata->n );
1714 
1715  /* check for lower and upper objective bounds */
1716  if ( (sepadata->useobjub || sepadata->useobjlb) && ! SCIPisZero(scip, SCIPcolGetObj(cols[j])) )
1717  {
1718  /* add lower objective bound */
1719  if ( mipdata->ylhs[mipdata->nrows] != NULL )
1720  {
1721  assert( sepadata->useobjlb );
1722  consvars[nconsvars] = mipdata->ylhs[mipdata->nrows];
1723  consvals[nconsvars] = -sigma * SCIPcolGetObj(cols[j]);
1724  ++nconsvars;
1725  }
1726 
1727  /* add upper objective bound */
1728  if ( mipdata->yrhs[mipdata->nrows] != NULL )
1729  {
1730  assert( sepadata->useobjub );
1731  consvars[nconsvars] = mipdata->yrhs[mipdata->nrows];
1732  consvals[nconsvars] = sigma * SCIPcolGetObj(cols[j]);
1733  ++nconsvars;
1734  }
1735  }
1736 
1737  /* add linear constraint */
1738  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "alpha_%d", j);
1739  SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, name, nconsvars, consvars, consvals, 0.0, 0.0,
1740  TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1741  SCIP_CALL( SCIPaddCons(subscip, cons) );
1742  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
1743  ++cnt;
1744  }
1745  /* generate part that makes sure that cut is valid for continuous variables */
1746  else if ( mipdata->coltype[j] == colContinuous || mipdata->coltype[j] == colConverted )
1747  {
1748  SCIP_Real sigma;
1749  SCIP_Real r;
1750 
1751  assert( cols[j] != NULL );
1752  colrows = SCIPcolGetRows(cols[j]);
1753  colvals = SCIPcolGetVals(cols[j]);
1754  nconsvars = 0;
1755 
1756  if ( mipdata->iscomplemented[j] )
1757  sigma = -1.0;
1758  else
1759  sigma = 1.0;
1760 
1761  /* add part for columns */
1762  for (i = 0; i < SCIPcolGetNLPNonz(cols[j]); ++i)
1763  {
1764  SCIP_ROW* row;
1765  int pos;
1766 
1767  row = colrows[i];
1768  assert( row != NULL );
1769 
1770  /* skip modifiable rows and local rows, unless allowed */
1771  if ( SCIProwIsModifiable(row) || (SCIProwIsLocal(row) && !sepadata->allowlocal) )
1772  continue;
1773 
1774  pos = SCIProwGetLPPos(row);
1775  assert( 0 <= pos && pos < nrows );
1776 
1777  if ( mipdata->ylhs[pos] != NULL )
1778  {
1779  consvars[nconsvars] = mipdata->ylhs[pos];
1780  consvals[nconsvars] = -sigma * colvals[i];
1781  ++nconsvars;
1782  }
1783  if ( mipdata->yrhs[pos] != NULL )
1784  {
1785  consvars[nconsvars] = mipdata->yrhs[pos];
1786  consvals[nconsvars] = sigma * colvals[i];
1787  ++nconsvars;
1788  }
1789  assert( nconsvars <= (int) mipdata->n );
1790  }
1791 
1792  /* check for lower and upper objective bounds */
1793  if ( (sepadata->useobjub || sepadata->useobjlb) && ! SCIPisZero(scip, SCIPcolGetObj(cols[j])) )
1794  {
1795  /* add lower objective bound */
1796  if ( mipdata->ylhs[mipdata->nrows] )
1797  {
1798  assert( sepadata->useobjlb );
1799  consvars[nconsvars] = mipdata->ylhs[mipdata->nrows];
1800  consvals[nconsvars] = -sigma * SCIPcolGetObj(cols[j]);
1801  ++nconsvars;
1802  }
1803 
1804  /* add upper objective bound */
1805  if ( mipdata->yrhs[mipdata->nrows] )
1806  {
1807  assert( sepadata->useobjub );
1808  consvars[nconsvars] = mipdata->yrhs[mipdata->nrows];
1809  consvals[nconsvars] = sigma * SCIPcolGetObj(cols[j]);
1810  ++nconsvars;
1811  }
1812  }
1813 
1814  /* add linear constraint */
1815  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "cont_%d", j);
1816 
1817  /* for free continuous variables require equality */
1818  r = SCIPinfinity(subscip);
1819  if ( SCIPisInfinity(scip, -lb[j]) && SCIPisInfinity(scip, ub[j]) )
1820  r = 0.0;
1821  else
1822  assert( SCIPisZero(scip, lb[j]) );
1823 
1824  SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, name, nconsvars, consvars, consvals, 0.0, r,
1825  TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1826  SCIP_CALL( SCIPaddCons(subscip, cons) );
1827  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
1828  ++cnt;
1829  }
1830  }
1831  assert( (int) cnt <= ncols );
1832  mipdata->m += cnt;
1833 
1834  /* create constraints for rhs of cut */
1835  nconsvars = 0;
1836 
1837  /* first for the rows */
1838  for (i = 0; i < nrows; ++i)
1839  {
1840  assert( rows[i] != NULL );
1841 
1842  /* skip modifiable rows and local rows, unless allowed */
1843  if ( SCIProwIsModifiable(rows[i]) || (SCIProwIsLocal(rows[i]) && !sepadata->allowlocal) )
1844  continue;
1845 
1846  /* if lhs is there */
1847  if ( mipdata->ylhs[i] != NULL && ! SCIPisZero(scip, lhs[i]) )
1848  {
1849  assert( ! SCIPisInfinity(scip, -lhs[i]) );
1850  consvars[nconsvars] = mipdata->ylhs[i];
1851  consvals[nconsvars] = -lhs[i];
1852  ++nconsvars;
1853  }
1854  /* if rhs is there */
1855  if ( mipdata->yrhs[i] != NULL && ! SCIPisZero(scip, rhs[i]) )
1856  {
1857  assert( ! SCIPisInfinity(scip, rhs[i]) );
1858  consvars[nconsvars] = mipdata->yrhs[i];
1859  consvals[nconsvars] = rhs[i];
1860  ++nconsvars;
1861  }
1862  assert( nconsvars <= (int) mipdata->n );
1863  }
1864 
1865  if ( sepadata->useobjub || sepadata->useobjlb )
1866  {
1867  /* add lower objective bound */
1868  if ( mipdata->ylhs[mipdata->nrows] != NULL && ! SCIPisZero(scip, lhs[mipdata->nrows]) )
1869  {
1870  assert( sepadata->useobjlb );
1871  assert( ! SCIPisInfinity(scip, -lhs[mipdata->nrows]) );
1872  consvars[nconsvars] = mipdata->ylhs[mipdata->nrows];
1873  consvals[nconsvars] = -lhs[mipdata->nrows];
1874  ++nconsvars;
1875  }
1876 
1877  /* add upper objective bound */
1878  if ( mipdata->yrhs[mipdata->nrows] != NULL && ! SCIPisZero(scip, rhs[mipdata->nrows]) )
1879  {
1880  assert( sepadata->useobjub );
1881  assert( ! SCIPisInfinity(scip, rhs[mipdata->nrows]) );
1882  consvars[nconsvars] = mipdata->yrhs[mipdata->nrows];
1883  consvals[nconsvars] = rhs[mipdata->nrows];
1884  ++nconsvars;
1885  }
1886  assert( nconsvars <= (int) mipdata->n );
1887  }
1888 
1889  /* next for the columns */
1890  for (j = 0; j < ncols; ++j)
1891  {
1892  /* if ub is there */
1893  if ( mipdata->z[j] != NULL && ! SCIPisZero(scip, ub[j]) )
1894  {
1895  assert( mipdata->coltype[j] == colPresent );
1896  assert( ! SCIPisInfinity(scip, ub[j]) );
1897  consvars[nconsvars] = mipdata->z[j];
1898  consvals[nconsvars] = ub[j];
1899  ++nconsvars;
1900  assert( nconsvars <= (int) mipdata->n );
1901  }
1902  }
1903  /* add beta variable */
1904  consvars[nconsvars] = mipdata->beta;
1905  consvals[nconsvars] = -1.0;
1906  ++nconsvars;
1907 
1908  /* add fractional-beta variable */
1909  consvars[nconsvars] = mipdata->fracbeta;
1910  consvals[nconsvars] = -1.0;
1911  ++nconsvars;
1912  assert( nconsvars <= (int) mipdata->n );
1913 
1914  /* add linear constraint */
1915  SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, "beta", nconsvars, consvars, consvals, 0.0, 0.0,
1916  TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1917  SCIP_CALL( SCIPaddCons(subscip, cons) );
1918  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
1919  ++mipdata->m;
1920 
1921  /* add primal separation constraint if required */
1922  if ( sepadata->primalseparation )
1923  {
1924  SCIP_SOL* bestsol;
1925  bestsol = SCIPgetBestSol(scip);
1926  if ( bestsol != NULL )
1927  {
1928  nconsvars = 0;
1929  for (j = 0; j < ncols; ++j)
1930  {
1931  if ( mipdata->alpha[j] != NULL )
1932  {
1933  SCIP_Real val;
1934  assert( mipdata->coltype[j] == colPresent );
1935 
1936  val = SCIPgetSolVal(scip, bestsol, SCIPcolGetVar(cols[j]));
1937  consvars[nconsvars] = mipdata->alpha[j];
1938  consvals[nconsvars] = val;
1939  ++nconsvars;
1940  assert( nconsvars <= (int) mipdata->n );
1941  }
1942  }
1943  consvars[nconsvars] = mipdata->beta;
1944  consvals[nconsvars] = -1.0;
1945  ++nconsvars;
1946 
1947  /* add linear constraint - allow slight deviation from equality */
1948  SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, "primalseparation", nconsvars, consvars, consvals, -EPSILONVALUE, EPSILONVALUE,
1949  TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1950  SCIP_CALL( SCIPaddCons(subscip, cons) );
1951  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
1952  ++mipdata->m;
1953  }
1954  }
1955 
1956  /* add constraint to force violated cuts if required */
1957  if ( sepadata->addviolationcons )
1958  {
1959  nconsvars = 0;
1960  for (j = 0; j < ncols; ++j)
1961  {
1962  if ( mipdata->alpha[j] != NULL )
1963  {
1964  consvars[nconsvars] = mipdata->alpha[j];
1965  consvals[nconsvars] = primsol[j];
1966  ++nconsvars;
1967  assert( nconsvars <= (int) mipdata->n );
1968  }
1969  }
1970  consvars[nconsvars] = mipdata->beta;
1971  consvals[nconsvars] = -1.0;
1972  ++nconsvars;
1973 
1974  /* add linear constraint - allow slight deviation from equality */
1975  SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, "violationConstraint", nconsvars, consvars, consvals, MINEFFICACY, SCIPinfinity(subscip),
1976  TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1977  SCIP_CALL( SCIPaddCons(subscip, cons) );
1978  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
1979  ++mipdata->m;
1980  }
1981 
1982  SCIPdebugMsg(scip, "Subscip has %u vars (%d integral, %d continuous), %u conss.\n",
1983  mipdata->n, SCIPgetNIntVars(subscip), SCIPgetNContVars(subscip), mipdata->m);
1984 
1985  /* free temporary memory */
1986  SCIPfreeBufferArray(scip, &consvars);
1987  SCIPfreeBufferArray(scip, &consvals);
1988 
1989  SCIPfreeBufferArray(scip, &primsol);
1990  SCIPfreeBufferArray(scip, &lb);
1991  SCIPfreeBufferArray(scip, &ub);
1992  SCIPfreeBufferArray(scip, &rhs);
1993  SCIPfreeBufferArray(scip, &lhs);
1994 
1995  /* SCIPdebug( SCIP_CALL( SCIPprintOrigProblem(subscip, NULL, NULL, FALSE) ) ); */
1996 
1997 #ifdef SCIP_WRITEPROB
1998  {
1999  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "cgsepa%s%s%s%s_%s.lp",
2000  sepadata->objlone ? "_l1" : "",
2001  sepadata->addviolationcons ? "_vc" : "",
2002  sepadata->skipmultbounds ? "_ub" : "",
2003  sepadata->primalseparation ? "_ps" : "",
2004  SCIPgetProbName(scip));
2005  SCIP_CALL( SCIPwriteOrigProblem(subscip, name, "lp", FALSE) );
2006  SCIPinfoMessage(scip, NULL, "Wrote subscip to file <%s>.\n", name);
2007  }
2008 #endif
2009 
2010  return SCIP_OKAY;
2011 }
2012 
2013 
2014 /** sets parameters for subscip */
2015 static
2017  SCIP_SEPADATA* sepadata, /**< separator data */
2018  CGMIP_MIPDATA* mipdata, /**< data for sub-MIP */
2019  SCIP_Bool* success /**< if setting was successful -> stop solution otherwise */
2020  )
2021 {
2022  SCIP* subscip;
2023 
2024  assert( sepadata != NULL );
2025  assert( mipdata != NULL );
2026  assert( success != NULL );
2027 
2028  *success = TRUE;
2029 
2030  subscip = mipdata->subscip;
2031  assert( subscip != NULL );
2032 
2033  /* set objective limit, if no corresponding constraint has been added */
2034  if ( ! sepadata->addviolationcons && ! sepadata->addviolconshdlr )
2035  {
2036  SCIP_CALL( SCIPsetObjlimit(subscip, MINEFFICACY) );
2037  }
2038 
2039  /* do not abort subscip on CTRL-C */
2040  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
2041 
2042  /* disable memory saving mode: this is likely to result in the maximal depth being reached. This is because DFS
2043  * results in a repeated branching on the alpha-variables, which often have large bounds resulting in deep levels of
2044  * the tree. */
2045  SCIP_CALL( SCIPsetRealParam(subscip, "memory/savefac", 1.0) );
2046 
2047  /* set number of solutions stored */
2048  SCIP_CALL( SCIPsetIntParam(subscip, "limits/maxsol", MAXNSOLS) );
2049 
2050  /* determine output to console */
2051 #ifdef SCIP_OUTPUT
2052  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
2053  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 1000) );
2054  SCIP_CALL( SCIPsetIntParam(subscip, "display/nsols/active", 2) );
2055 #else
2056  if ( sepadata->output )
2057  {
2058  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
2059  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 1000) );
2060  SCIP_CALL( SCIPsetIntParam(subscip, "display/nsols/active", 2) );
2061  }
2062  else
2063  {
2064  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
2065  }
2066 #endif
2067 
2068  if ( sepadata->subscipfast )
2069  {
2070  /* forbid recursive call of plugins solving subMIPs (also disables CG-separation) */
2071 #ifdef SCIP_OUTPUT
2072  SCIP_CALL( SCIPsetSubscipsOff(subscip, FALSE) );
2073 #else
2074  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) ); /* quiet */
2075 #endif
2076  }
2077  else
2078  {
2079  /* avoid recursive call */
2080  if ( ! SCIPisParamFixed(subscip, "separating/cgmip/freq") )
2081  {
2082  SCIP_CALL( SCIPsetIntParam(subscip, "separating/cgmip/freq", -1) );
2083  }
2084  }
2085 
2086 #ifdef SCIP_DISABLED_CODE
2087  /* the following possibly helps to improve performance (untested) */
2089 #else
2090 
2091  /* zirounding is often successful, so allow it some more calls */
2092  if( !SCIPisParamFixed(subscip, "heuristics/zirounding/minstopncalls") )
2093  {
2094  SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/zirounding/minstopncalls", 10000) );
2095  }
2096 
2097  if ( sepadata->subscipfast )
2098  {
2099  /* set other heuristics */
2100  if( !SCIPisParamFixed(subscip, "heuristics/shifting/freq") )
2101  {
2102  SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/shifting/freq", 3) );
2103  }
2104  if( !SCIPisParamFixed(subscip, "heuristics/simplerounding/freq") )
2105  {
2106  SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/simplerounding/freq", 1) );
2107  }
2108  if( !SCIPisParamFixed(subscip, "heuristics/rounding/freq") )
2109  {
2110  SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/rounding/freq", 1) );
2111  }
2112  if( !SCIPisParamFixed(subscip, "heuristics/oneopt/freq") )
2113  {
2114  SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/oneopt/freq", 1) );
2115  }
2116 
2117  /* SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/pscostdiving/freq", 1) ); */
2118  /* SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/feaspump/freq", 3) ); */
2119 
2120  /* SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/coefdiving/freq", -1) ); */
2121  /* SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/fracdiving/freq", -1) ); */
2122  /* SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/guideddiving/freq", -1) ); */
2123  /* SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/linesearchdiving/freq", -1) ); */
2124  /* SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/objpscostdiving/freq", -1) ); */
2125  /* SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/rootsoldiving/freq", -1) ); */
2126  /* SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/veclendiving/freq", -1) ); */
2127 
2128  /* use fast presolving */
2130 
2131  /* disable conflict analysis */
2132  /* SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/useprop", FALSE) ); */
2133  /* SCIP_CALL( SCIPsetCharParam(subscip, "conflict/useinflp", 'o') ); */
2134  /* SCIP_CALL( SCIPsetCharParam(subscip, "conflict/useboundlp", 'o') ); */
2135  /* SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/usesb", FALSE) ); */
2136  /* SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/usepseudo", FALSE) ); */
2137 
2138  /* use fast separation */
2140  }
2141 #endif
2142 
2143  return SCIP_OKAY;
2144 }
2145 
2146 
2147 /** solve subscip */
2148 static
2150  SCIP* scip, /**< SCIP data structure */
2151  SCIP_SEPADATA* sepadata, /**< separator data */
2152  CGMIP_MIPDATA* mipdata, /**< data for sub-MIP */
2153  SCIP_Bool* success /**< if setting was successful -> stop solution otherwise */
2154  )
2155 {
2156  SCIP* subscip;
2157  SCIP_RETCODE retcode;
2158  SCIP_STATUS status;
2159  SCIP_Real timelimit;
2160  SCIP_Real memorylimit;
2161  SCIP_Longint nodelimit;
2162 
2163  assert( scip != NULL );
2164  assert( sepadata != NULL );
2165  assert( mipdata != NULL );
2166  assert( success != NULL );
2167 
2168  *success = TRUE;
2169 
2170  subscip = mipdata->subscip;
2171 
2172  SCIP_CALL( SCIPcheckCopyLimits(scip, success) );
2173 
2174  if ( *success )
2175  {
2176  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
2177 
2178  SCIP_CALL( SCIPgetRealParam(subscip, "limits/time", &timelimit) );
2179  SCIP_CALL( SCIPgetRealParam(subscip, "limits/memory", &memorylimit) );
2180 
2181  /* reduce time and memory limit if a smaller limit is stored in the separator data */
2182  if ( sepadata->timelimit < timelimit )
2183  {
2184  SCIP_CALL( SCIPsetRealParam(subscip, "limits/time", sepadata->timelimit) );
2185  }
2186  if ( sepadata->memorylimit < memorylimit )
2187  {
2188  SCIP_CALL( SCIPsetRealParam(subscip, "limits/memorylimit", sepadata->memorylimit) );
2189  }
2190  }
2191  else
2192  return SCIP_OKAY;
2193 
2194  /* set nodelimit for subproblem */
2195  if ( sepadata->minnodelimit < 0 || sepadata->maxnodelimit < 0 )
2196  nodelimit = SCIP_LONGINT_MAX;
2197  else
2198  {
2199  assert( sepadata->minnodelimit >= 0 && sepadata->maxnodelimit >= 0 );
2200  nodelimit = SCIPgetNLPIterations(scip);
2201  nodelimit = MAX(sepadata->minnodelimit, nodelimit);
2202  nodelimit = MIN(sepadata->maxnodelimit, nodelimit);
2203  }
2204  assert( nodelimit >= 0 );
2205  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nodelimit) );
2206 
2207  SCIPdebugMsg(scip, "Solving sub-SCIP (time limit: %f mem limit: %f node limit: %" SCIP_LONGINT_FORMAT ") ...\n", timelimit, memorylimit, nodelimit);
2208 
2209  /* disable statistic timing inside sub SCIP */
2210  if( !sepadata->output )
2211  {
2212  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
2213  }
2214 
2215  /* check whether we want a complete solve */
2216  if ( ! sepadata->earlyterm )
2217  {
2218  retcode = SCIPsolve(subscip);
2219 
2220  /* errors in solving the subproblem should not kill the overall solving process;
2221  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop. */
2222  if ( retcode != SCIP_OKAY )
2223  {
2224 #ifndef NDEBUG
2225  SCIP_CALL( retcode );
2226 #endif
2227  SCIPwarningMessage(scip, "Error while solving subproblem in CGMIP separator; sub-SCIP terminated with code <%d>\n", retcode);
2228  *success = FALSE;
2229  return SCIP_OKAY;
2230  }
2231 
2232  status = SCIPgetStatus(subscip);
2233 
2234 #ifdef SCIP_OUTPUT
2235  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
2236 #else
2237  if ( sepadata->output )
2238  {
2239  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
2240  }
2241 #endif
2242 
2243  /* if the solution process was terminated or the problem is infeasible (can happen because of violation constraint) */
2244  if ( status == SCIP_STATUS_TIMELIMIT || status == SCIP_STATUS_USERINTERRUPT || status == SCIP_STATUS_INFEASIBLE || status == SCIP_STATUS_INFORUNBD )
2245  {
2246  *success = FALSE;
2247  return SCIP_OKAY;
2248  }
2249 
2250  /* all other statuses except optimal are invalid */
2251  if ( status != SCIP_STATUS_OPTIMAL && status != SCIP_STATUS_NODELIMIT )
2252  {
2253  SCIPerrorMessage("Solution of subscip for CG-separation returned with invalid status %d.\n", status);
2254  return SCIP_ERROR;
2255  }
2256  }
2257  else
2258  {
2259  /* otherwise we want a heuristic solve */
2260 
2261  /* -> solve until first solution is found */
2262  SCIP_CALL( SCIPsetIntParam(subscip, "limits/bestsol", 1) );
2263  retcode = SCIPsolve(subscip);
2264  SCIP_CALL( SCIPsetIntParam(subscip, "limits/bestsol", -1) );
2265 
2266  /* errors in solving the subproblem should not kill the overall solving process;
2267  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop. */
2268  if ( retcode != SCIP_OKAY )
2269  {
2270 #ifndef NDEBUG
2271  SCIP_CALL( retcode );
2272 #endif
2273  SCIPwarningMessage(scip, "Error while solving subproblem in CGMIP separator; sub-SCIP terminated with code <%d>\n", retcode);
2274  *success = FALSE;
2275  return SCIP_OKAY;
2276  }
2277 
2278  status = SCIPgetStatus(subscip);
2279 
2280  /* if the solution process was terminated or the problem is infeasible (can happen because of violation constraint) */
2281  if ( status == SCIP_STATUS_TIMELIMIT || status == SCIP_STATUS_USERINTERRUPT || status == SCIP_STATUS_NODELIMIT ||
2282  status == SCIP_STATUS_INFEASIBLE || status == SCIP_STATUS_INFORUNBD || status == SCIP_STATUS_MEMLIMIT )
2283  {
2284  /* output statistics before stopping */
2285 #ifdef SCIP_OUTPUT
2286  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
2287 #else
2288  if ( sepadata->output )
2289  {
2290  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
2291  }
2292 #endif
2293  *success = FALSE;
2294  return SCIP_OKAY;
2295  }
2296 
2297  /* all other statuses except optimal or bestsollimit are invalid - (problem cannot be infeasible) */
2298  if ( status != SCIP_STATUS_OPTIMAL && status != SCIP_STATUS_BESTSOLLIMIT )
2299  {
2300  SCIPerrorMessage("Solution of subscip for CG-separation returned with invalid status %d.\n", status);
2301  return SCIP_ERROR;
2302  }
2303 
2304  /* solve some more, if a feasible solution was found */
2305  if ( status == SCIP_STATUS_BESTSOLLIMIT )
2306  {
2307  SCIPdebugMsg(scip, "Continue solving separation problem ...\n");
2308 
2309  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", STALLNODELIMIT) );
2310  retcode = SCIPsolve(subscip);
2311  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", -1LL) );
2312 
2313  /* errors in solving the subproblem should not kill the overall solving process;
2314  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop. */
2315  if ( retcode != SCIP_OKAY )
2316  {
2317 #ifndef NDEBUG
2318  SCIP_CALL( retcode );
2319 #endif
2320  SCIPwarningMessage(scip, "Error while solving subproblem in CGMIP separator; sub-SCIP terminated with code <%d>\n", retcode);
2321  *success = FALSE;
2322  return SCIP_OKAY;
2323  }
2324 
2325  status = SCIPgetStatus(subscip);
2326  assert( status != SCIP_STATUS_BESTSOLLIMIT );
2327 
2328 #ifdef SCIP_OUTPUT
2329  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
2330 #else
2331  if ( sepadata->output )
2332  {
2333  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
2334  }
2335 #endif
2336 
2337  /* if the solution process was terminated */
2338  if ( status == SCIP_STATUS_TIMELIMIT || status == SCIP_STATUS_USERINTERRUPT || status == SCIP_STATUS_MEMLIMIT )
2339  {
2340  *success = FALSE;
2341  return SCIP_OKAY;
2342  }
2343 
2344  /* all other statuses except optimal or bestsollimit are invalid */
2345  if ( status != SCIP_STATUS_OPTIMAL && status != SCIP_STATUS_STALLNODELIMIT && status != SCIP_STATUS_NODELIMIT )
2346  {
2347  SCIPerrorMessage("Solution of subscip for CG-separation returned with invalid status %d.\n", status);
2348  return SCIP_ERROR;
2349  }
2350  }
2351  }
2352 
2353  return SCIP_OKAY;
2354 }
2355 
2356 /** Computes cut from the given multipliers
2357  *
2358  * Note that the cut computed here in general will not be the same as the one computed with the
2359  * sub-MIP, because of numerical differences. Here, we only combine rows whose corresponding
2360  * multiplier is positive w.r.t. the feasibility tolerance. In the sub-MIP, however, the rows are
2361  * combined in any case. This makes a difference, if the coefficients in the matrix are large and
2362  * hence yield a value that is larger than the tolerance.
2363  *
2364  * Because of the transformations we have the following:
2365  *
2366  * If variable \f$x_j\f$ was complemented, we have \f$x'_j = u_j - x_j\f$. If in the transformed
2367  * system the lower bound is used, its corresponding multiplier is \f$y^T A'_j - \lfloor y^T A'_j
2368  * \rfloor\f$, which corresponds to
2369  * \f[
2370  * y^T A'_j - \lfloor y^T A'_j \rfloor = - y^T A_j - \lfloor - y^T A_j \rfloor = - y^T A_j + \lceil y^T A_j \rceil
2371  * \f]
2372  * in the original system.
2373  *
2374  * If such a variable was at its upper bound before the transformation, it is at its lower bound
2375  * afterwards. Hence, its contribution to the cut is 0.
2376  *
2377  * Note that if the original LP-solution does not satisfy some of the rows with equality the
2378  * violation of the cut might be smaller than what is computed with the reduced sub-MIP.
2379  *
2380  * Furthermore, note that if continuous variables have been shifted, the computed violated may be
2381  * different as well, because the necessary changes in the lhs/rhs are not used here anymore.
2382  *
2383  * @todo check if cut is correct if continuous variables have been shifted.
2384  */
2385 static
2387  SCIP* scip, /**< original scip */
2388  SCIP_SEPA* sepa, /**< separator */
2389  CGMIP_MIPDATA* mipdata, /**< data for sub-MIP */
2390  SCIP_SEPADATA* sepadata, /**< separator data */
2391  SCIP_SOL* sol, /**< current solution for sub-MIP */
2392  SCIP_Real* cutcoefs, /**< coefficients of the cut */
2393  SCIP_Real* cutrhs, /**< rhs of the cut */
2394  SCIP_Bool* localrowsused, /**< pointer to store whether local rows were used in summation */
2395  SCIP_Bool* localboundsused, /**< pointer to store whether local bounds were used in summation */
2396  int* cutrank, /**< pointer to store the cut rank */
2397  SCIP_Bool* success /**< whether we produced a valid cut */
2398  )
2399 {
2400  SCIP* subscip;
2401  SCIP_VAR** vars;
2402  SCIP_ROW** rows;
2403  SCIP_COL** cols;
2404  SCIP_Real val;
2405  SCIP_Real maxabsweight;
2406  int nvars;
2407  int ncols;
2408  int nrows;
2409  int i;
2410  int j;
2411 
2412  assert( scip != NULL );
2413  assert( mipdata != NULL );
2414  assert( sepadata != NULL );
2415  assert( cutcoefs != NULL );
2416  assert( cutrhs != NULL );
2417  assert( localrowsused != NULL );
2418  assert( cutrank != NULL );
2419  assert( success != NULL );
2420 
2421  subscip = mipdata->subscip;
2422  assert( subscip != NULL );
2423 
2424  /* get data */
2425  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
2426  SCIP_CALL( SCIPgetLPRowsData(scip, &rows, &nrows) );
2427  SCIP_CALL( SCIPgetLPColsData(scip, &cols, &ncols) );
2428  assert( nrows == (int) mipdata->nrows );
2429  assert( ncols == (int) mipdata->ncols );
2430 
2431  /* initialize */
2432  *success = TRUE;
2433  *localrowsused = FALSE;
2434  *cutrank = 0;
2435  *localboundsused = FALSE;
2436  BMSclearMemoryArray(cutcoefs, nvars);
2437  *cutrhs = 0.0;
2438 
2439  /* find maximal absolute weight */
2440  maxabsweight = 0.0;
2441  for (i = 0; i < nrows; ++i)
2442  {
2443  SCIP_ROW* row;
2444  SCIP_Real absweight = 0.0;
2445 
2446  row = rows[i];
2447  assert( row != NULL );
2448 
2449  /* skip modifiable rows and local rows, unless allowed */
2450  if ( SCIProwIsModifiable(row) || (SCIProwIsLocal(row) && !sepadata->allowlocal) )
2451  {
2452  assert( mipdata->ylhs[i] == NULL && mipdata->yrhs[i] == NULL );
2453  continue;
2454  }
2455 
2456  /* get weight from solution (take larger of the values of lhs/rhs) */
2457  if ( mipdata->ylhs[i] != NULL )
2458  {
2459  val = SCIPgetSolVal(subscip, sol, mipdata->ylhs[i]);
2460 
2461  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
2462  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
2463 
2464  if ( SCIPisFeasPositive(scip, val) )
2465  absweight = val;
2466 
2467  assert( ! sepadata->onlyrankone || SCIProwGetOriginSepa(row) != sepa );
2468  }
2469  if ( mipdata->yrhs[i] != NULL )
2470  {
2471  val = SCIPgetSolVal(subscip, sol, mipdata->yrhs[i]);
2472 
2473  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
2474  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
2475 
2476  /* in a suboptimal solution both values may be positive - take the one with larger absolute value */
2477  if ( SCIPisFeasGT(scip, val, absweight) )
2478  absweight = val;
2479 
2480  assert( ! sepadata->onlyrankone || SCIProwGetOriginSepa(row) != sepa );
2481  }
2482  assert( ! SCIPisNegative(scip, absweight) );
2483 
2484  if ( absweight > maxabsweight )
2485  maxabsweight = absweight;
2486  }
2487 
2488  /* get weight from objective cuts */
2489  if ( sepadata->useobjub || sepadata->useobjlb )
2490  {
2491  SCIP_Real absweight = 0.0;
2492 
2493  assert( mipdata->ntotalrows == mipdata->nrows + 1 );
2494 
2495  if ( mipdata->ylhs[mipdata->nrows] != NULL )
2496  {
2497  val = SCIPgetSolVal(subscip, sol, mipdata->ylhs[mipdata->nrows]);
2498  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
2499 
2500  if ( SCIPisFeasPositive(scip, val) )
2501  absweight = val;
2502  }
2503  if ( mipdata->yrhs[mipdata->nrows] != NULL )
2504  {
2505  val = SCIPgetSolVal(subscip, sol, mipdata->yrhs[mipdata->nrows]);
2506  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
2507 
2508  /* in a suboptimal solution both values may be positive - take the one with larger absolute value */
2509  if ( SCIPisFeasGT(scip, val, absweight) )
2510  absweight = val;
2511  }
2512 
2513  if ( absweight > maxabsweight )
2514  maxabsweight = absweight;
2515  }
2516 
2517  /* calculate the row summation */
2518  for (i = 0; i < nrows; ++i)
2519  {
2520  SCIP_ROW* row;
2521  SCIP_Real weight;
2522  SCIP_Real absweight;
2523  SCIP_Bool uselhs;
2524 
2525  row = rows[i];
2526  assert( row != NULL );
2527 
2528  /* skip modifiable rows and local rows, unless allowed */
2529  if ( SCIProwIsModifiable(row) || (SCIProwIsLocal(row) && !sepadata->allowlocal) )
2530  {
2531  assert( mipdata->ylhs[i] == NULL && mipdata->yrhs[i] == NULL );
2532  continue;
2533  }
2534 
2535  /* get weight from solution */
2536  weight = 0.0;
2537  uselhs = FALSE;
2538  if ( mipdata->ylhs[i] != NULL )
2539  {
2540  val = SCIPgetSolVal(subscip, sol, mipdata->ylhs[i]);
2541  assert( ! SCIPisFeasNegative(subscip, val) );
2542 
2543  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
2544  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
2545 
2546  if ( SCIPisFeasPositive(scip, val) )
2547  {
2548  uselhs = TRUE;
2549  weight = -val;
2550  }
2551  }
2552  if ( mipdata->yrhs[i] != NULL )
2553  {
2554  val = SCIPgetSolVal(subscip, sol, mipdata->yrhs[i]);
2555  assert( ! SCIPisFeasNegative(subscip, val) );
2556 
2557  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
2558  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
2559 
2560  /* in a suboptimal solution both values may be positive - take the one with larger absolute value */
2561  if ( SCIPisFeasGT(scip, val, REALABS(weight)) )
2562  weight = val;
2563  }
2564 
2565  /* add row if weight is nonzero and lies within range */
2566  absweight = REALABS(weight);
2567  if ( ! SCIPisSumZero(scip, weight) && absweight * MAXWEIGHTRANGE >= maxabsweight )
2568  {
2569  SCIP_COL** rowcols;
2570  SCIP_Real* rowvals;
2571 
2572  rowcols = SCIProwGetCols(row);
2573  rowvals = SCIProwGetVals(row);
2574 
2575  /* add the row coefficients to the sum */
2576  for (j = 0; j < SCIProwGetNLPNonz(row); ++j)
2577  {
2578  int idx;
2579  SCIP_VAR* var;
2580 
2581  assert( rowcols[j] != NULL );
2582  var = SCIPcolGetVar(rowcols[j]);
2583 
2584  assert( var != NULL );
2585  assert( SCIPvarGetStatus(var) == SCIP_VARSTATUS_COLUMN );
2586  assert( SCIPvarGetCol(var) == rowcols[j] );
2587 
2588  idx = SCIPvarGetProbindex(var);
2589  assert( 0 <= idx && idx < nvars );
2590 
2591  cutcoefs[idx] += weight * rowvals[j];
2592  }
2593 
2594  /* compute rhs */
2595  if ( uselhs )
2596  {
2597  assert( ! SCIPisInfinity(scip, -SCIProwGetLhs(row)) );
2598  val = SCIProwGetLhs(row) - SCIProwGetConstant(row);
2599  if ( SCIProwIsIntegral(row) )
2600  val = SCIPfeasCeil(scip, val); /* row is integral: round left hand side up */
2601  }
2602  else
2603  {
2604  assert( ! SCIPisInfinity(scip, SCIProwGetRhs(row)) );
2605  val = SCIProwGetRhs(row) - SCIProwGetConstant(row);
2606  if ( SCIProwIsIntegral(row) )
2607  val = SCIPfeasFloor(scip, val); /* row is integral: round right hand side down */
2608  }
2609  (*cutrhs) += weight * val;
2610 
2611  *localrowsused = *localrowsused || SCIProwIsLocal(row);
2612 
2613  if ( SCIProwGetRank(row) > *cutrank )
2614  *cutrank = SCIProwGetRank(row);
2615  }
2616  }
2617  /* add 1 to cutrank */
2618  ++(*cutrank);
2619 
2620  /* get weight from objective bounds */
2621  if ( sepadata->useobjub || sepadata->useobjlb )
2622  {
2623  SCIP_Real weight = 0.0;
2624  SCIP_Bool uselhs = FALSE;
2625  SCIP_Real absweight;
2626 
2627  assert( mipdata->ntotalrows == mipdata->nrows + 1 );
2628 
2629  if ( mipdata->ylhs[mipdata->nrows] != NULL )
2630  {
2631  val = SCIPgetSolVal(subscip, sol, mipdata->ylhs[mipdata->nrows]);
2632  assert( ! SCIPisFeasNegative(subscip, val) );
2633  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
2634  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
2635 
2636  if ( SCIPisFeasPositive(scip, val) )
2637  {
2638  uselhs = TRUE;
2639  weight = -val;
2640  }
2641  }
2642  if ( mipdata->yrhs[mipdata->nrows] != NULL )
2643  {
2644  val = SCIPgetSolVal(subscip, sol, mipdata->yrhs[mipdata->nrows]);
2645  assert( ! SCIPisFeasNegative(subscip, val) );
2646  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
2647  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
2648 
2649  /* in a suboptimal solution both values may be positive - take the one with larger absolute value */
2650  if ( SCIPisFeasGT(scip, val, REALABS(weight)) )
2651  weight = val;
2652  }
2653 
2654  /* add objective row if weight is nonzero and lies within range */
2655  absweight = REALABS(weight);
2656  if ( ! SCIPisSumZero(scip, weight) && absweight * MAXWEIGHTRANGE >= maxabsweight )
2657  {
2658  SCIP_Real obj = 0.0;
2659 
2660  /* add the objective row coefficients to the sum */
2661  for (j = 0; j < ncols; ++j)
2662  {
2663  obj = SCIPcolGetObj(cols[j]);
2664  if ( ! SCIPisZero(scip, obj) )
2665  cutcoefs[j] += weight * obj;
2666  }
2667 
2668  /* compute rhs */
2669  if ( uselhs )
2670  {
2671  val = SCIPgetLowerbound(scip);
2672  assert( ! SCIPisInfinity(scip, -val) );
2673  if ( SCIPisObjIntegral(scip) )
2674  val = SCIPfeasCeil(scip, val); /* objective is integral: round left hand side up */
2675  }
2676  else
2677  {
2678  val = SCIPgetUpperbound(scip);
2679  assert( ! SCIPisInfinity(scip, val) );
2680  if ( SCIPisObjIntegral(scip) )
2681  val = SCIPfeasFloor(scip, val); /* objective is integral: round right hand side down */
2682  }
2683  (*cutrhs) += weight * val;
2684  }
2685  }
2686 
2687  /* add upper bounds */
2688  for (j = 0; j < ncols; ++j)
2689  {
2690  assert( cols[j] != NULL );
2691  if ( mipdata->z[j] != NULL )
2692  {
2693  assert( mipdata->coltype[j] == colPresent );
2694 
2695  val = SCIPgetSolVal(subscip, sol, mipdata->z[j]);
2696  assert( ! SCIPisFeasNegative(subscip, val) );
2697 
2698  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
2699  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
2700 
2701  /* if a bound has been used */
2702  if ( SCIPisSumPositive(subscip, val) )
2703  {
2704  SCIP_VAR* var;
2705  int idx;
2706 
2707  var = SCIPcolGetVar(cols[j]);
2708 
2709  assert( var != NULL );
2710  assert( SCIPvarGetStatus(var) == SCIP_VARSTATUS_COLUMN );
2711  assert( SCIPvarIsIntegral(var) );
2712  assert( SCIPvarGetCol(var) == cols[j] );
2713 
2714  idx = SCIPvarGetProbindex(var);
2715  assert( 0 <= idx && idx < nvars );
2716 
2717  /* check whether variable is complemented */
2718  if ( mipdata->iscomplemented[j] )
2719  {
2720  SCIP_Real lbnd;
2721  lbnd = SCIPvarGetLbGlobal(var);
2722  assert( ! SCIPisInfinity(scip, -lbnd) );
2723  assert( SCIPisIntegral(scip, lbnd) );
2724  assert( SCIPisEQ(scip, SCIPvarGetLbLocal(var), SCIPcolGetLb(cols[j])) );
2725 
2726  /* variable should not be free */
2727  assert( ! SCIPisInfinity(scip, -lbnd) || ! SCIPisInfinity(scip, SCIPvarGetUbGlobal(var)) );
2728 
2729  /* if allowed, try to use stronger local bound */
2730  if ( sepadata->allowlocal && SCIPvarGetLbLocal(var) - 0.5 > lbnd )
2731  {
2732  lbnd = SCIPvarGetLbLocal(var);
2733  assert( SCIPisIntegral(scip, lbnd) );
2734  *localboundsused = TRUE;
2735  }
2736 
2737  cutcoefs[idx] -= val;
2738  *cutrhs -= lbnd * val;
2739  }
2740  else
2741  {
2742  SCIP_Real ubnd;
2743  ubnd = SCIPvarGetUbGlobal(var);
2744  assert( ! SCIPisInfinity(scip, ubnd) );
2745  assert( SCIPisIntegral(scip, ubnd) );
2746  assert( SCIPisEQ(scip, SCIPvarGetUbLocal(var), SCIPcolGetUb(cols[j])) );
2747 
2748  /* if allowed, try to use stronger local bound */
2749  if ( sepadata->allowlocal && SCIPvarGetUbLocal(var) + 0.5 < ubnd )
2750  {
2751  ubnd = SCIPvarGetUbLocal(var);
2752  assert( SCIPisIntegral(scip, ubnd) );
2753  *localboundsused = TRUE;
2754  }
2755 
2756  cutcoefs[idx] += val;
2757  *cutrhs += ubnd * val;
2758  }
2759  }
2760  }
2761  }
2762 
2763  /* check lower bounds for integral variables */
2764  for (j = 0; j < nvars; ++j)
2765  {
2766  SCIP_VAR* var;
2767  int pos;
2768 
2769  var = vars[j];
2770  assert( var != NULL );
2771  pos = SCIPcolGetLPPos(SCIPvarGetCol(var));
2772 
2773  /* a variable may have status COLUMN, but the corresponding column may not (yet) be in the LP */
2774  if ( pos >= 0 && mipdata->coltype[pos] != colContinuous && mipdata->coltype[pos] != colConverted )
2775  {
2776  assert( pos < ncols );
2777  assert( SCIPvarGetStatus(var) == SCIP_VARSTATUS_COLUMN );
2778  assert( SCIPvarIsIntegral(var) );
2779 
2780  /* check whether variable is complemented */
2781  if ( mipdata->iscomplemented[pos] )
2782  {
2783  assert( ! mipdata->isshifted[pos] );
2784  /* if the variable is complemented, the multiplier for the upper bound arises from the
2785  lower bound multiplier for the transformed problem - because of the minus-sign in the
2786  transformation this yields a round-up operation. */
2787  val = SCIPfeasCeil(scip, cutcoefs[j]) - cutcoefs[j];
2788  assert( ! SCIPisFeasNegative(scip, val) );
2789 
2790  /* only if variable needs to be rounded */
2791  if ( SCIPisSumPositive(scip, val) )
2792  {
2793  SCIP_Real ubnd;
2794  ubnd = SCIPvarGetUbGlobal(var);
2795  assert( ! SCIPisInfinity(scip, ubnd) );
2796  assert( SCIPisIntegral(scip, ubnd) );
2797 
2798  /* variable should not be free */
2799  assert( ! SCIPisInfinity(scip, -SCIPvarGetLbGlobal(var)) || ! SCIPisInfinity(scip, ubnd) );
2800 
2801  /* if allowed, try to use stronger local bound */
2802  if ( sepadata->allowlocal && SCIPvarGetUbLocal(var) + 0.5 < ubnd )
2803  {
2804  ubnd = SCIPvarGetUbLocal(var);
2805  assert( SCIPisIntegral(scip, ubnd) );
2806  *localboundsused = TRUE;
2807  }
2808 
2809  /* round cut coefficients, i.e., add val to cutcoefs[j] */
2810  cutcoefs[j] = SCIPfeasCeil(scip, cutcoefs[j]);
2811 
2812  /* correct rhs */
2813  if ( ! SCIPisSumZero(scip, ubnd) )
2814  *cutrhs += ubnd * val;
2815  }
2816  }
2817  else
2818  {
2819  /* compute multiplier for lower bound: */
2820  val = cutcoefs[j] - SCIPfeasFloor(scip, cutcoefs[j]);
2821  assert( ! SCIPisFeasNegative(scip, val) );
2822 
2823  /* only if variable needs to be rounded */
2824  if ( SCIPisSumPositive(scip, val) )
2825  {
2826  SCIP_Real lbnd;
2827  lbnd = SCIPvarGetLbGlobal(var);
2828  assert( ! SCIPisInfinity(scip, -lbnd) );
2829  assert( SCIPisIntegral(scip, lbnd) );
2830 
2831  /* variable should not be free */
2832  assert( ! SCIPisInfinity(scip, -lbnd) || ! SCIPisInfinity(scip, SCIPvarGetUbGlobal(var)) );
2833 
2834  /* if allowed, try to use stronger local bound */
2835  if ( sepadata->allowlocal && SCIPvarGetLbLocal(var) - 0.5 > lbnd )
2836  {
2837  lbnd = SCIPvarGetLbLocal(var);
2838  assert( SCIPisIntegral(scip, lbnd) );
2839  *localboundsused = TRUE;
2840  }
2841 
2842  /* round cut coefficients, i.e., subtract val from cutcoefs[j] */
2843  cutcoefs[j] = SCIPfeasFloor(scip, cutcoefs[j]);
2844 
2845  /* correct rhs */
2846  if ( ! SCIPisSumZero(scip, lbnd) )
2847  *cutrhs -= lbnd * val;
2848  }
2849  }
2850  }
2851  else
2852  {
2853  /* force coefficients of all continuous variables or of variables not in the lp to zero */
2854  assert( pos == -1 || mipdata->coltype[pos] == colContinuous || mipdata->coltype[pos] == colConverted );
2855 
2856  /* check whether all coefficients for continuous or converted variables are nonnegative */
2857  if ( pos >= 0 )
2858  {
2859  if ( SCIPisNegative(scip, cutcoefs[j]) )
2860  {
2861  *success = FALSE;
2862  break;
2863  }
2864  }
2865 
2866  cutcoefs[j] = 0.0;
2867  }
2868  }
2869 
2870  /* round rhs */
2871  *cutrhs = SCIPfeasFloor(scip, *cutrhs);
2872 
2873  return SCIP_OKAY;
2874 }
2875 
2876 /** Create CG-cut directly from solution of sub-MIP */
2877 static
2879  SCIP* scip, /**< SCIP data structure */
2880  SCIP_SEPA* sepa, /**< separator */
2881  SCIP_SEPADATA* sepadata, /**< separator data */
2882  CGMIP_MIPDATA* mipdata, /**< data for sub-MIP */
2883  SCIP_SOL* sol, /**< solution of sub-MIP */
2884  SCIP_Real* cutcoefs, /**< cut coefficients */
2885  int* cutinds, /**< problem indices of variables appearing in cut */
2886  SCIP_Real* cutvals, /**< values of variables in cut */
2887  SCIP_Real* varsolvals, /**< solution value of variables */
2888  SCIP_Real* weights, /**< weights to compute cmir cut */
2889  int* nprevrows, /**< number of previously generated rows */
2890  SCIP_ROW** prevrows, /**< previously generated rows */
2891  SCIP_Bool* cutoff, /**< whether a cutoff has been detected */
2892  unsigned int* ngen /**< number of generated cuts */
2893  )
2894 {
2895  char name[SCIP_MAXSTRLEN];
2896  SCIP_Bool cutislocal;
2897  SCIP_Bool localrowsused;
2898  SCIP_Bool localboundsused;
2899  SCIP_Real cutrhs;
2900  SCIP_Real cutact;
2901  SCIP_Bool success;
2902  SCIP_VAR** vars;
2903  int cutrank = 0;
2904  int nvars;
2905  int k;
2906 
2907  assert( scip != NULL );
2908  assert( sepadata != NULL );
2909  assert( mipdata != NULL );
2910  assert( sol != NULL );
2911  assert( cutcoefs != NULL );
2912  assert( cutinds != NULL );
2913  assert( cutvals != NULL );
2914  assert( varsolvals != NULL );
2915  assert( weights != NULL );
2916  assert( nprevrows != NULL );
2917  assert( prevrows != NULL );
2918  assert( cutoff != NULL );
2919  assert( ngen != NULL );
2920 
2921  /* get variable data */
2922  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
2923 
2924  cutrhs = 0.0;
2925  localrowsused = FALSE;
2926  localboundsused = FALSE;
2927  *cutoff = FALSE;
2928  success = TRUE;
2929 
2930  /* compute coefficients */
2931  SCIP_CALL( computeCut(scip, sepa, mipdata, sepadata, sol, cutcoefs, &cutrhs, &localrowsused, &localboundsused, &cutrank, &success) );
2932  cutislocal = localrowsused || localboundsused;
2933 
2934  /* take next solution if cut was not valid */
2935  if ( ! success )
2936  {
2937  SCIPdebugMsg(scip, "cut not valid - skipping ...\n");
2938  return SCIP_OKAY;
2939  }
2940 
2941  /* compute activity */
2942  cutact = 0.0;
2943  for (k = 0; k < nvars; ++k)
2944  cutact += cutcoefs[k] * varsolvals[k];
2945 
2946 #ifdef SCIP_DISABLED_CODE
2947  /* the following test should be treated with care because of numerical differences - see computeCut() */
2948  {
2949  /* check for correctness of computed values */
2950  SCIP* subscip;
2951  SCIP_Real obj = 0.0;
2952  SCIP_Real val;
2953  SCIP_Bool contVarShifted = FALSE;
2954  unsigned int j;
2955  SCIP_COL** cols;
2956  int ncols;
2957 
2958  subscip = mipdata->subscip;
2959  assert( subscip != NULL );
2960 
2961  SCIP_CALL( SCIPprintSol(subscip, sol, NULL, FALSE) );
2962 
2963  SCIP_CALL( SCIPgetLPColsData(scip, &cols, &ncols) );
2964  for (j = 0; j < mipdata->ncols; ++j)
2965  {
2966  if ( mipdata->coltype[j] == colPresent )
2967  {
2968  int idx;
2969  assert( mipdata->alpha[j] != NULL );
2970  val = SCIPgetSolVal(subscip, sol, mipdata->alpha[j]);
2971  assert( SCIPisFeasIntegral(subscip, val) );
2972  idx = SCIPvarGetProbindex(SCIPcolGetVar(cols[j]));
2973  assert( SCIPisFeasEQ(scip, val, cutcoefs[idx]) );
2974  obj += val * SCIPvarGetObj(mipdata->alpha[j]);
2975  }
2976  else
2977  {
2978  if ( (mipdata->coltype[j] == colContinuous || mipdata->coltype[j] == colConverted) && mipdata->isshifted[j] )
2979  contVarShifted = TRUE;
2980  }
2981  }
2982  assert( mipdata->beta != NULL );
2983  val = SCIPgetSolVal(subscip, sol, mipdata->beta);
2984  assert( SCIPisFeasIntegral(subscip, val) );
2985  obj += val * SCIPvarGetObj(mipdata->beta);
2986  assert( contVarShifted || SCIPisFeasEQ(scip, obj, cutact - cutrhs) );
2987  }
2988 #endif
2989 
2990  /* if successful, convert dense cut into sparse row, and add the row as a cut */
2991  if ( SCIPisFeasGT(scip, cutact, cutrhs) )
2992  {
2993  SCIP_Real cutnorm;
2994  int cutlen;
2995 
2996  /* store the cut as sparse row, calculate activity and norm of cut */
2997  SCIP_CALL( storeCutInArrays(scip, nvars, cutcoefs, varsolvals, mipdata->normtype,
2998  cutinds, cutvals, &cutlen, &cutact, &cutnorm) );
2999 
3000  SCIPdebugMsg(scip, "act=%f, rhs=%f, norm=%f, eff=%f\n", cutact, cutrhs, cutnorm, (cutact - cutrhs)/cutnorm);
3001 
3002  /* if norm is 0, the cut is trivial */
3003  if ( SCIPisPositive(scip, cutnorm) )
3004  {
3005  SCIP_Bool violated = SCIPisEfficacious(scip, (cutact - cutrhs)/cutnorm);
3006 
3007  if ( violated || (sepadata->usecutpool && ! cutislocal ) )
3008  {
3009  SCIP_ROW* cut;
3010 
3011  /* create the cut */
3012  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "cgcut%d_%u", SCIPgetNLPs(scip), *ngen);
3013  SCIP_CALL( SCIPcreateEmptyRowSepa(scip, &cut, sepa, name, -SCIPinfinity(scip), cutrhs, cutislocal, FALSE, sepadata->dynamiccuts) );
3014  SCIP_CALL( SCIPcacheRowExtensions(scip, cut) );
3015 
3016  for( k = 0; k < cutlen; ++k )
3017  {
3018  SCIP_CALL( SCIPaddVarToRow(scip, cut, vars[cutinds[k]], cutvals[k]) );
3019  }
3020 
3021  /* set cut rank */
3022  SCIProwChgRank(cut, cutrank);
3023 
3024  SCIP_CALL( SCIPflushRowExtensions(scip, cut) );
3025 
3026  /*SCIPdebug( SCIP_CALL( SCIPprintRow(scip, cut, NULL) ) );*/
3027 
3028  /* add cut to pool */
3029  if ( ! cutislocal )
3030  {
3031  assert( violated || sepadata->usecutpool );
3032  SCIP_CALL( SCIPaddPoolCut(scip, cut) );
3033  }
3034 
3035  /* add cut if it is violated */
3036  if ( violated )
3037  {
3038  /* check whether cut has been found before - may happend due to projection */
3039  for (k = 0; k < *nprevrows; ++k)
3040  {
3041  SCIP_Real parval;
3042 
3043  assert( prevrows[k] != NULL );
3044  parval = SCIProwGetParallelism(cut, prevrows[k], 'e');
3045  /* exit if row is parallel to existing cut and rhs is not better */
3046  if ( SCIPisEQ(scip, parval, 1.0) && SCIPisGE(scip, cutrhs, SCIProwGetRhs(prevrows[k])) )
3047  break;
3048  }
3049 
3050  /* if cut is new */
3051  if ( k >= *nprevrows )
3052  {
3053  prevrows[*nprevrows] = cut;
3054  ++(*nprevrows);
3055 
3056  SCIPdebugMsg(scip, " -> CG-cut <%s>: act=%f, rhs=%f, norm=%f, eff=%f, min=%f, max=%f (range=%f)\n",
3057  name, SCIPgetRowLPActivity(scip, cut), SCIProwGetRhs(cut), SCIProwGetNorm(cut),
3058  SCIPgetCutEfficacy(scip, NULL, cut),
3059  SCIPgetRowMinCoef(scip, cut), SCIPgetRowMaxCoef(scip, cut),
3060  SCIPgetRowMaxCoef(scip, cut)/SCIPgetRowMinCoef(scip, cut));
3061 #ifdef SCIP_DEBUG
3062  SCIP_CALL( SCIPprintRow(scip, cut, NULL) );
3063 #else
3064  if ( sepadata->output )
3065  {
3066  SCIP_CALL( SCIPprintRow(scip, cut, NULL) );
3067  }
3068 #endif
3069  SCIP_CALL( SCIPaddRow(scip, cut, FALSE, cutoff) );
3070  ++(*ngen);
3071  }
3072  else
3073  {
3074  SCIPdebugMsg(scip, "Cut already exists.\n");
3075  /* release the row */
3076  SCIP_CALL( SCIPreleaseRow(scip, &cut) );
3077  }
3078  }
3079  else
3080  {
3081  /* release the row */
3082  SCIP_CALL( SCIPreleaseRow(scip, &cut) );
3083  }
3084  }
3085  }
3086  }
3087 
3088  return SCIP_OKAY;
3089 }
3090 
3091 
3092 /** create CG-cut via CMIR-function */
3093 static
3095  SCIP* scip, /**< SCIP data structure */
3096  SCIP_SEPA* sepa, /**< separator */
3097  SCIP_SEPADATA* sepadata, /**< separator data */
3098  CGMIP_MIPDATA* mipdata, /**< data for sub-MIP */
3099  SCIP_SOL* sol, /**< solution of sub-MIP */
3100  SCIP_AGGRROW* aggrrow, /**< aggregation row to use for creating MIR cut */
3101  SCIP_Real* cutcoefs, /**< cut coefficients */
3102  int* cutinds, /**< problem indices of variables appearing in cut */
3103  SCIP_Real* cutvals, /**< values of variables in cut */
3104  SCIP_Real* varsolvals, /**< solution value of variables */
3105  SCIP_Real* weights, /**< weights to compute cmir cut */
3106  int* boundsfortrans, /**< bounds for cmir function of NULL */
3107  SCIP_BOUNDTYPE* boundtypesfortrans, /**< type of bounds for cmir function or NULL */
3108  int* nprevrows, /**< number of previously generated rows */
3109  SCIP_ROW** prevrows, /**< previously generated rows */
3110  SCIP_Bool* cutoff, /**< whether a cutoff has been detected */
3111  unsigned int* ngen /**< number of generated cuts */
3112  )
3113 {
3114  char name[SCIP_MAXSTRLEN];
3115  SCIP_Longint maxdnom;
3116  SCIP_Bool cutislocal;
3117  SCIP_Real maxscale;
3118  SCIP_Real cutrhs;
3119  SCIP_Real cutefficacy;
3120  SCIP_Bool success;
3121  SCIP_ROW** rows;
3122  SCIP_VAR** vars;
3123  SCIP* subscip;
3124  int nrows;
3125  int nvars;
3126  int k;
3127  int cutrank;
3128  int cutnnz;
3129 
3130  assert( scip != NULL );
3131  assert( sepadata != NULL );
3132  assert( mipdata != NULL );
3133  assert( sol != NULL );
3134  assert( cutcoefs != NULL );
3135  assert( cutinds != NULL );
3136  assert( cutvals != NULL );
3137  assert( varsolvals != NULL );
3138  assert( weights != NULL );
3139  assert( nprevrows != NULL );
3140  assert( prevrows != NULL );
3141  assert( cutoff != NULL );
3142  assert( ngen != NULL );
3143 
3144  *cutoff = FALSE;
3145  subscip = mipdata->subscip;
3146  assert( subscip != NULL );
3147 
3148  SCIP_CALL( SCIPgetLPRowsData(scip, &rows, &nrows) );
3149  assert( nrows > 0 );
3150  assert( (int) mipdata->nrows == nrows );
3151 
3152  /* @todo more advanced settings - compare sepa_gomory.c */
3153  maxdnom = (SCIP_Longint) sepadata->cutcoefbnd+1;
3154  maxscale = 10000.0;
3155 
3156  /* get variable data */
3157  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
3158 
3159  /* generate weights */
3160  for (k = 0; k < nrows; ++k)
3161  {
3162  SCIP_Real val;
3163 
3164  weights[k] = 0;
3165  if ( mipdata->ylhs[k] != NULL )
3166  {
3167  assert( !SCIProwIsModifiable(rows[k]) && (!SCIProwIsLocal(rows[k]) || sepadata->allowlocal) );
3168 
3169  val = SCIPgetSolVal(subscip, sol, mipdata->ylhs[k]);
3170  assert( ! SCIPisFeasNegative(subscip, val) );
3171 
3172  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
3173  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
3174 
3175  if ( SCIPisFeasPositive(subscip, val) )
3176  weights[k] = -val;
3177  }
3178  if ( mipdata->yrhs[k] != NULL )
3179  {
3180  assert( !SCIProwIsModifiable(rows[k]) && (!SCIProwIsLocal(rows[k]) || sepadata->allowlocal) );
3181 
3182  val = SCIPgetSolVal(subscip, sol, mipdata->yrhs[k]);
3183  assert( ! SCIPisFeasNegative(subscip, val) );
3184 
3185  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
3186  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
3187 
3188  /* in a suboptimal solution both values may be positive - take the one with larger absolute value */
3189  if ( SCIPisFeasGT(scip, val, ABS(weights[k])) )
3190  weights[k] = val;
3191  }
3192  }
3193 
3194  /* set up data for bounds to use */
3195  if ( sepadata->cmirownbounds )
3196  {
3197  int typefortrans;
3198 
3199  assert( boundsfortrans != NULL );
3200  assert( boundtypesfortrans != NULL );
3201 
3202  if ( sepadata->allowlocal )
3203  typefortrans = -2;
3204  else
3205  typefortrans = -1;
3206 
3207  /* check all variables */
3208  for (k = 0; k < nvars; ++k)
3209  {
3210  int pos;
3211  SCIP_VAR* var;
3212 
3213  var = vars[k];
3214  assert( var != NULL );
3215  pos = SCIPcolGetLPPos(SCIPvarGetCol(var));
3216 
3217  if ( pos < 0 )
3218  continue;
3219 
3220  assert( pos < (int) mipdata->ncols );
3221  assert( SCIPvarGetStatus(var) == SCIP_VARSTATUS_COLUMN );
3222 
3223  boundsfortrans[k] = typefortrans;
3224  boundtypesfortrans[k] = SCIP_BOUNDTYPE_LOWER;
3225 
3226  if ( mipdata->coltype[pos] == colContinuous || mipdata->coltype[pos] == colConverted )
3227  {
3228  assert( SCIPvarIsIntegral(var) || mipdata->coltype[pos] != colContinuous );
3229  continue;
3230  }
3231 
3232  /* check upper bound */
3233  if ( mipdata->z[pos] != NULL && SCIPisSumPositive(subscip, SCIPgetSolVal(subscip, sol, mipdata->z[pos])) )
3234  {
3235  /* check whether variable is complemented */
3236  if ( ! mipdata->iscomplemented[pos] )
3237  boundtypesfortrans[k] = SCIP_BOUNDTYPE_UPPER;
3238  /* otherwise use lower bound */
3239  }
3240  else
3241  {
3242  /* check whether variable is complemented */
3243  if ( mipdata->iscomplemented[pos] )
3244  boundtypesfortrans[k] = SCIP_BOUNDTYPE_UPPER;
3245  /* otherwise use lower bound */
3246  }
3247  }
3248  }
3249 
3250  /* create a MIR cut using the above calculated weights */
3251  cutefficacy = -1.0;
3252  cutrhs = -1.0;
3253  SCIP_CALL( SCIPaggrRowSumRows(scip, aggrrow, weights, NULL, -1, FALSE,
3254  sepadata->allowlocal, 2, (int) MAXAGGRLEN(nvars), &success) );
3255 
3256  if( !success )
3257  return SCIP_OKAY;
3258 
3259  SCIP_CALL( SCIPcalcMIR(scip, NULL, POSTPROCESS, BOUNDSWITCH, USEVBDS, sepadata->allowlocal, FIXINTEGRALRHS, boundsfortrans,
3260  boundtypesfortrans, MINFRAC, MAXFRAC, 1.0, aggrrow, cutcoefs, &cutrhs, cutinds, &cutnnz, &cutefficacy,
3261  &cutrank, &cutislocal, &success) );
3262 
3263  assert( sepadata->allowlocal || !cutislocal );
3264  SCIPdebugMsg(scip, "CMIR: success = %u, cut is%sefficacious (cutefficacy: %g, cutrhs: %g)\n", success,
3265  SCIPisEfficacious(scip, cutefficacy) ? " " : " not ", cutefficacy, cutrhs);
3266 
3267  /* if successful, convert dense cut into sparse row, and add the row as a cut
3268  * only if the cut if violated - if it is not violated we might store non-local cuts in the pool
3269  */
3270  if( success && (SCIPisEfficacious(scip, cutefficacy) || (sepadata->usecutpool && ! cutislocal)) )
3271  {
3272  SCIP_ROW* cut;
3273 
3274  /* create the cut */
3275  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "cgcut%d_%u", SCIPgetNLPs(scip), *ngen);
3276  SCIP_CALL( SCIPcreateEmptyRowSepa(scip, &cut, sepa, name, -SCIPinfinity(scip), cutrhs, cutislocal, FALSE, sepadata->dynamiccuts) );
3277 
3278  SCIP_CALL( SCIPcacheRowExtensions(scip, cut) );
3279 
3280  for( k = 0; k < cutnnz; ++k )
3281  {
3282  SCIP_CALL( SCIPaddVarToRow(scip, cut, vars[cutinds[k]], cutcoefs[k]) );
3283  }
3284 
3285  assert( success );
3286 
3287  /* set cut rank */
3288  SCIProwChgRank(cut, cutrank);
3289 
3290 #ifdef SCIP_DEBUG
3291  SCIP_CALL( SCIPprintRow(scip, cut, NULL) );
3292 #else
3293  if ( sepadata->output )
3294  {
3295  SCIP_CALL( SCIPprintRow(scip, cut, NULL) );
3296  }
3297 #endif
3298 
3299  /* try to scale the cut to integral values */
3300  SCIP_CALL( SCIPmakeRowIntegral(scip, cut, -SCIPepsilon(scip), SCIPsumepsilon(scip),
3301  maxdnom, maxscale, MAKECONTINTEGRAL, &success) );
3302 
3303  /* if the cut could be made integral */
3304  if ( success )
3305  {
3306  SCIP_CALL( SCIPflushRowExtensions(scip, cut) );
3307 
3308  /* add cut to pool */
3309  if ( ! cutislocal )
3310  {
3311  assert( SCIPisEfficacious(scip, cutefficacy) || sepadata->usecutpool );
3312  SCIP_CALL( SCIPaddPoolCut(scip, cut) );
3313  }
3314 
3315  if ( ! SCIPisCutEfficacious(scip, NULL, cut) )
3316  {
3317  SCIPdebugMsg(scip, " -> CG-cut <%s> no longer efficacious: act=%f, rhs=%f, norm=%f, eff=%f\n",
3318  name, SCIPgetRowLPActivity(scip, cut), SCIProwGetRhs(cut), SCIProwGetNorm(cut),
3319  SCIPgetCutEfficacy(scip, NULL, cut));
3320 
3321  /* release the row */
3322  SCIP_CALL( SCIPreleaseRow(scip, &cut) );
3323  }
3324  else
3325  {
3326  /* check whether cut has been found before - may happend due to projection */
3327  for (k = 0; k < *nprevrows; ++k)
3328  {
3329  SCIP_Real parval;
3330 
3331  assert( prevrows[k] != NULL );
3332  parval = SCIProwGetParallelism(cut, prevrows[k], 'e');
3333  /* exit if row is parallel to existing cut and rhs is not better */
3334  if ( SCIPisEQ(scip, parval, 1.0) && SCIPisGE(scip, cutrhs, SCIProwGetRhs(prevrows[k])) )
3335  break;
3336  }
3337 
3338  /* if cut is new */
3339  if ( k >= *nprevrows )
3340  {
3341  prevrows[*nprevrows] = cut;
3342  ++(*nprevrows);
3343 
3344  SCIPdebugMsg(scip, " -> CG-cut <%s>: act=%f, rhs=%f, norm=%f, eff=%f, rank=%d, min=%f, max=%f (range=%f)\n",
3345  name, SCIPgetRowLPActivity(scip, cut), SCIProwGetRhs(cut), SCIProwGetNorm(cut),
3346  SCIPgetCutEfficacy(scip, NULL, cut), SCIProwGetRank(cut),
3347  SCIPgetRowMinCoef(scip, cut), SCIPgetRowMaxCoef(scip, cut),
3348  SCIPgetRowMaxCoef(scip, cut)/SCIPgetRowMinCoef(scip, cut));
3349  #ifdef SCIP_OUTPUT
3350  SCIP_CALL( SCIPprintRow(scip, cut, NULL) );
3351  #else
3352  if ( sepadata->output )
3353  {
3354  SCIP_CALL( SCIPprintRow(scip, cut, NULL) );
3355  }
3356  #endif
3357  SCIP_CALL( SCIPaddRow(scip, cut, FALSE, cutoff) );
3358  ++(*ngen);
3359  }
3360  else
3361  {
3362  SCIPdebugMsg(scip, "Cut already exists.\n");
3363  /* release the row */
3364  SCIP_CALL( SCIPreleaseRow(scip, &cut) );
3365  }
3366  }
3367  }
3368  else
3369  {
3370  SCIPdebugMsg(scip, " -> CG-cut <%s> could not be scaled to integral coefficients: rhs=%f, eff=%f\n",
3371  name, cutefficacy, cutrhs);
3372 
3373  /* release the row */
3374  SCIP_CALL( SCIPreleaseRow(scip, &cut) );
3375  }
3376  }
3377 
3378  return SCIP_OKAY;
3379 }
3380 
3381 
3382 /** create CG-cut via strong-CG-function */
3383 static
3385  SCIP* scip, /**< SCIP data structure */
3386  SCIP_SEPA* sepa, /**< separator */
3387  SCIP_SEPADATA* sepadata, /**< separator data */
3388  CGMIP_MIPDATA* mipdata, /**< data for sub-MIP */
3389  SCIP_SOL* sol, /**< solution of sub-MIP */
3390  SCIP_AGGRROW* aggrrow, /**< aggregation row to use for creating MIR cut */
3391  SCIP_Real* cutcoefs, /**< cut coefficients */
3392  int* cutinds, /**< problem indices of variables appearing in cut */
3393  SCIP_Real* cutvals, /**< values of variables in cut */
3394  SCIP_Real* varsolvals, /**< solution value of variables */
3395  SCIP_Real* weights, /**< weights to compute cmir cut */
3396  int* nprevrows, /**< number of previously generated rows */
3397  SCIP_ROW** prevrows, /**< previously generated rows */
3398  SCIP_Bool* cutoff, /**< whether a cutoff has been detected */
3399  unsigned int* ngen /**< number of generated cuts */
3400  )
3401 {
3402  char name[SCIP_MAXSTRLEN];
3403  SCIP_Longint maxdnom;
3404  SCIP_Bool cutislocal;
3405  SCIP_Real maxscale;
3406  SCIP_Real cutrhs;
3407  SCIP_Real cutefficacy;
3408  SCIP_Bool success;
3409  SCIP_ROW** rows;
3410  SCIP_VAR** vars;
3411  SCIP* subscip;
3412  int nrows;
3413  int nvars;
3414  int k;
3415  int cutrank;
3416  int cutnnz;
3417 
3418  assert( scip != NULL );
3419  assert( sepadata != NULL );
3420  assert( mipdata != NULL );
3421  assert( sol != NULL );
3422  assert( cutcoefs != NULL );
3423  assert( cutinds != NULL );
3424  assert( cutvals != NULL );
3425  assert( varsolvals != NULL );
3426  assert( weights != NULL );
3427  assert( nprevrows != NULL );
3428  assert( prevrows != NULL );
3429  assert( cutoff != NULL );
3430  assert( ngen != NULL );
3431 
3432  *cutoff = FALSE;
3433  subscip = mipdata->subscip;
3434  assert( subscip != NULL );
3435 
3436  SCIP_CALL( SCIPgetLPRowsData(scip, &rows, &nrows) );
3437  assert( nrows > 0 );
3438  assert( (int) mipdata->nrows == nrows );
3439 
3440  /* @todo more advanced settings - compare sepa_gomory.c */
3441  maxdnom = (SCIP_Longint) sepadata->cutcoefbnd + 1;
3442  maxscale = 10000.0;
3443 
3444  /* get variable data */
3445  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
3446 
3447  /* generate weights */
3448  for (k = 0; k < nrows; ++k)
3449  {
3450  SCIP_Real val;
3451 
3452  weights[k] = 0;
3453  if ( mipdata->ylhs[k] != NULL )
3454  {
3455  assert( !SCIProwIsModifiable(rows[k]) && (!SCIProwIsLocal(rows[k]) || sepadata->allowlocal) );
3456 
3457  val = SCIPgetSolVal(subscip, sol, mipdata->ylhs[k]);
3458  assert( ! SCIPisFeasNegative(subscip, val) );
3459 
3460  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
3461  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
3462 
3463  if ( SCIPisFeasPositive(subscip, val) )
3464  weights[k] = -val;
3465  }
3466  if ( mipdata->yrhs[k] != NULL )
3467  {
3468  assert( !SCIProwIsModifiable(rows[k]) && (!SCIProwIsLocal(rows[k]) || sepadata->allowlocal) );
3469 
3470  val = SCIPgetSolVal(subscip, sol, mipdata->yrhs[k]);
3471  assert( ! SCIPisFeasNegative(subscip, val) );
3472 
3473  assert( sepadata->skipmultbounds || SCIPisFeasLT(subscip, val, 1.0) );
3474  val = SCIPfrac(scip, val); /* take fractional value if variable has no upper bounds */
3475 
3476  /* in a suboptimal solution both values may be positive - take the one with larger absolute value */
3477  if ( SCIPisFeasGT(scip, val, ABS(weights[k])) )
3478  weights[k] = val;
3479  }
3480  }
3481 
3482  /* create a strong CG cut out of the weighted LP rows using the B^-1 row as weights */
3483  cutefficacy = -1.0;
3484  cutrhs = -1.0;
3485  SCIP_CALL( SCIPaggrRowSumRows(scip, aggrrow, weights, NULL, -1, FALSE,
3486  sepadata->allowlocal, 1, (int) MAXAGGRLEN(nvars), &success) );
3487 
3488  if( !success )
3489  return SCIP_OKAY;
3490 
3491  SCIP_CALL( SCIPcalcStrongCG(scip, NULL, POSTPROCESS, BOUNDSWITCH, USEVBDS, sepadata->allowlocal, MINFRAC, MAXFRAC,
3492  1.0, aggrrow, cutcoefs, &cutrhs, cutinds, &cutnnz, &cutefficacy, &cutrank, &cutislocal, &success) );
3493 
3494  assert( sepadata->allowlocal || !cutislocal );
3495  SCIPdebugMsg(scip, "Strong-CG: success = %u, cut is%sefficacious (cutefficacy: %g, cutrhs: %g)\n", success,
3496  SCIPisEfficacious(scip, cutefficacy) ? " " : " not ", cutefficacy, cutrhs);
3497 
3498  /* if successful, convert dense cut into sparse row, and add the row as a cut
3499  * only if the cut if violated - if it is not violated we might store non-local cuts in the pool
3500  */
3501  if( success && (SCIPisEfficacious(scip, cutefficacy) || (sepadata->usecutpool && ! cutislocal)) )
3502  {
3503  SCIP_ROW* cut;
3504 
3505  /* create the cut */
3506  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "cgcut%d_%u", SCIPgetNLPs(scip), *ngen);
3507  SCIP_CALL( SCIPcreateEmptyRowSepa(scip, &cut, sepa, name, -SCIPinfinity(scip), cutrhs, cutislocal, FALSE, sepadata->dynamiccuts) );
3508 
3509  SCIP_CALL( SCIPcacheRowExtensions(scip, cut) );
3510 
3511  for( k = 0; k < cutnnz; ++k )
3512  {
3513  SCIP_CALL( SCIPaddVarToRow(scip, cut, vars[cutinds[k]], cutcoefs[k]) );
3514  }
3515 
3516  assert( success );
3517 
3518  /* set cut rank */
3519  SCIProwChgRank(cut, cutrank);
3520 
3521 #ifdef SCIP_DEBUG
3522  SCIP_CALL( SCIPprintRow(scip, cut, NULL) );
3523 #else
3524  if ( sepadata->output )
3525  {
3526  SCIP_CALL( SCIPprintRow(scip, cut, NULL) );
3527  }
3528 #endif
3529 
3530  /* try to scale the cut to integral values */
3531  SCIP_CALL( SCIPmakeRowIntegral(scip, cut, -SCIPepsilon(scip), SCIPsumepsilon(scip),
3532  maxdnom, maxscale, MAKECONTINTEGRAL, &success) );
3533 
3534  /* if the cut could be made integral */
3535  if ( success )
3536  {
3537  SCIP_CALL( SCIPflushRowExtensions(scip, cut) );
3538 
3539  /* add cut to pool */
3540  if ( ! cutislocal )
3541  {
3542  assert( SCIPisEfficacious(scip, cutefficacy) || sepadata->usecutpool );
3543  SCIP_CALL( SCIPaddPoolCut(scip, cut) );
3544  }
3545 
3546  if ( ! SCIPisCutEfficacious(scip, NULL, cut) )
3547  {
3548  SCIPdebugMsg(scip, " -> CG-cut <%s> no longer efficacious: act=%f, rhs=%f, norm=%f, eff=%f\n",
3549  name, SCIPgetRowLPActivity(scip, cut), SCIProwGetRhs(cut), SCIProwGetNorm(cut),
3550  SCIPgetCutEfficacy(scip, NULL, cut));
3551 
3552  /* release the row */
3553  SCIP_CALL( SCIPreleaseRow(scip, &cut) );
3554  }
3555  else
3556  {
3557  /* check whether cut has been found before - may happend due to projection */
3558  for (k = 0; k < *nprevrows; ++k)
3559  {
3560  SCIP_Real parval;
3561 
3562  assert( prevrows[k] != NULL );
3563  parval = SCIProwGetParallelism(cut, prevrows[k], 'e');
3564  /* exit if row is parallel to existing cut and rhs is not better */
3565  if ( SCIPisEQ(scip, parval, 1.0) && SCIPisGE(scip, cutrhs, SCIProwGetRhs(prevrows[k])) )
3566  break;
3567  }
3568 
3569  /* if cut is new */
3570  if ( k >= *nprevrows )
3571  {
3572  prevrows[*nprevrows] = cut;
3573  ++(*nprevrows);
3574 
3575  SCIPdebugMsg(scip, " -> CG-cut <%s>: act=%f, rhs=%f, norm=%f, eff=%f, rank=%d, min=%f, max=%f (range=%f)\n",
3576  name, SCIPgetRowLPActivity(scip, cut), SCIProwGetRhs(cut), SCIProwGetNorm(cut),
3577  SCIPgetCutEfficacy(scip, NULL, cut), SCIProwGetRank(cut),
3578  SCIPgetRowMinCoef(scip, cut), SCIPgetRowMaxCoef(scip, cut),
3579  SCIPgetRowMaxCoef(scip, cut)/SCIPgetRowMinCoef(scip, cut));
3580  #ifdef SCIP_OUTPUT
3581  SCIP_CALL( SCIPprintRow(scip, cut, NULL) );
3582  #else
3583  if ( sepadata->output )
3584  {
3585  SCIP_CALL( SCIPprintRow(scip, cut, NULL) );
3586  }
3587  #endif
3588  SCIP_CALL( SCIPaddRow(scip, cut, FALSE, cutoff) );
3589  ++(*ngen);
3590  }
3591  else
3592  {
3593  SCIPdebugMsg(scip, "Cut already exists.\n");
3594  /* release the row */
3595  SCIP_CALL( SCIPreleaseRow(scip, &cut) );
3596  }
3597  }
3598  }
3599  else
3600  {
3601  SCIPdebugMsg(scip, " -> CG-cut <%s> could not be scaled to integral coefficients: rhs=%f, eff=%f\n",
3602  name, cutefficacy, cutrhs);
3603 
3604  /* release the row */
3605  SCIP_CALL( SCIPreleaseRow(scip, &cut) );
3606  }
3607  }
3608 
3609  return SCIP_OKAY;
3610 }
3611 
3612 
3613 /** Create CG-cuts from solutions of sub-MIP */
3614 static
3616  SCIP* scip, /**< SCIP data structure */
3617  SCIP_SEPA* sepa, /**< separator */
3618  SCIP_SEPADATA* sepadata, /**< separator data */
3619  CGMIP_MIPDATA* mipdata, /**< data for sub-MIP */
3620  SCIP_Bool* cutoff, /**< whether a cutoff has been detected */
3621  unsigned int* ngen /**< number of generated cuts */
3622  )
3623 {
3624  SCIP_BOUNDTYPE* boundtypesfortrans;
3625  SCIP_STAGE stage;
3626  SCIP_AGGRROW* aggrrow = NULL;
3627  SCIP_Real* varsolvals;
3628  SCIP_Real* weights;
3629  int* cutinds;
3630  SCIP_Real* cutvals;
3631  SCIP_Real* cutcoefs;
3632  SCIP_ROW** prevrows;
3633  SCIP_SOL** sols;
3634  SCIP_VAR** vars;
3635  SCIP* subscip;
3636  int* boundsfortrans;
3637  int nprevrows;
3638  int ntotalrows;
3639  int nsols;
3640  int nvars;
3641  int k;
3642  int s;
3643 
3644  assert( scip != NULL );
3645  assert( sepadata != NULL );
3646  assert( mipdata != NULL );
3647  assert( cutoff != NULL );
3648  assert( ngen != NULL );
3649 
3650  subscip = mipdata->subscip;
3651  assert( subscip != NULL );
3652 
3653  *cutoff = FALSE;
3654  *ngen = 0;
3655 
3656  /* check if solving was successful and get solutions */
3657  stage = SCIPgetStage(subscip);
3658  if ( stage == SCIP_STAGE_SOLVING || stage == SCIP_STAGE_SOLVED )
3659  nsols = SCIPgetNSols(subscip);
3660  else
3661  nsols = 0;
3662 
3663  /* only if solutions have been found */
3664  if ( nsols == 0 )
3665  return SCIP_OKAY;
3666 
3667  SCIPdebugMsg(scip, "Generating CG-cuts from %d sols (cmir: %u, strong-cg: %u) ...\n", nsols, sepadata->usecmir, sepadata->usestrongcg);
3668 
3669  sols = SCIPgetSols(subscip);
3670 
3671  /* get variable data */
3672  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
3673 
3674  /* allocate temporary memory */
3675  assert(mipdata->ntotalrows <= INT_MAX);
3676  ntotalrows = (int)mipdata->ntotalrows;
3677  assert( ntotalrows >= SCIPgetNLPRows(scip) && ntotalrows <= SCIPgetNLPRows(scip) + 1 );
3678  SCIP_CALL( SCIPallocBufferArray(scip, &cutcoefs, nvars) );
3679  SCIP_CALL( SCIPallocBufferArray(scip, &varsolvals, nvars) );
3680  SCIP_CALL( SCIPallocBufferArray(scip, &cutinds, nvars) );
3681  SCIP_CALL( SCIPallocBufferArray(scip, &cutvals, nvars) );
3682  SCIP_CALL( SCIPallocBufferArray(scip, &weights, ntotalrows) );
3683  SCIP_CALL( SCIPallocBufferArray(scip, &prevrows, 2 * nsols) );
3684 
3685  if ( sepadata->usecmir || sepadata->usestrongcg )
3686  {
3687  SCIP_CALL( SCIPaggrRowCreate(scip, &aggrrow) );
3688  }
3689 
3690  /* prepare arrays for bound information, if requested */
3691  if ( sepadata->usecmir && sepadata->cmirownbounds )
3692  {
3693  SCIP_CALL( SCIPallocBufferArray(scip, &boundsfortrans, nvars) );
3694  SCIP_CALL( SCIPallocBufferArray(scip, &boundtypesfortrans, nvars) );
3695  }
3696  else
3697  {
3698  boundsfortrans = NULL;
3699  boundtypesfortrans = NULL;
3700  }
3701 
3702  /* get solution values */
3703  for (k = 0; k < nvars; ++k)
3704  {
3705  if ( SCIPvarGetStatus(vars[k]) == SCIP_VARSTATUS_COLUMN )
3706  varsolvals[k] = SCIPvarGetLPSol(vars[k]);
3707  else
3708  varsolvals[k] = 0.0;
3709  }
3710 
3711  /* loop through solutions found */
3712  nprevrows = 0;
3713  for (s = 0; s < nsols; ++s)
3714  {
3715  SCIP_SOL* sol;
3716  sol = sols[s];
3717 
3718  /* generate cuts by the C-MIR and/or Strong-CG functions */
3719  if ( sepadata->usecmir )
3720  {
3721  SCIP_CALL( createCGCutCMIR(scip, sepa, sepadata, mipdata, sol, aggrrow, cutcoefs, cutinds, cutvals, varsolvals, weights,
3722  boundsfortrans, boundtypesfortrans, &nprevrows, prevrows, cutoff, ngen) );
3723  }
3724 
3725  if ( sepadata->usestrongcg )
3726  {
3727  SCIP_CALL( createCGCutStrongCG(scip, sepa, sepadata, mipdata, sol, aggrrow, cutcoefs, cutinds, cutvals, varsolvals, weights,
3728  &nprevrows, prevrows, cutoff, ngen) );
3729  }
3730 
3731  if ( ! sepadata->usecmir && ! sepadata->usestrongcg )
3732  {
3733  SCIP_CALL( createCGCutDirect(scip, sepa, sepadata, mipdata, sol, cutcoefs, cutinds, cutvals, varsolvals, weights,
3734  &nprevrows, prevrows, cutoff, ngen) );
3735 
3736  assert(! sepadata->usecmir && ! sepadata->usestrongcg);
3737  }
3738  }
3739  assert( nprevrows <= 2 * nsols );
3740  assert( sepadata->usecmir || nprevrows <= nsols );
3741  assert( sepadata->usestrongcg || nprevrows <= nsols );
3742 
3743  /* release rows */
3744  for (k = 0; k < nprevrows; ++k)
3745  {
3746  SCIP_CALL( SCIPreleaseRow(scip, &(prevrows[k])) );
3747  }
3748 
3749  if ( sepadata->usecmir || sepadata->usestrongcg )
3750  SCIPaggrRowFree(scip, &aggrrow);
3751 
3752  /* free temporary memory */
3753  SCIPfreeBufferArrayNull(scip, &boundsfortrans);
3754  SCIPfreeBufferArrayNull(scip, &boundtypesfortrans);
3755 
3756  SCIPfreeBufferArray(scip, &prevrows);
3757  SCIPfreeBufferArray(scip, &weights);
3758  SCIPfreeBufferArray(scip, &cutvals);
3759  SCIPfreeBufferArray(scip, &cutinds);
3760  SCIPfreeBufferArray(scip, &varsolvals);
3761  SCIPfreeBufferArray(scip, &cutcoefs);
3762 
3763  return SCIP_OKAY;
3764 }
3765 
3766 
3767 /** frees "subscip" data */
3768 static
3770  SCIP* scip, /**< SCIP data structure */
3771  SCIP_SEPA* sepa, /**< separator data */
3772  CGMIP_MIPDATA* mipdata /**< data for sub-MIP */
3773  )
3774 {
3775  SCIP_SEPADATA* sepadata;
3776  unsigned int i, j;
3777  SCIP* subscip;
3778 
3779  assert( scip != NULL );
3780  assert( sepa != NULL );
3781  assert( mipdata != NULL );
3782 
3783  /* free separator data */
3784  sepadata = SCIPsepaGetData(sepa);
3785  assert( sepadata != NULL );
3786 
3787  SCIPdebugMsg(scip, "Freeing subscip ...\n");
3788 
3789  subscip = mipdata->subscip;
3790  assert( subscip != NULL );
3791 
3792  for (j = 0; j < mipdata->ncols; ++j)
3793  {
3794  if ( mipdata->coltype[j] == colPresent )
3795  {
3796  assert( mipdata->alpha[j] != NULL );
3797  SCIP_CALL( SCIPreleaseVar(subscip, &(mipdata->alpha[j])) );
3798  SCIP_CALL( SCIPreleaseVar(subscip, &(mipdata->fracalpha[j])) );
3799  }
3800  }
3801  SCIP_CALL( SCIPreleaseVar(subscip, &(mipdata->beta)) );
3802  SCIP_CALL( SCIPreleaseVar(subscip, &(mipdata->fracbeta)) );
3803 
3804  for (i = 0; i < mipdata->nrows; ++i)
3805  {
3806  if ( mipdata->ylhs[i] != NULL )
3807  {
3808  SCIP_CALL( SCIPreleaseVar(subscip, &(mipdata->ylhs[i])) );
3809  }
3810  if ( mipdata->yrhs[i] != NULL )
3811  {
3812  SCIP_CALL( SCIPreleaseVar(subscip, &(mipdata->yrhs[i])) );
3813  }
3814  }
3815 
3816  if ( sepadata->useobjub || sepadata->useobjlb )
3817  {
3818  if ( mipdata->yrhs[mipdata->nrows] )
3819  {
3820  SCIP_CALL( SCIPreleaseVar(subscip, &(mipdata->yrhs[mipdata->nrows])) );
3821  }
3822  if ( mipdata->ylhs[mipdata->nrows] )
3823  {
3824  SCIP_CALL( SCIPreleaseVar(subscip, &(mipdata->ylhs[mipdata->nrows])) );
3825  }
3826  }
3827 
3828  for (j = 0; j < mipdata->ncols; ++j)
3829  {
3830  if ( mipdata->z[j] != NULL )
3831  {
3832  SCIP_CALL( SCIPreleaseVar(subscip, &(mipdata->z[j])) );
3833  }
3834  }
3835 
3836  SCIP_CALL( SCIPfree(&(mipdata->subscip)) );
3837 
3838  SCIPfreeBlockMemoryArray(scip, &(mipdata->z), 2*mipdata->ncols); /*lint !e647*/
3839  SCIPfreeBlockMemoryArray(scip, &(mipdata->yrhs), mipdata->ntotalrows);
3840  SCIPfreeBlockMemoryArray(scip, &(mipdata->ylhs), mipdata->ntotalrows);
3841  SCIPfreeBlockMemoryArray(scip, &(mipdata->isshifted), mipdata->ncols);
3842  SCIPfreeBlockMemoryArray(scip, &(mipdata->iscomplemented), mipdata->ncols);
3843  SCIPfreeBlockMemoryArray(scip, &(mipdata->coltype), mipdata->ncols);
3844  SCIPfreeBlockMemoryArray(scip, &(mipdata->fracalpha), mipdata->ncols);
3845  SCIPfreeBlockMemoryArray(scip, &(mipdata->alpha), mipdata->ncols);
3846 
3847  return SCIP_OKAY;
3848 }
3849 
3850 
3851 /*
3852  * Callback methods
3853  */
3854 
3855 
3856 /** initialization method of separator (called after problem was transformed) */
3857 static
3858 SCIP_DECL_SEPAINIT(sepaInitCGMIP)
3859 {
3860  SCIP_SEPADATA* sepadata;
3861 
3862  sepadata = SCIPsepaGetData(sepa);
3863  assert(sepadata != NULL);
3864 
3865  /* create and initialize random number generator */
3866  SCIP_CALL( SCIPcreateRandom(scip, &sepadata->randnumgen, DEFAULT_RANDSEED, TRUE) );
3867 
3868  return SCIP_OKAY;
3869 }
3870 
3871 /** deinitialization method of separator (called before transformed problem is freed) */
3872 static
3873 SCIP_DECL_SEPAEXIT(sepaExitCGMIP)
3874 { /*lint --e{715}*/
3875  SCIP_SEPADATA* sepadata;
3876 
3877  sepadata = SCIPsepaGetData(sepa);
3878  assert(sepadata != NULL);
3879 
3880  SCIPfreeRandom(scip, &sepadata->randnumgen);
3881 
3882  return SCIP_OKAY;
3883 }
3884 
3885 /** copy method for separator plugins (called when SCIP copies plugins) */
3886 static
3887 SCIP_DECL_SEPACOPY(sepaCopyCGMIP)
3888 { /*lint --e{715}*/
3889  assert( scip != NULL );
3890  assert( sepa != NULL );
3891  assert( strcmp(SCIPsepaGetName(sepa), SEPA_NAME) == 0 );
3892 
3893  /* call inclusion method of constraint handler */
3895 
3896  return SCIP_OKAY;
3897 }
3898 
3899 
3900 /** destructor of separator to free user data (called when SCIP is exiting) */
3901 static
3902 SCIP_DECL_SEPAFREE(sepaFreeCGMIP)
3903 { /*lint --e{715}*/
3904  SCIP_SEPADATA* sepadata;
3905 
3906  assert( scip != NULL );
3907  assert( sepa != NULL );
3908  assert( strcmp(SCIPsepaGetName(sepa), SEPA_NAME) == 0 );
3909 
3910  /* free separator data */
3911  sepadata = SCIPsepaGetData(sepa);
3912  assert( sepadata != NULL );
3913 
3914  SCIPfreeBlockMemory(scip, &sepadata);
3915 
3916  SCIPsepaSetData(sepa, NULL);
3917 
3918  return SCIP_OKAY;
3919 }
3920 
3921 
3922 /** LP solution separation method of separator */
3923 static
3924 SCIP_DECL_SEPAEXECLP(sepaExeclpCGMIP)
3925 { /*lint --e{715}*/
3926  SCIP_SEPADATA* sepadata;
3927  CGMIP_MIPDATA* mipdata;
3928 
3929  int depth;
3930  int ncalls;
3931  int ncols;
3932  int nrows;
3933  unsigned int ngen;
3934  SCIP_Bool success;
3935  SCIP_Bool cutoff = FALSE;
3936 
3937  assert( scip != NULL );
3938  assert( sepa != NULL );
3939  assert( strcmp(SCIPsepaGetName(sepa), SEPA_NAME) == 0 );
3940  assert( result != NULL );
3941 
3942  *result = SCIP_DIDNOTRUN;
3943  ngen = 0;
3944 
3945  sepadata = SCIPsepaGetData(sepa);
3946  assert(sepadata != NULL);
3947 
3948  depth = SCIPgetDepth(scip);
3949 
3950  /* only call separator, if we are not close to terminating */
3951  if ( SCIPisStopped(scip) )
3952  return SCIP_OKAY;
3953 
3954  /* only call separator up to a maximum depth */
3955  if ( sepadata->maxdepth >= 0 && depth > sepadata->maxdepth )
3956  return SCIP_OKAY;
3957 
3958  /* only call separator a given number of times at each node */
3959  ncalls = SCIPsepaGetNCallsAtNode(sepa);
3960  if ( (depth == 0 && sepadata->maxroundsroot >= 0 && ncalls >= sepadata->maxroundsroot)
3961  || (depth > 0 && sepadata->maxrounds >= 0 && ncalls >= sepadata->maxrounds) )
3962  return SCIP_OKAY;
3963 
3964  /* only call separator, if an optimal LP solution is at hand */
3966  return SCIP_OKAY;
3967 
3968  /* skip separation if there are continuous variables, but only integers required */
3969  if ( SCIPgetNContVars(scip) > 0 && sepadata->onlyintvars )
3970  return SCIP_OKAY;
3971 
3972  /* only call separator, if there are fractional variables */
3973  if ( SCIPgetNLPBranchCands(scip) == 0 )
3974  return SCIP_OKAY;
3975 
3976  /* check for parameters */
3977  if ( ( sepadata->useobjub || sepadata->useobjlb ) && ( sepadata->usecmir || sepadata->usestrongcg ) )
3978  {
3980  "WARNING - sepa_cgmip: Using objective function bounds and CMIR or Strong-CG functions is useless. Turning off usage of objective function bounds.\n");
3981  SCIP_CALL( SCIPsetBoolParam(scip, "separating/cgmip/useobjub", FALSE) );
3982  SCIP_CALL( SCIPsetBoolParam(scip, "separating/cgmip/useobjlb", FALSE) );
3983  }
3984  sepadata->allowlocal = allowlocal;
3985 
3986  /* get LP data */
3987  ncols = SCIPgetNLPCols(scip);
3988  nrows = SCIPgetNLPRows(scip);
3989  if ( ncols <= NCOLSTOOSMALL || nrows <= NROWSTOOSMALL )
3990  return SCIP_OKAY;
3991 
3992  /* determine whether we should run the separation based on a decision tree */
3993  if ( sepadata->decisiontree )
3994  {
3995  SCIP_Bool separate;
3996  SCIP_Real firstlptime;
3997 
3998  separate = FALSE;
3999  firstlptime = SCIPgetFirstLPTime(scip);
4000 
4001  if ( nrows <= 136 && firstlptime <= 0.05 && ncols <= 143 )
4002  separate = TRUE;
4003  else if ( nrows <= 136 && 0.05 < firstlptime && firstlptime <= 0.15 && ncols <= 143 )
4004  separate = TRUE;
4005  else if ( 136 < nrows && nrows <= 332 && ncols <= 143 )
4006  separate = TRUE;
4007  else if ( 136 < nrows && nrows <= 332 && 655 < ncols && ncols <= 1290 )
4008  separate = TRUE;
4009  else if ( 333 < nrows && nrows <= 874 && 0.15 < firstlptime && firstlptime <= 0.25 && 2614 < ncols && ncols <= 5141 )
4010  separate = TRUE;
4011  else if ( 875 < nrows && nrows <= 1676 && firstlptime <= 0.05 && 143 < ncols && ncols <= 265 )
4012  separate = TRUE;
4013  else if ( 875 < nrows && nrows <= 1676 && firstlptime <= 0.05 && 265 < ncols && ncols <= 654 )
4014  separate = TRUE;
4015  else if ( 875 < nrows && nrows <= 1676 && 0.05 < firstlptime && firstlptime <= 0.15 )
4016  separate = TRUE;
4017  else if ( 875 < nrows && nrows <= 1676 && 0.15 < firstlptime && firstlptime <= 0.25 && 1291 < ncols && ncols <= 2613 )
4018  separate = TRUE;
4019  else if ( nrows > 8146 && 0.75 < firstlptime && firstlptime <= 6.25 && 655 < ncols && ncols <= 1290 )
4020  separate = TRUE;
4021  else if ( nrows > 8146 && 0.75 < firstlptime && firstlptime <= 6.25 && 1291 < ncols && ncols <= 2613 )
4022  separate = TRUE;
4023  else if ( nrows > 8146 && firstlptime > 6.25 )
4024  separate = TRUE;
4025 
4026  if ( ! separate )
4027  {
4028  return SCIP_OKAY;
4029  }
4030  }
4031 
4032  /* preceed with separation */
4033  *result = SCIP_DIDNOTFIND;
4034 
4035  SCIPdebugMsg(scip, "separating CG-cuts via sub-MIPs: %d cols, %d rows\n", ncols, nrows);
4036 
4037  /* prepare data */
4038  SCIP_CALL( SCIPallocBlockMemory(scip, &mipdata) );
4039  mipdata->subscip = NULL;
4040  mipdata->alpha = NULL;
4041  mipdata->fracalpha = NULL;
4042  mipdata->beta = NULL;
4043  mipdata->fracbeta = NULL;
4044  mipdata->coltype = NULL;
4045  mipdata->iscomplemented = NULL;
4046  mipdata->isshifted = NULL;
4047  mipdata->ylhs = NULL;
4048  mipdata->yrhs = NULL;
4049  mipdata->z = NULL;
4050  mipdata->normtype = ' ';
4051 
4052  mipdata->conshdlrfullnorm = CONSHDLRFULLNORM;
4053  mipdata->scip = scip;
4054  mipdata->sepa = sepa;
4055  mipdata->sepadata = sepadata;
4056 
4057  /* get the type of norm to use for efficacy calculations */
4058  SCIP_CALL( SCIPgetCharParam(scip, "separating/efficacynorm", &mipdata->normtype) );
4059 
4060  /* create subscip */
4061  SCIP_CALL( createSubscip(scip, sepa, sepadata, mipdata) );
4062 
4063  /* set parameters */
4064  SCIP_CALL( subscipSetParams(sepadata, mipdata, &success) );
4065 
4066  if ( success && !SCIPisStopped(scip) )
4067  {
4068  /* solve subscip */
4069  SCIP_CALL( solveSubscip(scip, sepadata, mipdata, &success) );
4070 
4071  /* preceed if solution was successful */
4072  if ( success && ! SCIPisStopped(scip) )
4073  {
4074  SCIP_CALL( createCGCuts(scip, sepa, sepadata, mipdata, &cutoff, &ngen) );
4075  }
4076  }
4077 
4078  SCIP_CALL( freeSubscip(scip, sepa, mipdata) );
4079  SCIPfreeBlockMemory(scip, &mipdata);
4080 
4081  SCIPdebugMsg(scip, "Found %u CG-cuts.\n", ngen);
4082 
4083  if ( cutoff )
4084  *result = SCIP_CUTOFF;
4085  else if ( ngen > 0 )
4086  *result = SCIP_SEPARATED;
4087 
4088 #ifdef SCIP_OUTPUT
4089  /* SCIP_CALL( SCIPwriteLP(scip, "cuts.lp") ); */
4090  /* SCIP_CALL( SCIPwriteMIP(scip, "cuts.lp", FALSE, TRUE) ); */
4091 #endif
4092 
4093  return SCIP_OKAY;
4094 }
4095 
4096 /*
4097  * separator specific interface methods
4098  */
4099 
4100 /** creates the CGMIP MIR cut separator and includes it in SCIP */
4102  SCIP* scip /**< SCIP data structure */
4103  )
4104 {
4105  SCIP_SEPADATA* sepadata;
4106  SCIP_SEPA* sepa;
4107 
4108  /* create separator data */
4109  SCIP_CALL( SCIPallocBlockMemory(scip, &sepadata) );
4110 
4111  sepa = NULL;
4112  /* include separator */
4114  SEPA_USESSUBSCIP, SEPA_DELAY, sepaExeclpCGMIP, NULL, sepadata) );
4115  assert(sepa != NULL);
4116 
4117  SCIP_CALL( SCIPsetSepaCopy(scip, sepa, sepaCopyCGMIP) );
4118  SCIP_CALL( SCIPsetSepaFree(scip, sepa, sepaFreeCGMIP) );
4119  SCIP_CALL( SCIPsetSepaInit(scip, sepa, sepaInitCGMIP) );
4120  SCIP_CALL( SCIPsetSepaExit(scip, sepa, sepaExitCGMIP) );
4121 
4122  /* add separator parameters */
4123  SCIP_CALL( SCIPaddIntParam(scip,
4124  "separating/" SEPA_NAME "/maxrounds",
4125  "maximal number of cgmip separation rounds per node (-1: unlimited)",
4126  &sepadata->maxrounds, FALSE, DEFAULT_MAXROUNDS, -1, INT_MAX, NULL, NULL) );
4127 
4128  SCIP_CALL( SCIPaddIntParam(scip,
4129  "separating/" SEPA_NAME "/maxroundsroot",
4130  "maximal number of cgmip separation rounds in the root node (-1: unlimited)",
4131  &sepadata->maxroundsroot, FALSE, DEFAULT_MAXROUNDSROOT, -1, INT_MAX, NULL, NULL) );
4132 
4133  SCIP_CALL( SCIPaddIntParam(scip,
4134  "separating/" SEPA_NAME "/maxdepth",
4135  "maximal depth at which the separator is applied (-1: unlimited)",
4136  &sepadata->maxdepth, FALSE, DEFAULT_MAXDEPTH, -1, INT_MAX, NULL, NULL) );
4137 
4139  "separating/" SEPA_NAME "/decisiontree",
4140  "Use decision tree to turn separation on/off?",
4141  &sepadata->decisiontree, FALSE, DEFAULT_DECISIONTREE, NULL, NULL) );
4142 
4144  "separating/" SEPA_NAME "/timelimit",
4145  "time limit for sub-MIP",
4146  &sepadata->timelimit, TRUE, DEFAULT_TIMELIMIT, 0.0, SCIP_REAL_MAX, NULL, NULL) );
4147 
4149  "separating/" SEPA_NAME "/memorylimit",
4150  "memory limit for sub-MIP",
4151  &sepadata->memorylimit, TRUE, DEFAULT_MEMORYLIMIT, 0.0, SCIP_REAL_MAX, NULL, NULL) );
4152 
4154  "separating/" SEPA_NAME "/minnodelimit",
4155  "minimum number of nodes considered for sub-MIP (-1: unlimited)",
4156  &sepadata->minnodelimit, FALSE, DEFAULT_MINNODELIMIT, -1LL, SCIP_LONGINT_MAX, NULL, NULL) );
4157 
4159  "separating/" SEPA_NAME "/maxnodelimit",
4160  "maximum number of nodes considered for sub-MIP (-1: unlimited)",
4161  &sepadata->maxnodelimit, FALSE, DEFAULT_MAXNODELIMIT, -1LL, SCIP_LONGINT_MAX, NULL, NULL) );
4162 
4164  "separating/" SEPA_NAME "/cutcoefbnd",
4165  "bounds on the values of the coefficients in the CG-cut",
4166  &sepadata->cutcoefbnd, TRUE, DEFAULT_CUTCOEFBND, 0.0, SCIP_REAL_MAX, NULL, NULL) );
4167 
4169  "separating/" SEPA_NAME "/onlyactiverows",
4170  "Use only active rows to generate cuts?",
4171  &sepadata->onlyactiverows, FALSE, DEFAULT_ONLYACTIVEROWS, NULL, NULL) );
4172 
4173  SCIP_CALL( SCIPaddIntParam(scip,
4174  "separating/" SEPA_NAME "/maxrowage",
4175  "maximal age of rows to consider if onlyactiverows is false",
4176  &sepadata->maxrowage, FALSE, DEFAULT_MAXROWAGE, -1, INT_MAX, NULL, NULL) );
4177 
4179  "separating/" SEPA_NAME "/onlyrankone",
4180  "Separate only rank 1 inequalities w.r.t. CG-MIP separator?",
4181  &sepadata->onlyrankone, FALSE, DEFAULT_ONLYRANKONE, NULL, NULL) );
4182 
4184  "separating/" SEPA_NAME "/onlyintvars",
4185  "Generate cuts for problems with only integer variables?",
4186  &sepadata->onlyintvars, FALSE, DEFAULT_ONLYINTVARS, NULL, NULL) );
4187 
4189  "separating/" SEPA_NAME "/contconvert",
4190  "Convert some integral variables to be continuous to reduce the size of the sub-MIP?",
4191  &sepadata->contconvert, FALSE, DEFAULT_CONTCONVERT, NULL, NULL) );
4192 
4194  "separating/" SEPA_NAME "/contconvfrac",
4195  "fraction of integral variables converted to be continuous (if contconvert)",
4196  &sepadata->contconvfrac, FALSE, DEFAULT_CONTCONVFRAC, 0.0, 1.0, NULL, NULL) );
4197 
4198  SCIP_CALL( SCIPaddIntParam(scip,
4199  "separating/" SEPA_NAME "/contconvmin",
4200  "minimum number of integral variables before some are converted to be continuous",
4201  &sepadata->contconvmin, FALSE, DEFAULT_CONTCONVMIN, -1, INT_MAX, NULL, NULL) );
4202 
4204  "separating/" SEPA_NAME "/intconvert",
4205  "Convert some integral variables attaining fractional values to have integral value?",
4206  &sepadata->intconvert, FALSE, DEFAULT_INTCONVERT, NULL, NULL) );
4207 
4209  "separating/" SEPA_NAME "/intconvfrac",
4210  "fraction of frac. integral variables converted to have integral value (if intconvert)",
4211  &sepadata->intconvfrac, FALSE, DEFAULT_INTCONVFRAC, 0.0, 1.0, NULL, NULL) );
4212 
4213  SCIP_CALL( SCIPaddIntParam(scip,
4214  "separating/" SEPA_NAME "/intconvmin",
4215  "minimum number of integral variables before some are converted to have integral value",
4216  &sepadata->intconvmin, FALSE, DEFAULT_INTCONVMIN, -1, INT_MAX, NULL, NULL) );
4217 
4219  "separating/" SEPA_NAME "/skipmultbounds",
4220  "Skip the upper bounds on the multipliers in the sub-MIP?",
4221  &sepadata->skipmultbounds, FALSE, DEFAULT_SKIPMULTBOUNDS, NULL, NULL) );
4222 
4224  "separating/" SEPA_NAME "/objlone",
4225  "Should the objective of the sub-MIP minimize the l1-norm of the multipliers?",
4226  &sepadata->objlone, FALSE, DEFAULT_OBJLONE, NULL, NULL) );
4227 
4229  "separating/" SEPA_NAME "/objweight",
4230  "weight used for the row combination coefficient in the sub-MIP objective",
4231  &sepadata->objweight, TRUE, DEFAULT_OBJWEIGHT, 0.0, SCIP_REAL_MAX, NULL, NULL) );
4232 
4234  "separating/" SEPA_NAME "/objweightsize",
4235  "Weight each row by its size?",
4236  &sepadata->objweightsize, FALSE, DEFAULT_OBJWEIGHTSIZE, NULL, NULL) );
4237 
4239  "separating/" SEPA_NAME "/dynamiccuts",
4240  "should generated cuts be removed from the LP if they are no longer tight?",
4241  &sepadata->dynamiccuts, FALSE, DEFAULT_DYNAMICCUTS, NULL, NULL) );
4242 
4244  "separating/" SEPA_NAME "/usecmir",
4245  "use CMIR-generator (otherwise add cut directly)?",
4246  &sepadata->usecmir, FALSE, DEFAULT_USECMIR, NULL, NULL) );
4247 
4249  "separating/" SEPA_NAME "/usestrongcg",
4250  "use strong CG-function to strengthen cut?",
4251  &sepadata->usestrongcg, FALSE, DEFAULT_USESTRONGCG, NULL, NULL) );
4252 
4254  "separating/" SEPA_NAME "/cmirownbounds",
4255  "tell CMIR-generator which bounds to used in rounding?",
4256  &sepadata->cmirownbounds, FALSE, DEFAULT_CMIROWNBOUNDS, NULL, NULL) );
4257 
4259  "separating/" SEPA_NAME "/usecutpool",
4260  "use cutpool to store CG-cuts even if the are not efficient?",
4261  &sepadata->usecutpool, FALSE, DEFAULT_USECUTPOOL, NULL, NULL) );
4262 
4264  "separating/" SEPA_NAME "/primalseparation",
4265  "only separate cuts that are tight for the best feasible solution?",
4266  &sepadata->primalseparation, FALSE, DEFAULT_PRIMALSEPARATION, NULL, NULL) );
4267 
4269  "separating/" SEPA_NAME "/earlyterm",
4270  "terminate separation if a violated (but possibly sub-optimal) cut has been found?",
4271  &sepadata->earlyterm, FALSE, DEFAULT_EARLYTERM, NULL, NULL) );
4272 
4274  "separating/" SEPA_NAME "/addviolationcons",
4275  "add constraint to subscip that only allows violated cuts (otherwise add obj. limit)?",
4276  &sepadata->addviolationcons, FALSE, DEFAULT_ADDVIOLATIONCONS, NULL, NULL) );
4277 
4279  "separating/" SEPA_NAME "/addviolconshdlr",
4280  "add constraint handler to filter out violated cuts?",
4281  &sepadata->addviolconshdlr, FALSE, DEFAULT_ADDVIOLCONSHDLR, NULL, NULL) );
4282 
4284  "separating/" SEPA_NAME "/conshdlrusenorm",
4285  "should the violation constraint handler use the norm of a cut to check for feasibility?",
4286  &sepadata->conshdlrusenorm, FALSE, DEFAULT_CONSHDLRUSENORM, NULL, NULL) );
4287 
4289  "separating/" SEPA_NAME "/useobjub",
4290  "Use upper bound on objective function (via primal solution)?",
4291  &sepadata->useobjub, FALSE, DEFAULT_USEOBJUB, NULL, NULL) );
4292 
4294  "separating/" SEPA_NAME "/useobjlb",
4295  "Use lower bound on objective function (via primal solution)?",
4296  &sepadata->useobjlb, FALSE, DEFAULT_USEOBJLB, NULL, NULL) );
4297 
4299  "separating/" SEPA_NAME "/subscipfast",
4300  "Should the settings for the sub-MIP be optimized for speed?",
4301  &sepadata->subscipfast, FALSE, DEFAULT_SUBSCIPFAST, NULL, NULL) );
4302 
4304  "separating/" SEPA_NAME "/output",
4305  "Should information about the sub-MIP and cuts be displayed?",
4306  &sepadata->output, FALSE, DEFAULT_OUTPUT, NULL, NULL) );
4307 
4308  return SCIP_OKAY;
4309 }
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
Definition: scip_mem.h:116
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
int SCIPgetNIntVars(SCIP *scip)
Definition: scip_prob.c:2134
SCIP_RETCODE SCIPcalcStrongCG(SCIP *scip, SCIP_SOL *sol, SCIP_Bool postprocess, SCIP_Real boundswitch, SCIP_Bool usevbds, SCIP_Bool allowlocal, SCIP_Real minfrac, SCIP_Real maxfrac, SCIP_Real scale, SCIP_AGGRROW *aggrrow, SCIP_Real *cutcoefs, SCIP_Real *cutrhs, int *cutinds, int *cutnnz, SCIP_Real *cutefficacy, int *cutrank, SCIP_Bool *cutislocal, SCIP_Bool *success)
Definition: cuts.c:8216
SCIP_RETCODE SCIPgetCharParam(SCIP *scip, const char *name, char *value)
Definition: scip_param.c:398
void SCIPaggrRowFree(SCIP *scip, SCIP_AGGRROW **aggrrow)
Definition: cuts.c:1581
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:1048
#define NULL
Definition: def.h:246
#define DEFAULT_INTCONVERT
Definition: sepa_cgmip.c:120
SCIP_SEPADATA * sepadata
Definition: struct_sepa.h:58
#define SCIPallocBlockMemoryArray(scip, ptr, num)
Definition: scip_mem.h:99
SCIP_RETCODE SCIPcacheRowExtensions(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:1547
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define DEFAULT_OUTPUT
Definition: sepa_cgmip.c:140
public methods for SCIP parameter handling
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:411
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
int SCIProwGetAge(SCIP_ROW *row)
Definition: lp.c:17038
SCIP_SEPA * SCIProwGetOriginSepa(SCIP_ROW *row)
Definition: lp.c:17123
static SCIP_RETCODE createCGCutCMIR(SCIP *scip, SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata, CGMIP_MIPDATA *mipdata, SCIP_SOL *sol, SCIP_AGGRROW *aggrrow, SCIP_Real *cutcoefs, int *cutinds, SCIP_Real *cutvals, SCIP_Real *varsolvals, SCIP_Real *weights, int *boundsfortrans, SCIP_BOUNDTYPE *boundtypesfortrans, int *nprevrows, SCIP_ROW **prevrows, SCIP_Bool *cutoff, unsigned int *ngen)
Definition: sepa_cgmip.c:3094
#define MAXNSOLS
Definition: sepa_cgmip.c:151
public methods for memory management
SCIP_RETCODE SCIPflushRowExtensions(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:1570
#define DEFAULT_OBJLONE
Definition: sepa_cgmip.c:124
#define MAXWEIGHTRANGE
Definition: sepa_cgmip.c:162
#define DEFAULT_CMIROWNBOUNDS
Definition: sepa_cgmip.c:130
enum CGMIP_ColType CGMIP_COLTYPE
Definition: sepa_cgmip.c:220
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17344
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
Definition: scip_param.c:379
#define SCIP_MAXSTRLEN
Definition: def.h:267
#define BETAEPSILONVALUE
Definition: sepa_cgmip.c:147
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
Definition: scip_prob.c:162
#define STALLNODELIMIT
Definition: sepa_cgmip.c:148
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
Definition: lp.c:16838
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
Definition: scip_lp.c:1607
SCIP_Bool SCIPisSumPositive(SCIP *scip, SCIP_Real val)
static SCIP_DECL_CONSFREE(consFreeViolatedCuts)
Definition: sepa_cgmip.c:483
#define SQR(x)
Definition: def.h:198
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17400
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
public solving methods
public methods for timing
#define USEVBDS
Definition: sepa_cgmip.c:156
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:17018
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1251
SCIP_Bool SCIPisFeasNegative(SCIP *scip, SCIP_Real val)
int SCIProwGetNLPNonz(SCIP_ROW *row)
Definition: lp.c:16894
#define FIXINTEGRALRHS
Definition: sepa_cgmip.c:160
static SCIP_DECL_SEPAINIT(sepaInitCGMIP)
Definition: sepa_cgmip.c:3858
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:1918
#define DEFAULT_INTCONVMIN
Definition: sepa_cgmip.c:122
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip_sol.c:2312
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:16959
#define FALSE
Definition: def.h:72
#define CONSHDLR_NAME
Definition: sepa_cgmip.c:263
methods for the aggregation rows
#define DEFAULT_CUTCOEFBND
Definition: sepa_cgmip.c:110
SCIP_Bool SCIPcolIsIntegral(SCIP_COL *col)
Definition: lp.c:16749
SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:183
SCIP_Real SCIPcolGetUb(SCIP_COL *col)
Definition: lp.c:16660
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip_copy.c:3012
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:243
SCIP_Real SCIPcolGetObj(SCIP_COL *col)
Definition: lp.c:16640
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10253
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
#define TRUE
Definition: def.h:71
const char * SCIPsepaGetName(SCIP_SEPA *sepa)
Definition: sepa.c:689
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPwriteOrigProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames)
Definition: scip_prob.c:652
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:1022
static SCIP_RETCODE solveSubscip(SCIP *scip, SCIP_SEPADATA *sepadata, CGMIP_MIPDATA *mipdata, SCIP_Bool *success)
Definition: sepa_cgmip.c:2149
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:17037
#define NROWSTOOSMALL
Definition: sepa_cgmip.c:143
public methods for problem variables
#define DEFAULT_USEOBJLB
Definition: sepa_cgmip.c:138
#define DEFAULT_CONTCONVMIN
Definition: sepa_cgmip.c:119
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:114
#define CONSHDLR_DESC
Definition: sepa_cgmip.c:264
#define SEPA_PRIORITY
Definition: sepa_cgmip.c:98
static SCIP_RETCODE SCIPincludeConshdlrViolatedCut(SCIP *scip, CGMIP_MIPDATA *mipdata)
Definition: sepa_cgmip.c:576
#define DEFAULT_EARLYTERM
Definition: sepa_cgmip.c:133
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define SCIP_LONGINT_MAX
Definition: def.h:143
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:142
#define DEFAULT_MAXDEPTH
Definition: sepa_cgmip.c:106
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:338
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip_mem.h:97
SCIP_RETCODE SCIPgetLPColsData(SCIP *scip, SCIP_COL ***cols, int *ncols)
Definition: scip_lp.c:495
int SCIPgetNLPBranchCands(SCIP *scip)
Definition: scip_branch.c:417
public methods for SCIP variables
SCIP_RETCODE SCIPsetSepaCopy(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPACOPY((*sepacopy)))
Definition: scip_sepa.c:220
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
Definition: scip_param.c:694
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:203
#define SCIPdebugMsg
Definition: scip_message.h:88
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:155
SCIP_Bool SCIPisSumZero(SCIP *scip, SCIP_Real val)
public methods for separator plugins
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
#define SEPA_USESSUBSCIP
Definition: sepa_cgmip.c:101
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:279
int SCIPgetNContVars(SCIP *scip)
Definition: scip_prob.c:2224
static SCIP_RETCODE solCutIsViolated(SCIP *scip, CGMIP_MIPDATA *mipdata, SCIP_SOL *sol, SCIP_Bool *violated)
Definition: sepa_cgmip.c:290
SCIP_Real SCIPepsilon(SCIP *scip)
SCIP_Real SCIPgetRowMaxCoef(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:1828
SCIP_Real SCIPfeasCeil(SCIP *scip, SCIP_Real val)
#define MAXAGGRLEN(nvars)
Definition: sepa_cgmip.c:164
public methods for numerical tolerances
SCIP_SEPADATA * SCIPsepaGetData(SCIP_SEPA *sepa)
Definition: sepa.c:600
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
public methods for querying solving statistics
#define DEFAULT_TIMELIMIT
Definition: sepa_cgmip.c:108
const char * SCIPgetProbName(SCIP *scip)
Definition: scip_prob.c:1123
public methods for the branch-and-bound tree
#define DEFAULT_USEOBJUB
Definition: sepa_cgmip.c:137
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17354
SCIP_Bool SCIPisCutEfficacious(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
Definition: scip_cut.c:161
public methods for managing constraints
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
Definition: scip_prob.c:1298
SCIP_Real SCIPcolGetPrimsol(SCIP_COL *col)
Definition: lp.c:16683
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2577
#define DEFAULT_ADDVIOLATIONCONS
Definition: sepa_cgmip.c:134
#define DEFAULT_DECISIONTREE
Definition: sepa_cgmip.c:107
#define DEFAULT_ONLYINTVARS
Definition: sepa_cgmip.c:116
SCIP_Real SCIPgetRowMinCoef(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:1810
#define DEFAULT_MAXROUNDSROOT
Definition: sepa_cgmip.c:105
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip_param.c:291
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2822
#define MAKECONTINTEGRAL
Definition: sepa_cgmip.c:161
#define NCOLSTOOSMALL
Definition: sepa_cgmip.c:144
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
Definition: lp.c:16828
#define DEFAULT_MINNODELIMIT
Definition: sepa_cgmip.c:111
SCIP_RETCODE SCIPsetSepaExit(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAEXIT((*sepaexit)))
Definition: scip_sepa.c:268
#define DEFAULT_ONLYACTIVEROWS
Definition: sepa_cgmip.c:113
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:17068
struct CGMIP_MIPData CGMIP_MIPDATA
Definition: sepa_cgmip.c:255
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip_mem.h:143
int SCIPsepaGetNCallsAtNode(SCIP_SEPA *sepa)
Definition: sepa.c:816
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip_param.c:520
SCIP_STATUS SCIPgetStatus(SCIP *scip)
Definition: scip_general.c:518
#define BOUNDSWITCH
Definition: sepa_cgmip.c:155
SCIP_Bool SCIPisEfficacious(SCIP *scip, SCIP_Real efficacy)
Definition: scip_cut.c:179
static SCIP_DECL_CONSCHECK(consCheckViolatedCuts)
Definition: sepa_cgmip.c:541
static SCIP_DECL_CONSLOCK(consLockViolatedCuts)
Definition: sepa_cgmip.c:567
SCIP_Real SCIPcolGetLb(SCIP_COL *col)
Definition: lp.c:16650
#define DEFAULT_OBJWEIGHTSIZE
Definition: sepa_cgmip.c:126
SCIP_RETCODE SCIPsetConshdlrFree(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSFREE((*consfree)))
Definition: scip_cons.c:434
SCIP_Bool SCIProwIsIntegral(SCIP_ROW *row)
Definition: lp.c:17058
static SCIP_RETCODE subscipSetParams(SCIP_SEPADATA *sepadata, CGMIP_MIPDATA *mipdata, SCIP_Bool *success)
Definition: sepa_cgmip.c:2016
void SCIPsepaSetData(SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata)
Definition: sepa.c:610
SCIP_CONSHDLRDATA * SCIPconshdlrGetData(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4211
#define DEFAULT_MAXROWAGE
Definition: sepa_cgmip.c:114
static SCIP_DECL_SEPAEXECLP(sepaExeclpCGMIP)
Definition: sepa_cgmip.c:3924
#define DEFAULT_CONSHDLRUSENORM
Definition: sepa_cgmip.c:136
#define REALABS(x)
Definition: def.h:181
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:17718
#define MINEFFICACY
Definition: sepa_cgmip.c:150
int SCIPgetNLPRows(SCIP *scip)
Definition: scip_lp.c:629
public methods for problem copies
#define DEFAULT_ONLYRANKONE
Definition: sepa_cgmip.c:115
#define SCIP_CALL(x)
Definition: def.h:358
SCIP_Real SCIPgetLowerbound(SCIP *scip)
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPsetEmphasis(SCIP *scip, SCIP_PARAMEMPHASIS paramemphasis, SCIP_Bool quiet)
Definition: scip_param.c:951
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:16969
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip_message.c:296
#define DEFAULT_SUBSCIPFAST
Definition: sepa_cgmip.c:139
SCIP_Real SCIPgetRowLPActivity(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:1899
SCIP_RETCODE SCIPaddRow(SCIP *scip, SCIP_ROW *row, SCIP_Bool forcecut, SCIP_Bool *infeasible)
Definition: scip_cut.c:294
#define DEFAULT_PRIMALSEPARATION
Definition: sepa_cgmip.c:132
static SCIP_Real computeObjWeightSize(int rowsize, int minrowsize, int maxrowsize)
Definition: sepa_cgmip.c:863
SCIP_Bool SCIProwIsModifiable(SCIP_ROW *row)
Definition: lp.c:17078
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
Definition: lp.c:16905
#define DEFAULT_SKIPMULTBOUNDS
Definition: sepa_cgmip.c:123
public methods for constraint handler plugins and constraints
SCIP_RETCODE SCIPincludeSepaBasic(SCIP *scip, SCIP_SEPA **sepa, const char *name, const char *desc, int priority, int freq, SCIP_Real maxbounddist, SCIP_Bool usessubscip, SCIP_Bool delay, SCIP_DECL_SEPAEXECLP((*sepaexeclp)), SCIP_DECL_SEPAEXECSOL((*sepaexecsol)), SCIP_SEPADATA *sepadata)
Definition: scip_sepa.c:178
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed, SCIP_Bool useglobalseed)
SCIP_RETCODE SCIPincludeSepaCGMIP(SCIP *scip)
Definition: sepa_cgmip.c:4101
#define DEFAULT_RANDSEED
Definition: sepa_cgmip.c:141
SCIP_RETCODE SCIPcalcMIR(SCIP *scip, SCIP_SOL *sol, SCIP_Bool postprocess, SCIP_Real boundswitch, SCIP_Bool usevbds, SCIP_Bool allowlocal, SCIP_Bool fixintegralrhs, int *boundsfortrans, SCIP_BOUNDTYPE *boundtypesfortrans, SCIP_Real minfrac, SCIP_Real maxfrac, SCIP_Real scale, SCIP_AGGRROW *aggrrow, SCIP_Real *cutcoefs, SCIP_Real *cutrhs, int *cutinds, int *cutnnz, SCIP_Real *cutefficacy, int *cutrank, SCIP_Bool *cutislocal, SCIP_Bool *success)
Definition: cuts.c:3904
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:130
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
Definition: lp.c:16915
#define DEFAULT_USECUTPOOL
Definition: sepa_cgmip.c:131
public data structures and miscellaneous methods
static SCIP_RETCODE createCGCutStrongCG(SCIP *scip, SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata, CGMIP_MIPDATA *mipdata, SCIP_SOL *sol, SCIP_AGGRROW *aggrrow, SCIP_Real *cutcoefs, int *cutinds, SCIP_Real *cutvals, SCIP_Real *varsolvals, SCIP_Real *weights, int *nprevrows, SCIP_ROW **prevrows, SCIP_Bool *cutoff, unsigned int *ngen)
Definition: sepa_cgmip.c:3384
#define SCIP_Bool
Definition: def.h:69
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip_lp.c:226
int SCIPgetNImplVars(SCIP *scip)
Definition: scip_prob.c:2179
static SCIP_DECL_SEPAEXIT(sepaExitCGMIP)
Definition: sepa_cgmip.c:3873
#define MAXFRAC
Definition: sepa_cgmip.c:159
enum SCIP_Status SCIP_STATUS
Definition: type_stat.h:58
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip_prob.c:1478
int SCIPgetDepth(SCIP *scip)
Definition: scip_tree.c:715
SCIP_RETCODE SCIPaddPoolCut(SCIP *scip, SCIP_ROW *row)
Definition: scip_cut.c:405
#define MIN(x, y)
Definition: def.h:216
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:578
public methods for LP management
SCIP_RETCODE SCIPcreateEmptyRowSepa(SCIP *scip, SCIP_ROW **row, SCIP_SEPA *sepa, const char *name, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool removable)
Definition: scip_lp.c:1365
SCIP_Real SCIPgetCutEfficacy(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
Definition: scip_cut.c:138
public methods for cuts and aggregation rows
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17192
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
Definition: scip_var.c:104
#define MINFRAC
Definition: sepa_cgmip.c:158
int SCIPgetNSols(SCIP *scip)
Definition: scip_sol.c:2263
static SCIP_DECL_SEPACOPY(sepaCopyCGMIP)
Definition: sepa_cgmip.c:3887
#define DEFAULT_OBJWEIGHT
Definition: sepa_cgmip.c:125
#define DEFAULT_DYNAMICCUTS
Definition: sepa_cgmip.c:127
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:17058
Constraint handler for linear constraints in their most general form, .
int SCIPgetNObjVars(SCIP *scip)
Definition: scip_prob.c:2272
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
static SCIP_DECL_SEPAFREE(sepaFreeCGMIP)
Definition: sepa_cgmip.c:3902
int SCIPgetNBinVars(SCIP *scip)
Definition: scip_prob.c:2089
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
Definition: misc.c:9630
public methods for the LP relaxation, rows and columns
int SCIProwGetRank(SCIP_ROW *row)
Definition: lp.c:17048
#define DEFAULT_USESTRONGCG
Definition: sepa_cgmip.c:129
#define SCIP_REAL_MAX
Definition: def.h:158
SCIP_Real SCIProwGetParallelism(SCIP_ROW *row1, SCIP_ROW *row2, char orthofunc)
Definition: lp.c:7631
SCIP_Real * r
Definition: circlepacking.c:50
#define CONSHDLRFULLNORM
Definition: sepa_cgmip.c:149
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)
#define SCIP_LONGINT_FORMAT
Definition: def.h:149
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
Definition: lp.c:16925
#define SQRT(x)
Definition: def.h:199
public methods for branching rule plugins and branching
SCIP_RETCODE SCIPreleaseRow(SCIP *scip, SCIP_ROW **row)
Definition: scip_lp.c:1474
SCIP_Bool SCIPisObjIntegral(SCIP *scip)
Definition: scip_prob.c:1618
static SCIP_RETCODE freeSubscip(SCIP *scip, SCIP_SEPA *sepa, CGMIP_MIPDATA *mipdata)
Definition: sepa_cgmip.c:3769
static SCIP_RETCODE storeCutInArrays(SCIP *scip, int nvars, SCIP_Real *cutcoefs, SCIP_Real *varsolvals, char normtype, int *cutinds, SCIP_Real *cutvals, int *cutlen, SCIP_Real *cutact, SCIP_Real *cutnorm)
Definition: sepa_cgmip.c:612
general public methods
#define DEFAULT_USECMIR
Definition: sepa_cgmip.c:128
#define MAX(x, y)
Definition: def.h:215
SCIP_RETCODE SCIPsetSepaFree(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAFREE((*sepafree)))
Definition: scip_sepa.c:236
SCIP_RETCODE SCIPsetSepaInit(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAINIT((*sepainit)))
Definition: scip_sepa.c:252
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip_sol.c:2362
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPaggrRowSumRows(SCIP *scip, SCIP_AGGRROW *aggrrow, SCIP_Real *weights, int *rowinds, int nrowinds, SCIP_Bool sidetypebasis, SCIP_Bool allowlocal, int negslack, int maxaggrlen, SCIP_Bool *valid)
Definition: cuts.c:2093
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:16729
public methods for solutions
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_prob.c:1724
public methods for random numbers
void SCIProwChgRank(SCIP_ROW *row, int rank)
Definition: lp.c:17181
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1187
#define DEFAULT_MAXROUNDS
Definition: sepa_cgmip.c:104
public methods for message output
#define DEFAULT_CONTCONVERT
Definition: sepa_cgmip.c:117
#define DEFAULT_INTCONVFRAC
Definition: sepa_cgmip.c:121
SCIP_VAR * a
Definition: circlepacking.c:57
SCIP_Bool SCIPisFeasPositive(SCIP *scip, SCIP_Real val)
Chvatal-Gomory cuts computed via a sub-MIP.
#define DEFAULT_ADDVIOLCONSHDLR
Definition: sepa_cgmip.c:135
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16849
int SCIProwGetLPPos(SCIP_ROW *row)
Definition: lp.c:17148
#define SCIP_Real
Definition: def.h:157
enum SCIP_Stage SCIP_STAGE
Definition: type_set.h:50
static SCIP_DECL_CONSENFOLP(consEnfolpViolatedCuts)
Definition: sepa_cgmip.c:500
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip_general.c:738
#define SEPA_DESC
Definition: sepa_cgmip.c:97
public methods for message handling
SCIP_RETCODE SCIPaggrRowCreate(SCIP *scip, SCIP_AGGRROW **aggrrow)
Definition: cuts.c:1549
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
Definition: scip_lp.c:2099
#define SCIP_Longint
Definition: def.h:142
#define POSTPROCESS
Definition: sepa_cgmip.c:157
#define SEPA_DELAY
Definition: sepa_cgmip.c:102
SCIP_Real SCIPfrac(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip_copy.c:2976
#define SEPA_FREQ
Definition: sepa_cgmip.c:99
static SCIP_RETCODE createSubscip(SCIP *scip, SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata, CGMIP_MIPDATA *mipdata)
Definition: sepa_cgmip.c:1021
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
struct SCIP_ConshdlrData SCIP_CONSHDLRDATA
Definition: type_cons.h:50
SCIP_Real SCIPgetVarSol(SCIP *scip, SCIP_VAR *var)
Definition: scip_var.c:2309
#define OBJWEIGHTRANGE
Definition: sepa_cgmip.c:152
int SCIPgetNLPCols(SCIP *scip)
Definition: scip_lp.c:551
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17410
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE createCGCutDirect(SCIP *scip, SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata, CGMIP_MIPDATA *mipdata, SCIP_SOL *sol, SCIP_Real *cutcoefs, int *cutinds, SCIP_Real *cutvals, SCIP_Real *varsolvals, SCIP_Real *weights, int *nprevrows, SCIP_ROW **prevrows, SCIP_Bool *cutoff, unsigned int *ngen)
Definition: sepa_cgmip.c:2878
static SCIP_RETCODE transformColumn(SCIP *scip, SCIP_SEPADATA *sepadata, CGMIP_MIPDATA *mipdata, SCIP_COL *col, SCIP_Real offset, SCIP_Real sigma, SCIP_Real *lhs, SCIP_Real *rhs, SCIP_Real *lb, SCIP_Real *ub, SCIP_Real *primsol)
Definition: sepa_cgmip.c:752
SCIP_Real SCIPsumepsilon(SCIP *scip)
SCIP_Real SCIPgetUpperbound(SCIP *scip)
#define DEFAULT_MEMORYLIMIT
Definition: sepa_cgmip.c:109
static SCIP_RETCODE createCGCuts(SCIP *scip, SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata, CGMIP_MIPDATA *mipdata, SCIP_Bool *cutoff, unsigned int *ngen)
Definition: sepa_cgmip.c:3615
#define DEFAULT_MAXNODELIMIT
Definition: sepa_cgmip.c:112
public methods for separators
#define BMSclearMemoryArray(ptr, num)
Definition: memory.h:119
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
Definition: scip_lp.c:573
SCIP_Longint SCIPgetNLPs(SCIP *scip)
public methods for global and local (sub)problems
int SCIPcolGetNLPNonz(SCIP_COL *col)
Definition: lp.c:16817
int SCIPcolGetLPPos(SCIP_COL *col)
Definition: lp.c:16770
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:16921
static SCIP_DECL_CONSENFOPS(consEnfopsViolatedCuts)
Definition: sepa_cgmip.c:527
SCIP_RETCODE SCIPmakeRowIntegral(SCIP *scip, SCIP_ROW *row, SCIP_Real mindelta, SCIP_Real maxdelta, SCIP_Longint maxdnom, SCIP_Real maxscale, SCIP_Bool usecontvars, SCIP_Bool *success)
Definition: scip_lp.c:1750
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip_sol.c:1410
default SCIP plugins
#define SEPA_NAME
Definition: sepa_cgmip.c:96
SCIP_Real SCIProwGetNorm(SCIP_ROW *row)
Definition: lp.c:16935
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:211
#define EPSILONVALUE
Definition: sepa_cgmip.c:146
SCIP_Real SCIPgetFirstLPTime(SCIP *scip)
Definition: scip_timing.c:526
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip_param.c:973
#define ABS(x)
Definition: def.h:211
#define DEFAULT_CONTCONVFRAC
Definition: sepa_cgmip.c:118
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip_param.c:636
struct SCIP_SepaData SCIP_SEPADATA
Definition: type_sepa.h:38
#define SEPA_MAXBOUNDDIST
Definition: sepa_cgmip.c:100
static SCIP_RETCODE computeCut(SCIP *scip, SCIP_SEPA *sepa, CGMIP_MIPDATA *mipdata, SCIP_SEPADATA *sepadata, SCIP_SOL *sol, SCIP_Real *cutcoefs, SCIP_Real *cutrhs, SCIP_Bool *localrowsused, SCIP_Bool *localboundsused, int *cutrank, SCIP_Bool *success)
Definition: sepa_cgmip.c:2386
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:129
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:370
CGMIP_ColType
Definition: sepa_cgmip.c:212
memory allocation routines
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:1824