GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
relax_gcg.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 relax_gcg.c
30 *
31 * @brief GCG relaxator
32 * @author Gerald Gamrath
33 * @author Martin Bergner
34 * @author Alexander Gross
35 * @author Michael Bastubbe
36 * @author Erik Muehmer
37 *
38 * \bug
39 * - The memory limit is not strictly enforced
40 * - Dealing with timelimits is a working hack only
41 * - CTRL-C handling is very flaky
42 */
43
44/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
45
46//#define SCIP_DEBUG
47
48#include <string.h>
49#ifdef _OPENMP
50#include <omp.h>
51#include "gcg/struct_locks.h"
52#endif
53#include "gcg/type_locks.h"
54
55#include "scip/scipdefplugins.h"
56#include "scip/cons_linear.h"
57#include "scip/cons_setppc.h"
58#include "scip/scip.h"
59#include "scip/misc.h"
60#include "scip/clock.h"
61
62#include "gcg/relax_gcg.h"
63#include "gcg/gcg.h"
64#include "gcg/struct_gcg.h"
66#include "gcg/struct_sepagcg.h"
67
69#include "gcg/cons_origbranch.h"
71#include "gcg/pricer_gcg.h"
72#include "gcg/benders_gcg.h"
73#include "gcg/masterplugins.h"
74#include "gcg/bendersplugins.h"
75#include "gcg/cons_decomp.h"
76#include "gcg/scip_misc.h"
77#include "gcg/solver_knapsack.h"
78
79#include "gcg/params_visu.h"
80
81#ifndef NO_AUT_LIB
84#endif
85
86#define RELAX_NAME "gcg"
87#define RELAX_DESC "relaxator for gcg project representing the master lp"
88#define RELAX_PRIORITY -1
89#define RELAX_FREQ 1
90#define RELAX_INCLUDESLP TRUE
91
92#define DEFAULT_DISCRETIZATION TRUE
93#define DEFAULT_MIPDISCRETIZATION TRUE
94#define DEFAULT_AGGREGATION TRUE
95#define DEFAULT_DISPINFOS FALSE
96#define DEFAULT_MODE GCG_DECMODE_DANTZIGWOLFE /**< the decomposition mode that GCG will use. (0: Dantzig-Wolfe (default),
97 1: Benders' decomposition, 2: solve original problem) */
98#define DEFAULT_BLISS TRUE
99#define DEFAULT_BLISS_SEARCH_NODE_LIMIT 0
100#define DEFAULT_BLISS_GENERATOR_LIMIT 100
101#define DEFAULT_AGGREGATIONNCONSSLIMIT 300
102#define DEFAULT_AGGREGATIONNVARSLIMIT 300
103
104#define DELVARS
105
106/*
107 * Data structures
108 */
109
110/** relaxator data */
111
113{
114 /* problems and convexity constraints */
115 GCG* gcg; /**< GCG data structure */
116 SCIP** pricingprobs; /**< the array of pricing problems */
117 int npricingprobs; /**< the number of pricing problems */
118 int maxpricingprobs; /**< capacity of pricingprobs */
119 int nrelpricingprobs; /**< the number of relevant pricing problems */
120 int* blockrepresentative;/**< number of the pricing problem, that represents the i-th problem */
121 int* nblocksidentical; /**< number of pricing blocks represented by the i-th pricing problem */
122 SCIP_CONS** convconss; /**< array of convexity constraints, one for each block */
123 int ntransvars; /**< number of variables directly transferred to the master problem */
124 int nlinkingvars; /**< number of linking variables */
125 int nvarlinkconss; /**< number of constraints that ensure that copies of linking variables have the same value */
126 SCIP_Real pricingprobsmemused; /**< sum of memory used after problem creation stage of all pricing problems */
127
128 /* constraint data */
129 SCIP_CONS** masterconss; /**< array of constraints in the master problem */
130 SCIP_CONS** origmasterconss; /**< array of constraints in the original problem that belong to the
131 * master problem */
132 SCIP_CONS** linearmasterconss; /**< array of linear constraints equivalent to the cons in
133 * the original problem that belong to the master problem */
134 SCIP_CONS** varlinkconss; /**< array of constraints ensuring linking vars equality */
135 int* varlinkconsblock; /**< array of constraints ensuring linking vars equality */
136 int maxmasterconss; /**< length of the array mastercons */
137 int nmasterconss; /**< number of constraints saved in mastercons */
138
139 SCIP_SOL* currentorigsol; /**< current lp solution transformed into the original space */
140 SCIP_Bool origsolfeasible; /**< is the current lp solution primal feasible in the original space? */
141 SCIP_Longint lastmasterlpiters; /**< number of lp iterations when currentorigsol was updated the last time */
142 SCIP_Longint lastmasternode; /**< number of current node when currentorigsol was updated the last time */
143 SCIP_SOL* lastmastersol; /**< last feasible master solution that was added to the original problem */
144 SCIP_CONS** markedmasterconss; /**< array of conss that are marked to be in the master */
145 int nmarkedmasterconss; /**< number of elements in array of conss that are marked to be in the master */
146 int maxmarkedmasterconss; /**< capacity of markedmasterconss */
147 SCIP_Longint lastsolvednodenr; /**< node number of the node that was solved at the last call of the relaxator */
148
149 /* branchrule data */
150 GCG_BRANCHRULE** branchrules; /**< branching rules registered in the relaxator */
151 int nbranchrules; /**< number of branching rules registered in the relaxator */
152 GCG_BRANCHRULE** activebranchrules; /**< branching rules that created extended master conss (cache) */
153 GCG_BRANCHDATA** activebranchdata; /**< data represeting the branching decisions of the active nodes (cache) */
154 GCG_EXTENDEDMASTERCONSDATA** activebranchextendedmasterconss; /**< array of extended master conss that are active in the current node (cache) */
155 int nactivebranchextendedmasterconss; /**< number of extended master conss that are active in the current node */
156 int maxactivebranchextendedmasterconss; /**< capacity of activebranchextendedmasterconss */
157
158 /* parameter data */
159 SCIP_Bool discretization; /**< TRUE: use discretization approach; FALSE: use convexification approach */
160 SCIP_Bool mipdiscretization; /**< TRUE: use discretization approach in MIPs; FALSE: use convexification approach in MIPs*/
161 SCIP_Bool aggregation; /**< should identical blocks be aggregated (only for discretization approach)? */
162 SCIP_Bool masterissetpart; /**< is the master a set partitioning problem? */
163 SCIP_Bool masterissetcover; /**< is the master a set covering problem? */
164 SCIP_Bool dispinfos; /**< should additional information be displayed? */
165 GCG_DECMODE mode; /**< the decomposition mode for GCG. 0: Dantzig-Wolfe (default), 1: Benders' decomposition, 2: automatic */
166 int origverblevel; /**< the verbosity level of the original problem */
167 SCIP_Bool usesymmetrylib; /**< should symmetry detection lib be used to check for identical blocks? */
168 int searchnodelimit; /**< bliss search node limit (requires patched bliss version) */
169 int generatorlimit; /**< bliss generator limit (requires patched bliss version) */
170 int aggregationnconsslimit; /**< if this limit on the number of constraints of a block is exceeded the aggregation information for this block is not calculated */
171 int aggregationnvarslimit; /**< if this limit on the number of variables of a block is exceeded the aggregation information for this block is not calculated */
172
173 /* data for probing */
174 SCIP_Bool masterinprobing; /**< is the master problem in probing mode? */
175 SCIP_HEUR* probingheur; /**< heuristic that started probing in master problem, or NULL */
176 SCIP_SOL* storedorigsol; /**< original solution that was stored before the probing */
177 SCIP_Bool storedfeasibility; /**< is the stored original solution feasible? */
178
179 /* structure information */
180 GCG_DECOMP* decomp; /**< structure information */
181 SCIP_Bool relaxisinitialized; /**< indicates whether the relaxator is initialized */
182
183 /* statistical information */
184 SCIP_Longint simplexiters; /**< cumulative simplex iterations */
185 SCIP_CLOCK* rootnodetime; /**< time in root node */
186
187 /* visualization parameter */
188 GCG_PARAMDATA* paramsvisu; /**< parameters for visualization */
189
190 /* stashed limit settings */
191 SCIP_Bool limitsettingsstashed; /**< are limit settings currently stashed? */
192 SCIP_Longint stashednodelimit; /**< stashed node limit */
193 SCIP_Longint stashedstallnodelimit; /**< stashed stalling node limit */
194 SCIP_Real stashedgaplimit; /**< stashed gap limit */
195 int stashedsollimit; /**< stashed solution limit */
196 SCIP_Real stashedtimelimit; /**< stashed time limit */
197
198 /* separator data*/
199 GCG_SEPA** separators; /**< separators registered to the relaxator */
200 int nseparators; /**< number of separators registered to the relaxator */
201
202#ifdef _OPENMP
203 GCG_LOCKS* locks; /** OpenMP locks */
204#endif
205};
206
207
208/*
209 * Local methods
210 */
211
212/** add the activated branch node's extended master cons to the cache */
213static
215 GCG* gcg, /**< GCG data structure */
216 SCIP_RELAXDATA* relaxdata, /**< relaxator data data structure */
217 GCG_BRANCHRULE* branchrule, /**< branchrule that was activated */
218 GCG_BRANCHDATA* branchdata /**< branchdata that was activated */
219 )
220{
221 GCG_EXTENDEDMASTERCONSDATA* extendedmasterconsdata;
223
224 assert(origprob != NULL);
225 assert(relaxdata != NULL);
226 assert(branchrule != NULL);
227 assert(branchdata != NULL);
228
229 /* add only if branch creates an extended master cons */
230 extendedmasterconsdata = NULL;
231 if( branchrule->branchgetextendedmastercons == NULL )
232 return SCIP_OKAY;
233 SCIP_CALL( branchrule->branchgetextendedmastercons(gcg, branchdata, &extendedmasterconsdata) );
234 if( extendedmasterconsdata == NULL )
235 return SCIP_OKAY;
236
237 if( relaxdata->maxactivebranchextendedmasterconss == 0 )
238 {
243 }
244 else
246 {
247 int newsize;
252 relaxdata->maxactivebranchextendedmasterconss = newsize;
253 }
255 assert(relaxdata->activebranchrules != NULL);
256 assert(relaxdata->activebranchdata != NULL);
258
259 relaxdata->activebranchrules[relaxdata->nactivebranchextendedmasterconss] = branchrule;
260 relaxdata->activebranchdata[relaxdata->nactivebranchextendedmasterconss] = branchdata;
261 relaxdata->activebranchextendedmasterconss[relaxdata->nactivebranchextendedmasterconss] = extendedmasterconsdata;
263
264 return SCIP_OKAY;
265}
266
267/** drop the most recently added branch extended master cons data */
268static
270 GCG* gcg, /**< GCG data structure */
271 SCIP_RELAXDATA* relaxdata, /**< relaxator data data structure */
272 GCG_BRANCHRULE* branchrule, /**< branchrule that was deactivated */
273 GCG_BRANCHDATA* branchdata /**< branchdata that was deactivated */
274 )
275{
276 assert(gcg != NULL);
277 assert(relaxdata != NULL);
278
279 if( relaxdata->nactivebranchextendedmasterconss == 0 )
280 return SCIP_OKAY;
281
282 /* drop only if branch created an extended master cons */
283 if( relaxdata->activebranchrules[relaxdata->nactivebranchextendedmasterconss-1] != branchrule
284 || relaxdata->activebranchdata[relaxdata->nactivebranchextendedmasterconss-1] != branchdata )
285 return SCIP_OKAY;
286
290
291 return SCIP_OKAY;
292}
293
294/** sets the number of the block, the given original variable belongs to */
295static
297 GCG* gcg, /**< GCG data structure */
298 SCIP_RELAXDATA* relaxdata, /**< relaxator data data structure */
299 SCIP_VAR* var, /**< variable to set the block number for */
300 int newblock /**< number of the block, the variable belongs to */
301 )
302{
303 int blocknr;
304
305 assert(gcg != NULL);
306 assert(var != NULL);
307 assert(newblock >= 0 || (GCGgetDecompositionMode(relaxdata->gcg) == GCG_DECMODE_BENDERS && newblock == -2));
308
310 assert(relaxdata != NULL);
311
312 blocknr = GCGvarGetBlock(var);
314
315 assert(relaxdata->npricingprobs > 0);
316 assert(newblock < relaxdata->npricingprobs);
317 assert(blocknr >= -2 && blocknr < relaxdata->npricingprobs);
318
319 /* var belongs to no block so far, just set the new block number */
320 if( blocknr == -1 )
321 {
322 assert(newblock >= 0);
323 GCGvarSetBlock(var, newblock);
324 }
325 /* if var already belongs to another block, it is a linking variable */
326 else if( blocknr != newblock )
327 {
328 SCIP_CALL( GCGoriginalVarAddBlock(gcg, var, newblock, relaxdata->npricingprobs, relaxdata->mode) );
329 assert(newblock == -2 || GCGisLinkingVarInBlock(var, newblock));
331 }
332 blocknr = GCGvarGetBlock(var);
333 assert(blocknr == -2 || blocknr == newblock);
334
335 return SCIP_OKAY;
336}
337
338/** marks the constraint to be transferred to the master problem */
339static
341 GCG* gcg, /**< GCG data structure */
342 SCIP_RELAXDATA* relaxdata, /**< relaxator data data structure */
343 SCIP_CONS* cons /**< constraint that is forced to be in the master */
344 )
345{
346 SCIP* scip;
347#ifndef NDEBUG
348 int i;
349#endif
350 assert(gcg != NULL);
351 assert(cons != NULL);
352 assert(relaxdata != NULL);
353
355
356 /* allocate array, if not yet done */
357 if( relaxdata->markedmasterconss == NULL )
358 {
361 relaxdata->nmarkedmasterconss = 0;
362 }
364
365#ifndef NDEBUG
366 /* check that constraints are not marked more than one time */
367 for( i = 0; i < relaxdata->nmarkedmasterconss; i++ )
368 assert(relaxdata->markedmasterconss[i] != cons);
369#endif
370
371 /* save constraint */
372 relaxdata->markedmasterconss[relaxdata->nmarkedmasterconss] = cons;
373 relaxdata->nmarkedmasterconss++;
374
375 return SCIP_OKAY;
376}
377
378
379/** converts the structure to the GCG format by setting the appropriate blocks and master constraints */
380static
382 GCG* gcg, /**< GCG data structure */
383 SCIP_RELAXDATA* relaxdata, /**< relaxator data structure */
384 GCG_DECOMP* decomp /**< decomp data structure */
385 )
386{
387 SCIP* origprob;
388 int i;
389 int j;
390 int k;
391 int v;
392 int nblocks;
393 int nvars;
394 SCIP_VAR** origvars;
395 SCIP_HASHMAP* transvar2origvar;
396 SCIP_CONS** linkingconss;
397 int nlinkingconss;
398 SCIP_VAR** linkingvars;
399 int nlinkingvars;
400 SCIP_VAR*** subscipvars;
401 int* nsubscipvars;
402 SCIP_CONS*** subscipconss;
403 int* nsubscipconss;
404
405 assert(decomp != NULL);
406 assert(relaxdata != NULL);
407 assert(gcg != NULL);
408
411
412
415
417
418 origvars = SCIPgetVars(origprob);
420 linkingconss = GCGdecompGetLinkingconss(decomp);
421 nlinkingconss = GCGdecompGetNLinkingconss(decomp);
422 linkingvars = GCGdecompGetLinkingvars(decomp);
423 nlinkingvars = GCGdecompGetNLinkingvars(decomp);
424 subscipvars = GCGdecompGetSubscipvars(decomp);
425 nsubscipvars = GCGdecompGetNSubscipvars(decomp);
426
427 subscipconss = GCGdecompGetSubscipconss(decomp);
428 nsubscipconss = GCGdecompGetNSubscipconss(decomp);
429 nblocks = GCGdecompGetNBlocks(decomp);
430
431 SCIP_CALL( SCIPhashmapCreate(&transvar2origvar, SCIPblkmem(origprob), nvars) );
432 relaxdata->npricingprobs = nblocks;
434
435 SCIPdebugMessage("Copying structure with %d blocks, %d linking vars and %d linking constraints.\n", nblocks, nlinkingvars, nlinkingconss);
436
437 /* set master constraints */
438 for( i = 0; i < nlinkingconss; ++i )
439 {
440 assert(linkingconss[i] != NULL);
441 /* SCIPdebugMessage("\tProcessing linking constraint %s.\n", SCIPconsGetName(linkingconss[i])); */
442 if( SCIPconsIsActive(linkingconss[i]) )
443 {
444 SCIP_CALL( markConsMaster(gcg, relaxdata, linkingconss[i]) );
445 }
446 }
447
448 /* prepare the map from transformed to original variables */
449 for( i = 0; i < nvars; ++i )
450 {
451 SCIP_VAR* transvar;
452
453 SCIP_CALL( SCIPgetTransformedVar(origprob, origvars[i], &transvar) );
454 assert(transvar != NULL);
455
456 SCIP_CALL( SCIPhashmapInsert(transvar2origvar, transvar, origvars[i]) );
457 }
458
459 for( i = 0; i < nblocks; ++i )
460 {
461 /* SCIPdebugMessage("\tProcessing block %d (%d conss, %d vars).\n", i, nsubscipconss[i], nsubscipvars[i]); */
462 assert((subscipvars[i] == NULL) == (nsubscipvars[i] == 0));
463 for( j = 0; j < nsubscipvars[i]; ++j )
464 {
465 SCIP_VAR* relevantvar;
466 assert(subscipvars[i][j] != NULL);
467 relevantvar = SCIPvarGetProbvar(subscipvars[i][j]);
468
469 /* If there is a corresponding original (untransformed) variable, assign it to the block */
470 if( SCIPhashmapGetImage(transvar2origvar, subscipvars[i][j]) != NULL )
471 {
472 SCIP_VAR* origvar;
473
474 origvar = (SCIP_VAR*) SCIPhashmapGetImage(transvar2origvar, subscipvars[i][j]);
475 assert(SCIPvarGetData(origvar) != NULL);
476
477 SCIP_CALL( setOriginalVarBlockNr(gcg, relaxdata, origvar, i) );
478 SCIPdebugMessage("\t\tOriginal var %s (%p) in block %d\n", SCIPvarGetName(subscipvars[i][j]), (void*) subscipvars[i][j], i);
479 }
480
481 /* Assign the corresponding problem variable to the block */
482 if( SCIPvarGetData(relevantvar) == NULL )
483 SCIP_CALL( GCGorigVarCreateData(gcg, relevantvar) );
484 SCIP_CALL( setOriginalVarBlockNr(gcg, relaxdata, relevantvar, i) );
485
486 SCIPdebugMessage("\t\tTransformed var %s (%p) in block %d\n", SCIPvarGetName(relevantvar), (void*) relevantvar, i);
487
488 assert(SCIPvarGetData(subscipvars[i][j]) != NULL || SCIPvarGetData(relevantvar) != NULL);
489 }
490 }
491 SCIPdebugMessage("\tProcessing linking variables.\n");
492 for( i = 0; i < nlinkingvars; ++i )
493 {
494 int nfound = 0;
495
496 if( GCGoriginalVarIsLinking(linkingvars[i]) )
497 continue;
498
499 SCIPdebugMessage("\tDetecting constraint blocks of linking var %s\n", SCIPvarGetName(linkingvars[i]));
500 /* HACK; @todo find out constraint blocks more intelligently */
501 for( j = 0; j < nblocks; ++j )
502 {
503 int found = FALSE;
504 for( k = 0; k < nsubscipconss[j]; ++k )
505 {
506 SCIP_VAR** curvars;
507 int ncurvars;
508 if( SCIPconsIsDeleted(subscipconss[j][k]) )
509 continue;
510 ncurvars = GCGconsGetNVars(origprob, subscipconss[j][k]);
511 curvars = NULL;
512 if( ncurvars > 0 )
513 {
514 SCIP_CALL( SCIPallocBufferArray(origprob, &curvars, ncurvars) );
515 SCIP_CALL( GCGconsGetVars(origprob, subscipconss[j][k], curvars, ncurvars) );
516
517 for( v = 0; v < ncurvars; ++v )
518 {
519 if( SCIPvarGetProbvar(curvars[v]) == linkingvars[i] || curvars[v] == linkingvars[i] )
520 {
521 SCIPdebugMessage("\t\t%s is in %d\n", SCIPvarGetName(SCIPvarGetProbvar(curvars[v])), j);
522 assert(SCIPvarGetData(linkingvars[i]) != NULL);
523 SCIP_CALL( setOriginalVarBlockNr(gcg, relaxdata, SCIPvarGetProbvar(linkingvars[i]), j) );
524 found = TRUE;
525 break;
526 }
527 }
528
529 SCIPfreeBufferArray(origprob, &curvars);
530 }
531
532 if( found )
533 {
534 nfound++;
535 break;
536 }
537
538 }
539 }
540
541 /* if the linking variable is only in one block, then it would not have been flagged as a linking variable. In
542 * the Benders' decomposition case, then linking variable needs to be flagged as linking so that it is added to
543 * the master problem.
544 */
545 if( nfound == 1 && GCGgetDecompositionMode(gcg) == GCG_DECMODE_BENDERS )
546 {
547 SCIP_CALL( setOriginalVarBlockNr(gcg, relaxdata, SCIPvarGetProbvar(linkingvars[i]), -2) );
548 }
549 }
550
551 SCIPhashmapFree(&transvar2origvar);
552 return SCIP_OKAY;
553}
554
555/** ensures size of masterconss array */
556static
558 GCG* gcg,
559 SCIP_RELAXDATA* relaxdata,
560 int size
561 )
562{
563 SCIP* scip;
564 assert(gcg != NULL);
565 assert(relaxdata != NULL);
566 assert(relaxdata->masterconss != NULL);
567
569
570 if( relaxdata->maxmasterconss < size )
571 {
572 int newsize = SCIPcalcMemGrowSize(scip, size);
573 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(relaxdata->masterconss), relaxdata->maxmasterconss, newsize) );
574 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(relaxdata->origmasterconss), relaxdata->maxmasterconss, newsize) );
575 relaxdata->maxmasterconss = newsize;
576
577 }
578 assert(relaxdata->maxmasterconss >= size);
579
580 return SCIP_OKAY;
581}
582
583/** ensures size of branchrules array: enlarges the array by 1 */
584static
586 GCG* gcg,
587 SCIP_RELAXDATA* relaxdata
588 )
589{
590 assert(gcg != NULL);
591 assert(relaxdata != NULL);
592 assert((relaxdata->branchrules == NULL) == (relaxdata->nbranchrules == 0));
593
594 if( relaxdata->nbranchrules == 0 )
595 {
596 SCIP_CALL( SCIPallocMemoryArray(GCGgetOrigprob(gcg), &(relaxdata->branchrules), 1) ); /*lint !e506*/
597 }
598 else
599 {
600 SCIP_CALL( SCIPreallocMemoryArray(GCGgetOrigprob(gcg), &(relaxdata->branchrules), (size_t)relaxdata->nbranchrules+1) );
601 }
602
603 return SCIP_OKAY;
604}
605
606/** ensures size of branchrules array: enlarges the array by 1 */
607static
609 GCG* gcg,
610 SCIP_RELAXDATA* relaxdata
611 )
612{
613 assert(gcg != NULL);
614 assert(relaxdata != NULL);
615 assert((relaxdata->separators == NULL) == (relaxdata->nseparators == 0));
616
617 if( relaxdata->separators == 0 )
618 {
619 SCIP_CALL( SCIPallocMemoryArray(GCGgetOrigprob(gcg), &(relaxdata->separators), 1) ); /*lint !e506*/
620 }
621 else
622 {
623 SCIP_CALL( SCIPreallocMemoryArray(GCGgetOrigprob(gcg), &(relaxdata->separators), (size_t)relaxdata->nseparators+1) );
624 }
625
626 return SCIP_OKAY;
627}
628
629/** check whether the master problem has a set partitioning or set covering structure */
630static
632 GCG* gcg, /**< GCG data structure */
633 SCIP_RELAXDATA* relaxdata /**< relaxator data structure */
634 )
635{
636 SCIP* scip;
637 SCIP_CONS** masterconss;
638 int nmasterconss;
639 int i;
640
641 assert(relaxdata->decomp != NULL);
642
644 masterconss = GCGdecompGetLinkingconss(relaxdata->decomp);
645 nmasterconss = GCGdecompGetNLinkingconss(relaxdata->decomp);
646 assert(nmasterconss >= 0);
647 assert(masterconss != NULL || nmasterconss == 0);
648
649 if( nmasterconss == 0 || relaxdata->nvarlinkconss > 0 )
650 {
651 relaxdata->masterissetcover = FALSE;
652 relaxdata->masterissetpart = FALSE;
653 return SCIP_OKAY;
654 }
655
656 relaxdata->masterissetcover = TRUE;
657 relaxdata->masterissetpart = TRUE;
658
659 for( i = 0; i < nmasterconss; ++i )
660 {
661 assert(masterconss != NULL);
662
663 if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(masterconss[i])), "setppc") == 0 )
664 {
665 switch( SCIPgetTypeSetppc(scip, masterconss[i]) )
666 {
668 relaxdata->masterissetpart = FALSE;
669 break;
671 relaxdata->masterissetcover = FALSE;
672 break;
674 relaxdata->masterissetcover = FALSE;
675 relaxdata->masterissetpart = FALSE;
676 break;
677 }
678 }
679 else if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(masterconss[i])), "logicor") == 0 )
680 {
681 relaxdata->masterissetpart = FALSE;
682 break;
683 }
684 else if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(masterconss[i])), "linear") == 0 )
685 {
686 SCIP_SETPPCTYPE type;
687
688 if( GCGgetConsIsSetppc(scip, masterconss[i], &type) )
689 {
690 switch( type )
691 {
693 relaxdata->masterissetpart = FALSE;
694 break;
696 relaxdata->masterissetcover = FALSE;
697 break;
699 relaxdata->masterissetcover = FALSE;
700 relaxdata->masterissetpart = FALSE;
701 break;
702 }
703 }
704 else
705 {
706 relaxdata->masterissetcover = FALSE;
707 relaxdata->masterissetpart = FALSE;
708 break;
709 }
710 }
711 else
712 {
713 relaxdata->masterissetcover = FALSE;
714 relaxdata->masterissetpart = FALSE;
715 break;
716 }
717 }
718
719 if( relaxdata->masterissetcover )
720 {
721 assert(!relaxdata->masterissetpart);
722 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Master problem is a set covering problem.\n");
723 }
724 if( relaxdata->masterissetpart )
725 {
726 assert(!relaxdata->masterissetcover);
727 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Master problem is a set partitioning problem.\n");
728 }
729
730 return SCIP_OKAY;
731}
732
733/** checks whether there are identical pricing blocks */
734static
736 GCG* gcg, /**< GCG data structure */
737 SCIP_RELAXDATA* relaxdata, /**< the relaxator data data structure*/
738 SCIP_HASHMAP** hashorig2pricingvar /**< mapping from orig to pricingvar for each block */
739 )
740{
741 PARTIALDECOMP_C* partialdec;
742 SCIP* scip;
743
744 int i;
745 int j;
746 int k;
747
748 int nrelevant;
749
750 SCIPdebugMessage("checking identical blocks \n");
751 assert(gcg != NULL);
752 assert(relaxdata != NULL);
753
755
756 for( i = 0; i < relaxdata->npricingprobs; i++ )
757 {
758 relaxdata->blockrepresentative[i] = i;
759 relaxdata->nblocksidentical[i] = 1;
760 }
761
762 relaxdata->nrelpricingprobs = relaxdata->npricingprobs;
763 nrelevant = 0;
764
765 if( ( !relaxdata->discretization || !relaxdata->aggregation ) )
766 {
767 SCIPdebugMessage("discretization is off, aggregation is off\n");
768 return SCIP_OKAY;
769 }
770
772 SCIPdebugMessage( "nconss: %d; ndetectionconss: %d -> using partialdec information for identity test \n", SCIPgetNConss(scip), GCGconshdlrDecompGetNFormerDetectionConssForID(gcg, GCGdecompGetPartialdecID(relaxdata->decomp) ) );
773
775
777 {
778 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Calculating aggregation information.\n");
780 }
781
783 assert(nrelevant > 0 || GCGconshdlrDecompPartialdecGetNBlocks(partialdec) == 0);
784 for( j = 0; j < nrelevant; ++j )
785 {
787 const int* eqclassblocks = GCGconshdlrDecompPartialdecGetBlocksForEqClass(partialdec, j);
788 int neqclassblocks = GCGconshdlrDecompPartialdecGetNBlocksForEqClass(partialdec, j);
789
790 SCIPdebugMessage("Block %d is relevant!\n", rb);
791 relaxdata->nblocksidentical[rb] = neqclassblocks;
792
793 assert(eqclassblocks[0] == rb);
794 for( i = 1; i < neqclassblocks; ++i )
795 {
796 int b = eqclassblocks[i];
797 const int* repvarmap = GCGconshdlrDecompPartialdecGetRepVarMap(partialdec, j, i);
798
799 // block b will be represented by block rb
800 relaxdata->blockrepresentative[b] = rb;
801 relaxdata->nblocksidentical[b] = 0;
802 SCIPdebugMessage("Block %d is represented by block %d.\n", b, rb);
803
804 for( k = 0; k < GCGconshdlrDecompPartialdecGetNVarsForBlock(partialdec, b); ++k )
805 {
806 int rvi = repvarmap[k];
808 SCIP_VAR* repvar = GCGconshdlrDecompPartialdecGetOrigVarForBlock(partialdec, rb, rvi);
809 SCIP_VAR* pricingvar = GCGoriginalVarGetPricingVar(repvar);
810
811 assert(GCGvarIsPricing(pricingvar));
812 assert(GCGvarIsOriginal(origvar));
814 GCGoriginalVarSetPricingVar(origvar, pricingvar);
815 assert(GCGvarGetBlock(pricingvar) == rb);
816 assert(b == rb || !GCGoriginalVarIsLinking(origvar));
817 SCIP_CALL( GCGpricingVarAddOrigVar(relaxdata->pricingprobs[rb], pricingvar, origvar) );
818 SCIPdebugMessage("Var <%s> is mapped to <%s> (<%s>).\n", SCIPvarGetName(origvar), SCIPvarGetName(repvar),
819 SCIPvarGetName(pricingvar));
820 }
821
822#ifndef NDEBUG
823 /* assert that the representative variable map is order-preserving. */
824 {
825 int nbvars = GCGconshdlrDecompPartialdecGetNVarsForBlock(partialdec, b);
826 SCIP_Real* bprobidx;
827 int* bpricingidx;
828 int kk;
829
830 SCIP_CALL( SCIPallocBufferArray(scip, &bprobidx, nbvars) );
831 SCIP_CALL( SCIPallocBufferArray(scip, &bpricingidx, nbvars) );
832 for( kk = 0; kk < nbvars; ++kk )
833 {
835 bprobidx[kk] = (SCIP_Real) SCIPvarGetProbindex(bvar);
836 bpricingidx[kk] = SCIPvarGetIndex(GCGoriginalVarGetPricingVar(bvar));
837 }
838 SCIPsortRealInt(bprobidx, bpricingidx, nbvars);
839 for( kk = 1; kk < nbvars; ++kk )
840 assert(bpricingidx[kk-1] < bpricingidx[kk]);
841
842 SCIPfreeBufferArray(scip, &bpricingidx);
843 SCIPfreeBufferArray(scip, &bprobidx);
844 }
845#endif
846 }
847 }
848
849 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Matrix has %d blocks, using %d%s pricing problem%s.\n",
850 relaxdata->npricingprobs, nrelevant, (relaxdata->npricingprobs == nrelevant ? "" : " aggregated"), (nrelevant == 1 ? "" : "s"));
851
852 relaxdata->nrelpricingprobs = nrelevant;
853
854 if( relaxdata->npricingprobs > nrelevant )
855 {
856 // this is a workaround (GCG cannot handle different bounds on aggregated variables, see checkAggregatedLocalBounds)
857 SCIP_CALL( SCIPsetBoolParam(scip, "misc/allowstrongdualreds", FALSE) );
859 }
860
861 return SCIP_OKAY;
862}
863
864/** sets the pricing problem parameters */
866 GCG_DECTYPE dectype, /**< the dectype of the decomp */
867 SCIP* pricingprob, /**< SCIP data structure of the pricing problem */
868 int clocktype, /**< clocktype to use in the pricing problem */
869 SCIP_Real infinity, /**< values larger than this are considered infinity in the pricing problem */
870 SCIP_Real epsilon, /**< absolute values smaller than this are considered zero in the pricing problem */
871 SCIP_Real sumepsilon, /**< absolute values of sums smaller than this are considered zero in the pricing problem */
872 SCIP_Real feastol, /**< feasibility tolerance for constraints in the pricing problem */
873 SCIP_Real lpfeastolfactor, /**< primal feasibility tolerance factor of LP solver in the pricing problem */
874 SCIP_Real dualfeastol, /**< feasibility tolerance for reduced costs in LP solution in the pricing problem */
875 SCIP_Bool enableppcuts /**< should ppcuts be stored for sepa_basis */
876 )
877{
878 assert(pricingprob != NULL);
879
880 if( dectype != GCG_DECTYPE_DIAGONAL )
881 {
882 /* disable conflict analysis */
883 SCIP_CALL( SCIPsetBoolParam(pricingprob, "conflict/useprop", FALSE) );
884 SCIP_CALL( SCIPsetCharParam(pricingprob, "conflict/useinflp", 'o') );
885 SCIP_CALL( SCIPsetCharParam(pricingprob, "conflict/useboundlp", 'o') );
886 SCIP_CALL( SCIPsetBoolParam(pricingprob, "conflict/usesb", FALSE) );
887 SCIP_CALL( SCIPsetBoolParam(pricingprob, "conflict/usepseudo", FALSE) );
888
889 /* reduce the effort spent for hash tables */
890 SCIP_CALL( SCIPsetBoolParam(pricingprob, "misc/usevartable", FALSE) );
891 SCIP_CALL( SCIPsetBoolParam(pricingprob, "misc/useconstable", FALSE) );
892 SCIP_CALL( SCIPsetBoolParam(pricingprob, "misc/usesmalltables", TRUE) );
893
894 /* disable expensive presolving */
895 /* @todo test whether this really helps, perhaps set presolving emphasis to fast? */
896 SCIP_CALL( SCIPsetBoolParam(pricingprob, "constraints/linear/presolpairwise", FALSE) );
897 SCIP_CALL( SCIPsetBoolParam(pricingprob, "constraints/setppc/presolpairwise", FALSE) );
898 SCIP_CALL( SCIPsetBoolParam(pricingprob, "constraints/logicor/presolpairwise", FALSE) );
899 SCIP_CALL( SCIPsetBoolParam(pricingprob, "constraints/linear/presolusehashing", FALSE) );
900 SCIP_CALL( SCIPsetBoolParam(pricingprob, "constraints/setppc/presolusehashing", FALSE) );
901 SCIP_CALL( SCIPsetBoolParam(pricingprob, "constraints/logicor/presolusehashing", FALSE) );
902
903 /* disable dual fixing presolver for the moment (propagator should be safe), because we want to avoid variables fixed to infinity */
904 SCIP_CALL( SCIPsetIntParam(pricingprob, "propagating/dualfix/maxprerounds", 0) );
905 SCIP_CALL( SCIPfixParam(pricingprob, "propagating/dualfix/maxprerounds") );
906
907
908 /* disable solution storage ! */
909 SCIP_CALL( SCIPsetIntParam(pricingprob, "limits/maxorigsol", 0) );
910 SCIP_CALL( SCIPfixParam(pricingprob, "limits/maxorigsol") );
911
912 /* @todo enable presolving and propagation of xor constraints if bug is fixed */
913
914 /* disable presolving and propagation of xor constraints as work-around for a SCIP bug */
915 SCIP_CALL( SCIPsetIntParam(pricingprob, "constraints/xor/maxprerounds", 0) );
916 SCIP_CALL( SCIPsetIntParam(pricingprob, "constraints/xor/propfreq", -1) );
917
918 /* jonas' stuff */
919 if( enableppcuts )
920 {
921 int pscost;
922 int prop;
923
924 SCIP_CALL( SCIPgetIntParam(pricingprob, "branching/pscost/priority", &pscost) );
925 SCIP_CALL( SCIPgetIntParam(pricingprob, "propagating/maxroundsroot", &prop) );
926 SCIP_CALL( SCIPsetIntParam(pricingprob, "branching/pscost/priority", 11000) );
927 SCIP_CALL( SCIPsetIntParam(pricingprob, "propagating/maxroundsroot", 0) );
929 }
930 }
931
932 /* disable multiaggregation because of infinite values */
933 SCIP_CALL( SCIPsetBoolParam(pricingprob, "presolving/donotmultaggr", TRUE) );
934
935 /* disable output to console */
936 SCIP_CALL( SCIPsetIntParam(pricingprob, "display/verblevel", (int)SCIP_VERBLEVEL_NONE) );
937 #if SCIP_VERSION > 210
938 SCIP_CALL( SCIPsetBoolParam(pricingprob, "misc/printreason", FALSE) );
939 #endif
940
941 /* do not abort subproblem on CTRL-C */
942 SCIP_CALL( SCIPsetBoolParam(pricingprob, "misc/catchctrlc", FALSE) );
943
944 /* set clock type */
945 SCIP_CALL( SCIPsetIntParam(pricingprob, "timing/clocktype", clocktype) );
946
947 SCIP_CALL( SCIPsetBoolParam(pricingprob, "misc/calcintegral", FALSE) );
948 SCIP_CALL( SCIPsetBoolParam(pricingprob, "misc/finitesolutionstore", TRUE) );
949
950 SCIP_CALL( SCIPsetRealParam(pricingprob, "numerics/infinity", infinity) );
951 SCIP_CALL( SCIPsetRealParam(pricingprob, "numerics/epsilon", epsilon) );
952 SCIP_CALL( SCIPsetRealParam(pricingprob, "numerics/sumepsilon", sumepsilon) );
953 SCIP_CALL( SCIPsetRealParam(pricingprob, "numerics/feastol", feastol) );
954 SCIP_CALL( SCIPsetRealParam(pricingprob, "numerics/lpfeastolfactor", lpfeastolfactor) );
955 SCIP_CALL( SCIPsetRealParam(pricingprob, "numerics/dualfeastol", dualfeastol) );
956
957 return SCIP_OKAY;
958}
959
960
961/** creates a variable in a pricing problem corresponding to the given original variable (belonging to exactly one block) */
962static
964 SCIP_RELAXDATA* relaxdata, /**< relaxator data data structure */
965 SCIP_VAR* origvar /**< corresponding variable in the original program */
966 )
967{
968 SCIP_VAR* var;
969 int pricingprobnr;
970
971 assert(relaxdata != NULL);
972 assert(origvar != NULL);
973
974 pricingprobnr = GCGvarGetBlock(origvar);
975 assert(pricingprobnr >= 0);
976
977 SCIP_CALL( GCGoriginalVarCreatePricingVar(relaxdata->pricingprobs[pricingprobnr], origvar, &var) );
978 assert(var != NULL);
979
981 SCIP_CALL( SCIPaddVar(relaxdata->pricingprobs[pricingprobnr], var) );
983 /* because the variable was added to the problem,
984 * it is captured by SCIP and we can safely release it right now
985 */
986 SCIP_CALL( SCIPreleaseVar(relaxdata->pricingprobs[pricingprobnr], &var) );
987
988 return SCIP_OKAY;
989}
990
991/** creates a variable in each of the pricing problems linked by given original variable */
992static
994 GCG* gcg, /**< GCG data structure */
995 SCIP_RELAXDATA* relaxdata, /**< relaxator data data structure */
996 SCIP_VAR* origvar /**< corresponding linking variable in the original program */
997 )
998{
999 SCIP* scip;
1000 SCIP_VAR* var;
1001 SCIP_CONS* linkcons;
1002#ifndef NDEBUG
1003 SCIP_CONS** linkconss;
1004 int nblocks;
1005#endif
1006 SCIP_VAR** pricingvars;
1007 int i;
1008
1009 assert(origvar != NULL);
1010 assert(relaxdata != NULL);
1011
1013
1014 /* get variable data of the original variable */
1015 assert(GCGvarIsOriginal(origvar));
1017 pricingvars = GCGlinkingVarGetPricingVars(origvar);
1018
1019#ifndef NDEBUG
1020 nblocks = GCGlinkingVarGetNBlocks(origvar);
1021 /* checks that GCGrelaxSetOriginalVarBlockNr() worked correctly */
1022 {
1023 int count;
1024
1025 linkconss = GCGlinkingVarGetLinkingConss(origvar);
1026 /* the linking constraints could be NULL if the Benders' decomposition is used. */
1027 if( linkconss != NULL )
1028 {
1029 count = 0;
1030 for( i = 0; i < relaxdata->npricingprobs; i++ )
1031 {
1032 assert(linkconss[i] == NULL);
1033
1034 if( pricingvars[i] != NULL )
1035 count++;
1036 }
1037 assert(nblocks == count);
1038 }
1039 }
1040#endif
1041
1042 for( i = 0; i < relaxdata->npricingprobs; ++i )
1043 {
1044 if( pricingvars[i] == NULL )
1045 continue;
1046
1047 SCIP_CALL( GCGlinkingVarCreatePricingVar(relaxdata->pricingprobs[i], i, origvar, &var) );
1048
1049 GCGlinkingVarSetPricingVar(origvar, i, var);
1050
1052 SCIP_CALL( SCIPaddVar(relaxdata->pricingprobs[i], var) );
1053
1054
1055 if( relaxdata->mode != GCG_DECMODE_BENDERS )
1056 {
1057 SCIP_CALL( GCGlinkingVarCreateMasterCons(relaxdata->gcg, i, origvar, &linkcons) );
1058 GCGlinkingVarSetLinkingCons(origvar, linkcons, i);
1059 SCIP_CALL( SCIPaddCons(GCGgetMasterprob(relaxdata->gcg), linkcons) );
1060
1061 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &relaxdata->varlinkconss, relaxdata->nvarlinkconss, (size_t)relaxdata->nvarlinkconss+1) );
1062 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &relaxdata->varlinkconsblock, relaxdata->nvarlinkconss, (size_t)relaxdata->nvarlinkconss+1) );
1063
1064 relaxdata->varlinkconss[relaxdata->nvarlinkconss] = linkcons;
1065 relaxdata->varlinkconsblock[relaxdata->nvarlinkconss] = i;
1066 relaxdata->nvarlinkconss++;
1067 }
1068
1069 /* because the variable was added to the problem,
1070 * it is captured by SCIP and we can safely release it right now
1071 */
1072 SCIP_CALL( SCIPreleaseVar(relaxdata->pricingprobs[i], &var) );
1073 }
1074
1075#ifndef NDEBUG
1076 /* checks that createLinkingPricingVars() worked correctly */
1077 {
1078 int count;
1079
1080 linkconss = GCGlinkingVarGetLinkingConss(origvar);
1081 /* the linking constraints could be NULL if the Benders' decomposition is used. */
1082 if( linkconss != NULL )
1083 {
1084 count = 0;
1085 for( i = 0; i < relaxdata->npricingprobs; i++ )
1086 {
1087 if( pricingvars[i] != NULL )
1088 {
1089 count++;
1090 assert(GCGvarIsPricing(pricingvars[i]));
1091 assert(relaxdata->mode == GCG_DECMODE_BENDERS || linkconss[i] != NULL);
1092 }
1093 else
1094 assert(linkconss[i] == NULL);
1095 }
1096 assert(nblocks == count);
1097 }
1098 }
1099#endif
1100
1101
1102 return SCIP_OKAY;
1103}
1104
1105/** create pricing problem variables */
1106static
1108 GCG* gcg, /**< GCG data structure */
1109 SCIP_RELAXDATA* relaxdata, /**< relaxator data data structure */
1110 SCIP_HASHMAP** hashorig2pricingvar /**< hashmap mapping original variables to pricing variables */
1111 )
1112{
1113 SCIP* scip;
1114 SCIP_VAR** vars;
1115 int nvars;
1116 int v;
1117 int i;
1118 int npricingprobs;
1119#ifndef NDEBUG
1120 SCIP_HASHMAP* hashorig2origvar;
1121#endif
1122
1123 assert(gcg != NULL);
1124 assert(relaxdata != NULL);
1125
1127
1128 /* create pricing variables and map them to the original variables */
1131 npricingprobs = relaxdata->npricingprobs;
1132
1133#ifndef NDEBUG
1134 SCIP_CALL( SCIPhashmapCreate(&hashorig2origvar, SCIPblkmem(scip), 10*SCIPgetNVars(scip)+1) );
1135#endif
1136
1137 for( v = 0; v < nvars; v++ )
1138 {
1139 int blocknr;
1140 SCIP_VAR* probvar;
1141
1143
1144 probvar = SCIPvarGetProbvar(vars[v]);
1145 assert(SCIPvarIsTransformed(probvar));
1146 blocknr = GCGvarGetBlock(probvar);
1147 if( blocknr == -1 )
1148 {
1149 int tempblock;
1150 tempblock = (int) (size_t) SCIPhashmapGetImage(GCGdecompGetVartoblock(relaxdata->decomp), probvar)-1; /*lint !e507*/
1151 if( tempblock >= GCGdecompGetNBlocks(relaxdata->decomp) )
1152 {
1153 blocknr = -1;
1154 }
1155 else
1156 {
1157 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " changed block number to %d \n", tempblock );
1158 blocknr = tempblock; /*lint !e806*/
1159 }
1160 }
1161
1162#ifndef NDEBUG
1163 SCIPdebugMessage("Creating map for (%p, %p) var %s:", (void*)(vars[v]), (void*)(probvar), SCIPvarGetName(probvar));
1164 assert( !SCIPhashmapExists(hashorig2origvar, probvar) );
1165 SCIP_CALL( SCIPhashmapInsert(hashorig2origvar, (void*)(probvar), (void*)(probvar)) );
1166#endif
1167
1168 /* variable belongs to exactly one block --> create corresponding pricing variable*/
1169 if( blocknr >= 0 )
1170 {
1171 SCIPdebugPrintf("block %d", blocknr);
1172
1174 SCIP_CALL( createPricingVar(relaxdata, probvar) );
1176 assert(hashorig2pricingvar != NULL);
1177 assert(hashorig2pricingvar[blocknr] != NULL);
1178
1179 SCIPdebugPrintf("-> %p\n", (void*) GCGoriginalVarGetPricingVar(probvar));
1180
1181 assert(!SCIPhashmapExists(hashorig2pricingvar[blocknr], probvar));
1182 SCIP_CALL( SCIPhashmapInsert(hashorig2pricingvar[blocknr], (void*)(probvar),
1183 (void*)(GCGoriginalVarGetPricingVar(probvar)) ));
1184
1185 assert(GCGvarIsPricing((SCIP_VAR*) SCIPhashmapGetImage(hashorig2pricingvar[blocknr], probvar)));
1186 }
1187 /* variable is a linking variable --> create corresponding pricing variable in all linked blocks
1188 * and create corresponding linking constraints */
1189 else if( GCGoriginalVarIsLinking(probvar) )
1190 {
1191 SCIP_VAR** pricingvars;
1192 SCIPdebugPrintf("linking.\n");
1193 relaxdata->nlinkingvars++;
1194 SCIP_CALL( createLinkingPricingVars(gcg, relaxdata, probvar) );
1196
1197
1198 pricingvars = GCGlinkingVarGetPricingVars(probvar);
1199
1200 for( i = 0; i < npricingprobs; i++ )
1201 {
1202 if( pricingvars[i] != NULL )
1203 {
1204 assert(GCGvarIsPricing(pricingvars[i]));
1205 assert(hashorig2pricingvar != NULL);
1206 assert(hashorig2pricingvar[i] != NULL);
1207 assert(!SCIPhashmapExists(hashorig2pricingvar[i], probvar));
1208 SCIP_CALL( SCIPhashmapInsert(hashorig2pricingvar[i], (void*)(probvar),
1209 (void*)(pricingvars[i])) );
1210 assert(GCGvarIsPricing((SCIP_VAR*) SCIPhashmapGetImage(hashorig2pricingvar[i], probvar)));
1211 }
1212 }
1213 }
1214 else
1215 {
1216 assert(GCGvarGetBlock(probvar) == -1);
1218 SCIPdebugPrintf("master!\n");
1219 relaxdata->ntransvars++;
1220 }
1221 assert(SCIPhashmapExists(hashorig2origvar, probvar));
1222 }
1223
1224#ifndef NDEBUG
1225 SCIPhashmapFree(&hashorig2origvar);
1226#endif
1227
1228 return SCIP_OKAY;
1229}
1230
1231
1232/** displays statistics of the pricing problems */
1233static
1235 GCG* gcg, /**< GCG data structure */
1236 SCIP** pricingprobs, /**< array of pricing problems */
1237 int npricingprobs, /**< number of pricingproblems */
1238 int* blockrepresentative /**< array of representation information */
1239)
1240{
1241 SCIP* scip;
1242 char name[SCIP_MAXSTRLEN];
1243 int i;
1244
1245 assert(gcg != NULL);
1246 assert(pricingprobs != NULL);
1247 assert(blockrepresentative != NULL);
1248 assert(npricingprobs > 0);
1249
1251
1252 for( i = 0; i < npricingprobs; i++ )
1253 {
1254 int nbin;
1255 int nint;
1256 int nimpl;
1257 int ncont;
1258
1259 if( blockrepresentative[i] != i )
1260 continue;
1261
1262 SCIP_CALL( SCIPgetVarsData(pricingprobs[i], NULL, NULL, &nbin, &nint, &nimpl, &ncont) );
1263
1264 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "pricing problem %d: %d conss, %d vars (%d bins, %d ints, %d impls and %d cont)\n", i,
1265 SCIPgetNConss(pricingprobs[i]), SCIPgetNVars(pricingprobs[i]), nbin, nint, nimpl, ncont);
1266
1267 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "pricingprob_%d.lp", i);
1268 SCIP_CALL( SCIPwriteOrigProblem(pricingprobs[i], name, NULL, FALSE) );
1269 }
1270
1271 return SCIP_OKAY;
1272}
1273
1274
1275/** allocates initial problem specific data */
1276static
1278 GCG* gcg, /**< GCG data structure */
1279 SCIP_RELAXDATA* relaxdata /**< relaxatordata data structure */
1280 )
1281{
1282 SCIP* scip;
1283 assert(gcg != NULL);
1284 assert(relaxdata != NULL);
1285
1287
1288 /* initialize relaxator data */
1289 relaxdata->maxmasterconss = 16;
1290 assert(relaxdata->nmasterconss == 0);
1291
1292 /* arrays of constraints belonging to the master problems */
1293 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(relaxdata->masterconss), relaxdata->maxmasterconss) );
1295
1296 if( relaxdata->npricingprobs > relaxdata->maxpricingprobs )
1297 {
1298 int i;
1299 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(relaxdata->pricingprobs), relaxdata->maxpricingprobs, relaxdata->npricingprobs) );
1302
1303 /* array for saving convexity constraints belonging to one of the pricing problems */
1304 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(relaxdata->convconss), relaxdata->maxpricingprobs, relaxdata->npricingprobs) );
1305
1306 for( i = relaxdata->maxpricingprobs; i < relaxdata->npricingprobs; ++i)
1307 {
1308 relaxdata->pricingprobs[i] = NULL;
1309 }
1310
1311 relaxdata->maxpricingprobs = relaxdata->npricingprobs;
1312 }
1313
1314 return SCIP_OKAY;
1315}
1316
1317
1318/** creates the master problem with the specified name */
1319static
1321 GCG* gcg, /**< GCG data structure */
1322 const char* name, /**< name of the master problem */
1323 int clocktype, /**< clocktype to use in the master problem */
1324 SCIP_Real infinity, /**< values larger than this are considered infinity in the master problem */
1325 SCIP_Real epsilon, /**< absolute values smaller than this are considered zero in the master problem */
1326 SCIP_Real sumepsilon, /**< absolute values of sums smaller than this are considered zero in the master problem */
1327 SCIP_Real feastol, /**< feasibility tolerance for constraints in the master problem */
1328 SCIP_Real lpfeastolfactor, /**< primal feasibility tolerance factor of LP solver in the master problem */
1329 SCIP_Real dualfeastol, /**< feasibility tolerance for reduced costs in LP solution in the master problem */
1330 GCG_DECMODE mode /**< the decomposition mode */
1331 )
1332{
1334 assert(gcg != NULL);
1335 assert(name != NULL);
1336
1338
1339 /* set clocktype */
1340 SCIP_CALL( SCIPsetIntParam(masterprob, "timing/clocktype", clocktype) );
1341
1342 /* set numerical tolerances */
1343 SCIP_CALL( SCIPsetRealParam(masterprob, "numerics/infinity", infinity) );
1344 SCIP_CALL( SCIPsetRealParam(masterprob, "numerics/epsilon", epsilon) );
1345 SCIP_CALL( SCIPsetRealParam(masterprob, "numerics/sumepsilon", sumepsilon) );
1346 SCIP_CALL( SCIPsetRealParam(masterprob, "numerics/feastol", feastol) );
1347 SCIP_CALL( SCIPsetRealParam(masterprob, "numerics/lpfeastolfactor", lpfeastolfactor) );
1348 SCIP_CALL( SCIPsetRealParam(masterprob, "numerics/dualfeastol", dualfeastol) );
1349
1350 /* disable aggregation and multiaggregation of variables, as this might lead to issues with copied original variables */
1351 SCIP_CALL( SCIPsetBoolParam(masterprob, "presolving/donotaggr", TRUE) );
1352 SCIP_CALL( SCIPsetBoolParam(masterprob, "presolving/donotmultaggr", TRUE) );
1353
1354 /* do not catch ctrl-c @todo: add this feature*/
1355 SCIP_CALL( SCIPsetBoolParam(masterprob, "misc/catchctrlc", FALSE) );
1356
1357 /* the following settings are for decomposition, so if the original problem is solved directly, then these settings
1358 * are not required
1359 */
1360 if( mode == GCG_DECMODE_ORIGINAL )
1361 {
1362 return SCIP_OKAY;
1363 }
1364
1365 if( mode == GCG_DECMODE_DANTZIGWOLFE )
1367
1368 /* do not modify the time limit after solving the master problem */
1369 SCIP_CALL( SCIPsetBoolParam(masterprob, "reoptimization/commontimelimit", FALSE) );
1370
1371 /* for Benders' decomposition, some additional parameter settings are required for the master problem. */
1372 if( mode == GCG_DECMODE_BENDERS )
1373 {
1376 SCIP_CALL( SCIPsetIntParam(masterprob, "presolving/maxrestarts", 0) );
1377 SCIP_CALL( SCIPsetIntParam(masterprob, "propagating/maxroundsroot", 0) );
1378 SCIP_CALL( SCIPsetIntParam(masterprob, "heuristics/trysol/freq", 1) );
1379 SCIP_CALL( SCIPsetBoolParam(masterprob, "constraints/benders/active", TRUE) );
1380 SCIP_CALL( SCIPsetBoolParam(masterprob, "constraints/benderslp/active", TRUE) );
1381 SCIP_CALL( SCIPsetBoolParam(masterprob, "benders/gcg/lnscheck", FALSE) );
1382 SCIP_CALL( SCIPsetIntParam(masterprob, "presolving/maxrounds", 1) );
1383 SCIP_CALL( SCIPsetIntParam(masterprob, "constraints/benders/maxprerounds", 1) );
1384
1385 /* the trysol heuristic must have a high priority to ensure the solutions found by the relaxator are added to the
1386 * original problem
1387 */
1388 SCIP_CALL( SCIPsetIntParam(GCGgetOrigprob(gcg), "heuristics/trysol/freq", 1) );
1389
1390 /* disabling pricing problem aggregation */
1391 SCIP_CALL( SCIPsetBoolParam(GCGgetOrigprob(gcg), "relaxing/gcg/aggregation/enabled", FALSE) );
1392 }
1393
1394 return SCIP_OKAY;
1395}
1396
1397
1398/** creates the pricing problem with the specified name */
1399static
1401 SCIP_RELAXDATA* relaxdata, /**< the relaxator data data structure */
1402 SCIP** pricingscip, /**< Pricing GCG data structure */
1403 const char* name, /**< name of the pricing problem */
1404 int clocktype, /**< clocktype to use in the pricing problem */
1405 SCIP_Real infinity, /**< values larger than this are considered infinity in the pricing problem */
1406 SCIP_Real epsilon, /**< absolute values smaller than this are considered zero in the pricing problem */
1407 SCIP_Real sumepsilon, /**< absolute values of sums smaller than this are considered zero in the pricing problem */
1408 SCIP_Real feastol, /**< feasibility tolerance for constraints in the pricing problem */
1409 SCIP_Real lpfeastolfactor, /**< primal feasibility tolerance factor of LP solver in the pricing problem */
1410 SCIP_Real dualfeastol, /**< feasibility tolerance for reduced costs in LP solution in the pricing problem */
1411 SCIP_Bool enableppcuts /**< should ppcuts be stored for sepa_basis */
1412 )
1413{
1414 assert(pricingscip != NULL);
1415 assert(name != NULL);
1416 assert(relaxdata->mode != GCG_DECMODE_ORIGINAL);
1417
1418 if( *pricingscip == NULL )
1419 {
1420 SCIP_CALL( SCIPcreate(pricingscip) );
1421 SCIP_CALL( SCIPincludeDefaultPlugins(*pricingscip) );
1422 SCIP_CALL( GCGsetPricingProblemParameters(GCGdecompGetType(relaxdata->decomp), *pricingscip, clocktype, infinity, epsilon, sumepsilon, feastol, lpfeastolfactor, dualfeastol, enableppcuts) );
1423
1424 if( relaxdata->mode == GCG_DECMODE_BENDERS )
1425 {
1426#if SCIP_VERSION >= 1100
1427 SCIP_CALL( SCIPsetBoolParam(*pricingscip, "symmetries/enabled", FALSE) );
1428#else
1429 SCIP_CALL( SCIPsetIntParam(*pricingscip, "misc/usesymmetry", 0) );
1430#endif
1431 }
1432 }
1433 SCIP_CALL( SCIPcreateProb(*pricingscip, name, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
1434
1435 return SCIP_OKAY;
1436}
1437
1438
1439/** saves the coefficient of the masterconstraints in the original variable */
1440static
1442 GCG* gcg, /**< GCG data structure */
1443 SCIP_VAR** origvars, /**< original variables array */
1444 int norigvars, /**< size of original variables array*/
1445 int nmasterconss, /**< size of masterconns array */
1446 SCIP_CONS** origmasterconss, /**< orig master constraints array */
1447 SCIP_CONS** masterconss /**< master constraints */
1448 )
1449{
1450 SCIP* scip;
1451 int v;
1452 int i;
1453
1454 assert(gcg != NULL);
1455 assert(origvars != NULL || norigvars == 0);
1456 assert(norigvars >= 0);
1457 assert(nmasterconss >= 0);
1458 assert(masterconss != NULL);
1459 assert(origmasterconss != NULL);
1460
1462
1463 /* for original variables, save the coefficients in the master problem */
1464 for( v = 0; v < norigvars; v++ )
1465 {
1466 SCIP_VAR* var;
1467 var = SCIPvarGetProbvar(origvars[v]); /*lint !e613*/
1471 }
1472
1473 /* save coefs */
1474 for( i = 0; i < nmasterconss; i++ )
1475 {
1476 SCIP_VAR** vars;
1477 SCIP_Real* vals;
1478 int nvars;
1479
1480 nvars = GCGconsGetNVars(scip, origmasterconss[i]);
1483 GCGconsGetVars(scip, origmasterconss[i], vars, nvars);
1484 GCGconsGetVals(scip, origmasterconss[i], vals, nvars);
1485 for( v = 0; v < nvars; v++ )
1486 {
1487 SCIP_CALL( GCGoriginalVarAddCoef(gcg, vars[v], vals[v], masterconss[i]) );
1488 }
1489 SCIPfreeBufferArray(scip, &vals);
1491 }
1492
1493 return SCIP_OKAY;
1494}
1495
1496/** creates the master problem constraints */
1497static
1499 GCG* gcg, /**< GCG data structure */
1500 SCIP_RELAXDATA* relaxdata /**< the relaxator data data structure */
1501 )
1502{
1503 SCIP* scip;
1504 SCIP_CONS** masterconss;
1505 int nmasterconss;
1506 SCIP_CONS* mastercons;
1507 int c;
1508 char name[SCIP_MAXSTRLEN];
1509
1511 masterconss = GCGdecompGetLinkingconss(relaxdata->decomp);
1512 nmasterconss = GCGdecompGetNLinkingconss(relaxdata->decomp);
1513
1514 // assert(SCIPhashmapGetNElements(relaxdata->hashorig2origvar) == SCIPgetNVars(scip));
1515 for( c = 0; c < nmasterconss; ++c )
1516 {
1517 int nconsvars;
1518 int consvarssize;
1519 SCIP_VAR** consvars;
1520 SCIP_Real* consvals;
1521 SCIP_Bool* releasevars;
1522 int i;
1523
1524 if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(masterconss[c])), "origbranch") == 0 )
1525 continue;
1526
1527 /* in the Benders' decomposition mode, all variables from the linking constraints need to be added to the master
1528 * problem. Additionally, if the original problem is solved directly, then we must ensure that all variables are
1529 * added to the master problem.
1530 */
1532 {
1533 nconsvars = GCGconsGetNVars(scip, masterconss[c]);
1534 consvarssize = nconsvars;
1535
1536 SCIP_CALL( SCIPallocBufferArray(scip, &consvars, consvarssize) );
1537 SCIP_CALL( SCIPallocBufferArray(scip, &consvals, consvarssize) );
1538 SCIP_CALL( SCIPallocClearBufferArray(scip, &releasevars, consvarssize) );
1539
1540 SCIP_CALL( GCGconsGetVars(scip, masterconss[c], consvars, nconsvars) );
1541 SCIP_CALL( GCGconsGetVals(scip, masterconss[c], consvals, nconsvars) );
1542
1543 for( i = 0; i < nconsvars; i++ )
1544 {
1545 SCIP_VAR* origvar;
1546
1547 /* if the variable is a linking variable or is directly transferred to the master problem, then it is not
1548 * added to the constraint. This is because the linking variables and the transferred variables are added
1549 * later in GCGmasterCreateInitialMastervars().
1550 */
1551 while( i < nconsvars && (GCGoriginalVarIsLinking(consvars[i]) || GCGoriginalVarIsTransVar(consvars[i])) )
1552 {
1553 consvars[i] = consvars[nconsvars - 1];
1554 consvals[i] = consvals[nconsvars - 1];
1555 nconsvars--;
1556 }
1557
1558 if( i >= nconsvars )
1559 break;
1560
1561 /* assigning the origvar to the next variables that is not a linking variable */
1562 origvar = consvars[i];
1563
1564 assert(GCGoriginalVarGetNMastervars(origvar) <= 1);
1565
1566 /* if the original has already has a copy in the master problem, then this is used. Otherwise, the master
1567 * problem variable is created.
1568 */
1569 if( GCGoriginalVarGetNMastervars(origvar) > 0 )
1570 {
1571 consvars[i] = GCGoriginalVarGetMastervars(origvar)[0];
1572 releasevars[i] = FALSE;
1573 }
1574 else
1575 {
1576 SCIP_CALL( GCGcreateInitialMasterVar(gcg, consvars[i], &consvars[i]) );
1577 SCIP_CALL( SCIPaddVar(GCGgetMasterprob(gcg), consvars[i]) );
1578
1579 SCIP_CALL( GCGoriginalVarAddMasterVar(gcg, origvar, consvars[i], 1.0) );
1580
1581 releasevars[i] = TRUE;
1582 }
1583
1584 assert(GCGoriginalVarGetNMastervars(origvar) <= 1);
1585 }
1586 }
1587 else
1588 {
1589 nconsvars = 0;
1590 consvars = NULL;
1591 consvals = NULL;
1592 releasevars = NULL;
1593 }
1594
1595 /* create and add corresponding linear constraint in the master problem */
1596 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "m_%s", SCIPconsGetName(masterconss[c]));
1597 SCIP_CALL( SCIPcreateConsLinear(GCGgetMasterprob(relaxdata->gcg), &mastercons, name, nconsvars, consvars, consvals,
1598 GCGconsGetLhs(scip, masterconss[c]), GCGconsGetRhs(scip, masterconss[c]),
1600
1601 SCIP_CALL( SCIPaddCons(GCGgetMasterprob(relaxdata->gcg), mastercons) );
1602 SCIPdebugMessage("Copying %s to masterproblem\n", SCIPconsGetName(masterconss[c]));
1603 /* store the constraints in the arrays origmasterconss and masterconss in the problem data */
1604 SCIP_CALL( ensureSizeMasterConss(gcg, relaxdata, relaxdata->nmasterconss+1) );
1605 SCIP_CALL( SCIPcaptureCons(scip, masterconss[c]) );
1606 relaxdata->origmasterconss[relaxdata->nmasterconss] = masterconss[c];
1607 relaxdata->masterconss[relaxdata->nmasterconss] = mastercons;
1608 relaxdata->nmasterconss++;
1609
1610 /* in the Benders' decomposition mode, the consvars and consvals arrays need to be freed */
1612 {
1613 assert(releasevars != NULL);
1614 assert(consvars != NULL);
1615 for( i = 0; i < nconsvars; i++ )
1616 {
1617 if( releasevars[i] )
1618 {
1619 SCIP_CALL( SCIPreleaseVar(GCGgetMasterprob(relaxdata->gcg), &consvars[i]) );
1620 }
1621 }
1622
1623 SCIPfreeBufferArray(scip, &releasevars);
1624 SCIPfreeBufferArray(scip, &consvals);
1625 SCIPfreeBufferArray(scip, &consvars);
1626 }
1627 }
1628 assert(relaxdata->nmasterconss == nmasterconss);
1630
1631 return SCIP_OKAY;
1632}
1633
1634/** creates the pricing problem constraints */
1635static
1637 GCG* gcg, /**< GCG data structure */
1638 SCIP_RELAXDATA* relaxdata, /**< the relaxator data data structure */
1639 SCIP_HASHMAP** hashorig2pricingvar /**< hashmap mapping original to corresponding pricing variables */
1640 )
1641{
1642 SCIP* scip;
1643 SCIP_CONS*** subscipconss;
1644 int* nsubscipconss;
1645 SCIP_CONS* newcons;
1646 SCIP_HASHMAP* hashorig2pricingconstmp;
1647 int nblocks;
1648 int b;
1649 int c;
1650 char name[SCIP_MAXSTRLEN];
1652
1653 assert(gcg != NULL);
1654 assert(relaxdata != NULL);
1655
1657 subscipconss = GCGdecompGetSubscipconss(relaxdata->decomp);
1658 nsubscipconss = GCGdecompGetNSubscipconss(relaxdata->decomp);
1659 nblocks = GCGdecompGetNBlocks(relaxdata->decomp);
1660
1661 SCIP_CALL( SCIPhashmapCreate(&hashorig2pricingconstmp, SCIPblkmem(scip), SCIPgetNConss(scip)) ); /*lint !e613*/
1662
1663 for( b = 0; b < nblocks; ++b )
1664 {
1665 assert(hashorig2pricingvar != NULL);
1666 for( c = 0; c < nsubscipconss[b]; ++c )
1667 {
1668 SCIPdebugMessage("copying %s to pricing problem %d\n", SCIPconsGetName(subscipconss[b][c]), b);
1669 if( !SCIPconsIsActive(subscipconss[b][c]) )
1670 {
1671 SCIPdebugMessage("skipping, cons <%s> inactive\n", SCIPconsGetName(subscipconss[b][c]));
1672 continue;
1673 }
1674 SCIP_CALL( SCIPgetTransformedCons(scip, subscipconss[b][c], &subscipconss[b][c]) );
1675 assert(subscipconss[b][c] != NULL);
1676
1677 /* copy the constraint */
1678 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "p%d_%s", b, SCIPconsGetName(subscipconss[b][c]));
1679 SCIP_CALL( SCIPgetConsCopy(scip, relaxdata->pricingprobs[b], subscipconss[b][c], &newcons, SCIPconsGetHdlr(subscipconss[b][c]),
1680 hashorig2pricingvar[b], hashorig2pricingconstmp, name,
1682
1683 /* constraint was successfully copied */
1684 assert(success);
1685
1686 SCIP_CALL( SCIPaddCons(relaxdata->pricingprobs[b], newcons) );
1687
1688
1689#ifndef NDEBUG
1690 {
1691 SCIP_VAR** curvars;
1692 int ncurvars;
1693
1694 ncurvars = GCGconsGetNVars(relaxdata->pricingprobs[b], newcons);
1695 curvars = NULL;
1696 if( ncurvars > 0 )
1697 {
1698 int i;
1699
1700 SCIP_CALL( SCIPallocBufferArray(scip, &curvars, ncurvars) );
1701 SCIP_CALL( GCGconsGetVars(relaxdata->pricingprobs[b], newcons, curvars, ncurvars) );
1702
1703 for( i = 0; i < ncurvars; ++i )
1704 {
1705 if( SCIPisFeasEQ( scip, SCIPvarGetLbGlobal(curvars[i]), SCIPvarGetUbGlobal(curvars[i]) ) && SCIPisFeasEQ( scip, SCIPvarGetUbGlobal(curvars[i]), 0. ) )
1706 continue;
1707
1708 assert(GCGvarIsPricing(curvars[i]) || ( SCIPvarIsNegated(curvars[i]) && GCGvarIsPricing(SCIPvarGetNegatedVar(curvars[i]) ) ) );
1709 }
1710
1711 SCIPfreeBufferArrayNull(scip, &curvars);
1712 }
1713 }
1714#endif
1715 SCIP_CALL( SCIPreleaseCons(relaxdata->pricingprobs[b], &newcons) );
1716 }
1717 }
1718
1719 SCIPhashmapFree(&hashorig2pricingconstmp);
1720
1721 return SCIP_OKAY;
1722}
1723
1724/** creates the master problem and the pricing problems and copies the constraints into them */
1725static
1727 GCG* gcg, /**< GCG data structure */
1728 SCIP_RELAXDATA* relaxdata /**< the relaxator data data structure */
1729 )
1730{
1731 SCIP* origprob;
1732 int npricingprobs;
1733 SCIP_HASHMAP** hashorig2pricingvar;
1734 SCIP_Bool enableppcuts;
1735 char name[SCIP_MAXSTRLEN];
1736 int clocktype;
1738 SCIP_Real epsilon;
1739 SCIP_Real sumepsilon;
1740 SCIP_Real feastol;
1741 SCIP_Real lpfeastolfactor;
1742 SCIP_Real dualfeastol;
1743 int i;
1744
1745 assert(gcg != NULL);
1746 assert(relaxdata != NULL);
1747
1748 assert(relaxdata->decomp != NULL);
1749
1751
1752 SCIP_CALL( convertStructToGCG(gcg, relaxdata, relaxdata->decomp) );
1753
1754 /* if there are no pricing problems, then the original problem will be solved directly. */
1755 if( relaxdata->npricingprobs == 0 )
1756 {
1757 int origmode = relaxdata->mode;
1758
1759 /* setting the mode to ORIGINAL */
1760 relaxdata->mode = GCG_DECMODE_ORIGINAL;
1761 SCIP_CALL( SCIPfixParam(origprob, "relaxing/gcg/mode") );
1762
1763 if( origmode == GCG_DECMODE_DANTZIGWOLFE )
1764 {
1765 /* initialising the master problem */
1766 SCIP_CALL( SCIPsetIntParam(gcg->bendersmasterprob, "display/verblevel", (int)SCIP_VERBLEVEL_NONE) );
1767 SCIP_CALL( SCIPsetBoolParam(gcg->bendersmasterprob, "display/relevantstats", FALSE) );
1769
1770
1771 /* disabling unnecessary display columns */
1772 SCIP_CALL( SCIPsetIntParam(origprob, "display/sumlpiterations/active", 0) );
1773 SCIP_CALL( SCIPsetIntParam(origprob, "display/lpiterations/active", 0) );
1774 SCIP_CALL( SCIPsetIntParam(origprob, "display/degeneracy/active", 0) );
1775
1776 /* setting the total node limit to 1 for the original SCIP instance. This is because Benders' decomposition solves
1777 * the MIP within the relaxator of the root node. So no branching in the original problem is required.
1778 */
1779 SCIP_CALL( SCIPsetLongintParam(origprob, "limits/totalnodes", 1) );
1780
1781 /* swapping the master problem with the original master problem */
1782 relaxdata->gcg->masterprob = gcg->bendersmasterprob;
1783 }
1784
1785 SCIP_CALL( SCIPsetIntParam(GCGgetMasterprob(relaxdata->gcg), "constraints/components/maxprerounds", 0) );
1786 SCIP_CALL( SCIPsetBoolParam(origprob, "relaxing/gcg/discretization", FALSE) );
1787 }
1788
1789
1790 npricingprobs = relaxdata->npricingprobs;
1791 hashorig2pricingvar = NULL;
1792
1793 if( npricingprobs > 0 )
1794 {
1795 /* create hashmaps for mapping from original to pricing variables */
1796 SCIP_CALL( SCIPallocBufferArray(origprob, &(hashorig2pricingvar), npricingprobs) );
1797 }
1798
1799 SCIPdebugMessage("Creating master problem...\n");
1800
1801 SCIP_CALL( initRelaxProblemdata(gcg, relaxdata) );
1802
1803 /* get clocktype of the original SCIP instance in order to use the same clocktype in master and pricing problems */
1804 SCIP_CALL( SCIPgetIntParam(origprob, "timing/clocktype", &clocktype) );
1805
1806 /* get numerical tolerances of the original SCIP instance in order to use the same numerical tolerances in master and pricing problems */
1807 SCIP_CALL( SCIPgetRealParam(origprob, "numerics/infinity", &infinity) );
1808 SCIP_CALL( SCIPgetRealParam(origprob, "numerics/epsilon", &epsilon) );
1809 SCIP_CALL( SCIPgetRealParam(origprob, "numerics/sumepsilon", &sumepsilon) );
1810 SCIP_CALL( SCIPgetRealParam(origprob, "numerics/feastol", &feastol) );
1811 SCIP_CALL( SCIPgetRealParam(origprob, "numerics/lpfeastolfactor", &lpfeastolfactor) );
1812 SCIP_CALL( SCIPgetRealParam(origprob, "numerics/dualfeastol", &dualfeastol) );
1813
1814 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "master_%s", SCIPgetProbName(origprob));
1815 SCIP_CALL( createMasterProblem(gcg, name, clocktype, infinity, epsilon, sumepsilon, feastol,
1816 lpfeastolfactor, dualfeastol, relaxdata->mode) );
1817
1818 enableppcuts = FALSE;
1819 SCIP_CALL( SCIPgetBoolParam(origprob, "sepa/basis/enableppcuts", &enableppcuts) );
1820
1821 /* create the pricing problems */
1822 for( i = 0; i < npricingprobs; i++ )
1823 {
1824 relaxdata->convconss[i] = NULL;
1825 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "pricing_block_%d", i);
1826 SCIP_CALL( createPricingProblem(relaxdata, &(relaxdata->pricingprobs[i]), name, clocktype, infinity, epsilon, sumepsilon,
1827 feastol, lpfeastolfactor, dualfeastol, enableppcuts) );
1828 SCIP_CALL( SCIPhashmapCreate(&(hashorig2pricingvar[i]), SCIPblkmem(origprob), SCIPgetNVars(origprob)) ); /*lint !e613*/
1829
1830 /* disabling restarts from the tree size estimation */
1831 SCIP_CALL( SCIPsetCharParam(relaxdata->pricingprobs[i], "estimation/restarts/restartpolicy", 'n') );
1832 }
1833
1834 SCIP_CALL( createPricingVariables(gcg, relaxdata, hashorig2pricingvar) );
1835
1836 /* create master and pricing problem constraints
1837 * If the master problem is solved directly, then we can still call methods creating the pricing problems. These
1838 * methods check the number of pricing problems and number of blocks. As such, if the original problem is solved
1839 * directly, then nothing will happen in these methods
1840 */
1841 SCIP_CALL( createMasterprobConss(gcg, relaxdata) );
1842 SCIP_CALL( createPricingprobConss(gcg, relaxdata, hashorig2pricingvar) );
1844
1845 /* check if the master problem is a set partitioning or set covering problem */
1846 SCIP_CALL( checkSetppcStructure(gcg, relaxdata) );
1847
1848 /* check for identity of blocks */
1849 SCIP_CALL( checkIdenticalBlocks(gcg, relaxdata, hashorig2pricingvar) );
1850
1851 /* the convexity constraints are only added in the Dantzig-Wolfe mode */
1852 if( relaxdata->mode == GCG_DECMODE_DANTZIGWOLFE )
1853 {
1854 for( i = 0; i < relaxdata->npricingprobs; i++ )
1855 {
1856 if( relaxdata->blockrepresentative[i] != i )
1857 continue;
1858
1859 /* create the corresponding convexity constraint */
1860 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "conv_block_%d", i);
1861 SCIP_CALL( SCIPcreateConsLinear(GCGgetMasterprob(relaxdata->gcg), &(relaxdata->convconss[i]), name, 0, NULL, NULL,
1862 relaxdata->nblocksidentical[i]*1.0, relaxdata->nblocksidentical[i]*1.0,
1864 SCIP_CALL( SCIPaddCons(GCGgetMasterprob(relaxdata->gcg), relaxdata->convconss[i]) );
1865 }
1866 }
1867
1868 /* display statistics */
1869 if( relaxdata->dispinfos )
1870 {
1872 SCIP_CALL( SCIPwriteOrigProblem(GCGgetMasterprob(relaxdata->gcg), "masterprob.lp", "lp", FALSE) );
1873 }
1874
1875 if( hashorig2pricingvar != NULL )
1876 {
1877 for( i = 0; i < npricingprobs; i++ )
1878 SCIPhashmapFree(&(hashorig2pricingvar[i]));
1879
1880 SCIPfreeBufferArray(origprob, &(hashorig2pricingvar));
1881 }
1882
1883 /* get used memory and save it for reference */
1884 for( i = 0; i < npricingprobs; ++i )
1885 {
1886 relaxdata->pricingprobsmemused += SCIPgetMemUsed(relaxdata->pricingprobs[i])/1048576.0;
1887 }
1888
1889 return SCIP_OKAY;
1890}
1891
1892/** combines the solutions from all (disjoint) problems to one solution */
1893static
1895 GCG* gcg, /**< GCG data structure */
1896 SCIP_SOL** newsol, /**< pointer to store new solution */
1897 SCIP** probs, /**< array of (solved) subproblems */
1898 int nprobs /**< number of subproblems */
1899 )
1900{
1901 SCIP* scip;
1902#ifdef SCIP_DEBUG
1903 int i;
1904#endif
1905
1906 int v;
1907 int nvars;
1908
1909 SCIP_VAR** vars;
1910 assert(gcg != NULL);
1911 assert(newsol != NULL);
1912 assert(probs != NULL);
1913 assert(nprobs > 0);
1914
1916
1917 SCIP_CALL( SCIPcreateSol(scip, newsol, NULL) );
1920
1921#ifdef SCIP_DEBUG
1922 for( i = 0; i < nprobs; ++i )
1923 {
1924 if( probs[i] == NULL )
1925 continue;
1926
1927 SCIPprintOrigProblem(probs[i], NULL, "lp", FALSE);
1928 SCIPprintSol(probs[i], SCIPgetBestSol(probs[i]), NULL, FALSE );
1929 }
1930#endif
1931
1932 for( v = 0; v < nvars; ++v )
1933 {
1934 SCIP_VAR* pricingvar;
1935 int block;
1936
1937 pricingvar = GCGoriginalVarGetPricingVar(vars[v]);
1938 block = GCGvarGetBlock(pricingvar);
1939 assert(block >= 0);
1940 assert(block < nprobs);
1941 assert(probs[block] != NULL);
1942
1943 /* @todo solval should be 0 before, anyway, check it with an assert */
1944 SCIP_CALL( SCIPincSolVal(scip, *newsol, vars[v], SCIPgetSolVal(probs[block], SCIPgetBestSol(probs[block]), pricingvar)) );
1945 }
1946 return SCIP_OKAY;
1947}
1948
1949/** sets the pricing objective function to what is necessary */
1950static
1952 GCG* gcg, /**< GCG data structure */
1953 SCIP** probs, /**< array of subproblems */
1954 int nprobs /**< number of subproblems */
1955 )
1956{
1957 SCIP* scip;
1958 int v;
1959 int nvars;
1960 SCIP_VAR** vars;
1961 int i;
1962
1963 assert(gcg != NULL);
1964 assert(probs != NULL);
1965 assert(nprobs > 0);
1966
1970
1971 /* if the Benders' decomposition is used, then the transformed problem of the subproblems must be freed.
1972 * This is because the within the create subproblem stage, if the subproblem is an LP, then the SCIP instance is put
1973 * into probing mode.
1974 */
1976 {
1977 for( i = 0; i < nprobs; i++ )
1978 {
1979 /* if the problem is not in SCIP_STAGE_PROBLEM, then the transformed problem must be freed. The subproblem
1980 * should also be in probing mode.
1981 */
1982 if( SCIPgetStage(probs[i]) != SCIP_STAGE_PROBLEM )
1983 {
1984 if( SCIPinProbing(probs[i]) )
1985 {
1986 SCIP_CALL( SCIPendProbing(probs[i]) );
1987 }
1988
1989 SCIP_CALL( SCIPfreeTransform(probs[i]) );
1990 }
1991 }
1992 }
1993
1994 for( v = 0; v < nvars; ++v )
1995 {
1996 SCIP_VAR* pricingvar;
1997 SCIP_VAR* origvar;
1998 SCIP_Real objvalue;
1999
2001 origvar = SCIPvarGetProbvar(vars[v]);
2002
2004 continue;
2005
2006 pricingvar = GCGoriginalVarGetPricingVar(origvar);
2007 assert(pricingvar != NULL);
2008
2009 objvalue = SCIPvarGetObj(origvar);
2010 /* SCIPinfoMessage(scip, NULL, "%s: %f block %d\n", SCIPvarGetName(origvar), SCIPvarGetObj(origvar),
2011 GCGvarGetBlock(origvar)); */
2012 SCIP_CALL( SCIPchgVarObj(probs[GCGvarGetBlock(pricingvar)], pricingvar, objvalue) );
2013 }
2014 return SCIP_OKAY;
2015}
2016
2017/** solve a block problem when the decomposition is diagonal */
2018static
2020 GCG* gcg, /**< GCG data structure */
2021 SCIP* blockprob, /**< the block problem that will be solved */
2022 SCIP_RELAXDATA* relaxdata, /**< relaxator data structure */
2023 SCIP_Real timelimit, /**< the original problem timelimit */
2024 int blocknum, /**< the number of the block, -1 for the original problem */
2025 SCIP_RESULT* result, /**< result pointer to indicate success or failure */
2026 SCIP_Real* objvalue /**< the objective function value */
2027 )
2028{
2029 SCIP* scip;
2030 SCIP_Real blocktimelimit;
2031 SCIP_STATUS blockprobstatus = SCIP_STATUS_UNKNOWN;
2032
2033 assert(gcg != NULL);
2034 assert(result != NULL);
2035 assert(objvalue != NULL);
2036
2038 (*result) = SCIP_DIDNOTRUN;
2039
2040#ifdef SCIP_DEBUG
2041 char name[SCIP_MAXSTRLEN];
2042#endif
2043
2044 if( blockprob == NULL )
2045 {
2046 (*result) = SCIP_SUCCESS;
2047 return SCIP_OKAY;
2048 }
2049
2051 {
2052 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Solving block %i.\n", blocknum+1);
2053 }
2054
2055 SCIP_CALL( SCIPsetIntParam(blockprob, "display/verblevel", relaxdata->origverblevel) );
2057
2058 /* give the pricing problem 2% more time then the original scip has left */
2059 if( SCIPgetStage(blockprob) > SCIP_STAGE_PROBLEM )
2060 {
2061 if( SCIPisInfinity(scip, timelimit) )
2062 {
2063 blocktimelimit = SCIPinfinity(blockprob);
2064 }
2065 else
2066 {
2067 blocktimelimit = (timelimit - SCIPgetSolvingTime(scip)) * 1.02 + SCIPgetSolvingTime(blockprob);
2068 blocktimelimit = MIN(SCIPinfinity(blockprob), blocktimelimit); /*lint !e666*/
2069 }
2070 }
2071 else
2072 {
2073 if( SCIPisInfinity(scip, timelimit) )
2074 {
2075 blocktimelimit = SCIPinfinity(blockprob);
2076 }
2077 else
2078 {
2079 blocktimelimit = (timelimit - SCIPgetSolvingTime(scip)) * 1.02;
2080 blocktimelimit = MIN(SCIPinfinity(blockprob), blocktimelimit); /*lint !e666*/
2081 }
2082 }
2083
2084 if( blocktimelimit < 0 )
2085 {
2086 (*result) = SCIP_DIDNOTRUN;
2087 return SCIP_OKAY;
2088 }
2089
2090 SCIP_CALL( SCIPsetRealParam(blockprob, "limits/time", blocktimelimit) );
2091
2092#ifdef SCIP_DEBUG
2093 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "block_%i.lp", blocknum);
2094 SCIP_CALL( SCIPwriteOrigProblem(blockprob, name, "lp", FALSE) );
2095#endif
2096
2098 {
2099 /* try to solve with knapsack solver first */
2100 if( SCIPgetNConss(blockprob) == 1 )
2101 {
2103 GCG_PRICINGSTATUS status;
2104 int nsolvars;
2105 SCIP_VAR** solvars = NULL;
2106 SCIP_Real* solvals = NULL;
2107
2108 SCIP_CALL( GCGsolverKnapsackSolveKnapsack(TRUE, blockprob, &solval, &status, &solvars, &solvals, &nsolvars) );
2109
2110 if( solvars != NULL )
2111 {
2112 assert(solvals != NULL);
2113
2114 if( status == GCG_PRICINGSTATUS_OPTIMAL )
2115 {
2116 SCIP_SOL* sol = NULL;
2117 SCIP_Bool stored = FALSE;
2118 SCIPcreateSol(blockprob, &sol, NULL);
2119 SCIPsetSolVals(blockprob, sol, nsolvars, solvars, solvals);
2120 SCIPaddSolFree(blockprob, &sol, &stored);
2121 assert(stored);
2122 if( stored )
2123 {
2124 blockprobstatus = SCIP_STATUS_OPTIMAL;
2125 (*objvalue) += solval;
2126 }
2127 }
2128
2129 SCIPfreeBufferArray(blockprob, &solvals);
2130 SCIPfreeBufferArray(blockprob, &solvars);
2131 }
2132
2133 if( status == GCG_PRICINGSTATUS_INFEASIBLE )
2134 {
2135 blockprobstatus = SCIP_STATUS_INFEASIBLE;
2136 }
2137 }
2138
2139 if( blockprobstatus == SCIP_STATUS_UNKNOWN )
2140 {
2141 SCIP_CALL( SCIPsolve(blockprob) );
2142 blockprobstatus = SCIPgetStatus(blockprob);
2143 }
2144 }
2145 else
2146 {
2147 SCIP_BENDERS* benders;
2148 SCIP_Bool infeasible;
2149
2151
2152 /* retrieving the Benders' decomposition */
2153 benders = SCIPfindBenders(GCGgetMasterprob(gcg), "gcg");
2154
2155 /* since the diagonal blocks are being solved, this indicates that the subproblems are independent. As such, we
2156 * can declare this in the Benders' decomposition framework. This allows us to call
2157 * SCIPsolveBendersSubproblem() without setting up the problem
2158 */
2159 SCIPbendersSetSubproblemIsIndependent(benders, blocknum, TRUE);
2160
2161 /* solving the Benders' decomposition subproblem */
2162 SCIP_CALL( SCIPsolveBendersSubproblem(GCGgetMasterprob(gcg), benders, NULL, blocknum, &infeasible,
2163 TRUE, NULL) );
2164 }
2165
2166 switch( blockprobstatus )
2167 {
2171 /* no other blocks should be solved. */
2173 break;
2180 /* no other blocks should be solved. */
2182 break;
2185 (*result) = SCIP_SUCCESS;
2186 if( SCIPgetStage(blockprob) >= SCIP_STAGE_TRANSFORMED )
2187 (*objvalue) += SCIPgetDualbound(blockprob);
2188 break;
2189 default:
2190 break;
2191 } /*lint !e788*/
2192
2193 return SCIP_OKAY;
2194}
2195
2196/** frees the block problem */
2197static
2199 GCG* gcg, /**< GCG data structure */
2200 SCIP* blockprob, /**< the block problem that will be solved */
2201 SCIP_RELAXDATA* relaxdata, /**< relaxator data structure */
2202 int blocknum /**< the number of the block, -1 for the original problem */
2203 )
2204{
2205 assert(gcg != NULL);
2206
2207 if( blockprob == NULL )
2208 return SCIP_OKAY;
2209
2211 {
2212 SCIP_CALL( SCIPfreeTransform(blockprob) );
2213 }
2214 else
2215 {
2216 SCIP_BENDERS* benders;
2217
2219
2220 /* retrieving the Benders' decomposition */
2221 benders = SCIPfindBenders(GCGgetMasterprob(gcg), "gcg");
2222
2223 /* freeing the Benders' decomposition subproblems */
2225 }
2226
2227 return SCIP_OKAY;
2228}
2229
2230/** solves the blocks diagonal and individually */
2231static
2233 GCG* gcg, /**< GCG data structure */
2234 SCIP_RELAXDATA* relaxdata, /**< relaxator data structure */
2235 SCIP_RESULT* result, /**< result pointer to indicate success or failure */
2236 SCIP_Real* lowerbound /**< lower bound pointer to return the lower bound */
2237 )
2238{
2239 SCIP* scip;
2240 int i;
2241 SCIP_Real timelimit;
2242 SCIP_Real objvalue;
2243 SCIP_SOL *newsol;
2244 SCIP_Bool isfeasible;
2245 SCIP_RESULT solveresult;
2246
2248
2249 /* set objective of pricing problems to original objective */
2251 {
2253 }
2254
2255 SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) );
2256
2257 objvalue = 0.0;
2258
2260 {
2261 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Block diagonal structure detected, solving blocks individually.\n");
2262 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "There is an objective function offset of %f.\n", SCIPgetTransObjoffset(scip));
2263 }
2264
2265 /* if the original problem is solved directly, then we call solveBlockProblem with the master problem */
2267 {
2268 SCIP_CALL( solveBlockProblem(gcg, GCGgetMasterprob(gcg), relaxdata, timelimit, -1, &solveresult, &objvalue) );
2269
2270 if( solveresult == SCIP_CUTOFF || solveresult == SCIP_DIDNOTRUN )
2271 {
2272 (*result) = solveresult;
2273 return SCIP_OKAY;
2274 }
2275 }
2276 else
2277 {
2278 /* solve pricing problems one after the other */
2279 for( i = 0; i < relaxdata->npricingprobs; ++i )
2280 {
2281 SCIP_CALL( solveBlockProblem(gcg, relaxdata->pricingprobs[i], relaxdata, timelimit, i, &solveresult, &objvalue) );
2282
2283 if( solveresult == SCIP_CUTOFF || solveresult == SCIP_DIDNOTRUN )
2284 {
2285 (*result) = solveresult;
2286 return SCIP_OKAY;
2287 }
2288 }
2289 }
2290
2291 /* get solution and glue it together */
2292
2294 {
2296 }
2297 else
2298 {
2299 SCIP_CALL( combineSolutions(gcg, &newsol, relaxdata->pricingprobs, relaxdata->npricingprobs) );
2300 }
2301
2302 /* update lower bound pointer and add solution such that this node will be cut off automatically */
2304 *lowerbound = -objvalue;
2305 else
2306 *lowerbound = objvalue;
2307
2308 SCIP_CALL( SCIPcheckSol(scip, newsol, TRUE, TRUE, TRUE, TRUE, TRUE, &isfeasible) );
2309 assert(isfeasible);
2310
2311 SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, FALSE, TRUE, TRUE, TRUE, &isfeasible) );
2312
2313 /** @todo maybe add a constraint here to indicate that it has been decomposed */
2314
2315 /* if the original problem is solved directly, then we call freeBlockProblem with the master problem */
2317 {
2318 /* solve pricing problems one after the other */
2319 for( i = 0; i < relaxdata->npricingprobs; ++i )
2320 {
2321 SCIP_CALL( freeBlockProblem(gcg, relaxdata->pricingprobs[i], relaxdata, i) );
2322 }
2323 }
2324
2326
2327 return SCIP_OKAY;
2328
2329}
2330
2332 GCG* gcg
2333 )
2334{
2335 SCIP_RELAX* relax;
2336 SCIP_RELAXDATA* relaxdata;
2337
2338 assert(gcg != NULL);
2339
2340 relax = GCGgetRelax(gcg);
2341 assert(relax != NULL);
2342
2343 relaxdata = SCIPrelaxGetData(relax);
2344 assert(relaxdata != NULL);
2345
2346 return relaxdata->decomp;
2347}
2348
2349/** sets the structure information */
2350static
2352 GCG* gcg, /**< GCG data structure */
2353 GCG_DECOMP* decomp /**< decomposition data structure */
2354 )
2355{
2356 SCIP_RELAX* relax;
2357 SCIP_RELAXDATA* relaxdata;
2358
2359 assert(gcg != NULL);
2360 assert(decomp != NULL);
2361
2362 relax = GCGgetRelax(gcg);
2363 assert(relax != NULL);
2364
2365 relaxdata = SCIPrelaxGetData(relax);
2366 assert(relaxdata != NULL);
2367
2368 if( relaxdata->decomp != NULL )
2369 SCIP_CALL( GCGdecompFree(gcg, &relaxdata->decomp ) );
2370
2371 relaxdata->decomp = decomp;
2372
2373 return SCIP_OKAY;
2374}
2375
2376/** transforms the master problem **/
2377static
2379 GCG* gcg, /**< GCG data structure */
2380 SCIP_RELAX* relax /**< relaxator data structure */
2381 )
2382{
2383 SCIP* scip;
2385 SCIP_VAR** vars;
2386 SCIP_CONS** oldconss;
2387 SCIP_RELAXDATA* relaxdata;
2388 int i;
2389 int nvars;
2390
2391 assert(gcg != NULL);
2392 assert(relax != NULL);
2393
2395 relaxdata = SCIPrelaxGetData(relax);
2396 assert(relaxdata != NULL);
2397
2398 masterprob = GCGgetMasterprob(relaxdata->gcg);
2401 SCIP_CALL( SCIPduplicateBufferArray(scip, &oldconss, relaxdata->masterconss, relaxdata->nmasterconss) );
2402
2403 /* transform the master constraints */
2405 relaxdata->masterconss, relaxdata->masterconss) );
2406 for( i = 0; i < relaxdata->nmasterconss; ++i )
2407 {
2408 SCIP_CALL( SCIPreleaseCons(masterprob, &(oldconss[i])) );
2409 }
2410 SCIPfreeBufferArray(scip, &oldconss);
2411
2412 /* transform the convexity constraints */
2413 for( i = 0; i < relaxdata->npricingprobs; i++ )
2414 {
2415 if( relaxdata->convconss[i] != NULL )
2416 {
2417 SCIP_CONS* oldcons = relaxdata->convconss[i];
2418 SCIP_CALL( SCIPreleaseCons(masterprob, &oldcons) );
2419 SCIP_CALL( SCIPtransformCons(masterprob, relaxdata->convconss[i], &(relaxdata->convconss[i])) );
2420 }
2421 }
2422
2425
2426 /* transform the linking variable constraints */
2427 for( i = 0; i < nvars; ++i )
2428 {
2430
2432 {
2433 int j;
2434 SCIP_CONS** linkconss;
2435 linkconss = GCGlinkingVarGetLinkingConss(vars[i]);
2436 /* the linking constraints could be NULL if the Benders' decomposition is used. */
2437 if( linkconss != NULL )
2438 {
2439 for( j = 0; j < relaxdata->npricingprobs; ++j )
2440 {
2441 if( linkconss[j] != NULL )
2442 {
2443 SCIP_CONS* tempcons;
2444 SCIP_CALL( SCIPtransformCons(masterprob, linkconss[j], &(tempcons)) );
2445 GCGlinkingVarSetLinkingCons(vars[i], tempcons, j);
2446 }
2447 }
2448 }
2449 }
2450 }
2451 for( i = 0; i < relaxdata->nvarlinkconss; ++i )
2452 {
2453 SCIP_CONS* transcons;
2454
2455 SCIP_CALL( SCIPgetTransformedCons(masterprob, relaxdata->varlinkconss[i], &transcons) );
2456 assert(transcons != NULL);
2457
2459 relaxdata->varlinkconss[i] = transcons;
2460 }
2461 return SCIP_OKAY;
2462}
2463
2464/** initializes and transforms relaxator data */
2465static
2467 GCG* gcg, /**< GCG data structure */
2468 SCIP_RELAX* relax /**< relaxator data structure */
2469 )
2470{
2471 SCIP* scip;
2472 SCIP_RELAXDATA* relaxdata;
2473 int permutationseed;
2474 int oxfordcomma;
2475
2476 assert(gcg != NULL);
2477 assert(relax != NULL);
2478
2480 relaxdata = SCIPrelaxGetData(relax);
2481 assert(relaxdata != NULL);
2482
2483 /* when the original problem should be solved directly, then a decomposition must be made with zero blocks */
2485 {
2486 GCG_DECOMP* decomp;
2488
2489 assert(relaxdata->decomp == NULL);
2490
2491 retcode = GCGcreateBasicDecomp(gcg, &decomp, TRUE);
2493 if( retcode != SCIP_OKAY )
2494 {
2495 SCIPerrorMessage("Could not add decomp to cons_decomp!\n");
2496 return SCIP_ERROR;
2497 }
2498
2499 assert(decomp != NULL );
2500
2501 GCGsetStructDecomp(gcg, decomp);
2502 }
2503
2504 if( relaxdata->decomp == NULL )
2505 {
2506 relaxdata->decomp = GCGgetBestDecomp(gcg, TRUE);
2507 if( relaxdata->decomp == NULL )
2508 {
2509 PARTIALDECOMP_C* partialdec;
2510 SCIPwarningMessage(scip, "No complete decomposition available. Creating basic decomposition.\n");
2513
2514 relaxdata->decomp = GCGgetBestDecomp(gcg, FALSE);
2515 assert( relaxdata->decomp != NULL );
2516 }
2517 }
2518
2519 oxfordcomma = 0;
2520 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "Chosen structure has %d blocks", GCGdecompGetNBlocks(relaxdata->decomp));
2521 /* every master-only variable internally also counts as linking, but should not be reported as linking variable */
2522 if ( GCGdecompGetNLinkingvars(relaxdata->decomp) - GCGdecompGetNMastervars(relaxdata->decomp) > 0)
2523 {
2524 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, ", %d linking variables", GCGdecompGetNLinkingvars(relaxdata->decomp) - GCGdecompGetNMastervars(relaxdata->decomp));
2525 ++oxfordcomma;
2526 }
2527 if ( GCGdecompGetNMastervars(relaxdata->decomp) > 0 )
2528 {
2529 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, ", %d master-only (static) variables", GCGdecompGetNMastervars(relaxdata->decomp));
2530 ++oxfordcomma;
2531 }
2532 if ( oxfordcomma > 0 )
2533 {
2535 }
2536 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " and %d linking constraints.\n", GCGdecompGetNLinkingconss(relaxdata->decomp));
2537 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "This decomposition has a maxwhite score of %f.\n", GCGdecompGetMaxwhiteScore(relaxdata->decomp));
2538
2539 /* permute the decomposition if the permutation seed is set */
2540 SCIP_CALL( SCIPgetIntParam(scip, "randomization/permutationseed", &permutationseed) );
2541
2542 if( permutationseed > 0 )
2543 {
2544 SCIP_RANDNUMGEN* randnumgen;
2545
2546 SCIP_CALL( SCIPcreateRandom(scip, &randnumgen, (unsigned int) permutationseed, TRUE) );
2547 SCIP_CALL( GCGpermuteDecomp(gcg, relaxdata->decomp, randnumgen) );
2548 SCIPfreeRandom(scip, &randnumgen);
2549 }
2550
2551 if( relaxdata->discretization && (SCIPgetNContVars(scip) > 0) )
2552 {
2553 if( relaxdata->mipdiscretization )
2554 {
2555 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Warning: Discretization with continuous variables is only an experimental feature.\n");
2556 }
2557 else
2558 {
2559 SCIP_CALL( SCIPsetBoolParam(scip, "relaxing/gcg/discretization", FALSE) );
2560 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Warning: Discretization with continuous variables is disabled by parameter relaxing/gcg/mipdiscretization.\n");
2561 }
2562 }
2563
2564 SCIP_CALL( createMaster(gcg, relaxdata) );
2565
2566#ifdef _OPENMP
2568 {
2569 int ompmaxthreads = omp_get_max_threads();
2570 int nthreads = GCGpricerGetMaxNThreads(gcg);
2571 if( nthreads > 0 )
2572 nthreads = MIN(nthreads, GCGgetNRelPricingprobs(gcg));
2573 else
2574 nthreads = MIN(ompmaxthreads, GCGgetNRelPricingprobs(gcg));
2575 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Using up to %d (of %d) thread(s) to solve the pricing problems.\n", nthreads, ompmaxthreads);
2576 }
2577#endif
2578
2579 /* for Benders' decomposition, the Benders' plugin must be activated */
2580 if( relaxdata->mode == GCG_DECMODE_BENDERS )
2581 {
2583 relaxdata->npricingprobs) );
2584 }
2585
2586 relaxdata->lastsolvednodenr = -1;
2587
2588 /* set objective limit in master problem if objective limit in original problem is finite */
2590 {
2592 }
2593
2594 relaxdata->relaxisinitialized = TRUE;
2595
2596 return SCIP_OKAY;
2597}
2598
2599#ifdef _OPENMP
2600/** initializes all OpenMP locks */
2601static
2602void initLocks(
2603 GCG_LOCKS* locks /**< OpenMP locks */
2604 )
2605{
2606 assert(locks != NULL);
2607 GCG_INIT_LOCK(&locks->memorylock);
2608 GCG_INIT_LOCK(&locks->pricinglock);
2609 GCG_INIT_LOCK(&locks->pricinglimitslock);
2610 GCG_INIT_LOCK(&locks->pricestorelock);
2611 GCG_INIT_LOCK(&locks->printlock);
2612}
2613
2614/** destroys all OpenMP locks */
2615static
2616void destroyLocks(
2617 GCG_LOCKS* locks /**< OpenMP locks */
2618 )
2619{
2620 assert(locks != NULL);
2621 GCG_DESTROY_LOCK(&locks->memorylock);
2622 GCG_DESTROY_LOCK(&locks->pricinglock);
2623 GCG_DESTROY_LOCK(&locks->pricinglimitslock);
2624 GCG_DESTROY_LOCK(&locks->pricestorelock);
2625 GCG_DESTROY_LOCK(&locks->printlock);
2626}
2627#endif
2628
2629/** initializes relaxator data */
2630static
2632 GCG* gcg, /**< GCG data structure */
2633 SCIP_RELAXDATA* relaxdata /**< relaxdata data structure */
2634 )
2635{
2637 assert(relaxdata != NULL);
2638
2639 relaxdata->gcg = gcg;
2640 relaxdata->decomp = NULL;
2641
2642 relaxdata->nbranchrules = 0;
2643 relaxdata->branchrules = NULL;
2644 relaxdata->paramsvisu = NULL;
2645
2646 relaxdata->blockrepresentative = NULL;
2647 relaxdata->convconss = NULL;
2648 relaxdata->lastsolvednodenr = 0;
2649
2650 relaxdata->origmasterconss = NULL;
2651 relaxdata->masterconss = NULL;
2652 relaxdata->nmasterconss = 0;
2653
2654 relaxdata->npricingprobs = -1;
2655 relaxdata->maxpricingprobs = 0;
2656 relaxdata->pricingprobs = NULL;
2657 relaxdata->nrelpricingprobs = 0;
2658 relaxdata->currentorigsol = NULL;
2659 relaxdata->storedorigsol = NULL;
2660 relaxdata->origsolfeasible = FALSE;
2661 relaxdata->storedfeasibility = FALSE;
2662 relaxdata->nblocksidentical = NULL;
2663
2664 relaxdata->lastmastersol = NULL;
2665 relaxdata->lastmasterlpiters = 0;
2666 relaxdata->lastmasternode = -1;
2667 relaxdata->markedmasterconss = NULL;
2668 relaxdata->maxmarkedmasterconss = 0;
2669 relaxdata->masterinprobing = FALSE;
2670 relaxdata->probingheur = NULL;
2671
2672 relaxdata->ntransvars = 0;
2673 relaxdata->nlinkingvars = 0;
2674 relaxdata->nvarlinkconss = 0;
2675 relaxdata->varlinkconss = NULL;
2676 relaxdata->varlinkconsblock = NULL;
2677 relaxdata->pricingprobsmemused = 0.0;
2678
2679 relaxdata->relaxisinitialized = FALSE;
2680 relaxdata->simplexiters = 0;
2681 relaxdata->rootnodetime = NULL;
2682
2683 relaxdata->limitsettingsstashed = FALSE;
2684
2685 relaxdata->activebranchrules = NULL;
2686 relaxdata->activebranchdata = NULL;
2688 relaxdata->nactivebranchextendedmasterconss = 0;
2690
2691 relaxdata->separators = NULL;
2692 relaxdata->nseparators = 0;
2693
2694 SCIP_CALL( GCGcreateParamsVisu(gcg, &(relaxdata->paramsvisu)) );
2695 assert(relaxdata->paramsvisu != NULL);
2696
2697#ifdef _OPENMP
2698 SCIP_CALL( SCIPallocBlockMemory(origprob, &relaxdata->locks) );
2699 initLocks(relaxdata->locks);
2700#endif
2701
2702return SCIP_OKAY;
2703}
2704
2705/** resets relaxator data */
2706static
2708 SCIP_RELAXDATA* relaxdata /**< relaxdata data structure */
2709 )
2710{
2711 assert(relaxdata != NULL);
2712
2713 assert(relaxdata->decomp == NULL);
2714
2715 relaxdata->lastsolvednodenr = 0;
2716
2717 assert(relaxdata->origmasterconss == NULL);
2718 assert(relaxdata->masterconss == NULL);
2719 relaxdata->nmasterconss = 0;
2720
2721 relaxdata->npricingprobs = -1;
2722 relaxdata->nrelpricingprobs = 0;
2723 assert(relaxdata->currentorigsol == NULL);
2724 assert(relaxdata->storedorigsol == NULL);
2725 relaxdata->origsolfeasible = FALSE;
2726 relaxdata->storedfeasibility = FALSE;
2727
2728 relaxdata->lastmastersol = NULL;
2729 relaxdata->lastmasterlpiters = 0;
2730 relaxdata->lastmasternode = -1;
2731 assert(relaxdata->markedmasterconss == NULL);
2732 assert(relaxdata->maxmarkedmasterconss == 0);
2733 assert(relaxdata->masterinprobing == FALSE);
2734 assert(relaxdata->probingheur == NULL);
2735
2736 relaxdata->ntransvars = 0;
2737 relaxdata->nlinkingvars = 0;
2738 relaxdata->nvarlinkconss = 0;
2739 assert(relaxdata->varlinkconss == NULL);
2740 assert(relaxdata->varlinkconsblock == NULL);
2741 relaxdata->pricingprobsmemused = 0.0;
2742
2743 assert(relaxdata->relaxisinitialized == FALSE);
2744 relaxdata->simplexiters = 0;
2745 assert(relaxdata->rootnodetime == NULL);
2746}
2747
2748/*
2749 * Callback methods of relaxator
2750 */
2751
2752/** destructor of relaxator to free user data (called when SCIP is exiting) */
2753static
2755{
2756 SCIP_RELAXDATA* relaxdata;
2757 int i;
2758
2759 relaxdata = SCIPrelaxGetData(relax);
2760 assert(relaxdata != NULL);
2761
2762 /* free array for branchrules*/
2763 if( relaxdata->nbranchrules > 0 )
2764 {
2765 for( i = 0; i < relaxdata->nbranchrules; i++ )
2766 {
2767 SCIPfreeMemory(scip, &(relaxdata->branchrules[i]));
2768 }
2769 SCIPfreeMemoryArray(scip, &(relaxdata->branchrules));
2770 }
2771
2772 /* free array for separators*/
2773 if( relaxdata->nseparators > 0 )
2774 {
2775 for( i = 0; i < relaxdata->nseparators; i++ )
2776 {
2777 SCIPfreeMemory(scip, &(relaxdata->separators[i]));
2778 }
2779 SCIPfreeMemoryArray(scip, &(relaxdata->separators));
2780 }
2781
2782 /* free pricing problems */
2783 if( relaxdata->pricingprobs != NULL )
2784 {
2785 for( i = relaxdata->maxpricingprobs - 1; i >= 0 ; i-- )
2786 {
2787 SCIP_CALL( SCIPfree(&(relaxdata->pricingprobs[i])) );
2788 }
2792 SCIPfreeBlockMemoryArrayNull(scip, &(relaxdata->convconss), relaxdata->npricingprobs);
2793 }
2794
2795 /* free visualization parameters */
2796 if( relaxdata->paramsvisu != NULL )
2797 {
2798 GCGVisuFreeParams(relaxdata->gcg, relaxdata->paramsvisu);
2799 }
2800
2801 /* free master problem */
2802 if( relaxdata->gcg->dwmasterprob != NULL )
2803 {
2804 SCIP_CALL( SCIPfree(&(relaxdata->gcg->dwmasterprob)) );
2805 }
2806
2807 /* free the benders master problem */
2808 if( relaxdata->gcg->bendersmasterprob != NULL )
2809 {
2810 SCIP_CALL( SCIPfree(&(relaxdata->gcg->bendersmasterprob)) );
2811 }
2812
2813 /* free used decomposition */
2814 if( relaxdata->decomp != NULL )
2815 {
2816 SCIP_CALL( GCGdecompFree(relaxdata->gcg, &relaxdata->decomp) );
2817 }
2818
2819#ifdef _OPENMP
2820 /* free locks struct */
2821 if( relaxdata->locks != NULL )
2822 {
2823 destroyLocks(relaxdata->locks);
2824 SCIPfreeBlockMemory(scip, &relaxdata->locks);
2825 }
2826#endif
2827
2828 relaxdata->gcg->masterprob = NULL;
2829 relaxdata->gcg->dwmasterprob = NULL;
2830 relaxdata->gcg->bendersmasterprob = NULL;
2831 relaxdata->gcg->relax = NULL;
2832
2833 SCIPfreeMemory(scip, &relaxdata);
2834 return SCIP_OKAY;
2835}
2836
2837/** deinitialization method of relaxator (called before transformed problem is freed) */
2838
2839static
2841{
2842 SCIP_RELAXDATA* relaxdata;
2843 int i;
2844
2845 assert(scip != NULL);
2846 assert(relax != NULL);
2847
2848 relaxdata = SCIPrelaxGetData(relax);
2849 assert(relaxdata != NULL);
2850
2851 /* free pricing problems */
2852 for( i = relaxdata->npricingprobs - 1; i >= 0 ; i-- )
2853 {
2854 SCIP_CALL( SCIPfreeProb(relaxdata->pricingprobs[i]) );
2855 }
2856
2857 if( relaxdata->decomp != NULL )
2858 {
2859 SCIP_CALL( GCGdecompFree(relaxdata->gcg, &relaxdata->decomp) );
2860 relaxdata->decomp = NULL;
2861 }
2862
2863 relaxdata->relaxisinitialized = FALSE;
2864 relaxdata->limitsettingsstashed = FALSE;
2865
2866 return SCIP_OKAY;
2867}
2868
2869
2870/** initialize the relaxator and master problem for solving the original problem by Dantzig-Wolfe reformulation and
2871 * Benders' decomposition
2872 */
2873static
2875 GCG* gcg, /**< the GCG data structure */
2876 SCIP_RELAX* relax /**< the relaxator */
2877)
2878{
2879 SCIP* scip;
2880 SCIP_RELAXDATA* relaxdata;
2881
2882 assert(gcg != NULL);
2883 assert(relax != NULL);
2884
2886 relaxdata = SCIPrelaxGetData(relax);
2887 assert(relaxdata != NULL);
2888
2889 if( !SCIPisTransformed(GCGgetMasterprob(relaxdata->gcg)) )
2890 {
2891 /* set integral objective status in the extended problem, if possible */
2892 if( SCIPisObjIntegral(scip) && relaxdata->discretization && SCIPgetNContVars(scip) == 0
2893 && relaxdata->mode == GCG_DECMODE_DANTZIGWOLFE )
2894 {
2896 }
2897 SCIP_CALL( transformMaster(gcg, relax) );
2898 /* transform the decomposition */
2899 // SCIP_CALL( GCGdecompTransform(scip, relaxdata->decomp) );
2901 assert(relaxdata->decomp != NULL);
2902 }
2903
2904 return SCIP_OKAY;
2905}
2906
2907
2908/** solving process initialization method of relaxator (called when branch and bound process is about to begin) */
2909static
2911{
2912 SCIP_RELAXDATA* relaxdata;
2913
2914 assert(scip != NULL);
2915 assert(relax != NULL);
2916
2917 relaxdata = SCIPrelaxGetData(relax);
2918 assert(relaxdata != NULL);
2919 assert(GCGgetMasterprob(relaxdata->gcg) != NULL);
2920
2921 resetRelaxdata(relaxdata);
2922 SCIP_CALL( SCIPcreateClock(scip, &(relaxdata->rootnodetime)) );
2923
2924 /* set active masterprob */
2925 switch( GCGgetDecompositionMode(relaxdata->gcg) )
2926 {
2929 {
2930 relaxdata->gcg->masterprob = relaxdata->gcg->bendersmasterprob;
2931 break;
2932 }
2934 {
2935 relaxdata->gcg->masterprob = relaxdata->gcg->dwmasterprob;
2936 break;
2937 }
2938 default:
2939 {
2940 SCIPerrorMessage("Unknown decomposition mode.");
2941 return SCIP_ERROR;
2942 }
2943 }
2944
2945 /* alternative verbosity levels are used for the Benders' decomposition and original mode compared to the Dantzig-Wolfe
2946 * decomposition mode.
2947 */
2949 {
2950 /* first getting the verbosity level for the original problem before setting it to none. While the verbosity level
2951 * was collected previously, the user may have changed this in the mean time.
2952 */
2953 SCIP_CALL( SCIPgetIntParam(scip, "display/verblevel", &relaxdata->origverblevel) );
2954
2955 /* deactivating display columns */
2956 SCIP_CALL( SCIPsetIntParam(scip, "display/sumlpiterations/active", 0) );
2957 SCIP_CALL( SCIPsetIntParam(scip, "display/lpiterations/active", 0) );
2958 SCIP_CALL( SCIPsetIntParam(scip, "display/degeneracy/active", 0) );
2959
2960 /* setting the total node limit to 1 for the original SCIP instance. This is because Benders' decomposition solves
2961 * the MIP within the relaxator of the root node. So no branching in the original problem is required.
2962 */
2963 SCIP_CALL( SCIPsetLongintParam(scip, "limits/totalnodes", 1LL) );
2964 }
2965
2966 /* fixing the GCG mode parameter. This ensure that the user does not change this during the solution process. If the
2967 * mode parameter were to change, the behaviour is unknown.
2968 */
2969 SCIP_CALL( SCIPfixParam(scip, "relaxing/gcg/mode") );
2970
2971 /* Informing the user of the decomposition technique that is being used to solve the original problem */
2973 if( relaxdata->mode == GCG_DECMODE_DANTZIGWOLFE )
2974 {
2975 SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, "A Dantzig-Wolfe reformulation is applied to solve the original problem.\n");
2976 }
2977 else if( relaxdata->mode == GCG_DECMODE_BENDERS )
2978 {
2979 SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, "A Benders' decomposition is applied to solve the original problem.\n");
2980 }
2981 else if( relaxdata->mode == GCG_DECMODE_ORIGINAL )
2982 {
2983 SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, "No reformulation will be performed. Solving the original model.\n");
2984 }
2985
2986 if( !SCIPisStopped(scip) )
2987 SCIP_CALL( initRelaxator(relaxdata->gcg, relax) );
2988
2989 return SCIP_OKAY;
2990}
2991
2992
2993/** solving process deinitialization method of relaxator (called before branch and bound process data is freed) */
2994static
2996{
2997 SCIP_RELAXDATA* relaxdata;
2998 int i;
2999
3000 assert(scip != NULL);
3001 assert(relax != NULL);
3002
3003 relaxdata = SCIPrelaxGetData(relax);
3004 assert(relaxdata != NULL);
3005
3007 relaxdata->maxmarkedmasterconss = 0;
3008
3009 /* free arrays for constraints */
3010 for( i = 0; i < relaxdata->nmasterconss; i++ )
3011 {
3013 SCIP_CALL( SCIPreleaseCons(GCGgetMasterprob(relaxdata->gcg), &relaxdata->masterconss[i]) );
3014 }
3015 for( i = 0; i < relaxdata->npricingprobs; i++ )
3016 {
3017 if( relaxdata->convconss[i] != NULL )
3018 SCIP_CALL( SCIPreleaseCons(GCGgetMasterprob(relaxdata->gcg), &relaxdata->convconss[i]) );
3019 }
3020 for( i = 0; i < relaxdata->nvarlinkconss; i++ )
3021 {
3022 SCIP_CALL( SCIPreleaseCons(GCGgetMasterprob(relaxdata->gcg), &relaxdata->varlinkconss[i]) );
3023 }
3024 SCIPfreeBlockMemoryArrayNull(scip, &(relaxdata->varlinkconss), relaxdata->nvarlinkconss);
3027 SCIPfreeBlockMemoryArrayNull(scip, &(relaxdata->masterconss), relaxdata->maxmasterconss);
3028
3029 /* free master problem */
3030 if( GCGgetMasterprob(relaxdata->gcg) != NULL )
3031 {
3033 }
3034
3035 /* free solutions */
3036 if( relaxdata->currentorigsol != NULL )
3037 {
3038 SCIP_CALL( SCIPfreeSol(scip, &relaxdata->currentorigsol) );
3039 relaxdata->currentorigsol = NULL;
3040 }
3041 if( relaxdata->storedorigsol != NULL )
3042 {
3043 SCIP_CALL( SCIPfreeSol(scip, &relaxdata->storedorigsol) );
3044 relaxdata->storedorigsol = NULL;
3045 }
3046
3047 if( relaxdata->decomp != NULL )
3048 {
3049 SCIP_CALL( GCGdecompFree(relaxdata->gcg, &relaxdata->decomp) );
3050 relaxdata->decomp = NULL;
3051 }
3052
3053 SCIP_CALL( GCGfreeOrigVarsData(relaxdata->gcg) );
3054
3055 /* free root node clock */
3056 if( relaxdata->rootnodetime != NULL )
3057 {
3058 SCIP_CALL( SCIPfreeClock(scip, &(relaxdata->rootnodetime)) );
3059 relaxdata->rootnodetime = NULL;
3060 }
3061
3062 if( relaxdata->maxactivebranchextendedmasterconss > 0 )
3063 {
3068 relaxdata->nactivebranchextendedmasterconss = 0;
3069 }
3070
3071 relaxdata->relaxisinitialized = FALSE;
3072
3073 return SCIP_OKAY;
3074}
3075
3076
3077/** sets (time and gap) limits in the master problem based on limits of the original problem */
3078static
3080 GCG* gcg, /**< the GCG data structure */
3081 SCIP* masterprob, /**< the master problem SCIP instance */
3082 SCIP_Real origtimelimit, /**< time limit fo the original problem */
3083 SCIP_Real origgaplimit /**< gap limit of the original problem */
3084 )
3085{
3086 SCIP* scip;
3087 SCIP_Real mastertimelimit;
3088
3090 mastertimelimit = SCIPinfinity(scip);
3091
3092 if( masterprob == NULL )
3094
3095 if( !SCIPisInfinity(scip, origtimelimit) )
3096 {
3097 /* give the master 0.5 seconds more time than the original scip has left */
3098 mastertimelimit = (origtimelimit - SCIPgetSolvingTime(scip)) + 0.5 + SCIPgetSolvingTime(masterprob);
3099 assert(origtimelimit - SCIPgetSolvingTime(scip) > 0 || SCIPisStopped(scip));
3100
3101 SCIPdebugMessage(" time limit for master: %f, left: %f, left for original problem: %f\n",
3102 mastertimelimit,
3103 mastertimelimit - SCIPgetSolvingTime(masterprob),
3104 origtimelimit - SCIPgetSolvingTime(scip));
3105 }
3106 SCIP_CALL( SCIPsetRealParam(masterprob, "limits/time", mastertimelimit) );
3107
3108 /* set gap limit */
3109 SCIP_CALL( SCIPsetRealParam(masterprob, "limits/gap", origgaplimit) );
3110 return SCIP_OKAY;
3111}
3112
3113
3114/** method to solve the master problem that is used by Dantzig-Wolfe and Benders' decomposition */
3115static
3117 GCG* gcg, /**< the GCG data structure */
3118 SCIP* masterprob, /**< the master problem SCIP instance */
3119 SCIP_RELAXDATA* relaxdata, /**< the relaxator data */
3120 SCIP_Longint nodelimit, /**< the number of nodes the will be solved in this master problem */
3121 SCIP_Real* lowerbound, /**< the lowerbound computed by the relaxator for the current node */
3122 SCIP_RESULT* result /**< the result of the relaxation call */
3123 )
3124{
3125 SCIP* scip;
3126 assert(gcg != NULL);
3128 assert(relaxdata != NULL);
3129
3131
3132 /* update the number of the last solved node */
3134
3135 /* increase the node limit for the master problem by 1 */
3136 SCIP_CALL( SCIPsetLongintParam(masterprob, "limits/nodes", nodelimit) );
3137
3138 /* loop to solve the master problem, this is a workaround and does not fix any problem */
3139 do
3140 {
3141 SCIP_Real timelimit;
3142 SCIP_Real memorylimit;
3143 SCIP_Real gaplimit;
3144
3145 /* set memorylimit for master */
3146 SCIP_CALL( SCIPgetRealParam(scip, "limits/memory", &memorylimit) );
3147 if( !SCIPisInfinity(scip, memorylimit) )
3148 memorylimit -= SCIPgetMemUsed(scip)/1048576.0;
3149
3150 SCIP_CALL( SCIPsetRealParam(masterprob, "limits/memory", memorylimit) );
3151
3152 SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) );
3153 SCIP_CALL( SCIPgetRealParam(scip, "limits/gap", &gaplimit) );
3154
3155 SCIP_CALL( setMasterLimits(gcg, masterprob, timelimit, gaplimit) );
3156
3157 /* if we have a blockdetection, see whether the node is block diagonal. Additionally, the solveDiagonalBlocks can
3158 * be called when the original problem is solved directly.
3159 */
3160 if( GCGdecompGetType(relaxdata->decomp) == GCG_DECTYPE_DIAGONAL || relaxdata->mode == GCG_DECMODE_ORIGINAL )
3161 {
3162 SCIP_CALL( solveDiagonalBlocks(gcg, relaxdata, result, lowerbound) );
3163 if( *result == SCIP_SUCCESS || *result == SCIP_CUTOFF )
3164 {
3166 return SCIP_OKAY;
3167 }
3168 }
3169 /* We are solving the masterproblem regularly */
3170 else
3171 {
3173 }
3174
3175
3177 {
3178 break;
3179 }
3180
3181 if( !SCIPisInfinity(scip, timelimit) && !SCIPisStopped(scip) )
3182 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "time for master problem was too short, extending time.\n");
3183 }
3184 while( !SCIPisStopped(scip) );
3185
3187 {
3189 {
3191 return SCIP_OKAY;
3192 }
3193 }
3194
3195 /* set the lower bound pointer */
3197 {
3198 *lowerbound = SCIPgetLocalDualbound(masterprob);
3199 if( SCIPisInfinity(scip, *lowerbound) )
3200 {
3202 return SCIP_OKAY;
3203 }
3204 }
3205 else
3206 {
3207 SCIPdebugMessage(" stage: %d\n", SCIPgetStage(masterprob));
3210 {
3212 assert(!SCIPisInfinity(scip, *lowerbound));
3213 }
3215 {
3216 SCIP_Real tilim;
3217 SCIP_CALL( SCIPgetRealParam(masterprob, "limits/time", &tilim) );
3218 if( tilim-SCIPgetSolvingTime(masterprob) < 0 )
3219 {
3221 return SCIP_OKAY;
3222 }
3223 *lowerbound = SCIPinfinity(scip);
3225 return SCIP_OKAY;
3226 }
3228 {
3230 return SCIP_OKAY;
3231 }
3232 else
3233 {
3234 SCIPwarningMessage(scip, "Stage <%d> is not handled!\n", SCIPgetStage(masterprob));
3236 return SCIP_OKAY;
3237 }
3238 }
3239
3240 SCIPdebugMessage(" update lower bound (value = %g).\n", *lowerbound);
3241
3242 /* NOTE: All other points when result is set, the function is exited immediately. Ensure that this is checked for
3243 * future changes to this function
3244 */
3246
3247 return SCIP_OKAY;
3248}
3249
3250
3251/** execution method of the relaxator for Dantzig-Wolfe reformulation */
3252static
3254 GCG* gcg, /**< the GCG data structure */
3255 SCIP_RELAX* relax, /**< the relaxator */
3256 SCIP_Real* lowerbound, /**< the lowerbound computed by the relaxator for the current node */
3257 SCIP_RESULT* result /**< the result of the relaxation call */
3258 )
3259{
3260 SCIP* scip;
3262 SCIP_RELAXDATA* relaxdata;
3263 SCIP_Longint oldnnodes;
3264 SCIP_Longint nodelimit;
3265 SCIP_Bool stored;
3266
3267 assert(gcg != NULL);
3268 assert(relax != NULL);
3269 assert(result != NULL);
3271
3273 relaxdata = SCIPrelaxGetData(relax);
3274 assert(relaxdata != NULL);
3276
3279
3280 assert(relaxdata->gcg->masterprob == relaxdata->gcg->dwmasterprob);
3281
3282 /* solve the next node in the master problem */
3284
3285 /* only solve the relaxation if it was not yet solved at the current node */
3287 {
3288 SCIP_CONS* activeorigcons;
3289
3290 /* start root node time clock */
3292 {
3293 SCIP_CALL( SCIPstartClock(scip, relaxdata->rootnodetime) );
3294 SCIPdebugMessage(" root node time clock started.\n");
3295 }
3296
3297 /* increase the node limit for the master problem by 1 */
3298 SCIP_CALL( SCIPgetLongintParam(masterprob, "limits/nodes", &oldnnodes) );
3299
3300 nodelimit = (SCIPgetRootNode(scip) == SCIPgetCurrentNode(scip) ? 1 : oldnnodes + 1);
3301 /* solving the master problem */
3302 SCIP_CALL( solveMasterProblem(gcg, masterprob, relaxdata, nodelimit, lowerbound, result) );
3303 assert(*result == SCIP_CUTOFF || !SCIPisInfinity(scip, *lowerbound));
3304
3305 if( relaxdata->currentorigsol != NULL )
3306 {
3307 SCIP_CALL( SCIPtrySol(scip, relaxdata->currentorigsol, FALSE, FALSE, TRUE, TRUE, TRUE, &stored) );
3308 }
3309
3310 /* if a new primal solution was found in the master problem, transfer it to the original problem */
3312 {
3313 SCIP_SOL* newsol;
3314
3316
3318 #ifdef SCIP_DEBUG
3319 SCIP_CALL( SCIPtrySol(scip, newsol, TRUE, TRUE, TRUE, TRUE, TRUE, &stored) );
3320 #else
3321 SCIP_CALL( SCIPtrySol(scip, newsol, FALSE, FALSE, TRUE, TRUE, TRUE, &stored) );
3322 #endif
3323 #ifndef NDEBUG
3324 /* only check failed solution if best master solution is valid */
3325 if( !stored && GCGmasterIsBestsolValid(gcg) )
3326 {
3327 SCIP_CALL( SCIPcheckSolOrig(scip, newsol, &stored, TRUE, TRUE) );
3328 }
3329 #endif
3330 /** @bug The solution doesn't have to be accepted, numerics might bite us, so the transformation might fail.
3331 * A remedy could be: Round the values or propagate changes or call a heuristic to fix it.
3332 * SCIP rejects a solution if it is equal to a known one
3333 */
3334 SCIP_CALL( SCIPfreeSol(scip, &newsol) );
3335
3336 if( stored )
3337 SCIPdebugMessage(" updated current best primal feasible solution.\n");
3338 }
3339
3340 activeorigcons = GCGconsOrigbranchGetActiveCons(gcg);
3341 if( GCGconsOrigbranchGetBranchrule(activeorigcons) != NULL )
3342 {
3344 GCGconsOrigbranchGetBranchdata(activeorigcons), *lowerbound) );
3345 }
3346
3347 /* stop root node clock */
3349 {
3350 SCIP_CALL( SCIPstopClock(scip, relaxdata->rootnodetime) );
3351 SCIPdebugMessage(" root node time clock stopped at %6.2fs.\n", SCIPgetClockTime(scip, relaxdata->rootnodetime));
3352 }
3353 }
3354 else
3355 {
3356 SCIPdebugMessage("Problem has been already solved at this node\n");
3357 }
3358
3361
3362 return SCIP_OKAY;
3363}
3364
3365
3366/** method to solve the master problem for Benders' decomposition and when solving the original problem directly. */
3367static
3369 GCG* gcg, /**< the GCG data structure */
3370 SCIP_RELAX* relax, /**< the relaxator */
3371 SCIP_Real* lowerbound, /**< the lowerbound computed by the relaxator for the current node */
3372 SCIP_RESULT* result /**< the result of the relaxation call */
3373 )
3374{
3375 SCIP* scip;
3377 SCIP_RELAXDATA* relaxdata;
3378 SCIP_Longint nodelimit;
3379
3380 assert(gcg != NULL);
3381 assert(relax != NULL);
3382 assert(result != NULL);
3383
3385 relaxdata = SCIPrelaxGetData(relax);
3386 assert(relaxdata != NULL);
3388
3389 masterprob = GCGgetMasterprob(relaxdata->gcg);
3391
3392 assert(relaxdata->gcg->masterprob == relaxdata->gcg->bendersmasterprob);
3393
3394 /* solve the next node in the master problem */
3396
3397 /* prior to performing the decomposition the original problem verbosity is changed to NONE. This avoids output from
3398 * the original problem before the decomposition output. Once the decomposition has been performed, then the
3399 * verbosity level of the original problem is returned to the original verbosity level.
3400 */
3401 SCIP_CALL( SCIPsetIntParam(scip, "display/verblevel", relaxdata->origverblevel) );
3402 SCIP_CALL( SCIPsetIntParam(masterprob, "display/verblevel", relaxdata->origverblevel) );
3404
3405 /* getting the node limit from the original problem. This is because the master problem is solved to optimality in
3406 * the execution of the relaxator.
3407 */
3408 SCIP_CALL( SCIPgetLongintParam(scip, "limits/nodes", &nodelimit) );
3409
3410 /* solving the master problem */
3411 SCIP_CALL( solveMasterProblem(gcg, masterprob, relaxdata, nodelimit, lowerbound, result) );
3412
3413 /* if the master problem has been detected as infeasible, then the result must be set to SCIP_CUTOFF. */
3415 (*result) = SCIP_CUTOFF;
3416
3417 /* if the master problem has been solved to optimality, the we cutoff the root node. This informs that original
3418 * problem that no further processing is required.
3419 */
3421 {
3422 (*result) = SCIP_CUTOFF;
3423 }
3424
3425 /* if there is no primal solution for the original problem, then the master solution is transferred */
3427 {
3428 SCIP_SOL* newsol;
3429 SCIP_Bool stored;
3430
3431 relaxdata->lastmastersol = SCIPgetBestSol(GCGgetMasterprob(relaxdata->gcg));
3432
3434#ifdef SCIP_DEBUG
3435 SCIP_CALL( SCIPtrySol(scip, newsol, TRUE, TRUE, TRUE, TRUE, TRUE, &stored) );
3436#else
3437 SCIP_CALL( SCIPtrySol(scip, newsol, FALSE, FALSE, TRUE, TRUE, TRUE, &stored) );
3438#endif
3439 /* only check failed solution if best master solution is valid */
3440 if( !stored && GCGmasterIsBestsolValid(gcg) )
3441 {
3442 SCIP_CALL( SCIPcheckSolOrig(scip, newsol, &stored, TRUE, TRUE) );
3443 }
3444 /** @bug The solution doesn't have to be accepted, numerics might bite us, so the transformation might fail.
3445 * A remedy could be: Round the values or propagate changes or call a heuristic to fix it.
3446 */
3447 SCIP_CALL( SCIPfreeSol(scip, &newsol) );
3448
3449 if( stored )
3450 SCIPdebugMessage(" updated current best primal feasible solution.\n");
3451 }
3452
3453 /* set the lower bound pointer */
3456 {
3457 *lowerbound = SCIPgetDualbound(masterprob);
3458 }
3459
3460 /* if the time, memory or node limit is hit in the Original or Benders mode, then we need to interrupt the solve.
3461 * This is required because the original problem is not solved in either of these modes, so it is not certain that
3462 * the original SCIP will also exceed the limit (definitely not for the node limit).
3463 */
3466 {
3468 }
3469
3470 /* if the result pointer is DIDNOTRUN, this implies that the master problem was interrupted during solving. Since
3471 * Benders' decomposition uses a one-tree approach, then the user limits must be adhered to. This means, the if a
3472 * limit is exceeded, this is still a success for the solving.
3473 */
3474 if( (*result) == SCIP_DIDNOTRUN )
3475 (*result) = SCIP_SUCCESS;
3476
3477 return SCIP_OKAY;
3478}
3479
3480/** execution method of the relaxator for Benders' decomposition */
3481static
3483 GCG* gcg, /**< the GCG data structure */
3484 SCIP_RELAX* relax, /**< the relaxator */
3485 SCIP_Real* lowerbound, /**< the lowerbound computed by the relaxator for the current node */
3486 SCIP_RESULT* result /**< the result of the relaxation call */
3487 )
3488{
3489 assert(gcg != NULL);
3490 assert(relax != NULL);
3491 assert(result != NULL);
3492
3493 SCIP_CALL( solveMasterProblemAndEvaluate(gcg, relax, lowerbound, result) );
3494
3495 return SCIP_OKAY;
3496}
3497
3498/** execution method of the relaxator when the original problem is solved directly */
3499static
3501 GCG* gcg, /**< the GCG data structure */
3502 SCIP_RELAX* relax, /**< the relaxator */
3503 SCIP_Real* lowerbound, /**< the lowerbound computed by the relaxator for the current node */
3504 SCIP_RESULT* result /**< the result of the relaxation call */
3505 )
3506{
3507 assert(gcg != NULL);
3508 assert(relax != NULL);
3509 assert(result != NULL);
3510
3511 SCIP_CALL( solveMasterProblemAndEvaluate(gcg, relax, lowerbound, result) );
3512
3513 return SCIP_OKAY;
3514}
3515
3516
3517/** execution method of relaxator */
3518static
3520{
3521 SCIP_RELAXDATA* relaxdata;
3522
3523 assert(scip != NULL);
3524 assert(relax != NULL);
3525 assert(result != NULL);
3526
3527 relaxdata = SCIPrelaxGetData(relax);
3528 assert(relaxdata != NULL);
3529
3530 SCIP_CALL( initializeMasterProblemSolve(relaxdata->gcg, relax) );
3531
3534 /* construct the LP in the original problem */
3536 assert(!cutoff);
3538 }
3539
3540 /* selecting the solving algorithm based upon the decomposition mode selected by the user, or whether the original
3541 * problem should be solved directly
3542 */
3544 {
3545 SCIP_CALL( GCGrestoreLimitSettings(relaxdata->gcg) );
3546 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "There are no pricing problems in the decomposition. The original problem will be solved directly.\n");
3547 SCIP_CALL( relaxExecGcgOriginalProblem(relaxdata->gcg, relax, lowerbound, result) );
3548 }
3549 else if( relaxdata->mode == GCG_DECMODE_DANTZIGWOLFE )
3550 {
3551 SCIP_CALL( relaxExecGcgDantzigWolfe(relaxdata->gcg, relax, lowerbound, result) );
3552 }
3553 else if( relaxdata->mode == GCG_DECMODE_BENDERS )
3554 {
3555 SCIP_CALL( GCGrestoreLimitSettings(relaxdata->gcg) );
3556 SCIP_CALL( relaxExecGcgBendersDecomposition(relaxdata->gcg, relax, lowerbound, result) );
3557 }
3558 else
3559 {
3560 SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "Sorry, the automatic selection is not currently available\n");
3561 }
3562
3563 assert(*result == SCIP_CUTOFF || !SCIPisInfinity(scip, *lowerbound));
3564
3565 return SCIP_OKAY;
3566}
3567
3568#define relaxCopyGcg NULL
3569#define relaxInitGcg NULL
3570
3571
3572/*
3573 * relaxator specific interface methods
3574 */
3575
3576/** creates the GCG relaxator and includes it in SCIP */
3578 GCG* gcg /**< GCG data structure */
3579 )
3580{
3581 SCIP_RELAX* relax;
3582 SCIP_RELAXDATA* relaxdata;
3583 SCIP* origprob;
3584
3586 assert(origprob != NULL);
3587
3588#ifdef _OPENMP
3589 {
3590 char name[SCIP_MAXSTRLEN];
3591 SCIPsnprintf(name, SCIP_MAXSTRLEN, "OpenMP %d", _OPENMP);
3592 SCIP_CALL( SCIPincludeExternalCodeInformation(origprob, name, "multi-platform shared-memory parallel programming library (openmp.org)") );
3593 }
3594#endif
3595
3596#ifdef WITH_BLISS
3597 {
3598 char name[SCIP_MAXSTRLEN];
3600 SCIP_CALL( SCIPincludeExternalCodeInformation(origprob, name, "A Tool for Computing Automorphism Groups of Graphs by T. Junttila and P. Kaski (http://www.tcs.hut.fi/Software/bliss/)") );
3601 }
3602#endif
3603
3604#ifdef WITH_NAUTY
3605 {
3606 char name[SCIP_MAXSTRLEN];
3608 SCIP_CALL( SCIPincludeExternalCodeInformation(origprob, name, "Tool for Computing Automorphism Groups of Graphs by B.D. McKay and A. Piperno (https://pallini.di.uniroma1.it/)") );
3609 }
3610#endif
3611
3612 /* create GCG relaxator data */
3613 SCIP_CALL( SCIPallocMemory(origprob, &relaxdata) );
3614 SCIP_CALL( initRelaxdata(gcg, relaxdata) );
3615
3616 /* include relaxator */
3618 relaxExitGcg, relaxInitsolGcg, relaxExitsolGcg, relaxExecGcg, relaxdata) );
3620 assert(relax != NULL);
3621 gcg->relax = relax;
3622
3623 /* inform the main scip, that no LPs should be solved */
3624 SCIP_CALL( SCIPsetIntParam(origprob, "lp/solvefreq", 0) );
3625
3626 /* Disable restarts */
3627 SCIP_CALL( SCIPsetIntParam(origprob, "presolving/maxrestarts", 0) );
3628 SCIP_CALL( SCIPsetBoolParam(origprob, "misc/calcintegral", FALSE) );
3629
3630 /* initialize the scip data structure for the master problem. The master problem is initialized as the Dantzig-Wolfe
3631 * master problem. The alternate master problem is initialized as the Benders' decomposition master problem.
3632 */
3633 SCIP_CALL( SCIPcreate(&(gcg->dwmasterprob)) );
3634 gcg->masterprob = gcg->dwmasterprob;
3635 SCIP_CALL( GCGincludePricerGcg(relaxdata->gcg) );
3638
3639 /* getting the verbosity level of the original problem */
3640 SCIP_CALL( SCIPgetIntParam(origprob, "display/verblevel", &relaxdata->origverblevel) );
3641
3642 /* disable display output in the master problem */
3643 SCIP_CALL( SCIPsetIntParam(gcg->masterprob, "display/verblevel", (int)SCIP_VERBLEVEL_NONE) );
3644
3645 /* set parameters in master problem */
3646 SCIP_CALL( SCIPsetIntParam(gcg->masterprob, "pricing/maxvars", INT_MAX) );
3647 SCIP_CALL( SCIPsetIntParam(gcg->masterprob, "pricing/maxvarsroot", INT_MAX) );
3648 SCIP_CALL( SCIPsetRealParam(gcg->masterprob, "pricing/abortfac", 1.0) );
3649 SCIP_CALL( SCIPsetIntParam(gcg->masterprob, "lp/disablecutoff", 1) );
3650#ifdef DELVARS
3651 /* set paramteters to allow deletion of variables */
3652 SCIP_CALL( SCIPsetBoolParam(gcg->masterprob, "pricing/delvars", TRUE) );
3653 SCIP_CALL( SCIPsetBoolParam(gcg->masterprob, "pricing/delvarsroot", TRUE) );
3654 SCIP_CALL( SCIPsetBoolParam(gcg->masterprob, "lp/cleanupcols", TRUE) );
3655 SCIP_CALL( SCIPsetBoolParam(gcg->masterprob, "lp/cleanupcolsroot", TRUE) );
3656#endif
3657
3658 /* initializing the alternate master problem. The alternate master problem is initially the Benders' decomposition
3659 * master problem
3660 */
3661 SCIP_CALL( SCIPcreate(&(gcg->bendersmasterprob)) );
3665
3666 SCIP_CALL( SCIPsetIntParam(gcg->bendersmasterprob, "display/verblevel", (int)SCIP_VERBLEVEL_NONE) );
3667 SCIP_CALL( SCIPsetBoolParam(gcg->bendersmasterprob, "display/relevantstats", FALSE) );
3668
3669 /* add GCG relaxator parameters */
3670 SCIP_CALL( SCIPaddBoolParam(origprob, "relaxing/gcg/discretization",
3671 "should discretization (TRUE) or convexification (FALSE) approach be used?",
3673 SCIP_CALL( SCIPaddBoolParam(origprob, "relaxing/gcg/mipdiscretization",
3674 "should discretization (TRUE) or convexification (FALSE) approach be used in mixed-integer programs?",
3676 SCIP_CALL( SCIPaddBoolParam(origprob, "relaxing/gcg/aggregation/enabled",
3677 "should identical blocks be aggregated (only for discretization approach)?",
3678 &(relaxdata->aggregation), FALSE, DEFAULT_AGGREGATION, NULL, NULL) );
3679 SCIP_CALL( SCIPaddIntParam(origprob, "relaxing/gcg/aggregation/limitnconssperblock",
3680 "Limits the number of constraints of a block (aggregation information for block is not calculated when exceeded)",
3681 &(relaxdata->aggregationnconsslimit), FALSE, DEFAULT_AGGREGATIONNCONSSLIMIT, 0, INT_MAX, NULL, NULL) );
3682 SCIP_CALL( SCIPaddIntParam(origprob, "relaxing/gcg/aggregation/limitnvarsperblock",
3683 "Limits the number of variables of a block (aggregation information for block is not calculated when exceeded)",
3684 &(relaxdata->aggregationnvarslimit), FALSE, DEFAULT_AGGREGATIONNVARSLIMIT, 0, INT_MAX, NULL, NULL) );
3685#ifndef NO_AUT_LIB
3686 SCIP_CALL( SCIPaddBoolParam(origprob, "relaxing/gcg/aggregation/usesymmetrylib",
3687 "should a symmetry detection library be used to check for identical blocks?",
3688 &(relaxdata->usesymmetrylib), FALSE, DEFAULT_BLISS, NULL, NULL) );
3689 SCIP_CALL( SCIPaddIntParam(origprob, "relaxing/gcg/aggregation/searchnodelimit",
3690 "search node limit (0: unlimited), requires patched bliss version",
3691 &(relaxdata->searchnodelimit), TRUE, (int)DEFAULT_BLISS_SEARCH_NODE_LIMIT, 0, INT_MAX, NULL, NULL) );
3692 SCIP_CALL( SCIPaddIntParam(origprob, "relaxing/gcg/aggregation/generatorlimit",
3693 "generator limit (0: unlimited), requires patched bliss version or version >= 0.76",
3694 &(relaxdata->generatorlimit), TRUE, (int)DEFAULT_BLISS_GENERATOR_LIMIT, 0, INT_MAX, NULL, NULL) );
3695#else
3696 relaxdata->usesymmetrylib = FALSE;
3697 relaxdata->searchnodelimit = 0;
3698 relaxdata->generatorlimit = 0;
3699#endif
3700 SCIP_CALL( SCIPaddBoolParam(origprob, "relaxing/gcg/dispinfos",
3701 "should additional information about the blocks be displayed?",
3702 &(relaxdata->dispinfos), FALSE, DEFAULT_DISPINFOS, NULL, NULL) );
3703 SCIP_CALL( SCIPaddIntParam(origprob, "relaxing/gcg/mode",
3704 "the decomposition mode that GCG will use. (0: Dantzig-Wolfe (default), 1: Benders' decomposition, "
3705 "2: no decomposition will be performed)",
3706 (int*)&(relaxdata->mode), FALSE, (int)DEFAULT_MODE, 0, 2, NULL, NULL) );
3707
3708 return SCIP_OKAY;
3709}
3710
3711
3712/*
3713 * relaxator specific interface methods for coordination of branching rules
3714 */
3715
3716/** includes a branching rule into the relaxator data */
3718 GCG* gcg, /**< SCIP data structure */
3719 SCIP_BRANCHRULE** branchrule, /**< branching rule for which callback methods are saved */
3720 GCG_BRANCHRULE** gcgbranchrule, /**< pointer to store created GCG branch rule (can be NULL) */
3721 const char* name, /**< name of branching rule */
3722 const char* desc, /**< description of branching rule */
3723 int priority, /**< priority of the branching rule */
3724 int maxdepth, /**< maximal depth level, up to which this branching rule should be used (or -1) */
3725 SCIP_Real maxbounddist, /**< maximal relative distance from current node's dual bound to primal bound
3726 * compared to best node's dual bound for applying branching rule
3727 * (0.0: only on current best node, 1.0: on all nodes) */
3728 SCIP_BRANCHRULEDATA* branchruledata, /**< branching rule data */
3729 GCG_DECL_BRANCHACTIVEMASTER((*branchactivemaster)),/**< activation method for branchrule */
3730 GCG_DECL_BRANCHDEACTIVEMASTER((*branchdeactivemaster)),/**< deactivation method for branchrule */
3731 GCG_DECL_BRANCHPROPMASTER((*branchpropmaster)),/**< propagation method for branchrule */
3732 GCG_DECL_BRANCHMASTERSOLVED((*branchmastersolved)),/**< master solved method for branchrule */
3733 GCG_DECL_BRANCHDATADELETE((*branchdatadelete)),/**< branchdata deletion method for branchrule */
3734 GCG_DECL_BRANCHNEWCOL ((*branchnewcol)), /**< new column handler method of branching rule */
3735 GCG_DECL_BRANCHGETEXTENDEDMASTERCONS ((*branchgetextendedmastercons)), /**< extended master cons getter of branching rule */
3736 GCG_DECL_BRANCHGETEXTENDEDMASTERCONSCOEFF((*branchgetextendedmasterconscoeff)) /**< column coefficient calculation method for extended master conss */
3737 )
3738{
3739 SCIP_RELAX* relax;
3740 SCIP_RELAXDATA* relaxdata;
3741 int pos;
3742
3743 assert(gcg != NULL);
3744 assert(branchrule != NULL);
3745
3746 relax = GCGgetRelax(gcg);
3747 assert(relax != NULL);
3748
3749 relaxdata = SCIPrelaxGetData(relax);
3750 assert(relaxdata != NULL);
3751
3752 SCIP_CALL( ensureSizeBranchrules(gcg, relaxdata) );
3753
3754 pos = relaxdata->nbranchrules;
3755
3756 SCIP_CALL( SCIPincludeBranchruleBasic(GCGgetMasterprob(gcg), branchrule, name, desc, priority,
3757 maxdepth, maxbounddist, branchruledata) );
3758
3759 /* store callback functions */
3760 SCIP_CALL( SCIPallocMemory(GCGgetOrigprob(gcg), &(relaxdata->branchrules[pos])) );
3761 relaxdata->branchrules[pos]->branchrule = *branchrule;
3762 relaxdata->branchrules[pos]->branchactivemaster = branchactivemaster;
3763 relaxdata->branchrules[pos]->branchdeactivemaster = branchdeactivemaster;
3764 relaxdata->branchrules[pos]->branchpropmaster = branchpropmaster;
3765 relaxdata->branchrules[pos]->branchmastersolved = branchmastersolved;
3766 relaxdata->branchrules[pos]->branchdatadelete = branchdatadelete;
3767 relaxdata->branchrules[pos]->branchnewcol = branchnewcol;
3768 relaxdata->branchrules[pos]->branchgetextendedmastercons = branchgetextendedmastercons;
3769 relaxdata->branchrules[pos]->branchgetextendedmasterconscoeff = branchgetextendedmasterconscoeff;
3770 relaxdata->nbranchrules++;
3771
3772 if( gcgbranchrule != NULL )
3773 *gcgbranchrule = relaxdata->branchrules[pos];
3774
3776
3777 return SCIP_OKAY;
3778}
3779
3780/** perform activation method of the given branchrule for the given branchdata */
3782 GCG* gcg, /**< GCG data structure */
3783 GCG_BRANCHRULE* branchrule, /**< branching rule that did the branching */
3784 GCG_BRANCHDATA* branchdata /**< data representing the branching decision */
3785 )
3786{
3787 SCIP_RELAX* relax;
3788 SCIP_RELAXDATA* relaxdata;
3789
3790 assert(gcg != NULL);
3791 assert(branchrule != NULL);
3792
3793 relax = GCGgetRelax(gcg);
3794 assert(relax != NULL);
3795
3796 relaxdata = SCIPrelaxGetData(relax);
3797 assert(relaxdata != NULL);
3798
3799 /* call activation method of branching rule */
3800 if( branchrule->branchactivemaster != NULL )
3801 SCIP_CALL( branchrule->branchactivemaster(gcg, branchdata) );
3802
3803 SCIP_CALL( addActiveBranchExtendedmastercons(gcg, relaxdata, branchrule, branchdata) );
3804
3805 return SCIP_OKAY;
3806}
3807
3808/** perform deactivation method of the given branchrule for the given branchdata */
3810 GCG* gcg, /**< GCG data structure */
3811 GCG_BRANCHRULE* branchrule, /**< branching rule that did the branching */
3812 GCG_BRANCHDATA* branchdata /**< data representing the branching decision */
3813 )
3814{
3815 SCIP_RELAX* relax;
3816 SCIP_RELAXDATA* relaxdata;
3817
3818 assert(gcg != NULL);
3819 assert(branchrule != NULL);
3820
3821 relax = GCGgetRelax(gcg);
3822 assert(relax != NULL);
3823
3824 relaxdata = SCIPrelaxGetData(relax);
3825 assert(relaxdata != NULL);
3826
3827 /* call deactivation method of branching rule */
3828 if( branchrule->branchdeactivemaster != NULL )
3829 SCIP_CALL( branchrule->branchdeactivemaster(gcg, branchdata) );
3830
3831 SCIP_CALL( dropActiveBranchExtendedmastercons(gcg, relaxdata, branchrule, branchdata) );
3832
3833 return SCIP_OKAY;
3834}
3835
3836/** perform propagation method of the given branchrule for the given branchdata */
3838 GCG* gcg, /**< GCG data structure */
3839 GCG_BRANCHRULE* branchrule, /**< branching rule that did the branching */
3840 GCG_BRANCHDATA* branchdata, /**< data representing the branching decision */
3841 SCIP_RESULT* result /**< pointer to store the result of the propagation call */
3842 )
3843{
3844 assert(gcg != NULL);
3845 assert(branchrule != NULL);
3846 assert(result != NULL);
3847
3849
3850 /* call propagation method of branching rule*/
3851 if( branchrule->branchpropmaster != NULL )
3852 SCIP_CALL( branchrule->branchpropmaster(gcg, branchdata, result) );
3853
3854 return SCIP_OKAY;
3855}
3856
3857/** frees branching data created by the given branchrule */
3859 GCG* gcg, /**< GCG data structure */
3860 GCG_BRANCHRULE* branchrule, /**< branching rule that did the branching */
3861 GCG_BRANCHDATA** branchdata, /**< data representing the branching decision */
3862 SCIP_Bool origbranch, /**< true iff an origbranch triggered this call */
3863 SCIP_Bool force /**< branch data must be deleted if true */
3864 )
3865{
3866 assert(gcg != NULL);
3867 assert(branchrule != NULL);
3868 assert(branchdata != NULL);
3869
3870 /* call branchrule data deletion method of the branching rule */
3871 if( branchrule->branchdatadelete != NULL )
3872 SCIP_CALL( branchrule->branchdatadelete(gcg, branchdata, origbranch, force) );
3873 else
3874 {
3875 if( *branchdata != NULL )
3876 {
3877 SCIPfreeMemory(GCGgetMasterprob(gcg), branchdata);
3878 }
3879 }
3880
3881 return SCIP_OKAY;
3882}
3883
3884/** notifies the branching rule that a new mastervariable was created while this node was active */
3886 GCG* gcg, /**< GCG data structure */
3887 GCG_BRANCHRULE* branchrule, /**< branching rule that did the branching */
3888 GCG_BRANCHDATA* branchdata, /**< data representing the branching decision */
3889 SCIP_VAR* mastervar /**< new mastervariable that was created */
3890 )
3891{
3892 assert(gcg != NULL);
3893 assert(branchrule != NULL);
3894 assert(branchdata != NULL);
3895 assert(mastervar != NULL);
3896
3897 /* call new mastervariable handler method of branching rule*/
3898 if( branchrule->branchnewcol != NULL )
3899 SCIP_CALL( branchrule->branchnewcol(gcg, branchdata, mastervar) );
3900
3901 return SCIP_OKAY;
3902}
3903
3904/** gets the extendedmasterconsdata created by this branching rule, if any */
3906 GCG* gcg, /**< GCG data structure */
3907 GCG_BRANCHRULE* branchrule, /**< branching rule that did the branching */
3908 GCG_BRANCHDATA* branchdata, /**< data representing the branching decision */
3909 GCG_EXTENDEDMASTERCONSDATA** extendedmasterconsdata /**< the extendedmasterconsdata to grab */
3910 )
3911{
3912 assert(gcg != NULL);
3913 assert(branchrule != NULL);
3914 assert(extendedmasterconsdata == NULL);
3915
3916 /* call extended master cons getter method of branching rule */
3917 if( branchrule->branchgetextendedmastercons != NULL )
3918 {
3919 SCIP_CALL( branchrule->branchgetextendedmastercons(gcg, branchdata, extendedmasterconsdata) );
3920 assert(*extendedmasterconsdata != NULL);
3921 }
3922 else
3923 {
3924 *extendedmasterconsdata = NULL;
3925 }
3926
3927 return SCIP_OKAY;
3928}
3929
3930/** get extended master conss of all active nodes */
3932 GCG* gcg, /**< GCG data structure */
3933 GCG_BRANCHRULE*** branchrules, /**< branching rules that created extended master conss (can be NULL) */
3934 GCG_BRANCHDATA*** branchdata, /**< data represeting the branching decisions of the active nodes (can be NULL) */
3935 GCG_EXTENDEDMASTERCONSDATA*** extendedmasterconsdata, /**< array of extended master conss generated by branching in all currently active nodes */
3936 int* nextendedmasterconss /**< number of currently active branching rules that created extended master conss */
3937 )
3938{
3939 SCIP_RELAX* relax;
3940 SCIP_RELAXDATA* relaxdata;
3941
3942 assert(gcg != NULL);
3943
3944 relax = GCGgetRelax(gcg);
3945 assert(relax != NULL);
3946
3947 relaxdata = SCIPrelaxGetData(relax);
3948 assert(relaxdata != NULL);
3949
3950 if( branchrules != NULL )
3951 *branchrules = relaxdata->activebranchrules;
3952 if( branchdata != NULL )
3953 *branchdata = relaxdata->activebranchdata;
3954 *extendedmasterconsdata = relaxdata->activebranchextendedmasterconss;
3955 *nextendedmasterconss = relaxdata->nactivebranchextendedmasterconss;
3956
3957 return SCIP_OKAY;
3958}
3959
3960/** perform method of the given branchrule that is called after the master LP is solved */
3962 GCG* gcg, /**< GCG data structure */
3963 GCG_BRANCHRULE* branchrule, /**< branching rule that did the branching */
3964 GCG_BRANCHDATA* branchdata, /**< data representing the branching decision */
3965 SCIP_Real newlowerbound /**< the new local lowerbound */
3966 )
3967{
3968
3969 assert(gcg != NULL);
3970 assert(branchrule != NULL);
3971
3972 /* call master problem solved method of the branching rule */
3973 if( branchrule->branchmastersolved != NULL )
3974 SCIP_CALL( branchrule->branchmastersolved(gcg, branchdata, newlowerbound) );
3975
3976 return SCIP_OKAY;
3977}
3978
3979
3980/** transforms a constraint of the original problem into the master variable space
3981 * and stores information about the constraints in the variable */
3983 GCG* gcg, /**< GCG data structure */
3984 SCIP_CONS* cons, /**< the constraint that should be transformed */
3985 SCIP_CONS** transcons /**< pointer to store the transformed constraint */
3986 )
3987{
3988 SCIP* scip;
3989 SCIP_RELAX* relax;
3990 SCIP_RELAXDATA* relaxdata;
3991 SCIP_CONS* mastercons;
3992 char name[SCIP_MAXSTRLEN];
3993
3995 int nmastervars;
3996 SCIP_VAR** consvars;
3997 SCIP_Real* consvals;
3998 int nconsvars;
3999 int v;
4000 int i;
4001 int j;
4002
4003 assert(gcg != NULL);
4004 assert(cons != NULL);
4005
4007 relax = GCGgetRelax(gcg);
4008 assert(relax != NULL);
4009
4010 relaxdata = SCIPrelaxGetData(relax);
4011 assert(relaxdata != NULL);
4012
4013 /* create and add corresponding linear constraint in the master problem */
4014 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "m_%s", SCIPconsGetName(cons));
4015 SCIP_CALL( SCIPcreateConsLinear(GCGgetMasterprob(relaxdata->gcg), &mastercons, name, 0, NULL, NULL,
4016 GCGconsGetLhs(scip, cons), GCGconsGetRhs(scip, cons),
4018 SCIPconsIsStickingAtNode(cons)) );
4019
4020 /* now compute coefficients of the master variables in the master constraint */
4023
4024 consvars = SCIPgetVarsLinear(scip, cons);
4025 nconsvars = SCIPgetNVarsLinear(scip, cons);
4026 consvals = SCIPgetValsLinear(scip, cons);
4027
4028
4029 /* add coefs of the original variables in the constraint to their variable data */
4030 for( v = 0; v < nconsvars; v++ )
4031 {
4032 SCIP_CALL( GCGoriginalVarAddCoef(gcg, consvars[v], consvals[v], mastercons) );
4033 }
4034
4035 /* add master variables to the corresponding master constraint */
4036 for( v = 0; v < nmastervars; v++ )
4037 {
4038 SCIP_VAR** origvars;
4039 SCIP_Real* origvals;
4040 int norigvars;
4041 SCIP_Real coef = 0.0;
4042
4043 origvars = GCGmasterVarGetOrigvars(mastervars[v]);
4044 norigvars = GCGmasterVarGetNOrigvars(mastervars[v]);
4045 origvals = GCGmasterVarGetOrigvals(mastervars[v]);
4046
4047 for( i = 0; i < norigvars; i++ )
4048 for( j = 0; j < nconsvars; j++ )
4049 if( consvars[j] == origvars[i] )
4050 coef += consvals[j] * origvals[i];
4051
4052 if( !SCIPisFeasZero(scip, coef) )
4053 {
4054 SCIP_CALL( SCIPaddCoefLinear(GCGgetMasterprob(gcg), mastercons, mastervars[v], coef) );
4055 }
4056 }
4057
4058 /* store the constraints in the arrays origmasterconss and masterconss in the problem data */
4059 SCIP_CALL( ensureSizeMasterConss(gcg, relaxdata, relaxdata->nmasterconss+1) );
4060 SCIP_CALL( SCIPcaptureCons(scip, cons) );
4061 relaxdata->origmasterconss[relaxdata->nmasterconss] = cons;
4062 relaxdata->masterconss[relaxdata->nmasterconss] = mastercons;
4063
4065 relaxdata->nmasterconss) );
4066
4067 relaxdata->nmasterconss++;
4068
4069 *transcons = mastercons;
4070
4071 return SCIP_OKAY;
4072}
4073
4074/** returns the pricing problem of the given number */
4076 GCG* gcg, /**< GCG data structure */
4077 int pricingprobnr /**< number of the pricing problem */
4078 )
4079{
4080 SCIP_RELAX* relax;
4081 SCIP_RELAXDATA* relaxdata;
4082
4083 assert(gcg != NULL);
4084
4085 relax = GCGgetRelax(gcg);
4086 assert(relax != NULL);
4087
4088 relaxdata = SCIPrelaxGetData(relax);
4089 assert(relaxdata != NULL);
4090
4091 return relaxdata->pricingprobs[pricingprobnr];
4092}
4093
4094/** returns the number of relevant pricing problems */
4096 GCG* gcg /**< GCG data structure */
4097 )
4098{
4099 SCIP_RELAX* relax;
4100 SCIP_RELAXDATA* relaxdata;
4101
4102 relax = GCGgetRelax(gcg);
4103 assert(relax != NULL);
4104
4105 relaxdata = SCIPrelaxGetData(relax);
4106 assert(relaxdata != NULL);
4107
4108 assert(relaxdata->nrelpricingprobs >= -1);
4109 return relaxdata->nrelpricingprobs;
4110}
4111
4112/** returns the number of pricing problems */
4114 GCG* gcg /**< GCG data structure */
4115 )
4116{
4117 SCIP_RELAX* relax;
4118 SCIP_RELAXDATA* relaxdata;
4119
4120 relax = GCGgetRelax(gcg);
4121 assert(relax != NULL);
4122
4123 relaxdata = SCIPrelaxGetData(relax);
4124 assert(relaxdata != NULL);
4125
4126 assert(relaxdata->npricingprobs >= -1);
4127 return relaxdata->npricingprobs;
4128}
4129
4130/** returns TRUE iff the pricing problem of the given number is relevant, that means is not identical to
4131 * another and represented by it */
4133 GCG* gcg, /**< GCG data structure */
4134 int pricingprobnr /**< number of the pricing problem */
4135 )
4136{
4137 SCIP_RELAX* relax;
4138 SCIP_RELAXDATA* relaxdata;
4139
4140 assert(gcg != NULL);
4141
4142 relax = GCGgetRelax(gcg);
4143 assert(relax != NULL);
4144
4145 relaxdata = SCIPrelaxGetData(relax);
4146 assert(relaxdata != NULL);
4147
4148 return (relaxdata->blockrepresentative[pricingprobnr] == pricingprobnr);
4149
4150}
4151
4152/**
4153 * for a given block, return the block by which it is represented
4154 */
4156 GCG* gcg, /**< GCG data structure */
4157 int pricingprobnr /**< number of the pricing problem */
4158 )
4159{
4160 SCIP_RELAX* relax;
4161 SCIP_RELAXDATA* relaxdata;
4162
4163 if( pricingprobnr == -1 )
4164 return -1;
4165
4166 assert(gcg != NULL);
4167
4168 relax = GCGgetRelax(gcg);
4169 assert(relax != NULL);
4170
4171 relaxdata = SCIPrelaxGetData(relax);
4172 assert(relaxdata != NULL);
4173
4174 assert(pricingprobnr >= 0);
4175 assert(pricingprobnr < relaxdata->npricingprobs);
4176 assert(relaxdata->nblocksidentical[pricingprobnr] >= 0);
4177 assert((relaxdata->blockrepresentative[pricingprobnr] == pricingprobnr)
4178 == (relaxdata->nblocksidentical[pricingprobnr] > 0));
4179
4180 return relaxdata->blockrepresentative[pricingprobnr];
4181}
4182
4183/** returns the number of blocks in the original formulation, that are represented by
4184 * the pricingprob with the given number */
4186 GCG* gcg, /**< GCG data structure */
4187 int pricingprobnr /**< number of the pricing problem */
4188 )
4189{
4190 SCIP_RELAX* relax;
4191 SCIP_RELAXDATA* relaxdata;
4192
4193 assert(gcg != NULL);
4194
4195 relax = GCGgetRelax(gcg);
4196 assert(relax != NULL);
4197 assert(pricingprobnr >= 0);
4198
4199 relaxdata = SCIPrelaxGetData(relax);
4200 assert(relaxdata != NULL);
4201 assert(pricingprobnr <= relaxdata->npricingprobs);
4202 assert(relaxdata->nblocksidentical[pricingprobnr] >= 0);
4203 assert((relaxdata->blockrepresentative[pricingprobnr] == pricingprobnr)
4204 == (relaxdata->nblocksidentical[pricingprobnr] > 0));
4205
4206 return relaxdata->nblocksidentical[pricingprobnr];
4207
4208}
4209
4210/** returns the number of constraints in the master problem */
4212 GCG* gcg /**< GCG data structure */
4213 )
4214{
4215 SCIP_RELAX* relax;
4216 SCIP_RELAXDATA* relaxdata;
4217
4218 relax = GCGgetRelax(gcg);
4219 assert(relax != NULL);
4220
4221 relaxdata = SCIPrelaxGetData(relax);
4222 assert(relaxdata != NULL);
4223
4224 return relaxdata->nmasterconss;
4225}
4226
4227/** returns the contraints in the master problem */
4229 GCG* gcg /**< GCG data structure */
4230 )
4231{
4232 SCIP_RELAX* relax;
4233 SCIP_RELAXDATA* relaxdata;
4234
4235 relax = GCGgetRelax(gcg);
4236 assert(relax != NULL);
4237
4238 relaxdata = SCIPrelaxGetData(relax);
4239 assert(relaxdata != NULL);
4240
4241 return relaxdata->masterconss;
4242}
4243
4244/** returns the linking constraints in the original problem that correspond to the constraints in the master problem */
4246 GCG* gcg /**< GCG data structure */
4247 )
4248{
4249 SCIP_RELAX* relax;
4250 SCIP_RELAXDATA* relaxdata;
4251
4252 relax = GCGgetRelax(gcg);
4253 assert(relax != NULL);
4254
4255 relaxdata = SCIPrelaxGetData(relax);
4256 assert(relaxdata != NULL);
4257
4258 return relaxdata->origmasterconss;
4259}
4260
4261/** returns the convexity constraint for the given block */
4263 GCG* gcg, /**< GCG data structure */
4264 int blocknr /**< the number of the block for which we
4265 * need the convexity constraint */
4266 )
4267{
4268 SCIP_RELAX* relax;
4269 SCIP_RELAXDATA* relaxdata;
4270
4271 assert(gcg != NULL);
4272 assert(blocknr >= 0);
4273
4274 relax = GCGgetRelax(gcg);
4275 assert(relax != NULL);
4276
4277 relaxdata = SCIPrelaxGetData(relax);
4278 assert(relaxdata != NULL);
4279 assert(blocknr < relaxdata->npricingprobs);
4280
4281 return relaxdata->convconss[blocknr];
4282}
4283
4284/** returns the visualization parameters */
4286 GCG* gcg /**< GCG data structure */
4287 )
4288{
4289 SCIP_RELAX* relax;
4290 SCIP_RELAXDATA* relaxdata;
4291 GCG_PARAMDATA* paramdata;
4292
4293 assert(gcg != NULL);
4294
4295 relax = GCGgetRelax(gcg);
4296 assert(relax != NULL);
4297
4298 relaxdata = SCIPrelaxGetData(relax);
4299 assert(relaxdata != NULL);
4300 assert(relaxdata->paramsvisu != NULL);
4301
4302 paramdata = relaxdata->paramsvisu;
4303 assert(paramdata != NULL);
4304
4305 return paramdata;
4306}
4307
4308/** returns the current solution for the original problem */
4310 GCG* gcg /**< GCG data structure */
4311 )
4312{
4313 SCIP_RELAX* relax;
4314 SCIP_RELAXDATA* relaxdata;
4315
4316 assert(gcg != NULL);
4317
4318 relax = GCGgetRelax(gcg);
4319 assert(relax != NULL);
4320
4321 relaxdata = SCIPrelaxGetData(relax);
4322 assert(relaxdata != NULL);
4323
4324 return relaxdata->currentorigsol;
4325}
4326
4327/** returns whether the current solution is primal feasible in the original problem */
4329 GCG* gcg /**< GCG data structure */
4330 )
4331{
4332 SCIP_RELAX* relax;
4333 SCIP_RELAXDATA* relaxdata;
4334
4335 assert(gcg != NULL);
4336
4337 relax = GCGgetRelax(gcg);
4338 assert(relax != NULL);
4339
4340 relaxdata = SCIPrelaxGetData(relax);
4341 assert(relaxdata != NULL);
4342
4343 return relaxdata->origsolfeasible;
4344}
4345
4346/** returns whether the master problem is a set covering problem */
4348 GCG* gcg /**< GCG data structure */
4349 )
4350{
4351 SCIP_RELAX* relax;
4352 SCIP_RELAXDATA* relaxdata;
4353
4354 assert(gcg != NULL);
4355
4356 relax = GCGgetRelax(gcg);
4357 assert(relax != NULL);
4358
4359 relaxdata = SCIPrelaxGetData(relax);
4360 assert(relaxdata != NULL);
4361
4362 return relaxdata->masterissetcover;
4363}
4364
4365/** returns whether the master problem is a set partitioning problem */
4367 GCG* gcg /**< GCG data structure */
4368 )
4369{
4370 SCIP_RELAX* relax;
4371 SCIP_RELAXDATA* relaxdata;
4372
4373 assert(gcg != NULL);
4374
4375 relax = GCGgetRelax(gcg);
4376 assert(relax != NULL);
4377
4378 relaxdata = SCIPrelaxGetData(relax);
4379 assert(relaxdata != NULL);
4380
4381 return relaxdata->masterissetpart;
4382}
4383
4384/** start probing mode on both the original and master problems
4385 *
4386 * @note This mode is intended for working on the original variables but using the master LP;
4387 * it currently only supports bound changes on the original variables,
4388 * but no additional rows
4389 */
4391 GCG* gcg, /**< GCG data structure */
4392 SCIP_HEUR* probingheur /**< heuristic that started probing mode, or NULL */
4393 )
4394{
4395 SCIP* scip;
4396 SCIP_RELAX* relax;
4397 SCIP_RELAXDATA* relaxdata;
4399
4400 assert(gcg != NULL);
4401
4403 relax = GCGgetRelax(gcg);
4404 assert(relax != NULL);
4405
4406 relaxdata = SCIPrelaxGetData(relax);
4407 assert(relaxdata != NULL);
4408
4409 if( relaxdata->masterinprobing )
4410 {
4411 SCIPerrorMessage("already in GCG probing mode\n");
4412 return SCIP_INVALIDCALL;
4413 }
4414
4415 masterprob = GCGgetMasterprob(relaxdata->gcg);
4417
4418 /* start probing in both the original and the master problem */
4421
4422 relaxdata->masterinprobing = TRUE;
4423 relaxdata->probingheur = probingheur;
4424
4425 /* remember the current original solution */
4426 assert(relaxdata->storedorigsol == NULL);
4427 if( relaxdata->currentorigsol != NULL )
4428 {
4429 SCIP_CALL( SCIPcreateSolCopy(scip, &relaxdata->storedorigsol, relaxdata->currentorigsol) );
4430 relaxdata->storedfeasibility = relaxdata->origsolfeasible;
4431 }
4432
4433 return SCIP_OKAY;
4434}
4435
4436/** returns the heuristic that started probing in the master problem, or NULL */
4438 GCG* gcg /**< GCG data structure */
4439 )
4440{
4441 SCIP_RELAX* relax;
4442 SCIP_RELAXDATA* relaxdata;
4443
4444 assert(gcg != NULL);
4445
4446 relax = GCGgetRelax(gcg);
4447 assert(relax != NULL);
4448
4449 relaxdata = SCIPrelaxGetData(relax);
4450 assert(relaxdata != NULL);
4451
4452 return relaxdata->probingheur;
4453}
4454
4455/** add a new probing node the original problem together with an original branching constraint
4456 *
4457 * @note A corresponding probing node must be added to the master problem right before solving the probing LP
4458 */
4460 GCG* gcg /**< GCG data structure */
4461 )
4462{
4463 SCIP* scip;
4464 SCIP_RELAX* relax;
4465 SCIP_RELAXDATA* relaxdata;
4466 SCIP_CONS* probingcons;
4467 SCIP_NODE* probingnode;
4468
4469 assert(gcg != NULL);
4470
4472 relax = GCGgetRelax(gcg);
4473 assert(relax != NULL);
4474
4475 relaxdata = SCIPrelaxGetData(relax);
4476 assert(relaxdata != NULL);
4477
4478 if( !relaxdata->masterinprobing )
4479 {
4480 SCIPerrorMessage("not in GCG probing mode\n");
4481 return SCIP_INVALIDCALL;
4482 }
4483
4485 {
4486 SCIPerrorMessage("original and master problem not at same probing depth\n");
4487 return SCIP_INVALIDCALL;
4488 }
4489
4490 /* add a probing node in the original problem together with an original branching constraint */
4492 probingnode = SCIPgetCurrentNode(scip);
4493 SCIP_CALL( GCGcreateConsOrigbranch(gcg, &probingcons, "probingcons", probingnode,
4495 SCIP_CALL( SCIPaddConsNode(scip, probingnode, probingcons, NULL) );
4496 SCIP_CALL( SCIPreleaseCons(scip, &probingcons) );
4497
4498
4499 return SCIP_OKAY;
4500}
4501
4502/** add a new probing node the master problem together with a master branching constraint
4503 * which ensures that bound changes are transferred to master and pricing problems
4504 *
4505 * @note A corresponding probing node must have been added to the original problem beforehand;
4506 * furthermore, this method must be called after bound changes to the original problem have been made
4507 */
4509 GCG* gcg /**< GCG data structure */
4510 )
4511{
4512 SCIP* scip;
4513 SCIP_RELAX* relax;
4514 SCIP_RELAXDATA* relaxdata;
4516 SCIP_CONS* probingcons;
4517 SCIP_NODE* probingnode;
4518
4519 assert(gcg != NULL);
4520
4522 relax = GCGgetRelax(gcg);
4523 assert(relax != NULL);
4524
4525 relaxdata = SCIPrelaxGetData(relax);
4526 assert(relaxdata != NULL);
4527
4528 if( !relaxdata->masterinprobing )
4529 {
4530 SCIPerrorMessage("not in GCG probing mode\n");
4531 return SCIP_INVALIDCALL;
4532 }
4533
4534 masterprob = GCGgetMasterprob(relaxdata->gcg);
4536
4538 {
4539 SCIPerrorMessage("master probing node must be created after original probing node\n");
4540 return SCIP_INVALIDCALL;
4541 }
4542
4543 /* add a probing node in the master problem together with a master branching constraint */
4545 probingnode = SCIPgetCurrentNode(masterprob);
4547 SCIP_CALL( GCGcreateConsMasterbranch(gcg, &probingcons, "mprobingcons", probingnode,
4549 SCIP_CALL( SCIPaddConsNode(masterprob, probingnode, probingcons, NULL) );
4550 SCIP_CALL( SCIPreleaseCons(masterprob, &probingcons) );
4551
4552 return SCIP_OKAY;
4553}
4554
4555/** add a new probing node the master problem together with a master branching constraint
4556 * which ensures that bound changes are transferred to master and pricing problems as well as additional
4557 * constraints
4558 *
4559 * @note A corresponding probing node must have been added to the original problem beforehand;
4560 * furthermore, this method must be called after bound changes to the original problem have been made
4561 */
4563 GCG* gcg, /**< GCG data structure */
4564 GCG_BRANCHRULE* branchrule, /**< pointer to the branching rule */
4565 GCG_BRANCHDATA* branchdata, /**< branching data */
4566 SCIP_CONS** origbranchconss, /**< original constraints enforcing the branching decision */
4567 int norigbranchconss, /**< number of original constraints */
4568 int maxorigbranchconss /**< capacity of origbranchconss */
4569 )
4570{
4571 SCIP* scip;
4572 SCIP_RELAX* relax;
4573 SCIP_RELAXDATA* relaxdata;
4575 SCIP_CONS* probingcons;
4576 SCIP_NODE* probingnode;
4577
4578 assert(gcg != NULL);
4579
4581 relax = GCGgetRelax(gcg);
4582 assert(relax != NULL);
4583
4584 relaxdata = SCIPrelaxGetData(relax);
4585 assert(relaxdata != NULL);
4586
4587 if( !relaxdata->masterinprobing )
4588 {
4589 SCIPerrorMessage("not in GCG probing mode\n");
4590 return SCIP_INVALIDCALL;
4591 }
4592
4593 masterprob = GCGgetMasterprob(relaxdata->gcg);
4595
4597 {
4598 SCIPerrorMessage("master probing node must be created after original probing node\n");
4599 return SCIP_INVALIDCALL;
4600 }
4601
4602 /* add a probing node in the master problem together with a master branching constraint */
4604 probingnode = SCIPgetCurrentNode(masterprob);
4606 SCIP_CALL( GCGcreateConsMasterbranch(relaxdata->gcg, &probingcons, "mprobingcons", probingnode,
4607 GCGconsMasterbranchGetActiveCons(gcg), branchrule, branchdata, origbranchconss, norigbranchconss, maxorigbranchconss) );
4608 SCIP_CALL( SCIPaddConsNode(masterprob, probingnode, probingcons, NULL) );
4609 SCIP_CALL( SCIPreleaseCons(masterprob, &probingcons) );
4610
4611 return SCIP_OKAY;
4612}
4613
4614/** add probing nodes to both the original and master problem;
4615 * furthermore, add origbranch and masterbranch constraints to transfer branching decisions
4616 * from the original to the master problem
4617 */
4619 GCG* gcg, /**< GCG data structure */
4620 int probingdepth /**< probing depth of the node in the probing path that should be reactivated */
4621 )
4622{
4623 SCIP* scip;
4624 SCIP_RELAX* relax;
4625 SCIP_RELAXDATA* relaxdata;
4627
4628 assert(gcg != NULL);
4629
4631 relax = GCGgetRelax(gcg);
4632 assert(relax != NULL);
4633
4634 relaxdata = SCIPrelaxGetData(relax);
4635 assert(relaxdata != NULL);
4636
4637 if( !relaxdata->masterinprobing )
4638 {
4639 SCIPerrorMessage("not in GCG probing mode\n");
4640 return SCIP_INVALIDCALL;
4641 }
4642
4643 masterprob = GCGgetMasterprob(relaxdata->gcg);
4645
4646 SCIP_CALL( SCIPbacktrackProbing(scip, probingdepth) );
4647 SCIP_CALL( SCIPbacktrackProbing(masterprob, probingdepth) );
4648
4649 return SCIP_OKAY;
4650}
4651
4652/** solve the master probing LP with or without pricing */
4653static
4655 GCG* gcg, /**< GCG data structure */
4656 int maxlpiterations, /**< maximum number of lp iterations allowed */
4657 int maxpricerounds, /**< maximum number of pricing rounds allowed */
4658 SCIP_Bool usepricing, /**< should the LP be solved with or without pricing? */
4659 SCIP_Longint* nlpiterations, /**< pointer to store the number of performed LP iterations (or NULL) */
4660 int* npricerounds, /**< pointer to store the number of performed pricing rounds (or NULL) */
4661 SCIP_Real* lpobjvalue, /**< pointer to store the lp obj value if lp was solved */
4662 SCIP_Bool* lpsolved, /**< pointer to store whether the lp was solved */
4663 SCIP_Bool* lperror, /**< pointer to store whether an unresolved LP error occured or the
4664 * solving process should be stopped (e.g., due to a time limit) */
4665 SCIP_Bool* cutoff /**< pointer to store whether the probing direction is infeasible */
4666 )
4667{
4668 SCIP_RELAX* relax;
4669 SCIP_RELAXDATA* relaxdata;
4672 SCIP_Longint oldnlpiters;
4673 int oldpricerounds;
4674 SCIP_Longint nodelimit;
4675
4676 assert(gcg != NULL);
4677
4678 /* get the relaxator */
4679 relax = GCGgetRelax(gcg);
4680 assert(relax != NULL);
4681
4682 /* get the relaxator data */
4683 relaxdata = SCIPrelaxGetData(relax);
4684 assert(relaxdata != NULL);
4685
4686 if( !relaxdata->masterinprobing )
4687 {
4688 SCIPerrorMessage("not in GCG probing mode\n");
4689 return SCIP_INVALIDCALL;
4690 }
4691
4692 /* get master problem */
4693 masterprob = GCGgetMasterprob(relaxdata->gcg);
4695
4696 /* increase node limit for the master problem by 1 */
4697 SCIP_CALL( SCIPgetLongintParam(masterprob, "limits/nodes", &nodelimit) );
4698 SCIP_CALL( SCIPsetLongintParam(masterprob, "limits/nodes", nodelimit + 1) );
4699
4700 /* propagate probing bound changes to the master problem */
4702 assert(!(*cutoff));
4703
4704 /* remember LP iterations and pricing rounds before LP solving */
4705 oldnlpiters = SCIPgetNLPIterations(masterprob);
4706 oldpricerounds = SCIPgetNPriceRounds(masterprob);
4707
4708 *lpobjvalue = 0.0;
4709 *lpsolved = FALSE;
4710
4711 /* solve the probing LP */
4712 if( usepricing )
4713 {
4714 /* LP iterations are unlimited when probing LP is solved with pricing */
4715 assert(maxlpiterations == -1);
4717 }
4718 else
4719 {
4720 assert(maxpricerounds == 0);
4721 SCIP_CALL( SCIPsolveProbingLP(masterprob, maxlpiterations, lperror, NULL) );
4722 }
4724
4725 /* reset the node limit */
4726 SCIP_CALL( SCIPsetLongintParam(masterprob, "limits/nodes", nodelimit) );
4727
4728 /* calculate number of LP iterations and pricing rounds performed */
4729 if( nlpiterations != NULL )
4731 if( npricerounds != NULL )
4732 *npricerounds = SCIPgetNPriceRounds(masterprob) - oldpricerounds;
4733
4734 if( !(*lperror) )
4735 {
4736 /* get LP solution status, objective value */
4739 {
4740 SCIPdebugMessage("lpobjval = %g\n", SCIPgetLPObjval(masterprob));
4741 *lpobjvalue = SCIPgetLPObjval(masterprob);
4742 *lpsolved = TRUE;
4744 }
4745 }
4746 else
4747 {
4748 SCIPdebugMessage("something went wrong, an lp error occurred\n");
4749 }
4750
4751 return SCIP_OKAY;
4752}
4753
4754
4755/** solve the master probing LP without pricing */
4757 GCG* gcg, /**< GCG data structure */
4758 int maxlpiterations, /**< maximum number of lp iterations allowed */
4759 SCIP_Longint* nlpiterations, /**< pointer to store the number of performed LP iterations (or NULL) */
4760 SCIP_Real* lpobjvalue, /**< pointer to store the lp obj value if lp was solved */
4761 SCIP_Bool* lpsolved, /**< pointer to store whether the lp was solved */
4762 SCIP_Bool* lperror, /**< pointer to store whether an unresolved LP error occured or the
4763 * solving process should be stopped (e.g., due to a time limit) */
4764 SCIP_Bool* cutoff /**< pointer to store whether the probing direction is infeasible */
4765 )
4766{
4767 SCIP_CALL( performProbing(gcg, maxlpiterations, 0, FALSE, nlpiterations,
4768 NULL, lpobjvalue, lpsolved, lperror, cutoff) );
4769
4770 return SCIP_OKAY;
4771}
4772
4773
4774/** solve the master probing LP with pricing */
4776 GCG* gcg, /**< GCG data structure */
4777 int maxpricerounds, /**< maximum number of pricing rounds allowed */
4778 SCIP_Longint* nlpiterations, /**< pointer to store the number of performed LP iterations (or NULL) */
4779 int* npricerounds, /**< pointer to store the number of performed pricing rounds (or NULL) */
4780 SCIP_Real* lpobjvalue, /**< pointer to store the lp obj value if lp was solved */
4781 SCIP_Bool* lpsolved, /**< pointer to store whether the lp was solved */
4782 SCIP_Bool* lperror, /**< pointer to store whether an unresolved LP error occured or the
4783 * solving process should be stopped (e.g., due to a time limit) */
4784 SCIP_Bool* cutoff /**< pointer to store whether the probing direction is infeasible */
4785 )
4786{
4787 SCIP_CALL( performProbing(gcg, -1, maxpricerounds, TRUE, nlpiterations,
4788 npricerounds, lpobjvalue, lpsolved, lperror, cutoff) );
4789
4790 return SCIP_OKAY;
4791}
4792
4793/** end probing mode in both the original and master problems */
4795 GCG* gcg /**< GCG data structure */
4796 )
4797{
4798 SCIP* scip;
4799 SCIP_RELAX* relax;
4800 SCIP_RELAXDATA* relaxdata;
4802
4803 SCIP_VAR** vars;
4804 int nvars;
4805
4806 assert(gcg != NULL);
4807
4809 relax = GCGgetRelax(gcg);
4810 assert(relax != NULL);
4811
4812 relaxdata = SCIPrelaxGetData(relax);
4813 assert(relaxdata != NULL);
4814
4815 if( !relaxdata->masterinprobing )
4816 {
4817 SCIPerrorMessage("not in GCG probing mode\n");
4818 return SCIP_INVALIDCALL;
4819 }
4820
4821 masterprob = GCGgetMasterprob(relaxdata->gcg);
4823
4825 assert(vars != NULL);
4826 assert(nvars >= 0);
4827
4830
4831 relaxdata->masterinprobing = FALSE;
4832 relaxdata->probingheur = NULL;
4833
4834 /* if a new primal solution was found in the master problem, transfer it to the original problem
4835 * @todo: this is probably not necessary anymore since it is done by an event handler
4836 */
4838 {
4839 SCIP_SOL* newsol;
4840 SCIP_Bool stored;
4841
4843
4845
4846 SCIP_CALL( SCIPtrySol(scip, newsol, FALSE, FALSE, TRUE, TRUE, TRUE, &stored) );
4847 if( !stored )
4848 {
4849 SCIP_CALL( SCIPcheckSolOrig(scip, newsol, &stored, TRUE, TRUE) );
4850 }
4851 assert(stored);
4852 SCIP_CALL( SCIPfreeSol(scip, &newsol) );
4853
4854 SCIPdebugMessage("probing finished in master problem\n");
4855 }
4856
4857 /* restore old relaxation solution and branching candidates */
4858 if( relaxdata->currentorigsol != NULL )
4859 {
4860 SCIPdebugMessage("Freeing previous solution origsol\n");
4861 SCIP_CALL( SCIPfreeSol(scip, &(relaxdata->currentorigsol)) );
4862 }
4864
4865 if( relaxdata->storedorigsol != NULL )
4866 {
4867 int i;
4868
4871
4872 for( i = 0; i < nvars; i++ )
4873 {
4874 SCIP_VAR* var;
4876
4877 var = vars[i];
4878 solval = SCIPgetSolVal(scip, relaxdata->storedorigsol, var);
4879
4881
4883 {
4884 /* this was an assertion but I think it is ok to fail as the old solution is restored
4885 * and probing may happen directly after branching */
4888 }
4889 }
4891
4892 SCIP_CALL( SCIPfreeSol(scip, &relaxdata->storedorigsol) );
4893
4894 relaxdata->origsolfeasible = relaxdata->storedfeasibility;
4895 }
4896
4897 /** @todo solve master problem again */
4898
4899 return SCIP_OKAY;
4900}
4901
4902
4903/** checks whether a variable should be added as an external branching candidate, if so it is added */
4904static
4906 GCG* gcg, /**< the GCG data structure */
4907 SCIP_VAR* var /**< the variable to check whether to add as a branching candidate */
4908 )
4909{
4910 SCIP* scip;
4911 assert(gcg != NULL);
4912 assert(var != NULL);
4913
4915
4917 {
4919 {
4920 SCIPdebugMessage("lblocal = %g, ublocal = %g\n", SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var));
4921 SCIPdebugMessage("var = %s, vartype = %d, val = %g\n", SCIPvarGetName(var), SCIPvarGetType(var),
4923 }
4924
4926
4929 }
4930
4931 return SCIP_OKAY;
4932}
4933
4934
4935/* frees current currentorigsol, sets origsolfeasible to FALSE and clears external branching candidates */
4936static
4938 GCG* gcg, /**< the GCG data structure */
4939 SCIP_RELAXDATA* relaxdata /**< relaxdata of the relaxator */
4940 )
4941{
4942 SCIP* scip;
4943
4945 relaxdata->origsolfeasible = FALSE;
4946 /* free previous solution and clear branching candidates */
4947 if( relaxdata->currentorigsol != NULL )
4948 {
4949 SCIPdebugMessage("Freeing previous solution origsol\n");
4950 SCIP_CALL( SCIPfreeSol(scip, &(relaxdata->currentorigsol)) );
4951 }
4952
4954 {
4956 }
4957 return SCIP_OKAY;
4958}
4959
4960
4961/** transforms the current solution of the master problem into the original problem's space
4962 * and saves this solution as currentsol in the relaxator's data
4963 */
4965 GCG* gcg /**< GCG data structure */
4966 )
4967{
4968 SCIP* scip;
4970 SCIP_RELAX* relax;
4971 SCIP_RELAXDATA* relaxdata;
4972 SCIP_VAR** origvars;
4973 int norigvars;
4974 SCIP_Bool stored;
4975
4976 assert(gcg != NULL);
4977
4979 relax = GCGgetRelax(gcg);
4980 assert(relax != NULL);
4981
4982 relaxdata = SCIPrelaxGetData(relax);
4983 assert(relaxdata != NULL);
4984
4985 origvars = SCIPgetVars(scip);
4986 norigvars = SCIPgetNVars(scip);
4987 assert(origvars != NULL);
4988
4989 /* retrieving the master problem */
4991
4992 /* if the master problem has not been solved, don't try to update the solution */
4994 {
4995 SCIP_CALL( freeCurrentOrigSol(gcg, relaxdata) );
4996 return SCIP_OKAY;
4997 }
4998
5000 {
5001 SCIP_SOL* mastersol;
5002 SCIP_Longint currentnode;
5003
5005
5006 /* create new solution */
5008 {
5009 SCIPdebugMessage("Masterproblem still solving, mastersol = NULL\n");
5010 mastersol = NULL;
5011
5012 if( relaxdata->lastmasternode == currentnode && relaxdata->lastmasterlpiters >= SCIPgetNLPIterations(masterprob) )
5013 {
5014 SCIPdebugMessage("no new lp iterations\n");
5015 return SCIP_OKAY;
5016 }
5017 }
5019 {
5020 mastersol = SCIPgetBestSol(masterprob);
5021 if( mastersol == NULL )
5022 {
5023 SCIP_CALL( freeCurrentOrigSol(gcg, relaxdata) );
5024 SCIPdebugMessage("Masterproblem solved, no master sol present\n");
5025 return SCIP_OKAY;
5026 }
5027 SCIPdebugMessage("Masterproblem solved, mastersol = %p\n", (void*) mastersol);
5028 }
5029 else
5030 {
5031 SCIPdebugMessage("stage in master not solving and not solved!\n");
5032 return SCIP_OKAY;
5033 }
5034
5035 /* free previous solution and clear branching candidates */
5036 SCIP_CALL( freeCurrentOrigSol(gcg, relaxdata) );
5037
5039 relaxdata->lastmasternode = currentnode;
5040
5041 if( !SCIPisInfinity(scip, SCIPgetSolOrigObj(masterprob, mastersol)) && GCGmasterIsSolValid(gcg, mastersol) )
5042 {
5043 int i;
5044 int j;
5045 SCIP_Bool violatesvarbnds;
5046
5047 /* transform the master solution to the original variable space */
5048 SCIP_CALL( GCGtransformMastersolToOrigsol(gcg, mastersol, &(relaxdata->currentorigsol), FALSE, &violatesvarbnds) );
5049 assert(!violatesvarbnds || !GCGmasterIsSolValid(gcg, mastersol));
5050
5051 /* store the solution as relaxation solution */
5054
5056 SCIP_CALL( SCIPtrySol(scip, relaxdata->currentorigsol, FALSE, FALSE, TRUE, TRUE, TRUE, &stored) );
5057 else
5058 SCIP_CALL( SCIPcheckSol(scip, relaxdata->currentorigsol, FALSE, FALSE, TRUE, TRUE, TRUE, &stored) );
5059
5060 SCIPdebugMessage("updated current original LP solution, %s feasible in the original problem!\n",
5061 (stored ? "" : "not"));
5062
5063 if( stored )
5064 relaxdata->origsolfeasible = TRUE;
5065
5066 /* in the case of Benders decomposition, only the master variables can be added as branching candidates */
5068 {
5070 SCIP_VAR** masterorigvars;
5071 int nmastervars;
5072 int nmasterorigvars;
5073
5074 /* get variables of the master problem and their solution values */
5076
5077 /* looping over all master variables to get the original variable for branching candidates */
5078 for( i = 0; i < nmastervars; i++ )
5079 {
5080 /* skip variables not created by GCG, e.g. the auxiliary variables of the Benders' decomposition
5081 * framework, which have no counterpart in the original problem
5082 */
5083 if( !GCGvarIsMaster(mastervars[i]) )
5084 continue;
5085
5086 masterorigvars = GCGmasterVarGetOrigvars(mastervars[i]);
5087 nmasterorigvars = GCGmasterVarGetNOrigvars(mastervars[i]);
5088
5089 for( j = 0; j < nmasterorigvars; j++ )
5091 }
5092 }
5093 else
5094 {
5096 /* store branching candidates */
5097 for( i = 0; i < norigvars; i++ )
5099 }
5100
5101 SCIPdebugMessage("updated relaxation branching candidates\n");
5102 }
5103 }
5104 else
5105 {
5106 SCIP_CALL( freeCurrentOrigSol(gcg, relaxdata) );
5107 }
5108
5109 return SCIP_OKAY;
5110}
5111
5112
5113/** gets the total memory used after problem creation stage for all pricingproblems */
5115 GCG* gcg /**< GCG data structure */
5116 )
5117{
5118 SCIP_RELAX* relax;
5119 SCIP_RELAXDATA* relaxdata;
5120
5121 int p;
5122 SCIP_Real memused;
5123
5124 relax = GCGgetRelax(gcg);
5125 assert(relax != NULL);
5126
5127 relaxdata = SCIPrelaxGetData(relax);
5128 assert(relaxdata != NULL);
5129
5130 memused = 0.0;
5131
5132 /* @todo replace the computation by relaxdata->pricingprobsmemused if we can assure that the memory
5133 * used by the pricing problems is constant */
5134
5135 /* compute memory that is used by all pricing problems */
5136 for( p = 0; p < relaxdata->npricingprobs; ++p )
5137 {
5138 memused += SCIPgetMemUsed(relaxdata->pricingprobs[p])/1048576.0;
5139 }
5140
5141 return memused;
5142}
5143
5144/** returns whether the relaxator has been initialized */
5146 GCG* gcg /**< GCG data structure */
5147 )
5148{
5149
5150 SCIP_RELAX* relax;
5151 SCIP_RELAXDATA* relaxdata;
5152
5153 relax = GCGgetRelax(gcg);
5154 assert(relax != NULL);
5155
5156 relaxdata = SCIPrelaxGetData(relax);
5157 assert(relaxdata != NULL);
5158
5159 return relaxdata->relaxisinitialized;
5160}
5161
5162/** returns the average degeneracy */
5164 GCG* gcg /**< GCG data structure */
5165 )
5166{
5167
5168 SCIP_Real degeneracy;
5170 SCIP* origprob;
5171
5172 assert(gcg != NULL);
5173
5176
5177 degeneracy = 0.0;
5178 if( masterprob != NULL )
5179 {
5180 degeneracy = GCGmasterGetDegeneracy(gcg);
5181 if( SCIPisInfinity(masterprob, degeneracy) )
5182 degeneracy = SCIPinfinity(origprob);
5183 }
5184 return degeneracy;
5185}
5186
5187/** return linking constraints for variables */
5189 GCG* gcg /**< GCG data structure */
5190 )
5191{
5192 SCIP_RELAX* relax;
5193 SCIP_RELAXDATA* relaxdata;
5194
5195 relax = GCGgetRelax(gcg);
5196 assert(relax != NULL);
5197
5198 relaxdata = SCIPrelaxGetData(relax);
5199 assert(relaxdata != NULL);
5200
5201 return relaxdata->varlinkconss;
5202}
5203
5204/** return blocks of linking constraints for variables */
5206 GCG* gcg /**< GCG data structure */
5207 )
5208{
5209 SCIP_RELAX* relax;
5210 SCIP_RELAXDATA* relaxdata;
5211
5212 relax = GCGgetRelax(gcg);
5213 assert(relax != NULL);
5214
5215 relaxdata = SCIPrelaxGetData(relax);
5216 assert(relaxdata != NULL);
5217
5218 return relaxdata->varlinkconsblock;
5219}
5220
5221/** return number of linking constraints for variables */
5223 GCG* gcg /**< GCG data structure */
5224 )
5225{
5226 SCIP_RELAX* relax;
5227 SCIP_RELAXDATA* relaxdata;
5228
5229 relax = GCGgetRelax(gcg);
5230 assert(relax != NULL);
5231
5232 relaxdata = SCIPrelaxGetData(relax);
5233 assert(relaxdata != NULL);
5234
5235 return relaxdata->nvarlinkconss;
5236}
5237
5238/** return number of linking variables */
5240 GCG* gcg /**< GCG data structure */
5241 )
5242{
5243 SCIP_RELAX* relax;
5244 SCIP_RELAXDATA* relaxdata;
5245
5246 relax = GCGgetRelax(gcg);
5247 assert(relax != NULL);
5248
5249 relaxdata = SCIPrelaxGetData(relax);
5250 assert(relaxdata != NULL);
5251
5252 return relaxdata->nlinkingvars;
5253}
5254
5255/** return number of variables directly transferred to the master problem */
5257 GCG* gcg /**< GCG data structure */
5258 )
5259{
5260 SCIP_RELAX* relax;
5261 SCIP_RELAXDATA* relaxdata;
5262
5263 relax = GCGgetRelax(gcg);
5264 assert(relax != NULL);
5265
5266 relaxdata = SCIPrelaxGetData(relax);
5267 assert(relaxdata != NULL);
5268
5269 return relaxdata->ntransvars;
5270}
5271
5272/** returns the relaxation solution from the Benders' decomposition */
5274 GCG* gcg /**< GCG data structure */
5275 )
5276{
5277 SCIP_RELAX* relax;
5278 SCIP_RELAXDATA* relaxdata;
5279 SCIP_BENDERS* benders;
5280
5281 relax = GCGgetRelax(gcg);
5282 assert(relax != NULL);
5283
5284 relaxdata = SCIPrelaxGetData(relax);
5285 assert(relaxdata != NULL);
5286
5287 benders = SCIPfindBenders(GCGgetMasterprob(relaxdata->gcg), "gcg");
5288 assert(benders != NULL);
5289
5290 return GCGbendersGetRelaxSol(benders);
5291}
5292
5293/** returns the decomposition mode */
5295 GCG* gcg /**< GCG data structure */
5296 )
5297{
5298 SCIP_RELAX* relax;
5299 SCIP_RELAXDATA* relaxdata;
5300
5301 assert(gcg != NULL);
5302
5303 relax = GCGgetRelax(gcg);
5304 assert(relax != NULL);
5305
5306 relaxdata = SCIPrelaxGetData(relax);
5307 assert(relaxdata != NULL);
5308
5309 return (GCG_DECMODE)relaxdata->mode;
5310}
5311
5312/** return root node time clock */
5314 GCG* gcg /**< GCG data structure */
5315 )
5316{
5317 SCIP_RELAX* relax;
5318 SCIP_RELAXDATA* relaxdata;
5319
5320 assert(gcg != NULL);
5321
5322 relax = GCGgetRelax(gcg);
5323 assert(relax != NULL);
5324
5325 relaxdata = SCIPrelaxGetData(relax);
5326 assert(relaxdata != NULL);
5327
5328 return relaxdata->rootnodetime;
5329}
5330
5332 GCG* gcg /**< GCG data structure */
5333 )
5334{
5336 switch( SCIPgetStage(origprob) )
5337 {
5338 case SCIP_STAGE_INIT:
5339 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "no problem exists\n");
5340 break;
5341
5342 case SCIP_STAGE_PROBLEM:
5345 break;
5346
5348 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "problem is already transformed\n");
5349 break;
5350
5357 case SCIP_STAGE_SOLVING:
5358 case SCIP_STAGE_SOLVED:
5361 case SCIP_STAGE_FREE:
5362 default:
5363 SCIPerrorMessage("invalid SCIP stage\n");
5364 return SCIP_INVALIDCALL;
5365 }
5366
5367 return SCIP_OKAY;
5368}
5369
5371 GCG* gcg /**< GCG data structure */
5372 )
5373{
5375 switch( SCIPgetStage(origprob) )
5376 {
5377 case SCIP_STAGE_INIT:
5378 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "no problem exists\n");
5379 break;
5380
5381 case SCIP_STAGE_PROBLEM:
5384
5385 /*lint -fallthrough*/
5386
5390 {
5392 }
5395 break;
5396
5398 case SCIP_STAGE_SOLVING:
5399 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "problem is already presolved\n");
5400 break;
5401
5402 case SCIP_STAGE_SOLVED:
5403 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "problem is already solved\n");
5404 break;
5405
5412 case SCIP_STAGE_FREE:
5413 default:
5414 SCIPerrorMessage("invalid SCIP stage\n");
5415 return SCIP_INVALIDCALL;
5416 }
5417
5418 return SCIP_OKAY;
5419}
5420
5422 GCG* gcg /**< GCG data structure */
5423 )
5424{
5427
5428 switch( SCIPgetStage(origprob) )
5429 {
5430 case SCIP_STAGE_INIT:
5431 SCIPverbMessage(origprob, SCIP_VERBLEVEL_DIALOG, NULL, "no problem exists\n");
5432 break;
5433
5434 case SCIP_STAGE_PROBLEM:
5437
5438 /*lint -fallthrough*/
5439
5442 {
5443 SCIPverbMessage(origprob, SCIP_VERBLEVEL_DIALOG, NULL, "The detection for the original problem took place already.\n");
5444 }
5445 else
5446 {
5447 SCIPverbMessage(origprob, SCIP_VERBLEVEL_DIALOG, NULL, "starting detection\n");
5449 }
5450 break;
5454 {
5455 SCIPverbMessage(origprob, SCIP_VERBLEVEL_DIALOG, NULL, "The detection for the presolved problem took place already.\n");
5456 }
5457 else
5458 {
5459 SCIPverbMessage(origprob, SCIP_VERBLEVEL_DIALOG, NULL, "starting detection\n");
5461 }
5462 break;
5463 case SCIP_STAGE_SOLVING:
5464 case SCIP_STAGE_SOLVED:
5471 case SCIP_STAGE_FREE:
5472 default:
5473 SCIPerrorMessage("invalid SCIP stage\n");
5474 return SCIP_INVALIDCALL;
5475 }
5476
5477 return SCIP_OKAY;
5478}
5479
5481 GCG* gcg /**< GCG data structure */
5482 )
5483{
5485 int presolrounds;
5486 SCIP_Bool exit = FALSE;
5488
5489 presolrounds = -1;
5490
5492
5493 while( !exit )
5494 {
5495 switch( SCIPgetStage(origprob) )
5496 {
5497 case SCIP_STAGE_INIT:
5498 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "No problem exists\n");
5499 exit = TRUE;
5500 break;
5501
5502 case SCIP_STAGE_PROBLEM:
5505
5506 /*lint -fallthrough*/
5507
5511 {
5512 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "there is an original decomposition and problem is not presolved yet -> disable presolving and start optimizing (rerun with presolve command before detect command for detecting in presolved problem) \n");
5513 SCIP_CALL( SCIPgetIntParam(origprob, "presolving/maxrounds", &presolrounds) );
5514 SCIP_CALL( SCIPsetIntParam(origprob, "presolving/maxrounds", 0) );
5515 }
5518
5519 break;
5520
5523
5525 {
5527 if( result == SCIP_DIDNOTFIND )
5528 {
5529 GCG_DECOMP* bestdecomp;
5530 bestdecomp = GCGgetBestDecomp(gcg, TRUE);
5532 GCGdecompFree(gcg, &bestdecomp);
5533 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "No decomposition exists or could be detected. Solution process started with original problem...\n");
5534 }
5535 }
5537 {
5538 #ifndef NDEBUG
5539 GCG_DECOMP* bestdecomp;
5540 bestdecomp = GCGgetBestDecomp(gcg, TRUE);
5541 assert(bestdecomp != NULL);
5542 GCGdecompFree(gcg, &bestdecomp);
5543 #endif
5544 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "Preexisting decomposition found. Solution process started...\n");
5545 }
5547 {
5548 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "No decomposition exists or could be detected. Solution process started with original problem...\n");
5549 }
5552
5553 /*lint -fallthrough*/
5554 case SCIP_STAGE_SOLVING:
5556 {
5558 }
5560 exit = TRUE;
5561 break;
5562
5563 case SCIP_STAGE_SOLVED:
5564 SCIPverbMessage(origprob, SCIP_VERBLEVEL_HIGH, NULL, "Problem is already solved\n");
5565 exit = TRUE;
5566 break;
5567
5574 case SCIP_STAGE_FREE:
5575 default:
5576 SCIPerrorMessage("invalid SCIP stage <%d>\n", SCIPgetStage(origprob));
5577 return SCIP_INVALIDCALL;
5578 }
5579 }
5580
5581 if( presolrounds != -1 )
5582 {
5583 SCIP_CALL( SCIPsetIntParam(origprob, "presolving/maxrounds", presolrounds) );
5584 }
5585
5586 return SCIP_OKAY;
5587}
5588
5590 GCG* gcg /**< GCG data structure */
5591 )
5592{
5593 SCIP* origprob;
5595 SCIP_Real dualbound;
5596
5597 assert(gcg != NULL);
5598
5600
5601 /* get master problem */
5604
5605 dualbound = SCIPgetDualbound(origprob);
5606
5607 /* @todo find a better way to do this */
5609 {
5610 SCIP_Real masterdualbound;
5611
5612 masterdualbound = SCIPgetDualbound(masterprob);
5613 masterdualbound = SCIPretransformObj(origprob, masterdualbound);
5614 dualbound = MAX(dualbound, masterdualbound);
5615 }
5616
5617 return dualbound;
5618}
5619
5621 GCG* gcg /**< GCG data structure */
5622 )
5623{
5624 SCIP* origprob;
5626 SCIP_Real primalbound;
5627
5628 assert(gcg != NULL);
5629
5631
5632 /* get master problem */
5635
5636 primalbound = SCIPgetPrimalbound(origprob);
5637
5638 /* @todo find a better way to do this */
5640 {
5641 SCIP_Real masterprimalbound;
5642 masterprimalbound = SCIPgetPrimalbound(masterprob);
5643 masterprimalbound = SCIPretransformObj(origprob, masterprimalbound);
5644
5645 primalbound = MIN(primalbound, masterprimalbound);
5646 }
5647
5648 return primalbound;
5649}
5650
5652 GCG* gcg /**< GCG data structure */
5653 )
5654{
5655 SCIP* origprob;
5656 SCIP_Real dualbound;
5657 SCIP_Real primalbound;
5658 SCIP_Real gap;
5659
5660 assert(gcg != NULL);
5661
5663 primalbound = GCGgetPrimalbound(gcg);
5664 dualbound = GCGgetDualbound(gcg);
5665
5666 /* this is the gap calculation from SCIPgetGap() */
5667 if( SCIPisEQ(origprob, primalbound, dualbound) )
5668 gap = 0.0;
5669 else if( SCIPisZero(origprob, dualbound )
5670 || SCIPisZero(origprob, primalbound)
5671 || SCIPisInfinity(origprob, REALABS(primalbound))
5672 || SCIPisInfinity(origprob, REALABS(dualbound))
5673 || primalbound * dualbound < 0.0 )
5674 gap = SCIPinfinity(origprob);
5675 else
5676 {
5677 SCIP_Real absdual = REALABS(dualbound);
5678 SCIP_Real absprimal = REALABS(primalbound);
5679
5680 gap = REALABS((primalbound - dualbound)/MIN(absdual, absprimal));
5681 }
5682
5683 return gap;
5684}
5685
5687 GCG* gcg
5688 )
5689{
5690 SCIP_RELAX* relax;
5691
5692 assert(gcg != NULL);
5693
5694 relax = GCGgetRelax(gcg);
5695 assert(relax != NULL);
5697 return initializeMasterProblemSolve(gcg, relax);
5698}
5699
5701 GCG* gcg
5702 )
5703{
5704 SCIP* scip;
5706 SCIP_RELAXDATA* relaxdata;
5707 SCIP_RELAX* relax;
5708
5711 relax = GCGgetRelax(gcg);
5712 assert(relax != NULL);
5713 relaxdata = SCIPrelaxGetData(relax);
5714 assert(relaxdata != NULL);
5715
5716 if( relaxdata->limitsettingsstashed == FALSE )
5717 {
5718 relaxdata->limitsettingsstashed = TRUE;
5719
5720 SCIP_CALL( SCIPgetLongintParam(scip, "limits/nodes", &relaxdata->stashednodelimit) );
5721 SCIP_CALL( SCIPgetLongintParam(scip, "limits/stallnodes", &relaxdata->stashedstallnodelimit) );
5722 SCIP_CALL( SCIPgetRealParam(scip, "limits/gap", &relaxdata->stashedgaplimit) );
5723 SCIP_CALL( SCIPgetIntParam(scip, "limits/solutions", &relaxdata->stashedsollimit) );
5724 SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &relaxdata->stashedtimelimit) );
5725
5726 SCIPresetParam(scip, "limits/nodes");
5727 SCIPresetParam(scip, "limits/stallnodes");
5728 SCIPresetParam(scip, "limits/gap");
5729 SCIPresetParam(scip, "limits/solutions");
5730 SCIPresetParam(scip, "limits/time");
5731 SCIPresetParam(masterprob, "limits/gap");
5732 SCIPresetParam(masterprob, "limits/time");
5733 }
5734
5735 return SCIP_OKAY;
5736}
5737
5739 GCG* gcg
5740 )
5741{
5742 SCIP* scip;
5744 SCIP_RELAXDATA* relaxdata;
5745 SCIP_RELAX* relax;
5746
5749 relax = GCGgetRelax(gcg);
5750 assert(relax != NULL);
5751 relaxdata = SCIPrelaxGetData(relax);
5752 assert(relaxdata != NULL);
5753
5754 if( relaxdata->limitsettingsstashed == TRUE )
5755 {
5756 relaxdata->limitsettingsstashed = FALSE;
5757
5758 SCIP_CALL( SCIPsetLongintParam(scip, "limits/nodes", relaxdata->stashednodelimit) );
5759 SCIP_CALL( SCIPsetLongintParam(scip, "limits/stallnodes", relaxdata->stashedstallnodelimit) );
5760 SCIP_CALL( SCIPsetRealParam(scip, "limits/gap", relaxdata->stashedgaplimit) );
5761 SCIP_CALL( SCIPsetIntParam(scip, "limits/solutions", relaxdata->stashedsollimit) );
5762 SCIP_CALL( SCIPsetRealParam(scip, "limits/time", relaxdata->stashedtimelimit) );
5763
5765 }
5766
5767 return SCIP_OKAY;
5768}
5769
5770#ifdef _OPENMP
5771GCG_LOCKS* GCGgetLocks(
5772 GCG* gcg /**< the GCG data structure */
5773 )
5774{
5775 SCIP_RELAXDATA* relaxdata;
5776 SCIP_RELAX* relax = GCGgetRelax(gcg);
5777 assert(relax != NULL);
5778
5779 relaxdata = SCIPrelaxGetData(relax);
5780 assert(relaxdata != NULL);
5781
5782 return relaxdata->locks;
5783}
5784#endif
5785
5786/** returns the GCG data structure */
5789 SCIP* origprob /**< SCIP data structure */
5790 )
5791{
5792 SCIP_RELAX* relax;
5793 SCIP_RELAXDATA* relaxdata;
5794
5795 assert(origprob != NULL);
5796
5798 assert(relax != NULL);
5799
5800 relaxdata = SCIPrelaxGetData(relax);
5801 assert(relaxdata != NULL);
5802
5803 return relaxdata->gcg;
5804}
5805
5806/** includes a separator into the relaxator data */
5808 GCG* gcg, /**< SCIP data structure */
5809 SCIP_SEPA** sepa, /**< pointer to store created scip separator */
5810 GCG_SEPA** gcgsepa, /**< pointer to store created GCG separator (can be NULL) */
5811 const char* name, /**< name of separator */
5812 const char* desc, /**< description of separator */
5813 int priority, /**< priority of separator (>= 0: before, < 0: after constraint handlers) */
5814 int freq, /**< frequency for calling separator */
5815 SCIP_Real maxbounddist, /**< maximal relative distance from current node's dual bound to primal bound compared
5816 * to best node's dual bound for applying separation */
5817 SCIP_Bool usessubscip, /**< does the separator use a secondary SCIP instance? */
5818 SCIP_Bool delay, /**< should separator be delayed, if other separators found cuts? */
5819 SCIP_DECL_SEPAEXECLP ((*sepaexeclp)), /**< LP solution separation method of separator */
5820 SCIP_DECL_SEPAEXECSOL ((*sepaexecsol)), /**< arbitrary primal solution separation method of separator */
5821 SCIP_SEPADATA* sepadata, /**< separator data */
5822 GCG_DECL_SEPAGETCOLCOEFFICIENT((*sepagetcolcoef)),/**< method for computing the column coefficient for a cut */
5823 GCG_DECL_SEPAMASTERCUTDELETE((*sepamastercutdelete))/**< callback to delete the mastersepacutdata */
5824 )
5825{
5826 SCIP_RELAX* relax;
5827 SCIP_RELAXDATA* relaxdata;
5828 int pos;
5829
5830 assert(gcg != NULL);
5831 assert(sepa != NULL);
5832
5833 relax = GCGgetRelax(gcg);
5834 assert(relax != NULL);
5835
5836 relaxdata = SCIPrelaxGetData(relax);
5837 assert(relaxdata != NULL);
5838
5839 SCIP_CALL( ensureSizeSeparators(gcg, relaxdata) );
5840
5841 pos = relaxdata->nseparators;
5842
5843 SCIP_CALL( SCIPincludeSepaBasic(GCGgetMasterprob(gcg), sepa, name, desc, priority, freq, maxbounddist, usessubscip,
5844 delay, sepaexeclp, sepaexecsol, sepadata) );
5845
5846 /* store callback functions */
5847 SCIP_CALL( SCIPallocMemory(GCGgetOrigprob(gcg), &(relaxdata->separators[pos])) );
5848 relaxdata->separators[pos]->separator = *sepa;
5849 relaxdata->separators[pos]->sepagetcolcoefficient = sepagetcolcoef;
5850 relaxdata->separators[pos]->sepamastercutdelete = sepamastercutdelete;
5851 relaxdata->nseparators++;
5852
5853 if( gcgsepa != NULL )
5854 *gcgsepa = relaxdata->separators[pos];
5855
5856 return SCIP_OKAY;
5857}
automorphism recognition of SCIPs
void GCGgetBlissName(char *buffer, int len)
void GCGgetNautyName(char *buffer, int len)
SCIP_RETCODE GCGincludeBendersGcg(GCG *gcg)
GCG Benders' decomposition.
SCIP_RETCODE GCGincludeBendersPlugins(GCG *gcg)
SCIP plugins for the master problem running in Benders' decomposition mode.
SCIP_VAR ** b
SCIP_Bool GCGconshdlrDecompPartialdecAggregationInformationCalculated(PARTIALDECOMP_C *partialdecomp)
returns whether aggregation information has been calculated for a partialdec
int GCGconshdlrDecompPartialdecGetReprBlockForEqClass(PARTIALDECOMP_C *partialdecomp, int eqclass)
gets the representative block of a equivalence class of partialdec
SCIP_Bool GCGconshdlrDecompCheckConsistency(GCG *gcg)
check whether partialdecs are consistent
const int * GCGconshdlrDecompPartialdecGetBlocksForEqClass(PARTIALDECOMP_C *partialdecomp, int eqclass)
gets the blocks of a equivalence class of partialdec
SCIP_RETCODE GCGconshdlrDecompTranslateOrigPartialdecs(GCG *gcg)
translates unpresolved partialdec to a complete presolved one
int GCGconshdlrDecompPartialdecGetNEquivalenceClasses(PARTIALDECOMP_C *partialdecomp)
gets number of equivalence classes of partialdec
const int * GCGconshdlrDecompPartialdecGetRepVarMap(PARTIALDECOMP_C *partialdecomp, int eqclass, int eqclassblock)
Returns a vector that maps probvar indices of a block contained in an equivalence class to the probva...
int GCGconshdlrDecompPartialdecGetNVarsForBlock(PARTIALDECOMP_C *partialdecomp, int block)
gets the number of variables of a block
SCIP_VAR * GCGconshdlrDecompPartialdecGetOrigVarForBlock(PARTIALDECOMP_C *partialdecomp, int block, int blockvarindex)
returns the original variable for a block and index
SCIP_RETCODE GCGconshdlrDecompSelectPartialdec(PARTIALDECOMP_C *partialdecomp, SCIP_Bool select)
selects/unselects a partialdecomp
SCIP_RETCODE GCGconshdlrDecompAddBasicPartialdec(GCG *gcg, SCIP_Bool presolved, PARTIALDECOMP_C **partialdecomp)
creates and adds a basic partialdecomp (all cons/vars are assigned to master)
SCIP_Bool GCGdetectionTookPlace(GCG *gcg, SCIP_Bool original)
int GCGconshdlrDecompPartialdecGetNBlocks(PARTIALDECOMP_C *partialdecomp)
gets block number of partialdec
SCIP_RETCODE GCGdetectStructure(GCG *gcg, SCIP_RESULT *result)
interface method to detect the structure including presolving
int GCGconshdlrDecompGetNFormerDetectionConssForID(GCG *gcg, int id)
gets number of active constraints during the detection of the decomp with given id
int GCGconshdlrDecompPartialdecGetNBlocksForEqClass(PARTIALDECOMP_C *partialdecomp, int eqclass)
gets the number of blocks of a equivalence class of partialdec
SCIP_RETCODE SCIPconshdlrDecompRepairConsNames(GCG *gcg)
unsigned int GCGconshdlrDecompGetNFinishedPartialdecsTransformed(GCG *gcg)
Gets the number of finished partialdecs available for the transformed problem.
GCG_DECOMP * GCGgetBestDecomp(GCG *gcg, SCIP_Bool printwarnings)
Gets the best known decomposition.
SCIP_Bool GCGconshdlrDecompOrigPartialdecExists(GCG *gcg)
returns whether or not an original decompositions exists in the data structures
void GCGconshdlrDecompPartialdecCalcAggregationInformation(PARTIALDECOMP_C *partialdecomp, SCIP_Bool ignoreDetectionLimits)
calculates aggregation information for a partialdec
PARTIALDECOMP * GCGconshdlrDecompGetPartialdecFromID(GCG *gcg, int partialdecid)
local method to find a partialdec for a given id or NULL if no partialdec with such id is found
constraint handler for structure detection
struct PARTIALDECOMP_C PARTIALDECOMP_C
Definition cons_decomp.h:59
SCIP_RETCODE GCGconsIntegralorigAddBranchrule(GCG *gcg, SCIP_BRANCHRULE *branchrule)
constraint handler for the integrality constraint
SCIP_CONS * GCGconsMasterbranchGetActiveCons(GCG *gcg)
SCIP_RETCODE GCGcreateConsMasterbranch(GCG *gcg, SCIP_CONS **cons, const char *name, SCIP_NODE *node, SCIP_CONS *parentcons, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_CONS **origbranchconss, int norigbranchconss, int maxorigbranchconss)
constraint handler for storing the branching decisions at each node of the tree
SCIP_CONS * GCGconsOrigbranchGetActiveCons(GCG *gcg)
GCG_BRANCHRULE * GCGconsOrigbranchGetBranchrule(SCIP_CONS *cons)
SCIP_RETCODE GCGconsOrigbranchAddRootCons(GCG *gcg)
GCG_BRANCHDATA * GCGconsOrigbranchGetBranchdata(SCIP_CONS *cons)
SCIP_RETCODE GCGcreateConsOrigbranch(GCG *gcg, SCIP_CONS **cons, const char *name, SCIP_NODE *node, SCIP_CONS *parentcons, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata)
constraint handler for storing the branching decisions at each node of the tree
SCIP_VAR ** GCGdecompGetLinkingvars(GCG_DECOMP *decomp)
Definition decomp.c:1056
SCIP_RETCODE GCGcreateBasicDecomp(GCG *gcg, GCG_DECOMP **decomp, SCIP_Bool solveorigprob)
Definition decomp.c:2418
SCIP_RETCODE GCGdecompCheckConsistency(GCG *gcg, GCG_DECOMP *decdecomp)
Definition decomp.c:2297
int GCGdecompGetPartialdecID(GCG_DECOMP *decomp)
Definition decomp.c:1685
SCIP_CONS *** GCGdecompGetSubscipconss(GCG_DECOMP *decomp)
Definition decomp.c:924
int GCGdecompGetNLinkingconss(GCG_DECOMP *decomp)
Definition decomp.c:995
SCIP_RETCODE GCGdecompAddRemainingConss(GCG *gcg, GCG_DECOMP *decdecomp)
Definition decomp.c:2206
SCIP_CONS ** GCGdecompGetLinkingconss(GCG_DECOMP *decomp)
Definition decomp.c:985
int GCGdecompGetNMastervars(GCG_DECOMP *decomp)
Definition decomp.c:1089
SCIP_HASHMAP * GCGdecompGetVartoblock(GCG_DECOMP *decomp)
Definition decomp.c:1221
int * GCGdecompGetNSubscipvars(GCG_DECOMP *decomp)
Definition decomp.c:847
SCIP_Real GCGdecompGetMaxwhiteScore(GCG_DECOMP *decomp)
Definition decomp.c:713
SCIP_RETCODE GCGdecompFree(GCG *gcg, GCG_DECOMP **decdecomp)
Definition decomp.c:541
int GCGdecompGetNBlocks(GCG_DECOMP *decomp)
Definition decomp.c:757
int GCGdecompGetNLinkingvars(GCG_DECOMP *decomp)
Definition decomp.c:1066
SCIP_VAR *** GCGdecompGetSubscipvars(GCG_DECOMP *decomp)
Definition decomp.c:837
GCG_DECTYPE GCGdecompGetType(GCG_DECOMP *decomp)
Definition decomp.c:703
SCIP_RETCODE GCGpermuteDecomp(GCG *gcg, GCG_DECOMP *decomp, SCIP_RANDNUMGEN *randnumgen)
Definition decomp.c:4384
int * GCGdecompGetNSubscipconss(GCG_DECOMP *decomp)
Definition decomp.c:933
#define GCG_EXPORT
Definition def.h:59
#define SCIP_MAXSTRLEN
#define SCIP_Longint
#define SCIP_Bool
#define MIN(x, y)
#define SCIP_Real
#define MAX(x, y)
#define SCIP_LONGINT_FORMAT
#define REALABS(x)
#define TRUE
#define FALSE
#define infinity
SCIP_RELAX * GCGgetRelax(GCG *gcg)
Definition gcg.cpp:176
GCG interface methods.
SCIP_RETCODE GCGoriginalVarAddMasterVar(GCG *gcg, SCIP_VAR *origvar, SCIP_VAR *var, SCIP_Real val)
Definition gcgvar.c:1206
void GCGoriginalVarSetNCoefs(SCIP_VAR *var, int ncoefs)
Definition gcgvar.c:737
SCIP_Bool GCGvarIsOriginal(SCIP_VAR *var)
Definition gcgvar.c:231
SCIP_VAR ** GCGlinkingVarGetPricingVars(SCIP_VAR *var)
Definition gcgvar.c:488
int GCGlinkingVarGetNBlocks(SCIP_VAR *var)
Definition gcgvar.c:572
SCIP_RETCODE GCGorigVarCreateData(GCG *gcg, SCIP_VAR *var)
Definition gcgvar.c:382
int GCGmasterVarGetNOrigvars(SCIP_VAR *var)
Definition gcgvar.c:971
SCIP_VAR ** GCGoriginalVarGetMastervars(SCIP_VAR *var)
Definition gcgvar.c:666
SCIP_RETCODE GCGcreateInitialMasterVar(GCG *gcg, SCIP_VAR *var, SCIP_VAR **newvar)
Definition gcgvar.c:1586
SCIP_RETCODE GCGfreeOrigVarsData(GCG *gcg)
Definition gcgvar.c:346
void GCGvarSetBlock(SCIP_VAR *var, int block)
Definition gcgvar.c:1133
SCIP_Bool GCGoriginalVarIsLinking(SCIP_VAR *var)
Definition gcgvar.c:247
void GCGoriginalVarSetPricingVar(SCIP_VAR *var, SCIP_VAR *pricingvar)
Definition gcgvar.c:300
SCIP_RETCODE GCGcreateOrigVarsData(GCG *gcg)
Definition gcgvar.c:320
SCIP_VAR * GCGoriginalVarGetPricingVar(SCIP_VAR *var)
Definition gcgvar.c:281
SCIP_CONS ** GCGlinkingVarGetLinkingConss(SCIP_VAR *var)
Definition gcgvar.c:872
SCIP_RETCODE GCGpricingVarAddOrigVar(SCIP *pricingprob, SCIP_VAR *pricingvar, SCIP_VAR *origvar)
Definition gcgvar.c:610
SCIP_RETCODE GCGoriginalVarCreatePricingVar(SCIP *pricingprob, SCIP_VAR *origvar, SCIP_VAR **var)
Definition gcgvar.c:1302
SCIP_RETCODE GCGoriginalVarAddCoef(GCG *gcg, SCIP_VAR *var, SCIP_Real val, SCIP_CONS *cons)
Definition gcgvar.c:758
SCIP_VAR ** GCGmasterVarGetOrigvars(SCIP_VAR *var)
Definition gcgvar.c:993
SCIP_Real * GCGoriginalVarGetCoefs(SCIP_VAR *var)
Definition gcgvar.c:702
SCIP_Bool GCGisLinkingVarInBlock(SCIP_VAR *var, int block)
Definition gcgvar.c:1149
SCIP_Bool GCGvarIsMaster(SCIP_VAR *var)
Definition gcgvar.c:176
SCIP_Bool GCGoriginalVarIsTransVar(SCIP_VAR *var)
Definition gcgvar.c:264
void GCGlinkingVarSetPricingVar(SCIP_VAR *origvar, int pricingprobnr, SCIP_VAR *var)
Definition gcgvar.c:506
SCIP_RETCODE GCGlinkingVarCreatePricingVar(SCIP *pricingscip, int pricingprobnr, SCIP_VAR *origvar, SCIP_VAR **var)
Definition gcgvar.c:1339
SCIP_Real * GCGmasterVarGetOrigvals(SCIP_VAR *var)
Definition gcgvar.c:1017
SCIP_RETCODE GCGoriginalVarAddBlock(GCG *gcg, SCIP_VAR *var, int newblock, int nblocks, GCG_DECMODE mode)
Definition gcgvar.c:808
SCIP_RETCODE GCGlinkingVarCreateMasterCons(GCG *gcg, int pricingprobnr, SCIP_VAR *origvar, SCIP_CONS **linkcons)
Definition gcgvar.c:1374
int GCGoriginalVarGetNMastervars(SCIP_VAR *var)
Definition gcgvar.c:648
void GCGlinkingVarSetLinkingCons(SCIP_VAR *var, SCIP_CONS *cons, int index)
Definition gcgvar.c:891
int GCGvarGetBlock(SCIP_VAR *var)
Definition gcgvar.c:1118
SCIP_SOL * GCGbendersGetRelaxSol(SCIP_BENDERS *benders)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
enum SCIP_SetppcType SCIP_SETPPCTYPE
SCIP_SETPPCTYPE SCIPgetTypeSetppc(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_SETPPCTYPE_PARTITIONING
SCIP_SETPPCTYPE_COVERING
SCIP_SETPPCTYPE_PACKING
SCIP_RETCODE SCIPgetConsCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_CONS *sourcecons, SCIP_CONS **targetcons, SCIP_CONSHDLR *sourceconshdlr, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *name, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, SCIP_Bool global, SCIP_Bool *valid)
SCIP_Bool GCGmasterIsBestsolValid(GCG *gcg)
SCIP_Real GCGmasterGetDegeneracy(GCG *gcg)
SCIP_RETCODE GCGmasterAddMasterconsToHashmap(GCG *gcg, SCIP_CONS *cons, int pos)
SCIP_Bool GCGmasterIsCurrentSolValid(GCG *gcg)
SCIP_Bool GCGmasterIsSolValid(GCG *gcg, SCIP_SOL *mastersol)
SCIP_RETCODE GCGincludePricerGcg(GCG *gcg)
SCIP_RETCODE GCGmasterCreateInitialMastervars(GCG *gcg)
GCG_EXPORT SCIP_RETCODE GCGtransformProb(GCG *gcg)
Definition relax_gcg.c:5331
GCG_EXPORT SCIP_Bool GCGisMasterSetPartitioning(GCG *gcg)
Definition relax_gcg.c:4366
SCIP_RETCODE GCGtransformMastersolToOrigsol(GCG *gcg, SCIP_SOL *mastersol, SCIP_SOL **origsol, SCIP_Bool ignorelocalvarbnds, SCIP_Bool *violatesvarbnds)
Definition misc.c:135
GCG_EXPORT SCIP * GCGgetPricingprob(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4075
GCG_EXPORT SCIP_CONS ** GCGgetMasterConss(GCG *gcg)
Definition relax_gcg.c:4228
GCG_EXPORT int GCGgetNTransvars(GCG *gcg)
Definition relax_gcg.c:5256
GCG_EXPORT SCIP_CONS ** GCGgetOrigMasterConss(GCG *gcg)
Definition relax_gcg.c:4245
GCG_EXPORT SCIP_RETCODE GCGdetect(GCG *gcg)
Definition relax_gcg.c:5421
GCG_EXPORT SCIP_CONS * GCGgetConvCons(GCG *gcg, int blocknr)
Definition relax_gcg.c:4262
GCG_EXPORT int GCGgetNMasterConss(GCG *gcg)
Definition relax_gcg.c:4211
GCG_EXPORT SCIP_CONS ** GCGgetVarLinkingconss(GCG *gcg)
Definition relax_gcg.c:5188
GCG_EXPORT int GCGgetNVarLinkingconss(GCG *gcg)
Definition relax_gcg.c:5222
GCG_EXPORT SCIP_Bool GCGrelaxIsInitialized(GCG *gcg)
Definition relax_gcg.c:5145
GCG_EXPORT SCIP_Real GCGgetPricingprobsMemUsed(GCG *gcg)
Definition relax_gcg.c:5114
GCG_EXPORT int GCGgetNRelPricingprobs(GCG *gcg)
Definition relax_gcg.c:4095
GCG_EXPORT GCG_DECOMP * GCGgetStructDecomp(GCG *gcg)
Definition relax_gcg.c:2331
GCG_EXPORT SCIP_Bool GCGisMasterSetCovering(GCG *gcg)
Definition relax_gcg.c:4347
GCG_EXPORT GCG_PARAMDATA * GCGgetParamsVisu(GCG *gcg)
Definition relax_gcg.c:4285
GCG_EXPORT SCIP_CLOCK * GCGgetRootNodeTime(GCG *gcg)
Definition relax_gcg.c:5313
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
GCG_EXPORT int GCGgetNIdenticalBlocks(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4185
GCG_EXPORT int GCGgetNLinkingvars(GCG *gcg)
Definition relax_gcg.c:5239
GCG_EXPORT SCIP_SOL * GCGgetBendersRelaxationSol(GCG *gcg)
Definition relax_gcg.c:5273
GCG_EXPORT int GCGgetNPricingprobs(GCG *gcg)
Definition relax_gcg.c:4113
GCG_EXPORT int GCGgetBlockRepresentative(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4155
SCIP * GCGgetMasterprob(GCG *gcg)
Definition gcg.cpp:99
GCG_EXPORT SCIP_Real GCGgetDegeneracy(GCG *gcg)
Definition relax_gcg.c:5163
GCG_EXPORT GCG_DECMODE GCGgetDecompositionMode(GCG *gcg)
Definition relax_gcg.c:5294
GCG_EXPORT int * GCGgetVarLinkingconssBlock(GCG *gcg)
Definition relax_gcg.c:5205
GCG_EXPORT SCIP_Bool GCGisPricingprobRelevant(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4132
GCG_EXPORT SCIP_RETCODE GCGsolve(GCG *gcg)
Definition relax_gcg.c:5480
GCG_EXPORT SCIP_RETCODE GCGpresolve(GCG *gcg)
Definition relax_gcg.c:5370
SCIP_Bool SCIPisTransformed(SCIP *scip)
SCIP_Bool SCIPisStopped(SCIP *scip)
SCIP_RETCODE SCIPfree(SCIP **scip)
SCIP_RETCODE SCIPcreate(SCIP **scip)
SCIP_STATUS SCIPgetStatus(SCIP *scip)
SCIP_STAGE SCIPgetStage(SCIP *scip)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPsetObjIntegral(SCIP *scip)
const char * SCIPgetProbName(SCIP *scip)
int SCIPgetNContVars(SCIP *scip)
SCIP_RETCODE SCIPwriteOrigProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames)
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
SCIP_Real SCIPgetTransObjoffset(SCIP *scip)
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
SCIP_Real SCIPgetObjlimit(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNConss(SCIP *scip)
SCIP_RETCODE SCIPfreeProb(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_RETCODE SCIPprintOrigProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
SCIP_Bool SCIPisObjIntegral(SCIP *scip)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPaddConsNode(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode)
SCIP_Real SCIPgetLocalLowerbound(SCIP *scip)
SCIP_Real SCIPgetLocalDualbound(SCIP *scip)
SCIP_Real GCGconsGetRhs(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:109
SCIP_Bool GCGgetConsIsSetppc(SCIP *scip, SCIP_CONS *cons, SCIP_SETPPCTYPE *setppctype)
Definition scip_misc.c:760
SCIP_RETCODE GCGconsGetVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int nvars)
Definition scip_misc.c:487
SCIP_Real GCGconsGetLhs(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:207
SCIP_RETCODE GCGconsGetVals(SCIP *scip, SCIP_CONS *cons, SCIP_Real *vals, int nvals)
Definition scip_misc.c:618
int GCGconsGetNVars(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:433
SCIP_RETCODE SCIPsetMessagehdlr(SCIP *scip, SCIP_MESSAGEHDLR *messagehdlr)
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
SCIP_VERBLEVEL SCIPgetVerbLevel(SCIP *scip)
SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
void SCIPsetMessagehdlrQuiet(SCIP *scip, SCIP_Bool quiet)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
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 SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
SCIP_RETCODE SCIPresetParam(SCIP *scip, const char *name)
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_RETCODE SCIPsetCharParam(SCIP *scip, const char *name, char 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 SCIPgetLongintParam(SCIP *scip, const char *name, SCIP_Longint *value)
SCIP_RETCODE SCIPgetIntParam(SCIP *scip, const char *name, int *value)
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
SCIP_RETCODE SCIPfixParam(SCIP *scip, const char *name)
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_BENDERS * SCIPfindBenders(SCIP *scip, const char *name)
SCIP_RETCODE SCIPactivateBenders(SCIP *scip, SCIP_BENDERS *benders, int nsubproblems)
SCIP_RETCODE SCIPfreeBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, int probnumber)
SCIP_RETCODE SCIPsolveBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, SCIP_SOL *sol, int probnumber, SCIP_Bool *infeasible, SCIP_Bool solvecip, SCIP_Real *objective)
void SCIPbendersSetSubproblemIsIndependent(SCIP_BENDERS *benders, int probnumber, SCIP_Bool isindep)
SCIP_RETCODE SCIPincludeBranchruleBasic(SCIP *scip, SCIP_BRANCHRULE **branchruleptr, const char *name, const char *desc, int priority, int maxdepth, SCIP_Real maxbounddist, SCIP_BRANCHRULEDATA *branchruledata)
SCIP_RETCODE SCIPaddExternBranchCand(SCIP *scip, SCIP_VAR *var, SCIP_Real score, SCIP_Real solval)
void SCIPclearExternBranchCands(SCIP *scip)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_RETCODE SCIPtransformConss(SCIP *scip, int nconss, SCIP_CONS **conss, SCIP_CONS **transconss)
SCIP_Bool SCIPconsIsDeleted(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_RETCODE SCIPgetTransformedCons(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **transcons)
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_RETCODE SCIPtransformCons(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **transcons)
SCIP_RETCODE SCIPcaptureCons(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPincludeExternalCodeInformation(SCIP *scip, const char *name, const char *description)
SCIP_RETCODE SCIPflushLP(SCIP *scip)
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
SCIP_Bool SCIPisLPConstructed(SCIP *scip)
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
SCIP_Real SCIPgetLPObjval(SCIP *scip)
#define SCIPreallocMemoryArray(scip, ptr, newnum)
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
#define SCIPallocMemoryArray(scip, ptr, num)
#define SCIPallocClearBufferArray(scip, ptr, num)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
#define SCIPfreeMemoryArray(scip, ptr)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
#define SCIPfreeBufferArrayNull(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
SCIP_PRICER * SCIPfindPricer(SCIP *scip, const char *name)
SCIP_RETCODE SCIPactivatePricer(SCIP *scip, SCIP_PRICER *pricer)
int SCIPgetProbingDepth(SCIP *scip)
SCIP_RETCODE SCIPpropagateProbing(SCIP *scip, int maxproprounds, SCIP_Bool *cutoff, SCIP_Longint *ndomredsfound)
SCIP_RETCODE SCIPbacktrackProbing(SCIP *scip, int probingdepth)
SCIP_Bool SCIPinProbing(SCIP *scip)
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
SCIP_RETCODE SCIPnewProbingNode(SCIP *scip)
SCIP_RETCODE SCIPsolveProbingLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
SCIP_RETCODE SCIPendProbing(SCIP *scip)
SCIP_RETCODE SCIPsolveProbingLPWithPricing(SCIP *scip, SCIP_Bool pretendroot, SCIP_Bool displayinfo, int maxpricerounds, SCIP_Bool *lperror, SCIP_Bool *cutoff)
SCIP_RETCODE SCIPincludeRelax(SCIP *scip, const char *name, const char *desc, int priority, int freq, SCIP_DECL_RELAXCOPY((*relaxcopy)), SCIP_DECL_RELAXFREE((*relaxfree)), SCIP_DECL_RELAXINIT((*relaxinit)), SCIP_DECL_RELAXEXIT((*relaxexit)), SCIP_DECL_RELAXINITSOL((*relaxinitsol)), SCIP_DECL_RELAXEXITSOL((*relaxexitsol)), SCIP_DECL_RELAXEXEC((*relaxexec)), SCIP_RELAXDATA *relaxdata)
SCIP_RELAX * SCIPfindRelax(SCIP *scip, const char *name)
SCIP_RELAXDATA * SCIPrelaxGetData(SCIP_RELAX *relax)
SCIP_RETCODE SCIPincludeSepaBasic(SCIP *scip, SCIP_SEPA **sepa, const char *name, const char *desc, int priority, int freq, SCIP_Real maxbounddist, SCIP_Bool usessubscip, SCIP_Bool delay, SCIP_DECL_SEPAEXECLP((*sepaexeclp)), SCIP_DECL_SEPAEXECSOL((*sepaexecsol)), SCIP_SEPADATA *sepadata)
SCIP_RETCODE SCIPcheckSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
SCIP_RETCODE SCIPcreateSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
SCIP_RETCODE SCIPincSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real incval)
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
SCIP_RETCODE SCIPcheckSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
SCIP_RETCODE SCIPpresolve(SCIP *scip)
SCIP_RETCODE SCIPfreeTransform(SCIP *scip)
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
SCIP_RETCODE SCIPsolve(SCIP *scip)
SCIP_Real SCIPgetPrimalbound(SCIP *scip)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Real SCIPgetDualbound(SCIP *scip)
int SCIPgetNActiveConss(SCIP *scip)
int SCIPgetNPriceRounds(SCIP *scip)
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
SCIP_RETCODE SCIPcreateClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_Real SCIPgetClockTime(SCIP *scip, SCIP_CLOCK *clck)
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
SCIP_NODE * SCIPgetRootNode(SCIP *scip)
SCIP_Real SCIPgetRelaxSolObj(SCIP *scip)
SCIP_VAR * SCIPvarGetNegatedVar(SCIP_VAR *var)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Bool SCIPvarIsTransformed(SCIP_VAR *var)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
int SCIPvarGetIndex(SCIP_VAR *var)
int SCIPvarGetProbindex(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_Real SCIPgetRelaxSolVal(SCIP *scip, SCIP_VAR *var)
SCIP_VARDATA * SCIPvarGetData(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_Bool SCIPvarIsNegated(SCIP_VAR *var)
SCIP_Bool SCIPvarIsOriginal(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
SCIP_RETCODE SCIPgetTransformedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **transvar)
SCIP_Bool SCIPallowStrongDualReds(SCIP *scip)
SCIP_RETCODE SCIPsetRelaxSolValsSol(SCIP *scip, SCIP_RELAX *relax, SCIP_SOL *sol, SCIP_Bool includeslp)
SCIP_RETCODE GCGincludeRelaxGcg(GCG *gcg)
Definition relax_gcg.c:3577
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed, SCIP_Bool useglobalseed)
void SCIPsortRealInt(SCIP_Real *realarray, int *intarray, int len)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIP_Bool GCGvarIsPricing(SCIP_VAR *var)
Definition gcgvar.c:159
SCIPfreeMemory(GCGgetOrigprob(gcg), &divingdata)
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 j
SCIP_Longint nlpiterations
SCIP_Bool success
SCIP_Real solval
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
SCIP_RETCODE retcode
int i
int nvars
SCIPfreeBufferArray(scip, &cycles)
SCIP_SOL * sol
SCIP_VAR ** mastervars
int nmastervars
SCIP_Bool lperror
static SCIP_LPSOLSTAT lpsolstat
heurdata npricerounds
int maxdepth
SCIP_Bool cutoff
SCIP_Bool lpsolved
#define NULL
SCIP_RETCODE GCGincludeMasterPlugins(GCG *gcg)
SCIP plugins for generic column generation.
SCIP_Bool SCIPmessagehdlrIsQuiet(SCIP_MESSAGEHDLR *messagehdlr)
SCIP_RETCODE GCGcreateParamsVisu(GCG *gcg, GCG_PARAMDATA **paramdata)
void GCGVisuFreeParams(GCG *gcg, GCG_PARAMDATA *paramdata)
#define DEFAULT_DISPINFOS
GCG variable pricer.
helper functions for automorphism detection
GCG_EXPORT SCIP_Real GCGgetGap(GCG *gcg)
Definition relax_gcg.c:5651
GCG_EXPORT SCIP_Real GCGgetPrimalbound(GCG *gcg)
Definition relax_gcg.c:5620
GCG_EXPORT SCIP_Real GCGgetDualbound(GCG *gcg)
Definition relax_gcg.c:5589
#define SCIPerrorMessage
#define SCIPdebugPrintf
static SCIP_RETCODE solveBlockProblem(GCG *gcg, SCIP *blockprob, SCIP_RELAXDATA *relaxdata, SCIP_Real timelimit, int blocknum, SCIP_RESULT *result, SCIP_Real *objvalue)
Definition relax_gcg.c:2019
SCIP_RETCODE GCGrelaxBranchActiveMaster(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata)
Definition relax_gcg.c:3781
SCIP_RETCODE GCGrelaxBranchGetAllActiveExtendedMasterConss(GCG *gcg, GCG_BRANCHRULE ***branchrules, GCG_BRANCHDATA ***branchdata, GCG_EXTENDEDMASTERCONSDATA ***extendedmasterconsdata, int *nextendedmasterconss)
Definition relax_gcg.c:3931
static SCIP_RETCODE initRelaxProblemdata(GCG *gcg, SCIP_RELAXDATA *relaxdata)
Definition relax_gcg.c:1277
SCIP_RETCODE GCGrelaxNewProbingnodeMaster(GCG *gcg)
Definition relax_gcg.c:4508
#define RELAX_DESC
Definition relax_gcg.c:87
static SCIP_RETCODE solveMasterProblemAndEvaluate(GCG *gcg, SCIP_RELAX *relax, SCIP_Real *lowerbound, SCIP_RESULT *result)
Definition relax_gcg.c:3368
static SCIP_RETCODE ensureSizeBranchrules(GCG *gcg, SCIP_RELAXDATA *relaxdata)
Definition relax_gcg.c:585
static SCIP_RETCODE createPricingProblem(SCIP_RELAXDATA *relaxdata, SCIP **pricingscip, const char *name, int clocktype, SCIP_Real infinity, SCIP_Real epsilon, SCIP_Real sumepsilon, SCIP_Real feastol, SCIP_Real lpfeastolfactor, SCIP_Real dualfeastol, SCIP_Bool enableppcuts)
Definition relax_gcg.c:1400
static SCIP_RETCODE relaxExecGcgBendersDecomposition(GCG *gcg, SCIP_RELAX *relax, SCIP_Real *lowerbound, SCIP_RESULT *result)
Definition relax_gcg.c:3482
SCIP_RETCODE GCGrelaxBranchPropMaster(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_RESULT *result)
Definition relax_gcg.c:3837
static SCIP_RETCODE convertStructToGCG(GCG *gcg, SCIP_RELAXDATA *relaxdata, GCG_DECOMP *decomp)
Definition relax_gcg.c:381
static SCIP_RETCODE createPricingprobConss(GCG *gcg, SCIP_RELAXDATA *relaxdata, SCIP_HASHMAP **hashorig2pricingvar)
Definition relax_gcg.c:1636
static SCIP_RETCODE dropActiveBranchExtendedmastercons(GCG *gcg, SCIP_RELAXDATA *relaxdata, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata)
Definition relax_gcg.c:269
#define RELAX_PRIORITY
Definition relax_gcg.c:88
SCIP_RETCODE GCGrelaxBranchMasterSolved(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_Real newlowerbound)
Definition relax_gcg.c:3961
SCIP_RETCODE GCGrelaxBranchNewCol(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_VAR *mastervar)
Definition relax_gcg.c:3885
static SCIP_RETCODE createMasterProblem(GCG *gcg, const char *name, int clocktype, SCIP_Real infinity, SCIP_Real epsilon, SCIP_Real sumepsilon, SCIP_Real feastol, SCIP_Real lpfeastolfactor, SCIP_Real dualfeastol, GCG_DECMODE mode)
Definition relax_gcg.c:1320
static SCIP_RETCODE relaxExecGcgDantzigWolfe(GCG *gcg, SCIP_RELAX *relax, SCIP_Real *lowerbound, SCIP_RESULT *result)
Definition relax_gcg.c:3253
SCIP_RETCODE GCGrelaxNewProbingnodeMasterCons(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_CONS **origbranchconss, int norigbranchconss, int maxorigbranchconss)
Definition relax_gcg.c:4562
SCIP_RETCODE GCGrelaxPerformProbing(GCG *gcg, int maxlpiterations, SCIP_Longint *nlpiterations, SCIP_Real *lpobjvalue, SCIP_Bool *lpsolved, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition relax_gcg.c:4756
SCIP_RETCODE GCGrelaxIncludeBranchrule(GCG *gcg, SCIP_BRANCHRULE **branchrule, GCG_BRANCHRULE **gcgbranchrule, const char *name, const char *desc, int priority, int maxdepth, SCIP_Real maxbounddist, SCIP_BRANCHRULEDATA *branchruledata, GCG_DECL_BRANCHACTIVEMASTER((*branchactivemaster)), GCG_DECL_BRANCHDEACTIVEMASTER((*branchdeactivemaster)), GCG_DECL_BRANCHPROPMASTER((*branchpropmaster)), GCG_DECL_BRANCHMASTERSOLVED((*branchmastersolved)), GCG_DECL_BRANCHDATADELETE((*branchdatadelete)), GCG_DECL_BRANCHNEWCOL((*branchnewcol)), GCG_DECL_BRANCHGETEXTENDEDMASTERCONS((*branchgetextendedmastercons)),)
Definition relax_gcg.c:3717
#define RELAX_INCLUDESLP
Definition relax_gcg.c:90
SCIP_RETCODE GCGrelaxIncludeSepa(GCG *gcg, SCIP_SEPA **sepa, GCG_SEPA **gcgsepa, const char *name, const char *desc, int priority, int freq, SCIP_Real maxbounddist, SCIP_Bool usessubscip, SCIP_Bool delay, SCIP_DECL_SEPAEXECLP((*sepaexeclp)), SCIP_DECL_SEPAEXECSOL((*sepaexecsol)), SCIP_SEPADATA *sepadata, GCG_DECL_SEPAGETCOLCOEFFICIENT((*sepagetcolcoef)),)
Definition relax_gcg.c:5807
static SCIP_RETCODE freeCurrentOrigSol(GCG *gcg, SCIP_RELAXDATA *relaxdata)
Definition relax_gcg.c:4937
SCIP_RETCODE GCGrelaxStartProbing(GCG *gcg, SCIP_HEUR *probingheur)
Definition relax_gcg.c:4390
#define RELAX_NAME
Definition relax_gcg.c:86
static SCIP_RETCODE createMaster(GCG *gcg, SCIP_RELAXDATA *relaxdata)
Definition relax_gcg.c:1726
static SCIP_RETCODE checkIdenticalBlocks(GCG *gcg, SCIP_RELAXDATA *relaxdata, SCIP_HASHMAP **hashorig2pricingvar)
Definition relax_gcg.c:735
#define RELAX_FREQ
Definition relax_gcg.c:89
static SCIP_RETCODE createMasterprobConss(GCG *gcg, SCIP_RELAXDATA *relaxdata)
Definition relax_gcg.c:1498
SCIP_RETCODE GCGrelaxUpdateCurrentSol(GCG *gcg)
Definition relax_gcg.c:4964
SCIP_SOL * GCGrelaxGetCurrentOrigSol(GCG *gcg)
Definition relax_gcg.c:4309
SCIP_RETCODE GCGrestoreLimitSettings(GCG *gcg)
Definition relax_gcg.c:5738
SCIP_RETCODE GCGsetPricingProblemParameters(GCG_DECTYPE dectype, SCIP *pricingprob, int clocktype, SCIP_Real infinity, SCIP_Real epsilon, SCIP_Real sumepsilon, SCIP_Real feastol, SCIP_Real lpfeastolfactor, SCIP_Real dualfeastol, SCIP_Bool enableppcuts)
Definition relax_gcg.c:865
static SCIP_RETCODE transformMaster(GCG *gcg, SCIP_RELAX *relax)
Definition relax_gcg.c:2378
static SCIP_RETCODE initRelaxdata(GCG *gcg, SCIP_RELAXDATA *relaxdata)
Definition relax_gcg.c:2631
static SCIP_RETCODE createLinkingPricingVars(GCG *gcg, SCIP_RELAXDATA *relaxdata, SCIP_VAR *origvar)
Definition relax_gcg.c:993
static SCIP_RETCODE solveDiagonalBlocks(GCG *gcg, SCIP_RELAXDATA *relaxdata, SCIP_RESULT *result, SCIP_Real *lowerbound)
Definition relax_gcg.c:2232
static SCIP_RETCODE checkSetppcStructure(GCG *gcg, SCIP_RELAXDATA *relaxdata)
Definition relax_gcg.c:631
SCIP_RETCODE GCGrelaxBranchDataDelete(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA **branchdata, SCIP_Bool origbranch, SCIP_Bool force)
Definition relax_gcg.c:3858
SCIP_RETCODE GCGrelaxTransOrigToMasterCons(GCG *gcg, SCIP_CONS *cons, SCIP_CONS **transcons)
Definition relax_gcg.c:3982
static SCIP_RETCODE setMasterLimits(GCG *gcg, SCIP *masterprob, SCIP_Real origtimelimit, SCIP_Real origgaplimit)
Definition relax_gcg.c:3079
#define DEFAULT_AGGREGATIONNCONSSLIMIT
Definition relax_gcg.c:101
SCIP_RETCODE GCGrelaxNewProbingnodeOrig(GCG *gcg)
Definition relax_gcg.c:4459
static SCIP_RETCODE createPricingVariables(GCG *gcg, SCIP_RELAXDATA *relaxdata, SCIP_HASHMAP **hashorig2pricingvar)
Definition relax_gcg.c:1107
#define relaxInitGcg
Definition relax_gcg.c:3569
static SCIP_RETCODE performProbing(GCG *gcg, int maxlpiterations, int maxpricerounds, SCIP_Bool usepricing, SCIP_Longint *nlpiterations, int *npricerounds, SCIP_Real *lpobjvalue, SCIP_Bool *lpsolved, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition relax_gcg.c:4654
static SCIP_DECL_RELAXEXITSOL(relaxExitsolGcg)
Definition relax_gcg.c:2995
SCIP_RETCODE GCGinitializeMasterProblemSolve(GCG *gcg)
Definition relax_gcg.c:5686
SCIP_RETCODE GCGrelaxPerformProbingWithPricing(GCG *gcg, int maxpricerounds, SCIP_Longint *nlpiterations, int *npricerounds, SCIP_Real *lpobjvalue, SCIP_Bool *lpsolved, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition relax_gcg.c:4775
#define DEFAULT_DISCRETIZATION
Definition relax_gcg.c:92
static SCIP_RETCODE ensureSizeMasterConss(GCG *gcg, SCIP_RELAXDATA *relaxdata, int size)
Definition relax_gcg.c:557
static SCIP_RETCODE relaxExecGcgOriginalProblem(GCG *gcg, SCIP_RELAX *relax, SCIP_Real *lowerbound, SCIP_RESULT *result)
Definition relax_gcg.c:3500
SCIP_RETCODE GCGrelaxEndProbing(GCG *gcg)
Definition relax_gcg.c:4794
static SCIP_RETCODE saveOriginalVarMastercoeffs(GCG *gcg, SCIP_VAR **origvars, int norigvars, int nmasterconss, SCIP_CONS **origmasterconss, SCIP_CONS **masterconss)
Definition relax_gcg.c:1441
#define relaxCopyGcg
Definition relax_gcg.c:3568
static SCIP_RETCODE checkAndAddExternalBranchingCandidate(GCG *gcg, SCIP_VAR *var)
Definition relax_gcg.c:4905
#define DEFAULT_MIPDISCRETIZATION
Definition relax_gcg.c:93
#define DEFAULT_AGGREGATIONNVARSLIMIT
Definition relax_gcg.c:102
static void resetRelaxdata(SCIP_RELAXDATA *relaxdata)
Definition relax_gcg.c:2707
SCIP_RETCODE GCGstashLimitSettings(GCG *gcg)
Definition relax_gcg.c:5700
SCIP_HEUR * GCGrelaxGetProbingheur(GCG *gcg)
Definition relax_gcg.c:4437
static SCIP_RETCODE freeBlockProblem(GCG *gcg, SCIP *blockprob, SCIP_RELAXDATA *relaxdata, int blocknum)
Definition relax_gcg.c:2198
#define DEFAULT_BLISS
Definition relax_gcg.c:98
SCIP_Bool GCGrelaxIsOrigSolFeasible(GCG *gcg)
Definition relax_gcg.c:4328
static SCIP_RETCODE createPricingVar(SCIP_RELAXDATA *relaxdata, SCIP_VAR *origvar)
Definition relax_gcg.c:963
static SCIP_RETCODE setOriginalVarBlockNr(GCG *gcg, SCIP_RELAXDATA *relaxdata, SCIP_VAR *var, int newblock)
Definition relax_gcg.c:296
#define DEFAULT_MODE
Definition relax_gcg.c:96
static SCIP_RETCODE initRelaxator(GCG *gcg, SCIP_RELAX *relax)
Definition relax_gcg.c:2466
SCIP_RETCODE GCGrelaxBacktrackProbing(GCG *gcg, int probingdepth)
Definition relax_gcg.c:4618
static SCIP_RETCODE GCGsetStructDecomp(GCG *gcg, GCG_DECOMP *decomp)
Definition relax_gcg.c:2351
GCG_EXPORT GCG * GCGrelaxGetGcg(SCIP *origprob)
Definition relax_gcg.c:5788
#define DEFAULT_BLISS_SEARCH_NODE_LIMIT
Definition relax_gcg.c:99
static SCIP_RETCODE setPricingObjsOriginal(GCG *gcg, SCIP **probs, int nprobs)
Definition relax_gcg.c:1951
static SCIP_RETCODE initializeMasterProblemSolve(GCG *gcg, SCIP_RELAX *relax)
Definition relax_gcg.c:2874
static SCIP_DECL_RELAXFREE(relaxFreeGcg)
Definition relax_gcg.c:2754
static SCIP_DECL_RELAXEXEC(relaxExecGcg)
Definition relax_gcg.c:3519
static SCIP_RETCODE solveMasterProblem(GCG *gcg, SCIP *masterprob, SCIP_RELAXDATA *relaxdata, SCIP_Longint nodelimit, SCIP_Real *lowerbound, SCIP_RESULT *result)
Definition relax_gcg.c:3116
static SCIP_RETCODE displayPricingStatistics(GCG *gcg, SCIP **pricingprobs, int npricingprobs, int *blockrepresentative)
Definition relax_gcg.c:1234
static SCIP_RETCODE markConsMaster(GCG *gcg, SCIP_RELAXDATA *relaxdata, SCIP_CONS *cons)
Definition relax_gcg.c:340
static SCIP_RETCODE combineSolutions(GCG *gcg, SCIP_SOL **newsol, SCIP **probs, int nprobs)
Definition relax_gcg.c:1894
#define DEFAULT_BLISS_GENERATOR_LIMIT
Definition relax_gcg.c:100
static SCIP_RETCODE ensureSizeSeparators(GCG *gcg, SCIP_RELAXDATA *relaxdata)
Definition relax_gcg.c:608
static SCIP_DECL_RELAXEXIT(relaxExitGcg)
Definition relax_gcg.c:2840
SCIP_RETCODE GCGrelaxBranchGetExtendedMasterCons(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, GCG_EXTENDEDMASTERCONSDATA **extendedmasterconsdata)
Definition relax_gcg.c:3905
static SCIP_RETCODE addActiveBranchExtendedmastercons(GCG *gcg, SCIP_RELAXDATA *relaxdata, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata)
Definition relax_gcg.c:214
#define DEFAULT_AGGREGATION
Definition relax_gcg.c:94
SCIP_RETCODE GCGrelaxBranchDeactiveMaster(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata)
Definition relax_gcg.c:3809
static SCIP_DECL_RELAXINITSOL(relaxInitsolGcg)
Definition relax_gcg.c:2910
GCG relaxator.
various SCIP helper methods
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
GCG_EXPORT SCIP_RETCODE GCGsolverKnapsackSolveKnapsack(SCIP_Bool exactly, SCIP *pricingprob, SCIP_Real *solval, GCG_PRICINGSTATUS *status, SCIP_VAR ***solvars, SCIP_Real **solvals, int *nsolvars)
knapsack solver for pricing problems
SCIP_BRANCHRULE * branchrule
SCIP_SEPA * separator
SCIP * bendersmasterprob
Definition struct_gcg.h:59
SCIP * masterprob
Definition struct_gcg.h:57
SCIP * dwmasterprob
Definition struct_gcg.h:58
SCIP_RELAX * relax
Definition struct_gcg.h:60
SCIP_CONS ** markedmasterconss
Definition relax_gcg.c:144
GCG_DECMODE mode
Definition relax_gcg.c:165
GCG_SEPA ** separators
Definition relax_gcg.c:199
SCIP_Bool discretization
Definition relax_gcg.c:159
SCIP_SOL * currentorigsol
Definition relax_gcg.c:139
SCIP_Longint lastmasterlpiters
Definition relax_gcg.c:141
GCG_EXTENDEDMASTERCONSDATA ** activebranchextendedmasterconss
Definition relax_gcg.c:154
SCIP_CONS ** convconss
Definition relax_gcg.c:122
GCG_BRANCHRULE ** branchrules
Definition relax_gcg.c:150
SCIP_Longint lastsolvednodenr
Definition relax_gcg.c:147
int * nblocksidentical
Definition relax_gcg.c:121
SCIP_Longint stashednodelimit
Definition relax_gcg.c:192
SCIP_SOL * storedorigsol
Definition relax_gcg.c:176
SCIP_Bool mipdiscretization
Definition relax_gcg.c:160
SCIP_CONS ** origmasterconss
Definition relax_gcg.c:130
SCIP_HEUR * probingheur
Definition relax_gcg.c:175
int * blockrepresentative
Definition relax_gcg.c:120
GCG_PARAMDATA * paramsvisu
Definition relax_gcg.c:188
SCIP_Bool relaxisinitialized
Definition relax_gcg.c:181
SCIP_Longint simplexiters
Definition relax_gcg.c:184
int aggregationnconsslimit
Definition relax_gcg.c:170
SCIP_Bool masterissetpart
Definition relax_gcg.c:162
SCIP_Bool usesymmetrylib
Definition relax_gcg.c:167
int * varlinkconsblock
Definition relax_gcg.c:135
SCIP ** pricingprobs
Definition relax_gcg.c:116
SCIP_Bool dispinfos
Definition relax_gcg.c:164
SCIP_Bool masterinprobing
Definition relax_gcg.c:174
SCIP_Longint stashedstallnodelimit
Definition relax_gcg.c:193
SCIP_CONS ** masterconss
Definition relax_gcg.c:129
int aggregationnvarslimit
Definition relax_gcg.c:171
int maxactivebranchextendedmasterconss
Definition relax_gcg.c:156
SCIP_CONS ** linearmasterconss
Definition relax_gcg.c:132
SCIP_CONS ** varlinkconss
Definition relax_gcg.c:134
SCIP_Real pricingprobsmemused
Definition relax_gcg.c:126
GCG_BRANCHDATA ** activebranchdata
Definition relax_gcg.c:153
SCIP_Bool aggregation
Definition relax_gcg.c:161
int maxmarkedmasterconss
Definition relax_gcg.c:146
SCIP_Real stashedgaplimit
Definition relax_gcg.c:194
GCG_BRANCHRULE ** activebranchrules
Definition relax_gcg.c:152
SCIP_CLOCK * rootnodetime
Definition relax_gcg.c:185
SCIP_Bool origsolfeasible
Definition relax_gcg.c:140
SCIP_Real stashedtimelimit
Definition relax_gcg.c:196
SCIP_SOL * lastmastersol
Definition relax_gcg.c:143
SCIP_Longint lastmasternode
Definition relax_gcg.c:142
GCG_DECOMP * decomp
Definition relax_gcg.c:180
SCIP_Bool limitsettingsstashed
Definition relax_gcg.c:191
int nactivebranchextendedmasterconss
Definition relax_gcg.c:155
SCIP_Bool storedfeasibility
Definition relax_gcg.c:177
SCIP_Bool masterissetcover
Definition relax_gcg.c:163
int nmarkedmasterconss
Definition relax_gcg.c:145
data structures for branching rules
gcg data structure
data structures for storing OpenMP locks
data structures for separators for master
struct SCIP_Benders SCIP_BENDERS
struct SCIP_Branchrule SCIP_BRANCHRULE
struct SCIP_BranchruleData SCIP_BRANCHRULEDATA
#define GCG_DECL_BRANCHDATADELETE(x)
struct GCG_BranchData GCG_BRANCHDATA
#define GCG_DECL_BRANCHGETEXTENDEDMASTERCONSCOEFF(x)
#define GCG_DECL_BRANCHDEACTIVEMASTER(x)
struct GCG_Branchrule GCG_BRANCHRULE
#define GCG_DECL_BRANCHGETEXTENDEDMASTERCONS(x)
#define GCG_DECL_BRANCHPROPMASTER(x)
#define GCG_DECL_BRANCHACTIVEMASTER(x)
#define GCG_DECL_BRANCHMASTERSOLVED(x)
#define GCG_DECL_BRANCHNEWCOL(x)
struct SCIP_Clock SCIP_CLOCK
struct SCIP_Cons SCIP_CONS
@ GCG_DECMODE_BENDERS
Definition type_decomp.h:63
@ GCG_DECMODE_DANTZIGWOLFE
Definition type_decomp.h:62
@ GCG_DECMODE_ORIGINAL
Definition type_decomp.h:64
enum Dectype GCG_DECTYPE
Definition type_decomp.h:57
struct GCG_Decomp GCG_DECOMP
Definition type_decomp.h:45
@ GCG_DECTYPE_DIAGONAL
Definition type_decomp.h:53
enum Decmode GCG_DECMODE
Definition type_decomp.h:69
struct GCG_ExtendedMasterConsData GCG_EXTENDEDMASTERCONSDATA
struct Gcg GCG
Definition type_gcg.h:44
struct SCIP_Heur SCIP_HEUR
type definitions for locks data structure
#define GCG_INIT_LOCK(lockptr)
Definition type_locks.h:72
#define GCG_DESTROY_LOCK(lockptr)
Definition type_locks.h:74
void GCG_LOCKS
Definition type_locks.h:66
enum SCIP_LPSolStat SCIP_LPSOLSTAT
SCIP_LPSOLSTAT_OPTIMAL
SCIP_LPSOLSTAT_INFEASIBLE
SCIP_LPSOLSTAT_OBJLIMIT
SCIP_VERBLEVEL_DIALOG
SCIP_VERBLEVEL_NONE
SCIP_VERBLEVEL_MINIMAL
SCIP_VERBLEVEL_HIGH
SCIP_VERBLEVEL_NORMAL
struct SCIP_HashMap SCIP_HASHMAP
struct SCIP_RandNumGen SCIP_RANDNUMGEN
struct GCG_ParamData GCG_PARAMDATA
SCIP_PARAMSETTING_OFF
enum GCG_PricingStatus GCG_PRICINGSTATUS
@ GCG_PRICINGSTATUS_OPTIMAL
@ GCG_PRICINGSTATUS_INFEASIBLE
SCIP_OBJSENSE_MAXIMIZE
struct SCIP_Relax SCIP_RELAX
struct SCIP_RelaxData SCIP_RELAXDATA
SCIP_DIDNOTRUN
SCIP_CUTOFF
SCIP_DIDNOTFIND
SCIP_SUCCESS
enum SCIP_Result SCIP_RESULT
SCIP_INVALIDCALL
SCIP_ERROR
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
struct SCIP_SepaData SCIP_SEPADATA
#define SCIP_DECL_SEPAEXECSOL(x)
#define SCIP_DECL_SEPAEXECLP(x)
struct SCIP_Sepa SCIP_SEPA
struct GCG_Sepa GCG_SEPA
#define GCG_DECL_SEPAGETCOLCOEFFICIENT(x)
#define GCG_DECL_SEPAMASTERCUTDELETE(x)
SCIP_STAGE_PROBLEM
SCIP_STAGE_INITPRESOLVE
SCIP_STAGE_SOLVED
SCIP_STAGE_PRESOLVING
SCIP_STAGE_TRANSFORMED
SCIP_STAGE_INITSOLVE
SCIP_STAGE_EXITPRESOLVE
SCIP_STAGE_EXITSOLVE
SCIP_STAGE_INIT
SCIP_STAGE_FREE
SCIP_STAGE_FREETRANS
SCIP_STAGE_SOLVING
SCIP_STAGE_TRANSFORMING
SCIP_STAGE_PRESOLVED
struct SCIP_Sol SCIP_SOL
SCIP_STATUS_OPTIMAL
SCIP_STATUS_BESTSOLLIMIT
SCIP_STATUS_SOLLIMIT
SCIP_STATUS_UNBOUNDED
SCIP_STATUS_UNKNOWN
SCIP_STATUS_GAPLIMIT
SCIP_STATUS_INFORUNBD
SCIP_STATUS_STALLNODELIMIT
SCIP_STATUS_TIMELIMIT
SCIP_STATUS_INFEASIBLE
SCIP_STATUS_NODELIMIT
SCIP_STATUS_MEMLIMIT
enum SCIP_Status SCIP_STATUS
struct SCIP_Node SCIP_NODE
struct SCIP_Var SCIP_VAR
SCIP_VARTYPE_INTEGER
SCIP_VARSTATUS_COLUMN
SCIP_VARSTATUS_LOOSE