GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
automorphism.cpp
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 automorphism.cpp
30 * @brief automorphism recognition of SCIPs
31 * @author Daniel Peters
32 * @author Martin Bergner
33 * @author Jonas Witt
34 * @author Michael Bastubbe
35 *
36 */
37
38/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
39
40/* #define SCIP_DEBUG */
43#include "gcg/scip_misc.h"
44#include "scip/scip.h"
45#include "gcg/gcg.h"
46#include "scip/cons_linear.h"
49#include "gcg/cons_decomp.hpp"
50
51#include <cstring>
52
53/** saves information of the permutation */
55{
56 SCIP_Bool aut; /**< true if there is an automorphism */
57 unsigned int n; /**< number of permutations */
58 SCIP_HASHMAP* varmap; /**< hashmap for permutated variables */
59 SCIP_HASHMAP* consmap; /**< hashmap for permutated constraints */
60 SCIP** scips; /**< array of scips to search for automorphisms */
61 int* nodemap; /**< mapping of the nodes; filled generator-wise */
62 int* conssperm; /**< mapping of constraints */
63 gcg::DETPROBDATA* detprobdata; /**< problem information the automorphism should be searched for */
64 gcg::PARTIALDECOMP* partialdec; /**< decomposition information */
65 std::vector<int>* blocks; /**< array of blocks the automporphisms are searched for */
66 SCIP* scip; /**< SCIP data structure */
67 int ncalls; /**< number of calls of this hook */
68 int generatorlimit; /**< generator limit */
69 AUT_GRAPH* graph; /**< graph used to search for automorphisms */
70
71
72 /** constructor for the hook struct*/
74 SCIP_HASHMAP* varmap_, /**< hashmap for permutated variables */
75 SCIP_HASHMAP* consmap_, /**< hashmap for permutated constraints */
76 unsigned int n_, /**< number of permutations */
77 AUT_GRAPH* graph_, /**< graph used to search for automorphisms */
78 gcg::PARTIALDECOMP* partialdec_, /**< partialdec the graphs should be compared for */
79 std::vector<int>* blocks_ /**< array of blocks the automporphisms are searched for */
80 );
81
82 /** destructor for hook struct */
83 ~AUT_HOOK2();
84
85
86 /** getter for the bool aut */
88
89 /** setter for the bool aut */
90 void setBool(SCIP_Bool aut);
91
92 /** getter for the number of nodes */
93 unsigned int getNNodes();
94
95 /** getter for the variables hashmap */
97
98 /** getter for the constraints hashmap */
100
101 /** getter for the graph */
103};
104
105
107{
108 aut = aut_;
109}
110
111
113{ /*lint -esym(1540,struct_hook::conssperm) */
115 if( conssperm != NULL )
117 conssperm = NULL;
120}
121
122
123
125{
126 return aut;
127}
128
130{
131 return n;
132}
133
138
143
145{
146 return graph;
147}
148
149/** constructor of the hook struct */
151 SCIP_HASHMAP* varmap_, /**< hashmap of permutated variables */
152 SCIP_HASHMAP* consmap_, /**< hahsmap of permutated constraints */
153 unsigned int n_, /**< number of permutations */
154 AUT_GRAPH* graph_, /**< graph used to search for automorphisms */
155 gcg::PARTIALDECOMP* partialdec_, /**< partialdec the graphs should be compared for */
156 std::vector<int>* blocks_ /**< array of blocks the automporphisms are searched for */
157 )
158{
159 size_t i;
160 aut = FALSE;
161 n = n_;
162 consmap = consmap_;
163 varmap = varmap_;
164 graph = graph_;
165 partialdec = partialdec_;
168 blocks = blocks_;
169 SCIP_CALL_ABORT( SCIPallocMemoryArray(scip, &nodemap, n_) ); /*lint !e666*/
170 for (i = 0; i < n_; ++i)
171 nodemap[i] = -1;
172 conssperm = NULL;
173 ncalls = 0;
174 generatorlimit = 0;
175
177}
178
179/** hook function to save the permutation of the graph; fhook() is called by metis for every generator,
180 * AUT_HOOK* hook stores a combined mapping in nodemapping that is filled generator-wise */
181static
182void fhook(
183 void* user_param, /**< data structure to save hashmaps with permutation */
184 unsigned int N, /**< number of permutations */
185 const unsigned int* aut /**< array of permutations */
186 )
187{ /*lint -e715*/
188
189 unsigned int i;
190 unsigned int j;
191 unsigned int n;
192 int nvars;
193 int nconss;
194 SCIP_VAR** vars1 = NULL;
195 SCIP_VAR** vars2 = NULL;
196 SCIP_CONS** conss1 = NULL;
197 SCIP_CONS** conss2 = NULL;
198 SCIP* partialdecscip = NULL;
199 gcg::DETPROBDATA* detprobdata = NULL;
200 gcg::PARTIALDECOMP* partialdec = NULL;
201 AUT_HOOK2* hook = (AUT_HOOK2*) user_param;
202
203 j = 0;
204 n = hook->getNNodes();
205
206 /* new detection stuff */
207 partialdec = hook->partialdec;
208 detprobdata = hook->detprobdata;
209 partialdecscip = NULL;
210
211 ++hook->ncalls;
212
213 if( hook->getBool() )
214 return;
215
216 // fallback check if library does not support termination
217 if( hook->generatorlimit > 0 && hook->ncalls > hook->generatorlimit )
218 {
219 hook->setBool(false);
220 return;
221 }
222
223 // SCIPdebugMessage("Looking for a permutation from [0,%u] bijective to [%u:%u] (N=%u) \n", n/2-1, n/2, n-1, N);
224 for( i = 0; i < n / 2; i++ )
225 {
226 assert(aut[i] < INT_MAX);
227
228 if( (aut[i]) >= n / 2 && hook->nodemap[i] == -1 )
229 {
230 assert(aut[i] < n);
231// SCIPdebugMessage("current generator: %u -> %u\n", i, aut[i]);
232 hook->nodemap[i] = aut[i];
233 }
234 }
235
236 for( i = 0; i < n / 2; i++ )
237 {
238// SCIPdebugMessage("general mapping : %u -> %u\n", i, hook->nodemap[i]);
239 if( hook->nodemap[i] >= (int) n / 2 )
240 ++j;
241 }
242
243 if( j == n / 2 )
244 {
245 hook->setBool(TRUE);
246 }
247
248 for( i = n; i < N; ++i )
249 {
250 if( aut[i] != i )
251 {
252 // SCIPdebugMessage("Master %u -> %u not the identity, no decomposition possible!\n", i, aut[i]);
253 hook->setBool(false);
254 break;
255 }
256 }
257
258// SCIPdebugMessage("Permutation %s found.\n", hook->getBool() ? "":"not");
259// SCIPdebugMessage("j = %u\n", j);
260
261 if( !hook->getBool() )
262 return;
263
264
265 nvars = partialdec->getNVarsForBlock((*hook->blocks)[0]);
266
267 assert(nvars == partialdec->getNVarsForBlock((*hook->blocks)[1]) );
268
269 partialdecscip = detprobdata->getScip();
270
271 SCIP_CALL_ABORT(SCIPallocBufferArray(partialdecscip, &vars1, nvars ));
272 SCIP_CALL_ABORT(SCIPallocBufferArray(partialdecscip, &vars2, nvars ));
273 nconss = partialdec->getNConssForBlock((*hook->blocks)[0]);
274 assert(nconss == partialdec->getNConssForBlock((*hook->blocks)[1]));
275
276 SCIP_CALL_ABORT( SCIPallocBufferArray(partialdecscip, &conss1, nconss ) );
277 SCIP_CALL_ABORT( SCIPallocBufferArray(partialdecscip, &conss2, nconss ) );
278
279 for( int v = 0; v < nvars; ++v )
280 {
281 vars1[v] = detprobdata->getVar(partialdec->getVarsForBlock((*hook->blocks)[0])[v]);
282 vars2[v] = detprobdata->getVar(partialdec->getVarsForBlock((*hook->blocks)[1])[v]);
283 }
284
285 for( int c = 0; c < nconss; ++c )
286 {
287 conss1[c] = detprobdata->getCons(partialdec->getConssForBlock((*hook->blocks)[0])[c]);
288 conss2[c] = detprobdata->getCons(partialdec->getConssForBlock((*hook->blocks)[1])[c]);
289 }
290
291 for( i = 0; i < (unsigned int) nvars+nconss; i++ )
292 {
293 /* Assuming the following layout:
294 * 0 ... nconss-1 = vertex ids for constraints
295 * nconss ... nconss+nvars-1 = vertex ids for variables
296 * nconss+nvars ... n-1 = nonzero entries (not relevant)
297 */
298 if( i < (unsigned int) nconss )
299 {
300 unsigned int consindex = i;
301 unsigned int consindex2 = hook->nodemap[i]-n/2;
302 assert( consindex2 < (unsigned int) nconss);
303 SCIP_CONS* cons1 = conss1[consindex];
304 SCIP_CONS* cons2 = conss2[consindex2];
305 SCIP_CALL_ABORT( SCIPhashmapInsert(hook->getConsHash(), cons2, cons1) );
306 SCIPdebugMessage("cons <%s> <-> cons <%s>\n", SCIPconsGetName(cons2), SCIPconsGetName(cons1));
307 }
308 else if( i < (unsigned int) nvars+nconss )
309 {
310 unsigned int varindex = i-nconss;
311 unsigned int varindex2 = hook->nodemap[i]-nconss-n/2;
312 assert( varindex2 < (unsigned int) nvars);
313 SCIP_VAR* var1 = vars1[varindex];
314 SCIP_VAR* var2 = vars2[varindex2];
315 SCIP_CALL_ABORT( SCIPhashmapInsert(hook->getVarHash(), var2, var1) );
316 SCIPdebugMessage("var <%s> <-> var <%s>\n", SCIPvarGetName(var2), SCIPvarGetName(var1));
317 }
318 }
319
320 partialdecscip = detprobdata->getScip();
321 SCIPfreeBufferArray(partialdecscip, &conss1);
322 SCIPfreeBufferArray(partialdecscip, &conss2);
323 SCIPfreeBufferArray(partialdecscip, &vars1);
324 SCIPfreeBufferArray(partialdecscip, &vars2);
325
326 hook->getGraph()->terminateSearch();
327}
328
329
330/** constructor for colorinfo arrays */
332 SCIP* scip, /**< SCIP data structure */
333 gcg::DETPROBDATA* detprobdata, /**< SCIP data structure */
334 AUT_COLOR* colorinfo, /**< struct to save intermediate information */
335 int nconss, /**< number of constraints */
336 int nvars, /**< number of variables */
337 int ncoeffs /**< number of coefficients */
338 )
339{
340 SCIP_CALL( SCIPallocMemoryArray(scip, &colorinfo->ptrarraycoefs, ((size_t) ncoeffs )));
341 colorinfo->alloccoefsarray = ncoeffs;
342 SCIP_CALL( SCIPallocMemoryArray(scip, &colorinfo->ptrarrayvars, (size_t) nvars));
343 SCIP_CALL( SCIPallocMemoryArray(scip, &colorinfo->ptrarrayconss, (size_t) nconss));
344 return SCIP_OKAY;
345}
346
347
348/** destructor for colorinfoarrays */
349static
351 SCIP* scip, /**< SCIP data structure */
352 AUT_COLOR* colorinfo /**< struct to save intermediate information */
353 )
354{
355 int i;
356
357 for(i = 0; i < colorinfo->lenvarsarray; i++ ){
358 AUT_VAR* svar = (AUT_VAR*) colorinfo->ptrarrayvars[i];
359 delete svar;
360 }
361 for(i = 0; i < colorinfo->lenconssarray; i++ ){
362 AUT_CONS* scons = (AUT_CONS*) colorinfo->ptrarrayconss[i];
363 delete scons;
364 }
365 for(i = 0; i < colorinfo->lencoefsarray; i++ ){
366 AUT_COEF* scoef = (AUT_COEF*) colorinfo->ptrarraycoefs[i];
367 delete scoef;
368 }
369
370 SCIPfreeMemoryArray(scip, &colorinfo->ptrarraycoefs);
371 SCIPfreeMemoryArray(scip, &colorinfo->ptrarrayconss);
372 SCIPfreeMemoryArray(scip, &colorinfo->ptrarrayvars);
373 return SCIP_OKAY;
374}
375
376
377/** set up a help structure for graph creation for new detection loop*/
378static
380 SCIP* scip, /**< SCIP data structure */
381 gcg::DETPROBDATA* detprobdata, /**< detprobdata corresponing to presolved or unpresolved problem */
382 gcg::PARTIALDECOMP* partialdec, /**< partial decomp the symmetry for two blocks is checked for */
383 int nblocks, /**< number of blocks the symmetry should be checked for */
384 std::vector<int> blocks, /**< vectors of block indices the symmetry be checked for */
385 AUT_COLOR* colorinfo, /**< data structure to save intermediate data */
386 SCIP_RESULT* result /**< result pointer to indicate success or failure */
387 )
388{ /*lint -esym(593, scoef) */
389 int i;
390 int j;
391 int b;
392 int nconss;
393 int nvars;
394 SCIP_Bool added;
395
396 added = FALSE;
397
398 //allocate max n of coefarray, varsarray, and boundsarray in origscip
399 nconss = partialdec->getNConssForBlock(blocks[0]) ;
400 nvars = partialdec->getNVarsForBlock(blocks[0]) ;
401 colorinfo->setOnlySign(FALSE);
402
403 for( b = 0; b < nblocks && *result == SCIP_SUCCESS; ++b )
404 {
405 int block = blocks[b];
406
407 assert( partialdec->getNVarsForBlock(blocks[b]) == nvars );
408 assert( partialdec->getNConssForBlock(blocks[b]) == nconss );
409
410 SCIPdebugMessage("Handling block %i (id %d %d x %d)\n", b, block, partialdec->getNConssForBlock(blocks[b]), partialdec->getNVarsForBlock(blocks[b]));
411 //save the properties of variables in a struct array and in a sorted pointer array
412 for( i = 0; i < nvars; i++ )
413 {
414 SCIP_VAR* var;
415 AUT_VAR* svar;
416
417 var = detprobdata->getVar(partialdec->getVarsForBlock(block)[i]);
418 svar = new AUT_VAR(scip, var);
419 //add to pointer array iff it doesn't exist
420 SCIP_CALL( colorinfo->insert(svar, &added) );
421 if( b > 0 && added)
422 {
424 break;
425 }
426 //otherwise free allocated memory
427 if( !added )
428 delete svar;
429 }
430 //save the properties of constraints in a struct array and in a sorted pointer array
431 for( i = 0; i < nconss && *result == SCIP_SUCCESS; i++ )
432 {
433 int consid;
434 SCIP_CONS* cons;
435
436 consid = partialdec->getConssForBlock(block)[i];
437 cons = detprobdata->getCons(consid);
438
439 if( detprobdata->getNVarsForCons(consid) == 0 )
440 continue;
441
442 AUT_CONS* scons = new AUT_CONS(scip, cons);
443 //add to pointer array iff it doesn't exist
444 SCIP_CALL( colorinfo->insert(scons, &added) );
445 if( b > 0 && added)
446 {
448 break;
449 }
450 //otherwise free allocated memory
451 if( !added )
452 delete scons;
453
454 //save the properties of variables of the constraints in a struct array and in a sorted pointer array
455 for( j = 0; j < detprobdata->getNVarsForCons(consid); j++ )
456 {
457 SCIP_Real val;
458 AUT_COEF* scoef;
459 val = detprobdata->getVal(consid, detprobdata->getVarsForCons(consid)[j]);
460 scoef = new AUT_COEF(scip, val );
461 //test, whether the coefficient is not zero
462 if( !SCIPisZero(scip, scoef->getVal()) )
463 {
464 //add to pointer array iff it doesn't exist
465 SCIP_CALL( colorinfo->insert(scoef, &added) );
466 if( b > 0 && added)
467 {
469 break;
470 }
471 }
472 //otherwise free allocated memory
473 if( !added )
474 delete scoef;
475 }
476 }
477 }
478
479 /* add color information for master constraints */
480 for( i = 0; i < partialdec->getNMasterconss() && *result == SCIP_SUCCESS; ++i )
481 {
482 int masterconsid;
483 SCIP_CONS* mastercons;
484
485 masterconsid = partialdec->getMasterconss()[i];
486 mastercons = detprobdata->getCons(masterconsid);
487
488 /* add right color for master constraint */
489 AUT_CONS* scons = new AUT_CONS(scip, mastercons);
490 SCIP_CALL( colorinfo->insert(scons, &added) );
491
492 /* if it hasn't been added, it is already present */
493 if(!added)
494 delete scons;
495
496 for( j = 0; j < detprobdata->getNVarsForCons(masterconsid); ++j )
497 {
498 AUT_COEF* scoef;
499 int varid;
500
501 varid = detprobdata->getVarsForCons(masterconsid)[j];
502 scoef= new AUT_COEF(scip, detprobdata->getVal(masterconsid, varid) );
503
504 added = FALSE;
505
506 if( !SCIPisZero(scip, scoef->getVal()) )
507 {
508 SCIP_CALL( colorinfo->insert(scoef, &added) );
509 }
510
511 if( !added )
512 delete scoef;
513 }
514 }
515
516 return SCIP_OKAY;
517}
518
519/** create a graph out of an array of scips */
520static
522 SCIP* scip, /**< SCIP data structure */
523 gcg::DETPROBDATA* detprobdata, /**< detection process information and data */
524 gcg::PARTIALDECOMP* partialdec, /**< partial decomposition */
525 std::vector<int> blocks, /**< vectors of block indices the symmetry be checked for */
526 AUT_COLOR colorinfo, /**< data structure to save intermediate data */
527 AUT_GRAPH* graph, /**< graph needed for discovering isomorphism */
528 int* pricingnodes, /**< number of pricing nodes without master */
529 SCIP_RESULT* result /**< result pointer to indicate success or failure */
530 )
531{
532 int i;
533 int j;
534 int b;
535 int ncurvars;
536 int* nnodesoffset;
537 int color;
538 int nconss;
539 int nvars;
540 int currentnode;
541 int* pricingnonzeros;
542 int* mastercoefindex;
543 unsigned int nconsvarpairs;
544 unsigned int nmasterconsnzs;
545 unsigned int nnodes;
546 unsigned int nnonemptyconss;
547 int nblocks = (int)blocks.size();
548 std::vector<bool> masterconssrelevant(partialdec->getNMasterconss(), false);
549
550 if( *result != SCIP_SUCCESS )
551 return SCIP_OKAY;
552
553 pricingnonzeros = NULL;
554 mastercoefindex = NULL;
555 nnodesoffset = NULL;
556
557 currentnode = 0;
558
559 scip = detprobdata->getScip();
560
561 SCIP_CALL( SCIPallocBufferArray(scip, &mastercoefindex, nblocks) );
562 BMSclearMemoryArray(mastercoefindex, nblocks);
563
564 nconss = partialdec->getNConssForBlock(blocks[0]);
565 nvars = partialdec->getNVarsForBlock(blocks[0]);
566
567 SCIP_CALL( SCIPallocBufferArray(scip, &nnodesoffset, nblocks) );
568 BMSclearMemoryArray(nnodesoffset, nblocks);
569 SCIP_CALL( SCIPallocBufferArray(scip, &pricingnonzeros, nblocks) );
570 BMSclearMemoryArray(pricingnonzeros, nblocks);
571
572 nconsvarpairs = 0;
573 nnonemptyconss = 0;
574 for( i = 0; i < nconss; i++ )
575 {
576 ncurvars = detprobdata->getNVarsForCons(partialdec->getConssForBlock(blocks[0])[i]);
577 if( ncurvars > 0 )
578 {
579 nconsvarpairs += ncurvars;
580 nnonemptyconss++;
581 }
582 }
583
584 nmasterconsnzs = 0;
585 for( i = 0; i < partialdec->getNMasterconss(); ++i )
586 nmasterconsnzs += partialdec->getNVarsOfBlockInMasterCons(i, blocks[0]);
587
588 nnodes = nblocks * (nnonemptyconss + nvars + nconsvarpairs + nmasterconsnzs) + partialdec->getNMasterconss();
589 graph->init(scip, nnodes);
590
591 for( b = 0; b < nblocks && *result == SCIP_SUCCESS; ++b )
592 {
593 int block = blocks[b];
594 int z = 0;
595
596 SCIPdebugMessage("Pricing problem %d\n", block);
597
598 nnodesoffset[b] = currentnode;
599
600 //add a node for every constraint
601 for( i = 0; i < nconss && *result == SCIP_SUCCESS; i++ )
602 {
603 int consid;
604 SCIP_CONS* cons;
605
606 consid = partialdec->getConssForBlock(block)[i];
607 ncurvars = detprobdata->getNVarsForCons(consid);
608 cons = detprobdata->getCons(consid);
609
610 if( ncurvars == 0 )
611 continue;
612
613 color = colorinfo.get( AUT_CONS(scip, cons) );
614
615 if(color == -1)
616 {
618 break;
619 }
620
621 SCIPdebugMessage("cons <%s> color %d\n", SCIPconsGetName(cons), color);
622 graph->setColor(currentnode, color);
623 currentnode++;
624 }
625 //add a node for every variable
626 for( i = 0; i < nvars && *result == SCIP_SUCCESS; i++ )
627 {
628 int varid;
629 SCIP_VAR* var;
630
631 varid = partialdec->getVarsForBlock(block)[i];
632 var = detprobdata->getVar(varid);
633
634 color = colorinfo.get( AUT_VAR(scip, var) );
635
636 if(color == -1) {
638 break;
639 }
640
641 SCIPdebugMessage("var <%s> color %d\n", SCIPvarGetName(var), color);
642 graph->setColor(currentnode, colorinfo.getLenCons() + color);
643 currentnode++;
644 }
645 //connecting the nodes with an additional node in the middle
646 //it is necessary, since only nodes have colors
647 for( i = 0; i < nconss && *result == SCIP_SUCCESS; i++ )
648 {
649 int consid;
650 SCIP_CONS* cons;
651 int conscolor;
652
653 consid = partialdec->getConssForBlock(block)[i];
654 ncurvars = detprobdata->getNVarsForCons(consid);
655 cons = detprobdata->getCons(consid);
656 conscolor = colorinfo.get(AUT_CONS(scip, cons));
657
658 if( ncurvars == 0 )
659 continue;
660
661 for( j = 0; j < ncurvars; j++ )
662 {
663 int varcolor;
664 int varid;
665 SCIP_VAR* var;
666 SCIP_Real val;
667
668 varid = detprobdata->getVarsForCons(consid)[j];
669 var = detprobdata->getVar(varid);
670
671 val = detprobdata->getVal(consid, varid);
672
673 varcolor = colorinfo.get( AUT_VAR(scip, var )) + colorinfo.getLenCons(); /*lint !e864 */
674 color = colorinfo.get( AUT_COEF(scip, val ));
675 if( color == -1 )
676 {
678 break;
679 }
680 color += colorinfo.getLenCons() + colorinfo.getLenVar(); /*lint !e864 */
681 graph->setColor(currentnode, color);
682 currentnode++;
683 graph->addEdge(nnodesoffset[b] + i, nnodesoffset[b] + nconss + nvars + z);
684 graph->addEdge(nnodesoffset[b] + nconss + nvars + z, nnodesoffset[b]+nconss + partialdec->getVarProbindexForBlock(varid, block) );
685 SCIPdebugMessage("nz: c <%s> (id: %d, color: %d) -> nz (id: %d) (value: %f, color: %d) -> var <%s> (id: %d, color: %d) \n",
686 SCIPconsGetName(cons),
687 nnodesoffset[b] + i,
688 conscolor,
689 nnodesoffset[b] + nconss + nvars + z,
690 val,
691 color+colorinfo.getLenCons() + colorinfo.getLenVar(), /*lint !e864 */
693 nnodesoffset[b]+nconss + partialdec->getVarProbindexForBlock(varid, block),
694 varcolor);
695 z++;
696 }
697 }
698 pricingnonzeros[b] = z;
699
700 /* add coefficient nodes for nonzeros in the master */
701 for( i = 0; i < partialdec->getNMasterconss() && *result == SCIP_SUCCESS; ++i )
702 {
703 int masterconsid;
704
705 masterconsid = partialdec->getMasterconss()[i];
706 ncurvars = detprobdata->getNVarsForCons(masterconsid);
707
708 for( j = 0; j < ncurvars; ++j )
709 {
710 int varid;
711 SCIP_VAR* var;
712 SCIP_Real val;
713
714 varid = detprobdata->getVarsForCons(masterconsid)[j];
715 /* ignore if the variable belongs to a different block */
716 if( !partialdec->isVarBlockvarOfBlock(varid, block) )
717 {
718// SCIPdebugMessage("Var <%s> belongs to a different block (%d)\n", SCIPvarGetName(detprobdata->getVar(varid) ), block);
719 continue;
720 }
721
722 var = detprobdata->getVar(varid);
723 val = detprobdata->getVal(masterconsid, varid);
724 color = colorinfo.get(AUT_COEF(scip, val));
725 assert(color != -1);
726 color += colorinfo.getLenCons() + colorinfo.getLenVar(); /*lint !e864 */
727
728 masterconssrelevant[i] = true;
729
730 /* add coefficent node for current coeff */
731 graph->setColor(currentnode, color);
732 assert(ABS(val) < SCIPinfinity(scip));
733 SCIPdebugMessage("master nz for var <%s> (id: %d) (value: %f, color: %d)\n", SCIPvarGetName(var), currentnode, val, color);
734 currentnode++;
735 }
736 }
737 SCIPdebugMessage("Iteration %d: currentnode = %d\n", b, currentnode);
738 }
739 /* connect the created graphs with nodes for the master problem */
740
741 SCIPdebugMessage( "handling %d masterconss\n", partialdec->getNMasterconss());
742 *pricingnodes = currentnode;
743
744 for( i = 0; i < partialdec->getNMasterconss() && *result == SCIP_SUCCESS; ++i )
745 {
746 int masterconsid;
747 SCIP_CONS* mastercons;
748 int masterconsnode;
749 int conscolor;
750
751 /**experimental */
752 if( !masterconssrelevant[i] ) {
753 currentnode++;
754 continue;
755 }
756 /*experimental end */
757
758 masterconsid= partialdec->getMasterconss()[i];
759 mastercons = detprobdata->getCons(masterconsid);
760 ncurvars = detprobdata->getNVarsForCons(masterconsid);
761
762 SCIPdebugMessage("Handling cons <%s>\n", SCIPconsGetName(mastercons));
763
764 /* create node for masterconss and get right color */
765 conscolor = colorinfo.get(AUT_CONS(scip, mastercons) );
766 assert(conscolor != -1);
767 graph->setColor(currentnode, conscolor);
768 masterconsnode = currentnode;
769 currentnode++;
770
771 for( j = 0; j < ncurvars; ++j )
772 {
773 int varid;
774 SCIP_VAR* var;
775 SCIP_Real val;
776 int blockid;
777 int coefnodeindex;
778 int bid;
779 int varcolor;
780
781 blockid = -1;
782 bid = -1;
783 varid = detprobdata->getVarsForCons(masterconsid)[j];
784
785 var = detprobdata->getVar(varid);
786
787 for( b = 0; b < nblocks; ++b )
788 {
789 if( partialdec->isVarBlockvarOfBlock(varid, blocks[b]) )
790 {
791 bid = b;
792 blockid = blocks[b];
793 break;
794 }
795 }
796
797 /* ignore if the variable belongs to a different block */
798 if( blockid == -1 )
799 {
800 //SCIPdebugMessage("Var <%s> belongs to a different block \n", SCIPvarGetName(var));
801 continue;
802 }
803 val = detprobdata->getVal(masterconsid, varid);
804
805 color = colorinfo.get(AUT_COEF(scip, val));
806 assert(color != -1);
807 color += colorinfo.getLenCons() + colorinfo.getLenVar(); /*lint !e864 */
808
809 /* get coefficient node for current coefficient */
810 coefnodeindex = nnodesoffset[bid] + nvars + nconss + pricingnonzeros[bid] + mastercoefindex[bid];
811 ++(mastercoefindex[bid]);
812
813 varcolor = colorinfo.get(AUT_VAR(scip, var));
814 assert(varcolor != -1);
815 varcolor += colorinfo.getLenCons();
816
817 assert( (unsigned int) masterconsnode < graph->getNVertices());
818 assert( (unsigned int) coefnodeindex < graph->getNVertices());
819 /* master constraint and coefficient */
820 graph->addEdge(masterconsnode, coefnodeindex);
821 SCIPdebugMessage("ma: c <%s> (id: %d, color: %d) -> nz (id: %d) (value: <%.6f> , color: %d) -> pricingvar <%s> (id: %d, color: %d)\n",
822 SCIPconsGetName(mastercons),
823 masterconsnode, conscolor, coefnodeindex, val, color, SCIPvarGetName(var),
824 nnodesoffset[bid] + nconss + varid, varcolor);
825
826 /* get node index for pricing variable and connect masterconss, coeff and pricingvar nodes */
827 graph->addEdge(coefnodeindex, nnodesoffset[bid] + nconss + partialdec->getVarProbindexForBlock(varid, blockid));
828 }
829 }
830
831#ifndef NDEBUG
832 if( *result == SCIP_SUCCESS )
833 assert(currentnode == (int) nnodes);
834#endif
835
836 //free all allocated memory
837 SCIPfreeBufferArray(scip, &pricingnonzeros);
838 SCIPfreeBufferArray(scip, &nnodesoffset);
839 SCIPfreeBufferArray(scip, &mastercoefindex);
840
841 return SCIP_OKAY;
842}
843
844/** compare two graphs w.r.t. automorphism */
846 SCIP* scip, /**< SCIP data structure */
847 gcg::PARTIALDECOMP* partialdec, /**< partialdec the graphs should be compared for */
848 int block1, /**< index of first pricing prob */
849 int block2, /**< index of second pricing prob */
850 SCIP_RESULT* result, /**< result pointer to indicate success or failure */
851 SCIP_HASHMAP* varmap, /**< hashmap to save permutation of variables */
852 SCIP_HASHMAP* consmap, /**< hashmap to save permutation of constraints */
853 unsigned int searchnodelimit, /**< search node limit */
854 unsigned int generatorlimit /**< generator limit */
855 )
856{
857 AUT_GRAPH graph;
858 AUT_HOOK2 *ptrhook;
859 AUT_COLOR colorinfo;
860 std::vector<int> blocks(2, -1);
861 gcg::DETPROBDATA* detprobdata;
862 int nconss;
863 int nvars;
864 int ncoeffs;
865
866 int pricingnodes;
867
869
870 assert(partialdec != NULL );
871
872 blocks[0] = block1;
873 blocks[1] = block2;
874 pricingnodes = 0;
875
876 detprobdata = partialdec->getDetprobdata();
877
878 assert(detprobdata != NULL);
879
880 //allocate max n of coefarray, varsarray, and boundsarray in origscip
881 nconss = partialdec->getNConssForBlock(blocks[0]) ;
882 nvars = partialdec->getNVarsForBlock(blocks[0]) ;
883 ncoeffs = partialdec->getNCoeffsForBlock( blocks[0]);
884 SCIP_CALL( allocMemoryNewDetection(scip, detprobdata, &colorinfo, nconss*2+partialdec->getNMasterconss(), nvars*2, ncoeffs*2 + partialdec->getNCoeffsForMaster() ) );
885 SCIP_CALL( setuparraysnewdetection(scip, detprobdata, partialdec, 2, blocks, &colorinfo, result) );
886 SCIPdebugMessage("finished setup array method.\n");
887 if( *result == SCIP_SUCCESS )
888 {
889 SCIP_CALL( createGraphNewDetection(scip, detprobdata, partialdec, blocks, colorinfo, &graph, &pricingnodes, result) );
890 SCIPdebugMessage("finished create graph.\n");
891 ptrhook = new AUT_HOOK2(varmap, consmap, (unsigned int) pricingnodes, &graph, partialdec, &blocks);
892 ptrhook->generatorlimit = generatorlimit;
893 SCIPdebugMessage("finished creating aut hook.\n");
894
895 graph.findAutomorphisms(ptrhook, &fhook, searchnodelimit, generatorlimit);
896
897 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL , NULL, "finished calling bliss: number of reporting function calls (=number of generators): %d \n", ptrhook->ncalls);
898 if( !ptrhook->getBool() )
900 graph.destroy();
901 delete ptrhook;
902 }
903 SCIP_CALL( freeMemory(scip, &colorinfo) );
904
905 SCIPdebugMessage("finished find automorphisms.\n");
906
907 return SCIP_OKAY;
908}
909
910static
912 SCIP* scip, /**< SCIP data structure */
913 SCIP_Real val /**< value */
914 )
915{
916 if( SCIPisNegative(scip, val) )
917 return -1;
918 if( SCIPisPositive(scip, val) )
919 return 1;
920 else
921 return 0;
922}
923
924/** compare two values of two scips */
925static
927 SCIP* scip, /**< SCIP data structure */
928 SCIP_Real val1, /**< value 1 to compare */
929 SCIP_Real val2, /**< value 2 to compare */
930 SCIP_Bool onlysign /**< use sign of values instead of values? */
931 )
932{
933 SCIP_Real compval1;
934 SCIP_Real compval2;
935
936 if( onlysign )
937 {
938 compval1 = getSign(scip, val1);
939 compval2 = getSign(scip, val2);
940 }
941 else
942 {
943 compval1 = val1;
944 compval2 = val2;
945 }
946
947
948 if( SCIPisLT(scip, compval1, compval2) )
949 return -1;
950 if( SCIPisGT(scip, compval1, compval2) )
951 return 1;
952 else
953 return 0;
954}
955
956/** compare two constraints of two scips */
957static
959 SCIP* scip, /**< SCIP data structure */
960 AUT_CONS* cons1, /**< constraint 1 to compare */
961 AUT_CONS* cons2, /**< constraint 2 to compare */
962 SCIP_Bool onlysign /**< use sign of values instead of values? */
963 )
964{
965 if( comp(scip, GCGconsGetRhs(scip, cons1->getCons()), GCGconsGetRhs(scip, cons2->getCons()), onlysign) != 0 )
966 return comp(scip, GCGconsGetRhs(scip, cons1->getCons()), GCGconsGetRhs(scip, cons2->getCons()), onlysign);
967 assert(SCIPisEQ(scip, GCGconsGetRhs(scip, cons1->getCons()), GCGconsGetRhs(scip, cons2->getCons())) || onlysign);
968
969 if( comp(scip, GCGconsGetLhs(scip, cons1->getCons()), GCGconsGetLhs(scip, cons2->getCons()), onlysign) != 0 )
970 return comp(scip, GCGconsGetLhs(scip, cons1->getCons()), GCGconsGetLhs(scip, cons2->getCons()), onlysign);
971 assert(SCIPisEQ(scip, GCGconsGetLhs(scip, cons1->getCons()), GCGconsGetLhs(scip, cons2->getCons())) || onlysign);
972
973 if( comp(scip, GCGconsGetNVars(scip, cons1->getCons()), GCGconsGetNVars(scip, cons2->getCons()), FALSE) != 0 )
974 return comp(scip, GCGconsGetNVars(scip, cons1->getCons()), GCGconsGetNVars(scip, cons2->getCons()), FALSE);
975 assert(SCIPisEQ(scip, GCGconsGetNVars(scip, cons1->getCons()), GCGconsGetNVars(scip, cons2->getCons())));
976
977 return strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons1->getCons())), SCIPconshdlrGetName(SCIPconsGetHdlr(cons2->getCons())));
978}
979
980
981/** compare two variables of two scips */
982static
984 SCIP* scip, /**< SCIP data structure */
985 AUT_VAR* var1, /**< variable 1 to compare */
986 AUT_VAR* var2, /**< variable 2 to compare */
987 SCIP_Bool onlysign /**< use sign of values instead of values? */
988 )
989{
990 SCIP_VAR* origvar1;
991 SCIP_VAR* origvar2;
992
993 if( GCGvarIsPricing(var1->getVar()) )
994 origvar1 = GCGpricingVarGetOriginalVar(var1->getVar());
995 else
996 origvar1 = var1->getVar();
997
998 if( GCGvarIsPricing(var2->getVar()) )
999 origvar2 = GCGpricingVarGetOriginalVar(var2->getVar());
1000 else
1001 origvar2 = var2->getVar();
1002
1003 if( comp(scip, SCIPvarGetUbGlobal(origvar1), SCIPvarGetUbGlobal(origvar2), onlysign) != 0 )
1004 return comp(scip, SCIPvarGetUbGlobal(origvar1), SCIPvarGetUbGlobal(origvar2), onlysign);
1005 assert(SCIPisEQ(scip, SCIPvarGetUbGlobal(origvar1), SCIPvarGetUbGlobal(origvar2)) || onlysign);
1006
1007 if( comp(scip, SCIPvarGetLbGlobal(origvar1), SCIPvarGetLbGlobal(origvar2), onlysign) != 0 )
1008 return comp(scip, SCIPvarGetLbGlobal(origvar1), SCIPvarGetLbGlobal(origvar2), onlysign);
1009 assert(SCIPisEQ(scip, SCIPvarGetLbGlobal(origvar1), SCIPvarGetLbGlobal(origvar2)) || onlysign);
1010
1011 if( comp(scip, SCIPvarGetObj((origvar1)), SCIPvarGetObj(origvar2), onlysign) != 0 )
1012 return comp(scip, SCIPvarGetObj(origvar1), SCIPvarGetObj(origvar2), onlysign);
1013 assert(SCIPisEQ(scip, SCIPvarGetObj(origvar1), SCIPvarGetObj(origvar2)) || onlysign);
1014
1015 if( SCIPvarGetType(origvar1) < SCIPvarGetType(origvar2) )
1016 return -1;
1017 if( SCIPvarGetType(origvar1) > SCIPvarGetType(origvar2) )
1018 return 1;
1019 return 0;
1020}
1021
1022/** SCIP interface method for sorting the constraints */
1023static
1025{
1026 AUT_CONS* aut1 = (AUT_CONS*) elem1;
1027 AUT_CONS* aut2 = (AUT_CONS*) elem2;
1028 return comp(aut1->getScip(), aut1, aut2, FALSE);
1029}
1030
1031/** SCIP interface method for sorting the constraints */
1032static
1034{
1035 AUT_CONS* aut1 = (AUT_CONS*) elem1;
1036 AUT_CONS* aut2 = (AUT_CONS*) elem2;
1037 return comp(aut1->getScip(), aut1, aut2, TRUE);
1038}
1039
1040/** SCIP interface method for sorting the variables */
1041static
1043{
1044 AUT_VAR* aut1 = (AUT_VAR*) elem1;
1045 AUT_VAR* aut2 = (AUT_VAR*) elem2;
1046 return comp(aut1->getScip(), aut1, aut2, FALSE);
1047}
1048
1049/** SCIP interface method for sorting the variables */
1050static
1052{
1053 AUT_VAR* aut1 = (AUT_VAR*) elem1;
1054 AUT_VAR* aut2 = (AUT_VAR*) elem2;
1055 return comp(aut1->getScip(), aut1, aut2, TRUE);
1056}
1057
1058/** SCIP interface method for sorting the constraint coefficients*/
1059static
1061{
1062 AUT_COEF* aut1 = (AUT_COEF*) elem1;
1063 AUT_COEF* aut2 = (AUT_COEF*) elem2;
1064 return comp(aut1->getScip(), aut1->getVal(), aut2->getVal(), FALSE); /*lint !e864*/
1065}
1066
1067/** SCIP interface method for sorting the constraint coefficients*/
1068static
1070{
1071 AUT_COEF* aut1 = (AUT_COEF*) elem1;
1072 AUT_COEF* aut2 = (AUT_COEF*) elem2;
1073 return comp(aut1->getScip(), aut1->getVal(), aut2->getVal(), TRUE); /*lint !e864*/
1074}
1075
1076
1077/** default constructor */
1078struct_colorinformation::struct_colorinformation()
1079 : color(0), lenconssarray(0), lenvarsarray(0), lencoefsarray(0), alloccoefsarray(0),
1080ptrarraycoefs(NULL), ptrarrayvars(NULL), ptrarrayconss(NULL), onlysign(FALSE)
1081{
1082
1083}
1084
1085/** inserts a variable to the pointer array of colorinformation */
1086SCIP_RETCODE struct_colorinformation::insert(
1087 AUT_VAR* svar, /**< variable which is to add */
1088 SCIP_Bool* added /**< true if a var was added */
1089 )
1090{
1091 int pos;
1092
1093 if( !onlysign )
1094 {
1095 if( !SCIPsortedvecFindPtr(ptrarrayvars, sortptrvar, svar, lenvarsarray, &pos) )
1096 {
1097 SCIPsortedvecInsertPtr(ptrarrayvars, sortptrvar, svar, &lenvarsarray, NULL);
1098 *added = TRUE;
1099 color++;
1100 }
1101 else
1102 *added = FALSE;
1103 }
1104 else
1105 {
1106 if( !SCIPsortedvecFindPtr(ptrarrayvars, sortptrvarsign, svar, lenvarsarray, &pos) )
1107 {
1108 SCIPsortedvecInsertPtr(ptrarrayvars, sortptrvarsign, svar, &lenvarsarray, NULL);
1109 *added = TRUE;
1110 color++;
1111 }
1112 else
1113 *added = FALSE;
1114 }
1115
1116
1117 return SCIP_OKAY;
1118}
1119
1120/** inserts a constraint to the pointer array of colorinformation */
1121SCIP_RETCODE struct_colorinformation::insert(
1122 AUT_CONS* scons, /**< constraint which is to add */
1123 SCIP_Bool* added /**< true if a constraint was added */
1124 )
1125{
1126 int pos;
1127
1128 if( !onlysign )
1129 {
1130 if( !SCIPsortedvecFindPtr(ptrarrayconss, sortptrcons, scons,
1131 lenconssarray, &pos) )
1132 {
1133 SCIPsortedvecInsertPtr(ptrarrayconss, sortptrcons, scons,
1134 &lenconssarray, NULL);
1135 *added = TRUE;
1136 color++;
1137 }
1138 else
1139 *added = FALSE;
1140 }
1141 else
1142 {
1143 if( !SCIPsortedvecFindPtr(ptrarrayconss, sortptrconssign, scons,
1144 lenconssarray, &pos) )
1145 {
1146 SCIPsortedvecInsertPtr(ptrarrayconss, sortptrconssign, scons,
1147 &lenconssarray, NULL);
1148 *added = TRUE;
1149 color++;
1150 }
1151 else
1152 *added = FALSE;
1153 }
1154
1155 return SCIP_OKAY;
1156}
1157
1158/** inserts a coefficient to the pointer array of colorinformation */
1159SCIP_RETCODE struct_colorinformation::insert(
1160 AUT_COEF* scoef, /**< coefficient which is to add */
1161 SCIP_Bool* added /**< true if a coefficient was added */
1162 )
1163{
1164 int pos;
1165
1166 if( !onlysign )
1167 {
1168 if( !SCIPsortedvecFindPtr(ptrarraycoefs, sortptrval, scoef, lencoefsarray, &pos) )
1169 {
1170 if( alloccoefsarray == 0 || alloccoefsarray < lencoefsarray + 1 )
1171 {
1172 int size = SCIPcalcMemGrowSize(scoef->getScip(), alloccoefsarray+1);
1173 SCIP_CALL( SCIPreallocMemoryArray(scip, &ptrarraycoefs, size) );
1174 alloccoefsarray = size;
1175 }
1176
1177 SCIPsortedvecInsertPtr(ptrarraycoefs, sortptrval, scoef, &lencoefsarray, NULL);
1178 *added = TRUE;
1179 color++;
1180 }
1181 else
1182 *added = FALSE;
1183 }
1184 else
1185 {
1186 if( !SCIPsortedvecFindPtr(ptrarraycoefs, sortptrvalsign, scoef, lencoefsarray, &pos) )
1187 {
1188 if( alloccoefsarray == 0 || alloccoefsarray < lencoefsarray + 1 )
1189 {
1190 int size = SCIPcalcMemGrowSize(scoef->getScip(), alloccoefsarray+1);
1191 SCIP_CALL( SCIPreallocMemoryArray(scip, &ptrarraycoefs, size) );
1192 alloccoefsarray = size;
1193 }
1194
1195 SCIPsortedvecInsertPtr(ptrarraycoefs, sortptrvalsign, scoef, &lencoefsarray, NULL);
1196 *added = TRUE;
1197 color++;
1198 }
1199 else
1200 *added = FALSE;
1201 }
1202
1203 return SCIP_OKAY;
1204}
1205
1206int struct_colorinformation::get(
1207 AUT_VAR svar /**< variable whose pointer you want */
1208 )
1209{
1210 int pos;
1211 SCIP_Bool found;
1212 if( !onlysign )
1213 found = SCIPsortedvecFindPtr(ptrarrayvars, sortptrvar, &svar, lenvarsarray, &pos);
1214 else
1215 found = SCIPsortedvecFindPtr(ptrarrayvars, sortptrvarsign, &svar, lenvarsarray, &pos);
1216 return found ? pos : -1;
1217}
1218
1219int struct_colorinformation::get(
1220 AUT_CONS scons /**< constraint whose pointer you want */
1221 )
1222{
1223 int pos;
1224 SCIP_Bool found;
1225 if( !onlysign )
1226 found = SCIPsortedvecFindPtr(ptrarrayconss, sortptrcons, &scons, lenconssarray, &pos);
1227 else
1228 found = SCIPsortedvecFindPtr(ptrarrayconss, sortptrconssign, &scons, lenconssarray, &pos);
1229 return found ? pos : -1;
1230}
1231
1232int struct_colorinformation::get(
1233 AUT_COEF scoef /**< coefficient whose pointer you want */
1234 )
1235{
1236 int pos;
1237 SCIP_Bool found;
1238 if( !onlysign )
1239 found = SCIPsortedvecFindPtr(ptrarraycoefs, sortptrval, &scoef, lencoefsarray, &pos);
1240 else
1241 found = SCIPsortedvecFindPtr(ptrarraycoefs, sortptrvalsign, &scoef, lencoefsarray, &pos);
1242 return found ? pos : -1;
1243}
1244
1245SCIP_RETCODE struct_colorinformation::setOnlySign(
1246 SCIP_Bool onlysign_ /**< new value for onlysign bool */
1247 )
1248{
1249 onlysign = onlysign_;
1250
1251 return SCIP_OKAY;
1252}
1253
1254
1255SCIP_Bool struct_colorinformation::getOnlySign()
1256{
1257 return onlysign;
1258}
1259
1260
1261int struct_colorinformation::getLenVar()
1262{
1263 return lenvarsarray;
1264}
1265
1266int struct_colorinformation::getLenCons()
1267{
1268 return lenconssarray;
1269}
1270
1271SCIP_CONS* struct_cons::getCons()
1272{
1273 return cons;
1274}
1275
1276SCIP* struct_cons::getScip()
1277{
1278 return scip;
1279}
1280
1281SCIP_VAR* struct_var::getVar ()
1282{
1283 return var;
1284}
1285
1286SCIP* struct_var::getScip()
1287{
1288 return scip;
1289}
1290
1291SCIP* struct_coef::getScip()
1292{
1293 return scip;
1294}
1295
1296SCIP_Real struct_coef::getVal()
1297{
1298 return val;
1299}
1300
1301/** constructor of the variable struct */
1302struct_var::struct_var(
1303 SCIP* scip_, /**< SCIP data structure */
1304 SCIP_VAR* svar /**< SCIP variable */
1305 )
1306{
1307 scip = scip_;
1308 var = svar;
1309}
1310
1311/** constructor of the constraint struct */
1312struct_cons::struct_cons(
1313 SCIP* scip_, /**< SCIP data structure */
1314 SCIP_CONS* scons /**< SCIP constraint */
1315 )
1316{
1317 scip = scip_;
1318 cons = scons;
1319}
1320
1321/** constructor of the coefficient struct */
1322struct_coef::struct_coef(
1323 SCIP* scip_, /**< SCIP data structure */
1324 SCIP_Real val_ /**< SCIP value */
1325 )
1326{
1327 scip = scip_;
1328 val = val_;
1329}
SCIP_RETCODE cmpGraphPair(SCIP *scip, gcg::PARTIALDECOMP *partialdec, int block1, int block2, SCIP_RESULT *result, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, unsigned int searchnodelimit, unsigned int generatorlimit)
static int getSign(SCIP *scip, SCIP_Real val)
static void fhook(void *user_param, unsigned int N, const unsigned int *aut)
static SCIP_RETCODE setuparraysnewdetection(SCIP *scip, gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec, int nblocks, std::vector< int > blocks, AUT_COLOR *colorinfo, SCIP_RESULT *result)
static SCIP_RETCODE allocMemoryNewDetection(SCIP *scip, gcg::DETPROBDATA *detprobdata, AUT_COLOR *colorinfo, int nconss, int nvars, int ncoeffs)
static SCIP_RETCODE createGraphNewDetection(SCIP *scip, gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec, std::vector< int > blocks, AUT_COLOR colorinfo, AUT_GRAPH *graph, int *pricingnodes, SCIP_RESULT *result)
static int comp(SCIP *scip, SCIP_Real val1, SCIP_Real val2, SCIP_Bool onlysign)
automorphism recognition of SCIPs
SCIP_VAR ** b
class storing partialdecs and the problem matrix
class storing (potentially incomplete) decompositions
GCG_EXPORT int getNConss()
returns the number of variables considered in the detprobdata
GCG_EXPORT SCIP * getScip()
returns the corresponding scip data structure
GCG_EXPORT int getNVarsForCons(int consIndex)
returns the number of variables for a given constraint
GCG_EXPORT SCIP_VAR * getVar(int varIndex)
returns SCIP variable related to a variable index
GCG_EXPORT SCIP_Real getVal(int row, int col)
returns a coefficient from the coefficient matrix
GCG_EXPORT std::vector< int > & getVarsForCons(int consIndex)
returns the variable indices of the coefficient matrix for a constraint
GCG_EXPORT SCIP_CONS * getCons(int consIndex)
returns the SCIP constraint related to a constraint index
class to manage partial decompositions
GCG_EXPORT int getNMasterconss()
Gets size of the vector containing master conss.
GCG_EXPORT int getNCoeffsForBlock(int blockid)
Gets the number of nonzero coeffs in a certain block.
GCG_EXPORT int getVarProbindexForBlock(int varid, int block)
Gets the index of a variable in the vector returned by PARTIALDECOMP::getVarsForBlock.
GCG_EXPORT std::vector< int > & getMasterconss()
Gets array containing all master conss indices.
GCG_EXPORT std::vector< int > & getConssForBlock(int block)
returns array containing constraints assigned to a block
GCG_EXPORT DETPROBDATA * getDetprobdata()
Gets the corresponding detprobdata.
int getNVarsOfBlockInMasterCons(int masterconsindex, int block)
returns the number of block vars contained in a master constraint
GCG_EXPORT int getNVarsForBlock(int block)
Gets size of the vector containing vars assigned to a block.
GCG_EXPORT int getNCoeffsForMaster()
GCG_EXPORT int getNConssForBlock(int block)
Gets size of the vector containing conss assigned to a block.
GCG_EXPORT bool isVarBlockvarOfBlock(int var, int block)
Checks whether the var is assigned to the block.
GCG_EXPORT std::vector< int > & getVarsForBlock(int block)
Gets array containing vars of a block.
C++ interface of cons_decomp.
static void freeMemory(SCIP *scip, AUT_COLOR *colorinfo)
#define SCIP_Bool
#define SCIP_Real
#define ABS(x)
#define SCIP_CALL_ABORT(x)
#define TRUE
#define FALSE
GCG interface methods.
SCIP_VAR * GCGpricingVarGetOriginalVar(SCIP_VAR *var)
Definition gcgvar.c:590
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
SCIP_Real GCGconsGetRhs(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:109
SCIP_Real GCGconsGetLhs(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:207
int GCGconsGetNVars(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:433
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
SCIP_DECL_SORTPTRCOMP(SCIPbendersComp)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
const char * SCIPconsGetName(SCIP_CONS *cons)
#define SCIPfreeMemoryArrayNull(scip, ptr)
#define SCIPreallocMemoryArray(scip, ptr, newnum)
#define SCIPallocMemoryArray(scip, ptr, num)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPfreeMemoryArray(scip, ptr)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_Bool SCIPsortedvecFindPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), void *val, int len, int *pos)
void SCIPsortedvecInsertPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), void *keyval, int *len, int *pos)
SCIP_Bool GCGvarIsPricing(SCIP_VAR *var)
Definition gcgvar.c:159
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
* result
SCIP_VAR * var
int j
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
int i
int nvars
SCIPfreeBufferArray(scip, &cycles)
SCIP_Longint nnodes
#define NULL
#define BMSclearMemoryArray(ptr, num)
helper functions for automorphism detection
struct struct_cons AUT_CONS
struct struct_colorinformation AUT_COLOR
struct struct_graph AUT_GRAPH
struct struct_coef AUT_COEF
struct struct_var AUT_VAR
various SCIP helper methods
AUT_HOOK2(SCIP_HASHMAP *varmap_, SCIP_HASHMAP *consmap_, unsigned int n_, AUT_GRAPH *graph_, gcg::PARTIALDECOMP *partialdec_, std::vector< int > *blocks_)
SCIP_HASHMAP * varmap
gcg::PARTIALDECOMP * partialdec
SCIP ** scips
unsigned int n
SCIP_HASHMAP * getVarHash()
SCIP_HASHMAP * getConsHash()
gcg::DETPROBDATA * detprobdata
int * conssperm
SCIP_Bool aut
std::vector< int > * blocks
unsigned int getNNodes()
AUT_GRAPH * getGraph()
SCIP_Bool getBool()
void setBool(SCIP_Bool aut)
SCIP_HASHMAP * consmap
AUT_GRAPH * graph
struct SCIP_Cons SCIP_CONS
SCIP_VERBLEVEL_FULL
struct SCIP_HashMap SCIP_HASHMAP
SCIP_DIDNOTFIND
SCIP_SUCCESS
enum SCIP_Result SCIP_RESULT
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
struct SCIP_Var SCIP_VAR