GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
class_detprobdata.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 class_detprobdata.cpp
30 * @brief class storing partialdecomps and the problem matrix
31 * @author Michael Bastubbe
32 * @author Julius Hense
33 * @author Hanna Franzen
34 */
35
36/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
37
38/*@todo don't disable lint */
39/*lint -e64 disable useless and wrong lint warning */
40
41/*@todo this looks like a workaround, is disabling warnings a good idea? */
42#ifdef __INTEL_COMPILER
43#ifndef _OPENMP
44#pragma warning disable 3180 /* disable wrong and useless omp warnings */
45#endif
46#endif
47
48//#define WRITE_ORIG_CONSTYPES
49// #define SCIP_DEBUG
50
51#include "scip/scipdefplugins.h"
52#include "gcg/gcg.h"
53#include "objscip/objscip.h"
54#include "scip/scip.h"
56#include "gcg/struct_detector.h"
57#include "gcg/pub_decomp.h"
58#include "gcg/struct_decomp.h"
59#include "gcg/cons_decomp.h"
60#include "gcg/cons_decomp.hpp"
61#include "gcg/decomp.h"
63#include "gcg/scip_misc.h"
64#include "scip/clock.h"
65#include "scip/cons.h"
66#include "scip/scip.h"
67#include "scip/var.h"
68#include <algorithm>
69#include <list>
70#include <iostream>
71#include <stdio.h>
72#include <sstream>
73#include <iomanip>
74#include <fstream>
75#include <exception>
76#include <random> /* needed for exponential distributed random dual variables */
77#include <set>
78
79#include "gcg/reader_gp.h"
80
81
82#ifdef _OPENMP
83#include <omp.h>
84#endif
85
86#define SCIP_CALL_EXC( x ) do \
87 { \
88 SCIP_RETCODE _restat_; \
89 if( ( _restat_ = ( x ) ) != SCIP_OKAY ) \
90 { \
91 SCIPerrorMessage( "Error <%d> in function call\n", _restat_); \
92 throw std::exception(); \
93 } \
94 } \
95 while( false )
96
97#define ENUM_TO_STRING( x ) # x
98#define DEFAULT_THREADS 0 /**< number of threads (0 is OpenMP default) */
99
100
101namespace gcg{
102
103/* local methods */
104
106{
108 const std::pair<int, int> &left,
109 const std::pair<int, int> &right)
110 {
111 if( left.second != right.second )
112 return left.second > right.second;
113 else return left.first < right.first;
114 }
115};
116
117
118/** returns the relevant representative of a var */
120 SCIP* scip,
122 )
123{
125}
126
127
128void DETPROBDATA::calcTranslationMapping(
129 DETPROBDATA* origdata,
130 std::vector<int>& rowothertothis,
131 std::vector<int>& rowthistoother,
132 std::vector<int>& colothertothis,
133 std::vector<int>& colthistoother,
134 std::vector<int>& missingrowinthis
135 )
136{
137 SCIP_CONS* transcons;
138 int nrowsother = origdata->nconss;
139 int nrowsthis = nconss;
140 int ncolsother = origdata->nvars;
141 int ncolsthis = nvars;
142
143 std::vector<SCIP_CONS*> origscipconss = origdata->relevantconss;
144 std::vector<SCIP_CONS*> thisscipconss = relevantconss;
145 std::vector<SCIP_VAR*> origscipvars = origdata->relevantvars;
146 std::vector<SCIP_VAR*> thisscipvars = relevantvars;
147
148 assert(nrowsother == (int) origscipconss.size() );
149 assert(nrowsthis == (int) thisscipconss.size() );
150
151 assert(ncolsother == (int) origscipvars.size() );
152 assert(ncolsthis == (int) thisscipvars.size() );
153
154 rowothertothis.assign( nrowsother, - 1 );
155 rowthistoother.assign( nrowsthis, - 1 );
156 colothertothis.assign( ncolsother, - 1 );
157 colthistoother.assign( ncolsthis, - 1 );
158
159 missingrowinthis.clear();
160
161 /* identify new and deleted rows and cols; and identify bijection between maintained variables */
162 for( int i = 0; i < nrowsother ; ++i )
163 {
164 SCIP_CONS* otherrow = origscipconss[i];
165 assert( otherrow != NULL );
166 SCIP_Bool foundmaintained = false;
167 for( int j2 = i; j2 < nrowsthis + i; ++j2 )
168 {
169 int j = j2 % nrowsthis;
170 SCIP_CONS* thisrow = thisscipconss[j];
171 assert( SCIPconsIsTransformed( thisrow ) );
172
173 SCIPgetTransformedCons(scip, origscipconss[i], &transcons);
174 if( transcons == thisrow)
175 {
176 rowothertothis[i] = j;
177 rowthistoother[j] = i;
178 foundmaintained = true;
179 break;
180 }
181
182 char buffer[SCIP_MAXSTRLEN];
183 assert( this->scip != NULL );
184 strcpy( buffer, SCIPconsGetName( thisrow ) + 2 );
185 assert( this->scip != NULL );
186 if( strcmp( SCIPconsGetName( otherrow ), SCIPconsGetName( thisrow ) ) == 0 )
187 {
188 rowothertothis[i] = j;
189 rowthistoother[j] = i;
190 foundmaintained = true;
191 break;
192 }
193 }
194 if( ! foundmaintained )
195 {
196 missingrowinthis.push_back( i );
197 }
198 }
199
200 for( int i = 0; i < ncolsother; ++i )
201 {
202 SCIP_VAR* othervar;
203 SCIP_VAR* probvar;
204 SCIP_CALL_ABORT( SCIPgetTransformedVar(scip, origscipvars[i], &othervar ) );
205 if (othervar == NULL)
206 continue;
207
208 probvar = SCIPvarGetProbvar(othervar);
209 if ( probvar == NULL )
210 continue;
211
212 for( int j2 = i; j2 < ncolsthis + i; ++j2 )
213 {
214 int j = j2 % ncolsthis;
215 if( probvar == thisscipvars[j] )
216 {
217 colothertothis[i] = j;
218 colthistoother[j] = i;
219 break;
220 }
221 }
222 }
223}
224
225
226void DETPROBDATA::getTranslatedPartialdecs(
227 std::vector<PARTIALDECOMP*>& origpartialdecs,
228 std::vector<int>& rowothertothis,
229 std::vector<int>& rowthistoother,
230 std::vector<int>& colothertothis,
231 std::vector<int>& colthistoother,
232 std::vector<PARTIALDECOMP*>& translatedpartialdecs,
233 SCIP_Bool translatesymmetry
234 )
235{
236 DETPROBDATA* origdetprobdata = NULL;
237
238 if( translatesymmetry )
239 {
240 // even if presolving is disabled some vars might be fixed to 0
241 // @todo: we could check if symmetry is still valid
242 origdetprobdata = GCGconshdlrDecompGetDetprobdataOrig(gcg);
243 if( origdetprobdata->getNConss() != getNConss() || origdetprobdata->getNVars() != getNVars() )
244 translatesymmetry = FALSE;
245 }
246 for( auto otherpartialdec : origpartialdecs )
247 {
248 PARTIALDECOMP* newpartialdec;
249
250 SCIPverbMessage(this->scip, SCIP_VERBLEVEL_FULL, NULL, " transform partialdec %d \n", otherpartialdec->getID());
251
252 newpartialdec = new PARTIALDECOMP(gcg, original);
253
254 /* prepare new partialdec */
255 newpartialdec->setNBlocks(otherpartialdec->getNBlocks());
256
257 newpartialdec->setUsergiven(otherpartialdec->getUsergiven());
258
259 /* set all (which have representative in the orig partialdec) constraints according to their representatives in the orig partialdec */
260 for( int b = 0; b < otherpartialdec->getNBlocks(); ++ b )
261 {
262 for( int i = 0; i < otherpartialdec->getNConssForBlock( b ); i ++ )
263 {
264 int thiscons = rowothertothis[otherpartialdec->getConssForBlock( b )[i]];
265 if( thiscons != - 1 )
266 {
267 newpartialdec->fixConsToBlock( thiscons, b );
268 }
269 }
270 }
271
272 for( int i = 0; i < otherpartialdec->getNMasterconss(); i ++ )
273 {
274 int thiscons = rowothertothis[otherpartialdec->getMasterconss()[i]];
275 if( thiscons != - 1 )
276 {
277 newpartialdec->fixConsToMaster(thiscons);
278 }
279 }
280
281 auto& blockstructures = otherpartialdec->getBlockStructures();
282 for( int b = 0; b < (int)blockstructures.size(); ++ b )
283 {
284 if( blockstructures[b] )
285 newpartialdec->setBlockStructure(b, blockstructures[b]->translateStructure(rowothertothis, colothertothis, translatesymmetry));
286 else
287 newpartialdec->setBlockStructure(b, NULL);
288 }
289
290 // we do not assign variables as the previous assignment might be invalid due to presolving
291
292 newpartialdec->setDetectorchain(otherpartialdec->getDetectorchain());
293 newpartialdec->setAncestorList(otherpartialdec->getAncestorList());
294
295 newpartialdec->addAncestorID(otherpartialdec->getID());
296
297 newpartialdec->copyPartitionStatistics(otherpartialdec);
298
299 for( int i = 0; i < otherpartialdec->getNDetectors(); ++i )
300 {
301 newpartialdec->addClockTime(otherpartialdec->getDetectorClockTime(i));
302 newpartialdec->addPctConssFromFree(otherpartialdec->getPctConssFromFree(i));
303 newpartialdec->addPctConssToBlock(otherpartialdec->getPctConssToBlock(i));
304 newpartialdec->addPctConssToBorder(otherpartialdec->getPctConssToBorder(i));
305 newpartialdec->addPctVarsFromFree(otherpartialdec->getPctVarsFromFree(i));
306 newpartialdec->addPctVarsToBlock(otherpartialdec->getPctVarsToBlock(i));
307 newpartialdec->addPctVarsToBorder(otherpartialdec->getPctVarsToBorder(i));
308 newpartialdec->addNNewBlocks(otherpartialdec->getNNewBlocks(i));
309 newpartialdec->addDetectorChainInfo(otherpartialdec->getDetectorchainInfo()[i].c_str());
310 }
311
312 newpartialdec->setStemsFromOrig(otherpartialdec->isAssignedToOrigProb());
313 newpartialdec->setFinishedByFinisherOrig(otherpartialdec->getFinishedByFinisher());
314 otherpartialdec->setTranslatedpartialdecid(newpartialdec->getID());
315
316 if( otherpartialdec->getFinishedByFinisher() )
317 newpartialdec->setDetectorFinishedOrig();
318
319 newpartialdec->setFinishedByFinisher(otherpartialdec->getFinishedByFinisher());
320 newpartialdec->prepare();
321
322 if( translatesymmetry && otherpartialdec->getNBlocks() == newpartialdec->getNBlocks() && otherpartialdec->aggInfoCalculated() )
323 {
324 newpartialdec->setSymmetryInformation(
325 [otherpartialdec] (int b)
326 {
327 return otherpartialdec->getReprBlockForEqClass(otherpartialdec->getEqClassForBlock(b));
328 },
329 [&colothertothis, &colthistoother, otherpartialdec, newpartialdec] (int b, int vi)
330 {
331 int v = newpartialdec->getVarsForBlock(b)[vi];
332 int eqclass = otherpartialdec->getEqClassForBlock(b);
333 int rb = otherpartialdec->getReprBlockForEqClass(eqclass);
334 auto& eqclassblocks = otherpartialdec->getBlocksForEqClass(eqclass);
335 assert(std::lower_bound(eqclassblocks.begin(), eqclassblocks.end(), b) != eqclassblocks.end());
336 int eqclassblock = (int) (std::lower_bound(eqclassblocks.begin(), eqclassblocks.end(), b) - eqclassblocks.begin());
337 assert(std::find(colthistoother.begin(), colthistoother.end(), v) != colthistoother.end());
338 int othervi = otherpartialdec->getVarsForBlock(b)[vi] == colthistoother[v] ? vi : otherpartialdec->getVarProbindexForBlock(colthistoother[v], b);
339 int blockVarIndex = otherpartialdec->getRepVarmap(eqclass, eqclassblock)[othervi];
340 if( newpartialdec->getVarsForBlock(rb)[blockVarIndex] == colothertothis[otherpartialdec->getVarsForBlock(rb)[blockVarIndex]] )
341 return blockVarIndex;
342 else
343 return newpartialdec->getVarProbindexForBlock(colothertothis[otherpartialdec->getVarsForBlock(rb)[blockVarIndex]], rb);
344 }
345 );
346 }
347
348 newpartialdec->getScore(GCGgetCurrentScore(gcg)) ;
349
350 translatedpartialdecs.push_back(newpartialdec);
351 }
352}
353
354
356 GCG* gcgstruct,
357 SCIP_Bool _originalProblem
358 ) :
359 gcg(gcgstruct), scip(GCGgetOrigprob(gcg)), openpartialdecs(0), ancestorpartialdecs( 0 ), origfixedtozerovars(0),
360 nvars(SCIPgetNVars(GCGgetOrigprob(gcg))), nconss(SCIPgetNConss(GCGgetOrigprob(gcg))), nnonzeros(0), original(_originalProblem), candidatesNBlocks(0),
362{
363 SCIP_CONS** conss;
364 SCIP_VAR** vars;
365 SCIP_Bool createconssadj;
366
367 if( original )
368 {
369 nvars = SCIPgetNOrigVars(scip);
370 nconss = SCIPgetNOrigConss(scip);
371 }
372
373 int relevantVarCounter = 0;
374 int relevantConsCounter = 0;
375
376 /* initilize matrix datastructures */
377 if( original )
378 {
379 conss = SCIPgetOrigConss(scip);
381 }
382 else
383 {
384 conss = SCIPgetConss(scip);
386 }
387
388 /* assign an index to every cons and var
389 * @TODO: are all constraints/variables relevant? (probvars etc) */
390 for( int i = 0; i < nconss; ++ i )
391 {
392 if( SCIPconsIsDeleted( conss[i] ) || SCIPconsIsObsolete(conss[i]) )
393 {
394 continue;
395 }
396
397 if( conss[i] != NULL )
398 {
399 constoindex[conss[i]] = relevantConsCounter;
400 relevantconss.push_back(conss[i]);
401 SCIPcaptureCons(scip, conss[i]);
402
403 ++relevantConsCounter;
404 }
405 else
406 {
407 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "relevant cons is NULL\n");
408 }
409 }
410
411 for( int i = 0; i < nvars; ++ i )
412 {
413 SCIP_VAR* relevantVar = original ? vars[i] : SCIPvarGetProbvar(vars[i]);
414
415 if( varIsFixedToZero(scip, vars[i]) )
416 {
417 origfixedtozerovars.push_back(relevantVar);
418 }
419 else if( relevantVar != NULL )
420 {
421 vartoindex[relevantVar] = relevantVarCounter;
422 relevantvars.push_back(relevantVar);
423 ++ relevantVarCounter;
424 }
425 }
426
427 /* from here on nvars and nconss represents the relevant numbers */
428 nvars = (int) relevantvars.size();
429 nconss = (int) relevantconss.size();
430 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, " nvars: %d / nconss: %d \n", nvars, nconss );
431 varsforconss.resize(nconss);
432 valsforconss.resize(nconss);
433 conssforvars.resize(nvars);
434
435 /* assumption: now every relevant constraint and variable has its index
436 * and is stored in the corresponding unordered_map */
437 /* find constraint <-> variable relationships and store them in both directions */
438 for( int i = 0; i < (int) relevantconss.size(); ++ i )
439 {
440 SCIP_CONS* cons;
441 SCIP_VAR** currVars = NULL;
442 SCIP_Real* currVals = NULL;
443 int nCurrVars;
444
445 cons = relevantconss[i];
446
447 nCurrVars = GCGconsGetNVars(scip, cons);
448 if( nCurrVars == 0 )
449 continue;
450
451 assert(SCIPconsGetName( cons) != NULL);
452
453 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &currVars, nCurrVars) );
454 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &currVals, nCurrVars) );
455 SCIP_CALL_ABORT( GCGconsGetVars(scip, cons, currVars, nCurrVars) );
456 SCIP_CALL_ABORT( GCGconsGetVals(scip, cons, currVals, nCurrVars) );
457
458 for( int currVar = 0; currVar < nCurrVars; ++ currVar )
459 {
460 int varIndex;
461 unordered_map<SCIP_VAR*, int>::const_iterator iterVar;
462
463 if( varIsFixedToZero(scip, currVars[currVar]) )
464 continue;
465
466 /*@todo remove this after the bug is fixed */
467 /* because of the bug of GCGconsGet*()-methods some variables have to be negated */
468 if( !SCIPvarIsNegated(currVars[currVar]) )
469 iterVar = vartoindex.find(currVars[currVar]);
470 else
471 iterVar = vartoindex.find(SCIPvarGetNegatedVar(currVars[currVar]));
472
473 if( iterVar == vartoindex.end() )
474 continue;
475
476 varIndex = iterVar->second;
477
478 varsforconss[i].push_back(varIndex);
479 conssforvars[varIndex].push_back(i);
480 valsforconss[i].push_back(currVals[currVar]);
481 valsMap[std::pair<int, int>(i, varIndex)] = currVals[currVar];
482 ++ nnonzeros;
483 }
484 SCIPfreeBufferArrayNull( scip, & currVals );
485 SCIPfreeBufferArrayNull( scip, & currVars );
486 }
487
488 createconssadj = (getNConss() < 1000);
489
490 if( createconssadj )
491 {
493 }
494} //end constructor
495
496
498{
499 for( int c = 0; c < nconss; ++c )
500 {
501 SCIP_CONS* cons;
502
503 cons = getCons(c);
504 SCIPreleaseCons(scip, &cons);
505 }
506
507 // Delete all partialdecs
509
510 for( size_t i = 0; i < conspartitioncollection.size(); ++ i )
511 {
512 size_t help = conspartitioncollection.size() - i - 1;
513 if( conspartitioncollection[help] != NULL )
514 delete conspartitioncollection[help];
515 }
516
517 for( size_t i = 0; i < varpartitioncollection.size(); ++ i )
518 {
519 size_t help = varpartitioncollection.size() - i - 1;
520 if( varpartitioncollection[help] != NULL )
521 delete varpartitioncollection[help];
522 }
523}
524
525
526/* @brief adds a candidate for block number and counts how often a candidate is added */
528 int candidate, /*< candidate for block size */
529 int nvotes /*< number of votes this candidates will get */
530 )
531{
532 if( candidate > 1 )
533 {
534 bool alreadyin = false;
535 for(auto& candidatesNBlock : candidatesNBlocks)
536 {
537 if( candidatesNBlock.first == candidate )
538 {
539 alreadyin = true;
540 candidatesNBlock.second = MAX(INT_MAX, candidatesNBlock.second + nvotes);
541 break;
542 }
543 }
544 if( !alreadyin )
545 {
546 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "added block number candidate: %d \n", candidate);
547 candidatesNBlocks.emplace_back(candidate, nvotes);
548 }
549 }
550}
551
552
554 ConsPartition* partition
555 )
556{
557 SCIP_Bool allowduplicates;
558
559 SCIPgetBoolParam(scip, "detection/classification/allowduplicates", &allowduplicates);
560
561 if( partition != NULL )
562 {
563 /* check whether there already exists an equivalent conspartition */
564 ConsPartition* equiv = NULL;
565
566 for( size_t i = 0; !allowduplicates && i < conspartitioncollection.size(); ++ i )
567 {
568 if( partition->isDuplicateOf(conspartitioncollection[i]) )
569 {
570 equiv = conspartitioncollection[i];
571 break;
572 }
573 }
574
575 if( equiv == NULL )
576 conspartitioncollection.push_back(partition);
577 else
578 {
579 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " Conspartition \"%s\" is not considered since it offers the same structure as \"%s\" conspartition\n", partition->getName(), equiv->getName() );
580 delete partition;
581 }
582 }
583}
584
585
587 PARTIALDECOMP* partialdec
588 )
589{
590 ancestorpartialdecs.push_back(partialdec);
591}
592
593
595 PARTIALDECOMP* partialdec
596 )
597{
598 assert(partialdec->checkConsistency());
599 if( partialdecIsNoDuplicateOfPartialdecs(partialdec, openpartialdecs, true) )
600 {
601 openpartialdecs.push_back(partialdec);
602 return true;
603 }
604 else
605 {
606 return false;
607 }
608}
609
610
612 PARTIALDECOMP* partialdec
613 )
614{
615 assert(partialdec->checkConsistency());
616 if( partialdec->isComplete() && partialdecIsNoDuplicateOfPartialdecs(partialdec, finishedpartialdecs, false) )
617 {
618 finishedpartialdecs.push_back(partialdec);
619 return true;
620 }
621 else
622 {
623 return false;
624 }
625}
626
627
629 PARTIALDECOMP* partialdec
630 )
631{
632 assert(partialdec->checkConsistency());
633 finishedpartialdecs.push_back(partialdec);
634}
635
636
638 VarPartition* partition
639 )
640{
641 SCIP_Bool allowduplicates;
642
643 SCIPgetBoolParam(scip, "detection/classification/allowduplicates", &allowduplicates);
644
645 if( partition != NULL )
646 {
647 /* check whether there already exists an equivalent varpartition */
648 VarPartition* equiv = NULL;
649
650 for( size_t i = 0; !allowduplicates && i < varpartitioncollection.size(); ++ i )
651 {
652 if( partition->isDuplicateOf(varpartitioncollection[i]) )
653 {
654 equiv = varpartitioncollection[i];
655 break;
656 }
657 }
658
659 if( equiv == NULL )
660 varpartitioncollection.push_back(partition);
661 else
662 {
663 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " Varpartition \"%s\" is not considered since it offers the same structure as \"%s\"\n", partition->getName(), equiv->getName() );
664 delete partition;
665 }
666
667 }
668}
669
670
672{
673 ancestorpartialdecs.clear();
674}
675
676
678{
679 openpartialdecs.clear();
680}
681
682
684{
685 finishedpartialdecs.clear();
686}
687
688
690{
691 std::set<int> conssadjacenciestemp;
692 conssadjacencies.reserve(relevantconss.size());
693
694 /* find constraint <-> constraint relationships and store them in both directions */
695 for( size_t i = 0; i < relevantconss.size(); ++i )
696 {
697 for( size_t varid = 0; varid < varsforconss[i].size(); ++varid )
698 {
699 int var = varsforconss[i][varid];
700
701 for( int othercons : conssforvars[var] )
702 {
703 if( othercons == (int) i )
704 continue;
705
706 conssadjacenciestemp.insert(othercons);
707 }
708 }
709
710 conssadjacencies.emplace_back();
711 for( int cons : conssadjacenciestemp )
712 {
713 conssadjacencies[i].push_back(cons);
714 }
715 conssadjacenciestemp.clear();
716 }
717}
718
719
721{
722 conssadjacencies = std::vector<std::vector<int>>();
723}
724
725
727 int partialdecindex
728 )
729{
730 assert( 0 <= partialdecindex && partialdecindex < (int) ancestorpartialdecs.size() );
731
732 return ancestorpartialdecs[partialdecindex];
733}
734
735
737 int partitionIndex
738 )
739{
740 assert(0 <= partitionIndex && partitionIndex < (int) conspartitioncollection.size() );
741
742 return conspartitioncollection[partitionIndex];
743}
744
745
747 int consIndex
748 )
749{
750 return relevantconss[consIndex];
751}
752
753
755 int cons
756 )
757{
758 return conssadjacencies[cons];
759}
760
761
763 int var
764 )
765{
766 return conssforvars[var];
767}
768
769
770std::vector<PARTIALDECOMP*>& DETPROBDATA::getOpenPartialdecs()
771{
772 return openpartialdecs;
773}
774
775
777 int partialdecindex
778 )
779{
780 assert( 0 <= partialdecindex && partialdecindex < (int) finishedpartialdecs.size() );
781
782 return finishedpartialdecs[partialdecindex];
783}
784
785
786std::vector<PARTIALDECOMP*>& DETPROBDATA::getFinishedPartialdecs()
787{
788 return finishedpartialdecs;
789}
790
791
793 SCIP_CONS* cons
794 )
795{
796 assert(constoindex.find(cons) != constoindex.cend());
797 return constoindex[cons];
798}
799
800
802 const char* consname
803 )
804{
805 SCIP_CONS* cons = original ?
806 (SCIPfindOrigCons(scip, consname) == NULL ?
807 SCIPfindCons(scip, consname): SCIPfindOrigCons(scip, consname)) : SCIPfindCons(scip, consname);
808 if( cons == NULL )
809 {
810 return -1;
811 }
812 return getIndexForCons(cons);
813}
814
815
817 const char* varname
818 )
819{
820 SCIP_VAR* var = SCIPfindVar(scip, varname);
821 if( var == NULL)
822 {
823 return -1;
824 }
825 return getIndexForVar(var);
826}
827
828
831 )
832{
833 assert(var != NULL);
834 return vartoindex[var];
835}
836
837
839{
840 return (int) ancestorpartialdecs.size();
841}
842
843
845{
846 return (int) conspartitioncollection.size();
847}
848
849
851{
852 return nconss;
853}
854
855
857 int cons
858 )
859{
860 return (int) conssadjacencies[cons].size();
861}
862
863
865 int var
866 )
867{
868 return (int) conssforvars[var].size();
869}
870
871
873{
874 return (int) openpartialdecs.size();
875}
876
877
879{
880 return (int) finishedpartialdecs.size();
881}
882
883
885{
886 return (int) (finishedpartialdecs.size() + openpartialdecs.size());
887}
888
889
891{
892 return nnonzeros;
893}
894
895
897{
898 return (int) varpartitioncollection.size();
899}
900
901
903{
904 return nvars;
905}
906
907
909 int cons
910 )
911{
912 return (int) varsforconss[cons].size();
913}
914
915
916std::vector<SCIP_VAR*> DETPROBDATA::getOrigVarsFixedZero()
917{
918 return origfixedtozerovars;
919}
920
921
922std::vector<SCIP_CONS*> DETPROBDATA::getRelevantConss()
923{
924 return relevantconss;
925}
926
927
928std::vector<SCIP_VAR*> DETPROBDATA::getRelevantVars()
929{
930 return relevantvars;
931}
932
933
935{
936 return scip;
937}
938
939
941{
942 return gcg;
943}
944
945
947 std::vector<int>& candidates
948 )
949{
950 int nusercandidates = GCGconshdlrDecompGetNBlockNumberCandidates(gcg);
951 /* get the block number candidates directly given by the user */
952 SCIPdebugMessage("number of user block number candidates: %d\n", nusercandidates);
953 for( int i = 0; i < nusercandidates; ++i )
954 {
956 candidates.push_back(candidate);
957 SCIPdebugMessage(" %d\n", candidate);
958 }
959
960 /* sort the current candidates */
961 std::sort(candidatesNBlocks.begin(), candidatesNBlocks.end(), sort_decr());
962
963 /* add sorted candidates and also */
964 SCIPdebugMessage("Sorted Candidates:\n");
965
966 for( auto& candidatesNBlock : candidatesNBlocks )
967 {
968 SCIPdebugMessage(" %d, %d\n", candidatesNBlock.first, candidatesNBlock.second);
969
970 /* push candidates to output vector */
971 candidates.push_back(candidatesNBlock.first);
972 }
973}
974
975
977 int row,
978 int col
979 )
980{
981 unordered_map<std::pair<int, int>, SCIP_Real, pair_hash>::const_iterator iter = valsMap.find(
982 std::pair<int, int>( row, col ) );
983
984 if( iter == valsMap.end() )
985 return 0.;
986
987 return iter->second;
988}
989
990
991std::vector<SCIP_Real>& DETPROBDATA::getValsForCons(
992 int cons
993 )
994{
995 return valsforconss[cons];
996}
997
998
1000 int partitionIndex
1001 )
1002{
1003 assert(0 <= partitionIndex && partitionIndex < (int) varpartitioncollection.size() );
1004
1005 return varpartitioncollection[partitionIndex];
1006}
1007
1008
1009std::vector<VarPartition*> DETPROBDATA::getVarPartitions()
1010{
1012}
1013
1014
1016 int varIndex
1017 )
1018{
1019 return relevantvars[varIndex];
1020}
1021
1022
1024 int cons
1025 )
1026{
1027 return varsforconss[cons];
1028}
1029
1030
1032 int consindexd
1033 )
1034{
1035 SCIP_CONS* cons;
1036
1037 cons = relevantconss[consindexd];
1038
1039 assert(cons != NULL);
1040
1041 return GCGgetConsIsCardinalityCons(scip, cons);
1042}
1043
1044
1046{
1047 return !conssadjacencies.empty();
1048}
1049
1050
1052 int consindexd
1053 )
1054{
1055 SCIP_CONS* cons;
1056
1057 cons = relevantconss[consindexd];
1058
1059 assert(cons != NULL);
1060
1061 if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), "setppc") == 0 )
1062 {
1063 switch( SCIPgetTypeSetppc(scip, cons) )
1064 {
1068 return true;
1069 }
1070 }
1071 else if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), "logicor") == 0 )
1072 {
1073 return true;
1074 }
1075 else if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), "linear") == 0 )
1076 {
1077 SCIP_SETPPCTYPE type;
1078
1079 if( GCGgetConsIsSetppc(scip, cons, &type) )
1080 {
1081 switch( type )
1082 {
1086 return true;
1087 }
1088 }
1089 }
1090
1091 return false;
1092}
1093
1094
1096 int consindexd
1097 )
1098{
1099 SCIP_CONS* cons;
1100
1101 cons = relevantconss[consindexd];
1102
1103 assert(cons != NULL);
1104
1105 if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), "setppc") == 0 )
1106 {
1107 switch( SCIPgetTypeSetppc(scip, cons) )
1108 {
1111 return true;
1113 return false;
1114
1115 }
1116 }
1117 else if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), "linear") == 0 )
1118 {
1119 SCIP_SETPPCTYPE type;
1120
1121 if( GCGgetConsIsSetppc(scip, cons, &type) )
1122 {
1123 switch( type )
1124 {
1127 return true;
1129 return false;
1130
1131 }
1132 }
1133 }
1134
1135 return false;
1136}
1137
1138
1140 SCIP_Real x /**< value */
1141 )
1142{
1143 return (!SCIPisInfinity(scip, x) && !SCIPisNegative(scip, x) && SCIPisIntegral(scip, x));
1144}
1145
1146
1148 PARTIALDECOMP* partialdec
1149 )
1150{
1151 return !(partialdecIsNoDuplicateOfPartialdecs(partialdec, finishedpartialdecs, false));
1152}
1153
1154
1156{
1157 return original;
1158}
1159
1160
1162 SCIP_Real lhs,
1163 SCIP_Real rhs
1164 )
1165{
1166 assert(scip != NULL);
1167
1168 return !(SCIPisEQ(scip, lhs, rhs)
1169 || SCIPisInfinity(scip, -lhs) || SCIPisInfinity(scip, rhs) );
1170}
1171
1172
1174 PARTIALDECOMP* comppartialdec,
1175 std::vector<PARTIALDECOMP*> const & partialdecs,
1176 bool sort
1177)
1178{
1179 assert( comppartialdec != NULL );
1180 SCIP_Bool isduplicate;
1181
1182 for( size_t i = 0; i < partialdecs.size(); ++ i )
1183 {
1184 assert( partialdecs[i] != NULL );
1185
1186 comppartialdec->isEqual( partialdecs[i], & isduplicate, sort );
1187 if( isduplicate )
1188 return false;
1189 }
1190 return true;
1191}
1192
1193
1195 FILE* file /**< output file or NULL for standard output */
1196 )
1197{
1198
1199 std::sort( candidatesNBlocks.begin(), candidatesNBlocks.end(), sort_decr() );
1200 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "NBLOCKCANDIDATES \n" );
1201 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "The following %d candidates for the number of blocks are known: (candidate : number of votes) \n", (int) candidatesNBlocks.size() );
1202 for( size_t i = 0; i < candidatesNBlocks.size(); ++i )
1203 {
1204 if( candidatesNBlocks[i].second != INT_MAX )
1205 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%d : %d \n", candidatesNBlocks[i].first, candidatesNBlocks[i].second );
1206 else
1207 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%d : %s \n", candidatesNBlocks[i].first, "user given" );
1208 }
1209}
1210
1211
1213 FILE* file /**< output file or NULL for standard output */
1214 )
1215{
1216 /* NPARTITION */
1217 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "CONSPARTITION \n" );
1219
1220 for(auto partition : conspartitioncollection)
1221 {
1222 std::vector<std::vector<int> > conssofclasses = std::vector<std::vector<int> >(partition->getNClasses()) ;
1223 for( int cons = 0; cons < getNConss(); ++cons )
1224 conssofclasses[partition->getClassOfCons(cons)].push_back(cons);
1225
1226 /* PARTITIONNAME */
1227 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%s \n", partition->getName() );
1228
1229
1230 /* NCLASSES */
1231 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%d \n", partition->getNClasses() );
1232
1233 for( int cl = 0; cl < partition->getNClasses(); ++cl )
1234 {
1235 /* CLASSNAME */
1236 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%s: %s\n", partition->getClassName(cl), partition->getClassDescription(cl) );
1237 /* NMEMBERS */
1238 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%ld\n", conssofclasses[cl].size() );
1239 }
1240 }
1241
1242 /* NPARTITION */
1243 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "VARPARTITION \n" );
1245
1246 for(auto partition : varpartitioncollection)
1247 {
1248 std::vector<std::vector<int> > varsofclasses = std::vector<std::vector<int> >(partition->getNClasses()) ;
1249 for( int var = 0; var < getNVars(); ++var )
1250 varsofclasses[partition->getClassOfVar(var)].push_back(var);
1251
1252 /* PARTITIONNAME */
1253 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%s \n", partition->getName() );
1254
1255
1256 /* NCLASSES */
1257 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%d \n", partition->getNClasses() );
1258
1259 for( int cl = 0; cl < partition->getNClasses(); ++cl )
1260 {
1261 /* CLASSNAME */
1262 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%s: %s\n", partition->getClassName(cl), partition->getClassDescription(cl) );
1263 /* NMEMBERS */
1264 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%ld\n", varsofclasses[cl].size() );
1265 }
1266 }
1267}
1268
1269
1271{
1272 /* get scoretype once, no need to call it twice for every comparison */
1274
1275 /* sort by score in descending order */
1276 std::sort(finishedpartialdecs.begin(), finishedpartialdecs.end(), [&](PARTIALDECOMP* a, PARTIALDECOMP* b) {return (a->getScore(score) > b->getScore(score)); });
1277}
1278
1279
1280std::vector<PARTIALDECOMP*> DETPROBDATA::translatePartialdecs(
1281 DETPROBDATA* otherdata,
1282 std::vector<PARTIALDECOMP*> otherpartialdecs,
1283 SCIP_Bool translateSymmetry
1284 )
1285{
1286 std::vector<int> rowothertothis;
1287 std::vector<int> rowthistoother;
1288 std::vector<int> colothertothis;
1289 std::vector<int> colthistoother;
1290 std::vector<int> missingrowinthis;
1291 std::vector<PARTIALDECOMP*> newpartialdecs;
1292
1293 calcTranslationMapping(otherdata, rowothertothis, rowthistoother, colothertothis, colthistoother, missingrowinthis);
1294
1296 " calculated translation; number of missing constraints: %ld; number of other partialdecs: %ld \n", missingrowinthis.size(),
1297 otherpartialdecs.size());
1298
1299 getTranslatedPartialdecs(otherpartialdecs, rowothertothis, rowthistoother, colothertothis, colthistoother, newpartialdecs, translateSymmetry);
1300 return newpartialdecs;
1301}
1302
1303std::vector<PARTIALDECOMP*> DETPROBDATA::translatePartialdecs(
1304 DETPROBDATA* otherdata,
1305 SCIP_Bool translateSymmetry
1306 )
1307{
1308 std::vector<int> rowothertothis;
1309 std::vector<int> rowthistoother;
1310 std::vector<int> colothertothis;
1311 std::vector<int> colthistoother;
1312 std::vector<int> missingrowinthis;
1313 std::vector<PARTIALDECOMP*> newpartialdecs;
1314
1315 calcTranslationMapping(otherdata, rowothertothis, rowthistoother, colothertothis, colthistoother, missingrowinthis);
1316
1318 " calculated translation; number of missing constraints: %ld; number of other partialdecs: %ld \n", missingrowinthis.size(),
1319 (otherdata->getOpenPartialdecs().size() + otherdata->getFinishedPartialdecs().size()));
1320
1321 getTranslatedPartialdecs(otherdata->getOpenPartialdecs(), rowothertothis, rowthistoother, colothertothis, colthistoother, newpartialdecs, translateSymmetry);
1322 getTranslatedPartialdecs(otherdata->getFinishedPartialdecs(), rowothertothis, rowthistoother, colothertothis, colthistoother, newpartialdecs, translateSymmetry);
1323 return newpartialdecs;
1324}
1325
1326} /* namespace gcg */
SCIP_VAR * a
SCIP_VAR ** b
SCIP_VAR ** x
class storing partialdecs and the problem matrix
GCG_EXPORT void addPartialdecToAncestor(PARTIALDECOMP *partialdec)
adds a partialdec to ancestor partialdecs
GCG_EXPORT bool addPartialdecToOpen(PARTIALDECOMP *partialdec)
adds a partialdec to current partialdecs (data structure for partialdecs that are goin to processed i...
GCG_EXPORT ConsPartition * getConsPartition(int partitionIndex)
returns pointer to a constraint partition
GCG_EXPORT std::vector< int > & getConssForVar(int varIndex)
returns the constraint indices of the coefficient matrix for a variable
GCG_EXPORT int getIndexForCons(SCIP_CONS *cons)
returns the constraint index related to a SCIP constraint
GCG_EXPORT std::vector< SCIP_Real > & getValsForCons(int consIndex)
returns the nonzero coefficients of the coefficient matrix for a constraint
GCG_EXPORT int getNConssForCons(int consIndex)
returns the number of constraints for a given constraint
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 std::vector< SCIP_VAR * > getOrigVarsFixedZero()
returns pointers to all orig vars that are fixed to zero
GCG_EXPORT int getNVarsForCons(int consIndex)
returns the number of variables for a given constraint
GCG_EXPORT SCIP_Bool isPartialdecDuplicateofFinished(PARTIALDECOMP *partialdec)
check if partialdec is a duplicate of an existing finished partialdec
GCG_EXPORT PARTIALDECOMP * getFinishedPartialdec(int partialdecindex)
returns a partialdec from finished partialdec data structure
GCG_EXPORT int getNNonzeros()
returns the number of nonzero entries in the coefficient matrix
GCG_EXPORT bool isConsCardinalityCons(int consindexd)
returns whether a constraint is a cardinality constraint, i.e. of the
GCG_EXPORT SCIP_Bool isRangedRow(SCIP_Real lhs, SCIP_Real rhs)
is constraint ranged row, i.e., -inf < lhs < rhs < inf?
GCG_EXPORT int getNVars()
return the number of variables considered in the detprobdata
SCIP_Real nblockscandidatescalctime
GCG_EXPORT void freeTemporaryData()
frees temporary data that is only needed during the detection process
GCG_EXPORT bool isConsSetppc(int consindexd)
is cons with specified index partitioning packing, or covering constraint?
GCG_EXPORT void getSortedCandidatesNBlocks(std::vector< int > &candidates)
gets the candidates for number of blocks added by the user followed by the found ones sorted in desce...
GCG_EXPORT int getNConssForVar(int varIndex)
returns the number of constraints for a given variable where the var has a nonzero entry in
GCG_EXPORT std::vector< int > & getConssForCons(int consIndex)
return array of constraint indices that have a common variable with the given constraint
GCG_EXPORT void addVarPartition(VarPartition *partition)
adds a variable partition if it is no duplicate of an existing variable partition
GCG_EXPORT void addPartialdecToFinishedUnchecked(PARTIALDECOMP *partialdec)
adds a partialdec to finished partialdecs without checking for duplicates, dev has to check this on h...
GCG_EXPORT PARTIALDECOMP * getAncestorPartialdec(int partialdecindex)
returns a partialdec from ancestor partialdec data structure with given index
GCG_EXPORT int getNPartialdecs()
GCG_EXPORT SCIP_VAR * getVar(int varIndex)
returns SCIP variable related to a variable index
GCG_EXPORT SCIP_Bool isFiniteNonnegativeIntegral(SCIP_Real x)
is constraint ranged row, i.e., -inf < lhs < rhs < inf?
GCG_EXPORT void printBlockcandidateInformation(FILE *file)
output method for json file writer to write block candidate information
GCG_EXPORT GCG * getGcg()
returns the corresponding gcg data structure
GCG_EXPORT DETPROBDATA(GCG *gcgstruct, SCIP_Bool _originalProblem)
constructor
GCG_EXPORT std::vector< SCIP_CONS * > getRelevantConss()
returns pointers to all constraints that are not marked as deleted or obsolete
GCG_EXPORT VarPartition * getVarPartition(int partitionIndex)
returns pointer to a variable partition with given index
GCG_EXPORT std::vector< PARTIALDECOMP * > & getFinishedPartialdecs()
gets all finished partialdecs
std::vector< std::pair< int, int > > candidatesNBlocks
GCG_EXPORT void createConssAdjacency()
create the constraint adjacency datastructure that is used (if created) for some methods to faster ac...
GCG_EXPORT bool addPartialdecToFinished(PARTIALDECOMP *partialdec)
adds a partialdec to finished partialdecs
GCG_EXPORT void clearAncestorPartialdecs()
clears ancestor partialdec data structure,
GCG_EXPORT SCIP_Bool isConssAdjInitialized()
determines whether or not the constraint-constraint adjacency data structure is initilized
GCG_EXPORT int getNFinishedPartialdecs()
GCG_EXPORT SCIP_Real getVal(int row, int col)
returns a coefficient from the coefficient matrix
GCG_EXPORT int getNOpenPartialdecs()
returns size of current (open) partialdec data structure
GCG_EXPORT int getIndexForVar(SCIP_VAR *var)
returns the variable index related to a SCIP variable
GCG_EXPORT void sortFinishedForScore()
sorts partialdecs in finished partialdecs data structure according to the current scoretype
GCG_EXPORT void printPartitionInformation(FILE *file)
output method for json file writer to write partition candidate information
GCG_EXPORT int getNAncestorPartialdecs()
returns size of ancestor partialdec data structure
GCG_EXPORT std::vector< PARTIALDECOMP * > translatePartialdecs(DETPROBDATA *otherdata, std::vector< PARTIALDECOMP * > otherpartialdecs, SCIP_Bool translateSymmetry)
translates partialdecs if the index structure of the problem has changed, e.g. due to presolving
GCG_EXPORT bool isConsSetpp(int consindexd)
is cons with specified indec partitioning, or packing covering constraint?
GCG_EXPORT std::vector< int > & getVarsForCons(int consIndex)
returns the variable indices of the coefficient matrix for a constraint
GCG_EXPORT void addCandidatesNBlocksNVotes(int candidate, int nvotes)
adds a candidate for block number and counts how often a candidate is added
GCG_EXPORT int getNVarPartitions()
returns number of different variable partitions
GCG_EXPORT int getNConsPartitions()
returns number of different constraint partitions
std::vector< ConsPartition * > conspartitioncollection
std::vector< VarPartition * > varpartitioncollection
GCG_EXPORT void clearFinishedPartialdecs()
clears finished partialdec data structure
GCG_EXPORT void addConsPartition(ConsPartition *partition)
adds a constraint partition if it is no duplicate of an existing constraint partition
GCG_EXPORT std::vector< PARTIALDECOMP * > & getOpenPartialdecs()
determines all partialdecs from current (open) partialdec data structure
GCG_EXPORT std::vector< SCIP_VAR * > getRelevantVars()
returns pointers to all problem vars that are not fixed to 0
GCG_EXPORT SCIP_CONS * getCons(int consIndex)
returns the SCIP constraint related to a constraint index
GCG_EXPORT SCIP_Bool partialdecIsNoDuplicateOfPartialdecs(PARTIALDECOMP *comppartialdec, std::vector< PARTIALDECOMP * > const &partialdecs, bool sort)
check if partialdec is a duplicate of any given partialdecs
GCG_EXPORT std::vector< VarPartition * > getVarPartitions()
returns vector to stored variable partitions
GCG_EXPORT SCIP_Bool isAssignedToOrigProb()
returns true if the matrix structure corresponds to the presolved problem
GCG_EXPORT void clearCurrentPartialdecs()
clears current partialdec data structure
GCG_EXPORT const char * getName()
GCG_EXPORT bool isDuplicateOf(IndexPartition *otherPartition)
class to manage partial decompositions
GCG_EXPORT void setAncestorList(std::vector< int > &newlist)
GCG_EXPORT SCIP_Real getScore(GCG_SCORE *score)
returns the score of the partialdec
GCG_EXPORT bool checkConsistency()
Checks whether the assignments in the partialdec are consistent.
GCG_EXPORT void addAncestorID(int ancestor)
GCG_EXPORT void setNBlocks(int nblocks)
sets number of blocks, only increasing number allowed
GCG_EXPORT void fixConsToBlock(int cons, int block)
adds a constraint to a block
GCG_EXPORT int getVarProbindexForBlock(int varid, int block)
Gets the index of a variable in the vector returned by PARTIALDECOMP::getVarsForBlock.
GCG_EXPORT bool setSymmetryInformation(std::function< int(int)> blockmapping, std::function< int(int, int)> varmapping)
sets symmetry information
GCG_EXPORT PARTIALDECOMP(GCG *gcgstruct, bool originalProblem)
Standard constructor, creates empty partialdec with unique id.
GCG_EXPORT void addPctVarsToBorder(SCIP_Real pct)
adds percentage of variables assigned to border
GCG_EXPORT void addDetectorChainInfo(const char *decinfo)
add information about the detector chain
void setBlockStructure(int block, BLOCK_STRUCTURE *blockstructure)
sets structure information of a specific block
GCG_EXPORT bool isComplete()
Gets whether this partialdec is complete, i.e. it has no more open constraints and variables.
GCG_EXPORT void setFinishedByFinisher(bool finished)
sets whether this partialdec was finished by a finishing detector
GCG_EXPORT void addPctVarsFromFree(SCIP_Real pct)
adds percentage of closed variables
GCG_EXPORT void addPctConssToBorder(SCIP_Real pct)
adds percentage of constraints assigned to border
GCG_EXPORT void addPctConssToBlock(SCIP_Real pct)
adds percentage of constraints assigned to blocks
GCG_EXPORT SCIP_RETCODE isEqual(PARTIALDECOMP *otherpartialdec, SCIP_Bool *isequal, bool sortpartialdecs)
method to check whether this partialdec is equal to a given other partialdec (
GCG_EXPORT void setStemsFromOrig(bool fromorig)
sets whether this partialdec stems from an orig problem partialdec
GCG_EXPORT void setUsergiven(USERGIVEN usergiven)
sets whether this partialdec is user given
GCG_EXPORT void setDetectorFinishedOrig()
sets detector that finished the partialdec in the original problem
GCG_EXPORT void setDetectorchain(std::vector< GCG_DETECTOR * > &givenDetectorChain)
sets the detectorchain with the given vector of detector pointers
GCG_EXPORT void addNNewBlocks(int nnewblocks)
adds how many new blocks were introduced
GCG_EXPORT void addPctConssFromFree(SCIP_Real pct)
adds percentage of closed constraints
GCG_EXPORT void setFinishedByFinisherOrig(bool finished)
sets whether this partialdec was finished by a finishing detector in the original problem
GCG_EXPORT int getID()
returns the unique id of the partialdec
GCG_EXPORT void addClockTime(SCIP_Real clocktime)
adds detection time of one detector
GCG_EXPORT void copyPartitionStatistics(const PARTIALDECOMP *otherpartialdec)
copies the given partialdec's partition statistics
GCG_EXPORT std::vector< int >::const_iterator fixConsToMaster(std::vector< int >::const_iterator itr)
fixes a constraint to the master constraints
GCG_EXPORT std::vector< int > & getVarsForBlock(int block)
Gets array containing vars of a block.
GCG_EXPORT void addPctVarsToBlock(SCIP_Real pct)
adds percentage of variables assigned to blocks
GCG_EXPORT int getNBlocks()
Gets the number of blocks.
void GCGconshdlrDecompDeregisterPartialdecs(GCG *gcg, SCIP_Bool original)
deregisters partialdecs in the conshdlr
int GCGconshdlrDecompGetNBlockNumberCandidates(GCG *gcg)
returns the number of block candidates given by the user
GCG_SCORE * GCGgetCurrentScore(GCG *gcg)
Gets the currently enabled score.
DETPROBDATA * GCGconshdlrDecompGetDetprobdataOrig(GCG *gcg)
help method to access detprobdata for unpresolved problem
int GCGconshdlrDecompGetBlockNumberCandidate(GCG *gcg, int index)
returns block number user candidate with given index
constraint handler for structure detection
C++ interface of cons_decomp.
private methods for working with decomp structures
#define SCIP_MAXSTRLEN
#define SCIP_Bool
#define MAX(x, y)
#define SCIP_CALL_ABORT(x)
#define FALSE
GCG interface methods.
enum SCIP_SetppcType SCIP_SETPPCTYPE
SCIP_SETPPCTYPE SCIPgetTypeSetppc(SCIP *scip, SCIP_CONS *cons)
SCIP_SETPPCTYPE_PARTITIONING
SCIP_SETPPCTYPE_COVERING
SCIP_SETPPCTYPE_PACKING
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
int SCIPgetNOrigConss(SCIP *scip)
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
SCIP_CONS ** SCIPgetConss(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
SCIP_CONS * SCIPfindOrigCons(SCIP *scip, const char *name)
int SCIPgetNConss(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
int SCIPgetNOrigVars(SCIP *scip)
SCIP_CONS ** SCIPgetOrigConss(SCIP *scip)
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
SCIP_CONS * SCIPfindCons(SCIP *scip, const char *name)
SCIP_Bool GCGgetConsIsCardinalityCons(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:846
SCIP_Bool GCGgetConsIsSetppc(SCIP *scip, SCIP_CONS *cons, SCIP_SETPPCTYPE *setppctype)
Definition scip_misc.c:760
SCIP_RETCODE GCGconsGetVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int nvars)
Definition scip_misc.c:487
SCIP_RETCODE GCGconsGetVals(SCIP *scip, SCIP_CONS *cons, SCIP_Real *vals, int nvals)
Definition scip_misc.c:618
int GCGconsGetNVars(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:433
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsDeleted(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_RETCODE SCIPgetTransformedCons(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **transcons)
SCIP_Bool SCIPconsIsObsolete(SCIP_CONS *cons)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_RETCODE SCIPcaptureCons(SCIP *scip, SCIP_CONS *cons)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPfreeBufferArrayNull(scip, ptr)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_VAR * SCIPvarGetNegatedVar(SCIP_VAR *var)
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
SCIP_Bool SCIPvarIsNegated(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_RETCODE SCIPgetTransformedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **transvar)
static assert(heur !=NULL)
SCIP_VAR * var
SCIP_VAR ** vars
int j
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
int i
int nvars
#define NULL
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
miscellaneous methods for visualizations
SCIP_Bool varIsFixedToZero(SCIP *scip, SCIP_VAR *var)
public methods for working with decomposition structures
GP file reader writing decompositions to gnuplot files.
various SCIP helper methods
structure information for decomposition information in GCG projects
data structures for detectors
combine two hash function of objects of a pair to get a vaulue for the pair
bool operator()(const std::pair< int, int > &left, const std::pair< int, int > &right)
struct SCIP_Cons SCIP_CONS
struct Gcg GCG
Definition type_gcg.h:44
SCIP_VERBLEVEL_HIGH
SCIP_VERBLEVEL_FULL
struct Scip SCIP
struct GCG_Score GCG_SCORE
Definition type_score.h:45
struct SCIP_Var SCIP_VAR