Scippy

GCG

Branch-and-Price & Column Generation for Everyone

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