GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
sepa_basis.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* GCG --- Generic Column Generation */
5/* a Dantzig-Wolfe decomposition based extension */
6/* of the branch-cut-and-price framework */
7/* SCIP --- Solving Constraint Integer Programs */
8/* */
9/* Copyright (C) 2010-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file sepa_basis.c
30 * @brief basis separator
31 * @author Jonas Witt
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
36/*#define SCIP_DEBUG*/
37
38#include <assert.h>
39#include <stdio.h>
40#include <string.h>
41
42#include "scip/scip.h"
43#include "scip/scipdefplugins.h"
44#include "gcg/sepa_basis.h"
45#include "gcg/sepa_original.h"
46#include "gcg/gcg.h"
47#include "gcg/relax_gcg.h"
48#include "gcg/pricer_gcg.h"
49#include "gcg/pub_gcgvar.h"
50
51
52#ifdef WITH_GSL
53#include <gsl/gsl_matrix.h>
54#include <gsl/gsl_permutation.h>
55#include <gsl/gsl_linalg.h>
56#endif
57
58#define SEPA_NAME "basis"
59#define SEPA_DESC "separator calculates a basis of the orig problem to generate cuts, which cut off the master lp sol"
60#define SEPA_PRIORITY 100
61#define SEPA_FREQ 0
62#define SEPA_MAXBOUNDDIST 1.0
63#define SEPA_USESSUBSCIP FALSE /**< does the separator use a secondary SCIP instance? */
64#define SEPA_DELAY TRUE /**< should separation method be delayed, if other separators found cuts? */
65
66#define STARTMAXCUTS 50 /**< maximal cuts used at the beginning */
67
68
69/*
70 * Data structures
71 */
72
73/** separator data */
75{
76 GCG* gcg; /**< GCG data structure */
77 SCIP_ROW** mastercuts; /**< cuts in the master problem */
78 SCIP_ROW** origcuts; /**< cuts in the original problem */
79 int norigcuts; /**< number of cuts in the original problem */
80 int nmastercuts; /**< number of cuts in the master problem */
81 int maxcuts; /**< maximal number of allowed cuts */
82 SCIP_ROW** newcuts; /**< new cuts to tighten original problem */
83 int nnewcuts; /**< number of new cuts */
84 int maxnewcuts; /**< maximal number of allowed new cuts */
85 int round; /**< number of separation round in probing LP of current node */
86 int currentnodenr; /**< number of current node */
87 SCIP_ROW* objrow; /**< row with obj coefficients */
88 SCIP_Bool enable; /**< parameter returns if basis separator is enabled */
89 SCIP_Bool enableobj; /**< parameter returns if objective constraint is enabled */
90 SCIP_Bool enableobjround; /**< parameter returns if rhs/lhs of objective constraint is rounded, when obj is int */
91 SCIP_Bool enableppcuts; /**< parameter returns if cuts generated during pricing are added to newconss array */
92 SCIP_Bool enableppobjconss; /**< parameter returns if objective constraint for each redcost of pp is enabled */
93 SCIP_Bool enableppobjcg; /**< parameter returns if objective constraint for each redcost of pp is enabled during pricing */
94 int separationsetting; /**< parameter returns which parameter setting is used for separation */
95 SCIP_Bool chgobj; /**< parameter returns if basis is searched with different objective */
96 SCIP_Bool chgobjallways; /**< parameter returns if obj is not only changed in first iteration */
97 SCIP_Bool genobjconvex; /**< parameter returns if objconvex is generated dynamically */
98 SCIP_Bool enableposslack; /**< parameter returns if positive slack should influence the probing objective function */
99 SCIP_Bool forcecuts; /**< parameter returns if cuts are forced to enter the LP */
100 int posslackexp; /**< parameter returns exponent of usage of positive slack */
101 SCIP_Bool posslackexpgen; /**< parameter returns if exponent should be automatically generated */
102 SCIP_Real posslackexpgenfactor; /**< parameter returns factor for automatically generated exponent */
103 int maxrounds; /**< parameter returns maximum number of separation rounds in probing LP (-1 if unlimited) */
104 int maxroundsroot; /**< parameter returns maximum number of separation rounds in probing LP in root node (-1 if unlimited) */
105 int mincuts; /**< parameter returns number of minimum cuts needed to return *result = SCIP_Separated */
106 SCIP_Real objconvex; /**< parameter return convex combination factor */
107};
108
109/*
110 * Local methods
111 */
112
113/** allocates enough memory to hold more cuts */
114static
116 SCIP* scip, /**< SCIP data structure */
117 SCIP_SEPADATA* sepadata, /**< separator data data structure */
118 int size /**< new size of cut arrays */
119 )
120{
121 assert(scip != NULL);
122 assert(sepadata != NULL);
123 assert(sepadata->mastercuts != NULL);
124 assert(sepadata->origcuts != NULL);
125 assert(sepadata->norigcuts <= sepadata->maxcuts);
126 assert(sepadata->norigcuts >= 0);
127 assert(sepadata->nmastercuts <= sepadata->maxcuts);
128 assert(sepadata->nmastercuts >= 0);
129
130 if( sepadata->maxcuts < size )
131 {
132 int newmaxcuts = SCIPcalcMemGrowSize(scip, size);
133 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(sepadata->mastercuts), sepadata->maxcuts, newmaxcuts) );
134 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(sepadata->origcuts), sepadata->maxcuts, newmaxcuts) );
135 sepadata->maxcuts = newmaxcuts;
136 }
137 assert(sepadata->maxcuts >= size);
138
139 return SCIP_OKAY;
140}
141
142/** allocates enough memory to hold more new cuts */
143static
145 SCIP* scip, /**< SCIP data structure */
146 SCIP_SEPADATA* sepadata, /**< separator data data structure */
147 int size /**< new size of cut arrays */
148 )
149{
150 assert(scip != NULL);
151 assert(sepadata != NULL);
152 assert(sepadata->newcuts != NULL);
153 assert(sepadata->nnewcuts <= sepadata->maxnewcuts);
154 assert(sepadata->nnewcuts >= 0);
155
156 if( sepadata->maxnewcuts < size )
157 {
158 int newmaxnewcuts = SCIPcalcMemGrowSize(scip, size);
159 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(sepadata->newcuts), sepadata->maxnewcuts, newmaxnewcuts) );
160 sepadata->maxnewcuts = newmaxnewcuts;
161 }
162 assert(sepadata->maxnewcuts >= size);
163
164 return SCIP_OKAY;
165}
166
167/** returns the result of the exponentiation for given exponent and basis (basis^exponent) */
168static
170 SCIP_Real basis, /**< basis for exponentiation */
171 int exponent /**< exponent for exponentiation */
172 )
173{
175 int i;
176
177 assert(exponent >= 0);
178
179 result = 1.0;
180 for( i = 0; i < exponent; ++i )
181 {
182 result *= basis;
183 }
184
185 return result;
186}
187
188/**< Initialize probing objective coefficient for each variable with original objective. */
189static
191 SCIP* origscip, /**< orig scip problem */
192 SCIP_Bool enableobj, /**< returns if objective row was added to the lp */
193 SCIP_Real objfactor /**< factor, the objective is multiplied with */
194)
195{
196 SCIP_VAR** origvars;
197 int norigvars;
198 SCIP_VAR* origvar;
199
200 SCIP_Real newobj;
201 int i;
202
203 assert(SCIPinProbing(origscip));
204
205 origvars = SCIPgetVars(origscip);
206 norigvars = SCIPgetNVars(origscip);
207
208 /* loop over original variables */
209 for( i = 0; i < norigvars; ++i )
210 {
211 /* get variable information */
212 origvar = origvars[i];
213 newobj = 0.0;
214
215 /* if objective row is enabled consider also the original objective value */
216 if( enableobj )
217 newobj = objfactor * SCIPvarGetObj(origvar);
218
219 SCIP_CALL( SCIPchgVarObjProbing(origscip, origvar, newobj) );
220 }
221 return SCIP_OKAY;
222}
223
224/**< Change probing objective coefficient for each variable by adding original objective
225 * to the probing objective.
226 */
227static
229 SCIP* origscip, /**< orig scip problem */
230 SCIP_Real objfactor, /**< factor the additional part of the objective is multiplied with */
231 SCIP_Real objdivisor /**< factor the additional part of the objective is divided with */
232)
233{
234 SCIP_VAR** origvars;
235 int norigvars;
236 SCIP_VAR* origvar;
237
238 SCIP_Real newobj;
239 int i;
240
241 assert(SCIPinProbing(origscip));
242
243 origvars = SCIPgetVars(origscip);
244 norigvars = SCIPgetNVars(origscip);
245
246 /* loop over original variables */
247 for( i = 0; i < norigvars; ++i )
248 {
249 /* get variable information */
250 origvar = origvars[i];
251
252 newobj = SCIPgetVarObjProbing(origscip, origvar) + (objfactor * SCIPvarGetObj(origvar))/ objdivisor ;
253
254 SCIP_CALL( SCIPchgVarObjProbing(origscip, origvar, newobj) );
255 }
256 return SCIP_OKAY;
257}
258
259/**< Initialize probing objective coefficient for each variable depending on the current origsol.
260 *
261 * If variable is at upper bound set objective to -1, if variable is at lower bound set obj to 1,
262 * else set obj to 0.
263 * Additionally, add original objective to the probing objective if this is enabled.
264 */
265static
267 SCIP* origscip, /**< orig scip problem */
268 SCIP_SEPADATA* sepadata, /**< separator specific data */
269 SCIP_SOL* origsol, /**< orig solution */
270 SCIP_Bool enableobj, /**< returns if objective row was added to the lp */
271 SCIP_Real objfactor /**< factor the objective is multiplied with */
272)
273{
274 SCIP_Bool enableposslack;
275 int posslackexp;
276
277 SCIP_VAR** origvars;
278 int norigvars;
279 SCIP_VAR* origvar;
280
281 SCIP_Real lb;
282 SCIP_Real ub;
284 SCIP_Real newobj;
285 SCIP_Real distance;
286
287 int i;
288
289 origvars = SCIPgetVars(origscip);
290 norigvars = SCIPgetNVars(origscip);
291
292 enableposslack = sepadata->enableposslack;
293 posslackexp = sepadata->posslackexp;
294
295 /* loop over original variables */
296 for( i = 0; i < norigvars; ++i )
297 {
298 /* get variable information */
299 origvar = origvars[i];
300 lb = SCIPvarGetLbLocal(origvar);
301 ub = SCIPvarGetUbLocal(origvar);
302 solval = SCIPgetSolVal(origscip, origsol, origvar);
303
304 assert(SCIPisFeasLE(origscip, solval, ub));
305 assert(SCIPisFeasGE(origscip, solval, lb));
306
307 /* if solution value of variable is at ub or lb initialize objective value of the variable
308 * such that the difference to this bound is minimized
309 */
310 if( SCIPisFeasEQ(origscip, lb, ub) )
311 {
312 newobj = 0.0;
313 }
314 else if( SCIPisLT(origscip, ub, SCIPinfinity(origscip)) && SCIPisFeasLE(origscip, ub, solval) )
315 {
316 newobj = -1.0;
317 }
318 else if( SCIPisGT(origscip, lb, -SCIPinfinity(origscip)) && SCIPisFeasGE(origscip, lb, solval) )
319 {
320 newobj = 1.0;
321 }
322 else if( enableposslack )
323 {
324 /* compute distance from solution to variable bound */
325 distance = MIN(solval - lb, ub - solval);
326
327 assert(SCIPisFeasPositive(origscip, distance));
328
329 /* check if distance is lower than 1 and compute factor */
330 if( SCIPisLT(origscip, distance, 1.0) )
331 {
332 newobj = exponentiate(MAX(0.0, 1.0 - distance), posslackexp);
333
334 /* check if algebraic sign has to be changed */
335 if( SCIPisLT(origscip, distance, solval - lb) )
336 newobj = -newobj;
337 }
338 else
339 {
340 newobj = 0.0;
341 }
342 }
343 else
344 {
345 newobj = 0.0;
346 }
347
348 /* if objective row is enabled consider also the original objective value */
349 if( enableobj )
350 newobj = newobj + SCIPvarGetObj(origvar);
351
352 SCIP_CALL( SCIPchgVarObjProbing(origscip, origvar, objfactor*newobj) );
353 }
354
355 return SCIP_OKAY;
356}
357
358/**< Change probing objective depending on the current origsol.
359 *
360 * Loop over all constraints lhs <= sum a_i*x_i <= rhs. If lhs == sum a_i*x_i^* add a_i to objective
361 * of variable i and if rhs == sum a_i*x_i^* add -a_i to objective of variable i.
362 */
363static
365 SCIP* origscip, /**< orig scip problem */
366 SCIP_SEPADATA* sepadata, /**< separator data */
367 SCIP_SOL* origsol, /**< orig solution */
368 SCIP_Real objfactor, /**< factor the objective is multiplied with */
369 SCIP_Real objdivisor /**< factor the objective is divided with */
370)
371{
372 SCIP_Bool enableposslack;
373 int posslackexp;
374
375 SCIP_ROW** rows;
376 int nrows;
377 SCIP_ROW* row;
378 SCIP_Real* vals;
379 SCIP_VAR** vars;
380 SCIP_COL** cols;
381 int nvars;
382
383 SCIP_Real lhs;
384 SCIP_Real rhs;
385 SCIP_Real* solvals;
386 SCIP_Real activity;
387 SCIP_Real factor;
388 SCIP_Real objadd;
390 SCIP_Real norm;
391 SCIP_Real distance;
392
393 int i;
394 int j;
395
396 rows = SCIPgetLPRows(origscip);
397 nrows = SCIPgetNLPRows(origscip);
398
399 enableposslack = sepadata->enableposslack;
400 posslackexp = sepadata->posslackexp;
401
402 assert(SCIPinProbing(origscip));
403
404 SCIP_CALL( SCIPallocBufferArray(origscip, &solvals, SCIPgetNVars(origscip)) );
405 SCIP_CALL( SCIPallocBufferArray(origscip, &vars, SCIPgetNVars(origscip)) );
406
407 /* loop over constraint and check activity */
408 for( i = 0; i < nrows; ++i )
409 {
410 row = rows[i];
411 lhs = SCIProwGetLhs(row);
412 rhs = SCIProwGetRhs(row);
413
414 nvars = SCIProwGetNNonz(row);
415 if( nvars == 0 || (sepadata->objrow != NULL && strcmp(SCIProwGetName(row),SCIProwGetName(sepadata->objrow)) == 0 ) )
416 continue;
417
418 /* get values, variables and solution values */
419 vals = SCIProwGetVals(row);
420 cols = SCIProwGetCols(row);
421 for( j = 0; j < nvars; ++j )
422 {
423 vars[j] = SCIPcolGetVar(cols[j]);
424 }
425
426 activity = SCIPgetRowSolActivity(origscip, row, origsol);
427
428 if( SCIPisFeasEQ(origscip, rhs, lhs) )
429 {
430 continue;
431 }
432 if( SCIPisLT(origscip, rhs, SCIPinfinity(origscip)) && SCIPisFeasLE(origscip, rhs, activity) )
433 {
434 factor = -1.0;
435 }
436 else if( SCIPisGT(origscip, lhs, -SCIPinfinity(origscip)) && SCIPisFeasGE(origscip, lhs, activity) )
437 {
438 factor = 1.0;
439 }
440 else if( enableposslack )
441 {
442 assert(!(SCIPisInfinity(origscip, rhs) && SCIPisInfinity(origscip, lhs)));
443 assert(!(SCIPisInfinity(origscip, activity) && SCIPisInfinity(origscip, -activity)));
444
445 /* compute distance from solution to row */
446 if( SCIPisInfinity(origscip, rhs) && SCIPisGT(origscip, lhs, -SCIPinfinity(origscip)) )
447 distance = activity - lhs;
448 else if( SCIPisInfinity(origscip, lhs) && SCIPisLT(origscip, rhs, SCIPinfinity(origscip)) )
449 distance = rhs - activity;
450 else
451 distance = MIN(activity - lhs, rhs - activity);
452
453 assert(SCIPisFeasPositive(origscip, distance) || !SCIPisCutEfficacious(origscip, origsol, row));
454
455 /* check if distance is lower than 1 and compute factor */
456 if( SCIPisLT(origscip, distance, 1.0) )
457 {
458 factor = exponentiate(MAX(0.0, 1.0 - distance), posslackexp);
459
460 /* check if algebraic sign has to be changed */
461 if( SCIPisLT(origscip, distance, activity - lhs) )
462 factor = -1.0*factor;
463 }
464 else
465 {
466 continue;
467 }
468 }
469 else
470 {
471 continue;
472 }
473
474 norm = SCIProwGetNorm(row);
475
476 /* loop over variables of the constraint and change objective */
477 for( j = 0; j < nvars; ++j )
478 {
479 obj = SCIPgetVarObjProbing(origscip, vars[j]);
480 objadd = (factor * vals[j]) / norm;
481
482 SCIP_CALL( SCIPchgVarObjProbing(origscip, vars[j], obj + (objfactor * objadd) / objdivisor) );
483 }
484 }
485
486 SCIPfreeBufferArray(origscip, &solvals);
487 SCIPfreeBufferArray(origscip, &vars);
488
489 return SCIP_OKAY;
490}
491
492#ifdef WITH_GSL
493/** Get matrix (including nrows and ncols) of rows that are satisfied with equality by sol */
494static
495SCIP_RETCODE getEqualityMatrixGsl(
496 SCIP* scip, /**< SCIP data structure */
497 SCIP_SOL* sol, /**< solution */
498 gsl_matrix** matrix, /**< pointer to store equality matrix */
499 int* nrows, /**< pointer to store number of rows */
500 int* ncols, /**< pointer to store number of columns */
501 int* prerank /**< pointer to store preprocessed rank */
502)
503{
504 int* var2col;
505 int* delvars;
506
507 int nvar2col;
508 int ndelvars;
509
511 int nlprows;
512
513 SCIP_COL** lpcols;
514 int nlpcols;
515
516 int i;
517 int j;
518
519 *ncols = SCIPgetNLPCols(scip);
522 nlpcols = SCIPgetNLPCols(scip);
523 lpcols = SCIPgetLPCols(scip);
524
525 *nrows = 0;
526
527 ndelvars = 0;
528 nvar2col = 0;
529
530 SCIP_CALL( SCIPallocBufferArray(scip, &var2col, nlpcols) );
531 SCIP_CALL( SCIPallocBufferArray(scip, &delvars, nlpcols) );
532
533 /* loop over lp cols and check if it is at one of its bounds */
534 for( i = 0; i < nlpcols; ++i )
535 {
536 SCIP_COL* lpcol;
537 SCIP_VAR* lpvar;
538
539 lpcol = lpcols[i];
540
541 lpvar = SCIPcolGetVar(lpcol);
542
543 if( SCIPisEQ(scip, SCIPgetSolVal(scip, sol, lpvar), SCIPcolGetUb(lpcol) )
544 || SCIPisEQ(scip, SCIPgetSolVal(scip, sol, lpvar), SCIPcolGetLb(lpcol)) )
545 {
546 int ind;
547
548 ind = SCIPcolGetIndex(lpcol);
549
550 delvars[ndelvars] = ind;
551
552 ++ndelvars;
553
554 var2col[ind] = -1;
555 }
556 else
557 {
558 int ind;
559
560 ind = SCIPcolGetIndex(lpcol);
561
562 var2col[ind] = nvar2col;
563
564 ++nvar2col;
565 }
566 }
567
568 SCIPsortInt(delvars, ndelvars);
569
570 *matrix = gsl_matrix_calloc(nlprows, nvar2col);
571
572 *ncols = nvar2col;
573
574 /* loop over lp rows and check if solution feasibility is equal to zero */
575 for( i = 0; i < nlprows; ++i )
576 {
577 SCIP_ROW* lprow;
578
579 lprow = lprows[i];
580
581 /* if solution feasiblity is equal to zero, add row to matrix */
582 if( SCIPisEQ(scip, SCIPgetRowSolFeasibility(scip, lprow, sol), 0.0) )
583 {
584 SCIP_COL** cols;
585 SCIP_Real* vals;
586 int nnonz;
587
588 cols = SCIProwGetCols(lprow);
589 vals = SCIProwGetVals(lprow);
590 nnonz = SCIProwGetNNonz(lprow);
591
592 /* get nonzero coefficients of row */
593 for( j = 0; j < nnonz; ++j )
594 {
595 int ind;
596 int pos;
597
598 ind = SCIPcolGetIndex(cols[j]);
599 assert(ind >= 0 && ind < nlpcols);
600
601 if( !SCIPsortedvecFindInt(delvars, ind, ndelvars, &pos) )
602 {
603 gsl_matrix_set(*matrix, *nrows, var2col[ind], vals[j]);
604 }
605 }
606 ++(*nrows);
607 }
608 }
609 *nrows = nlprows;
610 *prerank = ndelvars;
611
612 SCIPfreeBufferArray(scip, &delvars);
613 SCIPfreeBufferArray(scip, &var2col);
614
615 return SCIP_OKAY;
616}
617
618/** get the rank of a given matrix */
619static
620SCIP_RETCODE getRank(
621 SCIP* scip,
622 gsl_matrix* matrix,
623 int nrows,
624 int ncols,
625 int* rank
626)
627{
628 gsl_matrix* matrixq;
629 gsl_matrix* matrixr;
630
631 gsl_vector* tau;
632 gsl_vector* norm;
633 gsl_permutation* permutation;
634
635 int ranktmp;
636 int signum;
637
638 int i;
639
640 matrixq = gsl_matrix_alloc(nrows, nrows);
641 matrixr = gsl_matrix_alloc(nrows, ncols);
642
643 norm = gsl_vector_alloc(ncols);
644 tau = gsl_vector_alloc(MIN(nrows, ncols));
645
646 permutation = gsl_permutation_alloc(ncols);
647
648 gsl_linalg_QRPT_decomp(matrix, tau, permutation, &signum, norm);
649
650 gsl_linalg_QR_unpack(matrix, tau, matrixq, matrixr);
651
652 ranktmp = 0;
653
654 for( i = 0; i < MIN(nrows, ncols); ++i )
655 {
656 SCIP_Real val;
657
658 val = gsl_matrix_get(matrixr, i, i);
659
660 if( SCIPisZero(scip, val) )
661 {
662 break;
663 }
664 ++(ranktmp);
665 }
666
667 *rank = ranktmp;
668
669 gsl_matrix_free(matrixq);
670 gsl_matrix_free(matrixr);
671
672 gsl_vector_free(tau);
673 gsl_vector_free(norm);
674
675 gsl_permutation_free(permutation);
676
677 return SCIP_OKAY;
678}
679
680/** Get rank (number of linear independent rows) of rows that are satisfied
681 * with equality by solution sol */
682static
683SCIP_RETCODE getEqualityRankGsl(
684 SCIP* scip, /**< SCIP data structure */
685 SCIP_SOL* sol, /**< solution */
686 int* equalityrank /**< pointer to store rank of rows with equality */
687 )
688{
689 gsl_matrix* matrix;
690 int nrows;
691 int ncols;
692
693 int prerank;
694 int rowrank;
695
696 SCIP_CALL( getEqualityMatrixGsl(scip, sol, &matrix, &nrows, &ncols, &prerank) );
697
698 SCIP_CALL( getRank(scip, matrix, nrows, ncols, &rowrank) );
699
700 gsl_matrix_free(matrix);
701
702 *equalityrank = rowrank + prerank;
703
704 return SCIP_OKAY;
705}
706#endif
707
708/** add cuts based on the last objective function of the pricing problems, which did not yield any new columns
709 * (stating that the reduced cost are non-negative) */
710static
712 GCG* gcg, /**< GCG data structure */
713 SCIP_SEPA* sepa, /**< separator basis */
714 int ppnumber, /**< number of pricing problem */
715 SCIP_Real dualsolconv, /**< dual solution corresponding to convexity constraint */
716 SCIP_Bool newcuts, /**< add cut to newcuts in sepadata? (otherwise add it just to the cutpool) */
717 SCIP_Bool probing /**< add cut to probing LP? */
718)
719{
720 SCIP_SEPADATA* sepadata;
721 SCIP* origprob;
722 SCIP* pricingscip;
723
724 SCIP_VAR** pricingvars;
725 SCIP_VAR* var;
726
727 int npricingvars;
728 int nvars;
729
730 char name[SCIP_MAXSTRLEN];
731
732 int j;
733 int k;
734
735 SCIP_Real lhs;
736 SCIP_Real rhs;
737
738 sepadata = SCIPsepaGetData(sepa);
740 nvars = 0;
741 pricingscip = GCGgetPricingprob(gcg, ppnumber);
742 pricingvars = SCIPgetOrigVars(pricingscip);
743 npricingvars = SCIPgetNOrigVars(pricingscip);
744
745 if( !GCGisPricingprobRelevant(gcg, ppnumber) || pricingscip == NULL )
746 return SCIP_OKAY;
747
748 lhs = dualsolconv;
749 rhs = SCIPinfinity(origprob);
750
751 for( k = 0; k < GCGgetNIdenticalBlocks(gcg, ppnumber); ++k )
752 {
753 SCIP_ROW* origcut;
754
755 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "newconstraint_%d_%d_%d", SCIPsepaGetNCalls(sepa), ppnumber, k);
756
757 SCIP_CALL( SCIPcreateEmptyRowUnspec(origprob, &origcut, name, lhs, rhs, FALSE, FALSE, TRUE) );
758
759 nvars = 0;
760
761 for( j = 0; j < npricingvars ; ++j )
762 {
763 assert(GCGvarIsPricing(pricingvars[j]));
764
765 if( !SCIPisEQ(origprob, SCIPvarGetObj(pricingvars[j]), 0.0) )
766 {
767 var = GCGpricingVarGetOrigvars(pricingvars[j])[k];
768 assert(var != NULL);
769 SCIP_CALL( SCIPaddVarToRow(origprob, origcut, var, SCIPvarGetObj(pricingvars[j])) );
770 ++nvars;
771 }
772 }
773
774 if( nvars > 0 )
775 {
776 if( newcuts )
777 {
778 SCIP_CALL( ensureSizeNewCuts(origprob, sepadata, sepadata->nnewcuts + 1) );
779
780 sepadata->newcuts[sepadata->nnewcuts] = origcut;
781 SCIP_CALL( SCIPcaptureRow(origprob, sepadata->newcuts[sepadata->nnewcuts]) );
782 ++(sepadata->nnewcuts);
783
784 SCIPdebugMessage("cut added to new cuts in relaxdata\n");
785 }
786 else
787 {
788 SCIP_CALL( SCIPaddPoolCut(origprob, origcut) );
789 SCIPdebugMessage("cut added to orig cut pool\n");
790 }
791
792 if( probing )
793 {
795 SCIPdebugMessage("cut added to probing\n");
796 }
797
798
799 }
800 SCIP_CALL( SCIPreleaseRow(origprob, &origcut) );
801 }
802
803 return SCIP_OKAY;
804}
805/*
806 * Callback methods of separator
807 */
808
809/** copy method for separator plugins (called when SCIP copies plugins) */
810#define sepaCopyBasis NULL
811
812/** destructor of separator to free user data (called when SCIP is exiting) */
813static
814SCIP_DECL_SEPAFREE(sepaFreeBasis)
815{ /*lint --e{715}*/
816 SCIP_SEPADATA* sepadata;
817
818 sepadata = SCIPsepaGetData(sepa);
819 assert(sepadata != NULL);
820
821 SCIPfreeBlockMemory(scip, &sepadata);
822
823 return SCIP_OKAY;
824}
825
826/** initialization method of separator (called after problem was transformed) */
827static
828SCIP_DECL_SEPAINIT(sepaInitBasis)
829{ /*lint --e{715}*/
830 SCIP* origscip;
831 SCIP_SEPADATA* sepadata;
832
833 SCIP_VAR** origvars;
834 int norigvars;
835
836 char name[SCIP_MAXSTRLEN];
837
839 int i;
840
841 SCIP_Bool enable;
842 SCIP_Bool enableobj;
843
844 assert(scip != NULL);
845
846 sepadata = SCIPsepaGetData(sepa);
847 assert(sepadata != NULL);
848
849 origscip = GCGgetOrigprob(sepadata->gcg);
850 assert(origscip != NULL);
851
852 origvars = SCIPgetVars(origscip);
853 norigvars = SCIPgetNVars(origscip);
854
855 SCIPdebugMessage("sepaInitBasis\n");
856
857 enable = sepadata->enable;
858 enableobj = sepadata->enableobj;
859
861 sepadata->norigcuts = 0;
862 sepadata->nmastercuts = 0;
864 sepadata->nnewcuts = 0;
865 sepadata->objrow = NULL;
866 /* if separator is disabled do nothing */
867 if( !enable )
868 {
869 return SCIP_OKAY;
870 }
871
872 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(sepadata->origcuts), sepadata->maxcuts) ); /*lint !e506*/
873 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(sepadata->mastercuts), sepadata->maxcuts) ); /*lint !e506*/
874 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(sepadata->newcuts), sepadata->maxnewcuts) ); /*lint !e506*/
875
876 /* if objective row is enabled create row with objective coefficients */
877 if( enableobj )
878 {
879 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "objrow");
880 SCIP_CALL( SCIPcreateEmptyRowUnspec(origscip, &(sepadata->objrow), name, -SCIPinfinity(origscip), SCIPinfinity(origscip), TRUE, FALSE, TRUE) );
881
882 for( i = 0; i < norigvars; ++i )
883 {
884 obj = SCIPvarGetObj(origvars[i]);
885 SCIP_CALL( SCIPaddVarToRow(origscip, sepadata->objrow, origvars[i], obj) );
886 }
887 }
888
889 return SCIP_OKAY;
890}
891
892
893/** deinitialization method of separator (called before transformed problem is freed) */
894static
895SCIP_DECL_SEPAEXIT(sepaExitBasis)
896{ /*lint --e{715}*/
897 SCIP* origscip;
898 SCIP_SEPADATA* sepadata;
899 SCIP_Bool enableobj;
900
901 int i;
902
903 sepadata = SCIPsepaGetData(sepa);
904 assert(sepadata != NULL);
905 enableobj = sepadata->enableobj;
906 assert(sepadata->nmastercuts == sepadata->norigcuts);
907
908 origscip = GCGgetOrigprob(sepadata->gcg);
909 assert(origscip != NULL);
910
911 for( i = 0; i < sepadata->norigcuts; i++ )
912 {
913 SCIP_CALL( SCIPreleaseRow(origscip, &(sepadata->origcuts[i])) );
914 }
915
916 for( i = 0; i < sepadata->nnewcuts; ++i )
917 {
918 if( sepadata->newcuts[i] != NULL )
919 SCIP_CALL( SCIPreleaseRow(origscip, &(sepadata->newcuts[i])) );
920 }
921
922 if( enableobj )
923 SCIP_CALL( SCIPreleaseRow(origscip, &(sepadata->objrow)) );
924
925 SCIPfreeBlockMemoryArrayNull(scip, &(sepadata->origcuts), sepadata->maxcuts);
926 SCIPfreeBlockMemoryArrayNull(scip, &(sepadata->mastercuts), sepadata->maxcuts);
927 SCIPfreeBlockMemoryArrayNull(scip, &(sepadata->newcuts), sepadata->maxnewcuts);
928
929 return SCIP_OKAY;
930}
931
932/** solving process initialization method of separator (called when branch and bound process is about to begin) */
933static
934SCIP_DECL_SEPAINITSOL(sepaInitsolBasis)
935{ /*lint --e{715}*/
936 SCIP_SEPADATA* sepadata;
937
938 sepadata = SCIPsepaGetData(sepa);
939 assert(sepadata != NULL);
940
941 sepadata->nmastercuts = 0;
942
943 return SCIP_OKAY;
944}
945
946
947/** solving process deinitialization method of separator (called before branch and bound process data is freed) */
948static
949SCIP_DECL_SEPAEXITSOL(sepaExitsolBasis)
950{ /*lint --e{715}*/
951 SCIP_SEPADATA* sepadata;
952 int i;
953
954 sepadata = SCIPsepaGetData(sepa);
955 assert(sepadata != NULL);
956 assert(sepadata->nmastercuts == sepadata->norigcuts);
957
958 assert(GCGgetOrigprob(sepadata->gcg) != NULL);
959
960 for( i = 0; i < sepadata->nmastercuts; i++ )
961 {
962 SCIP_CALL( SCIPreleaseRow(scip, &(sepadata->mastercuts[i])) );
963 }
964
965 return SCIP_OKAY;
966}
967
968
969/** Initialize generic convex combination coefficient */
970static
972 SCIP* origscip, /**< original SCIP data structure */
973 SCIP_SEPADATA* sepadata, /**< separator data structure */
974 SCIP_SOL* origsol, /**< current original solution */
975 int nbasis, /**< rank of constraint matrix */
976 SCIP_Real* convex /**< pointer to store convex combination coefficient */
977)
978{ /*lint --e{715}*/
979#ifdef WITH_GSL
980 int rank;
981
982
983 SCIP_CALL( getEqualityRankGsl(origscip, origsol, &rank) );
984
985 *convex = 1.0* rank/nbasis;
986
987 SCIPdebugMessage("use generic coefficient %d/%d = %f\n", rank, nbasis, *convex);
988
989#else
990 SCIPwarningMessage(origscip, "Gnu Scientific Library is not enabled! \n"
991 "either set sepa/basis/genobjconvex = FALSE sepa/basis/posslackexpgen = FALSE \n"
992 "or compile with GSL=true and include Gnu Scientific Library\n");
993 *convex = sepadata->objconvex;
994#endif
995
996 return SCIP_OKAY;
997}
998
999
1000/** Initialize objective as convex combination of so-called face objective function and original objective function */
1001static
1003 SCIP* origscip, /**< original SCIP data structure */
1004 SCIP_SEPADATA* sepadata, /**< separator data structure */
1005 SCIP_SOL* origsol, /**< current original solution */
1006 SCIP_Real convex, /**< convex coefficient to initialize objective */
1007 SCIP_Bool genericconv /**< was convex coefficient calculated generically? */
1008)
1009{
1010 SCIP_Real objnormnull;
1011 SCIP_Real objnormcurrent;
1012
1013 objnormnull = 1.0;
1014 objnormcurrent = 1.0;
1015
1016 /* if coefficient is zero, only use original objective function */
1017 if( SCIPisEQ(origscip, convex, 0.0) )
1018 {
1019 SCIP_CALL( initProbingObjWithOrigObj(origscip, TRUE, 1.0) );
1020 }
1021 /* if coefficient is between zero and one, calculate convex combination */
1022 else if( SCIPisLT(origscip, convex, 1.0) )
1023 {
1024 SCIP_CALL( initProbingObjWithOrigObj(origscip, TRUE, 1.0) );
1025 objnormnull = SCIPgetObjNorm(origscip);
1026
1027 SCIP_CALL( initProbingObjUsingVarBounds(origscip, sepadata, origsol, FALSE, convex) );
1028 SCIP_CALL( chgProbingObjUsingRows(origscip, sepadata, origsol, convex, 1.0) );
1029
1030 objnormcurrent = SCIPgetObjNorm(origscip)/(convex);
1031
1032 if( SCIPisEQ(origscip, objnormcurrent, 0.0) )
1033 SCIP_CALL( initProbingObjWithOrigObj(origscip, TRUE, 1.0) );
1034 else if( SCIPisGT(origscip, objnormnull, 0.0) )
1035 SCIP_CALL( chgProbingObjAddingOrigObj(origscip, (1.0 - convex) * objnormcurrent, objnormnull) );
1036 }
1037 /* if coefficient is one, only use so-called face objective function (based on activity of rows and variables) */
1038 else if( SCIPisEQ(origscip, convex, 1.0) )
1039 {
1040 SCIP_CALL( initProbingObjUsingVarBounds(origscip, sepadata, origsol, !genericconv && sepadata->enableobj, 1.0) );
1041 SCIP_CALL( chgProbingObjUsingRows(origscip, sepadata, origsol, 1.0, 1.0) );
1042 }
1043
1044 return SCIP_OKAY;
1045}
1046
1047/** LP solution separation method of separator */
1048static
1049SCIP_DECL_SEPAEXECLP(sepaExeclpBasis)
1050{ /*lint --e{715}*/
1051
1052 SCIP* origscip;
1053 SCIP_SEPADATA* sepadata;
1054 GCG* gcg;
1055
1056 SCIP_ROW** cuts;
1057 SCIP_ROW* mastercut;
1058 SCIP_ROW* origcut;
1059 SCIP_COL** cols;
1060 SCIP_VAR** roworigvars;
1062 SCIP_Real* mastervals;
1063 int ncols;
1064 int ncuts;
1065 SCIP_Real* vals;
1066 int nmastervars;
1067
1068 SCIP_SOL* origsol;
1070 SCIP_Bool delayed;
1072 SCIP_Bool infeasible;
1073 SCIP_Real obj;
1074
1075 SCIP_Bool enable;
1076 SCIP_Bool enableobj;
1077 SCIP_Bool enableobjround;
1078 SCIP_Bool enableppobjconss;
1079
1080 char name[SCIP_MAXSTRLEN];
1081
1082 int i;
1083 int j;
1084 int iteration;
1085 int nbasis;
1086 int nlprowsstart;
1087 int nlprows;
1088 int maxrounds;
1089 SCIP_ROW** lprows;
1090 int nviolatedcuts;
1091
1092 SCIP_Bool isroot;
1093
1094 SCIP_RESULT resultdummy;
1095
1096 SCIP_Bool enoughcuts;
1097 int maxcuts;
1098
1099 int maxnsepastallrounds;
1100
1101 SCIP_Real objreldiff;
1102 int nfracs;
1103 SCIP_Real stalllpobjval;
1104 SCIP_Real lpobjval;
1105 SCIP_Bool stalling;
1106 int nsepastallrounds;
1107 int stallnfracs;
1108 SCIP_LPSOLSTAT stalllpsolstat;
1109
1110
1111 assert(scip != NULL);
1112 assert(result != NULL);
1113
1114 sepadata = SCIPsepaGetData(sepa);
1115 assert(sepadata != NULL);
1116 gcg = sepadata->gcg;
1117
1118 origscip = GCGgetOrigprob(sepadata->gcg);
1119 assert(origscip != NULL);
1120
1121 SCIPdebugMessage("calling sepaExeclpBasis\n");
1122
1124 cutoff = FALSE;
1125
1126 enable = sepadata->enable;
1127 enableobj = sepadata->enableobj;
1128 enableobjround = sepadata->enableobjround;
1129 enableppobjconss = sepadata->enableppobjconss;
1130
1131 /* if separator is disabled do nothing */
1132 if( !enable )
1133 {
1134 SCIPdebugMessage("separator is not enabled\n");
1136 return SCIP_OKAY;
1137 }
1138
1139 /* ensure master LP is solved to optimality */
1141 {
1142 SCIPdebugMessage("master LP not solved to optimality, do no separation!\n");
1144 return SCIP_OKAY;
1145 }
1146
1147 /* ensure pricing problems were not aggregated */
1149 {
1150 SCIPdebugMessage("aggregated pricing problems, do no separation!\n");
1152 return SCIP_OKAY;
1153 }
1154
1155 /* ensure to separate current sol */
1157
1158 /* do not separate if current solution is feasible */
1160 {
1161 SCIPdebugMessage("Current solution is feasible, no separation necessary!\n");
1163 return SCIP_OKAY;
1164 }
1165
1166 /* reset information on separation rounds in probing LP at current node */
1168 {
1170 sepadata->round = 0;
1171 }
1172
1174
1175 /* set maximum number of rounds at current node */
1176 maxrounds = (isroot ? sepadata->maxroundsroot : sepadata->maxrounds);
1177
1178 /* if no limit on number of rounds, set maxrounds to INT_MAX */
1179 if( maxrounds == -1 )
1180 maxrounds = INT_MAX;
1181
1182 /* get current original solution */
1183 origsol = GCGrelaxGetCurrentOrigSol(gcg);
1184
1185 /* get trans objective value */
1186 obj = SCIPgetSolTransObj(origscip, origsol);
1187
1188 /* get number of linearly independent rows needed for basis */
1189 nbasis = SCIPgetNLPCols(origscip);
1190
1192
1193 /* init iteration count of current sepa call */
1194 iteration = 0;
1195
1196 /* set parameter setting for separation */
1198
1199 /* disable rapid learning because it does not generate cuts */
1200 SCIP_CALL( SCIPsetIntParam(origscip, "separating/rapidlearning/freq", -1) );
1201
1202 /* start probing */
1203 SCIP_CALL( SCIPstartProbing(origscip) );
1204 SCIP_CALL( SCIPnewProbingNode(origscip) );
1205 SCIP_CALL( SCIPconstructLP(origscip, &cutoff) );
1206
1207 /* add origcuts to probing lp */
1208 for( i = 0; i < GCGsepaGetNOriginalSepaCuts(gcg); ++i )
1209 {
1212 }
1213
1214 /* add new cuts which did not cut off master sol to probing lp */
1215 for( i = 0; i < sepadata->nnewcuts; ++i )
1216 {
1217 if( SCIProwGetLPPos(sepadata->newcuts[i]) == -1 )
1218 SCIP_CALL( SCIPaddRowProbing(origscip, sepadata->newcuts[i]) );
1219 }
1220
1221 /* store number of lp rows in the beginning */
1222 nlprowsstart = SCIPgetNLPRows(origscip);
1223
1224 nsepastallrounds = 0;
1225 stalllpobjval = SCIP_REAL_MIN;
1226 stallnfracs = INT_MAX;
1227 stalling = FALSE;
1228 enoughcuts = FALSE;
1229
1230 maxcuts = 0;
1231 if( isroot )
1232 SCIP_CALL( SCIPgetIntParam(origscip, "separating/maxcutsroot", &maxcuts) );
1233 else
1234 SCIP_CALL( SCIPgetIntParam(origscip, "separating/maxcuts", &maxcuts) );
1235
1236 maxnsepastallrounds = 0;
1237 if( isroot )
1238 SCIP_CALL( SCIPgetIntParam(origscip, "separating/maxstallroundsroot", &maxnsepastallrounds) );
1239 else
1240 SCIP_CALL( SCIPgetIntParam(origscip, "separating/maxstallrounds", &maxnsepastallrounds) );
1241
1242 if( maxnsepastallrounds == -1 )
1243 maxnsepastallrounds = INT_MAX;
1244
1245 stalllpsolstat = SCIP_LPSOLSTAT_NOTSOLVED;
1246
1247
1248 /* while the counter is smaller than the number of allowed rounds,
1249 * try to separate origsol via probing lp sol */
1250 while( sepadata->round < maxrounds && nsepastallrounds < maxnsepastallrounds )
1251 {
1252 SCIPdebugMessage("round %d of at most %d rounds\n", sepadata->round + 1, maxrounds);
1253
1254 SCIP_CALL( SCIPapplyCutsProbing(origscip, &cutoff) );
1255
1256 /* add new constraints if this is enabled */
1257 if( enableppobjconss && iteration == 0 )
1258 {
1259 SCIP_Real* dualsolconv;
1260
1261 SCIPdebugMessage("add reduced cost cut for relevant pricing problems\n");
1262
1264 SCIP_CALL( GCGsetPricingObjs(gcg, dualsolconv) );
1265
1266 for( i = 0; i < GCGgetNPricingprobs(gcg); ++i )
1267 {
1268 SCIP_CALL( addPPObjConss(sepadata->gcg, sepa, i, dualsolconv[i], FALSE, TRUE) );
1269 }
1270
1271 SCIPfreeBufferArray(scip, &dualsolconv);
1272 }
1273
1274 /* initialize objective of probing LP */
1275 if( sepadata->chgobj && (iteration == 0 || sepadata->chgobjallways) )
1276 {
1277 SCIPdebugMessage("initialize objective function\n");
1278 if( sepadata->genobjconvex )
1279 {
1280 SCIP_Real genconvex;
1281
1282 SCIP_CALL( initGenconv(origscip, sepadata, origsol, nbasis, &genconvex) );
1283
1284 SCIP_CALL( initConvObj(origscip, sepadata, origsol, genconvex, TRUE) );
1285 }
1286 else
1287 {
1288 SCIPdebugMessage("use given coefficient %g\n", sepadata->objconvex);
1289
1290 if( sepadata->enableposslack && sepadata->posslackexpgen )
1291 {
1292 SCIP_Real genconvex;
1293 SCIP_Real factor;
1294
1295 factor = sepadata->posslackexpgenfactor;
1296
1297 SCIP_CALL( initGenconv(origscip, sepadata, origsol, nbasis, &genconvex) );
1298
1299 sepadata->posslackexp = (int) (SCIPceil(origscip, factor/(1.0 - genconvex)) + 0.5);
1300
1301 SCIPdebugMessage("exponent = %d\n", sepadata->posslackexp);
1302
1303 }
1304 SCIP_CALL( initConvObj(origscip, sepadata, origsol, sepadata->objconvex, FALSE) );
1305 }
1306 }
1307
1308 /* update rhs/lhs of objective constraint and add it to probing LP, if it exists (only in first iteration) */
1309 if( enableobj && iteration == 0 )
1310 {
1311 SCIPdebugMessage("initialize original objective cut\n");
1312
1313 /* round rhs/lhs of objective constraint, if it exists, obj is integral and this is enabled */
1314 if( SCIPisObjIntegral(origscip) && enableobjround )
1315 {
1316 SCIPdebugMessage("round lhs up\n");
1317 obj = SCIPceil(origscip, obj);
1318 }
1319
1320 SCIP_CALL( SCIPchgRowLhs(origscip, sepadata->objrow, obj) );
1321 SCIP_CALL( SCIPchgRowRhs(origscip, sepadata->objrow, SCIPinfinity(origscip)) );
1322
1323 SCIPdebugMessage("add original objective cut to probing LP\n");
1324
1325 /* add row to probing lp */
1326 SCIP_CALL( SCIPaddRowProbing(origscip, sepadata->objrow) );
1327 }
1328
1329 SCIPdebugMessage("solve probing LP\n");
1330
1331 /* solve probing lp */
1332 SCIP_CALL( SCIPsolveProbingLP(origscip, -1, &lperror, &cutoff) );
1333
1334 assert(!lperror);
1335
1336 /* check if we are stalling
1337 * We are stalling if
1338 * the LP value did not improve and
1339 * the number of fractional variables did not decrease.
1340 */
1341 if( SCIPgetLPSolstat(origscip) == SCIP_LPSOLSTAT_OPTIMAL )
1342 {
1344 lpobjval = SCIPgetLPObjval(origscip);
1345
1346 objreldiff = SCIPrelDiff(lpobjval, stalllpobjval);
1347 SCIPdebugMessage(" -> LP bound moved from %g to %g (reldiff: %g)\n",
1348 stalllpobjval, lpobjval, objreldiff);
1349
1350 stalling = (objreldiff <= 1e-04 &&
1351 nfracs >= (0.9 - 0.1 * nsepastallrounds) * stallnfracs);
1352
1353 stalllpobjval = lpobjval;
1354 stallnfracs = nfracs;
1355 }
1356 else if( SCIPgetLPSolstat(origscip) == SCIP_LPSOLSTAT_OBJLIMIT )
1357 {
1358 cutoff = TRUE;
1359 }
1360 else
1361 {
1362 stalling = (stalllpsolstat == SCIPgetLPSolstat(origscip));
1363 }
1364
1365 if( !cutoff )
1366 {
1367 if( !stalling )
1368 {
1369 nsepastallrounds = 0;
1370 }
1371 else
1372 {
1373 nsepastallrounds++;
1374 }
1375 stalllpsolstat = SCIPgetLPSolstat(origscip);
1376
1377 /* separate cuts in cutpool */
1378 SCIPdebugMessage("separate current LP sol in cutpool\n");
1379 SCIP_CALL( SCIPseparateSolCutpool(origscip, SCIPgetGlobalCutpool(origscip), NULL, isroot, &resultdummy) );
1380
1381 enoughcuts = (SCIPgetNCuts(origscip) >= 2 * (SCIP_Longint)maxcuts) || (resultdummy == SCIP_NEWROUND);
1382
1383 if( !enoughcuts )
1384 {
1385 /* separate current probing lp sol of origscip */
1386 SCIPdebugMessage("separate current LP solution\n");
1387 SCIP_CALL( SCIPseparateSol(origscip, NULL, isroot, isroot, FALSE, &delayed, &cutoff) );
1388
1389 enoughcuts = enoughcuts || (SCIPgetNCuts(origscip) >= 2 * (SCIP_Longint)maxcuts) || (resultdummy == SCIP_NEWROUND);
1390
1391 /* if we are close to the stall round limit, also call the delayed separators */
1392 if( !enoughcuts && delayed && !cutoff && nsepastallrounds >= maxnsepastallrounds-1)
1393 {
1394 SCIPdebugMessage("call delayed separators\n");
1395 SCIP_CALL( SCIPseparateSol(origscip, NULL, isroot, isroot, TRUE, &delayed, &cutoff) );
1396 }
1397 }
1398 }
1399
1400 if( !cutoff && !enoughcuts )
1401 {
1402 /* separate cuts in cutpool */
1403 SCIPdebugMessage("separate current LP sol in cutpool\n");
1404 SCIP_CALL( SCIPseparateSolCutpool(origscip, SCIPgetGlobalCutpool(origscip), NULL, isroot, &resultdummy) );
1405
1406 enoughcuts = enoughcuts || (SCIPgetNCuts(origscip) >= 2 * (SCIP_Longint)maxcuts) || (resultdummy == SCIP_NEWROUND);
1407 }
1408
1409 if( SCIPgetNCuts(origscip) == 0 && !cutoff )
1410 {
1411 /* separate cuts in delayed cutpool */
1412 SCIPdebugMessage("separate current LP sol in delayed cutpool\n");
1413 SCIP_CALL( SCIPseparateSolCutpool(origscip, SCIPgetDelayedGlobalCutpool(origscip), NULL, isroot, &resultdummy) );
1414
1415 enoughcuts = enoughcuts || (SCIPgetNCuts(origscip) >= 2 * (SCIP_Longint)maxcuts) || (resultdummy == SCIP_NEWROUND);
1416 }
1417
1418 /* if cut off is detected set result pointer and return SCIP_OKAY */
1419 if( cutoff )
1420 {
1422 SCIP_CALL( SCIPendProbing(origscip) );
1423
1424 /* disable separating again */
1426
1427 return SCIP_OKAY;
1428 }
1429
1430 /* separate cuts in cutpool */
1431 SCIP_CALL( SCIPseparateSolCutpool(origscip, SCIPgetGlobalCutpool(origscip), origsol, isroot, &resultdummy) );
1432 SCIP_CALL( SCIPseparateSolCutpool(origscip, SCIPgetDelayedGlobalCutpool(origscip), origsol, isroot, &resultdummy) );
1433
1434 assert(sepadata->norigcuts == sepadata->nmastercuts);
1435
1436 SCIPdebugMessage("%d cuts are in the original sepastore!\n", SCIPgetNCuts(origscip));
1437
1438 /* get separated cuts */
1439 cuts = SCIPgetCuts(origscip);
1440 ncuts = SCIPgetNCuts(origscip);
1441
1442 SCIP_CALL( ensureSizeCuts(scip, sepadata, sepadata->norigcuts + ncuts) );
1443
1447
1448 /* using nviolated cuts is a workaround for a SCIP issue:
1449 * it might happen that non-violated cuts are added to the sepastore,
1450 * which could lead to an infinite loop
1451 */
1452 /* initialize nviolated counting the number of cuts in the sepastore
1453 * that are violated by the current LP solution */
1454 nviolatedcuts = 0;
1455
1456 /* loop over cuts and transform cut to master problem (and safe cuts) if it seperates origsol */
1457 for( i = 0; i < ncuts; i++ )
1458 {
1459 SCIP_Bool colvarused;
1460 SCIP_Real shift;
1461
1462 colvarused = FALSE;
1463 origcut = cuts[i];
1464
1466 continue;
1467
1468 /* if cut is violated by LP solution, increase nviolatedcuts */
1469 if( SCIPisCutEfficacious(origscip, NULL, origcut) )
1470 {
1471 ++nviolatedcuts;
1472 }
1473
1474 /* get columns and vals of the cut */
1475 ncols = SCIProwGetNNonz(origcut);
1476 cols = SCIProwGetCols(origcut);
1477 vals = SCIProwGetVals(origcut);
1478
1479 /* get the variables corresponding to the columns in the cut */
1480 SCIP_CALL( SCIPallocBufferArray(scip, &roworigvars, ncols) );
1481 for( j = 0; j < ncols; j++ )
1482 {
1483 roworigvars[j] = SCIPcolGetVar(cols[j]);
1484 assert(roworigvars[j] != NULL);
1485 if( !GCGvarIsOriginal(roworigvars[j]) )
1486 {
1487 colvarused = TRUE;
1488 break;
1489 }
1490 }
1491
1492 if( colvarused )
1493 {
1494 SCIPwarningMessage(origscip, "colvar used in original cut %s\n", SCIProwGetName(origcut));
1495 SCIPfreeBufferArray(scip, &roworigvars);
1496 continue;
1497 }
1498
1499 if( !SCIPisCutEfficacious(origscip, origsol, origcut) )
1500 {
1501 if( !SCIProwIsLocal(origcut) )
1502 SCIP_CALL( SCIPaddPoolCut(origscip, origcut) );
1503
1504 SCIPfreeBufferArray(scip, &roworigvars);
1505
1506 continue;
1507 }
1508
1509 /* add the cut to the original cut storage */
1510 sepadata->origcuts[sepadata->norigcuts] = origcut;
1511 SCIP_CALL( SCIPcaptureRow(origscip, sepadata->origcuts[sepadata->norigcuts]) );
1512 sepadata->norigcuts++;
1513
1514 /* transform the original variables to master variables */
1515 shift = GCGtransformOrigvalsToMastervals(sepadata->gcg, roworigvars, vals, ncols, mastervars, mastervals, nmastervars);
1516
1517 /* create new cut in the master problem */
1518 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "mc_basis_%s", SCIProwGetName(origcut));
1519 SCIP_CALL( SCIPcreateEmptyRowSepa(scip, &mastercut, sepa, name,
1520 ( SCIPisInfinity(scip, -SCIProwGetLhs(origcut)) ?
1521 SCIProwGetLhs(origcut) : SCIProwGetLhs(origcut) - SCIProwGetConstant(origcut) - shift),
1522 ( SCIPisInfinity(scip, SCIProwGetRhs(origcut)) ?
1523 SCIProwGetRhs(origcut) : SCIProwGetRhs(origcut) - SCIProwGetConstant(origcut) - shift),
1524 SCIProwIsLocal(origcut), TRUE, FALSE) );
1525
1526 /* add master variables to the cut */
1527 SCIP_CALL( SCIPaddVarsToRow(scip, mastercut, nmastervars, mastervars, mastervals) );
1528
1529 /* add the cut to the master problem and to the master cut storage */
1530 SCIP_CALL( SCIPaddRow(scip, mastercut, sepadata->forcecuts, &infeasible) );
1531 sepadata->mastercuts[sepadata->nmastercuts] = mastercut;
1532 SCIP_CALL( SCIPcaptureRow(scip, sepadata->mastercuts[sepadata->nmastercuts]) );
1533 sepadata->nmastercuts++;
1534 SCIP_CALL( GCGsepaAddOriginalSepaCuts(gcg, origcut, mastercut) );
1535
1536 SCIP_CALL( SCIPreleaseRow(scip, &mastercut) );
1537 SCIPfreeBufferArray(scip, &roworigvars);
1538 }
1539
1540 SCIPdebugMessage("%d cuts are in the master sepastore!\n", SCIPgetNCuts(scip));
1541
1542 ++sepadata->round;
1543 ++iteration;
1544
1545 if( SCIPgetNCuts(scip) >= sepadata->mincuts )
1546 {
1548
1549 SCIPfreeBufferArray(scip, &mastervals);
1550 break;
1551 }
1552 /* use nviolated cuts instead of number of cuts in sepastore,
1553 * because non-violated might be added to the sepastore */
1554 else if( nviolatedcuts == 0 )
1555 {
1556 SCIPfreeBufferArray(scip, &mastervals);
1557 break;
1558 }
1559
1560 SCIPfreeBufferArray(scip, &mastervals);
1561
1562 assert(sepadata->norigcuts == sepadata->nmastercuts );
1563 }
1564
1565 SCIP_CALL( SCIPclearCuts(origscip) );
1566
1567 lprows = SCIPgetLPRows(origscip);
1568 nlprows = SCIPgetNLPRows(origscip);
1569
1570 assert(nlprowsstart <= nlprows);
1571
1572 SCIP_CALL( ensureSizeNewCuts(scip, sepadata, sepadata->nnewcuts + nlprows - nlprowsstart) );
1573
1574 for( i = nlprowsstart; i < nlprows; ++i )
1575 {
1577 {
1578 sepadata->newcuts[sepadata->nnewcuts] = lprows[i];
1579 SCIP_CALL( SCIPcaptureRow(origscip, sepadata->newcuts[sepadata->nnewcuts]) );
1580 ++(sepadata->nnewcuts);
1581 }
1582 }
1583
1584 /* end probing */
1585 SCIP_CALL( SCIPendProbing(origscip) );
1586
1587 if( SCIPgetNCuts(scip) > 0 )
1588 {
1590 }
1591
1592 /* disable separating again */
1594
1595 SCIPdebugMessage("exiting sepaExeclpBasis\n");
1596
1597 return SCIP_OKAY;
1598}
1599
1600/** arbitrary primal solution separation method of separator */
1601#define sepaExecsolBasis NULL
1602
1603/*
1604 * separator specific interface methods
1605 */
1606
1607/** creates the basis separator and includes it in SCIP */
1609 GCG* gcg /**< GCG data structure */
1610 )
1611{
1612 SCIP_SEPADATA* sepadata;
1615
1616 /* create master separator data */
1618
1619 sepadata->gcg = gcg;
1620 sepadata->mastercuts = NULL;
1621 sepadata->origcuts = NULL;
1622 sepadata->norigcuts = 0;
1623 sepadata->nmastercuts = 0;
1624 sepadata->maxcuts = 0;
1625 sepadata->newcuts = NULL;
1626 sepadata->nnewcuts = 0;
1627 sepadata->maxnewcuts = 0;
1628 sepadata->objrow = NULL;
1629 sepadata->round = 0;
1630 sepadata->currentnodenr = -1;
1631
1632 /* include separator */
1635 sepaCopyBasis, sepaFreeBasis, sepaInitBasis, sepaExitBasis, sepaInitsolBasis, sepaExitsolBasis, sepaExeclpBasis, sepaExecsolBasis,
1636 sepadata) );
1637
1638 /* add basis separator parameters */
1639 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/enable", "is basis separator enabled?",
1640 &(sepadata->enable), FALSE, TRUE, NULL, NULL) );
1641
1642 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/enableobj", "is objective constraint of separator enabled?",
1643 &(sepadata->enableobj), FALSE, FALSE, NULL, NULL) );
1644
1645 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/enableobjround", "round obj rhs/lhs of obj constraint if obj is int?",
1646 &(sepadata->enableobjround), FALSE, FALSE, NULL, NULL) );
1647
1648 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/enableppcuts", "add cuts generated during pricing to newconss array?",
1649 &(sepadata->enableppcuts), FALSE, FALSE, NULL, NULL) );
1650
1651 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/enableppobjconss", "is objective constraint for redcost of each pp of "
1652 "separator enabled?", &(sepadata->enableppobjconss), FALSE, FALSE, NULL, NULL) );
1653
1654 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/enableppobjcg", "is objective constraint for redcost of each pp during "
1655 "pricing of separator enabled?", &(sepadata->enableppobjcg), FALSE, FALSE, NULL, NULL) );
1656
1657 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/genobjconvex", "generated obj convex dynamically",
1658 &(sepadata->genobjconvex), FALSE, FALSE, NULL, NULL) );
1659
1660 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/enableposslack", "should positive slack influence the probing objective "
1661 "function?", &(sepadata->enableposslack), FALSE, FALSE, NULL, NULL) );
1662
1663 SCIP_CALL( SCIPaddIntParam(origprob, "sepa/" SEPA_NAME "/posslackexp", "exponent of positive slack usage",
1664 &(sepadata->posslackexp), FALSE, 1, 1, INT_MAX, NULL, NULL) );
1665
1666 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/posslackexpgen", "automatically generated exponent?",
1667 &(sepadata->posslackexpgen), FALSE, FALSE, NULL, NULL) );
1668
1669 SCIP_CALL( SCIPaddRealParam(origprob, "sepa/" SEPA_NAME "/posslackexpgenfactor", "factor for automatically generated exponent",
1672
1673 SCIP_CALL( SCIPaddRealParam(origprob, "sepa/" SEPA_NAME "/objconvex", "convex combination factor (= 0.0, use original objective; = 1.0, use face objective)",
1674 &(sepadata->objconvex), FALSE, 0.0, 0.0, 1.0, NULL, NULL) );
1675
1676 SCIP_CALL( SCIPaddIntParam(origprob, "sepa/" SEPA_NAME "/paramsetting", "parameter returns which parameter setting is used for "
1677 "separation (default = 0, aggressive = 1, fast = 2", &(sepadata->separationsetting), FALSE, 0, 0, 2, NULL, NULL) );
1678
1679 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/chgobj", "parameter returns if basis is searched with different objective",
1680 &(sepadata->chgobj), FALSE, TRUE, NULL, NULL) );
1681
1682 SCIP_CALL( SCIPaddIntParam(origprob, "sepa/" SEPA_NAME "/maxrounds", "parameter returns maximum number of separation rounds in probing LP (-1 if unlimited)",
1683 &(sepadata->maxrounds), FALSE, -1, -1, INT_MAX , NULL, NULL) );
1684
1685 SCIP_CALL( SCIPaddIntParam(origprob, "sepa/" SEPA_NAME "/maxroundsroot", "parameter returns maximum number of separation rounds in probing LP in root node (-1 if unlimited)",
1686 &(sepadata->maxroundsroot), FALSE, -1, -1, INT_MAX , NULL, NULL) );
1687
1688 SCIP_CALL( SCIPaddIntParam(origprob, "sepa/" SEPA_NAME "/mincuts", "parameter returns number of minimum cuts needed to "
1689 "return *result = SCIP_Separated", &(sepadata->mincuts), FALSE, 50, 1, INT_MAX, NULL, NULL) );
1690
1691 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/chgobjallways", "parameter returns if obj is changed not only in the "
1692 "first round", &(sepadata->chgobjallways), FALSE, FALSE, NULL, NULL) );
1693
1694 SCIP_CALL( SCIPaddBoolParam(origprob, "sepa/" SEPA_NAME "/forcecuts", "parameter returns if cuts are forced to enter the LP ",
1695 &(sepadata->forcecuts), FALSE, FALSE, NULL, NULL) );
1696
1697 return SCIP_OKAY;
1698}
1699
1700
1701/** returns the array of original cuts saved in the separator data */
1703 GCG* gcg /**< GCG data structure */
1704 )
1705{
1706 SCIP_SEPA* sepa;
1707 SCIP_SEPADATA* sepadata;
1708
1709 assert(gcg != NULL);
1710
1712 assert(sepa != NULL);
1713
1714 sepadata = SCIPsepaGetData(sepa);
1715 assert(sepadata != NULL);
1716
1717 return sepadata->origcuts;
1718}
1719
1720/** returns the number of original cuts saved in the separator data */
1722 GCG* gcg /**< GCG data structure */
1723 )
1724{
1725 SCIP_SEPA* sepa;
1726 SCIP_SEPADATA* sepadata;
1727
1728 assert(gcg != NULL);
1729
1731 assert(sepa != NULL);
1732
1733 sepadata = SCIPsepaGetData(sepa);
1734 assert(sepadata != NULL);
1735
1736 return sepadata->norigcuts;
1737}
1738
1739/** returns the array of master cuts saved in the separator data */
1741 GCG* gcg /**< GCG data structure */
1742 )
1743{
1744 SCIP_SEPA* sepa;
1745 SCIP_SEPADATA* sepadata;
1746
1747 assert(gcg != NULL);
1748
1750 assert(sepa != NULL);
1751
1752 sepadata = SCIPsepaGetData(sepa);
1753 assert(sepadata != NULL);
1754
1755 return sepadata->mastercuts;
1756}
1757
1758/** returns the number of master cuts saved in the separator data */
1760 GCG* gcg /**< GCG data structure */
1761 )
1762{
1763 SCIP_SEPA* sepa;
1764 SCIP_SEPADATA* sepadata;
1765
1766 assert(gcg != NULL);
1767
1769 assert(sepa != NULL);
1770
1771 sepadata = SCIPsepaGetData(sepa);
1772 assert(sepadata != NULL);
1773
1774 return sepadata->nmastercuts;
1775}
1776
1777/** transforms cut in pricing variables to cut in original variables and adds it to newcuts array */
1779 GCG* gcg,
1780 int ppnumber,
1781 SCIP_ROW* cut
1782 )
1783{
1785 SCIP* origprob;
1786 SCIP_SEPA* sepa;
1787 SCIP_SEPADATA* sepadata;
1788
1789 SCIP* pricingprob;
1790 SCIP_Real* vals;
1791 SCIP_COL** cols;
1792 SCIP_VAR** pricingvars;
1793 int nvars;
1794
1795 int i;
1796 int j;
1797 int k;
1798
1799 char name[SCIP_MAXSTRLEN];
1800
1803
1804 if( sepa == NULL )
1805 {
1806 SCIPerrorMessage("sepa basis not found\n");
1807 return SCIP_OKAY;
1808 }
1809
1810 sepadata = SCIPsepaGetData(sepa);
1812 masterprob = GCGgetMasterprob(sepadata->gcg);
1813 pricingprob = GCGgetPricingprob(gcg, ppnumber);
1814
1815 if( !sepadata->enableppcuts )
1816 {
1817 return SCIP_OKAY;
1818 }
1819
1820 assert(!SCIProwIsLocal(cut));
1821
1822 nvars = SCIProwGetNNonz(cut);
1823 cols = SCIProwGetCols(cut);
1824 vals = SCIProwGetVals(cut);
1825
1826 if( nvars == 0 )
1827 {
1828 return SCIP_OKAY;
1829 }
1830
1832
1833 for( i = 0; i < nvars; ++i )
1834 {
1835 pricingvars[i] = SCIPcolGetVar(cols[i]);
1836 assert(pricingvars[i] != NULL);
1837 }
1838
1839 for( k = 0; k < GCGgetNIdenticalBlocks(gcg, ppnumber); ++k )
1840 {
1841 SCIP_ROW* origcut;
1842
1843 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "ppcut_%d_%d_%d", SCIPsepaGetNCalls(sepa), ppnumber, k);
1844
1846 ( SCIPisInfinity(pricingprob, -SCIProwGetLhs(cut)) ?
1848 ( SCIPisInfinity(pricingprob, SCIProwGetRhs(cut)) ?
1850 FALSE, FALSE, TRUE) );
1851
1852 for( j = 0; j < nvars ; ++j )
1853 {
1854 SCIP_VAR* var;
1855
1856 if( !GCGvarIsPricing(pricingvars[j]) )
1857 {
1858 nvars = 0;
1859 break;
1860 }
1861 assert(GCGvarIsPricing(pricingvars[j]));
1862
1863 var = GCGpricingVarGetOrigvars(pricingvars[j])[k];
1864 assert(var != NULL);
1865
1866 SCIP_CALL( SCIPaddVarToRow(origprob, origcut, var, vals[j]) );
1867 }
1868
1869 if( nvars > 0 )
1870 {
1871 SCIP_CALL( ensureSizeNewCuts(masterprob, sepadata, sepadata->nnewcuts + 1) );
1872
1873 sepadata->newcuts[sepadata->nnewcuts] = origcut;
1874 SCIP_CALL( SCIPcaptureRow(masterprob, sepadata->newcuts[sepadata->nnewcuts]) );
1875 ++(sepadata->nnewcuts);
1876
1877 SCIPdebugMessage("cut added to orig cut pool\n");
1878 }
1879 SCIP_CALL( SCIPreleaseRow(origprob, &origcut) );
1880 }
1881
1882 SCIPfreeBufferArray(masterprob, &pricingvars);
1883
1884 return SCIP_OKAY;
1885}
1886
1887/** add cuts which are due to the latest objective function of the pricing problems
1888 * (reduced cost non-negative) */
1890 GCG* gcg, /**< GCG data structure */
1891 int ppnumber, /**< number of pricing problem */
1892 SCIP_Real dualsolconv, /**< dual solution corresponding to convexity constraint */
1893 SCIP_Bool newcuts /**< add cut to newcuts in sepadata? (otherwise add it just to the cutpool) */
1894)
1895{
1896 SCIP_SEPA* sepa;
1897
1899
1900 if( sepa == NULL )
1901 {
1902 SCIPerrorMessage("sepa basis not found\n");
1903 return SCIP_OKAY;
1904 }
1905
1906 SCIP_CALL( addPPObjConss(gcg, sepa, ppnumber, dualsolconv, newcuts, FALSE) );
1907
1908 return SCIP_OKAY;
1909}
#define SCIP_MAXSTRLEN
#define SCIP_Longint
#define SCIP_Bool
#define MIN(x, y)
#define SCIP_Real
#define MAX(x, y)
#define SCIP_REAL_MIN
#define TRUE
#define FALSE
#define STARTMAXCUTS
GCG interface methods.
SCIP_Bool GCGvarIsOriginal(SCIP_VAR *var)
Definition gcgvar.c:231
SCIP_VAR ** GCGpricingVarGetOrigvars(SCIP_VAR *var)
Definition gcgvar.c:1100
SCIP_RETCODE GCGsetPricingObjs(GCG *gcg, SCIP_Real *dualsolconv)
GCG_EXPORT SCIP * GCGgetPricingprob(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4075
GCG_EXPORT int GCGgetNRelPricingprobs(GCG *gcg)
Definition relax_gcg.c:4095
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
GCG_EXPORT int GCGgetNIdenticalBlocks(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4185
GCG_EXPORT int GCGgetNPricingprobs(GCG *gcg)
Definition relax_gcg.c:4113
SCIP * GCGgetMasterprob(GCG *gcg)
Definition gcg.cpp:99
SCIP_Real GCGtransformOrigvalsToMastervals(GCG *gcg, SCIP_VAR **origvars, SCIP_Real *origvals, int norigvars, SCIP_VAR **mastervars, SCIP_Real *mastervals, int nmastervars)
Definition misc.c:576
GCG_EXPORT SCIP_Bool GCGisPricingprobRelevant(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4132
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_Real SCIPgetObjNorm(SCIP *scip)
int SCIPgetNOrigVars(SCIP *scip)
SCIP_Bool SCIPisObjIntegral(SCIP *scip)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
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)
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)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
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)
SCIP_RETCODE SCIPgetIntParam(SCIP *scip, const char *name, int *value)
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
int SCIPcolGetIndex(SCIP_COL *col)
SCIP_Real SCIPcolGetLb(SCIP_COL *col)
SCIP_Real SCIPcolGetUb(SCIP_COL *col)
SCIP_RETCODE SCIPseparateSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool pretendroot, SCIP_Bool allowlocal, SCIP_Bool onlydelayed, SCIP_Bool *delayed, SCIP_Bool *cutoff)
SCIP_RETCODE SCIPaddPoolCut(SCIP *scip, SCIP_ROW *row)
SCIP_Bool SCIPisCutEfficacious(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
SCIP_CUTPOOL * SCIPgetGlobalCutpool(SCIP *scip)
SCIP_RETCODE SCIPseparateSolCutpool(SCIP *scip, SCIP_CUTPOOL *cutpool, SCIP_SOL *sol, SCIP_Bool pretendroot, SCIP_RESULT *result)
SCIP_CUTPOOL * SCIPgetDelayedGlobalCutpool(SCIP *scip)
SCIP_RETCODE SCIPaddRow(SCIP *scip, SCIP_ROW *row, SCIP_Bool forcecut, SCIP_Bool *infeasible)
SCIP_ROW ** SCIPgetCuts(SCIP *scip)
SCIP_RETCODE SCIPclearCuts(SCIP *scip)
int SCIPgetNCuts(SCIP *scip)
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
SCIP_ROW ** SCIPgetLPRows(SCIP *scip)
int SCIPgetNLPRows(SCIP *scip)
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
SCIP_COL ** SCIPgetLPCols(SCIP *scip)
SCIP_Real SCIPgetLPObjval(SCIP *scip)
int SCIPgetNLPCols(SCIP *scip)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
SCIP_RETCODE SCIPaddRowProbing(SCIP *scip, SCIP_ROW *row)
SCIP_RETCODE SCIPapplyCutsProbing(SCIP *scip, SCIP_Bool *cutoff)
SCIP_RETCODE SCIPchgVarObjProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
SCIP_Bool SCIPinProbing(SCIP *scip)
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
SCIP_Real SCIPgetVarObjProbing(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPnewProbingNode(SCIP *scip)
SCIP_RETCODE SCIPsolveProbingLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
SCIP_RETCODE SCIPendProbing(SCIP *scip)
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
SCIP_RETCODE SCIPchgRowLhs(SCIP *scip, SCIP_ROW *row, SCIP_Real lhs)
int SCIProwGetNNonz(SCIP_ROW *row)
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
SCIP_Real SCIProwGetNorm(SCIP_ROW *row)
int SCIProwGetLPPos(SCIP_ROW *row)
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
const char * SCIProwGetName(SCIP_ROW *row)
SCIP_RETCODE SCIPcaptureRow(SCIP *scip, SCIP_ROW *row)
SCIP_Real SCIPgetRowSolFeasibility(SCIP *scip, SCIP_ROW *row, SCIP_SOL *sol)
SCIP_RETCODE SCIPreleaseRow(SCIP *scip, SCIP_ROW **row)
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)
SCIP_RETCODE SCIPcreateEmptyRowUnspec(SCIP *scip, SCIP_ROW **row, const char *name, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool removable)
SCIP_RETCODE SCIPchgRowRhs(SCIP *scip, SCIP_ROW *row, SCIP_Real rhs)
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
SCIP_RETCODE SCIPaddVarsToRow(SCIP *scip, SCIP_ROW *row, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
SCIP_ROWORIGINTYPE SCIProwGetOrigintype(SCIP_ROW *row)
SCIP_Real SCIPgetRowSolActivity(SCIP *scip, SCIP_ROW *row, SCIP_SOL *sol)
SCIP_SEPA * SCIPfindSepa(SCIP *scip, const char *name)
SCIP_RETCODE SCIPincludeSepa(SCIP *scip, const char *name, const char *desc, int priority, int freq, SCIP_Real maxbounddist, SCIP_Bool usessubscip, SCIP_Bool delay, SCIP_DECL_SEPACOPY((*sepacopy)), SCIP_DECL_SEPAFREE((*sepafree)), SCIP_DECL_SEPAINIT((*sepainit)), SCIP_DECL_SEPAEXIT((*sepaexit)), SCIP_DECL_SEPAINITSOL((*sepainitsol)), SCIP_DECL_SEPAEXITSOL((*sepaexitsol)), SCIP_DECL_SEPAEXECLP((*sepaexeclp)), SCIP_DECL_SEPAEXECSOL((*sepaexecsol)), SCIP_SEPADATA *sepadata)
SCIP_SEPADATA * SCIPsepaGetData(SCIP_SEPA *sepa)
SCIP_Longint SCIPsepaGetNCalls(SCIP_SEPA *sepa)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPepsilon(SCIP *scip)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasPositive(SCIP *scip, SCIP_Real val)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
SCIP_NODE * SCIPgetRootNode(SCIP *scip)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_Bool SCIPsortedvecFindInt(int *intarray, int val, int len, int *pos)
void SCIPsortInt(int *intarray, int len)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIP_Bool GCGvarIsPricing(SCIP_VAR *var)
Definition gcgvar.c:159
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIP * origprob
* result
SCIP_VAR * var
SCIP_VAR ** vars
int nfracs
int j
SCIP_Real solval
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
int i
SCIP_Real objfactor
int nvars
SCIPfreeBufferArray(scip, &cycles)
int nlprows
SCIP_ROW ** lprows
SCIP_SOL * sol
SCIP_Real obj
SCIP_VAR ** mastervars
int nmastervars
SCIP_Bool lperror
SCIP_Bool cutoff
#define NULL
signum
GCG variable pricer.
public methods for GCG variables
#define SCIPerrorMessage
SCIP_RETCODE GCGrelaxUpdateCurrentSol(GCG *gcg)
Definition relax_gcg.c:4964
SCIP_SOL * GCGrelaxGetCurrentOrigSol(GCG *gcg)
Definition relax_gcg.c:4309
SCIP_Bool GCGrelaxIsOrigSolFeasible(GCG *gcg)
Definition relax_gcg.c:4328
GCG relaxator.
static SCIP_RETCODE initGenconv(SCIP *origscip, SCIP_SEPADATA *sepadata, SCIP_SOL *origsol, int nbasis, SCIP_Real *convex)
Definition sepa_basis.c:971
#define SEPA_PRIORITY
Definition sepa_basis.c:60
static SCIP_DECL_SEPAFREE(sepaFreeBasis)
Definition sepa_basis.c:814
SCIP_ROW ** GCGsepaBasisGetMastercuts(GCG *gcg)
#define SEPA_DELAY
Definition sepa_basis.c:64
static SCIP_DECL_SEPAINIT(sepaInitBasis)
Definition sepa_basis.c:828
SCIP_RETCODE GCGsepaBasisAddPricingCut(GCG *gcg, int ppnumber, SCIP_ROW *cut)
static SCIP_RETCODE initProbingObjWithOrigObj(SCIP *origscip, SCIP_Bool enableobj, SCIP_Real objfactor)
Definition sepa_basis.c:190
#define sepaCopyBasis
Definition sepa_basis.c:810
#define sepaExecsolBasis
#define SEPA_DESC
Definition sepa_basis.c:59
static SCIP_RETCODE chgProbingObjUsingRows(SCIP *origscip, SCIP_SEPADATA *sepadata, SCIP_SOL *origsol, SCIP_Real objfactor, SCIP_Real objdivisor)
Definition sepa_basis.c:364
static SCIP_RETCODE ensureSizeNewCuts(SCIP *scip, SCIP_SEPADATA *sepadata, int size)
Definition sepa_basis.c:144
static SCIP_Real exponentiate(SCIP_Real basis, int exponent)
Definition sepa_basis.c:169
#define SEPA_USESSUBSCIP
Definition sepa_basis.c:63
int GCGsepaBasisGetNMastercuts(GCG *gcg)
static SCIP_RETCODE initConvObj(SCIP *origscip, SCIP_SEPADATA *sepadata, SCIP_SOL *origsol, SCIP_Real convex, SCIP_Bool genericconv)
SCIP_RETCODE SCIPsepaBasisAddPPObjConss(GCG *gcg, int ppnumber, SCIP_Real dualsolconv, SCIP_Bool newcuts)
int GCGsepaBasisGetNOrigcuts(GCG *gcg)
static SCIP_DECL_SEPAEXITSOL(sepaExitsolBasis)
Definition sepa_basis.c:949
#define SEPA_MAXBOUNDDIST
Definition sepa_basis.c:62
SCIP_ROW ** GCGsepaBasisGetOrigcuts(GCG *gcg)
#define SEPA_FREQ
Definition sepa_basis.c:61
static SCIP_DECL_SEPAINITSOL(sepaInitsolBasis)
Definition sepa_basis.c:934
#define SEPA_NAME
Definition sepa_basis.c:58
static SCIP_RETCODE chgProbingObjAddingOrigObj(SCIP *origscip, SCIP_Real objfactor, SCIP_Real objdivisor)
Definition sepa_basis.c:228
static SCIP_DECL_SEPAEXIT(sepaExitBasis)
Definition sepa_basis.c:895
static SCIP_RETCODE ensureSizeCuts(SCIP *scip, SCIP_SEPADATA *sepadata, int size)
Definition sepa_basis.c:115
static SCIP_RETCODE addPPObjConss(GCG *gcg, SCIP_SEPA *sepa, int ppnumber, SCIP_Real dualsolconv, SCIP_Bool newcuts, SCIP_Bool probing)
Definition sepa_basis.c:711
SCIP_RETCODE GCGincludeSepaBasis(GCG *gcg)
static SCIP_RETCODE initProbingObjUsingVarBounds(SCIP *origscip, SCIP_SEPADATA *sepadata, SCIP_SOL *origsol, SCIP_Bool enableobj, SCIP_Real objfactor)
Definition sepa_basis.c:266
basis separator
SCIP_ROW ** GCGsepaGetOriginalSepaOrigcuts(GCG *gcg)
SCIP_RETCODE GCGsepaAddOriginalSepaCuts(GCG *gcg, SCIP_ROW *origcut, SCIP_ROW *mastercut)
SCIP_Bool GCGsepaOriginalSepaOrigcutExists(GCG *gcg, SCIP_ROW *origcut)
int GCGsepaGetNOriginalSepaCuts(GCG *gcg)
original separator
SCIP_Bool enableobj
Definition sepa_basis.c:89
SCIP_ROW ** newcuts
Definition sepa_basis.c:82
SCIP_Bool enableppobjconss
Definition sepa_basis.c:92
SCIP_Bool enableobjround
Definition sepa_basis.c:90
SCIP_Bool posslackexpgen
Definition sepa_basis.c:101
SCIP_ROW * objrow
Definition sepa_basis.c:87
SCIP_Real objconvex
Definition sepa_basis.c:106
SCIP_Bool forcecuts
Definition sepa_basis.c:99
SCIP_Bool enableppcuts
Definition sepa_basis.c:91
SCIP_Bool enableposslack
Definition sepa_basis.c:98
SCIP_Bool enable
Definition sepa_basis.c:88
SCIP_Bool chgobj
Definition sepa_basis.c:95
SCIP_Bool chgobjallways
Definition sepa_basis.c:96
SCIP_Bool genobjconvex
Definition sepa_basis.c:97
SCIP_Bool enableppobjcg
Definition sepa_basis.c:93
int separationsetting
Definition sepa_basis.c:94
SCIP_ROW ** origcuts
Definition sepa_basis.c:78
SCIP_ROW ** mastercuts
Definition sepa_basis.c:77
SCIP_Real posslackexpgenfactor
Definition sepa_basis.c:102
struct Gcg GCG
Definition type_gcg.h:44
struct SCIP_Row SCIP_ROW
enum SCIP_LPSolStat SCIP_LPSOLSTAT
SCIP_ROWORIGINTYPE_SEPA
struct SCIP_Col SCIP_COL
SCIP_LPSOLSTAT_NOTSOLVED
SCIP_LPSOLSTAT_OPTIMAL
SCIP_LPSOLSTAT_OBJLIMIT
SCIP_PARAMSETTING_OFF
enum SCIP_ParamSetting SCIP_PARAMSETTING
SCIP_DIDNOTRUN
SCIP_CUTOFF
SCIP_DIDNOTFIND
SCIP_SEPARATED
SCIP_NEWROUND
enum SCIP_Result SCIP_RESULT
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
struct SCIP_SepaData SCIP_SEPADATA
#define SCIP_DECL_SEPAEXECLP(x)
struct SCIP_Sepa SCIP_SEPA
struct SCIP_Sol SCIP_SOL
struct SCIP_Var SCIP_VAR