GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
heur_xprins.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 heur_xprins.c
30 * @brief Extreme Point RINS
31 * @author Christian Puchert
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
36#include <assert.h>
37#include <string.h>
38#include <stdio.h>
39
40#include "gcg/heur_xprins.h"
41#include "gcg/gcg.h"
42
43#include "scip/scip.h"
44#include "scip/misc.h"
45#include "scip/scipdefplugins.h"
46
47
48#define HEUR_NAME "xprins"
49#define HEUR_DESC "Extreme Point RINS"
50#define HEUR_DISPCHAR 'Y'
51#define HEUR_PRIORITY -1100600
52#define HEUR_FREQ 0
53#define HEUR_FREQOFS 0
54#define HEUR_MAXDEPTH -1
55#define HEUR_TIMING SCIP_HEURTIMING_AFTERNODE
56#define HEUR_USESSUBSCIP TRUE
57
58#define DEFAULT_EQUALITYRATE 0.5 /**< minimum percentage of coincidence of relaxation and extreme pts */
59#define DEFAULT_MAXNODES 1000LL /**< maximum number of nodes to regard in the subproblem */
60#define DEFAULT_MINIMPROVE 0.01 /**< factor by which xprins should at least improve the incumbent */
61#define DEFAULT_MINNODES 200LL /**< minimum number of nodes to regard in the subproblem */
62#define DEFAULT_MINFIXINGRATE 0.4 /**< minimum percentage of integer variables that have to be fixed */
63#define DEFAULT_NODESOFS 200LL /**< number of nodes added to the contingent of the total nodes */
64#define DEFAULT_NODESQUOT 0.1 /**< subproblem nodes in relation to nodes of the original problem */
65#define DEFAULT_NUSEDPTS -1 /**< number of extreme pts per block that will be taken into account
66 * (-1: all; 0: all which contribute to current relaxation solution)
67 */
68#define DEFAULT_RANDOMIZATION FALSE /**< should the choice which sols to take be randomized? */
69#define DEFAULT_COPYCUTS TRUE /**< if DEFAULT_USELPROWS is FALSE, then should all active cuts from the cutpool
70 * of the original scip be copied to constraints of the subscip
71 */
72#define DEFAULT_RANDSEED 7 /**< initial random seed */
73
74
75
76/*
77 * Data structures
78 */
79
80/** primal heuristic data */
81struct SCIP_HeurData
82{
83 GCG* gcg; /**< GCG data structure */
84 SCIP_Real equalityrate; /**< minimum percentage of coincidence of relaxation and extreme pts */
85 SCIP_Longint maxnodes; /**< maximum number of nodes to regard in the subproblem */
86 SCIP_Longint minnodes; /**< minimum number of nodes to regard in the subproblem */
87 SCIP_Longint nodesofs; /**< number of nodes added to the contingent of the total nodes */
88 SCIP_Longint usednodes; /**< nodes already used by xprins in earlier calls */
89 SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
90 int nusedpts; /**< number of extreme pts per block that will be taken into account
91 * (-1: all; 0: all which contribute to current relaxation solution)
92 */
93 unsigned int nfailures; /**< number of failures since last successful call */
94 SCIP_Longint nextnodenumber; /**< number of BnB nodes at which crossover should be called next */
95 SCIP_Real minfixingrate; /**< minimum percentage of integer variables that have to be fixed */
96 SCIP_Real minimprove; /**< factor by which xprins should at least improve the incumbent */
97 SCIP_Bool randomization; /**< should the choice which sols to take be randomized? */
98 SCIP_Bool copycuts; /**< if uselprows == FALSE, should all active cuts from cutpool be copied
99 * to constraints in subproblem?
100 */
101 SCIP_RANDNUMGEN* randnumgen; /**< random number generator */
102
103#ifdef SCIP_STATISTIC
104 SCIP_Longint nfixfails; /**< number of abortions due to a bad fixing rate */
105 SCIP_Real avgfixrate; /**< average rate of variables that are fixed */
106 SCIP_Real avgzerorate; /**< average rate of fixed variables that are zero */
107 SCIP_Longint totalsols; /**< total number of subSCIP solutions (including those which have not
108 * been added)
109 */
110 SCIP_Real subsciptime; /**< total subSCIP solving time in seconds */
111 SCIP_Real bestprimalbd; /**< objective value of best solution found by this heuristic */
112#endif
113};
114
115
116
117
118/*
119 * Local methods
120 */
121
122
123/** for each block, select extreme points (represented by mastervars) to be compared to the relaxation solution */
124static
126 GCG* gcg, /**< GCG data structure */
127 SCIP_HEURDATA* heurdata, /**< primal heuristic data */
128 int* selection, /**< indices of selected extreme points */
129 int* nactualpts, /**< number of points per block that have actually been selected */
130 SCIP_Bool* success /**< pointer to store whether the process was successful */
131 )
132{
133 SCIP* scip;
135 int nblocks;
136
138 SCIP_Real* mastervals;
139 int nmastervars;
140
141 int nusedpts;
142 int block;
143#ifndef NDEBUG
144 int nidentblocks;
145#endif
146 int* blocknrs;
147 int* identblock;
148 SCIP_Real* blockvalue;
149 SCIP_Real value;
150 SCIP_Real* selvalue;
151
152 int i;
153 int j;
154
155 /* check preconditions */
156 assert(gcg != NULL);
157 assert(heurdata != NULL);
158 assert(selection != NULL);
159 assert(success != NULL);
160
161 assert(heurdata->nusedpts >= 0);
162
164
165 /* get master problem */
168
169 /* get number of blocks */
170 nblocks = GCGgetNPricingprobs(gcg);
171
172 /* get variables of the master problem */
175 assert(nmastervars >= 0);
176
177 /* get master LP solution values */
180
181 /* get number of extreme points per block */
182 nusedpts = heurdata->nusedpts;
183
184 /* allocate memory */
185 SCIP_CALL( SCIPallocBufferArray(scip, &selvalue, nblocks * nusedpts) );
186 SCIP_CALL( SCIPallocBufferArray(scip, &blocknrs, nblocks) );
187 SCIP_CALL( SCIPallocBufferArray(scip, &blockvalue, nblocks) );
188 SCIP_CALL( SCIPallocBufferArray(scip, &identblock, nblocks) );
189
190 /* initialize the block values for the pricing problems */
191 for( i = 0; i < nblocks; i++ )
192 {
193 blockvalue[i] = 0.0;
194 blocknrs[i] = 0;
195 identblock[i] = i;
196 nactualpts[i] = 0;
197 }
198
199 *success = FALSE;
200
201 /* loop over all given master variables;
202 * this loop treats master variables that have value one or greater
203 * (in particular important if blocks are represented by others)
204 */
205 for( i = 0; i < nmastervars; i++ )
206 {
207 SCIP_VAR* mastervar;
208
209 mastervar = mastervars[i];
210 assert(GCGvarIsMaster(mastervar));
211
212 /* get block information and solution value */
213 block = GCGvarGetBlock(mastervar);
214 value = SCIPgetSolVal(masterprob, NULL, mastervar);
215
216 /** @todo handle infinite master solution values */
217 assert(!SCIPisInfinity(scip, value));
218
219 /* ignore irrelevant extreme points */
220 if( SCIPisFeasZero(scip, value) )
221 continue;
222
223 /* ignore rays
224 * @todo do it smarter */
225 if( GCGmasterVarIsRay(mastervar) )
226 continue;
227
228 /* variables belonging to no block are not treated here */
229 if( block == -1 )
230 continue;
231
232 /* get number of blocks that are identical to this block */
233 assert(block >= 0);
234#ifndef NDEBUG
235 nidentblocks = GCGgetNIdenticalBlocks(gcg, block);
236#endif
237
238 while( SCIPisFeasGE(scip, mastervals[i], 1.0) )
239 {
240 /* insert the extreme point in the selection (should be the only point for this block) */
241 j = identblock[block] * nusedpts;
242 assert(selection[j] == -1);
243 assert(nactualpts[identblock[block]] == 0);
244
245 nactualpts[identblock[block]] = 1;
246 selection[j] = i;
247 selvalue[j] = 1.0;
248
249 mastervals[i] = mastervals[i] - 1.0;
250 blocknrs[block]++;
251
252 /* search the next block to be considered */
253 for( j = identblock[block] + 1; j < nblocks; ++j )
254 if( GCGgetBlockRepresentative(gcg, j) == block )
255 {
256 identblock[block] = j;
257 break;
258 }
259
260#ifndef NDEBUG
261 assert(blocknrs[block] >= nidentblocks || j < nblocks);
262#endif
263 }
264 }
265
266 /* loop over all given master variables */
267 for( i = 0; i < nmastervars; i++ )
268 {
269 SCIP_VAR* mastervar;
270
271 mastervar = mastervars[i];
272 assert(GCGvarIsMaster(mastervar));
273
274 /* get block information and solution value */
275 block = GCGvarGetBlock(mastervar);
276 value = SCIPgetSolVal(masterprob, NULL, mastervar);
277
278 /** @todo handle infinite master solution values */
279 assert(!SCIPisInfinity(scip, value));
280
281 /* ignore irrelevant extreme points */
282 if( SCIPisFeasZero(scip, value) )
283 continue;
284
285 /* ignore rays */
286 if( GCGmasterVarIsRay(mastervar) )
287 continue;
288
289 /* variables belonging to no block are not treated here */
290 if( block == -1 )
291 continue;
292
293 /* get number of blocks that are identical to this block */
294 assert(block >= 0);
295#ifndef NDEBUG
296 nidentblocks = GCGgetNIdenticalBlocks(gcg, block);
297#endif
298
299 assert(SCIPisFeasGE(scip, mastervals[i], 0.0) && SCIPisFeasLT(scip, mastervals[i], 1.0));
300
301 while( SCIPisFeasPositive(scip, mastervals[i]) )
302 {
303 value = MIN(mastervals[i], 1.0 - blockvalue[block]);
304
305 /* check if the extreme point is good enough to be inserted in the selection
306 * by looking for a position where it may be inserted
307 */
308 for( j = (identblock[block] * nusedpts) + nactualpts[identblock[block]];
309 j > identblock[block] * nusedpts && SCIPisGT(scip, value, selvalue[j]); --j )
310 {
311 if( j < (identblock[block] + 1) * nusedpts )
312 {
313 selection[j] = selection[j-1];
314 selvalue[j] = selvalue[j-1];
315 }
316 }
317 if( j < (identblock[block] * nusedpts) + nusedpts )
318 {
319 selection[j] = i;
320 selvalue[j] = value;
321
322 if( nactualpts[identblock[block]] < nusedpts )
323 ++nactualpts[identblock[block]];
324 }
325
326 mastervals[i] = mastervals[i] - value;
327 if( SCIPisFeasZero(scip, mastervals[i]) )
328 mastervals[i] = 0.0;
329 blockvalue[block] += value;
330
331 /* if the value assigned to the block is equal to 1, this block is full and we consider the next block */
332 if( SCIPisFeasGE(scip, blockvalue[block], 1.0) )
333 {
334 blockvalue[block] = 0.0;
335 blocknrs[block]++;
336
337 /* search the next identical block to be considered */
338 for( j = identblock[block] + 1; j < nblocks; ++j )
339 if( GCGgetBlockRepresentative(gcg, j) == block )
340 {
341 identblock[block] = j;
342 break;
343 }
344
345#ifndef NDEBUG
346 assert(blocknrs[block] >= nidentblocks || j < nblocks);
347#endif
348 }
349 }
350 }
351
352 *success = TRUE;
353
354 /* free memory */
355 SCIPfreeBufferArray(scip, &identblock);
356 SCIPfreeBufferArray(scip, &blockvalue);
357 SCIPfreeBufferArray(scip, &blocknrs);
358 SCIPfreeBufferArray(scip, &selvalue);
359 SCIPfreeBufferArray(scip, &mastervals);
360
361 return SCIP_OKAY;
362}
363
364
365/** select extreme points (represented by mastervars) randomly */
366static
368 GCG* gcg, /**< GCG data structure */
369 SCIP_HEURDATA* heurdata, /**< primal heuristic data */
370 int* selection, /**< indices of selected extreme points */
371 int* nactualpts, /**< number of points per block that have actually been selected */
372 SCIP_Bool* success /**< pointer to store whether the process was successful */
373 )
374{
375 SCIP* origprob;
377 int nblocks;
378
380 int nmastervars;
381
382 int nusedpts; /* number of extreme points per block to be chosen */
383 int* npts; /* for each block, the number of available extreme points */
384 int* blockpts; /* all points of a block which to be considered */
385 SCIP_Real* ptvals; /* solution values of extreme points in master problem */
386
387 int i;
388 int j;
389
391
392 /* check preconditions */
393 assert(origprob != NULL);
394 assert(heurdata != NULL);
395 assert(selection != NULL);
396 assert(success != NULL);
397
398 /* get master problem */
401
402 /* get number of blocks */
403 nblocks = GCGgetNPricingprobs(gcg);
404
405 /* get variables of the master problem */
408 assert(nmastervars >= 0);
409
410 /* get number of extreme points per block */
411 nusedpts = heurdata->nusedpts;
412
413 /* allocate memory */
414 SCIP_CALL( SCIPallocBufferArray(origprob, &npts, nblocks) );
415
416 *success = TRUE;
417
418 /* check whether we have enough points per block to perform a randomization */
419 for( i = 0; i < nblocks; ++i )
420 npts[i] = 0;
421 for( i = 0; i < nmastervars; ++i )
422 {
423 SCIP_VAR* mastervar;
425 int block;
426
427 mastervar = mastervars[i];
428 solval = SCIPgetSolVal(masterprob, NULL, mastervar);
429 block = GCGvarGetBlock(mastervar);
430
431 if( block >= 0 && !SCIPisFeasZero(origprob, solval) )
432 ++npts[block];
433 }
434 for( i = 0; i < nblocks; ++i )
435 if( GCGisPricingprobRelevant(gcg, i) && npts[i] <= nusedpts )
436 *success = FALSE;
437
438 /* do not randomize if there are not enough points available */
439 if( !*success )
440 {
441 SCIPdebugMessage(" -> not enough extreme points available for randomization.\n");
442
443 /* free memory */
445
446 return SCIP_OKAY;
447 }
448
449 *success = FALSE;
450
451 /* perform randomization: for each block, select a set of extreme points to be considered */
452 for( i = 0; i < nblocks; ++i )
453 {
454 int blockrep;
455 int lastpt; /* the worst extreme point possible to choose */
456
457 int k;
458
459
460 SCIP_CALL( SCIPallocBufferArray(origprob, &blockpts, npts[i]) );
461 SCIP_CALL( SCIPallocBufferArray(origprob, &ptvals, npts[i]) );
462
463 /* get representative of this block */
464 blockrep = GCGgetBlockRepresentative(gcg, i);
465 assert(blockrep >= 0 && blockrep <= i);
466
467 /* get all relevant extreme points for this block */
468 k = 0;
469 for( j = 0; j < nmastervars; ++j )
470 {
471 SCIP_VAR* mastervar;
473 int block;
474
475 mastervar = mastervars[j];
476 solval = SCIPgetSolVal(masterprob, NULL, mastervar);
477 block = GCGvarGetBlock(mastervar);
478
479 if( block == blockrep && !SCIPisFeasZero(origprob, solval) )
480 {
481 assert(k < npts[blockrep]);
482 blockpts[k] = j;
483 ++k;
484 }
485 }
486 assert(k == npts[blockrep]);
487
488 /* sort the extreme points */
489 SCIPsortRealInt(ptvals, blockpts, npts[blockrep]);
490 lastpt = npts[blockrep];
491
492 /* perform a random selection for this block */
493 for( k = 0; k < nusedpts; ++k )
494 {
495 int idx;
496 int selidx;
497
498 idx = SCIPrandomGetInt(heurdata->randnumgen, nusedpts-k-1, lastpt-1);
499 selidx = i * nusedpts + k;
500 selection[selidx] = blockpts[idx];
501 lastpt = idx;
502 }
503
504 nactualpts[i] = nusedpts;
505
507 SCIPfreeBufferArray(origprob, &blockpts);
508 }
509
510 *success = TRUE;
511
512 /* free memory */
514
515 return SCIP_OKAY;
516}
517
518/*
519 * count extreme points per block to be considered;
520 * this is only done when no selection of extreme points has been made!
521 */
522static
524 GCG* gcg, /**< GCG data structure */
525 int* selection, /**< selected extreme points the heuristic will use, or NULL */
526 int nusedpts, /**< number of extreme points per block to be considered, or 0, or -1 */
527 int* nactualpts /**< number of points per block that have actually been selected */
528 )
529{
530 SCIP* origprob;
531 SCIP* masterprob; /* master problem */
532 SCIP_VAR** mastervars; /* master variables */
533 int nmastervars; /* number of master variables */
534 int nblocks;
535
536 int i;
537
538 assert(nusedpts == 0 || nusedpts == -1);
539 assert(selection == NULL);
540
542
543 /* get master problem and its variables */
548 assert(nmastervars >= 0);
549
550 nblocks = GCGgetNPricingprobs(gcg);
551
552 for( i = 0; i < nblocks; ++i )
553 nactualpts[i] = 0;
554 for( i = 0; i < nmastervars; ++i )
555 {
556 SCIP_VAR* mastervar;
557 int block;
558
559 mastervar = mastervars[i];
560 assert(mastervar != NULL);
561 block = GCGvarGetBlock(mastervar);
562 if( block >= 0 && (nusedpts == -1 || !SCIPisZero(origprob, SCIPgetSolVal(masterprob, NULL, mastervar))) )
563 ++nactualpts[block];
564 }
565 /* We have only counted for the relevant blocks so far,
566 * so it is still necessary to set the numbers of extreme points for the other blocks
567 */
568 for( i = 0; i < nblocks; ++i )
569 {
570 int blockrep = GCGgetBlockRepresentative(gcg, i);
571 assert(blockrep >= 0 && blockrep <= i);
572
573 nactualpts[i] = nactualpts[blockrep];
574 }
575
576 return SCIP_OKAY;
577}
578
579
580
581/** initialize the subSCIP instance: copy SCIP to subSCIP, set the parameters */
582static
584 SCIP* scip, /**< original SCIP data structure */
585 SCIP* subscip, /**< SCIP data structure for the subproblem */
586 SCIP_VAR** subvars, /**< the variables of the subproblem */
587 SCIP_HEURDATA* heurdata, /**< primal heuristic data */
588 SCIP_Longint nstallnodes, /**< node limit for subproblem */
589 SCIP_Real timelimit, /**< time limit for subproblem */
590 SCIP_Real memorylimit /**< memory limit for subproblem */
591 )
592{
593 SCIP_VAR** vars;
594 int nvars;
595
596 int i;
597
598 char probname[SCIP_MAXSTRLEN];
599 SCIP_HASHMAP* varmapfw; /* mapping of SCIP variables to subSCIP variables */
600 SCIP_Bool valid;
601
604
605 /* copy the SCIP instance to the subSCIP */
606
607 /* copy all plugins */
609
610 /* get name of the original problem and add the string "_extremeptsub" */
611 (void) SCIPsnprintf(probname, SCIP_MAXSTRLEN, "%s_extremeptsub", SCIPgetProbName(scip));
612
613 /* create the subproblem */
614 SCIP_CALL( SCIPcreateProb(subscip, probname, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
615
616 /* copy all variables */
617 SCIP_CALL( SCIPcopyVars(scip, subscip, varmapfw, NULL, NULL, NULL, 0, TRUE) );
618
619 /* copy all constraints */
620 valid = FALSE;
621 SCIP_CALL( SCIPcopyConss(scip, subscip, varmapfw, NULL, TRUE, FALSE, &valid) );
622 if( heurdata->copycuts )
623 {
624 /* copies all active cuts from cutpool of sourcescip to linear constraints in targetscip */
626 }
627 SCIPdebugMessage("Copying the SCIP constraints was %s complete.\n", valid ? "" : "not ");
628
629 /* get the subproblem variables */
630 for( i = 0; i < nvars; i++ )
631 subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
632
633 /* free hash map */
635
636 /* setup parameters of subSCIP */
637 /* do not abort subproblem on CTRL-C */
638 SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
639
640#ifdef SCIP_DEBUG
641 /* for debugging RENS, enable MIP output */
642 SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
643 SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
644#else
645 /* disable output to console */
646 SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
647#endif
648
649 /* set limits for the subproblem */
650 SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nstallnodes) );
651 SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", MAX(10, nstallnodes/10)) );
652 SCIP_CALL( SCIPsetRealParam(subscip, "limits/time", timelimit) );
653 SCIP_CALL( SCIPsetRealParam(subscip, "limits/memory", memorylimit) );
654
655 /* forbid recursive call of heuristics and separators solving subMIPs */
656 SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
657
658 /* disable cutting plane separation */
660
661 /* disable expensive presolving */
663
664 /* use best estimate node selection */
665 if( SCIPfindNodesel(subscip, "estimate") != NULL && !SCIPisParamFixed(subscip, "nodeselection/estimate/stdpriority") )
666 {
667 SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/estimate/stdpriority", INT_MAX/4) );
668 }
669
670 /* use inference branching */
671 if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
672 {
673 SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
674 }
675
676 /* disable conflict analysis */
677 if( !SCIPisParamFixed(subscip, "conflict/enable") )
678 {
679 SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/enable", FALSE) );
680 }
681
682 /* if there is already a solution, add an objective cutoff */
683 if( SCIPgetNSols(scip) > 0 )
684 {
685 SCIP_Real cutoff; /* objective cutoff for the subproblem */
686 SCIP_Real upperbound;
687
689
690 upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
692 {
694 }
695 else
696 {
697 if( SCIPgetUpperbound ( scip ) >= 0 )
699 else
701 }
702 cutoff = MIN(upperbound, cutoff );
703 SCIP_CALL( SCIPsetObjlimit(subscip, cutoff) );
704 }
705
706 return SCIP_OKAY;
707}
708
709
710/**
711 * compare an extreme point (represented by a master variable) to the relaxation solution
712 */
713static
715 GCG* gcg, /**< GCG data structure */
716 SCIP_VAR* mastervar, /**< master variable representing the extreme point */
717 int solblock, /**< block in which the relaxation solution should be compared, or -1 if all blocks of the extreme point should be considered */
718 int* neqpts, /**< for each original variable, count how many extreme points share its relaxation solution value */
719 SCIP_Bool* zeroblocks /**< for each block, the information whether it would be fixed entirely to zero */
720 )
721{
722 int block; /* representative block the master variable belongs to */
723 int nblocks;
724 SCIP_VAR** origvars; /* original variables of the extreme point */
725 SCIP_Real* origvals; /* values of the original variables in the extreme point */
726 int norigvars; /* number of original variables of the extreme point */
727 SCIP* scip;
728
729 int i;
730 int j;
731 int k;
732
734 assert(GCGvarIsMaster(mastervar));
735
736 block = GCGvarGetBlock(mastervar);
737 assert(block >= 0);
738
739 nblocks = GCGgetNPricingprobs(gcg);
740
741 /* get the actual extreme point */
742 origvars = GCGmasterVarGetOrigvars(mastervar);
743 origvals = GCGmasterVarGetOrigvals(mastervar);
744 norigvars = GCGmasterVarGetNOrigvars(mastervar);
745
746 /* compare each extreme point value to the corresponding relaxation solution value */
747 for( i = 0; i < norigvars; ++i )
748 {
749 SCIP_VAR* pricingvar;
750 SCIP_VAR** pricingorigvars;
751 int npricingorigvars;
752
753 if( SCIPvarGetType(origvars[i]) > SCIP_VARTYPE_INTEGER )
754 continue;
755
756 /* get the corresponding pricing variable;
757 * needed to obtain original variables corresponding to the current one from other blocks
758 * (see below)
759 */
760 if( GCGoriginalVarIsLinking(origvars[i]) )
761 {
762 SCIP_VAR** linkingpricingvars = GCGlinkingVarGetPricingVars(origvars[i]);
763 pricingvar = linkingpricingvars[block];
764 }
765 else
766 pricingvar = GCGoriginalVarGetPricingVar(origvars[i]);
767
768 assert(pricingvar != NULL);
769 assert(GCGvarIsPricing(pricingvar));
770
771 /* get all original variables corresponding to the current one;
772 * this is necessary since in case of identical, aggregated blocks,
773 * the extreme point may belong to multiple blocks
774 */
775 pricingorigvars = GCGpricingVarGetOrigvars(pricingvar);
776 npricingorigvars = GCGpricingVarGetNOrigvars(pricingvar);
777 assert(pricingorigvars != NULL);
778 assert(npricingorigvars >= 0);
779
780 for( j = 0; j < npricingorigvars; ++j )
781 {
782 int origblock;
783 int idx;
785
786 origblock = GCGvarGetBlock(pricingorigvars[j]);
787 assert(origblock != -1);
788
789 if( solblock != -1 &&
790 ((origblock != -2 && origblock != solblock) || (origblock == -2 && !GCGisLinkingVarInBlock(pricingorigvars[j], solblock))) )
791 continue;
792
793 idx = SCIPvarGetProbindex(pricingorigvars[j]);
794 assert(SCIPvarGetType(pricingorigvars[j]) <= SCIP_VARTYPE_INTEGER);
795 solval = SCIPgetRelaxSolVal(scip, pricingorigvars[j]);
796
797 /* If a relaxation solution value is zero, we assumed that it is zero in all extreme points,
798 * so we need to decrease the counter if this is not the case
799 */
800 if( SCIPisZero(scip, solval) )
801 {
802 if( !SCIPisZero(scip, origvals[i]) )
803 --neqpts[idx];
804 }
805 else
806 {
807 if( SCIPisEQ(scip, solval, origvals[i]) )
808 ++neqpts[idx];
809
810 /* The block will not be entirely fixed to zero, since the variable has nonzero relaxation solution value */
811 if( origblock != -2 )
812 zeroblocks[origblock] = FALSE;
813 else
814 {
815 /* For a linking variable, get all blocks it appears in */
816 SCIP_VAR** linkingpricingvars = GCGlinkingVarGetPricingVars(pricingorigvars[j]);
817 for( k = 0; k < nblocks; ++k )
818 if( linkingpricingvars[k] != NULL )
819 zeroblocks[k] = FALSE;
820 }
821 }
822 }
823 }
824}
825
826/**
827 * compare all selected extreme points to the relaxation solution
828 */
829static
831 GCG* gcg, /**< GCG data structure */
832 int* selection, /**< selected extreme points the heuristic will use, or NULL */
833 int nusedpts, /**< number of extreme points per block to be considered, or 0, or -1 */
834 int* neqpts, /**< for each original variable, count how many extreme points share its relaxation solution value */
835 SCIP_Bool* zeroblocks /**< for each block, the information whether it would be fixed entirely to zero */
836 )
837{
838 SCIP* origprob;
839 SCIP* masterprob; /* master problem */
840 SCIP_VAR** mastervars; /* master variables */
841 int nmastervars; /* number of master variables */
842 int nblocks;
843
844 int i;
845 int j;
846
848
849 /* get master problem and its variables */
854 assert(nmastervars >= 0);
855
856 nblocks = GCGgetNPricingprobs(gcg);
857
858 if( nusedpts <= 0 )
859 {
860 assert(nusedpts == 0 || nusedpts == -1);
861
862 for( i = 0; i < nmastervars; ++i )
863 {
864 SCIP_VAR* mastervar;
865
866 /* get master variable */
867 mastervar = mastervars[i];
868
869 /* ignore master variables which are just copies from original variables and no extreme points */
870 if( GCGvarGetBlock(mastervar) == -1 )
871 continue;
872
873 /* ignore master variable if it is zero and only the nonzeroes should be considered */
874 if( nusedpts == 0 && SCIPisZero(origprob, SCIPgetSolVal(masterprob, NULL, mastervar)) )
875 continue;
876
877 compareOneExtremePoint(gcg, mastervar, -1, neqpts, zeroblocks);
878 }
879 }
880 else
881 {
882 assert(selection != NULL);
883
884 for( i = 0; i < nblocks; ++i )
885 {
886 /* compare the relaxation solution to the selected extreme points */
887 for( j = 0; j < nusedpts; ++j )
888 {
889 int selidx = i * nusedpts + j;
890 if( selection[selidx] != -1 )
891 {
892 SCIP_VAR* mastervar;
893
894 /* get master variable */
895 mastervar = mastervars[selection[selidx]];
896 assert(mastervar != NULL);
898
899 compareOneExtremePoint(gcg, mastervar, i, neqpts, zeroblocks);
900 }
901 }
902 }
903 }
904
905 return SCIP_OKAY;
906}
907
908/** fix variables; for each variable, we evaluate the percentage of extreme points in which it has the same value
909 * as in the relaxation solution and fix it if the percentage exceeds a certain value
910 */
911static
913 GCG* gcg, /**< GCG data structure */
914 SCIP* subscip, /**< SCIP data structure for the subproblem */
915 SCIP_VAR** subvars, /**< the variables of the subproblem */
916 int* selection, /**< selected extreme points the heuristic will use, or NULL */
917 int* nactualpts, /**< number of points per block that have actually been selected */
918 SCIP_HEURDATA* heurdata, /**< primal heuristic data */
919 SCIP_Real* intfixingrate, /**< percentage of integers that get actually fixed */
920 SCIP_Real* zerofixingrate, /**< percentage of variables fixed to zero */
921 SCIP_Bool* success /**< pointer to store whether the problem was created successfully */
922 )
923{
924 SCIP* scip;
925 SCIP_VAR** vars; /* original scip variables */
926
927 int nblocks; /* number of blocks */
928 int nbinvars; /* number of binary variables in the original problem */
929 int nintvars; /* number of general integer variables */
930
931 int* neqpts; /* for each original variable, count the number of
932 points where it has the same value as the relaxation solution */
933 SCIP_Bool* zeroblocks; /* blocks that would be entirely fixed to zero */
934 int fixingcounter; /* count how many original variables are fixed */
935 int zerocounter; /* count how many variables are fixed to zero */
936
937 int i;
938 int j;
939
941
942 /* check preconditions */
943 assert(scip != NULL);
944 assert(subscip != NULL);
945 assert(subvars != NULL);
946 assert(heurdata != NULL);
947 assert(selection != NULL || heurdata->nusedpts < 0);
948 assert(nactualpts != NULL);
949 assert(intfixingrate != NULL);
950 assert(zerofixingrate != NULL);
951 assert(success != NULL);
952
953 /* get required data of the original problem */
955
956 nblocks = GCGgetNPricingprobs(gcg);
957 fixingcounter = 0;
958 zerocounter = 0;
959
960 *success = FALSE;
961
962 /* allocate memory */
964 SCIP_CALL( SCIPallocBufferArray(scip, &zeroblocks, nblocks) );
965
966 for( i = 0; i < nblocks; ++i )
967 zeroblocks[i] = TRUE;
968
969 /* initialize counters for identical solution values
970 *
971 * @note: Zero values of extreme points are not stored explicitly in the master
972 * variable data; therefore, we assume for each variable with solution value zero
973 * that each extreme point also has value zero, and we will later on decrease the
974 * counter for each point where this is not the case
975 */
976 for( i = 0; i < nbinvars + nintvars; ++i )
977 {
978 SCIP_VAR* var;
979 int block;
981
982 /* get variable, block and relaxation value */
983 var = vars[i];
984 assert(var != NULL);
985 block = GCGvarGetBlock(var);
987
988 if( !SCIPisZero(scip, solval) || block == -1 )
989 neqpts[i] = 0;
990 else if( block == -2 )
991 {
992 SCIP_VAR** linkingpricingvars = GCGlinkingVarGetPricingVars(var);
993 neqpts[i] = 0;
994 for( j = 0; j < nblocks; ++j )
995 if( linkingpricingvars[j] != NULL )
996 neqpts[i] += nactualpts[j];
997 }
998 else
999 {
1000 assert(block >= 0);
1001 neqpts[i] = nactualpts[block];
1002 }
1003 }
1004
1005 SCIP_CALL( compareExtremePointsToRelaxSol(gcg, selection, heurdata->nusedpts, neqpts, zeroblocks) );
1006
1007 /* try to fix the binary and general integer variables */
1008 for( i = 0; i < nbinvars + nintvars; ++i )
1009 {
1010 SCIP_VAR* var;
1011 int block; /* current block we are working in */
1013
1014 var = vars[i];
1016 block = GCGvarGetBlock(var);
1018
1019 /* Variables which were directly copied from the original problem do not appear in any extreme point;
1020 * they are fixed like in the RENS heuristic
1021 */
1022 if( block == -1 )
1023 {
1025 {
1026 /* fix variable to current relaxation solution if it is integral;
1027 * use exact integral value, if the variable is only integral within numerical tolerances
1028 */
1029 solval = SCIPfloor(scip, solval + 0.5);
1030 SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[i], solval) );
1031 SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[i], solval) );
1032
1033 fixingcounter++;
1034 if( SCIPisZero(scip, solval) )
1035 zerocounter++;
1036 }
1037 }
1038 /* For variables belonging to one or more blocks, we evaluate in how many percent of the
1039 * extreme points they have the same value as in the relaxation solution
1040 */
1041 else
1042 {
1043 int ntotalpts;
1044 SCIP_Real quoteqpts;
1045
1046 assert(block == -2 || block >= 0);
1047
1048 /* Calculate in how many extreme points the variable appears;
1049 * in case of linking variables, we need to consider points from all their blocks
1050 */
1051 if( block >= 0 )
1052 ntotalpts = nactualpts[block];
1053 else
1054 {
1055 SCIP_VAR** linkingpricingvars;
1056
1058 linkingpricingvars = GCGlinkingVarGetPricingVars(var);
1059
1060 ntotalpts = 0;
1061 for( j = 0; j < nblocks; ++j )
1062 if( linkingpricingvars[j] != NULL )
1063 ntotalpts += nactualpts[j];
1064 }
1065
1066 assert(neqpts[i] <= ntotalpts);
1067 quoteqpts = (SCIP_Real) neqpts[i] / (SCIP_Real) MAX(ntotalpts,1);
1068
1069 SCIPdebugMessage("Variable %s: %d/%d (%.2f percent) extreme points identical to relaxation solution (value=%g).\n",
1070 SCIPvarGetName(var), neqpts[i], ntotalpts, quoteqpts * 100, solval);
1071
1072 /* The variable can be fixed if the relaxation value is shared by enough extreme points;
1073 * besides, we avoid fixing entire blocks to zero
1074 */
1075 if( quoteqpts >= heurdata->equalityrate && (block < 0 || !zeroblocks[block]) )
1076 {
1077 SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[i], solval) );
1078 SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[i], solval) );
1079
1080 fixingcounter++;
1081 if( SCIPisZero(scip, solval) )
1082 zerocounter++;
1083 }
1084 }
1085 }
1086
1087 *intfixingrate = (SCIP_Real) fixingcounter / (SCIP_Real) (MAX(nbinvars + nintvars, 1));
1088 *zerofixingrate = (SCIP_Real)zerocounter / MAX((SCIP_Real)fixingcounter, 1.0);
1089
1090 /* If not enough variables were fixed, try to fix blocks which relaxation solution value zero,
1091 * until the minimum fixing rate is reached
1092 */
1093 while( *intfixingrate < heurdata->minfixingrate )
1094 {
1095 SCIPdebugMessage(" fixing rate only %5.2f --> trying to fix a zero block\n", *intfixingrate);
1096
1097 /* get the next zero block */
1098 for( i = 0; i < nblocks; ++i )
1099 if( zeroblocks[i] )
1100 {
1101 /* fix variables */
1102 for( j = 0; j < nbinvars + nintvars; ++j )
1103 if( GCGvarGetBlock(vars[j]) == i )
1104 {
1105 SCIP_Real quoteqpts;
1106
1107 /* evaluate percentage of extreme points having the same variable value as the relaxation solution */
1109 assert(neqpts[j] <= nactualpts[i]);
1110 quoteqpts = (SCIP_Real) neqpts[j] / (SCIP_Real) MAX(nactualpts[i],1);
1111
1112 if( quoteqpts >= heurdata->equalityrate )
1113 {
1114 SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[j], 0.0) );
1115 SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[j], 0.0) );
1116
1117 fixingcounter++;
1118 zerocounter++;
1119 }
1120 }
1121
1122 zeroblocks[i] = FALSE;
1123 break;
1124 }
1125
1126 *intfixingrate = (SCIP_Real)fixingcounter / (SCIP_Real)(MAX(nbinvars + nintvars, 1));
1127 *zerofixingrate = (SCIP_Real)zerocounter / MAX((SCIP_Real)fixingcounter, 1.0);
1128
1129 if( i == nblocks )
1130 break;
1131 }
1132
1133 /* if all variables were fixed or amount of fixed variables is insufficient, abort immediately */
1134 if( *intfixingrate < heurdata->minfixingrate )
1135 {
1136 SCIPstatisticPrintf("xprins statistic: fixed only %5.2f ( %5.2f zero) integer variables --> abort \n", *intfixingrate, *zerofixingrate);
1137 }
1138 if( fixingcounter == nbinvars + nintvars )
1139 {
1140 SCIPstatisticPrintf("xprins statistic: fixed all ( %5.2f zero) integer variables --> abort \n", *zerofixingrate);
1141 }
1142
1143 *success = TRUE;
1144
1145 /* free memory */
1146 SCIPfreeBufferArray(scip, &zeroblocks);
1147 SCIPfreeBufferArray(scip, &neqpts);
1148
1149 return SCIP_OKAY;
1150}
1151
1152
1153/** creates a new solution for the original problem by copying the solution of the subproblem */
1154static
1156 SCIP* scip, /**< original SCIP data structure */
1157 SCIP* subscip, /**< SCIP structure of the subproblem */
1158 SCIP_VAR** subvars, /**< the variables of the subproblem */
1159 SCIP_HEUR* heur, /**< primal heuristic structure */
1160 SCIP_SOL* subsol, /**< solution of the subproblem */
1161 SCIP_Bool* success /**< used to store whether new solution was found or not */
1162 )
1163{
1164#ifdef SCIP_STATISTIC
1166#endif
1167 SCIP_VAR** vars; /* the original problem's variables */
1168 int nvars;
1169 SCIP_SOL* newsol; /* solution to be created for the original problem */
1170 SCIP_Real* subsolvals; /* solution values of the subproblem */
1171
1172 assert(scip != NULL);
1173 assert(subscip != NULL);
1174 assert(subvars != NULL);
1175 assert(subsol != NULL);
1176
1177#ifdef SCIP_STATISTIC
1178 /* get heuristic data */
1179 heurdata = SCIPheurGetData(heur);
1180 assert( heurdata != NULL );
1181#endif
1182
1183 /* get variables' data */
1185 assert(nvars <= SCIPgetNOrigVars(subscip));
1186
1187 SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
1188
1189 /* copy the solution */
1190 SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
1191
1192 /* create new solution for the original problem */
1193 SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
1194 SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
1195
1196 SCIPstatisticPrintf("xprins statistic: Solution %13.6e found at node %"SCIP_LONGINT_FORMAT"\n",
1197 SCIPgetSolTransObj(scip, newsol), SCIPsolGetNodenum(subsol));
1198
1199 /* try to add new solution to scip */
1200#ifdef SCIP_STATISTIC
1201 if( !*success )
1202#endif
1204
1205#ifdef SCIP_STATISTIC
1206 if( SCIPgetSolTransObj(scip, newsol) < heurdata->bestprimalbd )
1207 heurdata->bestprimalbd = SCIPgetSolTransObj(scip, newsol);
1208
1209 SCIPstatisticPrintf("xprins statistic: Solution %13.6e found at node %"SCIP_LONGINT_FORMAT"\n",
1210 SCIPgetSolTransObj(scip, newsol), SCIPsolGetNodenum(subsol));
1211#endif
1212
1213 SCIP_CALL( SCIPfreeSol(scip, &newsol) );
1214
1215 SCIPfreeBufferArray(scip, &subsolvals);
1216
1217 return SCIP_OKAY;
1218}
1219
1220/** updates heurdata after a run of crossover */
1221static
1223 SCIP* scip, /**< original SCIP data structure */
1224 SCIP_HEURDATA* heurdata /**< primal heuristic data */
1225 )
1226{
1227 /* increase number of failures, calculate next node at which crossover should be called and update actual solutions */
1230 ? SCIPgetNNodes(scip) + 100*(2LL << heurdata->nfailures) /*lint !e703*/
1232}
1233
1234
1235
1236/*
1237 * Callback methods of primal heuristic
1238 */
1239
1240/** destructor of primal heuristic to free user data (called when SCIP is exiting) */
1241static
1242SCIP_DECL_HEURFREE(heurFreeXprins)
1243{ /*lint --e{715}*/
1245
1246 assert(heur != NULL);
1247 assert(scip != NULL);
1248
1249 /* get heuristic data */
1250 heurdata = SCIPheurGetData(heur);
1251 assert(heurdata != NULL);
1252
1253 /* free heuristic data */
1255 SCIPheurSetData(heur, NULL);
1256
1257 return SCIP_OKAY;
1258}
1259
1260/** initialization method of primal heuristic (called after problem was transformed) */
1261static
1262SCIP_DECL_HEURINIT(heurInitXprins)
1263{ /*lint --e{715}*/
1265
1266 assert(heur != NULL);
1267 assert(scip != NULL);
1268
1269 /* get heuristic data */
1270 heurdata = SCIPheurGetData(heur);
1271 assert(heurdata != NULL);
1272
1273 /* initialize data */
1274 heurdata->usednodes = 0;
1275 heurdata->nfailures = 0;
1277
1278 /* create random number generator */
1281
1282 return SCIP_OKAY;
1283}
1284
1285/** deinitialization method of primal heuristic (called before transformed problem is freed) */
1286static
1287SCIP_DECL_HEUREXIT(heurExitXprins)
1288{ /*lint --e{715}*/
1290
1291 assert(heur != NULL);
1292 assert(scip != NULL);
1293
1294 /* get heuristic data */
1295 heurdata = SCIPheurGetData(heur);
1296 assert(heurdata != NULL);
1297
1298 /* free random number generator */
1300
1301 return SCIP_OKAY;
1302}
1303
1304#ifdef SCIP_STATISTIC
1305/** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */
1306static
1307SCIP_DECL_HEURINITSOL(heurInitsolXprins)
1308{ /*lint --e{715}*/
1310
1311 assert(heur != NULL);
1312 assert(scip != NULL);
1313
1314 /* get heuristic data */
1315 heurdata = SCIPheurGetData(heur);
1316 assert(heurdata != NULL);
1317
1318 /* initialize statistical data */
1319 heurdata->avgfixrate = 0.0;
1320 heurdata->avgzerorate = 0.0;
1321 heurdata->totalsols = 0;
1322 heurdata->subsciptime = 0.0;
1323 heurdata->bestprimalbd = SCIPinfinity(scip);
1324
1325 return SCIP_OKAY;
1326}
1327
1328/** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */
1329static
1330SCIP_DECL_HEUREXITSOL(heurExitsolXprins)
1331{ /*lint --e{715}*/
1334
1335 assert(heur != NULL);
1336 assert(scip != NULL);
1337
1338 /* get heuristic data */
1339 heurdata = SCIPheurGetData(heur);
1340 assert(heurdata != NULL);
1341
1342 ncalls = SCIPheurGetNCalls(heur);
1343 heurdata->avgfixrate /= MAX((SCIP_Real)ncalls, 1.0);
1344 heurdata->avgzerorate /= MAX((SCIP_Real)ncalls, 1.0);
1345
1346 /* print detailed statistics */
1347 SCIPstatisticPrintf("LNS Statistics -- %s:\n", SCIPheurGetName(heur));
1349 SCIPstatisticPrintf("Failed Fixings : %13"SCIP_LONGINT_FORMAT"\n", heurdata->nfixfails);
1351 SCIPstatisticPrintf("Improving Sols : %13"SCIP_LONGINT_FORMAT"\n", SCIPheurGetNBestSolsFound(heur));
1352 SCIPstatisticPrintf("Total Sols : %13"SCIP_LONGINT_FORMAT"\n", heurdata->totalsols);
1353 SCIPstatisticPrintf("subSCIP time : %13.2f\n", heurdata->subsciptime);
1354 SCIPstatisticPrintf("subSCIP nodes : %13"SCIP_LONGINT_FORMAT"\n", heurdata->usednodes);
1355 SCIPstatisticPrintf("Avg. fixing rate : %13.2f\n", 100.0 * heurdata->avgfixrate);
1356 SCIPstatisticPrintf("Avg. zero rate : %13.2f\n", 100.0 * heurdata->avgzerorate);
1357 SCIPstatisticPrintf("Best primal bd. :");
1358 if( SCIPisInfinity(scip, heurdata->bestprimalbd) )
1359 SCIPstatisticPrintf(" infinity\n");
1360 else
1361 SCIPstatisticPrintf(" %13.6e\n", heurdata->bestprimalbd);
1362 SCIPstatisticPrintf("\n");
1363
1364 return SCIP_OKAY;
1365}
1366#endif
1367
1368
1369/** execution method of primal heuristic */
1370static
1371SCIP_DECL_HEUREXEC(heurExecXprins)
1372{ /*lint --e{715}*/
1373
1376
1377 SCIP* subscip;
1378 SCIP_VAR** subvars;
1379
1380 SCIP_Real memorylimit; /* memory limit for the subproblem */
1381 SCIP_Real timelimit; /* time limit for the subproblem */
1382 SCIP_Longint nstallnodes; /* node limit for the subproblem */
1383 SCIP_Real allfixingrate; /* percentage of all variables fixed */
1384 SCIP_Real intfixingrate; /* percentage of integer variables fixed */
1385 SCIP_Real zerofixingrate; /* percentage of variables fixed to zero */
1386
1387 int* selection; /* selected extreme points the heuristic will use, or NULL */
1388 int* nactualpts; /* number of points per block that have actually been selected -- may be less than 'nusedpts' */
1389 int nblocks;
1390
1393
1394 int i;
1395
1396 assert(heur != NULL);
1397 assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
1398 assert(scip != NULL);
1399 assert(result != NULL);
1400
1401 /* get heuristic data */
1402 heurdata = SCIPheurGetData(heur);
1403 assert(heurdata != NULL);
1404
1405 /* get master problem */
1408
1409 nblocks = GCGgetNPricingprobs(heurdata->gcg);
1410
1412
1413 /* do not execute the heuristic on invalid relaxation solutions
1414 * (which is the case if the node has been cut off)
1415 */
1417 {
1418 SCIPdebugMessage("skipping Extreme Point RINS: invalid relaxation solution\n");
1419 return SCIP_OKAY;
1420 }
1421
1422 /* only call heuristic, if an optimal LP solution is at hand */
1424 {
1425 SCIPdebugMessage("skipping Extreme Point RINS: master LP not solved to optimality.\n");
1426 return SCIP_OKAY;
1427 }
1428
1430
1431 /* if heuristic should be delayed, wait until certain number of nodes is reached */
1433 return SCIP_OKAY;
1434
1436
1437 /* only continue with some fractional variables */
1439 return SCIP_OKAY;
1440
1441 /* check whether there is enough time and memory left */
1442 timelimit = 0.0;
1443 memorylimit = 0.0;
1444 SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) );
1445 if( !SCIPisInfinity(scip, timelimit) )
1446 timelimit -= SCIPgetSolvingTime(scip);
1447 SCIP_CALL( SCIPgetRealParam(scip, "limits/memory", &memorylimit) );
1448
1449 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
1450 if( !SCIPisInfinity(scip, memorylimit) )
1451 {
1452 memorylimit -= SCIPgetMemUsed(scip)/1048576.0;
1453 memorylimit -= SCIPgetMemExternEstim(scip)/1048576.0;
1454 }
1455
1456 /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
1457 if( timelimit <= 0.0 || memorylimit <= 2.0*SCIPgetMemExternEstim(scip)/1048576.0 )
1458 return SCIP_OKAY;
1459
1460 /* calculate the maximal number of branching nodes until heuristic is aborted */
1461 nstallnodes = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
1462
1463 /* reward Crossover if it succeeded often */
1464 nstallnodes = (SCIP_Longint)
1465 (nstallnodes * (1.0 + 2.0*(SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur)+1.0)));
1466
1467 /* count the setup costs for the sub-MIP as 100 nodes */
1468 nstallnodes -= 100 * SCIPheurGetNCalls(heur);
1469 nstallnodes += heurdata->nodesofs;
1470
1471 /* determine the node limit for the current process */
1472 nstallnodes -= heurdata->usednodes;
1473 nstallnodes = MIN(nstallnodes, heurdata->maxnodes);
1474
1475 /* check whether we have enough nodes left to call subproblem solving */
1476 if( nstallnodes < heurdata->minnodes )
1477 {
1478 SCIPdebugMessage("skipping Extreme Point RINS: nstallnodes=%"SCIP_LONGINT_FORMAT", minnodes=%"SCIP_LONGINT_FORMAT"\n", nstallnodes, heurdata->minnodes);
1479 return SCIP_OKAY;
1480 }
1481
1482 if( SCIPisStopped(scip) )
1483 return SCIP_OKAY;
1484
1485 SCIPdebugMessage("Executing Extreme Point RINS heuristic ...\n");
1486
1487 /* allocate memory */
1489 SCIP_CALL( SCIPallocBufferArray(scip, &nactualpts, nblocks) );
1490 selection = NULL;
1491
1492 if( heurdata->nusedpts > 0 )
1493 {
1494 /* allocate memory */
1495 SCIP_CALL( SCIPallocBufferArray(scip, &selection, nblocks * heurdata->nusedpts) );
1496
1497 /* initialize empty selection */
1498 for( i = 0; i < nblocks * heurdata->nusedpts; ++i )
1499 selection[i] = -1;
1500
1501 /* for each block, select extreme points (represented by master variables) to perform RINS */
1502 success = FALSE;
1503 if( heurdata->randomization )
1504 {
1505 SCIPdebugMessage("selecting extreme points randomly...\n");
1506 SCIP_CALL( selectExtremePointsRandomized(heurdata->gcg, heurdata, selection, nactualpts, &success) );
1507 if( !success )
1508 {
1509 SCIPdebugMessage(" --> unsuccessful!\n");
1510 }
1511 }
1512 if( !heurdata->randomization || !success )
1513 {
1514 SCIPdebugMessage("selecting extreme points deterministically...\n");
1515 SCIP_CALL( selectExtremePoints(heurdata->gcg, heurdata, selection, nactualpts, &success) );
1516 }
1517
1518 /* do not execute heuristic if no new selection of extreme points was found */
1519 if( !success )
1520 {
1521 SCIPdebugMessage("no proper selection could be created - aborting heuristic.\n");
1522
1524
1525 /* free memory */
1526 SCIPfreeBufferArray(scip, &selection);
1527 SCIPfreeBufferArray(scip, &nactualpts);
1528 SCIPfreeBufferArray(scip, &subvars);
1529
1530 return SCIP_OKAY;
1531 }
1532 }
1533 else
1534 {
1535 if( heurdata->randomization )
1536 {
1537 SCIPwarningMessage(scip, "Randomization not supported when number of selected extreme points is not constant -- ignoring parameter\n");
1538 }
1539
1540 SCIP_CALL( countExtremePoints(heurdata->gcg, selection, heurdata->nusedpts, nactualpts) );
1541 }
1542
1543 /* initialize the subproblem */
1544 SCIP_CALL( SCIPcreate(&subscip) );
1545 SCIP_CALL( setupSubproblem(scip, subscip, subvars, heurdata, nstallnodes, timelimit, memorylimit) );
1546 SCIPdebugMessage("XP RINS subproblem: %d vars, %d conss\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip));
1547
1548 SCIPstatisticPrintf("xprins statistic: called at node %"SCIP_LONGINT_FORMAT"\n", SCIPgetNNodes(scip));
1549
1550 /* fix variables the variables of the subproblem */
1551 SCIP_CALL( fixVariables(heurdata->gcg, subscip, subvars, selection, nactualpts, heurdata, &intfixingrate, &zerofixingrate, &success) );
1552
1553#ifdef SCIP_STATISTIC
1554 /* for final statistics */
1555 heurdata->avgfixrate += intfixingrate;
1556 heurdata->avgzerorate += zerofixingrate;
1557#endif
1558
1559 /* if creation of subscip was aborted (e.g. due to number of fixings), free subscip and abort */
1560 if( !success )
1561 {
1562 /* this run will be counted as a failure since the neighborhood of the
1563 * solution was not fruitful in the sense that it was too big
1564 */
1566#ifdef SCIP_STATISTIC
1567 ++heurdata->nfixfails;
1568#endif
1569 goto TERMINATE;
1570 }
1571
1573
1574 /* presolve the subproblem */
1575 retcode = SCIPpresolve(subscip);
1576
1577 /* errors in solving the subproblem should not kill the overall solving process;
1578 * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
1579 */
1580 if( retcode != SCIP_OKAY )
1581 {
1582#ifndef NDEBUG
1583 SCIP_CALL( retcode );
1584#endif
1585 SCIPwarningMessage(scip, "Error while presolving subproblem in XP RINS heuristic; sub-SCIP terminated with code <%d>\n",retcode);
1586 goto TERMINATE;
1587 }
1588
1589 SCIPdebugMessage("XP RINS presolved subproblem: %d vars, %d conss, success=%u\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip), success);
1590
1591 allfixingrate = (SCIPgetNOrigVars(subscip) - SCIPgetNVars(subscip)) / (SCIP_Real)SCIPgetNOrigVars(subscip);
1592
1593 /* additional variables added in presolving may lead to the subSCIP having more variables than the original */
1594 allfixingrate = MAX(allfixingrate, 0.0);
1595
1596 /* after presolving, we should have at least reached a certain fixing rate over ALL variables (including continuous)
1597 * to ensure that not only the MIP but also the LP relaxation is easy enough
1598 */
1599 if( allfixingrate >= heurdata->minfixingrate / 2.0 )
1600 {
1601 SCIP_SOL** subsols;
1602 int nsubsols;
1603
1604 /* solve the subproblem */
1605 SCIPdebugMessage("subSCIP: Solving... (node limit = %lld, time limit = %.2g)\n", nstallnodes, timelimit);
1606
1607 /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
1608 * Hence in optimized mode, the return code is catched and a warning is printed, only in debug mode, SCIP will stop.
1609 */
1610#ifdef NDEBUG
1611 retcode = SCIPsolve(subscip);
1612 if( retcode != SCIP_OKAY )
1613 {
1614 SCIPwarningMessage(scip, "Error while solving subproblem in XP RINS heuristic; sub-SCIP terminated with code <%d>\n",
1615 retcode);
1616 }
1617#else
1618 SCIP_CALL( SCIPsolve(subscip) );
1619#endif
1620
1621#ifdef SCIP_STATISTIC
1622 heurdata->usednodes += SCIPgetNNodes(subscip);
1623 heurdata->subsciptime += SCIPgetTotalTime(subscip);
1624#endif
1625
1626 /* check, whether a solution was found;
1627 * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted
1628 */
1629 nsubsols = SCIPgetNSols(subscip);
1630 subsols = SCIPgetSols(subscip);
1631 success = FALSE;
1632#ifdef SCIP_STATISTIC
1633 heurdata->totalsols += nsubsols;
1634 for( i = 0; i < nsubsols; ++i )
1635#else
1636 for( i = 0; i < nsubsols && !success; ++i )
1637#endif
1638 {
1639 SCIP_CALL( createNewSol(scip, subscip, subvars, heur, subsols[i], &success) );
1640 if( success )
1642 }
1643
1644 SCIPstatisticPrintf("xprins statistic: fixed %6.3f integer variables ( %6.3f zero), %6.3f all variables, needed %6.1f sec (SCIP time: %6.1f sec), %"SCIP_LONGINT_FORMAT" nodes, found %d solutions, solution %10.4f found at node %"SCIP_LONGINT_FORMAT"\n",
1645 intfixingrate, zerofixingrate, allfixingrate, SCIPgetSolvingTime(subscip), SCIPgetSolvingTime(scip), SCIPgetNNodes(subscip), nsubsols,
1646 success ? SCIPgetPrimalbound(scip) : SCIPinfinity(scip), nsubsols > 0 ? SCIPsolGetNodenum(SCIPgetBestSol(subscip)) : -1 );
1647
1648 if( !success )
1649 {
1650 /* if no new solution was found, run was a failure */
1652 SCIPdebugMessage(" -> no subMIP solution found - subSCIP status is %d\n", SCIPgetStatus(subscip));
1653 }
1654 }
1655 else
1656 {
1657 SCIPstatisticPrintf("xprins statistic: fixed only %6.3f integer variables ( %6.3f zero), %6.3f all variables --> abort \n", intfixingrate, zerofixingrate, allfixingrate);
1658 }
1659
1660TERMINATE:
1661 /* free memory */
1662 SCIP_CALL( SCIPfree(&subscip) );
1663 SCIPfreeBufferArrayNull(scip, &selection);
1664 SCIPfreeBufferArray(scip, &nactualpts);
1665 SCIPfreeBufferArray(scip, &subvars);
1666
1667 return SCIP_OKAY;
1668}
1669
1670
1671
1672/*
1673 * primal heuristic specific interface methods
1674 */
1675
1676/** creates the Extreme Point RINS primal heuristic and includes it in SCIP */
1678 GCG* gcg /**< GCG data structure */
1679 )
1680{
1682 SCIP_HEUR* heur;
1684
1685 /* create Extreme Point RINS primal heuristic data */
1687 heurdata->gcg = gcg;
1688
1689 /* include primal heuristic */
1692 HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecXprins, heurdata) );
1693
1694 assert(heur != NULL);
1695
1696 /* set non-NULL pointers to callback methods */
1697 SCIP_CALL( SCIPsetHeurFree(origprob, heur, heurFreeXprins) );
1698 SCIP_CALL( SCIPsetHeurInit(origprob, heur, heurInitXprins) );
1699 SCIP_CALL( SCIPsetHeurExit(origprob, heur, heurExitXprins) );
1700#ifdef SCIP_STATISTIC
1701 SCIP_CALL( SCIPsetHeurInitsol(origprob, heur, heurInitsolXprins) );
1702 SCIP_CALL( SCIPsetHeurExitsol(origprob, heur, heurExitsolXprins) );
1703#endif
1704
1705 /* add Extreme Point RINS primal heuristic parameters */
1706
1707 SCIP_CALL( SCIPaddRealParam(origprob, "heuristics/"HEUR_NAME"/equalityrate",
1708 "minimum percentage of coincidence of relaxation and extreme pts",
1710
1711 SCIP_CALL( SCIPaddLongintParam(origprob, "heuristics/"HEUR_NAME"/nodesofs",
1712 "number of nodes added to the contingent of the total nodes",
1714
1715 SCIP_CALL( SCIPaddLongintParam(origprob, "heuristics/"HEUR_NAME"/maxnodes",
1716 "maximum number of nodes to regard in the subproblem",
1718
1719 SCIP_CALL( SCIPaddLongintParam(origprob, "heuristics/"HEUR_NAME"/minnodes",
1720 "minimum number of nodes required to start the subproblem",
1722
1723 SCIP_CALL( SCIPaddIntParam(origprob, "heuristics/"HEUR_NAME"/nusedpts",
1724 "number of extreme pts per block that will be taken into account (-1: all; 0: all which contribute to current relaxation solution)",
1725 &heurdata->nusedpts, FALSE, DEFAULT_NUSEDPTS, -1, INT_MAX, NULL, NULL) );
1726
1727 SCIP_CALL( SCIPaddRealParam(origprob, "heuristics/"HEUR_NAME"/nodesquot",
1728 "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1730
1731 SCIP_CALL( SCIPaddRealParam(origprob, "heuristics/"HEUR_NAME"/minfixingrate",
1732 "minimum percentage of integer variables that have to be fixed",
1734
1735 SCIP_CALL( SCIPaddRealParam(origprob, "heuristics/"HEUR_NAME"/minimprove",
1736 "factor by which crossover should at least improve the incumbent",
1738
1739 SCIP_CALL( SCIPaddBoolParam(origprob, "heuristics/"HEUR_NAME"/randomization",
1740 "should the choice which sols to take be randomized?",
1742
1743 SCIP_CALL( SCIPaddBoolParam(origprob, "heuristics/"HEUR_NAME"/copycuts",
1744 "if uselprows == FALSE, should all active cuts from cutpool be copied to constraints in subproblem?",
1746
1747 return SCIP_OKAY;
1748}
SCIP_DECL_HEUREXIT(Heur2opt::scip_exit)
SCIP_DECL_HEUREXITSOL(Heur2opt::scip_exitsol)
SCIP_DECL_HEURINIT(Heur2opt::scip_init)
SCIP_DECL_HEURINITSOL(Heur2opt::scip_initsol)
SCIP_DECL_HEURFREE(Heur2opt::scip_free)
SCIP_DECL_HEUREXEC(Heur2opt::scip_exec)
#define DEFAULT_RANDSEED
#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 SCIP_LONGINT_MAX
#define TRUE
#define FALSE
GCG interface methods.
SCIP_Bool GCGvarIsOriginal(SCIP_VAR *var)
Definition gcgvar.c:231
SCIP_VAR ** GCGlinkingVarGetPricingVars(SCIP_VAR *var)
Definition gcgvar.c:488
int GCGmasterVarGetNOrigvars(SCIP_VAR *var)
Definition gcgvar.c:971
SCIP_VAR ** GCGpricingVarGetOrigvars(SCIP_VAR *var)
Definition gcgvar.c:1100
SCIP_Bool GCGoriginalVarIsLinking(SCIP_VAR *var)
Definition gcgvar.c:247
SCIP_VAR * GCGoriginalVarGetPricingVar(SCIP_VAR *var)
Definition gcgvar.c:281
SCIP_VAR ** GCGmasterVarGetOrigvars(SCIP_VAR *var)
Definition gcgvar.c:993
SCIP_Bool GCGisLinkingVarInBlock(SCIP_VAR *var, int block)
Definition gcgvar.c:1149
int GCGpricingVarGetNOrigvars(SCIP_VAR *var)
Definition gcgvar.c:1082
SCIP_Bool GCGvarIsMaster(SCIP_VAR *var)
Definition gcgvar.c:176
SCIP_Real * GCGmasterVarGetOrigvals(SCIP_VAR *var)
Definition gcgvar.c:1017
SCIP_Bool GCGmasterVarIsRay(SCIP_VAR *var)
Definition gcgvar.c:937
int GCGvarGetBlock(SCIP_VAR *var)
Definition gcgvar.c:1118
SCIP_RETCODE SCIPcopyVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global)
SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
SCIP_RETCODE SCIPcopyConss(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool *valid)
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
GCG_EXPORT int GCGgetNIdenticalBlocks(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4185
GCG_EXPORT int GCGgetNPricingprobs(GCG *gcg)
Definition relax_gcg.c:4113
GCG_EXPORT int GCGgetBlockRepresentative(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4155
SCIP * GCGgetMasterprob(GCG *gcg)
Definition gcg.cpp:99
GCG_EXPORT SCIP_Bool GCGisPricingprobRelevant(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4132
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)
const char * SCIPgetProbName(SCIP *scip)
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
int SCIPgetNVars(SCIP *scip)
int SCIPgetNConss(SCIP *scip)
int SCIPgetNOrigVars(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)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
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 SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
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 SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
int SCIPgetNExternBranchCands(SCIP *scip)
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
SCIP_Longint SCIPheurGetNSolsFound(SCIP_HEUR *heur)
SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
const char * SCIPheurGetName(SCIP_HEUR *heur)
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
SCIP_Longint SCIPgetMemExternEstim(SCIP *scip)
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
#define SCIPfreeBufferArrayNull(scip, ptr)
SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
int SCIPgetNSols(SCIP *scip)
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_SOL ** SCIPgetSols(SCIP *scip)
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_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
SCIP_RETCODE SCIPpresolve(SCIP *scip)
SCIP_RETCODE SCIPsolve(SCIP *scip)
SCIP_Real SCIPgetPrimalbound(SCIP *scip)
SCIP_Real SCIPgetUpperbound(SCIP *scip)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Real SCIPgetLowerbound(SCIP *scip)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
SCIP_Real SCIPgetTotalTime(SCIP *scip)
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPinfinity(SCIP *scip)
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 SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
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_Real SCIPsumepsilon(SCIP *scip)
SCIP_Bool SCIPisFeasPositive(SCIP *scip, SCIP_Real val)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
int SCIPvarGetProbindex(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_Real SCIPgetRelaxSolVal(SCIP *scip, SCIP_VAR *var)
SCIP_Bool SCIPisRelaxSolValid(SCIP *scip)
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
unsigned int SCIPinitializeRandomSeed(SCIP *scip, unsigned int initialseedvalue)
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed, SCIP_Bool useglobalseed)
int SCIPrandomGetInt(SCIP_RANDNUMGEN *randnumgen, int minrandval, int maxrandval)
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))
#define HEUR_FREQOFS
#define HEUR_DESC
#define HEUR_DISPCHAR
#define HEUR_MAXDEPTH
#define HEUR_PRIORITY
#define HEUR_NAME
SCIP * origprob
#define HEUR_FREQ
#define DEFAULT_NODESQUOT
#define DEFAULT_NODESOFS
#define DEFAULT_COPYCUTS
#define DEFAULT_MAXNODES
#define HEUR_TIMING
#define DEFAULT_MINNODES
#define DEFAULT_MINIMPROVE
#define HEUR_USESSUBSCIP
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
SCIP_HASHMAP * varmapfw
* result
SCIP_VAR * var
SCIP_VAR ** vars
SCIP_Longint ncalls
int nbinvars
int j
int nintvars
SCIP_Bool success
SCIP_Real solval
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
SCIP_RETCODE retcode
int i
static SCIP_HEURDATA * heurdata
int nvars
SCIPfreeBufferArray(scip, &cycles)
#define DEFAULT_MINFIXINGRATE
SCIP_VAR ** mastervars
int nmastervars
SCIP_Bool cutoff
static SCIP_RETCODE setupSubproblem(SCIP *scip, SCIP *restmaster, SCIP_VAR **restmastervars, SCIP_Real minfixingrate, SCIP_Bool uselprows, SCIP_Bool pbheur, SCIP_Bool *success)
#define DEFAULT_NUSEDPTS
#define DEFAULT_RANDOMIZATION
static SCIP_RETCODE selectExtremePoints(GCG *gcg, SCIP_HEURDATA *heurdata, int *selection, SCIP_Bool *success)
static void updateFailureStatistic(SCIP *scip, SCIP_HEURDATA *heurdata)
static SCIP_RETCODE fixVariables(GCG *gcg, SCIP *subscip, SCIP_VAR **subvars, int *selection, SCIP_HEURDATA *heurdata, SCIP_Real *intfixingrate, SCIP_Real *zerofixingrate, SCIP_Bool *success)
static SCIP_RETCODE selectExtremePointsRandomized(GCG *gcg, SCIP_HEURDATA *heurdata, int *selection, SCIP_Bool *success)
#define DEFAULT_EQUALITYRATE
Definition heur_xprins.c:58
SCIP_RETCODE GCGincludeHeurXprins(GCG *gcg)
static SCIP_RETCODE compareExtremePointsToRelaxSol(GCG *gcg, int *selection, int nusedpts, int *neqpts, SCIP_Bool *zeroblocks)
static void compareOneExtremePoint(GCG *gcg, SCIP_VAR *mastervar, int solblock, int *neqpts, SCIP_Bool *zeroblocks)
static SCIP_RETCODE countExtremePoints(GCG *gcg, int *selection, int nusedpts, int *nactualpts)
Extreme Point RINS.
#define NULL
#define SCIPstatisticPrintf
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
SCIP_Longint nodesofs
SCIP_Real nodesquot
SCIP_Bool randomization
SCIP_Real equalityrate
Definition heur_xprins.c:84
SCIP_RANDNUMGEN * randnumgen
SCIP_Real minimprove
SCIP_Longint nextnodenumber
SCIP_Bool copycuts
SCIP_Real minfixingrate
SCIP_Longint usednodes
SCIP_Longint maxnodes
SCIP_Longint minnodes
unsigned int nfailures
struct Gcg GCG
Definition type_gcg.h:44
struct SCIP_HeurData SCIP_HEURDATA
struct SCIP_Heur SCIP_HEUR
SCIP_LPSOLSTAT_OPTIMAL
struct SCIP_HashMap SCIP_HASHMAP
struct SCIP_RandNumGen SCIP_RANDNUMGEN
SCIP_PARAMSETTING_OFF
SCIP_PARAMSETTING_FAST
SCIP_DIDNOTRUN
SCIP_DELAYED
SCIP_DIDNOTFIND
SCIP_FOUNDSOL
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
SCIP_STAGE_SOLVING
struct SCIP_Sol SCIP_SOL
struct SCIP_Var SCIP_VAR
SCIP_VARTYPE_INTEGER