GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
heur_xpcrossover.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_xpcrossover.c
30 * @brief Extreme Point Crossover
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
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 "xpcrossover"
49#define HEUR_DESC "Extreme Point Crossover"
50#define HEUR_DISPCHAR 'X'
51#define HEUR_PRIORITY -1100500
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_MAXNODES 1000LL /**< maximum number of nodes to regard in the subproblem */
59#define DEFAULT_MINIMPROVE 0.01 /**< factor by which crossover should at least improve the incumbent */
60#define DEFAULT_MINNODES 200LL /**< minimum number of nodes to regard in the subproblem */
61#define DEFAULT_MINFIXINGRATE 0.4 /**< minimum percentage of integer variables that have to be fixed */
62#define DEFAULT_NODESOFS 200LL /**< number of nodes added to the contingent of the total nodes */
63#define DEFAULT_NODESQUOT 0.1 /**< subproblem nodes in relation to nodes of the original problem */
64#define DEFAULT_NUSEDPTS 4 /**< number of extreme pts per block that will be taken into account */
65#define DEFAULT_RANDOMIZATION FALSE /**< should the choice which sols to take be randomized? */
66#define DEFAULT_COPYCUTS TRUE /**< if DEFAULT_USELPROWS is FALSE, then should all active cuts from the cutpool
67 * of the original scip be copied to constraints of the subscip
68 */
69#define DEFAULT_RANDSEED 7 /**< initial random seed */
70
71#define HASHSIZE_POINTS 11113 /**< size of hash table for extreme point tuples */
72
73
74
75
76/*
77 * Data structures
78 */
79typedef struct PointTuple POINTTUPLE;
80
81/** primal heuristic data */
82struct SCIP_HeurData
83{
84 GCG* gcg; /**< GCG data structure */
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 crossover in earlier calls */
89 SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
90
91 int nusedpts; /**< number of extreme pts per block that will be taken into account */
92 unsigned int nfailures; /**< number of failures since last successful call */
93 SCIP_Longint nextnodenumber; /**< number of BnB nodes at which crossover should be called next */
94 SCIP_Real minfixingrate; /**< minimum percentage of integer variables that have to be fixed */
95 SCIP_Real minimprove; /**< factor by which crossover should at least improve the incumbent */
96 SCIP_Bool randomization; /**< should the choice which sols to take be randomized? */
97 SCIP_Bool copycuts; /**< if uselprows == FALSE, should all active cuts from cutpool be copied
98 * to constraints in subproblem?
99 */
100 SCIP_RANDNUMGEN* randnumgen; /**< random number generator */
101 SCIP_HASHTABLE* hashtable; /**< hashtable used to store the extreme point tuples already used */
102 POINTTUPLE* lasttuple; /**< last tuple of extreme points */
103
104#ifdef SCIP_STATISTIC
105 SCIP_Longint nfixfails; /**< number of abortions due to a bad fixing rate */
106 SCIP_Real avgfixrate; /**< average rate of variables that are fixed */
107 SCIP_Real avgzerorate; /**< average rate of fixed variables that are zero */
108 SCIP_Longint totalsols; /**< total number of subSCIP solutions (including those which have not
109 * been added)
110 */
111 SCIP_Real subsciptime; /**< total subSCIP solving time in seconds */
112 SCIP_Real bestprimalbd; /**< objective value of best solution found by this heuristic */
113#endif
114};
115
116/** n-tuple of extreme points and their hashkey */
118{
119 int* indices; /**< sorted array of master variable indices */
120 int size; /**< size of the array (should be heurdata->nusedpts * nblocks) */
121 unsigned int key; /**< hashkey of the tuple */
122 POINTTUPLE* prev; /**< previous extreme point tuple created */
123};
124
125
126
127
128/*
129 * Local methods
130 */
131
132
133/** gets the hash key of an extreme point tuple */
134static
136{ /*lint --e{715}*/
137 return elem;
138}
139
140
141/** returns TRUE iff both extreme point tuples are identical */
142static
144{ /*lint --e{715}*/
145 int i;
146 int size;
147
148 int* indices1;
149 int* indices2;
150
151 indices1 = ((POINTTUPLE*)key1)->indices;
152 indices2 = ((POINTTUPLE*)key2)->indices;
153
154 /* there should be two nonempty arrays of the same size */
155 assert(indices1 != NULL);
156 assert(indices2 != NULL);
157 assert(((POINTTUPLE*)key1)->size == ((POINTTUPLE*)key2)->size);
158
159 size = ((POINTTUPLE*)key1)->size;
160
161 /* compare arrays by components, return TRUE, iff equal */
162 for( i = 0; i < size; i++ )
163 {
164 if( indices1[i] != indices2[i] )
165 return FALSE;
166 }
167
168 return TRUE;
169}
170
171
172/** returns hashkey of an extreme point tuple */
173static
175{ /*lint --e{715}*/
176 return ((POINTTUPLE*)key)->key;
177}
178
179
180/** calculates a hash key for a given tuple of master variable indices */
181static
182unsigned int calculateHashKey(
183 int* indices, /**< indices of master variables */
184 int size /**< number of master variables */
185 )
186{
187 int i;
188 unsigned int hashkey;
189
190 /* haskey should be (x1+2) * (x2+2) * ... * (xn+2) + (x1+1) + (x2+1) + ... + (xn+1) */
191 hashkey = 1;
192 for( i = 0; i < size; i++ )
193 hashkey *= indices[i] + 2;
194 for( i = 0; i < size; i++ )
195 hashkey += indices[i] + 1;
196
197 return hashkey;
198}
199
200
201/** creates a new tuple of extreme points (= mastervars) */
202static
204 SCIP* scip, /**< original SCIP data structure */
205 POINTTUPLE** elem, /**< tuple of master variables which should be created */
206 int* indices, /**< indices of master variables */
207 int size, /**< number of master variables */
208 SCIP_HEURDATA* heurdata /**< primal heuristic data */
209 )
210{
211 /* memory allocation */
213 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(*elem)->indices,size) );
214 BMScopyMemoryArray((*elem)->indices, indices, size);
215
216 /* data input */
217 SCIPsortInt((*elem)->indices, size);
218 (*elem)->size = size;
219 (*elem)->key = calculateHashKey((*elem)->indices, (*elem)->size);
220 (*elem)->prev = heurdata->lasttuple;
221
222 /* update heurdata */
223 heurdata->lasttuple = *elem;
224 return SCIP_OKAY;
225}
226
227
228/** for each block, select extreme points (represented by mastervars) to be crossed */
229static
231 GCG* gcg, /**< GCG data structure */
232 SCIP_HEURDATA* heurdata, /**< primal heuristic data */
233 int* selection, /**< indices of selected extreme points */
234 SCIP_Bool* success /**< pointer to store whether the process was successful */
235 )
236{
237 SCIP* origprob;
239 int nblocks;
240
242 SCIP_Real* mastervals;
243 int nmastervars;
244
245 int nusedpts;
246 int block;
247#ifndef NDEBUG
248 int nidentblocks;
249#endif
250 int* blocknrs;
251 int* identblock;
252 SCIP_Real* blockvalue;
253 SCIP_Real value;
254 SCIP_Real* selvalue;
255
256 POINTTUPLE* elem;
257
258 int i;
259 int j;
260 int k;
261
263
264 /* check preconditions */
265 assert(origprob != NULL);
266 assert(heurdata != NULL);
267 assert(selection != NULL);
268 assert(success != NULL);
269
270 /* get master problem */
273
274 /* get number of blocks */
275 nblocks = GCGgetNPricingprobs(gcg);
276
277 /* get variables of the master problem */
280 assert(nmastervars >= 0);
281
282 /* get master LP solution values */
285
286 /* get number of extreme points per block */
287 nusedpts = heurdata->nusedpts;
288
289 /* allocate memory */
290 SCIP_CALL( SCIPallocBufferArray(origprob, &selvalue, nblocks * nusedpts) );
291 SCIP_CALL( SCIPallocBufferArray(origprob, &blocknrs, nblocks) );
292 SCIP_CALL( SCIPallocBufferArray(origprob, &blockvalue, nblocks) );
293 SCIP_CALL( SCIPallocBufferArray(origprob, &identblock, nblocks) );
294
295 /* initialize the block values for the pricing problems */
296 for( i = 0; i < nblocks; i++ )
297 {
298 blockvalue[i] = 0.0;
299 blocknrs[i] = 0;
300 identblock[i] = i;
301 }
302
303 *success = FALSE;
304
305 /* loop over all given master variables;
306 * this loop treats master variables that have value one or greater
307 * (in particular important if blocks are represented by others)
308 */
309 for( i = 0; i < nmastervars; i++ )
310 {
311 SCIP_VAR* mastervar;
312
313 mastervar = mastervars[i];
314 assert(GCGvarIsMaster(mastervar));
315
316 /* get block information and solution value */
317 block = GCGvarGetBlock(mastervar);
318 value = SCIPgetSolVal(masterprob, NULL, mastervar);
319
320 /** @todo handle infinite master solution values */
322
323 /* ignore irrelevant extreme points */
324 if( SCIPisFeasZero(origprob, value) )
325 continue;
326
327 /* ignore rays
328 * @todo do it smarter */
329 if( GCGmasterVarIsRay(mastervar) )
330 continue;
331
332 /* variables belonging to no block are not treated here */
333 if( block == -1 )
334 continue;
335
336 /* get number of blocks that are identical to this block */
337 assert(block >= 0);
338#ifndef NDEBUG
339 nidentblocks = GCGgetNIdenticalBlocks(gcg, block);
340#endif
341
342 while( SCIPisFeasGE(origprob, mastervals[i], 1.0) )
343 {
344 /* insert the extreme point in the selection (should be the only point for this block) */
345 j = identblock[block] * nusedpts;
346 assert(selection[j] == -1);
347
348 selection[j] = i;
349 selvalue[j] = 1.0;
350
351 mastervals[i] = mastervals[i] - 1.0;
352 blocknrs[block]++;
353
354 /* search the next block to be considered */
355 for( j = identblock[block] + 1; j < nblocks; ++j )
356 if( GCGgetBlockRepresentative(gcg, j) == block )
357 {
358 identblock[block] = j;
359 break;
360 }
361
362#ifndef NDEBUG
363 assert(blocknrs[block] >= nidentblocks || j < nblocks);
364#endif
365 }
366 }
367
368 /* loop over all given master variables */
369 for( i = 0; i < nmastervars; i++ )
370 {
371 SCIP_VAR* mastervar;
372
373 mastervar = mastervars[i];
374 assert(GCGvarIsMaster(mastervar));
375
376 /* get block information and solution value */
377 block = GCGvarGetBlock(mastervar);
378 value = SCIPgetSolVal(masterprob, NULL, mastervar);
379
380 /** @todo handle infinite master solution values */
382
383 /* ignore irrelevant extreme points */
384 if( SCIPisFeasZero(origprob, value) )
385 continue;
386
387 /* ignore rays */
388 if( GCGmasterVarIsRay(mastervar) )
389 continue;
390
391 /* variables belonging to no block are not treated here */
392 if( block == -1 )
393 continue;
394
395 /* get number of blocks that are identical to this block */
396 assert(block >= 0);
397#ifndef NDEBUG
398 nidentblocks = GCGgetNIdenticalBlocks(gcg, block);
399#endif
400
401 assert(SCIPisFeasGE(origprob, mastervals[i], 0.0) && SCIPisFeasLT(origprob, mastervals[i], 1.0));
402
403 while( SCIPisFeasPositive(origprob, mastervals[i]) )
404 {
405 value = MIN(mastervals[i], 1.0 - blockvalue[block]);
406
407 /* check if the extreme point is good enough to be inserted in the selection */
408 for( j = identblock[block] * nusedpts; j < (identblock[block] + 1) * nusedpts; ++j )
409 {
410 /* if the extreme point is better than a point in the selection
411 * or there are < nusedpts, insert it
412 */
413 if( selection[j] == -1 || SCIPisGT(origprob, value, selvalue[j]) )
414 {
415 for( k = (identblock[block] + 1) * nusedpts - 1; k > j; --k )
416 {
417 selection[k] = selection[k-1];
418 selvalue[k] = selvalue[k-1];
419 }
420 selection[j] = i;
421 selvalue[j] = value;
422 break;
423 }
424 }
425
426 mastervals[i] = mastervals[i] - value;
427 if( SCIPisFeasZero(origprob, mastervals[i]) )
428 mastervals[i] = 0.0;
429 blockvalue[block] += value;
430
431 /* if the value assigned to the block is equal to 1, this block is full and we consider the next block */
432 if( SCIPisFeasGE(origprob, blockvalue[block], 1.0) )
433 {
434 blockvalue[block] = 0.0;
435 blocknrs[block]++;
436
437 /* search the next identical block to be considered */
438 for( j = identblock[block] + 1; j < nblocks; ++j )
439 if( GCGgetBlockRepresentative(gcg, j) == block )
440 {
441 identblock[block] = j;
442 break;
443 }
444
445#ifndef NDEBUG
446 assert(blocknrs[block] >= nidentblocks || j < nblocks);
447#endif
448 }
449 }
450 }
451
452 /* creates an object ready to be inserted into the hashtable */
453 SCIP_CALL( createPtTuple(origprob, &elem, selection, nusedpts * nblocks, heurdata) );
454
455 /* check whether the set is already in the hashtable, if not, insert it */
457 {
459 *success = TRUE;
460 }
461
462 /* free memory */
463 SCIPfreeBufferArray(origprob, &identblock);
464 SCIPfreeBufferArray(origprob, &blockvalue);
465 SCIPfreeBufferArray(origprob, &blocknrs);
466 SCIPfreeBufferArray(origprob, &selvalue);
467 SCIPfreeBufferArray(origprob, &mastervals);
468
469 return SCIP_OKAY;
470}
471
472
473/** select extreme points (represented by mastervars) to be crossed randomly */
474static
476 GCG* gcg, /**< GCG data structure */
477 SCIP_HEURDATA* heurdata, /**< primal heuristic data */
478 int* selection, /**< indices of selected extreme points */
479 SCIP_Bool* success /**< pointer to store whether the process was successful */
480 )
481{
482 SCIP* origprob;
484 int nblocks;
485
487 int nmastervars;
488
489 int nusedpts; /* number of extreme points per block to be chosen */
490 int* npts; /* for each block, the number of available extreme points */
491 int* blockpts; /* all points of a block which to be considered */
492 SCIP_Real* ptvals; /* solution values of extreme points in master problem */
493 int lastpt; /* the worst extreme point possible to choose */
494 int iters; /* iteration counter */
495
496 POINTTUPLE* elem;
497
498 int i;
499 int j;
500 int k;
501
503
504 /* check preconditions */
505 assert(origprob != NULL);
506 assert(heurdata != NULL);
507 assert(selection != NULL);
508 assert(success != NULL);
509
510 /* get master problem */
513
514 /* get number of blocks */
515 nblocks = GCGgetNPricingprobs(gcg);
516
517 /* get variables of the master problem */
520 assert(nmastervars >= 0);
521
522 /* get number of extreme points per block */
523 nusedpts = heurdata->nusedpts;
524
525 /* allocate memory */
526 SCIP_CALL( SCIPallocBufferArray(origprob, &npts, nblocks) );
527
528 *success = TRUE;
529
530 /* check whether we have enough points per block to perform a randomization */
531 for( i = 0; i < nblocks; ++i )
532 npts[i] = 0;
533 for( i = 0; i < nmastervars; ++i )
534 {
535 SCIP_VAR* mastervar;
537 int block;
538
539 mastervar = mastervars[i];
540 solval = SCIPgetSolVal(masterprob, NULL, mastervar);
541 block = GCGvarGetBlock(mastervar);
542
543 if( block >= 0 && !SCIPisFeasZero(origprob, solval) )
544 ++npts[block];
545 }
546 for( i = 0; i < nblocks; ++i )
547 if( GCGisPricingprobRelevant(gcg, i) && npts[i] <= nusedpts )
548 *success = FALSE;
549
550 /* do not randomize if there are not enough points available */
551 if( !*success )
552 {
553 SCIPdebugMessage(" -> not enough extreme points available for randomization.\n");
554
555 /* free memory */
557
558 return SCIP_OKAY;
559 }
560
561 *success = FALSE;
562 iters = 0;
563
564 /* perform at maximum 10 restarts and stop as soon as a new set of solutions is found */
565 do
566 {
567 for( i = 0; i < nblocks; ++i )
568 {
569 int blockrep;
570
571 SCIP_CALL( SCIPallocBufferArray(origprob, &blockpts, npts[i]) );
572 SCIP_CALL( SCIPallocBufferArray(origprob, &ptvals, npts[i]) );
573
574 /* get representative of this block */
575 blockrep = GCGgetBlockRepresentative(gcg, i);
576 assert(blockrep >= 0 && blockrep <= i);
577
578 /* get all relevant extreme points for this block */
579 k = 0;
580 for( j = 0; j < nmastervars; ++j )
581 {
582 SCIP_VAR* mastervar;
584 int block;
585
586 mastervar = mastervars[j];
587 solval = SCIPgetSolVal(masterprob, NULL, mastervar);
588 block = GCGvarGetBlock(mastervar);
589
590 if( block == blockrep && !SCIPisFeasZero(origprob, solval) )
591 {
592 assert(k < npts[blockrep]);
593 blockpts[k] = j;
594 ++k;
595 }
596 }
597 assert(k == npts[blockrep]);
598
599 /* sort the extreme points */
600 SCIPsortRealInt(ptvals, blockpts, npts[blockrep]);
601 lastpt = npts[blockrep];
602
603 /* perform a random selection for this block */
604 for( k = 0; k < nusedpts; ++k )
605 {
606 int idx;
607 int selidx;
608
609 idx = SCIPrandomGetInt(heurdata->randnumgen, nusedpts-k-1, lastpt-1);
610 selidx = i * nusedpts + k;
611 selection[selidx] = blockpts[idx];
612 lastpt = idx;
613 }
614
616 SCIPfreeBufferArray(origprob, &blockpts);
617 }
618
619 /* creates an object ready to be inserted into the hashtable */
620 SCIP_CALL( createPtTuple(origprob, &elem, selection, nusedpts * nblocks, heurdata) );
621
622 /* check whether the randomized set is already in the hashtable, if not, insert it */
624 {
626 *success = TRUE;
627 }
628 ++iters;
629 }
630 while( !*success && iters < 10 );
631
632 /* free memory */
634
635 return SCIP_OKAY;
636}
637
638
639#ifdef PRINTPOINTS
640/** prints selected extreme points to standard output */
641static
642SCIP_RETCODE printExtremePoints(
643 SCIP* scip,
644 int nusedpts,
645 int* selection
646 )
647{
649 int nblocks;
650
652 int nmastervars;
653 SCIP_VAR* mastervar;
654 SCIP_VAR** origvars;
655 SCIP_Real* origvals;
656 int norigvars;
657
658 int i;
659 int j;
660 int k;
661 int selidx;
662
663 assert(scip != NULL);
664
665 /* get master problem, number of blocks and extreme points per block */
668
669 nblocks = GCGgetNPricingprobs(scip);
670
671 /* get variables of the master problem */
674 assert(nmastervars >= 0);
675
676 /* first, print the relaxation solution */
677 SCIPdebugPrintf("------------------------------------------------------------\n");
678 SCIPdebugPrintf("Current relaxation solution:\n");
680 SCIPdebugPrintf("------------------------------------------------------------\n");
681
682 /* then, print the selected extreme points for each block */
683 for( i = 0; i < nblocks; ++i )
684 {
685 SCIPdebugPrintf("Block %i\n", i+1);
686 SCIPdebugPrintf("------------------------------------------------------------\n");
687
688 for( j = 0; j < nusedpts; ++j )
689 {
690 selidx = i * nusedpts + j;
691 if( selection[selidx] != -1 )
692 {
693 mastervar = mastervars[selection[selidx]];
694 assert(GCGvarIsMaster(mastervar));
695
696 origvars = GCGmasterVarGetOrigvars(mastervar);
697 origvals = GCGmasterVarGetOrigvals(mastervar);
698 norigvars = GCGmasterVarGetNOrigvars(mastervar);
699
700 SCIPdebugPrintf("Extreme point %i, mastervar %s, masterval=%g, index=%d:\n",
701 j+1, SCIPvarGetName(mastervar),
702 SCIPgetSolVal(masterprob, NULL, mastervar), SCIPvarGetProbindex(mastervar));
703 for( k = 0; k < norigvars; ++k )
704 {
705 SCIPdebugPrintf("%-32s % 20.15g \t(obj:%.15g)\n",
706 SCIPvarGetName(origvars[k]), origvals[k], SCIPvarGetObj(origvars[k]));
707 }
708 SCIPdebugPrintf("------------------------------------------------------------\n");
709 }
710 }
711 }
712
713 return SCIP_OKAY;
714}
715#endif
716
717/** initialize the subSCIP instance: copy SCIP to subSCIP, set the parameters */
718static
720 SCIP* scip, /**< original SCIP data structure */
721 SCIP* subscip, /**< SCIP data structure for the subproblem */
722 SCIP_VAR** subvars, /**< the variables of the subproblem */
723 SCIP_HEURDATA* heurdata, /**< primal heuristic data */
724 SCIP_Longint nstallnodes, /**< node limit for subproblem */
725 SCIP_Real timelimit, /**< time limit for subproblem */
726 SCIP_Real memorylimit /**< memory limit for subproblem */
727 )
728{
729 SCIP_VAR** vars;
730 int nvars;
731
732 int i;
733
734 char probname[SCIP_MAXSTRLEN];
735 SCIP_HASHMAP* varmapfw; /* mapping of SCIP variables to subSCIP variables */
736 SCIP_Bool valid;
737
740
741 /* copy the SCIP instance to the subSCIP */
742
743 /* copy all plugins */
745
746 /* get name of the original problem and add the string "_extremeptsub" */
747 (void) SCIPsnprintf(probname, SCIP_MAXSTRLEN, "%s_extremeptsub", SCIPgetProbName(scip));
748
749 /* create the subproblem */
750 SCIP_CALL( SCIPcreateProb(subscip, probname, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
751
752 /* copy all variables */
753 SCIP_CALL( SCIPcopyVars(scip, subscip, varmapfw, NULL, NULL, NULL, 0, TRUE) );
754
755 /* copy all constraints */
756 valid = FALSE;
757 SCIP_CALL( SCIPcopyConss(scip, subscip, varmapfw, NULL, TRUE, FALSE, &valid) );
758 if( heurdata->copycuts )
759 {
760 /* copies all active cuts from cutpool of sourcescip to linear constraints in targetscip */
762 }
763 SCIPdebugMessage("Copying the SCIP constraints was %s complete.\n", valid ? "" : "not ");
764
765 /* get the subproblem variables */
766 for( i = 0; i < nvars; i++ )
767 subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
768
769 /* free hash map */
771
772 /* setup parameters of subSCIP */
773 /* do not abort subproblem on CTRL-C */
774 SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
775
776#ifdef SCIP_DEBUG
777 /* for debugging RENS, enable MIP output */
778 SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
779 SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
780#else
781 /* disable output to console */
782 SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
783#endif
784
785 /* set limits for the subproblem */
786 SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nstallnodes) );
787 SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", MAX(10, nstallnodes/10)) );
788 SCIP_CALL( SCIPsetRealParam(subscip, "limits/time", timelimit) );
789 SCIP_CALL( SCIPsetRealParam(subscip, "limits/memory", memorylimit) );
790
791 /* forbid recursive call of heuristics and separators solving subMIPs */
792 SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
793
794 /* disable cutting plane separation */
796
797 /* disable expensive presolving */
799
800 /* use best estimate node selection */
801 if( SCIPfindNodesel(subscip, "estimate") != NULL && !SCIPisParamFixed(subscip, "nodeselection/estimate/stdpriority") )
802 {
803 SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/estimate/stdpriority", INT_MAX/4) );
804 }
805
806 /* use inference branching */
807 if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
808 {
809 SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
810 }
811
812 /* disable conflict analysis */
813 if( !SCIPisParamFixed(subscip, "conflict/enable") )
814 {
815 SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/enable", FALSE) );
816 }
817
818 /* if there is already a solution, add an objective cutoff */
819 if( SCIPgetNSols(scip) > 0 )
820 {
821 SCIP_Real cutoff; /* objective cutoff for the subproblem */
822 SCIP_Real upperbound;
823
825
826 upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
828 {
830 }
831 else
832 {
833 if( SCIPgetUpperbound ( scip ) >= 0 )
835 else
837 }
838 cutoff = MIN(upperbound, cutoff );
839 SCIP_CALL( SCIPsetObjlimit(subscip, cutoff) );
840 }
841
842 return SCIP_OKAY;
843}
844
845/** fix those variables which are identical in each extreme point of their blocks */
846static
848 GCG* gcg, /**< GCG data structure */
849 SCIP* subscip, /**< SCIP data structure for the subproblem */
850 SCIP_VAR** subvars, /**< the variables of the subproblem */
851 int* selection, /**< selected extreme points the heuristic will use */
852 SCIP_HEURDATA* heurdata, /**< primal heuristic data */
853 SCIP_Real* intfixingrate, /**< percentage of integers that get actually fixed */
854 SCIP_Real* zerofixingrate, /**< percentage of variables fixed to zero */
855 SCIP_Bool* success /**< pointer to store whether the problem was created successfully */
856 )
857{
858 SCIP* origprob;
859 SCIP* masterprob; /* master problem */
860 SCIP_VAR** mastervars; /* master variables */
861 SCIP_VAR** vars; /* original scip variables */
862
863 int nblocks; /* number of blocks */
864 int nusedpts; /* number of extreme points per block */
865 int nvars; /* number of original variables */
866 int nbinvars; /* number of binary variables in the original problem */
867 int nintvars; /* number of general integer variables */
868
869 SCIP_Real* fixvals; /* values to which original variables should be fixed */
870 SCIP_Bool* fixable; /* for each original variable, remember if it is fixable */
871 SCIP_Bool* zeroblocks; /* blocks that would be entirely fixed to zero */
872 int* ptcounter; /* for each original variable, count in how many extreme points it appears */
873 int fixingcounter; /* count how many original variables are fixed */
874 int zerocounter; /* count how many variables are fixed to zero */
875
876 int i;
877 int j;
878 int k;
879 int l;
880 int idx;
881
883
884 /* check preconditions */
885 assert(origprob != NULL);
886 assert(subscip != NULL);
887 assert(subvars != NULL);
888 assert(selection != NULL);
889 assert(heurdata != NULL);
890 assert(intfixingrate != NULL);
891 assert(zerofixingrate != NULL);
892 assert(success != NULL);
893
894 /* get master problem and its variables */
899
900 /* get required data of the original problem */
902
903 nblocks = GCGgetNPricingprobs(gcg);
904 nusedpts = heurdata->nusedpts;
905 assert(nusedpts >= 2);
906
907 fixingcounter = 0;
908 zerocounter = 0;
909
910 *success = FALSE;
911
912 /* allocate memory */
916 SCIP_CALL( SCIPallocBufferArray(origprob, &zeroblocks, nblocks) );
917
918 /* initialize fixing information for original variables
919 *
920 * @note: Zero values of extreme points are not stored explicitly in the master
921 * variable data; therefore
922 * * we assume for each variable that it can be fixed to zero
923 * * we assume a fixing value different from zero if we find
924 * a nonzero entry in the first extreme point (so the first point serves
925 * as a 'reference point')
926 * * we mark the variable as unfixable if we find a nonzero entry for it which
927 * differs from the current fixing value
928 * It still may happen that a variable is still marked as fixable although it
929 * appears nonzero in only some, but not all extreme points; this will be corrected
930 * later on (this is why we remember the number of points in which a variable appears
931 * nonzero)
932 */
933 for( i = 0; i < nbinvars + nintvars; ++i )
934 {
935 fixable[i] = TRUE;
936 fixvals[i] = 0.0;
937 ptcounter[i] = 0;
938 }
939 /* for each block, compare the selected extreme points */
940 for( i = 0; i < nblocks; ++i )
941 {
942 int blockrep;
943 SCIP_VAR* mastervar;
944 SCIP_VAR** origvars;
945 SCIP_Real* origvals;
946 int norigvars;
947 int selidx;
948
949 /* get the block that represents this block (in case of aggregation) */
950 blockrep = GCGgetBlockRepresentative(gcg, i);
951
952 /* at least one extreme point must have been selected */
953 selidx = i * nusedpts;
954 assert(selection[selidx] != -1);
955
956 /* check whether the block would be fixed entirely to zero;
957 * a neccessary condition is that only one extreme pt has been selected
958 * (actual original variable values are checked later)
959 */
960 selidx = i * nusedpts + 1;
961 if( selection[selidx] == -1 )
962 zeroblocks[i] = TRUE;
963 else
964 zeroblocks[i] = FALSE;
965
966 /* compare the selected extreme points, where the first point is the reference point */
967 for( j = 0; j < nusedpts; ++j )
968 {
969 selidx = i * nusedpts + j;
970 if( selection[selidx] != -1 )
971 {
972 /* get master variable */
973 mastervar = mastervars[selection[selidx]];
974 assert(GCGvarGetBlock(mastervar) == blockrep);
975
976 /* get extreme point */
977 origvars = GCGmasterVarGetOrigvars(mastervar);
978 origvals = GCGmasterVarGetOrigvals(mastervar);
979 norigvars = GCGmasterVarGetNOrigvars(mastervar);
980
981 for( k = 0; k < norigvars; ++k )
982 {
983 SCIP_VAR* origvar;
984 SCIP_Bool firstblock;
985
986 if( SCIPvarGetType(origvars[k]) > SCIP_VARTYPE_INTEGER )
987 continue;
988
989 if( SCIPisFeasEQ(origprob, SCIPvarGetLbGlobal(origvars[k]), SCIPvarGetUbGlobal(origvars[k]) ) )
990 continue;
991
992 /* get the corresponding pricing variable;
993 * check whether this is the first block in which this variable appears;
994 * search for the right original variable (in case of aggregation)
995 */
996 if( GCGoriginalVarIsLinking(origvars[k]) )
997 {
998#ifndef NDEBUG
999 SCIP_VAR* pricingvar;
1000#endif
1001 SCIP_VAR** linkingpricingvars;
1002
1003 linkingpricingvars = GCGlinkingVarGetPricingVars(origvars[k]);
1004#ifndef NDEBUG
1005 pricingvar = linkingpricingvars[blockrep];
1006 assert(pricingvar != NULL);
1007 assert(GCGvarIsPricing(pricingvar));
1008#endif
1009
1010 /* for linking variables, also check whether this is
1011 * the first block the variable appears in
1012 */
1013 for( l = 0; l < blockrep; ++l )
1014 if( linkingpricingvars[l] != NULL )
1015 break;
1016 firstblock = (l == blockrep);
1017
1018 /** @todo can there be aggregated linking variables? */
1019 origvar = origvars[k];
1020 }
1021 else
1022 {
1023 SCIP_VAR* pricingvar;
1024 SCIP_VAR** pricingorigvars;
1025 int npricingorigvars;
1026
1027 pricingvar = GCGoriginalVarGetPricingVar(origvars[k]);
1028 assert(pricingvar != NULL);
1029 assert(GCGvarIsPricing(pricingvar));
1030
1031 firstblock = TRUE;
1032
1033 /* from all original variables corresponding to the current one,
1034 * get the one which belongs to the current block;
1035 * this is necessary since in case of identical, aggregated blocks,
1036 * the extreme point may belong to multiple blocks
1037 */
1038 npricingorigvars = GCGpricingVarGetNOrigvars(pricingvar);
1039 pricingorigvars = GCGpricingVarGetOrigvars(pricingvar);
1040 origvar = NULL;
1041 for( l = 0; l < npricingorigvars; ++l )
1042 if( GCGvarGetBlock(pricingorigvars[l]) == i )
1043 {
1044 origvar = pricingorigvars[l];
1045 break;
1046 }
1047 assert(origvar != NULL);
1048 }
1049
1050 /* get the variable index */
1051 idx = SCIPvarGetProbindex(origvar);
1052 assert(idx < nbinvars + nintvars);
1053
1054 /* the first extreme point serves as a reference point */
1055 if( j == 0 && firstblock )
1056 fixvals[idx] = origvals[k];
1057 /* the variable can not be be fixed if its value differs in the extreme points */
1058 else
1059 if( fixable[idx] && !SCIPisEQ(origprob, fixvals[idx], origvals[k]) )
1060 fixable[idx] = FALSE;
1061
1062 if( !SCIPisZero(origprob, origvals[k]) )
1063 {
1064 ++ptcounter[idx];
1065 zeroblocks[i] = FALSE;
1066 }
1067 }
1068 }
1069 }
1070 }
1071
1072 /* try to fix the binary and general integer variables */
1073 for( i = 0; i < nbinvars + nintvars; ++i )
1074 {
1075 SCIP_VAR* var;
1076 int block; /* current block we are working in */
1077 SCIP_Real lb;
1078 SCIP_Real ub;
1079
1080 var = vars[i];
1082 block = GCGvarGetBlock(var);
1083
1084 /* Variables which were directly copied from the original problem do not appear in any extreme point;
1085 * they are fixed like in the RENS heuristic
1086 */
1087 if( block == -1 )
1088 {
1089 fixvals[i] = SCIPgetRelaxSolVal(origprob, var);
1090 if( SCIPisFeasIntegral(origprob, fixvals[i]) )
1091 {
1092 /* fix variable to current relaxation solution if it is integral;
1093 * use exact integral value, if the variable is only integral within numerical tolerances
1094 */
1095 fixvals[i] = SCIPfloor(origprob, fixvals[i] + 0.5);
1096 }
1097 else
1098 fixable[i] = FALSE;
1099 }
1100
1101 /* If the variable is assigned to a block, it is fixed it has the same value
1102 * in all selected extreme points of its blocks
1103 */
1104 else
1105 {
1106 int nlinkblocks;
1107
1108 assert(block >= 0 || block == -2);
1110 assert(ptcounter[i] <= nusedpts * nlinkblocks);
1111
1112 /* This case has not been treated yet:
1113 * A variable which has appeared nonzero in only some, but not all points
1114 * is not fixed
1115 */
1116 if( ptcounter[i] > 0 && ptcounter[i] < nusedpts * nlinkblocks )
1117 fixable[i] = FALSE;
1118
1119 /* If the variable has not appeared in any extreme point, it should be fixed to zero */
1120#ifdef SCIP_DEBUG
1121 if( ptcounter[i] == 0 )
1122 {
1123 assert(fixable[i]);
1124 assert(SCIPisZero(scip, fixvals[i]));
1125 }
1126#endif
1127 }
1128
1129 /* get variable's global bounds */
1130 lb = SCIPvarGetLbGlobal(var);
1131 ub = SCIPvarGetUbGlobal(var);
1132
1133 /* The fixing value can be outside transformed global bounds */
1134 if( fixable[i] && (lb > fixvals[i] || fixvals[i] > ub) )
1135 fixable[i] = FALSE;
1136
1137 /* The variable can be fixed if it has not been marked unfixable, which is the case if
1138 * - it was directly transferred to the master problem and has integer value or
1139 * - it appeared zero in all extreme points
1140 * - it did not appear zero in some extreme pts and nonzero in other extreme pts;
1141 * besides, we do not fix entire blocks to zero
1142 */
1143 if( fixable[i] && (block < 0 || !zeroblocks[block]) )
1144 {
1145 SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[i], fixvals[i]) );
1146 SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[i], fixvals[i]) );
1147
1148 fixingcounter++;
1149
1150 if( SCIPisZero(origprob, fixvals[i]) )
1151 zerocounter++;
1152 }
1153 }
1154
1155 *intfixingrate = (SCIP_Real)fixingcounter / (SCIP_Real)(MAX(nbinvars + nintvars, 1));
1156 *zerofixingrate = (SCIP_Real)zerocounter / MAX((SCIP_Real)fixingcounter, 1.0);
1157
1158 /* if not enough variables were fixed, try to fix zero blocks until the minimum fixing rate is reached */
1159 while( *intfixingrate < heurdata->minfixingrate )
1160 {
1161 SCIPdebugMessage(" fixing rate only %5.2f --> trying to fix a zero block\n", *intfixingrate);
1162
1163 /* get the next zero block */
1164 for( i = 0; i < nblocks; ++i )
1165 if( zeroblocks[i] )
1166 {
1167 /* fix variables */
1168 for( j = 0; j < nbinvars + nintvars; ++j )
1169 if( GCGvarGetBlock(vars[j]) == i && fixable[j] )
1170 {
1171 assert(SCIPisZero(origprob, fixvals[j]));
1172 SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[j], 0.0) );
1173 SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[j], 0.0) );
1174 fixingcounter++;
1175 zerocounter++;
1176 }
1177
1178 zeroblocks[i] = FALSE;
1179 break;
1180 }
1181
1182 *intfixingrate = (SCIP_Real)fixingcounter / (SCIP_Real)(MAX(nbinvars + nintvars, 1));
1183 *zerofixingrate = (SCIP_Real)zerocounter / MAX((SCIP_Real)fixingcounter, 1.0);
1184
1185 if( i == nblocks )
1186 break;
1187 }
1188
1189 /* if all variables were fixed or amount of fixed variables is insufficient, abort immediately */
1190 if( *intfixingrate < heurdata->minfixingrate )
1191 {
1192 SCIPstatisticPrintf("xpcrossover statistic: fixed only %5.2f ( %5.2f zero) integer variables --> abort \n", *intfixingrate, *zerofixingrate);
1193 }
1194 if( fixingcounter == nbinvars + nintvars )
1195 {
1196 SCIPstatisticPrintf("xpcrossover statistic: fixed all ( %5.2f zero) integer variables --> abort \n", *zerofixingrate);
1197 }
1198
1199 *success = TRUE;
1200
1201 /* free memory */
1202 SCIPfreeBufferArray(origprob, &zeroblocks);
1203 SCIPfreeBufferArray(origprob, &fixvals);
1204 SCIPfreeBufferArray(origprob, &fixable);
1205 SCIPfreeBufferArray(origprob, &ptcounter);
1206
1207 return SCIP_OKAY;
1208}
1209
1210
1211/** creates a new solution for the original problem by copying the solution of the subproblem */
1212static
1214 SCIP* scip, /**< original SCIP data structure */
1215 SCIP* subscip, /**< SCIP structure of the subproblem */
1216 SCIP_VAR** subvars, /**< the variables of the subproblem */
1217 SCIP_HEUR* heur, /**< primal heuristic structure */
1218 SCIP_SOL* subsol, /**< solution of the subproblem */
1219 SCIP_Bool* success /**< used to store whether new solution was found or not */
1220 )
1221{
1222#ifdef SCIP_STATISTIC
1224#endif
1225 SCIP_VAR** vars; /* the original problem's variables */
1226 int nvars;
1227 SCIP_SOL* newsol; /* solution to be created for the original problem */
1228 SCIP_Real* subsolvals; /* solution values of the subproblem */
1229
1230 assert(scip != NULL);
1231 assert(subscip != NULL);
1232 assert(subvars != NULL);
1233 assert(subsol != NULL);
1234
1235#ifdef SCIP_STATISTIC
1236 /* get heuristic data */
1237 heurdata = SCIPheurGetData(heur);
1238 assert( heurdata != NULL );
1239#endif
1240
1241 /* get variables' data */
1243 assert(nvars <= SCIPgetNOrigVars(subscip));
1244
1245 SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
1246
1247 /* copy the solution */
1248 SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
1249
1250 /* create new solution for the original problem */
1251 SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
1252 SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
1253
1254 /* try to add new solution to scip */
1255#ifdef SCIP_STATISTIC
1256 if( !*success )
1257#endif
1259
1260#ifdef SCIP_STATISTIC
1261 if( SCIPgetSolTransObj(scip, newsol) < heurdata->bestprimalbd )
1262 heurdata->bestprimalbd = SCIPgetSolTransObj(scip, newsol);
1263
1264 SCIPstatisticPrintf("xpcrossover statistic: Solution %13.6e found at node %"SCIP_LONGINT_FORMAT"\n",
1265 SCIPgetSolOrigObj(scip, newsol), SCIPsolGetNodenum(subsol));
1266#endif
1267
1268 SCIP_CALL( SCIPfreeSol(scip, &newsol) );
1269
1270 SCIPfreeBufferArray(scip, &subsolvals);
1271
1272 return SCIP_OKAY;
1273}
1274
1275/** updates heurdata after a run of crossover */
1276static
1278 SCIP* scip, /**< original SCIP data structure */
1279 SCIP_HEURDATA* heurdata /**< primal heuristic data */
1280 )
1281{
1282 /* increase number of failures, calculate next node at which crossover should be called and update actual solutions */
1285 ? SCIPgetNNodes(scip) + 100*(2LL << heurdata->nfailures) /*lint !e703*/
1287}
1288
1289
1290/*
1291 * Callback methods of primal heuristic
1292 */
1293
1294/** destructor of primal heuristic to free user data (called when SCIP is exiting) */
1295static
1296SCIP_DECL_HEURFREE(heurFreeXpcrossover)
1297{ /*lint --e{715}*/
1299
1300 assert(heur != NULL);
1301 assert(scip != NULL);
1302
1303 /* get heuristic data */
1304 heurdata = SCIPheurGetData(heur);
1305 assert(heurdata != NULL);
1306
1307 /* free heuristic data */
1309 SCIPheurSetData(heur, NULL);
1310
1311 return SCIP_OKAY;
1312}
1313
1314/** initialization method of primal heuristic (called after problem was transformed) */
1315static
1316SCIP_DECL_HEURINIT(heurInitXpcrossover)
1317{ /*lint --e{715}*/
1319
1320 assert(heur != NULL);
1321 assert(scip != NULL);
1322
1323 /* get heuristic data */
1324 heurdata = SCIPheurGetData(heur);
1325 assert(heurdata != NULL);
1326
1327 /* initialize data */
1328 heurdata->usednodes = 0;
1330 heurdata->nfailures = 0;
1332
1333 /* create random number generator */
1336
1337 /* initialize hash table */
1339 hashGetKeyPts, hashKeyEqPts, hashKeyValPts, NULL) );
1341
1342 return SCIP_OKAY;
1343}
1344
1345/** deinitialization method of primal heuristic (called before transformed problem is freed) */
1346static
1347SCIP_DECL_HEUREXIT(heurExitXpcrossover)
1348{ /*lint --e{715}*/
1350 POINTTUPLE* pointtuple;
1351
1352 assert(heur != NULL);
1353 assert(scip != NULL);
1354
1355 /* get heuristic data */
1356 heurdata = SCIPheurGetData(heur);
1357 assert(heurdata != NULL);
1358 pointtuple = heurdata->lasttuple;
1359
1360 /* free all pointtuples iteratively */
1361 while( pointtuple != NULL )
1362 {
1363 POINTTUPLE* tmp;
1364 tmp = pointtuple->prev;
1365 SCIPfreeBlockMemoryArray(scip, &pointtuple->indices, pointtuple->size);
1366 SCIPfreeBlockMemory(scip, &pointtuple);
1367 pointtuple = tmp;
1368 }
1369
1370 /* free hash table */
1373
1374 /* free random number generator */
1376
1377 return SCIP_OKAY;
1378}
1379
1380
1381#ifdef SCIP_STATISTIC
1382/** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */
1383static
1384SCIP_DECL_HEURINITSOL(heurInitsolXpcrossover)
1385{ /*lint --e{715}*/
1387
1388 assert(heur != NULL);
1389 assert(scip != NULL);
1390
1391 /* get heuristic data */
1392 heurdata = SCIPheurGetData(heur);
1393 assert(heurdata != NULL);
1394
1395 /* initialize statistical data */
1396 heurdata->avgfixrate = 0.0;
1397 heurdata->avgzerorate = 0.0;
1398 heurdata->totalsols = 0;
1399 heurdata->subsciptime = 0.0;
1400 heurdata->bestprimalbd = SCIPinfinity(scip);
1401
1402 return SCIP_OKAY;
1403}
1404
1405
1406/** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */
1407static
1408SCIP_DECL_HEUREXITSOL(heurExitsolXpcrossover)
1409{ /*lint --e{715}*/
1412
1413 assert(heur != NULL);
1414 assert(scip != NULL);
1415
1416 /* get heuristic data */
1417 heurdata = SCIPheurGetData(heur);
1418 assert(heurdata != NULL);
1419
1420 ncalls = SCIPheurGetNCalls(heur);
1421 heurdata->avgfixrate /= MAX((SCIP_Real)ncalls, 1.0);
1422 heurdata->avgzerorate /= MAX((SCIP_Real)ncalls, 1.0);
1423
1424 /* print detailed statistics */
1425 SCIPstatisticPrintf("LNS Statistics -- %s:\n", SCIPheurGetName(heur));
1427 SCIPstatisticPrintf("Failed Fixings : %13"SCIP_LONGINT_FORMAT"\n", heurdata->nfixfails);
1429 SCIPstatisticPrintf("Improving Sols : %13"SCIP_LONGINT_FORMAT"\n", SCIPheurGetNBestSolsFound(heur));
1430 SCIPstatisticPrintf("Total Sols : %13"SCIP_LONGINT_FORMAT"\n", heurdata->totalsols);
1431 SCIPstatisticPrintf("subSCIP time : %13.2f\n", heurdata->subsciptime);
1432 SCIPstatisticPrintf("subSCIP nodes : %13"SCIP_LONGINT_FORMAT"\n", heurdata->usednodes);
1433 SCIPstatisticPrintf("Avg. fixing rate : %13.2f\n", 100.0 * heurdata->avgfixrate);
1434 SCIPstatisticPrintf("Avg. zero rate : %13.2f\n", 100.0 * heurdata->avgzerorate);
1435 SCIPstatisticPrintf("Best primal bd. :");
1436 if( SCIPisInfinity(scip, heurdata->bestprimalbd) )
1437 SCIPstatisticPrintf(" infinity\n");
1438 else
1439 SCIPstatisticPrintf(" %13.6e\n", heurdata->bestprimalbd);
1440 SCIPstatisticPrintf("\n");
1441
1442 return SCIP_OKAY;
1443}
1444#endif
1445
1446
1447/** execution method of primal heuristic */
1448static
1449SCIP_DECL_HEUREXEC(heurExecXpcrossover)
1450{ /*lint --e{715}*/
1451
1454
1455 SCIP* subscip;
1456 SCIP_VAR** subvars;
1457
1458 SCIP_Real memorylimit; /* memory limit for the subproblem */
1459 SCIP_Real timelimit; /* time limit for the subproblem */
1460 SCIP_Longint nstallnodes; /* node limit for the subproblem */
1461 SCIP_Real allfixingrate; /* percentage of all variables fixed */
1462 SCIP_Real intfixingrate; /* percentage of integer variables fixed */
1463 SCIP_Real zerofixingrate; /* percentage of variables fixed to zero */
1464
1465 int* selection;
1466 int nblocks;
1467
1470
1471 int i;
1472
1473 assert(heur != NULL);
1474 assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
1475 assert(scip != NULL);
1476 assert(result != NULL);
1477
1478 /* get heuristic data */
1479 heurdata = SCIPheurGetData(heur);
1480 assert(heurdata != NULL);
1481
1482 /* get master problem */
1485
1486 nblocks = GCGgetNPricingprobs(heurdata->gcg);
1487
1489
1490 /* do not execute the heuristic on invalid relaxation solutions
1491 * (which is the case if the node has been cut off)
1492 */
1494 {
1495 SCIPdebugMessage("skipping Extreme Point Crossover: invalid relaxation solution\n");
1496 return SCIP_OKAY;
1497 }
1498
1499 /* only call heuristic, if an optimal LP solution is at hand */
1501 {
1502 SCIPdebugMessage("skipping Extreme Point Crossover: master LP not solved to optimality.\n");
1503 return SCIP_OKAY;
1504 }
1505
1507
1508 /* if heuristic should be delayed, wait until certain number of nodes is reached */
1510 return SCIP_OKAY;
1511
1513
1514 /* only continue with some fractional variables */
1516 return SCIP_OKAY;
1517
1518 /* check whether there is enough time and memory left */
1519 timelimit = 0.0;
1520 memorylimit = 0.0;
1521 SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) );
1522 if( !SCIPisInfinity(scip, timelimit) )
1523 timelimit -= SCIPgetSolvingTime(scip);
1524 SCIP_CALL( SCIPgetRealParam(scip, "limits/memory", &memorylimit) );
1525
1526 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
1527 if( !SCIPisInfinity(scip, memorylimit) )
1528 {
1529 memorylimit -= SCIPgetMemUsed(scip)/1048576.0;
1530 memorylimit -= SCIPgetMemExternEstim(scip)/1048576.0;
1531 }
1532
1533 /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
1534 if( timelimit <= 0.0 || memorylimit <= 2.0*SCIPgetMemExternEstim(scip)/1048576.0 )
1535 return SCIP_OKAY;
1536
1537 /* calculate the maximal number of branching nodes until heuristic is aborted */
1538 nstallnodes = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
1539
1540 /* reward Crossover if it succeeded often */
1541 nstallnodes = (SCIP_Longint)
1542 (nstallnodes * (1.0 + 2.0*(SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur)+1.0)));
1543
1544 /* count the setup costs for the sub-MIP as 100 nodes */
1545 nstallnodes -= 100 * SCIPheurGetNCalls(heur);
1546 nstallnodes += heurdata->nodesofs;
1547
1548 /* determine the node limit for the current process */
1549 nstallnodes -= heurdata->usednodes;
1550 nstallnodes = MIN(nstallnodes, heurdata->maxnodes);
1551
1552 /* check whether we have enough nodes left to call subproblem solving */
1553 if( nstallnodes < heurdata->minnodes )
1554 {
1555 SCIPdebugMessage("skipping Extreme Point Crossover: nstallnodes=%"SCIP_LONGINT_FORMAT", minnodes=%"SCIP_LONGINT_FORMAT"\n", nstallnodes, heurdata->minnodes);
1556 return SCIP_OKAY;
1557 }
1558
1559 if( SCIPisStopped(scip) )
1560 return SCIP_OKAY;
1561
1562 SCIPdebugMessage("Executing Extreme Point Crossover heuristic ...\n");
1563
1564 /* allocate memory */
1565 SCIP_CALL( SCIPallocBufferArray(scip, &selection, nblocks * heurdata->nusedpts) );
1567
1568 /* initialize empty selection */
1569 for( i = 0; i < nblocks * heurdata->nusedpts; ++i )
1570 selection[i] = -1;
1571
1572 /* for each block, select extreme points (represented by master variables) considered for a crossover */
1573 success = FALSE;
1574 if( heurdata->randomization )
1575 {
1576 SCIPdebugMessage("selecting extreme points randomly...\n");
1578 }
1579 if( !heurdata->randomization || !success )
1580 {
1581 SCIPdebugMessage("selecting extreme points...\n");
1583 }
1584
1585 /* do not execute heuristic if no new selection of extreme points was found */
1586 if( !success )
1587 {
1588 SCIPdebugMessage("no proper selection could be created - aborting heuristic.\n");
1589
1591
1592 /* free memory */
1593 SCIPfreeBufferArray(scip, &selection);
1594 SCIPfreeBufferArray(scip, &subvars);
1595
1596 return SCIP_OKAY;
1597 }
1598
1599#ifdef PRINTPOINTS
1600 SCIP_CALL( printExtremePoints(scip, heurdata->nusedpts, selection) );
1601#endif
1602
1603 /* initialize the subproblem */
1604 SCIP_CALL( SCIPcreate(&subscip) );
1605 SCIP_CALL( setupSubproblem(scip, subscip, subvars, heurdata, nstallnodes, timelimit, memorylimit) );
1606 SCIPdebugMessage("XP Crossover subproblem: %d vars, %d conss\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip));
1607
1608 SCIPstatisticPrintf("xpcrossover statistic: called at node %"SCIP_LONGINT_FORMAT"\n", SCIPgetNNodes(scip));
1609
1610 /* fix the variables of the subproblem */
1611 SCIP_CALL( fixVariables(heurdata->gcg, subscip, subvars, selection, heurdata, &intfixingrate, &zerofixingrate, &success) );
1612
1613#ifdef SCIP_STATISTIC
1614 /* for final statistics */
1615 heurdata->avgfixrate += intfixingrate;
1616 heurdata->avgzerorate += zerofixingrate;
1617#endif
1618
1619 /* if creation of subscip was aborted (e.g. due to number of fixings), free subscip and abort */
1620 if( !success )
1621 {
1622 /* this run will be counted as a failure since the neighborhood of the
1623 * solution was not fruitful in the sense that it was too big
1624 */
1626#ifdef SCIP_STATISTIC
1627 ++heurdata->nfixfails;
1628#endif
1629 goto TERMINATE;
1630 }
1631
1633
1634 /* presolve the subproblem */
1635 retcode = SCIPpresolve(subscip);
1636
1637 /* errors in solving the subproblem should not kill the overall solving process;
1638 * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
1639 */
1640 if( retcode != SCIP_OKAY )
1641 {
1642#ifndef NDEBUG
1643 SCIP_CALL( retcode );
1644#endif
1645 SCIPwarningMessage(scip, "Error while presolving subproblem in XP Crossover heuristic; sub-SCIP terminated with code <%d>\n",retcode);
1646 goto TERMINATE;
1647 }
1648
1649 SCIPdebugMessage("XP Crossover presolved subproblem: %d vars, %d conss, success=%u\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip), success);
1650
1651 allfixingrate = (SCIPgetNOrigVars(subscip) - SCIPgetNVars(subscip)) / (SCIP_Real)SCIPgetNOrigVars(subscip);
1652
1653 /* additional variables added in presolving may lead to the subSCIP having more variables than the original */
1654 allfixingrate = MAX(allfixingrate, 0.0);
1655
1656 /* after presolving, we should have at least reached a certain fixing rate over ALL variables (including continuous)
1657 * to ensure that not only the MIP but also the LP relaxation is easy enough
1658 */
1659 if( allfixingrate >= heurdata->minfixingrate / 2.0 )
1660 {
1661 SCIP_SOL** subsols;
1662 int nsubsols;
1663
1664 /* solve the subproblem */
1665 SCIPdebugMessage("subSCIP: Solving... (node limit = %lld, time limit = %.2g)\n", nstallnodes, timelimit);
1666
1667 /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
1668 * Hence in optimized mode, the return code is catched and a warning is printed, only in debug mode, SCIP will stop.
1669 */
1670#ifdef NDEBUG
1671 retcode = SCIPsolve(subscip);
1672 if( retcode != SCIP_OKAY )
1673 {
1674 SCIPwarningMessage(scip, "Error while solving subproblem in XP Crossover heuristic; sub-SCIP terminated with code <%d>\n",
1675 retcode);
1676 }
1677#else
1678 SCIP_CALL( SCIPsolve(subscip) );
1679#endif
1680
1681#ifdef SCIP_STATISTIC
1682 heurdata->usednodes += SCIPgetNNodes(subscip);
1683 heurdata->subsciptime += SCIPgetTotalTime(subscip);
1684#endif
1685
1686 /* check, whether a solution was found;
1687 * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted
1688 */
1689 nsubsols = SCIPgetNSols(subscip);
1690 subsols = SCIPgetSols(subscip);
1691 success = FALSE;
1692#ifdef SCIP_STATISTIC
1693 heurdata->totalsols += nsubsols;
1694 for( i = 0; i < nsubsols; ++i )
1695#else
1696 for( i = 0; i < nsubsols && !success; ++i )
1697#endif
1698 {
1699 SCIP_CALL( createNewSol(scip, subscip, subvars, heur, subsols[i], &success) );
1700 if( success )
1702 }
1703
1704 SCIPstatisticPrintf("xpcrossover 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",
1705 intfixingrate, zerofixingrate, allfixingrate, SCIPgetSolvingTime(subscip), SCIPgetSolvingTime(scip), SCIPgetNNodes(subscip), nsubsols,
1706 success ? SCIPgetPrimalbound(scip) : SCIPinfinity(scip), nsubsols > 0 ? SCIPsolGetNodenum(SCIPgetBestSol(subscip)) : -1 );
1707
1708 if( !success )
1709 {
1710 /* if no new solution was found, run was a failure */
1712 SCIPdebugMessage(" -> no subMIP solution found - subSCIP status is %d\n", SCIPgetStatus(subscip));
1713 }
1714 }
1715 else
1716 {
1717 SCIPstatisticPrintf("xpcrossover statistic: fixed only %6.3f integer variables ( %6.3f zero), %6.3f all variables --> abort \n", intfixingrate, zerofixingrate, allfixingrate);
1718 }
1719
1720TERMINATE:
1721 /* free memory */
1722 SCIP_CALL( SCIPfree(&subscip) );
1723 SCIPfreeBufferArray(scip, &selection);
1724 SCIPfreeBufferArray(scip, &subvars);
1725
1726 return SCIP_OKAY;
1727}
1728
1729
1730
1731/*
1732 * primal heuristic specific interface methods
1733 */
1734
1735/** creates the Extreme Point Crossover primal heuristic and includes it in SCIP */
1737 GCG* gcg /**< GCG data structure */
1738 )
1739{
1741 SCIP_HEUR* heur;
1743
1744 /* create Extreme Point Crossover primal heuristic data */
1746 heurdata->gcg = gcg;
1747
1748 /* include primal heuristic */
1751 HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecXpcrossover, heurdata) );
1752
1753 assert(heur != NULL);
1754
1755 /* set non-NULL pointers to callback methods */
1756 SCIP_CALL( SCIPsetHeurFree(origprob, heur, heurFreeXpcrossover) );
1757 SCIP_CALL( SCIPsetHeurInit(origprob, heur, heurInitXpcrossover) );
1758 SCIP_CALL( SCIPsetHeurExit(origprob, heur, heurExitXpcrossover) );
1759#ifdef SCIP_STATISTIC
1760 SCIP_CALL( SCIPsetHeurInitsol(origprob, heur, heurInitsolXpcrossover) );
1761 SCIP_CALL( SCIPsetHeurExitsol(origprob, heur, heurExitsolXpcrossover) );
1762#endif
1763
1764 /* add Extreme Point Crossover primal heuristic parameters */
1765
1766 SCIP_CALL( SCIPaddLongintParam(origprob, "heuristics/"HEUR_NAME"/nodesofs",
1767 "number of nodes added to the contingent of the total nodes",
1769
1770 SCIP_CALL( SCIPaddLongintParam(origprob, "heuristics/"HEUR_NAME"/maxnodes",
1771 "maximum number of nodes to regard in the subproblem",
1773
1774 SCIP_CALL( SCIPaddLongintParam(origprob, "heuristics/"HEUR_NAME"/minnodes",
1775 "minimum number of nodes required to start the subproblem",
1777
1778 SCIP_CALL( SCIPaddIntParam(origprob, "heuristics/"HEUR_NAME"/nusedpts",
1779 "number of extreme pts per block that will be taken into account",
1780 &heurdata->nusedpts, FALSE, DEFAULT_NUSEDPTS, 2, INT_MAX, NULL, NULL) );
1781
1782 SCIP_CALL( SCIPaddRealParam(origprob, "heuristics/"HEUR_NAME"/nodesquot",
1783 "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1785
1786 SCIP_CALL( SCIPaddRealParam(origprob, "heuristics/"HEUR_NAME"/minfixingrate",
1787 "minimum percentage of integer variables that have to be fixed",
1789
1790 SCIP_CALL( SCIPaddRealParam(origprob, "heuristics/"HEUR_NAME"/minimprove",
1791 "factor by which crossover should at least improve the incumbent",
1793
1794 SCIP_CALL( SCIPaddBoolParam(origprob, "heuristics/"HEUR_NAME"/randomization",
1795 "should the choice which sols to take be randomized?",
1797
1798 SCIP_CALL( SCIPaddBoolParam(origprob, "heuristics/"HEUR_NAME"/copycuts",
1799 "if uselprows == FALSE, should all active cuts from cutpool be copied to constraints in subproblem?",
1801
1802 return SCIP_OKAY;
1803}
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)
SCIP_DECL_HASHGETKEY(SCIPhashGetKeyCons)
#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 GCGlinkingVarGetNBlocks(SCIP_VAR *var)
Definition gcgvar.c:572
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
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 SCIPhashtableFree(SCIP_HASHTABLE **hashtable)
SCIP_Bool SCIPhashtableExists(SCIP_HASHTABLE *hashtable, void *element)
SCIP_RETCODE SCIPhashtableCreate(SCIP_HASHTABLE **hashtable, BMS_BLKMEM *blkmem, int tablesize, SCIP_DECL_HASHGETKEY((*hashgetkey)), SCIP_DECL_HASHKEYEQ((*hashkeyeq)), SCIP_DECL_HASHKEYVAL((*hashkeyval)), void *userptr)
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_DECL_HASHKEYEQ(SCIPhashKeyEqString)
SCIP_DECL_HASHKEYVAL(SCIPhashKeyValString)
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)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPallocBlockMemory(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_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
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 SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
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 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 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_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbGlobal(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)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
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)
void SCIPsortInt(int *intarray, int len)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIP_Bool GCGvarIsPricing(SCIP_VAR *var)
Definition gcgvar.c:159
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
SCIP_RETCODE GCGincludeHeurXpcrossover(GCG *gcg)
static unsigned int calculateHashKey(int *indices, int size)
#define HASHSIZE_POINTS
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 createPtTuple(SCIP *scip, POINTTUPLE **elem, int *indices, int size, SCIP_HEURDATA *heurdata)
static SCIP_RETCODE selectExtremePointsRandomized(GCG *gcg, SCIP_HEURDATA *heurdata, int *selection, SCIP_Bool *success)
struct PointTuple POINTTUPLE
Extreme Point Crossover.
#define NULL
#define BMScopyMemoryArray(ptr, source, num)
#define SCIPstatisticPrintf
#define SCIPdebugPrintf
SCIP_SOL * GCGrelaxGetCurrentOrigSol(GCG *gcg)
Definition relax_gcg.c:4309
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
POINTTUPLE * prev
unsigned int key
SCIP_Longint nodesofs
SCIP_Real nodesquot
SCIP_HASHTABLE * hashtable
SCIP_Bool randomization
SCIP_RANDNUMGEN * randnumgen
SCIP_Real minimprove
SCIP_Longint nextnodenumber
POINTTUPLE * lasttuple
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
struct SCIP_HashTable SCIP_HASHTABLE
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