Scippy

SCIP

Solving Constraint Integer Programs

presol_redvub.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-2016 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 email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file presol_redvub.c
17  * @brief remove redundant variable upper bound constraints
18  * @author Dieter Weninger
19  *
20  * This presolver looks for dominating variable bound constraints
21  * on the same continuous variable and discards them. For example let x be a
22  * continuous variable and y, y' are binary variables. In addition, let two variable
23  * upper bound constraints ax - by <= e and cx - dy' <= f are given. If
24  * ax - by <= e implies cx - dy' <= f, then we can remove the second constraint
25  * and substitute/aggregate y' := y. The same can be done with variable lower
26  * bound constraints.
27  *
28  */
29 
30 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
31 
32 #include <stdio.h>
33 #include <assert.h>
34 #include <string.h>
35 
36 
37 #include "scip/pub_matrix.h"
38 #include "presol_redvub.h"
39 
40 #define PRESOL_NAME "redvub"
41 #define PRESOL_DESC "detect redundant variable bound constraints"
42 #define PRESOL_PRIORITY -9000000 /**< priority of the presolver (>= 0: before, < 0: after constraint handlers) */
43 #define PRESOL_MAXROUNDS 0 /**< maximal number of presolving rounds the presolver participates in (-1: no limit) */
44 #define PRESOL_TIMING SCIP_PRESOLTIMING_EXHAUSTIVE /* timing of the presolver (fast, medium, or exhaustive) */
45 
46 #define MAXPAIRCOMP 1000 /**< maximal number of pairwise comparisons */
47 
48 /*
49  * Local methods
50  */
51 
52 /** verify if the constraint is a variable upper bound constraint */
53 static
55  SCIP* scip, /**< SCIP main data structure */
56  SCIP_MATRIX* matrix, /**< matrix instance */
57  int row, /**< row index */
58  SCIP_Real* lowthreshold, /**< low switching threshold */
59  SCIP_Real* highthreshold, /**< high switching threshold */
60  int* conidx, /**< variable index of continuous variable */
61  int* binidx /**< variable index of binary variable */
62  )
63 {
64  SCIP_Real* valpnt;
65  int* rowpnt;
66  SCIP_Bool isvub;
67 
68  assert(scip != NULL);
69  assert(matrix != NULL);
70  assert(0 <= row && row < SCIPmatrixGetNRows(matrix));
71  assert(lowthreshold != NULL);
72  assert(highthreshold != NULL);
73  assert(conidx != NULL);
74  assert(binidx != NULL);
75 
76  isvub = FALSE;
77 
78  if( SCIPmatrixGetRowNNonzs(matrix, row) == 2 && SCIPmatrixIsRowRhsInfinity(matrix, row) )
79  {
80  SCIP_VARTYPE type1;
81  SCIP_VARTYPE type2;
82  int idx1;
83  int idx2;
84  SCIP_VAR* var1;
85  SCIP_VAR* var2;
86  SCIP_Real val1;
87  SCIP_Real val2;
88 
89  rowpnt = SCIPmatrixGetRowIdxPtr(matrix, row);
90  valpnt = SCIPmatrixGetRowValPtr(matrix, row);
91 
92  idx1 = *rowpnt;
93  val1 = *valpnt;
94  var1 = SCIPmatrixGetVar(matrix, idx1);
95  type1 = SCIPvarGetType(var1);
96 
97  rowpnt++;
98  valpnt++;
99 
100  idx2 = *rowpnt;
101  val2 = *valpnt;
102  var2 = SCIPmatrixGetVar(matrix, idx2);
103  type2 = SCIPvarGetType(var2);
104 
105  /* we claim that the vub has the structure ax + cy >= b
106  * with a<0, c>0, x continuous, x>=0, y binary and obj(y)>=0
107  */
108  if( (type1 == SCIP_VARTYPE_CONTINUOUS && type2 == SCIP_VARTYPE_BINARY)
109  && val1 < 0.0 && val2 > 0.0 && SCIPisGE(scip, SCIPvarGetLbGlobal(var1), 0.0)
110  && SCIPisGE(scip, SCIPvarGetObj(var2), 0.0) )
111  {
112  *lowthreshold = SCIPmatrixGetRowLhs(matrix, row) / val1;
113  *highthreshold = (SCIPmatrixGetRowLhs(matrix, row) - val2) / val1;
114  *conidx = idx1;
115  *binidx = idx2;
116  isvub = TRUE;
117  }
118  else if( (type1 == SCIP_VARTYPE_BINARY && type2 == SCIP_VARTYPE_CONTINUOUS)
119  && val1 > 0.0 && val2 < 0.0 && SCIPisGE(scip, SCIPvarGetLbGlobal(var2), 0.0)
120  && SCIPisGE(scip, SCIPvarGetObj(var1), 0.0) )
121  {
122  *lowthreshold = SCIPmatrixGetRowLhs(matrix, row) / val2;
123  *highthreshold = (SCIPmatrixGetRowLhs(matrix, row) - val1) / val2;
124  *conidx = idx2;
125  *binidx = idx1;
126  isvub = TRUE;
127  }
128  }
129 
130  return isvub;
131 }
132 
133 /** verify if the constraint is a variable lower bound constraint */
134 static
136  SCIP* scip, /**< SCIP main data structure */
137  SCIP_MATRIX* matrix, /**< matrix instance */
138  int row, /**< row index */
139  SCIP_Real* lowthreshold, /**< low switching threshold */
140  SCIP_Real* highthreshold, /**< high switching threshold */
141  int* conidx, /**< variable index of continuous variable */
142  int* binidx /**< variable index of binary variable */
143  )
144 {
145  SCIP_Real* valpnt;
146  int* rowpnt;
147  SCIP_Bool isvlb;
148 
149  assert(scip != NULL);
150  assert(matrix != NULL);
151  assert(0 <= row && row < SCIPmatrixGetNRows(matrix));
152  assert(lowthreshold != NULL);
153  assert(highthreshold != NULL);
154  assert(conidx != NULL);
155  assert(binidx != NULL);
156 
157  isvlb = FALSE;
158 
159  if( SCIPmatrixGetRowNNonzs(matrix, row) == 2 && SCIPmatrixIsRowRhsInfinity(matrix, row) )
160  {
161  SCIP_VARTYPE type1;
162  SCIP_VARTYPE type2;
163  int idx1;
164  int idx2;
165  SCIP_VAR* var1;
166  SCIP_VAR* var2;
167  SCIP_Real val1;
168  SCIP_Real val2;
169 
170  rowpnt = SCIPmatrixGetRowIdxPtr(matrix, row);
171  valpnt = SCIPmatrixGetRowValPtr(matrix, row);
172 
173  idx1 = *rowpnt;
174  val1 = *valpnt;
175  var1 = SCIPmatrixGetVar(matrix, idx1);
176  type1 = SCIPvarGetType(var1);
177 
178  rowpnt++;
179  valpnt++;
180 
181  idx2 = *rowpnt;
182  val2 = *valpnt;
183  var2 = SCIPmatrixGetVar(matrix, idx2);
184  type2 = SCIPvarGetType(var2);
185 
186  /* we claim that the vlb has the structure ax + cy >= b
187  * with a>0, c<0, x continuous, x>=0, y binary and obj(y)>=0
188  */
189  if( (type1 == SCIP_VARTYPE_CONTINUOUS && type2 == SCIP_VARTYPE_BINARY)
190  && val1 > 0.0 && val2 < 0.0 && SCIPisGE(scip, SCIPvarGetLbGlobal(var1), 0.0)
191  && SCIPisGE(scip, SCIPvarGetObj(var2), 0.0) )
192  {
193  *lowthreshold = SCIPmatrixGetRowLhs(matrix, row) / val1;
194  *highthreshold = (SCIPmatrixGetRowLhs(matrix, row) - val2) / val1;
195  *conidx = idx1;
196  *binidx = idx2;
197  isvlb = TRUE;
198  }
199  else if( (type1 == SCIP_VARTYPE_BINARY && type2 == SCIP_VARTYPE_CONTINUOUS)
200  && val1 < 0.0 && val2 > 0.0 && SCIPisGE(scip, SCIPvarGetLbGlobal(var2), 0.0)
201  && SCIPisGE(scip, SCIPvarGetObj(var1), 0.0) )
202  {
203  *lowthreshold = SCIPmatrixGetRowLhs(matrix, row) / val2;
204  *highthreshold = (SCIPmatrixGetRowLhs(matrix, row) - val1) / val2;
205  *conidx = idx2;
206  *binidx = idx1;
207  isvlb = TRUE;
208  }
209  }
210 
211  return isvlb;
212 }
213 
214 
215 /** searches for variable upper bound constraints on the same continuous variable with a dominance relation */
216 static
218  SCIP* scip, /**< SCIP main data structure */
219  SCIP_MATRIX* matrix, /**< matrix containing the constraints */
220  int nvubs, /**< number of vubs */
221  int* vubs, /**< row indices of the vubs */
222  SCIP_Real* lowthresholds, /**< low switching thresholds */
223  SCIP_Real* highthresholds, /**< high switching thresholds */
224  int* conidxs, /**< variable indexes of continuous variable */
225  int* binidxs, /**< variable indexes of binary variable */
226  int* nvaragg, /**< number of variables for aggregation */
227  SCIP_Bool* isvartoagg, /**< flags indicating if variable could be aggregated */
228  SCIP_VAR** aggvars, /**< pointers to the variables by which the aggregation should be done */
229  int* ndeletecons, /**< number of deleteable constraints */
230  SCIP_Bool* deletecons /**< flags which constraints could be deleted */
231  )
232 {
233  int i;
234  int j;
235  SCIP_Bool uselinearscan;
236 
237  assert(scip != NULL);
238  assert(matrix != NULL);
239  assert(vubs != NULL);
240  assert(nvubs >= 2);
241  assert(lowthresholds != NULL);
242  assert(highthresholds != NULL);
243  assert(conidxs != NULL);
244  assert(binidxs != NULL);
245  assert(nvaragg != NULL);
246  assert(isvartoagg != NULL);
247  assert(aggvars != NULL);
248  assert(ndeletecons != NULL);
249  assert(deletecons != NULL);
250 
251  /* only use pairwise comparison for small number of vub constraints */
252  if( nvubs >= MAXPAIRCOMP )
253  uselinearscan = TRUE;
254  else
255  uselinearscan = FALSE;
256 
257  for( i = 0; i < nvubs; i++ )
258  {
259  for( j = i+1; j < nvubs; j++ )
260  {
261  if( !SCIPisEQ(scip, lowthresholds[i], lowthresholds[j]) )
262  continue;
263 
264  if( SCIPmatrixGetColNDownlocks(matrix, binidxs[j]) != 1 ||
265  SCIPmatrixGetColNDownlocks(matrix, binidxs[i]) != 1 )
266  continue;
267 
268  if( SCIPisLE(scip, highthresholds[i], highthresholds[j]) )
269  {
270 #ifdef SCIP_DEBUG
271  SCIPdebugMessage("Aggregate variable %s by %s\n",
272  SCIPvarGetName(SCIPmatrixGetVar(matrix, binidxs[j])),
273  SCIPvarGetName(SCIPmatrixGetVar(matrix, binidxs[i])));
274  SCIPdebugMessage("Delete variable upper bound constraint:\n");
275  SCIP_CALL( SCIPprintCons(scip, SCIPmatrixGetCons(matrix, vubs[j]), NULL));
276  SCIPinfoMessage(scip, NULL, "\n");
277 #endif
278 
279  isvartoagg[binidxs[j]] = TRUE;
280  aggvars[binidxs[j]] = SCIPmatrixGetVar(matrix, binidxs[i]);
281  (*nvaragg)++;
282 
283  deletecons[vubs[j]] = TRUE;
284  (*ndeletecons)++;
285  }
286  else
287  {
288  assert(SCIPisGT(scip, highthresholds[i], highthresholds[j]));
289 #ifdef SCIP_DEBUG
290  SCIPdebugMessage("Aggregate variable %s by %s\n",
291  SCIPvarGetName(SCIPmatrixGetVar(matrix, binidxs[i])),
292  SCIPvarGetName(SCIPmatrixGetVar(matrix, binidxs[j])));
293  SCIPdebugMessage("Delete variable upper bound constraint:\n");
294  SCIP_CALL( SCIPprintCons(scip, SCIPmatrixGetCons(matrix, vubs[i]), NULL));
295  SCIPinfoMessage(scip, NULL, "\n");
296 #endif
297 
298  isvartoagg[binidxs[i]] = TRUE;
299  aggvars[binidxs[i]] = SCIPmatrixGetVar(matrix, binidxs[j]);
300  (*nvaragg)++;
301 
302  deletecons[vubs[i]] = TRUE;
303  (*ndeletecons)++;
304  }
305 
306  if( uselinearscan )
307  break;
308  }
309  }
310 
311  return SCIP_OKAY;
312 }
313 
314 /** searches for variable lower bound constraints on the same continuous variable with a dominance relation */
315 static
317  SCIP* scip, /**< SCIP main data structure */
318  SCIP_MATRIX* matrix, /**< matrix containing the constraints */
319  int nvlbs, /**< number of vlbs */
320  int* vlbs, /**< row indices of the vlbs */
321  SCIP_Real* lowthresholds, /**< low switching thresholds */
322  SCIP_Real* highthresholds, /**< high switching thresholds */
323  int* conidxs, /**< variable indexes of continuous variable */
324  int* binidxs, /**< variable indexes of binary variable */
325  int* nvaragg, /**< number of variables for aggregation */
326  SCIP_Bool* isvartoagg, /**< flags indicating if variable could be aggregated */
327  SCIP_VAR** aggvars, /**< pointers to the variables by which the aggregation should be done */
328  int* ndeletecons, /**< number of deleteable constraints */
329  SCIP_Bool* deletecons /**< flags which constraints could be deleted */
330 
331  )
332 {
333  int i;
334  int j;
335  SCIP_Bool uselinearscan;
336 
337  assert(scip != NULL);
338  assert(matrix != NULL);
339  assert(vlbs != NULL);
340  assert(nvlbs >= 2);
341  assert(lowthresholds != NULL);
342  assert(highthresholds != NULL);
343  assert(conidxs != NULL);
344  assert(binidxs != NULL);
345  assert(nvaragg != NULL);
346  assert(isvartoagg != NULL);
347  assert(aggvars != NULL);
348  assert(ndeletecons != NULL);
349  assert(deletecons != NULL);
350 
351  if( nvlbs >= MAXPAIRCOMP )
352  uselinearscan = TRUE;
353  else
354  uselinearscan = FALSE;
355 
356  for( i = 0; i < nvlbs; i++ )
357  {
358  for( j = i+1; j < nvlbs; j++ )
359  {
360  if( !SCIPisEQ(scip, lowthresholds[i], lowthresholds[j]) )
361  continue;
362 
363  if( SCIPmatrixGetColNUplocks(matrix, binidxs[j]) != 1 ||
364  SCIPmatrixGetColNUplocks(matrix, binidxs[i]) != 1 )
365  continue;
366 
367  if( SCIPisGE(scip, highthresholds[i], highthresholds[j]) )
368  {
369 #ifdef SCIP_DEBUG
370  SCIPdebugMessage("Aggregate variable %s by %s\n",
371  SCIPvarGetName(SCIPmatrixGetVar(matrix, binidxs[j])),
372  SCIPvarGetName(SCIPmatrixGetVar(matrix, binidxs[i])));
373  SCIPdebugMessage("Delete variable lower bound constraint:\n");
374  SCIP_CALL( SCIPprintCons(scip, SCIPmatrixGetCons(matrix, vlbs[j]), NULL));
375  SCIPinfoMessage(scip, NULL, "\n");
376 #endif
377 
378  isvartoagg[binidxs[j]] = TRUE;
379  aggvars[binidxs[j]] = SCIPmatrixGetVar(matrix, binidxs[i]);
380  (*nvaragg)++;
381 
382  deletecons[vlbs[j]] = TRUE;
383  (*ndeletecons)++;
384  }
385  else
386  {
387  assert(SCIPisLT(scip, highthresholds[i], highthresholds[j]));
388 #ifdef SCIP_DEBUG
389  SCIPdebugMessage("Aggregate variable %s by %s\n",
390  SCIPvarGetName(SCIPmatrixGetVar(matrix, binidxs[i])),
391  SCIPvarGetName(SCIPmatrixGetVar(matrix, binidxs[j])));
392  SCIPdebugMessage("Delete variable lower bound constraint:\n");
393  SCIP_CALL( SCIPprintCons(scip, SCIPmatrixGetCons(matrix, vlbs[i]), NULL));
394  SCIPinfoMessage(scip, NULL, "\n");
395 #endif
396 
397  isvartoagg[binidxs[i]] = TRUE;
398  aggvars[binidxs[i]] = SCIPmatrixGetVar(matrix, binidxs[j]);
399  (*nvaragg)++;
400 
401  deletecons[vlbs[i]] = TRUE;
402  (*ndeletecons)++;
403  }
404 
405  if( uselinearscan )
406  break;
407  }
408  }
409 
410  return SCIP_OKAY;
411 }
412 
413 /** find variable aggregations and redundant variable bound constraints */
414 static
416  SCIP* scip, /**< SCIP main data structure */
417  SCIP_MATRIX* matrix, /**< constraint matrix */
418  int* nvaragg, /**< number of redundant variables */
419  SCIP_Bool* isvartoagg, /**< flags indicating which variables could be substituted/aggregated */
420  SCIP_VAR** aggvars, /**< pointers to the variables by which the aggregation should be done */
421  int* ndeletecons, /**< number of redundant constraints */
422  SCIP_Bool* deletecons /**< flags indicating which constraints could be deleted */
423  )
424 {
425  int c;
426  int* colpnt;
427  int* colend;
428  int* vbcons;
429  int nvbcons;
430  int ncols;
431  int nrows;
432  SCIP_Real* lowthresholds;
433  SCIP_Real* highthresholds;
434  int* conidxs;
435  int* binidxs;
436 
437  ncols = SCIPmatrixGetNColumns(matrix);
438  nrows = SCIPmatrixGetNRows(matrix);
439 
440  SCIP_CALL( SCIPallocBufferArray(scip, &binidxs, nrows) );
441  SCIP_CALL( SCIPallocBufferArray(scip, &conidxs, nrows) );
442  SCIP_CALL( SCIPallocBufferArray(scip, &lowthresholds, nrows) );
443  SCIP_CALL( SCIPallocBufferArray(scip, &highthresholds, nrows) );
444  SCIP_CALL( SCIPallocBufferArray(scip, &vbcons, nrows) );
445 
446  for( c = 0; c < ncols; c++ )
447  {
448  SCIP_VAR* var;
449 
450  var = SCIPmatrixGetVar(matrix, c);
451 
453  continue;
454 
455  /* search vubs per variable */
456  nvbcons = 0;
457  colpnt = SCIPmatrixGetColIdxPtr(matrix, c);
458  colend = colpnt + SCIPmatrixGetColNNonzs(matrix, c);
459  for( ; (colpnt < colend); colpnt++ )
460  {
461  SCIP_Real lowthreshold;
462  SCIP_Real highthreshold;
463  int conidx;
464  int binidx;
465 
466  if( isVub(scip, matrix, *colpnt, &lowthreshold, &highthreshold, &conidx, &binidx) )
467  {
468  vbcons[nvbcons] = *colpnt;
469  lowthresholds[nvbcons] = lowthreshold;
470  highthresholds[nvbcons] = highthreshold;
471  conidxs[nvbcons] = conidx;
472  binidxs[nvbcons] = binidx;
473  nvbcons++;
474  }
475  }
476  if( nvbcons >= 2 )
477  {
478  SCIP_CALL( detectDominatingVubs(scip, matrix, nvbcons, vbcons,
479  lowthresholds, highthresholds, conidxs, binidxs,
480  nvaragg, isvartoagg, aggvars, ndeletecons, deletecons) );
481  }
482 
483  /* search vlbs per variable */
484  nvbcons = 0;
485  colpnt = SCIPmatrixGetColIdxPtr(matrix, c);
486  colend = colpnt + SCIPmatrixGetColNNonzs(matrix, c);
487  for( ; (colpnt < colend); colpnt++ )
488  {
489  SCIP_Real lowthreshold;
490  SCIP_Real highthreshold;
491  int conidx;
492  int binidx;
493 
494  if( isVlb(scip, matrix, *colpnt, &lowthreshold, &highthreshold, &conidx, &binidx) )
495  {
496  vbcons[nvbcons] = *colpnt;
497  lowthresholds[nvbcons] = lowthreshold;
498  highthresholds[nvbcons] = highthreshold;
499  conidxs[nvbcons] = conidx;
500  binidxs[nvbcons] = binidx;
501  nvbcons++;
502  }
503  }
504  if( nvbcons >= 2 )
505  {
506  SCIP_CALL( detectDominatingVlbs(scip, matrix, nvbcons, vbcons,
507  lowthresholds, highthresholds, conidxs, binidxs,
508  nvaragg, isvartoagg, aggvars, ndeletecons, deletecons) );
509  }
510  }
511 
512  SCIPfreeBufferArray(scip, &vbcons);
513  SCIPfreeBufferArray(scip, &highthresholds);
514  SCIPfreeBufferArray(scip, &lowthresholds);
515  SCIPfreeBufferArray(scip, &conidxs);
516  SCIPfreeBufferArray(scip, &binidxs);
517 
518  return SCIP_OKAY;
519 }
520 
521 
522 /*
523  * Callback methods of presolver
524  */
525 
526 
527 /** execution method of presolver */
528 static
529 SCIP_DECL_PRESOLEXEC(presolExecRedvub)
530 { /*lint --e{715}*/
531  SCIP_MATRIX* matrix;
532  SCIP_Bool initialized;
533  SCIP_Bool complete;
534 
535  assert(result != NULL);
536  *result = SCIP_DIDNOTRUN;
537 
539  return SCIP_OKAY;
540 
542  return SCIP_OKAY;
543 
544  *result = SCIP_DIDNOTFIND;
545 
546  matrix = NULL;
547  SCIP_CALL( SCIPmatrixCreate(scip, &matrix, &initialized, &complete) );
548 
549  if( initialized && complete )
550  {
551  int nvaragg;
552  SCIP_Bool* isvartoagg;
553  int ndeletecons;
554  SCIP_Bool* deletecons;
555  SCIP_VAR** aggvars;
556  int ncols;
557  int nrows;
558 
559  ncols = SCIPmatrixGetNColumns(matrix);
560  nrows = SCIPmatrixGetNRows(matrix);
561 
562  nvaragg = 0;
563  ndeletecons = 0;
564 
565  SCIP_CALL( SCIPallocBufferArray(scip, &isvartoagg, ncols) );
566  BMSclearMemoryArray(isvartoagg, ncols);
567 
568  SCIP_CALL( SCIPallocBufferArray(scip, &deletecons, nrows) );
569  BMSclearMemoryArray(deletecons, nrows);
570 
571  SCIP_CALL( SCIPallocBufferArray(scip, &aggvars, ncols) );
572  BMSclearMemoryArray(aggvars, ncols);
573 
574  SCIP_CALL( findVarAggrRedVbcons(scip, matrix, &nvaragg, isvartoagg, aggvars, &ndeletecons, deletecons) );
575 
576  if( nvaragg > 0 )
577  {
578  int v;
579  for( v = 0; v < ncols; v++ )
580  {
581  if( isvartoagg[v] )
582  {
583  SCIP_Bool infeasible;
584  SCIP_Bool redundant;
585  SCIP_Bool aggregated;
586 
587  /* substitute/aggregate binary variable */
588  assert(aggvars[v] != NULL);
589  SCIP_CALL( SCIPaggregateVars(scip, SCIPmatrixGetVar(matrix,v), aggvars[v], 1.0, -1.0,
590  0.0, &infeasible, &redundant, &aggregated) );
591 
592  if( infeasible )
593  {
594  SCIPdebugMessage(" -> infeasible aggregation\n");
595  *result = SCIP_CUTOFF;
596  return SCIP_OKAY;
597  }
598 
599  if( aggregated )
600  {
601  (*naggrvars)++;
602 
603  /* set result pointer */
604  if( (*result) == SCIP_DIDNOTFIND )
605  *result = SCIP_SUCCESS;
606  }
607  }
608  }
609  }
610 
611  if( ndeletecons > 0 )
612  {
613  int r;
614  for( r = 0; r < nrows; r++ )
615  {
616  if( deletecons[r] )
617  {
618  SCIP_CONS* cons;
619 
620  /* remove redundant variable bound constraint */
621  cons = SCIPmatrixGetCons(matrix, r);
622  SCIP_CALL( SCIPdelCons(scip, cons) );
623 
624  (*ndelconss)++;
625 
626  /* set result pointer */
627  if( (*result) == SCIP_DIDNOTFIND )
628  *result = SCIP_SUCCESS;
629  }
630  }
631  }
632 
633  SCIPfreeBufferArray(scip, &aggvars);
634  SCIPfreeBufferArray(scip, &deletecons);
635  SCIPfreeBufferArray(scip, &isvartoagg);
636  }
637 
638  SCIPmatrixFree(scip, &matrix);
639 
640  return SCIP_OKAY;
641 }
642 
643 /*
644  * presolver specific interface methods
645  */
646 
647 /** creates the redvub presolver and includes it in SCIP */
649  SCIP* scip /**< SCIP data structure */
650  )
651 {
652  SCIP_PRESOL* presol;
653 
654  /* include presolver */
656  PRESOL_TIMING, presolExecRedvub, NULL) );
657 
658  return SCIP_OKAY;
659 }
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:41572
SCIP_VAR * SCIPmatrixGetVar(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1325
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16443
int SCIPmatrixGetNRows(SCIP_MATRIX *matrix)
Definition: matrix.c:1397
SCIP_RETCODE SCIPaggregateVars(SCIP *scip, SCIP_VAR *varx, SCIP_VAR *vary, SCIP_Real scalarx, SCIP_Real scalary, SCIP_Real rhs, SCIP_Bool *infeasible, SCIP_Bool *redundant, SCIP_Bool *aggregated)
Definition: scip.c:22886
SCIP_RETCODE SCIPdelCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip.c:11540
SCIP_CONS * SCIPmatrixGetCons(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1525
#define NULL
Definition: lpi_spx.cpp:130
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip.c:1125
void SCIPmatrixFree(SCIP *scip, SCIP_MATRIX **matrix)
Definition: matrix.c:782
#define MAXPAIRCOMP
Definition: presol_redvub.c:46
#define FALSE
Definition: def.h:56
#define TRUE
Definition: def.h:55
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define SCIP_CALL(x)
Definition: def.h:266
static SCIP_RETCODE findVarAggrRedVbcons(SCIP *scip, SCIP_MATRIX *matrix, int *nvaragg, SCIP_Bool *isvartoagg, SCIP_VAR **aggvars, int *ndeletecons, SCIP_Bool *deletecons)
static SCIP_Bool isVub(SCIP *scip, SCIP_MATRIX *matrix, int row, SCIP_Real *lowthreshold, SCIP_Real *highthreshold, int *conidx, int *binidx)
Definition: presol_redvub.c:54
int SCIPgetNActivePricers(SCIP *scip)
Definition: scip.c:5017
#define SCIPdebugMessage
Definition: pub_message.h:77
#define BMSclearMemoryArray(ptr, num)
Definition: memory.h:85
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:16905
static SCIP_Bool isVlb(SCIP *scip, SCIP_MATRIX *matrix, int row, SCIP_Real *lowthreshold, SCIP_Real *highthreshold, int *conidx, int *binidx)
int SCIPgetNContVars(SCIP *scip)
Definition: scip.c:10878
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
Definition: scip.c:26237
SCIP_RETCODE SCIPmatrixCreate(SCIP *scip, SCIP_MATRIX **matrixptr, SCIP_Bool *initialized, SCIP_Bool *complete)
Definition: matrix.c:430
int SCIPmatrixGetRowNNonzs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1373
SCIP_RETCODE SCIPincludePresolRedvub(SCIP *scip)
SCIP_Real SCIPmatrixGetRowLhs(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1407
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:41585
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:41598
int * SCIPmatrixGetRowIdxPtr(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1361
SCIP_Real * SCIPmatrixGetRowValPtr(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1349
SCIP_Bool SCIPinProbing(SCIP *scip)
Definition: scip.c:32131
#define PRESOL_NAME
Definition: presol_redvub.c:40
static SCIP_RETCODE detectDominatingVubs(SCIP *scip, SCIP_MATRIX *matrix, int nvubs, int *vubs, SCIP_Real *lowthresholds, SCIP_Real *highthresholds, int *conidxs, int *binidxs, int *nvaragg, SCIP_Bool *isvartoagg, SCIP_VAR **aggvars, int *ndeletecons, SCIP_Bool *deletecons)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:41611
#define SCIP_Bool
Definition: def.h:53
static SCIP_DECL_PRESOLEXEC(presolExecRedvub)
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip.c:801
#define PRESOL_TIMING
Definition: presol_redvub.c:44
int * SCIPmatrixGetColIdxPtr(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1245
#define PRESOL_DESC
Definition: presol_redvub.c:41
SCIP_Bool SCIPisNLPEnabled(SCIP *scip)
Definition: scip.c:28369
#define PRESOL_PRIORITY
Definition: presol_redvub.c:42
public methods for matrix
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:41624
static SCIP_RETCODE detectDominatingVlbs(SCIP *scip, SCIP_MATRIX *matrix, int nvlbs, int *vlbs, SCIP_Real *lowthresholds, SCIP_Real *highthresholds, int *conidxs, int *binidxs, int *nvaragg, SCIP_Bool *isvartoagg, SCIP_VAR **aggvars, int *ndeletecons, SCIP_Bool *deletecons)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16608
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:20585
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17057
remove redundant variable upper bound constraints
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip.c:1281
SCIP_Bool SCIPmatrixIsRowRhsInfinity(SCIP_MATRIX *matrix, int row)
Definition: matrix.c:1431
#define SCIP_Real
Definition: def.h:127
int SCIPmatrixGetColNDownlocks(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1313
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:58
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:20597
int SCIPmatrixGetColNUplocks(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1301
SCIP_RETCODE SCIPincludePresolBasic(SCIP *scip, SCIP_PRESOL **presolptr, const char *name, const char *desc, int priority, int maxrounds, SCIP_PRESOLTIMING timing, SCIP_DECL_PRESOLEXEC((*presolexec)), SCIP_PRESOLDATA *presoldata)
Definition: scip.c:6191
int SCIPmatrixGetNColumns(SCIP_MATRIX *matrix)
Definition: matrix.c:1269
#define PRESOL_MAXROUNDS
Definition: presol_redvub.c:43
int SCIPmatrixGetColNNonzs(SCIP_MATRIX *matrix, int col)
Definition: matrix.c:1257