class_seeed.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-2018 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 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 
36 /*#define SCIP_DEBUG*/
37 
38 #include "class_seeed.h"
39 #include "gcg.h"
40 #include "class_seeedpool.h"
41 #include "scip/cons_setppc.h"
42 #include "scip/scip.h"
43 #include "scip_misc.h"
44 #include "decomp.h"
45 #include "struct_detector.h"
46 #include "struct_decomp.h"
47 #include "cons_decomp.h"
48 #include "params_visu.h"
50 #include "reader_gp.h"
51 
52 #include <sstream>
53 #include <iostream>
54 #include <exception>
55 #include <algorithm>
56 #include <queue>
57 #include <fstream>
58 #include <stdlib.h>
59 
60 #ifdef WITH_BLISS
61 #include "pub_bliss.h"
62 #include "bliss_automorph.h"
63 #endif
64 
65 
66 #define SCIP_CALL_EXC( x ) do \
67  { \
68  SCIP_RETCODE _restat_; \
69  if( ( _restat_ = ( x ) ) != SCIP_OKAY ) \
70  { \
71  SCIPerrorMessage( "Error <%d> in function call\n", _restat_ ); \
72  throw std::exception(); \
73  } \
74  } \
75  while( FALSE )
76 
77 namespace gcg {
78 
79 const int Seeed::primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
80  101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227,
81  229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349};
82 
83 const int Seeed::nPrimes = 70;
84 
88  SCIP* _scip,
89  int givenid,
90  Seeedpool* givenseeedpool
91  ) :
92  scip( _scip ), id( givenid ), nBlocks( 0 ), nVars( givenseeedpool->getNVars() ), nConss( givenseeedpool->getNConss() ), masterConss( 0 ),
93  masterVars( 0 ), conssForBlocks( 0 ), varsForBlocks( 0 ), linkingVars( 0 ), stairlinkingVars( 0 ), isvaropen( givenseeedpool->getNVars(), true ),
94  isconsopen( givenseeedpool->getNConss(), true ), isvarmaster( givenseeedpool->getNVars(), false ), isconsmaster( givenseeedpool->getNConss(), false ),
95  ncoeffsforblock(std::vector<int>(0)), calculatedncoeffsforblock(FALSE), ncoeffsforblockformastercons(0),
96  varsforblocksorted(true), stairlinkingvarsforblocksorted(true),
97  conssforblocksorted(true), linkingvarssorted(true), mastervarssorted(true),
98  masterconsssorted(true), hashvalue( 0 ), changedHashvalue( false ), isselected( false ), isagginfoalreadytoexpensive(false), isFinishedByFinisher( false ),
99  agginfocalculated(FALSE), nrepblocks(0), reptoblocks(std::vector<std::vector<int>>(0)), blockstorep(std::vector<int>(0) ), pidtopidvarmaptofirst(std::vector<std::vector<std::vector<int> > >(0)),
100  detectorChain( 0 ), detectorChainFinishingUsed( 0 ), detectorClockTimes( 0 ), pctVarsToBorder( 0 ),
101  pctVarsToBlock( 0 ), pctVarsFromFree( 0 ), pctConssToBorder( 0 ), pctConssToBlock( 0 ), pctConssFromFree( 0 ),
102  nNewBlocks( 0 ), usedClassifier( 0 ), classesToMaster( 0 ), classesToLinking( 0 ), listofancestorids( 0 ),
103  usergiven( USERGIVEN::NOT ), isfromlegacymode( false ), score( -1. ), maxwhitescore( -1. ), bendersscore(-1.), benderareascore(-1.), strongdecompositionscore(-1.), borderareascore( -1. ),
104  maxwhitescoreagg(-1.), blockareascore(-1.), blockareascoreagg(-1.), maxforeseeingwhitescore(-1.),
105  maxforeseeingwhitescoreagg(-1.), setpartfwhitescore(-1.), setpartfwhitescoreagg(-1.),
106  detectorchainstring( NULL ), stemsFromUnpresolved( false ), isfromunpresolved( FALSE ),
107  isFinishedByFinisherUnpresolved( false ), finishedUnpresolvedBy( NULL ), seeedpool(givenseeedpool)
108 {
109 
110  for( int i = 0; i < nConss; ++i )
111  openConss.push_back(i);
112 
113  for( int i = 0; i < nVars; ++i )
114  openVars.push_back(i);
115 
116 }
117 
120  const Seeed *seeedtocopy
121  )
122 {
123  scip = ( seeedtocopy->scip );
124  id = seeedtocopy->id;
125  nBlocks = seeedtocopy->nBlocks;
126  nVars = seeedtocopy->nVars;
127  nConss = seeedtocopy->nConss;
128  masterConss = seeedtocopy->masterConss;
129  masterVars = seeedtocopy->masterVars;
130  conssForBlocks = seeedtocopy->conssForBlocks;
131  varsForBlocks = seeedtocopy->varsForBlocks;
132  linkingVars = seeedtocopy->linkingVars;
133  stairlinkingVars = seeedtocopy->stairlinkingVars;
134  openVars = seeedtocopy->openVars;
135  openConss = seeedtocopy->openConss;
136 
137  isvaropen = seeedtocopy->isvaropen;
138  masterconsssorted = seeedtocopy->masterconsssorted;
139 
140  isconsopen = seeedtocopy->isconsopen;
141 
142  isvarmaster = seeedtocopy->isvarmaster;
143  isconsmaster = seeedtocopy->isconsmaster;
144 
145  detectorChain = seeedtocopy->detectorChain;
146  detectorChainFinishingUsed = seeedtocopy->detectorChainFinishingUsed;
147  detectorchaininfo = seeedtocopy->detectorchaininfo;
148  hashvalue = seeedtocopy->hashvalue;
149  usergiven = seeedtocopy->usergiven;
150  isfromlegacymode = seeedtocopy->isfromlegacymode;
151  score = seeedtocopy->score;
152  borderareascore = seeedtocopy->borderareascore;
153  maxwhitescore = seeedtocopy->maxwhitescore;
154  bendersscore = -1.;
155  benderareascore = -1.;
156  changedHashvalue = seeedtocopy->changedHashvalue;
157  detectorClockTimes = seeedtocopy->detectorClockTimes;
158  pctVarsToBorder = seeedtocopy->pctVarsToBorder;
159  pctVarsToBlock = seeedtocopy->pctVarsToBlock;
160  pctVarsFromFree = seeedtocopy->pctVarsFromFree;
161  pctConssToBorder = seeedtocopy->pctConssToBorder;
162  pctConssToBlock = seeedtocopy->pctConssToBlock;
163  pctConssFromFree = seeedtocopy->pctConssFromFree;
164  usedClassifier = seeedtocopy->usedClassifier;
165  classesToMaster = seeedtocopy->classesToMaster;
166  classesToLinking = seeedtocopy->classesToLinking;
167  isFinishedByFinisher = seeedtocopy->isFinishedByFinisher;
168  ncoeffsforblockformastercons = seeedtocopy->ncoeffsforblockformastercons;
169  changedHashvalue = seeedtocopy->changedHashvalue;
170  nNewBlocks = seeedtocopy->nNewBlocks;
171  stemsFromUnpresolved = seeedtocopy->stemsFromUnpresolved;
172  finishedUnpresolvedBy = seeedtocopy->finishedUnpresolvedBy;
173  isFinishedByFinisherUnpresolved = seeedtocopy->isFinishedByFinisherUnpresolved;
174  isselected = false;
175  detectorchainstring = NULL;
176  isfromunpresolved = seeedtocopy->isfromunpresolved;
177  listofancestorids = seeedtocopy->listofancestorids;
178 
179  varsforblocksorted = seeedtocopy->varsforblocksorted;
180  stairlinkingvarsforblocksorted = seeedtocopy->stairlinkingvarsforblocksorted;
181  conssforblocksorted = seeedtocopy->conssforblocksorted;
182  linkingvarssorted = seeedtocopy->linkingvarssorted;
183  mastervarssorted = seeedtocopy->mastervarssorted;
184 
185  agginfocalculated = FALSE;
186  nrepblocks = seeedtocopy->nrepblocks;
187  reptoblocks = seeedtocopy->reptoblocks;
188  blockstorep = seeedtocopy->blockstorep;
189  pidtopidvarmaptofirst = seeedtocopy->pidtopidvarmaptofirst;
190  ncoeffsforblock = seeedtocopy->ncoeffsforblock;
191  calculatedncoeffsforblock = FALSE;
192 
193  blockareascore = -1.;
194  maxwhitescoreagg = -1.;
195  blockareascoreagg = -1.;
196  maxforeseeingwhitescore = -1.;
197  maxforeseeingwhitescoreagg = -1.;
198 
199  setpartfwhitescore = -1.;
200  setpartfwhitescoreagg = -1.;
201 
202  isagginfoalreadytoexpensive = seeedtocopy->isagginfoalreadytoexpensive;
203 
204  seeedpool = seeedtocopy->seeedpool;
205 
206 }
207 
210 {
211  if ( detectorchainstring != NULL )
212  SCIPfreeBlockMemoryArrayNull( scip, & detectorchainstring, SCIP_MAXSTRLEN );
213 }
214 
215 
217 static
219  SCIP* scip,
220  SCIP_Real* array1,
221  int array1length,
222  SCIP_Real* array2,
223  int array2length
224  )
225 {
226  int i;
227 
228  if( array1length != array2length )
229  return FALSE;
230 
231  if( array1length == 0 )
232  return TRUE;
233 
234  assert(array1 != NULL);
235  assert(array2 != NULL);
236 
237  for( i = 0; i < array1length; i++ )
238  {
239  if( !SCIPisEQ(scip, array1[i], array2[i]) )
240  return FALSE;
241  }
242 
243  return TRUE;
244 }
245 
246 
249  std::pair<int, int> const & a,
250  std::pair<int, int> const & b
251  )
252 {
253  return ( a.second < b.second );
254 }
255 
258 {
259  std::vector<int> vector = std::vector<int>( 0 );
260 
261  changedHashvalue = true;
262 
263  assert( (int) conssForBlocks.size() == nBlocks );
264  assert( (int) varsForBlocks.size() == nBlocks );
265  assert( (int) stairlinkingVars.size() == nBlocks );
266 
267  conssForBlocks.push_back( vector );
268  varsForBlocks.push_back( vector );
269  stairlinkingVars.push_back( vector );
270  nBlocks ++;
271  return nBlocks - 1;
272 }
273 
276  SCIP_Real clocktime
277  )
278 {
279  detectorClockTimes.push_back( clocktime );
280 }
281 
284  Seeed* ancestor
285  )
286 {
288  assert( ancestor != NULL );
289 
290  nNewBlocks.push_back( getNBlocks() - ancestor->getNBlocks() );
291  pctConssFromFree.push_back( getNConss() != 0 ? ( ancestor->getNOpenconss() - getNOpenconss() ) / (SCIP_Real) getNConss() : 0. );
292  pctVarsFromFree.push_back( getNVars() != 0 ? ( ancestor->getNOpenvars() - getNOpenvars() ) / (SCIP_Real) getNVars() : 0. );
293  pctConssToBlock.push_back( getNConss() != 0 ?
294  ( - getNOpenconss() - getNMasterconss() + ancestor->getNOpenconss() + ancestor->getNMasterconss() ) / getNConss() : 0. );
295  pctVarsToBlock.push_back( getNVars() != 0 ? ( - getNOpenvars() - getNMastervars() - getNLinkingvars() - getNTotalStairlinkingvars() + ancestor->getNOpenvars()
296  + ancestor->getNMastervars() + ancestor->getNLinkingvars() + ancestor->getNTotalStairlinkingvars() ) / getNVars() : 0. );
297  pctConssToBorder.push_back( getNConss() != 0 ? ( getNMasterconss() - ancestor->getNMasterconss() ) / (SCIP_Real) getNConss() : 0. );
298  pctVarsToBorder.push_back( getNVars() != 0 ? ( getNMastervars() + getNLinkingvars() + getNTotalStairlinkingvars() - ancestor->getNMastervars()
299  - ancestor->getNLinkingvars() - ancestor->getNTotalStairlinkingvars() ) / (SCIP_Real) getNVars() : 0. );
300  listofancestorids.push_back( ancestor->getID() );
301 }
302 
305  const char* decinfo
306  )
307 {
308  std::stringstream help;
309  help << decinfo;
310  detectorchaininfo.push_back( help.str() );
311 }
312 
314 void Seeed::addEmptyClassifierStatistics()
315 {
316  std::vector<int> emptyVector( 0 );
317  usedClassifier.push_back( NULL );
318  classesToMaster.push_back( emptyVector );
319  classesToLinking.push_back( emptyVector );
320 }
321 
324  int nnewblocks
325  )
326  {
327  nNewBlocks.push_back( nnewblocks );
328 
329  assert( nNewBlocks.size() <= detectorChain.size() );
330  }
331 
334  SCIP_Real pct
335  )
336  {
337  pctConssFromFree.push_back( pct );
338 
339  assert( pctConssFromFree.size() <= detectorChain.size() );
340  }
341 
344  SCIP_Real pct
345  )
346  {
347  pctConssToBlock.push_back( pct );
348 
349  assert( pctConssToBlock.size() <= detectorChain.size() );
350  }
351 
354  SCIP_Real pct
355  )
356  {
357  pctConssToBorder.push_back( pct );
358 
359  assert( pctConssToBorder.size() <= detectorChain.size() );
360  }
361 
364  SCIP_Real pct
365  )
366  {
367  pctVarsFromFree.push_back( pct );
368 
369  assert( pctVarsFromFree.size() <= detectorChain.size() );
370  }
371 
374  SCIP_Real pct
375  )
376  {
377  pctVarsToBlock.push_back( pct );
378 
379  assert( pctVarsToBlock.size() <= detectorChain.size() );
380  }
381 
384  SCIP_Real pct
385  )
386  {
387  pctVarsToBorder.push_back( pct );
388 
389  assert( pctVarsToBorder.size() <= detectorChain.size() );
390  }
391 
394 {
395  for( int b = 0; b < this->nBlocks; ++ b )
396  if( conssForBlocks[b].size() != 0 )
397  return true;
398  return false;
399 }
400 
403  SCIP_HASHMAP* constoblock,
404  int givenNBlocks
405  )
406 {
407  int cons;
408 
409  changedHashvalue = true;
410 
411  for( int i = 0; i < getNOpenconss(); ++ i )
412  {
413  cons = openConss[i];
414  if( ! SCIPhashmapExists( constoblock, (void*) (size_t) cons ) )
415  continue;
416  if( (int) (size_t) SCIPhashmapGetImage( constoblock, (void*) (size_t) cons ) - 1 == givenNBlocks )
417  bookAsMasterCons( cons );
418  }
419 
420  flushBooked();
421 
422  sort();
423  assert( checkConsistency( ) );
424  return SCIP_OKAY;
425 }
426 
430  )
431 {
432  std::vector<int> blocksOfOpenvar;
433  bool assigned = false;
434  int var;
435  int cons;
436 
437  changedHashvalue = true;
438 
440  for( int i = 0; i < getNOpenvars(); ++ i )
441  {
442  blocksOfOpenvar.clear();
443  var = openVars[i];
444  for( int b = 0; b < nBlocks; ++ b )
445  {
446  for( int c = 0; c < getNConssForBlock( b ); ++ c )
447  {
448  cons = conssForBlocks[b][c];
449  if( seeedpool->getVal( cons, var ) != 0 )
450  {
451  blocksOfOpenvar.push_back( b );
452  break;
453  }
454  }
455  }
456  if( blocksOfOpenvar.size() == 2 && blocksOfOpenvar[0] + 1 == blocksOfOpenvar[1] )
457  {
458  bookAsStairlinkingVar( var, blocksOfOpenvar[0] );
459  assigned = true;
460  }
461  }
462 
463  flushBooked();
464 
465  if( assigned )
466  sort();
467  return assigned;
468 }
469 
477 bool Seeed::assignHittingOpenconss(
478  )
479 {
480  int cons;
481  int var;
482  int block;
483  bool stairlinking;
484  bool assigned = false;
485  std::vector<int>::iterator it;
486  std::vector<int> blocksOfStairlinkingvars;
487  std::vector<int> blocksOfVars;
488  std::vector<int> blocks;
489  std::vector<int> eraseBlock;
490 
491  changedHashvalue = true;
492 
493  for( size_t c = 0; c < openConss.size(); ++ c )
494  {
495  cons = openConss[c];
496  stairlinking = false;
497 
498  blocksOfVars.clear();
499  blocks.clear();
500  blocksOfStairlinkingvars.clear();
501  eraseBlock.clear();
502 
504  for( int b = 0; b < nBlocks; ++ b )
505  {
506  for( int v = 0; v < seeedpool->getNVarsForCons( cons ); ++ v )
507  {
508  var = seeedpool->getVarsForCons( cons )[v];
509  if( isVarBlockvarOfBlock( var, b ) )
510  {
511  blocksOfVars.push_back( b );
512  break;
513  }
514  }
515  }
516 
517  for( int b = 0; b < nBlocks; ++ b )
518  {
519  for( int v = 0; v < seeedpool->getNVarsForCons( cons ); ++ v )
520  {
521  int var2 = seeedpool->getVarsForCons(cons)[v];
522  std::vector<int>::iterator lb = lower_bound( stairlinkingVars[b].begin(), stairlinkingVars[b].end(), var2 );
523  if( lb != stairlinkingVars[b].end() && *lb == var2 )
524  {
525  stairlinking = true;
526  blocksOfStairlinkingvars.push_back( b );
527  break;
528  }
529  }
530  }
531 
533  if( stairlinking && blocksOfVars.size() < 2 )
534  {
535  if( blocksOfVars.size() == 0 )
536  {
537  blocks.push_back( blocksOfStairlinkingvars[0] );
538  blocks.push_back( blocksOfStairlinkingvars[0] + 1 );
539  for( size_t i = 1; i < blocksOfStairlinkingvars.size(); ++ i )
540  {
541  for( it = blocks.begin(); it != blocks.end(); ++ it )
542  {
543  if( * it != blocksOfStairlinkingvars[i] && * it != blocksOfStairlinkingvars[i] + 1 )
544  eraseBlock.push_back( * it );
545  }
546  for( size_t j = 0; j < eraseBlock.size(); ++ j )
547  {
548  it = find( blocks.begin(), blocks.end(), eraseBlock[j] );
549  assert( it != blocks.end() );
550  blocks.erase( it );
551  }
552  }
553  }
554  else
555  {
556  blocks.push_back( blocksOfVars[0] );
557  for( size_t i = 0; i < blocksOfStairlinkingvars.size(); ++ i )
558  {
559  if( blocks[0] != blocksOfStairlinkingvars[i] && blocks[0] != blocksOfStairlinkingvars[i] + 1 )
560  {
561  blocks.clear();
562  break;
563  }
564  }
565  }
566  }
567 
568  if( blocksOfVars.size() > 1 )
569  {
570  bookAsMasterCons( cons );
571  assigned = true;
572  }
573  else if( ! stairlinking && blocksOfVars.size() == 1 )
574  {
575  bookAsBlockCons( cons, blocksOfVars[0] );
576  assigned = true;
577  }
578  else if( stairlinking && blocks.size() == 0 )
579  {
580  bookAsMasterCons( cons );
581  assigned = true;
582  }
583  else if( stairlinking && blocks.size() == 1 )
584  {
585  bookAsBlockCons( cons, blocks[0] );
586  assigned = true;
587  }
588  else if( stairlinking && blocks.size() > 1 )
589  {
590  block = blocks[0];
591  for( size_t i = 1; i < blocks.size(); ++ i )
592  {
593  if( getNConssForBlock( i ) < getNConssForBlock( block ) )
594  block = i;
595  }
596  bookAsBlockCons( cons, block );
597  assigned = true;
598  }
599  }
600 
601  flushBooked();
602 
603  if( assigned )
604  sort();
605 
606  return assigned;
607 }
608 
613 bool Seeed::assignHittingOpenvars(
614  )
615 {
616  int cons;
617  int var;
618  std::vector<int> blocksOfOpenvar;
619  bool found;
620  bool assigned = false;
621 
622  changedHashvalue = true;
623 
626  for( size_t i = 0; i < openVars.size(); ++ i )
627  {
628  blocksOfOpenvar.clear();
629  var = openVars[i];
630  assert( var >= 0 && var < nVars );
631  for( int b = 0; b < nBlocks; ++ b )
632  {
633  found = false;
634  for( int c = 0; c < getNConssForBlock( b ) && ! found; ++ c )
635  {
636  cons = conssForBlocks[b][c];
637  for( int v = 0; v < seeedpool->getNVarsForCons( cons ) && ! found; ++ v )
638  {
639  if( seeedpool->getVarsForCons( cons )[v] == var )
640  {
641  blocksOfOpenvar.push_back( b );
642  found = true;
643  }
644  }
645  }
646  }
647  if( blocksOfOpenvar.size() == 1 )
648  {
649  bookAsBlockVar( var, blocksOfOpenvar[0] );
650  assigned = true;
651  }
652  else if( blocksOfOpenvar.size() > 1 )
653  {
654  bookAsLinkingVar( var );
655  assigned = true;
656  }
657  }
658 
659  flushBooked();
660 
661  if( assigned )
662  sort();
663 
664  return assigned;
665 }
666 
670 SCIP_RETCODE Seeed::assignOpenPartialHittingConsToMaster(
671  )
672 {
673  int cons;
674  int var;
675  std::vector<int> blocksOfBlockvars;
676  std::vector<int> blocksOfOpenvar;
677  bool master;
678  bool hitsOpenVar;
679  std::vector<bool> isblockhit;
680  changedHashvalue = true;
681 
683  for( size_t c = 0; c < openConss.size(); ++ c )
684  {
685  isblockhit= std::vector<bool>(getNBlocks(), false );
686  blocksOfBlockvars.clear();
687  master = false;
688  hitsOpenVar = false;
689  cons = openConss[c];
690 
691 
692  for( int v = 0; v < seeedpool->getNVarsForCons( cons ) && ! master; ++ v )
693  {
694  var = seeedpool->getVarsForCons( cons )[v];
695 
696  if( isVarOpenvar( var ) )
697  {
698  hitsOpenVar = true;
699  continue;
700  }
701 
702  if( isVarMastervar( var ) )
703  {
704  master = true;
705  bookAsMasterCons( cons );
706  continue;
707  }
708 
709  for( int b = 0; b < nBlocks; ++ b )
710  {
711  if( isblockhit[b] )
712  continue;
713 
714  if( isVarBlockvarOfBlock( var, b ) )
715  {
716  blocksOfBlockvars.push_back( b );
717  isblockhit[b] = true;
718  break;
719  }
720  }
721  }
722  if( blocksOfBlockvars.size() == 1 && hitsOpenVar )
723  {
724  bookAsMasterCons( cons );
725  }
726  }
727 
728  flushBooked();
729 
730  return SCIP_OKAY;
731 }
732 
734 SCIP_RETCODE Seeed::assignOpenPartialHittingToMaster(
735  )
736 {
737  changedHashvalue = true;
738  assignOpenPartialHittingConsToMaster( );
739  assignOpenPartialHittingVarsToMaster( );
740  return SCIP_OKAY;
741 }
742 
745 SCIP_RETCODE Seeed::assignOpenPartialHittingVarsToMaster(
746  )
747 {
748  int cons;
749  int var;
750  std::vector<int> blocksOfBlockvars;
751  std::vector<int> blocksOfOpenvar;
752  bool hitsOpenCons;
753  std::vector<bool> isblockhit;
754  bool benders;
755 
756  changedHashvalue = true;
757  benders = seeedpool->isForBenders();
758 
760  for( size_t i = 0; i < openVars.size(); ++ i )
761  {
762  isblockhit= std::vector<bool>(getNBlocks(), false );
763  blocksOfOpenvar.clear();
764  var = openVars[i];
765  hitsOpenCons = false;
766 
767  for( int c = 0; c < seeedpool->getNConssForVar( var ); ++ c )
768  {
769  cons = seeedpool->getConssForVar( var )[c];
770 
771  if( benders && isConsMastercons( cons ) )
772  {
773  continue;
774  }
775 
776  if( isConsOpencons( cons ) )
777  {
778  hitsOpenCons = true;
779  continue;
780  }
781  for( int b = 0; b < nBlocks; ++ b )
782  {
783  if ( isblockhit[b] )
784  continue;
785 
786  if( isConsBlockconsOfBlock( cons, b ) )
787  {
788  blocksOfOpenvar.push_back( b );
789  isblockhit[b] = true;
790  break;
791  }
792  }
793 
794  }
795 
796 // if( benders && hitsmastercons )
797 // {
798 // bookAsLinkingVar( var );
799 // }
800 
801  if( blocksOfOpenvar.size() == 1 && hitsOpenCons )
802  {
803  bookAsLinkingVar( var );
804  }
805  }
806 
807  flushBooked();
808 
809 
810  return SCIP_OKAY;
811 }
812 
816  SCIP_HASHMAP* constoblock,
817  int additionalNBlocks
818 )
819 {
820  int oldNBlocks = nBlocks;
821  int consblock;
822  int cons;
823 
824  assert( additionalNBlocks >= 0 );
825 
826  changedHashvalue = true;
827 
828  for( int b = 0; b < additionalNBlocks; ++ b )
829  addBlock();
830 
831  for( int i = 0; i < getNOpenconss(); ++ i )
832  {
833  cons = openConss[i];
834 
835  if( ! SCIPhashmapExists( constoblock, (void*) (size_t) cons ) )
836  continue;
837  consblock = oldNBlocks + ( (int) (size_t) SCIPhashmapGetImage( constoblock, (void*) (size_t) cons ) - 1 );
838  assert( consblock >= oldNBlocks && consblock <= nBlocks );
839  if( consblock == nBlocks )
840  bookAsMasterCons( cons );
841  else
842  bookAsBlockCons( cons, consblock );
843  }
844 
845  flushBooked();
846 
847  deleteEmptyBlocks(false);
848  sort();
849  assert( checkConsistency( ) );
850  return SCIP_OKAY;
851 }
852 
856  std::vector<int> constoblock,
857  int additionalNBlocks
858  )
859 {
860  int oldNBlocks = nBlocks;
861  int consblock;
862  int cons;
863 
864  assert( additionalNBlocks >= 0 );
865 
866  changedHashvalue = true;
867 
868  for( int b = 0; b < additionalNBlocks; ++ b )
869  addBlock();
870 
871  for( int i = 0; i < getNOpenconss(); ++ i )
872  {
873  cons = openConss[i];
874 
875  if( constoblock[cons] == - 1 )
876  continue;
877 
878  consblock = oldNBlocks + ( constoblock[cons] - 1 );
879  assert( consblock >= oldNBlocks && consblock <= nBlocks );
880  if( consblock == nBlocks )
881  bookAsMasterCons( cons );
882  else
883  bookAsBlockCons( cons, consblock );
884  }
885 
886  flushBooked();
887 
888  deleteEmptyBlocks(false);
889  sort();
890  assert( checkConsistency( ) );
891  return SCIP_OKAY;
892 }
893 
896  int consToBlock,
897  int block
898  )
899 {
900  assert( consToBlock >= 0 && consToBlock < nConss );
901  assert( isconsopen[consToBlock] );
902  if( block >= nBlocks )
903  setNBlocks(block+1);
904  assert( block >= 0 && block < nBlocks );
905  std::pair<int, int> pair( consToBlock, block );
906  bookedAsBlockConss.push_back( pair );
907  return SCIP_OKAY;
908 }
909 
912  int varToBlock,
913  int block
914  )
915 {
916  assert( varToBlock >= 0 && varToBlock < nVars );
917  assert( isvaropen[varToBlock] );
918  assert( block >= 0 && block < nBlocks );
919  std::pair<int, int> pair( varToBlock, block );
920  bookedAsBlockVars.push_back( pair );
921  return SCIP_OKAY;
922 }
923 
926  int consToMaster
927  )
928 {
929  assert( consToMaster >= 0 && consToMaster < nConss );
930  assert(isconsopen[consToMaster]);
931  bookedAsMasterConss.push_back( consToMaster );
932  return SCIP_OKAY;
933 }
934 
937  int varToMaster
938  )
939 {
940  assert( varToMaster >= 0 && varToMaster < nVars );
941  assert( isvaropen[varToMaster]);
942  bookedAsMasterVars.push_back( varToMaster );
943  return SCIP_OKAY;
944 }
945 
948  int varToLinking
949  )
950 {
951  assert( varToLinking >= 0 && varToLinking < nVars );
952  assert( isvaropen[varToLinking]);
953  bookedAsLinkingVars.push_back( varToLinking );
954  return SCIP_OKAY;
955 }
956 
959  int varToStairlinking,
960  int firstBlock
961  )
962 {
963  assert( isvaropen[varToStairlinking]);
964  assert( varToStairlinking >= 0 && varToStairlinking < nVars );
965  assert( firstBlock >= 0 && firstBlock < ( nBlocks - 1 ) );
966  std::pair<int, int> pair( varToStairlinking, firstBlock );
967  bookedAsStairlinkingVars.push_back( pair );
968  return SCIP_OKAY;
969 }
970 
979 
980  std::vector<int> constoblocks = std::vector<int>(nConss, -1);
981  std::vector<int> vartoblocks = std::vector<int>(nVars, -1);
982  std::vector<int> mergeblocks = std::vector< int>(0);
983  int potentialnewblocks = 0;
984 
985 
986  for( int openvar = 0; openvar < getNVars(); ++openvar )
987  {
989  if( SCIPvarGetType(seeedpool->getScipVar(openvar) ) != SCIP_VARTYPE_BINARY )
990  {
991  int blockid = -1;
992  std::vector<bool> hitblock = std::vector<bool>(potentialnewblocks, false);
993  std::vector<int> hittenblocks = std::vector<int>(0);
994  for( int c = 0; c < seeedpool->getNConssForVar(openvar); ++c )
995  {
996  int cons = seeedpool->getConssForVar(openvar)[c];
997  if( constoblocks[cons] != -1 )
998  {
999  if( !hitblock[constoblocks[cons]] )
1000  {
1001  hitblock[constoblocks[cons]] = true;
1002  hittenblocks.push_back(constoblocks[cons]);
1003  }
1004  }
1005  }
1006 
1007  if( hittenblocks.size() == 0 )
1008  {
1009  ++potentialnewblocks;
1010  blockid = potentialnewblocks - 1;
1011  mergeblocks.push_back(blockid);
1012  vartoblocks[openvar] = blockid;
1013  }
1014 
1015  if( hittenblocks.size() == 1 )
1016  {
1017  blockid = hittenblocks[0];
1018  vartoblocks[openvar] = hittenblocks[0];
1019  }
1020 
1021  if( hittenblocks.size() > 1 )
1022  {
1023  int minblock = hittenblocks[0];
1024  for( size_t i = 1; i < hittenblocks.size(); ++i )
1025  {
1026  if( hittenblocks[i] < minblock )
1027  minblock = hittenblocks[i];
1028  }
1029  int mergeto = mergeblocks[minblock];
1030  for( size_t i = 0; i < hittenblocks.size(); ++i )
1031  {
1032  mergeblocks[hittenblocks[i]] = mergeto;
1033  }
1034  blockid = minblock;
1035  vartoblocks[openvar] = blockid;
1036  }
1037 
1038  assert(blockid != -1);
1039  for( int c = 0; c < seeedpool->getNConssForVar(openvar); ++c )
1040  {
1041  int cons = seeedpool->getConssForVar(openvar)[c];
1042  constoblocks[cons] = blockid;
1043  }
1044  }
1045  }
1046 
1047 
1048  int nnewblocks = 0;
1049  std::vector<int> currblocks = std::vector<int>(mergeblocks.size(), -1);
1050  for( int b = 0; b < potentialnewblocks; ++b )
1051  if( mergeblocks[b] == b )
1052  {
1053  currblocks[b] = nnewblocks;
1054  ++nnewblocks;
1055  }
1056  else
1057  currblocks[b] = currblocks[mergeblocks[b]];
1058 
1059  setNBlocks(nnewblocks);
1060 
1061  for( int openvar = 0; openvar < getNVars(); ++openvar )
1062  {
1063  if( vartoblocks[openvar] != -1)
1064  bookAsBlockVar(openvar, currblocks[vartoblocks[openvar]] );
1065  }
1066 
1067  for( int cons = 0; cons < getNConss(); ++cons )
1068  {
1069  if( constoblocks[cons] != -1)
1070  bookAsBlockCons(cons, currblocks[constoblocks[cons]]);
1071  }
1072 
1073  flushBooked();
1074 
1075  return;
1076 
1077 }
1078 
1080 {
1081 
1082  int limitfornconss;
1083  int limitfornvars;
1084 
1085  if( isagginfoalreadytoexpensive )
1086  return TRUE;
1087 
1088  SCIPgetIntParam(seeedpool->getScip(), "detection/aggregation/limitnconssperblock", &limitfornconss);
1089  SCIPgetIntParam(seeedpool->getScip(), "detection/aggregation/limitnvarsperblock", &limitfornvars);
1090 
1091 
1092 
1094  for( int b1 = 0; b1 < getNBlocks() ; ++b1 )
1095  {
1096  for( int b2 = b1+1; b2 < getNBlocks(); ++b2 )
1097  {
1098  if( getNVarsForBlock(b1) != getNVarsForBlock(b2) )
1099  continue;
1100 
1101  if( getNConssForBlock(b1) != getNConssForBlock(b2) )
1102  continue;
1103 
1104  SCIPdebugMessage("Checking if agg info is too expensive for blocks %d and %d, nconss: %d, nvars: %d . \n", b1, b2, getNConssForBlock(b2), getNVarsForBlock(b2) );
1105  if( getNConssForBlock(b2) >= limitfornconss || getNVarsForBlock(b2) >= limitfornvars )
1106  {
1107  SCIPdebugMessage("Calculating agg info is too expensive, nconss: %d, nvars: %d . \n", getNConssForBlock(b2), getNVarsForBlock(b2) );
1108  isagginfoalreadytoexpensive = true;
1109  return TRUE;
1110  }
1111  }
1112 
1113  }
1114 
1117  SCIPdebugMessage("Calculated: agg info is NOT too expensive.\n");
1118  return FALSE;
1119 }
1120 
1121 
1122 
1125  )
1126  {
1127 #ifdef WITH_BLISS
1128  SCIP_Bool tooexpensive;
1129 #endif
1130  SCIP_Bool aggisnotactive;
1131  SCIP_Bool discretization;
1132  SCIP_Bool aggregation;
1133 
1134  int nreps = 1;
1135 
1136  if( agginfocalculated )
1137  return;
1138 
1139  if( !isComplete() )
1140  return;
1141 
1142 #ifdef WITH_BLISS
1143  if( isAgginfoToExpensive() )
1144  tooexpensive = TRUE;
1145  else
1146  tooexpensive = FALSE;
1147 #endif
1148 
1149  SCIPgetBoolParam(seeedpool->getScip(), "relaxing/gcg/aggregation", &aggregation);
1150  SCIPgetBoolParam(seeedpool->getScip(), "relaxing/gcg/discretization", &discretization);
1151 
1152  if( discretization && aggregation )
1153  aggisnotactive = FALSE;
1154  else
1155  aggisnotactive = TRUE;
1156 
1157  std::vector<std::vector<int>> identblocksforblock( getNBlocks(), std::vector<int>(0) );
1158 
1159  blockstorep = std::vector<int>(getNBlocks(), -1);
1160 
1161  for( int b1 = 0; b1 < getNBlocks() ; ++b1 )
1162  {
1163  std::vector<int> currrep = std::vector<int>(0);
1164  std::vector< std::vector<int> > currrepvarmapforthisrep =std::vector<std::vector<int>>(0);
1165  std::vector<int> identityvec = std::vector<int>(0);
1166 
1167 
1168  if( !identblocksforblock[b1].empty() )
1169  continue;
1170 
1171  for( int i = 0; i < getNVarsForBlock(b1); ++i )
1172  identityvec.push_back(i);
1173 
1174  currrep.push_back(b1);
1175  currrepvarmapforthisrep.push_back(identityvec);
1176 
1177 
1178  for( int b2 = b1+1; b2 < getNBlocks(); ++b2 )
1179  {
1180  SCIP_Bool identical;
1181  SCIP_Bool notidentical;
1182  std::vector<int> varmap;
1183  SCIP_HASHMAP* varmap2;
1184 
1185  notidentical = FALSE;
1186  identical = FALSE;
1187 
1188  if( !identblocksforblock[b2].empty() )
1189  continue;
1190 
1191  if( aggisnotactive )
1192  continue;
1193 
1194 
1195  SCIP_CALL_ABORT( SCIPhashmapCreate( &varmap2,
1196  SCIPblkmem(seeedpool->getScip()),
1197  5 * getNVarsForBlock(b1)+1) ); /* +1 to deal with empty subproblems */
1198 
1199  SCIPdebugMessage("Check identity for block %d and block %d!\n", b1, b2);
1200 
1201  checkIdenticalBlocksTrivial( b1, b2, &notidentical);
1202 
1203  if( !notidentical )
1204  {
1205  checkIdenticalBlocksBrute( b1, b2, varmap, varmap2, &identical);
1206 
1207 #ifdef WITH_BLISS
1208  if( !tooexpensive && !identical )
1209  checkIdenticalBlocksBliss(b1, b2, varmap, varmap2, &identical);
1210 #endif
1211  }
1212  else
1213  identical = FALSE;
1214 
1215  if( identical )
1216  {
1217  SCIPdebugMessage("Block %d is identical to block %d!\n", b1, b2);
1218  identblocksforblock[b1].push_back(b2);
1219  identblocksforblock[b2].push_back(b1);
1220  currrep.push_back(b2);
1222  currrepvarmapforthisrep.push_back(varmap);
1223 
1224  }
1225  else
1226  {
1227  SCIPdebugMessage("Block %d is not identical to block %d!\n", b1, b2);
1228  }
1229  SCIPhashmapFree(&varmap2);
1230  }
1231 
1232  reptoblocks.push_back( currrep );
1233  pidtopidvarmaptofirst.push_back(currrepvarmapforthisrep);
1234  for( size_t i = 0; i < currrep.size(); ++i )
1235  blockstorep[currrep[i]] = nreps-1;
1236  ++nreps;
1237 
1238  }
1239  nrepblocks = nreps-1;
1240 
1241  agginfocalculated = TRUE;
1242 
1243  return;
1244  }
1245 
1246 
1247 
1250 {
1251  std::vector<std::pair<int, int>> blockorder = std::vector < std::pair<int, int> > ( 0 );
1252  long hashval = 0;
1253  long borderval = 0;
1254 
1256  for( int i = 0; i < this->nBlocks; ++ i )
1257  {
1258  if( this->conssForBlocks[i].size() > 0 )
1259  blockorder.push_back( std::pair<int, int>( i, this->conssForBlocks[i][0] ) );
1260  else
1261  {
1262  assert( this->varsForBlocks[i].size() > 0 );
1263  blockorder.push_back( std::pair<int, int>( i, this->getNConss() + this->varsForBlocks[i][0] ) );
1264  }
1265  }
1266 
1267  std::sort( blockorder.begin(), blockorder.end(), compare_blocks );
1268 
1269  for( int i = 0; i < nBlocks; ++ i )
1270  {
1271  long blockval = 0;
1272  int blockid = blockorder[i].first;
1273 
1274  for( size_t tau = 0; tau < conssForBlocks[blockid].size(); ++ tau )
1275  {
1276  blockval += ( 2 * conssForBlocks[blockid][tau] + 1 ) * pow( 2, tau % 16 );
1277  }
1278 
1279  hashval += primes[i % ( nPrimes - 1 )] * blockval;
1280  }
1281 
1282  for( size_t tau = 0; tau < masterConss.size(); ++ tau )
1283  {
1284  borderval += ( 2 * masterConss[tau] + 1 ) * pow( 2, tau % 16 );
1285  }
1286 
1287  hashval += primes[nBlocks % nPrimes] * borderval;
1288 
1289  hashval += primes[( nBlocks + 1 ) % nPrimes] * openVars.size();
1290 
1291  this->hashvalue = hashval;
1292 }
1293 
1295 SCIP_RETCODE Seeed::calcNCoeffsForBlocks(
1296 ){
1297 
1298  if( calculatedncoeffsforblock )
1299  return SCIP_OKAY;
1300 
1301  ncoeffsforblock = std::vector<int>(getNBlocks(), 0);
1302  int counter;
1303 
1304 
1305 
1306  for( int b = 0; b < getNBlocks(); ++b )
1307  {
1308  counter = 0;
1309  for( int blco = 0; blco < getNConssForBlock(b); ++blco )
1310  {
1311  int consid = getConssForBlock(b)[blco];
1312 
1313  for( int cva = 0; cva < seeedpool->getNVarsForCons(consid) ;++cva )
1314  if( isVarBlockvarOfBlock(seeedpool->getVarsForCons(consid)[cva], b ) )
1315  ++counter;
1316  }
1317  ncoeffsforblock[b] = counter;
1318  }
1319 
1320  counter = 0;
1321 
1322  for( int mco = 0; mco < getNMasterconss(); ++mco )
1323  {
1324  int consid = getMasterconss()[mco];
1325 
1326  counter += seeedpool->getNVarsForCons(consid);
1327  }
1328  ncoeffsformaster = counter;
1329 
1330  calculatedncoeffsforblock = TRUE;
1331 
1332  return SCIP_OKAY;
1333 }
1334 
1335 
1336 
1343  )
1344 {
1345  assert( getNTotalStairlinkingvars() == 0 );
1346 
1347  /* data structure containing pairs of varindices and blocknumbers */
1348  std::vector< std::pair< int, std::vector< int > > > blocksOfVars = findLinkingVarsPotentiallyStairlinking( );
1349 
1350  /* if there are no vars that are potentially stairlinking, return without further calculations */
1351  if( blocksOfVars.size() == 0 )
1352  return;
1353 
1354  GraphGCG* g = new GraphGCG( getNBlocks(), true );
1355 
1356  /* create block graph: every block is represented by a node and two nodes are adjacent if there exists a
1357  * var that potentially links these blocks, the edge weight is the number of such variables */
1358  for( int i = 0; i < (int) blocksOfVars.size(); ++i )
1359  {
1360  assert( blocksOfVars[i].second.size() == 2 );
1361  int v = blocksOfVars[i].second[0];
1362  int w = blocksOfVars[i].second[1];
1363 
1364  if ( g->isEdge( v, w ) )
1365  {
1366  g->setEdge( v, w, g->getEdgeWeight( v, w ) + 1 );
1367  }
1368  else
1369  {
1370  g->setEdge( v, w, 1 );
1371  }
1372  }
1373 
1374 
1375  bool isstaircase = true; /* maintains information whether staircase structure is still possible */
1376  std::vector< int > sources( 0 ); /* all nodes with degree one */
1377  std::vector< bool > marks( getNBlocks() ); /* a node is marked if its degree is zero or it is reachable from a source */
1378 
1379  /* firstly, check whether every node has an degree of at most 2 */
1380  for( int b = 0; b < getNBlocks(); ++b )
1381  {
1382  if( g->getNNeighbors( b ) > 2 )
1383  {
1384  isstaircase = false;
1385  break;
1386  }
1387  else if( g->getNNeighbors( b ) == 1 )
1388  {
1389  sources.push_back( b );
1390  }
1391  else if ( g->getNNeighbors( b ) == 0 )
1392  {
1393  marks[b] = true;
1394  }
1395  }
1396 
1397  /* secondly, check whether there exists a circle in the graph by moving along all paths starting from a source */
1398  for( int s = 0; s < (int) sources.size() && isstaircase; ++s )
1399  {
1400  int curBlock = sources[s];
1401  if( marks[curBlock] )
1402  continue;
1403 
1404  marks[curBlock] = true;
1405 
1406  /* check whether there is an unmarked neighbor
1407  * if there is none, a circle is detected */
1408  do
1409  {
1410  std::vector< int > neighbors = g->getNeighbors( curBlock );
1411  if( !marks[neighbors[0]] )
1412  {
1413  marks[neighbors[0]] = true;
1414  curBlock = neighbors[0];
1415  }
1416  else if ( !marks[neighbors[1]] )
1417  {
1418  marks[neighbors[1]] = true;
1419  curBlock = neighbors[1];
1420  }
1421  else
1422  {
1423  isstaircase = false;
1424  break;
1425  }
1426  }
1427  while( g->getNNeighbors( curBlock ) != 1 );
1428  }
1429 
1430  /* thirdly, check whether all nodes with neighbors are reachable from a source,
1431  * since there is a circle if this is not the case */
1432  for( int b = 0; b < getNBlocks() && isstaircase; ++b )
1433  {
1434  if( !marks[b] )
1435  {
1436  isstaircase = false;
1437  break;
1438  }
1439  }
1440 
1441  if( isstaircase )
1442  {
1444  }
1445  else
1446  {
1447  /* check if stairlinkingheuristic is activated */
1448  SCIP_Bool stairlinkingheur;
1449  SCIPgetBoolParam(scip, "detection/legacymode/stairlinkingheur", &stairlinkingheur);
1450  if( !stairlinkingheur )
1451  return;
1452 
1454  }
1455 
1457 
1458  assert( checkConsistency( ) );
1459 }
1460 
1465  GraphGCG* g
1466  )
1467 {
1468  int blockcounter = 0; /* counts current new block to assign an old one to */
1469  std::vector< int > blockmapping( getNBlocks() ); /* stores new block order */
1470  for( int b = 0; b < getNBlocks(); ++b )
1471  blockmapping[b] = -1;
1472 
1473  for( int b = 0; b < getNBlocks(); ++b )
1474  {
1475  if( g->getNNeighbors( b ) == 0 )
1476  {
1477  /* if block does not have a neighbor, just assign it to current blockindex */
1478  assert( blockmapping[b] == -1 );
1479  blockmapping[b] = blockcounter;
1480  ++blockcounter;
1481  }
1482  else if( blockmapping[b] == -1 && g->getNNeighbors( b ) == 1 )
1483  {
1484  /* if the block is the source of an yet unconsidered path, assign whole path to ascending new block ids */
1485  int curBlock = b;
1486  blockmapping[b] = blockcounter;
1487  ++blockcounter;
1488 
1489  do
1490  {
1491  std::vector< int > neighbors = g->getNeighbors( curBlock );
1492 
1493  if( blockmapping[neighbors[0]] == -1 )
1494  {
1495  blockmapping[neighbors[0]] = blockcounter;
1496  curBlock = neighbors[0];
1497  }
1498  else if ( blockmapping[neighbors[1]] == -1 )
1499  {
1500  blockmapping[neighbors[1]] = blockcounter;
1501  curBlock = neighbors[1];
1502  }
1503  else
1504  {
1505  assert( false );
1506  }
1507  ++blockcounter;
1508  }
1509  while( g->getNNeighbors( curBlock ) != 1 );
1510  }
1511  }
1512 
1513  changeBlockOrder( blockmapping );
1514 }
1515 
1519  GraphGCG* g
1520  )
1521 {
1522  int blockcounter = 0; /* counts current new block to assign an old one to */
1523  std::vector< int > blockmapping( getNBlocks() ); /* stores new block order */
1524  for( int b = 0; b < getNBlocks(); ++b )
1525  blockmapping[b] = -1;
1526 
1527  for( int b = 0; b < getNBlocks(); ++b )
1528  {
1529  if( g->getNNeighbors( b ) == 0 )
1530  {
1531  /* if block does not have a neighbor, just assign it to current blockindex */
1532  assert( blockmapping[b] == -1 );
1533  blockmapping[b] = blockcounter;
1534  ++blockcounter;
1535  }
1536  else if( blockmapping[b] == -1 )
1537  {
1538  /* if the block is part of an yet unconsidered path, walk along this path greedily
1539  * and assign whole path to ascending new block ids */
1540  int curBlock = b;
1541  blockmapping[b] = blockcounter;
1542  int maxNeighbor;
1543  int maxNeighborVal;
1544 
1545  do
1546  {
1547  ++blockcounter;
1548  std::vector< int > neighbors = g->getNeighbors( curBlock );
1549 
1550  maxNeighbor = -1;
1551  maxNeighborVal = -1;
1552 
1553  /* find yet unassigned neighbor block with maximum number of stairlinking vars connecting it to current block */
1554  for( int i = 0; i < (int) neighbors.size(); ++i )
1555  {
1556  if( blockmapping[neighbors[i]] == -1 && g->getEdgeWeight( curBlock, neighbors[i] ) > maxNeighborVal )
1557  {
1558  maxNeighbor = neighbors[i];
1559  maxNeighborVal = g->getEdgeWeight( curBlock, neighbors[i] );
1560  }
1561  }
1562 
1563  if( maxNeighbor != -1 )
1564  {
1565  assert( blockmapping[maxNeighbor] == -1 );
1566  blockmapping[maxNeighbor] = blockcounter;
1567  curBlock = maxNeighbor;
1568  }
1569  }
1570  while( maxNeighbor != -1 );
1571  }
1572  }
1573 
1574  changeBlockOrder( blockmapping );
1575 }
1576 
1580  std::vector<int> oldToNewBlockIndex
1581  )
1582 {
1583  assert((int ) oldToNewBlockIndex.size() == getNBlocks() );
1584  assert( getNTotalStairlinkingvars() == 0 );
1585 
1586  std::vector< std::vector< int > > newconssforblocks( getNBlocks() );
1587  std::vector< std::vector< int > > newvarsforblocks( getNBlocks() );
1588 
1589  for( int b = 0; b < getNBlocks(); ++b )
1590  {
1591  assert( 0 <= oldToNewBlockIndex[b] && oldToNewBlockIndex[b] < getNBlocks() );
1592 
1593  newconssforblocks[oldToNewBlockIndex[b]] = conssForBlocks[b];
1594  newvarsforblocks[oldToNewBlockIndex[b]] = varsForBlocks[b];
1595  }
1596 
1597  conssForBlocks = newconssforblocks;
1598  varsForBlocks = newvarsforblocks;
1599 }
1600 
1603 {
1604  for( size_t i = 0; i < openConss.size(); ++ i )
1605  {
1606  bool consfound = false;
1607  for( size_t k = 0; k < masterConss.size(); ++ k )
1608  {
1609  if( openConss[i] == masterConss[k] )
1610  {
1611  consfound = true;
1612  break;
1613  }
1614  }
1615  for( int b = 0; b < nBlocks && ! consfound; ++ b )
1616  {
1617  for( size_t k = 0; k < conssForBlocks[b].size(); ++ k )
1618  {
1619  if( openConss[i] == conssForBlocks[b][k] )
1620  {
1621  consfound = true;
1622  break;
1623  }
1624  }
1625  }
1626  if( ! consfound )
1627  {
1628  return false;
1629  }
1630  }
1631  openConss.clear();
1632  isconsopen = std::vector<bool>(nConss, false);
1633  return true;
1634 }
1635 
1636 
1637 
1638 
1641  )
1642 {
1643  std::vector<bool> openVarsBool( nVars, true );
1644  std::vector<int> stairlinkingvarsvec( 0 );
1645  std::vector<int>::const_iterator varIter = linkingVars.begin();
1646  std::vector<int>::const_iterator varIterEnd = linkingVars.end();
1647 
1648  int value;
1649 
1651  if( nBlocks != (int) conssForBlocks.size() )
1652  {
1653  SCIPwarningMessage(scip, "In (seeed %d) nBlocks %d and size of conssForBlocks %d are not identical! \n" , id, nBlocks, conssForBlocks.size() );
1654  assert( false );
1655  return false;
1656  }
1657 
1658  if( nBlocks != (int) varsForBlocks.size() )
1659  {
1660  SCIPwarningMessage(scip, "In (seeed %d) nBlocks %d and size of varsForBlocks %d are not identical! \n" , id, nBlocks, varsForBlocks.size() );
1661  assert( false );
1662  return false;
1663  }
1664 
1667  for( int b = 0; b < nBlocks; ++ b )
1668  {
1669  if( conssForBlocks[b].size() == 0 && varsForBlocks[b].size() == 0 )
1670  {
1671  SCIPwarningMessage(scip, "In (seeed %d) block %d is empty! \n" , id, b );
1672  this->displaySeeed();
1673  assert( false );
1674  return false;
1675  }
1676  }
1677 
1679  for( ; varIter != varIterEnd; ++ varIter )
1680  {
1681  if( ! openVarsBool[ * varIter] )
1682  {
1683  SCIPwarningMessage(scip, "In (seeed %d) linking variable with index %d is already assigned! \n" , id, * varIter );
1684 
1685  assert( false );
1686  return false;
1687  }
1688  openVarsBool[ * varIter] = false;
1689  }
1690 
1691  for( int b = 0; b < nBlocks; ++ b )
1692  {
1693  varIterEnd = varsForBlocks[b].end();
1694  for( varIter = varsForBlocks[b].begin(); varIter != varIterEnd; ++ varIter )
1695  {
1696  if( ! openVarsBool[ * varIter] )
1697  {
1698  SCIPwarningMessage(scip, "In (seeed %d) variable with index %d is already assigned but also assigned to block %d! \n" , id, * varIter, b );
1699  assert( false );
1700  return false;
1701  }
1702  openVarsBool[ * varIter] = false;
1703  }
1704  }
1705 
1706  varIterEnd = masterVars.end();
1707  for( varIter = masterVars.begin(); varIter != varIterEnd; ++ varIter )
1708  {
1709  if( ! openVarsBool[ * varIter] )
1710  {
1711  SCIPwarningMessage(scip, "In (seeed %d) variable with index %d is already assigned but also assigned to master! \n" , id, * varIter);
1712  assert( false );
1713  return false;
1714  }
1715  openVarsBool[ * varIter] = false;
1716  }
1717 
1718  for( int b = 0; b < nBlocks; ++ b )
1719  {
1720  varIter = stairlinkingVars[b].begin();
1721  varIterEnd = stairlinkingVars[b].end();
1722  for( ; varIter != varIterEnd; ++ varIter )
1723  {
1724  if( ! openVarsBool[ * varIter] )
1725  {
1726  SCIPwarningMessage(scip, "In (seeed %d) variable with index %d is already assigned but also assigned to stairlinking block %d! \n" , id, * varIter, b );
1727  assert( false );
1728  return false;
1729  }
1730  openVarsBool[ * varIter] = false;
1731  }
1732  if( ( b == nBlocks - 1 ) && ( (int) stairlinkingVars[b].size() != 0 ) )
1733  {
1734  SCIPwarningMessage(scip, "In (seeed %d) variable with index %d is is as assigned as stairlinking var of last block! \n" , id, * varIter );
1735  assert( false );
1736  return false;
1737  }
1738  }
1739 
1741  for( int v = 0; v < nVars; ++ v )
1742  {
1743  if( openVarsBool[v] == true && isVarOpenvar( v ) == false )
1744  {
1745  SCIPwarningMessage(scip, "In (seeed %d) variable with index %d is not assigned and not an open var! \n" , id, v );
1746  assert( false );
1747  return false;
1748  }
1749  }
1750 
1752  for( size_t i = 0; i < openVars.size(); ++ i )
1753  {
1754  if( openVarsBool[openVars[i]] == false )
1755  {
1756  SCIPwarningMessage(scip, "In (seeed %d) variable with index %d is an open var but assigned! \n" , id, openVars[i] );
1757  assert( false );
1758  return false;
1759  }
1760  }
1761 
1762  for( size_t i = 0; i < openVarsBool.size(); ++ i )
1763  {
1764  if( openVarsBool[i] != isvaropen[i] )
1765  {
1766  SCIPwarningMessage(scip, "In (seeed %d) variable with index %d is causes asynchronity with isvaropen array ! \n" , id, openVars[i] );
1767  assert( false );
1768  return false;
1769 
1770  }
1771  }
1772 
1774  std::vector<bool> openConssBool( nConss, true );
1775  std::vector<int> openConssVec( 0 );
1776  std::vector<int>::const_iterator consIter = masterConss.begin();
1777  std::vector<int>::const_iterator consIterEnd = masterConss.end();
1778 
1779  for( ; consIter != consIterEnd; ++ consIter )
1780  {
1781  if( ! openConssBool[ * consIter] )
1782  {
1783  SCIPwarningMessage(scip, "In (seeed %d) constraint with index %d is at least two times assigned as a master constraint! \n" , id, * consIter );
1784  assert( false );
1785  return false;
1786  }
1787  openConssBool[ * consIter] = false;
1788  }
1789 
1790  for( int b = 0; b < nBlocks; ++ b )
1791  {
1792  consIterEnd = conssForBlocks[b].end();
1793  for( consIter = conssForBlocks[b].begin(); consIter != consIterEnd; ++ consIter )
1794  {
1795  if( ! openConssBool[ * consIter] )
1796  {
1797  SCIPwarningMessage(scip, "In (seeed %d) constraint with index %d is already assigned but also assigned to block %d! \n" , id, * consIter, b );
1798  assert( false );
1799  return false;
1800  }
1801  openConssBool[ * consIter] = false;
1802  }
1803  }
1804 
1806  for( int v = 0; v < nConss; ++ v )
1807  {
1808  if( openConssBool[v] == true && isConsOpencons( v ) == false )
1809  {
1810  SCIPwarningMessage(scip, "In (seeed %d) constraint with index %d is not assigned and not an open cons! \n" , id, v );
1811  assert( false );
1812  return false;
1813  }
1814  }
1815 
1817  for( size_t i = 0; i < openConss.size(); ++ i )
1818  {
1819  if( openConssBool[openConss[i]] == false )
1820  {
1821  SCIPwarningMessage(scip, "In (seeed %d) constraint with index %d is an open cons but assigned! \n" , id, openConss[i] );
1822  assert( false );
1823  return false;
1824  }
1825  }
1826 
1828  for( int b = 0; b < nBlocks; ++ b )
1829  {
1830  value = - 1;
1831  for( int v = 0; v < getNVarsForBlock( b ); ++ v )
1832  {
1833  if( ! ( value < getVarsForBlock( b )[v] ) )
1834  {
1835  SCIPwarningMessage(scip, "In (seeed %d) variables of block %d are not sorted! \n" , id, b );
1836  assert( false );
1837  return false;
1838  }
1839  value = getVarsForBlock( b )[v];
1840  }
1841  }
1842  for( int b = 0; b < nBlocks; ++ b )
1843  {
1844  value = - 1;
1845  for( int v = 0; v < getNStairlinkingvars( b ); ++ v )
1846  {
1847  if( ! ( value < getStairlinkingvars( b )[v] ) )
1848  {
1849  SCIPwarningMessage(scip, "In (seeed %d) stairlinking variables of block %d are not sorted! \n" , id, b );
1850  assert( false );
1851  return false;
1852  }
1853  value = getStairlinkingvars( b )[v];
1854  }
1855  }
1856  value = - 1;
1857  for( int v = 0; v < getNLinkingvars(); ++ v )
1858  {
1859  if( ! ( value < getLinkingvars()[v] ) )
1860  {
1861  SCIPwarningMessage(scip, "In (seeed %d) linking variables are not sorted! \n" , id );
1862  assert( false );
1863  return false;
1864  }
1865  value = getLinkingvars()[v];
1866  }
1867  value = - 1;
1868  for( int v = 0; v < getNMastervars(); ++ v )
1869  {
1870  if( ! ( value < getMastervars()[v] ) )
1871  {
1872  SCIPwarningMessage(scip, "In (seeed %d) master variables are not sorted! \n" , id );
1873  assert( false );
1874  return false;
1875  }
1876  value = getMastervars()[v];
1877  }
1878  for( int b = 0; b < nBlocks; ++ b )
1879  {
1880  value = - 1;
1881  for( int v = 0; v < getNConssForBlock( b ); ++ v )
1882  {
1883  if( ! ( value < getConssForBlock( b )[v] ) )
1884  {
1885  SCIPwarningMessage(scip, "In (seeed %d) constraints of block %d are not sorted! \n" , id, b );
1886  assert( false );
1887  return false;
1888  }
1889  value = getConssForBlock( b )[v];
1890  }
1891  }
1892  value = - 1;
1893  for( int v = 0; v < getNMasterconss(); ++ v )
1894  {
1895  if( ! ( value < getMasterconss()[v] ) )
1896  {
1897  SCIPwarningMessage(scip, "In (seeed %d) master constraints are not sorted! \n" , id);
1898  assert( false );
1899  return false;
1900  }
1901  value = getMasterconss()[v];
1902  }
1903 
1905  for( int b = 0; b < nBlocks; ++ b )
1906  {
1907  for( int c = 0; c < getNConssForBlock( b ); ++ c )
1908  {
1909  for( int v = 0; v < seeedpool->getNVarsForCons( getConssForBlock( b )[c] ); ++ v )
1910  {
1911  int varid = seeedpool->getVarsForCons( getConssForBlock( b )[c] )[v];
1912 
1913  if( ! ( isVarBlockvarOfBlock( varid, b ) || isVarLinkingvar( varid ) || isVarStairlinkingvarOfBlock( varid, b )
1914  || isVarOpenvar( varid ) ) )
1915  {
1916  SCIP_Bool partofblock;
1917 
1918  partofblock = FALSE;
1919 
1920  SCIPwarningMessage( scip,
1921  "This should only happen during translation of (partial) decompositions from orginal to transformed problem, and means that translation has failed for this particaluar partial decomposition. Variable %d is not part of block %d or linking or open as constraint %d suggests! \n ", varid, b,
1922  getConssForBlock( b )[c] );
1923 
1924  for( int b2 = 0; b2 < getNBlocks(); ++b2 )
1925  {
1926  if ( isVarBlockvarOfBlock(varid, b2 ) )
1927  {
1928  partofblock = TRUE;
1929  SCIPwarningMessage( scip,
1930  "instead Variable %d is part of block %d \n ", varid, b2 );
1931  break;
1932  }
1933  }
1934 
1935  if( !partofblock )
1936  {
1937  if( isvarmaster[varid] )
1938  SCIPwarningMessage( scip,
1939  "instead Variable %d is part of master \n ", varid );
1940  else
1941  SCIPwarningMessage( scip,
1942  "in fact Variable %d is completely unassigned \n ", varid );
1943  }
1944  return false;
1945  }
1946  }
1947  }
1948  }
1949 
1950  return true;
1951 }
1952 
1953 
1954 #ifdef WITH_BLISS
1955 
1956 void Seeed::checkIdenticalBlocksBliss(
1957  int b1,
1958  int b2,
1959  std::vector<int>& varmap,
1960  SCIP_HASHMAP* varmap2,
1961  SCIP_Bool* identical
1962  )
1963 {
1964  *identical = FALSE;
1965  SCIP_HASHMAP* consmap;
1966  SCIP_Result result;
1967 
1968  varmap = std::vector<int>(getNVarsForBlock(b1), -1);
1969 
1970  SCIP_CALL_ABORT( SCIPhashmapCreate(&consmap,
1971  SCIPblkmem(seeedpool->getScip() ),
1972  getNConssForBlock(b1)+1) ); /* +1 to deal with empty subproblems */
1973 
1974 
1975  SCIPdebugMessage("obvious test fails, start building graph \n");
1976 
1977  cmpGraphPairNewdetection(seeedpool->getScip(), (SEEED_WRAPPER*) this, b1, b2, &result, varmap2, consmap );
1978  if ( result == SCIP_SUCCESS )
1979  {
1980  *identical = TRUE;
1982  for( int var2idinblock = 0; var2idinblock < getNVarsForBlock(b2) ; ++var2idinblock )
1983  {
1984  SCIP_VAR* var2;
1985  SCIP_VAR* var1;
1986  int var1idinblock;
1987  int var1id;
1988 
1989  var2 = seeedpool->getVarForIndex(getVarsForBlock(b2)[var2idinblock]);
1990  var1 = (SCIP_VAR*) SCIPhashmapGetImage(varmap2, (void*) var2);
1991  var1id = seeedpool->getIndexForVar(var1);
1992  var1idinblock = getVarProbindexForBlock(var1id, b1);
1993  varmap[var2idinblock] = var1idinblock;
1994  }
1995 
1996  }
1997  else
1998  *identical = FALSE;
1999 
2000  SCIPhashmapFree(&consmap);
2001 
2002  return;
2003 
2004 }
2005 #endif
2006 
2007 
2009 void Seeed::checkIdenticalBlocksBrute(
2010  int b1,
2011  int b2,
2012  std::vector<int>& varmap,
2013  SCIP_HASHMAP* varmap2,
2014  SCIP_Bool* identical
2015  )
2016 {
2017 
2018 
2019  *identical = FALSE;
2020  SCIPdebugMessage("check block %d and block %d for identity...\n", b1, b2);
2021  varmap = std::vector<int>(getNVars(), -1);
2022 
2023 
2025  for( int i = 0; i < getNVarsForBlock(b1); ++i )
2026  {
2027  SCIP_VAR* var1;
2028  SCIP_VAR* var2;
2029 
2030  var1 = seeedpool->getVarForIndex( getVarsForBlock(b1)[i] );
2031  var2 = seeedpool->getVarForIndex( getVarsForBlock(b2)[i] );
2032 
2033 
2034  if( !SCIPisEQ(scip, SCIPvarGetObj(var1), SCIPvarGetObj(var2) ) )
2035  {
2036  SCIPdebugMessage("--> obj differs for var %s and var %s!\n", SCIPvarGetName(var1), SCIPvarGetName(var2));
2037  return;
2038  }
2039  if( !SCIPisEQ(scip, SCIPvarGetLbGlobal(var1), SCIPvarGetLbGlobal(var2) ) )
2040  {
2041  SCIPdebugMessage("--> lb differs for var %s and var %s!\n", SCIPvarGetName(var1), SCIPvarGetName(var2));
2042  return;
2043  }
2044  if( !SCIPisEQ(scip, SCIPvarGetUbGlobal(var1), SCIPvarGetUbGlobal(var2) ) )
2045  {
2046  SCIPdebugMessage("--> ub differs for var %s and var %s!\n", SCIPvarGetName(var1), SCIPvarGetName(var2));
2047  return;
2048  }
2049  if( SCIPvarGetType(var1) != SCIPvarGetType(var2) )
2050  {
2051  SCIPdebugMessage("--> type differs for var %s and var %s!\n", SCIPvarGetName(var1), SCIPvarGetName(var2));
2052  return;
2053  }
2054 
2055  for( int mc = 0; mc < getNMasterconss(); ++mc )
2056  {
2057 
2058  if( !SCIPisEQ(scip, seeedpool->getVal(getMasterconss()[mc], getVarsForBlock(b1)[i]), seeedpool->getVal(getMasterconss()[mc], getVarsForBlock(b2)[i]) ))
2059  {
2060  SCIPdebugMessage("--> master coefficients differ for var %s (%f) and var %s (%f) !\n", SCIPvarGetName( seeedpool->getVarForIndex(getVarsForBlock(b1)[i]) ), seeedpool->getVal(getMasterconss()[mc], getVarsForBlock(b1)[i]), SCIPvarGetName( seeedpool->getVarForIndex(getVarsForBlock(b2)[i])), seeedpool->getVal(getMasterconss()[mc], getVarsForBlock(b2)[i]) );
2061  return;
2062  }
2063  }
2064 
2066  varmap[getVarsForBlock(b2)[i]] = getVarsForBlock(b1)[i];
2067  }
2068 
2069  for( int i = 0; i < getNConssForBlock(b1); ++i )
2070  {
2071  int cons1id;
2072  int cons2id;
2073  SCIP_CONS* cons1;
2074  SCIP_CONS* cons2;
2075  SCIP_Real* vals1;
2076  SCIP_Real* vals2;
2077  int nvals1;
2078  int nvals2;
2079 
2080  cons1id = getConssForBlock(b1)[i];
2081  cons2id = getConssForBlock(b2)[i];
2082 
2083  cons1 = seeedpool->getConsForIndex(cons1id);
2084  cons2 = seeedpool->getConsForIndex(cons2id);
2085 
2086  if( seeedpool->getNVarsForCons(cons1id) != seeedpool->getNVarsForCons(cons2id) )
2087  {
2088  SCIPdebugMessage("--> nvars differs for cons %s and cons %s!\n", SCIPconsGetName(cons1), SCIPconsGetName(cons2));
2089  return;
2090  }
2091 
2092  if( !SCIPisEQ(scip, GCGconsGetLhs(scip, cons1), GCGconsGetLhs(scip, cons2) ) )
2093  {
2094  SCIPdebugMessage("--> lhs differs for cons %s and cons %s!\n", SCIPconsGetName(cons1), SCIPconsGetName(cons2));
2095  return;
2096  }
2097 
2098  if( !SCIPisEQ(scip, GCGconsGetRhs(scip, cons1), GCGconsGetRhs(scip, cons2) ) )
2099  {
2100  SCIPdebugMessage("--> rhs differs for cons %s and cons %s!\n", SCIPconsGetName(cons1), SCIPconsGetName(cons2));
2101  return;
2102  }
2103 
2104  nvals1 = GCGconsGetNVars(scip, cons1);
2105  nvals2 = GCGconsGetNVars(scip, cons2);
2106  SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vals1, nvals1) );
2107  SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vals2, nvals2) );
2108  GCGconsGetVals(scip, cons1, vals1, nvals1);
2109  GCGconsGetVals(scip, cons2, vals2, nvals2);
2110 
2111 
2112  if( !realArraysAreEqual(scip, vals1, nvals1, vals2, nvals2) )
2113  {
2114  SCIPdebugMessage("--> coefs differ for cons %s and cons %s!\n", SCIPconsGetName(cons1), SCIPconsGetName(cons2));
2115  SCIPfreeBufferArray(scip, &vals1);
2116  SCIPfreeBufferArray(scip, &vals2);
2117  return;
2118  }
2119 
2120  for( int v = 0; v < seeedpool->getNVarsForCons(cons1id) ; ++v )
2121  {
2122  if( varmap[seeedpool->getVarsForCons(cons2id)[v]] != seeedpool->getVarsForCons(cons1id)[v])
2123  {
2124  SCIPfreeBufferArray(scip, &vals1);
2125  SCIPfreeBufferArray(scip, &vals2);
2126  SCIPdebugMessage("--> vars differ for cons %s and cons %s!\n", SCIPconsGetName(cons1), SCIPconsGetName(cons2));
2127  return;
2128  }
2129  }
2130 
2131 
2132 
2133  SCIPfreeBufferArray(scip, &vals1);
2134  SCIPfreeBufferArray(scip, &vals2);
2135 
2136  }
2137 
2138 
2139  varmap = std::vector<int>(getNVarsForBlock(b1), -1);
2140  for( int i = 0; i < getNVarsForBlock(b1); ++i )
2141  varmap[i] = i;
2142 
2143  *identical = TRUE;
2144  return;
2145 }
2146 
2148  )
2149 {
2150  ncoeffsforblockformastercons = std::vector<std::vector<int>>(getNBlocks());
2151 
2152  for( int b = 0; b < getNBlocks(); ++b )
2153  ncoeffsforblockformastercons[b] = std::vector<int>(getNMasterconss(), 0);
2154 
2155  for( int mc = 0; mc < getNMasterconss(); ++mc )
2156  {
2157  int cons = getMasterconss()[mc];
2158  for ( int vmc = 0; vmc < seeedpool->getNVarsForCons(cons); ++vmc )
2159  {
2160  int var = seeedpool->getVarsForCons(cons)[vmc];
2161  for( int b = 0; b < getNBlocks(); ++b )
2162  {
2163  if( isVarBlockvarOfBlock(var, b) )
2164  ++ncoeffsforblockformastercons[b][mc];
2165  }
2166  }
2167  }
2168  return;
2169 }
2170 
2171 
2172 SCIP_RETCODE Seeed::checkIdenticalBlocksTrivial(
2173  int b1,
2174  int b2,
2175  SCIP_Bool* notidentical)
2176 {
2177 
2178  if( getNConssForBlock(b1) != getNConssForBlock(b2) )
2179  {
2180  SCIPdebugMessage("--> number of constraints differs!\n");
2181  *notidentical = TRUE;
2182  return SCIP_OKAY;
2183  }
2184 
2185 
2186  if( getNVarsForBlock(b1) != getNVarsForBlock(b2) )
2187  {
2188  SCIPdebugMessage("--> number of variables differs!\n");
2189  *notidentical = TRUE;
2190  return SCIP_OKAY;
2191  }
2192 
2193  if( getNCoeffsForBlock(b1) != getNCoeffsForBlock( b2) )
2194  {
2195  SCIPdebugMessage("--> number of nonzero coeffs differs!\n");
2196  *notidentical = TRUE;
2197  return SCIP_OKAY;
2198  }
2199 
2200  if( ncoeffsforblockformastercons.size() == 0 )
2202 
2203  for( int mc = 0; mc < getNMasterconss(); ++mc )
2204  {
2205  if ( ncoeffsforblockformastercons[b1][mc] != ncoeffsforblockformastercons[b2][mc] )
2206  {
2207  SCIPdebugMessage("--> number of nonzero coeffs in %d-th master cons differs!\n", mc);
2208  *notidentical = TRUE;
2209  return SCIP_OKAY;
2210  }
2211  }
2212 
2213 
2214  return SCIP_OKAY;
2215 }
2216 
2217 
2218 
2223  )
2224 {
2225 
2226  int cons;
2227  int var;
2228 
2229  changedHashvalue = true;
2230 
2232  std::vector<int> varInBlocks;
2235  std::vector<int> openvarsToDelete( 0 );
2236  std::vector<int> oldOpenconss;
2237 
2238  std::vector<bool> isConsOpen( nConss, false );
2239  std::vector<bool> isConsVisited( nConss, false );
2240 
2241  std::vector<bool> isVarOpen( nVars, false );
2242  std::vector<bool> isVarVisited( nVars, false );
2243 
2244  std::queue<int> helpqueue = std::queue<int>();
2245  std::vector<int> neighborConss( 0 );
2246  std::vector<int> neighborVars( 0 );
2247 
2248  assert( (int) conssForBlocks.size() == nBlocks );
2249  assert( (int) varsForBlocks.size() == nBlocks );
2250  assert( (int) stairlinkingVars.size() == nBlocks );
2251 
2252  SCIP_CALL( refineToMaster( ) );
2253 
2254 
2255  if( nBlocks < 0 )
2256  nBlocks = 0;
2257 
2259  for( size_t c = 0; c < openConss.size(); ++ c )
2260  {
2261  cons = openConss[c];
2262  isConsOpen[cons] = true;
2263  }
2264 
2265  for( size_t v = 0; v < openVars.size(); ++ v )
2266  {
2267  var = openVars[v];
2268  isVarOpen[var] = true;
2269  }
2270 
2272  while( ! openConss.empty() )
2273  {
2274  int newBlockNr;
2275 
2276  assert( helpqueue.empty() );
2277  helpqueue.push( openConss[0] );
2278  neighborConss.clear();
2279  neighborConss.push_back( openConss[0] );
2280  isConsVisited[openConss[0]] = true;
2281  neighborVars.clear();
2282 
2283  while( ! helpqueue.empty() )
2284  {
2285  int nodeCons = helpqueue.front();
2286  assert( isConsOpencons( nodeCons ) );
2287  helpqueue.pop();
2288  for( int v = 0; v < seeedpool->getNVarsForCons( nodeCons ); ++ v )
2289  {
2290  var = seeedpool->getVarsForCons( nodeCons )[v];
2291  assert( isVarOpenvar( var ) || isVarLinkingvar( var ) );
2292 
2293  if( isVarVisited[var] || isVarLinkingvar( var ) )
2294  continue;
2295 
2296  for( int c = 0; c < seeedpool->getNConssForVar( var ); ++ c )
2297  {
2298  int otherNodeCons = seeedpool->getConssForVar( var )[c];
2299  if( ! isConsOpen[otherNodeCons] || isConsVisited[otherNodeCons] )
2300  {
2301  continue;
2302  }
2303  assert( isConsOpencons( otherNodeCons ) );
2304  isConsVisited[otherNodeCons] = true;
2305  neighborConss.push_back( otherNodeCons );
2306  helpqueue.push( otherNodeCons );
2307  }
2308  isVarVisited[var] = true;
2309  neighborVars.push_back( var );
2310  }
2311  }
2312 
2314  newBlockNr = getNBlocks() + 1;
2315  setNBlocks( newBlockNr );
2316  for( size_t i = 0; i < neighborConss.size(); ++ i )
2317  {
2318  cons = neighborConss[i];
2319 
2320  assert( isConsOpencons( cons ) );
2321  setConsToBlock( cons, newBlockNr - 1 );
2322 
2323  deleteOpencons( cons );
2324  }
2325  for( size_t i = 0; i < neighborVars.size(); ++ i )
2326  {
2327  var = neighborVars[i];
2328  setVarToBlock( var, newBlockNr - 1 );
2329  assert( isVarOpenvar( var ) );
2330  deleteOpenvar( var );
2331  }
2332  }
2333 
2335  for( size_t i = 0; i < openVars.size(); ++ i )
2336  {
2337  var = openVars[i];
2338  if( getNBlocks() != 0 )
2339  setVarToBlock( var, 0 );
2340  else
2341  setVarToMaster( var );
2342  openvarsToDelete.push_back( var );
2343  }
2344 
2345  for( size_t i = 0; i < openvarsToDelete.size(); ++ i )
2346  {
2347  var = openvarsToDelete[i];
2348  deleteOpenvar( var );
2349  }
2350 
2351  assert( openConss.empty() );
2352  assert( openVars.empty() );
2353 
2354  sort();
2355 
2356  assert( checkConsistency( ) );
2357 
2358  return SCIP_OKAY;
2359 }
2360 
2361 
2364  SCIP_Bool* success
2365  )
2366  {
2367  *success = FALSE;
2368  return SCIP_OKAY;
2369  }
2370 
2371 
2374  SCIP_Bool* success
2375  )
2376  {
2377  *success = FALSE;
2378  std::vector<int> constoreassign(0);
2379  std::vector<int> blockforconstoreassign(0);
2380 
2381  sort();
2382 
2383  std::vector<int> blockforvar(getNVars(), -1 );
2384 
2385 
2387  for( int b = 0; b < getNBlocks(); ++b )
2388  {
2389  for( size_t j = 0; j < (size_t) getNVarsForBlock(b); ++j )
2390  {
2391  blockforvar[getVarsForBlock(b)[j] ] = b;
2392  }
2393  }
2394 
2395 
2396  for( int mc = 0; mc < getNMasterconss(); ++mc )
2397  {
2398  int masterconsid = getMasterconss()[mc];
2399  int hittenblock = -1;
2400 
2401  SCIP_Bool hitsmastervar = FALSE;
2402  SCIP_Bool varhitsotherblock = FALSE;
2403 
2404  for( int var = 0; var < seeedpool->getNVarsForCons(masterconsid); ++var )
2405  {
2406  int varid = seeedpool->getVarsForCons(masterconsid)[var];
2407  if( isvarmaster[varid] )
2408  {
2409  hitsmastervar = TRUE;
2410  break;
2411  }
2412 
2413  if ( blockforvar[varid] != -1 )
2414  {
2415  if( hittenblock == -1 )
2416  hittenblock = blockforvar[varid];
2417  else if( hittenblock != blockforvar[varid] )
2418  {
2419  varhitsotherblock = TRUE;
2420  break;
2421  }
2422  }
2423  }
2424 
2425  if( hitsmastervar || varhitsotherblock )
2426  continue;
2427 
2428  if ( hittenblock != -1 )
2429  {
2430  constoreassign.push_back(masterconsid);
2431  blockforconstoreassign.push_back(hittenblock);
2432  }
2433  }
2434 
2435 
2436  for( size_t i = 0; i < constoreassign.size() ; ++i )
2437  {
2438  std::vector<int>::iterator todelete = lower_bound( masterConss.begin(), masterConss.end(), constoreassign[i] );
2439  masterConss.erase(todelete);
2440 
2441  conssForBlocks[blockforconstoreassign[i]].push_back( constoreassign[i] );
2442  conssforblocksorted = false;
2443 
2444  }
2445 
2446  if( constoreassign.size() > 0 )
2447  *success = SCIP_SUCCESS;
2448 
2449  sort();
2450 
2452  calcHashvalue();
2453 
2454  return SCIP_OKAY;
2455  }
2456 
2457 
2464  ){
2465 
2466  int cons;
2467  int var;
2468 
2469  changedHashvalue = true;
2470 
2471 
2473  std::vector<int> varInBlocks;
2476  std::vector<int> oldOpenconss;
2477  std::vector<int> openvarsToDelete;
2478 
2479  if( getNLinkingvars() != 0 )
2480  return completeByConnected();
2481 
2482  std::vector<bool> isConsOpen( nConss, false );
2483  std::vector<bool> isConsVisited( nConss, false );
2484 
2485  varInBlocks = std::vector<int>(nVars, -1);
2486 
2487  std::queue<int> helpqueue = std::queue<int>();
2488  std::vector<int> neighborConss( 0 );
2489 
2490  assert( (int) conssForBlocks.size() == nBlocks );
2491  assert( (int) varsForBlocks.size() == nBlocks );
2492  assert( (int) stairlinkingVars.size() == nBlocks );
2493 
2494  SCIP_CALL( refineToMaster( ) );
2495 
2496  assert(checkConsistency() );
2497 
2498  if( nBlocks < 0 )
2499  nBlocks = 0;
2500 
2502  for( size_t c = 0; c < openConss.size(); ++ c )
2503  {
2504  cons = openConss[c];
2505  isConsOpen[cons] = true;
2506  }
2507 
2509  while( ! openConss.empty() )
2510  {
2511  int newBlockNr;
2512 
2513  assert( helpqueue.empty() );
2514  helpqueue.push( openConss[0] );
2515  neighborConss.clear();
2516  neighborConss.push_back( openConss[0] );
2517  isConsVisited[openConss[0]] = true;
2518 
2519  while( ! helpqueue.empty() )
2520  {
2521  int nodeCons = helpqueue.front();
2522  assert( isConsOpencons( nodeCons ) );
2523  helpqueue.pop();
2524  for( int c = 0; c < seeedpool->getNConssForCons( nodeCons ); ++ c )
2525  {
2526  int othercons = seeedpool->getConssForCons( nodeCons )[c];
2527 
2528  if( isConsVisited[othercons] || isConsMastercons( othercons ) || ! isConsOpen[othercons] )
2529  continue;
2530 
2531  assert( isConsOpencons( othercons ) );
2532  isConsVisited[othercons] = true;
2533  neighborConss.push_back( othercons );
2534  helpqueue.push( othercons );
2535  }
2536  }
2537 
2539  newBlockNr = getNBlocks() + 1;
2540  setNBlocks( newBlockNr );
2541  for( size_t i = 0; i < neighborConss.size(); ++ i )
2542  {
2543  cons = neighborConss[i];
2544 
2545  assert( isConsOpencons( cons ) );
2546  setConsToBlock( cons, newBlockNr - 1 );
2547  deleteOpencons( cons );
2548 
2549  for( int j = 0; j < seeedpool->getNVarsForCons(cons); ++ j )
2550  {
2551  int newvar = seeedpool->getVarsForCons(cons)[j];
2552 
2553  if( isVarLinkingvar(newvar) || varInBlocks[newvar] != -1 )
2554  continue;
2555 
2556  assert(! isVarMastervar( newvar) );
2557  setVarToBlock( newvar, newBlockNr - 1 );
2558  varInBlocks[newvar] = newBlockNr - 1;
2559  if( isVarOpenvar(newvar) )
2560  deleteOpenvar( newvar );
2561  }
2562 
2563  }
2564 
2565  }
2566 
2568  for( size_t i = 0; i < openVars.size(); ++ i )
2569  {
2570  var = openVars[i];
2571  if( getNBlocks() != 0 )
2572  setVarToBlock( var, 0 );
2573  else
2574  setVarToMaster( var );
2575  openvarsToDelete.push_back( var );
2576  }
2577 
2578  for( size_t i = 0; i < openvarsToDelete.size(); ++ i )
2579  {
2580  var = openvarsToDelete[i];
2581  deleteOpenvar( var );
2582  }
2583 
2584  assert( openConss.empty() );
2585  assert( openVars.empty() );
2586 
2587  sort();
2588 
2589  assert( checkConsistency( ) );
2590 
2591  return SCIP_OKAY;
2592  }
2593 
2594 
2601  ){
2602 
2603  int cons;
2604  SCIP_Bool conssadjcalculated;
2605 
2606  changedHashvalue = true;
2607 
2608 
2610  std::vector<int> varInBlocks;
2613  std::vector<int> oldOpenconss;
2614  std::vector<int> openvarsToDelete;
2615 
2616  if( getNLinkingvars() != 0 )
2617  return completeByConnected();
2618 
2619  SCIPgetBoolParam(scip, "detection/conssadjcalculated", &conssadjcalculated);
2620 
2621  if( !conssadjcalculated )
2622  {
2623  seeedpool->createConssAdjacency();
2624  SCIPsetBoolParam(scip, "detection/conssadjcalculated", TRUE);
2625  }
2626 
2627  std::vector<bool> isConsOpen( nConss, false );
2628  std::vector<bool> isConsVisited( nConss, false );
2629 
2630  std::vector<std::vector<int>> conssfornewblocks(0);
2631  std::vector<std::vector<int>> varsfornewblocks(0);
2632 
2633  std::vector<int> constoconsider;
2634  int nnewblocks;
2635  int largestcomponent;
2636  int sizelargestcomponent;
2637 
2638  constoconsider = openConss;
2639 
2640  varInBlocks = std::vector<int>(nVars, -1);
2641  nnewblocks = 0;
2642  largestcomponent = -1;
2643  sizelargestcomponent = 0;
2644 
2645  std::queue<int> helpqueue = std::queue<int>();
2646  std::vector<int> neighborConss( 0 );
2647 
2648  assert( (int) conssForBlocks.size() == nBlocks );
2649  assert( (int) varsForBlocks.size() == nBlocks );
2650  assert( (int) stairlinkingVars.size() == nBlocks );
2651 
2652  assert(checkConsistency() );
2653 
2654  if( nBlocks < 0 )
2655  nBlocks = 0;
2656 
2658  for( size_t c = 0; c < openConss.size(); ++ c )
2659  {
2660  cons = openConss[c];
2661  isConsOpen[cons] = true;
2662  }
2663 
2665  while( ! constoconsider.empty() )
2666  {
2667  std::vector<int> newconss(0);
2668  std::vector<int> newvars(0);
2669 
2670  assert( helpqueue.empty() );
2671  helpqueue.push( constoconsider[0] );
2672  neighborConss.clear();
2673  neighborConss.push_back( constoconsider[0] );
2674  isConsVisited[constoconsider[0]] = true;
2675 
2676  while( ! helpqueue.empty() )
2677  {
2678  int nodeCons = helpqueue.front();
2679  assert( isConsOpencons( nodeCons ) );
2680  helpqueue.pop();
2681  for( int c = 0; c < seeedpool->getNConssForCons( nodeCons ); ++ c )
2682  {
2683  int othercons;
2684  othercons = seeedpool->getConssForCons( nodeCons )[c];
2685 
2686  if( isConsVisited[othercons] || isConsMastercons( othercons ) || ! isConsOpen[othercons] )
2687  continue;
2688 
2689  assert( isConsOpencons( othercons ) );
2690  isConsVisited[othercons] = true;
2691  neighborConss.push_back( othercons );
2692  helpqueue.push( othercons );
2693  }
2694  }
2695 
2697  ++nnewblocks;
2698  for( size_t i = 0; i < neighborConss.size(); ++ i )
2699  {
2700  std::vector<int>::iterator consiter;
2701  cons = neighborConss[i];
2702  consiter = std::lower_bound(constoconsider.begin(), constoconsider.end(), cons);
2703  assert(consiter != constoconsider.end() );
2704  constoconsider.erase(consiter);
2705  assert( isConsOpencons( cons ) );
2706  newconss.push_back(cons);
2707 
2708  for( int j = 0; j < seeedpool->getNVarsForCons(cons); ++ j )
2709  {
2710  int newvar = seeedpool->getVarsForCons(cons)[j];
2711 
2712  if( isVarLinkingvar(newvar) || varInBlocks[newvar] != -1 )
2713  continue;
2714 
2715  assert(! isVarMastervar( newvar) );
2716  newvars.push_back(newvar);
2717  varInBlocks[newvar] = nnewblocks;
2718  }
2719  }
2720  conssfornewblocks.push_back(newconss);
2721  varsfornewblocks.push_back(newvars);
2722  }
2723 
2724  for( int i = 0; i < nnewblocks; ++i )
2725  {
2726  if( (int)conssfornewblocks[i].size() > sizelargestcomponent )
2727  {
2728  sizelargestcomponent = (int)conssfornewblocks[i].size();
2729  largestcomponent = i;
2730  }
2731  }
2732 
2733  if( nnewblocks > 1 )
2734  {
2735  int oldnblocks;
2736  bool largestdone = false;
2737  oldnblocks = getNBlocks();
2738  setNBlocks(nnewblocks - 1 + getNBlocks());
2739 
2740  for( int i = 0; i < nnewblocks; ++i)
2741  {
2742  if( i == largestcomponent )
2743  {
2744  largestdone = true;
2745  continue;
2746  }
2747  for( int c = 0; c < (int) conssfornewblocks[i].size() ; ++c)
2748  {
2749  bookAsBlockCons(conssfornewblocks[i][c], oldnblocks + i - (largestdone ? 1 : 0) );
2750  }
2751 
2752  for( int v = 0; v < (int) varsfornewblocks[i].size() ; ++v )
2753  {
2754  bookAsBlockVar(varsfornewblocks[i][v], oldnblocks + i - (largestdone ? 1 : 0) );
2755  }
2756  }
2757 
2758  flushBooked();
2759 
2760  sort();
2761  }
2762 
2763  assert( checkConsistency( ) );
2764 
2765  return SCIP_OKAY;
2766  }
2767 
2768 
2769 
2770 
2775  )
2776 {
2777  bool checkVar;
2778  bool varInBlock;
2779  bool notassigned;
2780 
2781  changedHashvalue = true;
2782 
2784  std::vector<int> varInBlocks;
2786  assert( (int) conssForBlocks.size() == nBlocks );
2787  assert( (int) varsForBlocks.size() == nBlocks );
2788  assert( (int) stairlinkingVars.size() == nBlocks );
2789 
2790  if( nBlocks == 0 && openConss.size() > 0 )
2791  {
2792  addBlock();
2793  if( openConss.size() != 0 )
2794  {
2795  setConsToBlock( openConss[0], 0 );
2796  openConss.erase( openConss.begin() );
2797  }
2798  else if( masterConss.size() != 0 )
2799  {
2800  setConsToBlock( masterConss[0], 0 );
2801  masterConss.erase( masterConss.begin() );
2802  isconsmaster[masterConss[0]] = false;
2803  }
2804  else
2805  assert( ! ( openConss.size() == 0 && masterConss.size() == 0 ) );
2806  }
2807 
2809  for( size_t i = 0; i < openVars.size(); ++ i )
2810  {
2813  varInBlocks.clear();
2814 
2816  for( int b = 0; b < nBlocks; ++ b )
2817  {
2818  varInBlock = false;
2819  for( size_t k = 0; k < conssForBlocks[b].size() && ! varInBlock; ++ k )
2820  {
2821  for( int l = 0; l < seeedpool->getNVarsForCons( conssForBlocks[b][k] ); ++ l )
2822  {
2823  if( openVars[i] == seeedpool->getVarsForCons( conssForBlocks[b][k] )[l] )
2824  {
2825  varInBlocks.push_back( b );
2826  varInBlock = true;
2827  break;
2828  }
2829  }
2830  }
2831  }
2832  if( varInBlocks.size() == 1 )
2833  {
2834  bookAsBlockVar( openVars[i], varInBlocks[0] );
2835  continue;
2836  }
2837  else if( varInBlocks.size() == 2 )
2838  {
2839  if( varInBlocks[0] + 1 == varInBlocks[1] )
2840  {
2841  bookAsStairlinkingVar( openVars[i], varInBlocks[0] );
2842  continue;
2843  }
2844  else
2845  {
2846  bookAsLinkingVar( openVars[i] );
2847  continue;
2848  }
2849  }
2850  else if( varInBlocks.size() > 2 )
2851  {
2852  bookAsLinkingVar( openVars[i] );
2853  continue;
2854  }
2855 
2856  checkVar = true;
2857 
2859  for( size_t j = 0; j < openConss.size(); ++ j )
2860  {
2861  checkVar = true;
2862  for( int k = 0; k < seeedpool->getNVarsForCons( j ); ++ k )
2863  {
2864  if( openVars[i] == seeedpool->getVarsForCons( j )[k] )
2865  {
2866  checkVar = false;
2867  break;
2868  }
2869  }
2870  if( ! checkVar )
2871  {
2872  break;
2873  }
2874  }
2875 
2877  for( int k = 0; k < seeedpool->getNConssForVar( openVars[i] ) && checkVar; ++ k )
2878  {
2879  if( isconsmaster[seeedpool->getConssForVar(openVars[i])[k]] )
2880  {
2881  bookAsMasterVar( openVars[i] );
2882  checkVar = false;
2883  break;
2884  }
2885  }
2886 
2887 // for( size_t j = 0; j < masterConss.size() && checkVar; ++ j )
2888 // {
2889 // for( int k = 0; k < seeedpool->getNVarsForCons( masterConss[j] ); ++ k )
2890 // {
2891 // if( openVars[i] == seeedpool->getVarsForCons( masterConss[j] )[k] )
2892 // {
2893 // bookAsMasterVar( openVars[i] );
2894 // checkVar = false; /** the variable does'nt need to be checked any more */
2895 // break;
2896 // }
2897 // }
2898 // }
2899  }
2900 
2901  flushBooked();
2902 
2904  for( size_t i = 0; i < openConss.size(); ++ i )
2905  {
2906  std::vector<int> vecOpenvarsOfBlock;
2907  bool consGotBlockcons = false;
2910  for( int j = 0; j < nBlocks; ++ j )
2911  {
2913  consGotBlockcons = true;
2914  for( int k = 0; k < seeedpool->getNVarsForCons( openConss[i] ); ++ k )
2915  {
2916  if( isVarBlockvarOfBlock( seeedpool->getVarsForCons( openConss[i] )[k], j )
2917  || isVarOpenvar( seeedpool->getVarsForCons( openConss[i] )[k] )
2918  || isVarLinkingvar( seeedpool->getVarsForCons( openConss[i] )[k] )
2919  || isVarStairlinkingvarOfBlock( seeedpool->getVarsForCons( openConss[i] )[k], j )
2920  || ( j != 0 && isVarStairlinkingvarOfBlock( seeedpool->getVarsForCons( openConss[i] )[k], j - 1 ) ) )
2921  {
2922  if( isVarOpenvar( seeedpool->getVarsForCons( openConss[i] )[k] ) )
2923  {
2924  vecOpenvarsOfBlock.push_back( seeedpool->getVarsForCons( openConss[i] )[k] );
2925  }
2926  }
2927  else
2928  {
2929  vecOpenvarsOfBlock.clear();
2930  consGotBlockcons = false;
2931  break;
2932  }
2933  }
2934  if( consGotBlockcons )
2935  {
2936  bookAsBlockCons( openConss[i], j );
2937  for( size_t k = 0; k < vecOpenvarsOfBlock.size(); ++ k )
2938  {
2939  setVarToBlock( vecOpenvarsOfBlock[k], j );
2940  deleteOpenvar( vecOpenvarsOfBlock[k] );
2941  }
2942  vecOpenvarsOfBlock.clear();
2943 
2944  break;
2945  }
2946  }
2947 
2948  if( ! consGotBlockcons )
2949  bookAsMasterCons( openConss[i] );
2950  }
2951 
2952  flushBooked();
2953 
2955  for( size_t i = 0; i < openVars.size(); ++ i )
2956  {
2957  notassigned = true;
2958  for( size_t j = 0; j < masterConss.size() && notassigned; ++ j )
2959  {
2960  for( int k = 0; k < seeedpool->getNVarsForCons( masterConss[j] ); ++ k )
2961  {
2962  if( openVars[i] == seeedpool->getVarsForCons( masterConss[j] )[k] )
2963  {
2964  bookAsMasterVar( openVars[i] );
2965  notassigned = false;
2966  break;
2967  }
2968  }
2969  }
2970  }
2971 
2972  flushBooked();
2973 
2975  if( ! checkAllConssAssigned() )
2976  {
2977  SCIPwarningMessage(scip,"ERROR: Something went wrong, there are still open cons, although all should have been assigned\n" );
2978  assert( false );
2981  }
2982 
2984  if( ! openVars.empty() )
2985  {
2986  SCIPwarningMessage(scip,"ERROR: Something went wrong, there are still open vars, although all should have been assigned\n" );
2987  assert( false );
2988  }
2989 
2990  assert( checkConsistency( ) );
2991 
2992  return SCIP_OKAY;
2993 }
2994 
2997  int detectorchainindex
2998  )
2999 {
3000  assert( 0 <= detectorchainindex && detectorchainindex < (int) usedClassifier.size() );
3001 
3002  return ( usedClassifier[detectorchainindex] != NULL )
3003  && ( dynamic_cast<ConsClassifier*>( usedClassifier[detectorchainindex] ) != NULL );
3004 }
3005 
3012  )
3013 {
3014  int cons;
3015  int var;
3016  std::vector<int> blocksOfBlockvars;
3017  std::vector<int> blocksOfOpenvar;
3018  bool master;
3019  bool hitsOpenVar;
3020  bool hitsOpenCons;
3021  bool benders;
3022 
3023  benders = seeedpool->isForBenders();
3024 
3025  changedHashvalue = true;
3026 
3027  sort();
3028 
3030  for( size_t c = 0; c < openConss.size(); ++ c )
3031  {
3032  std::vector<bool> hitsblock = std::vector<bool>(nBlocks, false);
3033  blocksOfBlockvars.clear();
3034  master = false;
3035  hitsOpenVar = false;
3036  cons = openConss[c];
3037 
3038  for( int v = 0; v < seeedpool->getNVarsForCons( cons ) && ! master; ++ v )
3039  {
3040  var = seeedpool->getVarsForCons( cons )[v];
3041 
3042  if( isVarMastervar( var ) )
3043  {
3044  master = true;
3045  bookAsMasterCons( cons );
3046  continue;
3047  }
3048 
3049  if( isVarOpenvar( var ) )
3050  {
3051  hitsOpenVar = true;
3052  if( !benders )
3053  continue;
3054  }
3055 
3056 
3057  for( int b = 0; b < nBlocks && ! master; ++ b )
3058  {
3059  if( isVarBlockvarOfBlock( var, b ) && !hitsblock[b] )
3060  {
3061  hitsblock[b] = true;
3062  blocksOfBlockvars.push_back( b );
3063  break;
3064  }
3065  }
3066  }
3067 
3068  if ( benders && blocksOfBlockvars.size() == 1 && !master )
3069  bookAsBlockCons( cons, blocksOfBlockvars[0] );
3070 
3071 // if( benders && master )
3072 // bookAsMasterCons( cons );
3073 
3074  if( !benders && blocksOfBlockvars.size() > 1 )
3075  bookAsMasterCons( cons );
3076 
3077  /* also assign open constraints that only have vars assigned to one single block and no open vars*/
3078  if( blocksOfBlockvars.size() == 1 && ! hitsOpenVar && ! master && ! benders )
3079  bookAsBlockCons( cons, blocksOfBlockvars[0] );
3080  }
3081 
3082  flushBooked();
3083 
3085  for( size_t i = 0; i < openVars.size(); ++ i )
3086  {
3087  std::vector<bool> hitsblock = std::vector<bool>(nBlocks, false);
3088  bool hitsmasterconss = false;
3089  bool hitonlymasterconss = true;
3090  bool hitonlyblockconss = true;
3091  blocksOfOpenvar.clear();
3092  var = openVars[i];
3093  hitsOpenCons = false;
3094 
3095 
3096  for( int c = 0; c < seeedpool->getNConssForVar( var ); ++ c )
3097  {
3098  cons = seeedpool->getConssForVar( var )[c];
3099  if ( isConsMastercons(cons) )
3100  {
3101  hitsmasterconss = true;
3102  hitonlyblockconss = false;
3103  continue;
3104  }
3105 
3106  if( isConsOpencons( cons ) )
3107  {
3108  hitsOpenCons = true;
3109  hitonlyblockconss = false;
3110  hitonlymasterconss = false;
3111  continue;
3112  }
3113  }
3114  for( int b = 0; b < nBlocks; ++ b )
3115  {
3116  for( int c = 0; c < seeedpool->getNConssForVar( var ); ++ c )
3117  {
3118  cons = seeedpool->getConssForVar( var )[c];
3119  if( isConsBlockconsOfBlock( cons, b ) && !hitsblock[b] )
3120  {
3121  hitsblock[b] = true;
3122  hitonlymasterconss = false;
3123  blocksOfOpenvar.push_back( b );
3124  break;
3125  }
3126  }
3127  }
3128 
3129  if( blocksOfOpenvar.size() > 1 )
3130  {
3131  bookAsLinkingVar( var );
3132  continue;
3133  }
3134 
3135  if( benders && blocksOfOpenvar.size() == 1 && hitsmasterconss )
3136  {
3137  bookAsLinkingVar( var );
3138  }
3139 
3140  if( benders && hitonlyblockconss && blocksOfOpenvar.size() > 0 )
3141  {
3142  bookAsBlockVar( var, blocksOfOpenvar[0] );
3143  }
3144 
3145  if( benders && hitonlymasterconss)
3146  {
3147  bookAsMasterVar( var);
3148  }
3149 
3150  if( !benders && blocksOfOpenvar.size() == 1 && ! hitsOpenCons )
3151  {
3152  bookAsBlockVar( var, blocksOfOpenvar[0] );
3153  }
3154 
3155  if( !benders && blocksOfOpenvar.size() == 0 && ! hitsOpenCons )
3156  {
3157  bookAsMasterVar( var );
3158  }
3159 
3160 
3161 
3162  }
3163 
3164  flushBooked();
3165 
3166  return SCIP_OKAY;
3167 }
3168 
3171  const Seeed* otherseeed
3172  )
3173 {
3174  usedClassifier = otherseeed->usedClassifier;
3175  classesToMaster = otherseeed->classesToMaster;
3176  classesToLinking = otherseeed->classesToLinking;
3177 
3178  return SCIP_OKAY;
3179 }
3180 
3183  bool variables /* if TRUE a block is only considered to be empty if it contains neither constraints or variables */
3184  )
3185 {
3186  bool emptyBlocks = true;
3187  bool benders = false;
3188  int block = - 1;
3189  int b;
3190 
3191  changedHashvalue = true;
3192 
3193  assert( (int) conssForBlocks.size() == nBlocks );
3194  assert( (int) varsForBlocks.size() == nBlocks );
3195  assert( (int) stairlinkingVars.size() == nBlocks );
3196 
3197  benders = seeedpool->isForBenders();
3198 
3199  while( emptyBlocks )
3200  {
3201  emptyBlocks = false;
3202  for( b = 0; b < nBlocks; ++ b )
3203  {
3204  if( conssForBlocks[b].size() == 0 && ( variables ? varsForBlocks[b].size() == 0 : true) )
3205  {
3206  emptyBlocks = true;
3207  block = b;
3208  }
3209  if( benders && ( conssForBlocks[b].size() == 0 || varsForBlocks[b].size() == 0) )
3210  {
3211  emptyBlocks = true;
3212  block = b;
3213  }
3214 
3215  }
3216  if( emptyBlocks )
3217  {
3218  nBlocks --;
3219 
3220  std::vector<std::vector<int>>::iterator it;
3221 
3222  it = stairlinkingVars.begin();
3223  for( b = 0; b < block; ++ b )
3224  it ++;
3225  stairlinkingVars.erase( it );
3226 
3227  it = conssForBlocks.begin();
3228  for( b = 0; b < block; ++ b )
3229  it ++;
3230  for( size_t j = 0; j < conssForBlocks[block].size(); ++j )
3231  {
3232  masterConss.push_back(conssForBlocks[block][j]);
3233  isconsmaster[conssForBlocks[block][j]] = true;
3234  }
3235  std::sort( masterConss.begin(), masterConss.end() );
3236  conssForBlocks.erase( it );
3237 
3238  it = varsForBlocks.begin();
3239  for( b = 0; b < block; ++ b )
3240  it ++;
3241  for( size_t j = 0; j < varsForBlocks[block].size(); ++ j )
3242  {
3243  masterVars.push_back( varsForBlocks[block][j] );
3244  isvarmaster[varsForBlocks[block][j]] = true;
3245  }
3246  varsForBlocks.erase( it );
3247  std::sort( masterVars.begin(), masterVars.end() );
3248 
3249  //set stairlinkingvars of the previous block to block vars
3250  if( block != 0 && (int) stairlinkingVars[block - 1].size() != 0 )
3251  {
3252  std::vector<int>::iterator iter = stairlinkingVars[block - 1].begin();
3253  std::vector<int>::iterator iterEnd = stairlinkingVars[block - 1].end();
3254  std::vector<int> stairlinkingVarsOfPreviousBlock;
3255  for( ; iter != iterEnd; ++ iter )
3256  {
3257  bookAsBlockVar( * iter, block - 1 );
3258  stairlinkingVarsOfPreviousBlock.push_back( * iter );
3259  }
3260  for( size_t i = 0; i < stairlinkingVarsOfPreviousBlock.size(); ++ i )
3261  {
3262  iter = find( stairlinkingVars[block - 1].begin(), stairlinkingVars[block - 1].end(),
3263  stairlinkingVarsOfPreviousBlock[i] );
3264  assert( iter != stairlinkingVars[block - 1].end() );
3265  stairlinkingVars[block - 1].erase( iter );
3266  }
3267  flushBooked();
3268  }
3269  }
3270  }
3271  return SCIP_OKAY;
3272 }
3273 
3276  int opencons
3277  )
3278 {
3279  assert( opencons >= 0 && opencons < nConss );
3280  std::vector<int>::iterator it;
3281  it = lower_bound( openConss.begin(), openConss.end(), opencons );
3282  assert( it != openConss.end() && *it == opencons );
3283  openConss.erase( it );
3284  isconsopen[opencons] = false;
3285  changedHashvalue = true;
3286 
3287  return SCIP_OKAY;
3288 }
3289 
3292  int openvar
3293  )
3294 {
3295  assert( openvar >= 0 && openvar < nVars );
3296  std::vector<int>::iterator it;
3297  it = lower_bound( openVars.begin(), openVars.end(), openvar );
3298  assert( it != openVars.end() && *it == openvar );
3299  openVars.erase( it );
3300  isvaropen[openvar] = false;
3301  changedHashvalue = true;
3302  return SCIP_OKAY;
3303 }
3304 
3306 {
3307  if( !agginfocalculated )
3308  {
3309  SCIPinfoMessage(scip, NULL, " Aggregation information is not calculated yet \n ");
3310  return SCIP_OKAY;
3311  }
3312 
3313  SCIPinfoMessage(scip, NULL, " number of representative blocks: %d \n", nrepblocks);
3314  for( int i = 0; i < nrepblocks; ++i )
3315  {
3316  SCIPinfoMessage(scip, NULL, "representative block %d : ", i);
3317 
3318  for( size_t b = 0; b < reptoblocks[i].size(); ++b )
3319  SCIPinfoMessage(scip, NULL, "%d ", reptoblocks[i][b] );
3320 
3321  SCIPinfoMessage(scip, NULL, "\n", i);
3322  }
3323 
3324  return SCIP_OKAY;
3325 }
3326 
3328 SCIP_RETCODE Seeed::displayConss()
3329 {
3330  for( int b = 0; b < nBlocks; ++ b )
3331  {
3332  if( getNConssForBlock( b ) != 0 )
3333  {
3334  std::cout << "constraint(s) in block " << b << ": ";
3335  std::cout << getConssForBlock( b )[0] << "|" << SCIPconsGetName(seeedpool->getConsForIndex(getConssForBlock( b )[0]) ) ;
3336  for( int c = 1; c < getNConssForBlock( b ); ++ c )
3337  std::cout << ", " << getConssForBlock( b )[c] << "|" << SCIPconsGetName(seeedpool->getConsForIndex(getConssForBlock( b )[c]) ) ;
3338  std::cout << "\n";
3339  }
3340  else
3341  std::cout << "0 constraints in block " << b << std::endl;
3342  }
3343 
3344  if( getNMasterconss() != 0 )
3345  {
3346  std::cout << "masterconstraint(s): ";
3347  std::cout << masterConss[0];
3348  for( int c = 1; c < getNMasterconss(); ++ c )
3349  std::cout << ", " << masterConss[c];
3350  std::cout << "\n";
3351  }
3352  else
3353  std::cout << "0 masterconstraints" << std::endl;
3354 
3355  if( getNOpenconss() != 0 )
3356  {
3357  std::cout << "open constraint(s): ";
3358  std::cout << openConss[0];
3359  for( int c = 1; c < getNOpenconss(); ++ c )
3360  std::cout << ", " << openConss[c];
3361  std::cout << "\n";
3362  }
3363  else
3364  std::cout << "0 open constraints" << std::endl;
3365 
3366  return SCIP_OKAY;
3367 }
3368 
3370 SCIP_RETCODE Seeed::displayInfo(
3371  int detailLevel
3372  )
3373 {
3374  assert( seeedpool != NULL );
3375  assert( 0 <= detailLevel );
3376 
3377 
3378  std::cout << std::endl;
3379 
3380  /* general information */
3381  std::cout << "-- General information --" << std::endl;
3382  std::cout << " ID: " << id << std::endl;
3383  std::cout << " Hashvalue: " << hashvalue << std::endl;
3384  std::cout << " Score: " << score << std::endl;
3385  if( getNOpenconss() + getNOpenconss() > 0 )
3386  std::cout << " Maxwhitescore >= " << maxwhitescore << std::endl;
3387  else
3388  std::cout << " Max white score: " << maxwhitescore << std::endl;
3389  if( getNOpenconss() + getNOpenconss() == 0 )
3390  std::cout << " Max-foreseeing-white-score: " << maxforeseeingwhitescore << std::endl;
3391  if( getNOpenconss() + getNOpenconss() == 0 )
3392  std::cout << " Max-foreseeing-white-aggregated-score: " << maxforeseeingwhitescoreagg << std::endl;
3393  if( getNOpenconss() + getNOpenconss() == 0 )
3394  std::cout << " PPC-max-foreseeing-white-score: " << setpartfwhitescore << std::endl;
3395 
3396  if( getNOpenconss() + getNOpenconss() == 0 )
3397  std::cout << " PPC-max-foreseeing-white-aggregated-score: " << setpartfwhitescoreagg << std::endl;
3398 
3399  if( getNOpenconss() + getNOpenconss() == 0 )
3400  std::cout << " Benderborderarea: " << benderareascore << std::endl;
3401 
3402 
3403  if( getNOpenconss() + getNOpenconss() == 0 )
3404  std::cout << " Bendersscore: " << bendersscore << std::endl;
3405 
3406  if( getNOpenconss() + getNOpenconss() == 0 )
3407  std::cout << " blockarea: " << blockareascore << std::endl;
3408 
3409 
3410  if( getNOpenconss() + getNOpenconss() == 0 )
3411  std::cout << " borderareascore: " << borderareascore << std::endl;
3412 
3413 
3414  std::cout << " HassetppMaster: " << hasSetppMaster() << std::endl;
3415  std::cout << " HassetppcMaster: " << hasSetppcMaster() << std::endl;
3416  std::cout << " HassetppccardMaster: " << hasSetppccardMaster() << std::endl;
3417  std::cout << " Seeed is for the " << ( isfromunpresolved ? "unpresolved" : "presolved" ) << " problem and "
3418  << ( usergiven ? "usergiven" : "not usergiven" ) << "." << std::endl;
3419  std::cout << " Number of constraints: " << getNConss() << std::endl;
3420  std::cout << " Number of variables: " << getNVars() << std::endl;
3421 
3423  std::cout << std::endl;
3424 
3425 
3426 
3427  /* detection information */
3428  std::cout << "-- Detection and detectors --" << std::endl;
3429  std::cout << " Seeed stems from the " << ( stemsFromUnpresolved ? "unpresolved" : "presolved" ) << " problem." << std::endl;
3430  if( isFromLegacymode() )
3431  {
3432  std::cout << " Seeed is from a detector operating in legacymode." << std::endl;
3433  }
3434 
3435  /* ancestor seeeds' ids */
3436  std::cout << " IDs of ancestor seeeds: ";
3437  if( listofancestorids.size() > 0 )
3438  std::cout << listofancestorids[0];
3439  for( int i = 1; i < (int) listofancestorids.size(); ++i )
3440  std::cout << ", " << listofancestorids[i];
3441  std::cout << std::endl;
3442 
3443  /* detector chain information */
3444  std::cout << " " << getNDetectors() << " detector" << ( getNDetectors() > 1 ? "s" : "" ) << " worked on this seeed:";
3445  if( getNDetectors() != 0 )
3446  {
3447  std::string detectorrepres;
3448 
3449  if( detectorChain[0] == NULL )
3450  detectorrepres = "user";
3451  else
3452  {
3453  /* potentially add finisher label */
3454  detectorrepres = (
3455  getNDetectors() != 1 || !isFinishedByFinisher ? DECdetectorGetName(detectorChain[0]) :
3456  "(finish) " + std::string(DECdetectorGetName(detectorChain[0])));
3457  }
3458 
3459  if( detailLevel > 0 )
3460  {
3461  std::cout << std::endl << " 1.: " << detectorrepres << std::endl;
3462  std::cout << getDetectorStatistics( 0 );
3463  std::cout << getDetectorClassifierInfo( 0, detailLevel > 1 && ( !stemsFromUnpresolved || isfromunpresolved ) );
3464  }
3465  else
3466  {
3467  std::cout << " " << detectorrepres;
3468  }
3469 
3470  for( int d = 1; d < getNDetectors(); ++d )
3471  {
3472  /* potentially add finisher label */
3473  detectorrepres = (
3474  getNDetectors() != d + 1 || !isFinishedByFinisher ? DECdetectorGetName(detectorChain[d]) :
3475  "(finish) " + std::string(DECdetectorGetName(detectorChain[d])));
3476 
3477 
3478  if( detailLevel > 0 )
3479  {
3480  std::cout << " " << ( d + 1 ) << ".: " << detectorrepres << std::endl;
3481  std::cout << getDetectorStatistics( d );
3482  std::cout << getDetectorClassifierInfo( d, detailLevel > 1 && ( !stemsFromUnpresolved || isfromunpresolved ) );
3483  }
3484  else
3485  {
3486  std::cout << ", " << detectorrepres;
3487  }
3488  }
3489 
3490  if( detailLevel <= 0 )
3491  {
3492  std::cout << std::endl;
3493  }
3494  }
3495 
3496  std::cout << std::endl;
3497 
3498  /* variable information */
3499  std::cout << "-- Border and unassigned --" << std::endl;
3500  std::cout << " Linkingvariables";
3501  if( detailLevel > 1 )
3502  {
3503  std::cout << " (" << getNLinkingvars() << ")";
3504  if( getNLinkingvars() > 0 )
3505  std::cout << ": " << SCIPvarGetName( seeedpool->getVarForIndex( getLinkingvars()[0] ) );
3506  for( int v = 1; v < getNLinkingvars(); ++v )
3507  {
3508  std::cout << ", " << SCIPvarGetName( seeedpool->getVarForIndex( getLinkingvars()[v] ) );
3509  }
3510  std::cout << std::endl;
3511  }
3512  else
3513  {
3514  std::cout << ": " << getNLinkingvars() << std::endl;
3515  }
3516  std::cout << " Masterconstraints";
3517  if( detailLevel > 1 )
3518  {
3519  std::cout << " (" << getNMasterconss() << ")";
3520  if( getNMasterconss() > 0 )
3521  std::cout << ": " << SCIPconsGetName( seeedpool->getConsForIndex( getMasterconss()[0] ) );
3522  for( int c = 1; c < getNMasterconss(); ++c )
3523  {
3524  std::cout << ", " << SCIPconsGetName( seeedpool->getConsForIndex( getMasterconss()[c] ) );
3525  }
3526  std::cout << std::endl;
3527  }
3528  else
3529  {
3530  std::cout << ": " << getNMasterconss() << std::endl;
3531  }
3532  std::cout << " Mastervariables";
3533  if( detailLevel > 1 )
3534  {
3535  std::cout << " (" << getNMastervars() << ")";
3536  if( getNMastervars() > 0 )
3537  std::cout << ": " << SCIPvarGetName( seeedpool->getVarForIndex( getMastervars()[0] ) );
3538  for( int v = 1; v < getNMastervars(); ++v )
3539  {
3540  std::cout << ", " << SCIPvarGetName( seeedpool->getVarForIndex( getMastervars()[v] ) );
3541  }
3542  std::cout << std::endl;
3543  }
3544  else
3545  {
3546  std::cout << ": " << getNMastervars() << std::endl;
3547  }
3548  std::cout << " Open constraints";
3549  if( detailLevel > 1 )
3550  {
3551  std::cout << " (" << getNOpenconss() << ")";
3552  if( getNOpenconss() > 0 )
3553  std::cout << ": " << SCIPconsGetName( seeedpool->getConsForIndex( getOpenconss()[0] ) );
3554  for( int c = 1; c < getNOpenconss(); ++c )
3555  {
3556  std::cout << ", " << SCIPconsGetName( seeedpool->getConsForIndex( getOpenconss()[c] ) );
3557  }
3558  std::cout << std::endl;
3559  }
3560  else
3561  {
3562  std::cout << ": " << getNOpenconss() << std::endl;
3563  }
3564  std::cout << " Open variables";
3565  if( detailLevel > 1 )
3566  {
3567  std::cout << " (" << getNOpenvars() << ")";
3568  if( getNOpenvars() > 0 )
3569  std::cout << ": " << SCIPvarGetName( seeedpool->getVarForIndex( getOpenvars()[0] ) );
3570  for( int v = 1; v < getNOpenvars(); ++v )
3571  {
3572  std::cout << ", " << SCIPvarGetName( seeedpool->getVarForIndex( getOpenvars()[v] ) );
3573  }
3574  std::cout << std::endl;
3575  }
3576  else
3577  {
3578  std::cout << ": " << getNOpenvars() << std::endl;
3579  }
3580 
3581  std::cout << std::endl;
3582 
3583  /* block information */
3584  std::cout << "-- Blocks --" << std::endl;
3585  std::cout << " Number of blocks: " << nBlocks << std::endl;
3586 
3587  if( detailLevel > 0 )
3588  {
3589  for( int b = 0; b < nBlocks; ++b )
3590  {
3591  std::cout << " Block " << b << ":" << std::endl;
3592 
3593  std::cout << " Constraints";
3594  if( detailLevel > 1 )
3595  {
3596  std::cout << " (" << getNConssForBlock( b ) << ")";
3597  if( getNConssForBlock( b ) > 0 )
3598  std::cout << ": " << SCIPconsGetName( seeedpool->getConsForIndex( getConssForBlock( b )[0] ) );
3599  for( int c = 1; c < getNConssForBlock( b ); ++c )
3600  {
3601  std::cout << ", " << SCIPconsGetName( seeedpool->getConsForIndex( getConssForBlock( b )[c] ) );
3602  }
3603  std::cout << std::endl;
3604  }
3605  else
3606  {
3607  std::cout << ": " << getNConssForBlock( b ) << std::endl;
3608  }
3609 
3610  std::cout << " Variables";
3611  if( detailLevel > 1 )
3612  {
3613  std::cout << " (" << getNVarsForBlock( b ) << ")";
3614  if( getNVarsForBlock( b ) > 0 )
3615  std::cout << ": " << SCIPvarGetName( seeedpool->getVarForIndex( getVarsForBlock( b )[0] ) );
3616  for( int v = 1; v < getNVarsForBlock( b ); ++v )
3617  {
3618  std::cout << ", " << SCIPvarGetName( seeedpool->getVarForIndex( getVarsForBlock( b )[v] ) );
3619  }
3620  std::cout << std::endl;
3621  }
3622  else
3623  {
3624  std::cout << ": " << getNVarsForBlock( b ) << std::endl;
3625  }
3626 
3627  std::cout << " Stairlinkingvariables";
3628  if( detailLevel > 1 )
3629  {
3630  std::cout << " (" << getNStairlinkingvars( b ) << ")";
3631  if( getNStairlinkingvars( b ) > 0 )
3632  std::cout << ": " << SCIPvarGetName( seeedpool->getVarForIndex( getStairlinkingvars( b )[0] ) );
3633  for( int v = 1; v < getNStairlinkingvars( b ); ++v )
3634  {
3635  std::cout << ", " << SCIPvarGetName( seeedpool->getVarForIndex( getStairlinkingvars( b )[v] ) );
3636  }
3637  std::cout << std::endl;
3638  }
3639  else
3640  {
3641  std::cout << ": " << getNStairlinkingvars( b ) << std::endl;
3642  }
3643  }
3644  }
3645 
3646  std::cout << std::endl;
3647 
3648  return SCIP_OKAY;
3649 }
3650 
3652 SCIP_RETCODE Seeed::displaySeeed(
3653  )
3654 {
3655  std::cout << "ID: " << id << std::endl;
3656  std::cout << "number of blocks: " << nBlocks << std::endl;
3657  std::cout << "hashvalue: " << hashvalue << std::endl;
3658  std::cout << "score: " << score << std::endl;
3659  if( getNOpenconss() + getNOpenconss() > 0 )
3660  std::cout << "maxwhitescore >= " << maxwhitescore << std::endl;
3661  else
3662  std::cout << "maxwhitescore: " << maxwhitescore << std::endl;
3663  std::cout << "ancestorids: ";
3664  for( size_t i = 0; i < listofancestorids.size(); ++ i )
3665  std::cout << listofancestorids[i] << "; ";
3666  std::cout << std::endl;
3667 
3668  for( int b = 0; b < nBlocks; ++ b )
3669  {
3670  std::cout << getNConssForBlock( b ) << " constraint(s) in block " << b << std::endl;
3671  std::cout << getNVarsForBlock( b ) << " variable(s) in block " << b << std::endl;
3672  std::cout << getNStairlinkingvars( b ) << " stairlinkingvariable(s) in block " << b << std::endl;
3673  }
3674 
3675  std::cout << getNLinkingvars() << " linkingvariable(s)" << std::endl;
3676  std::cout << getNMasterconss() << " mastercontraint(s)" << std::endl;
3677  std::cout << getNMastervars() << " mastervariable(s)" << std::endl;
3678  std::cout << getNOpenconss() << " open constraint(s)" << std::endl;
3679  std::cout << getNOpenvars() << " open variable(s)" << std::endl;
3680  std::cout << " stems from unpresolved problem: " << stemsFromUnpresolved << std::endl;
3681  std::cout << getNDetectors() << " detector(s)";
3682  if( getNDetectors() != 0 )
3683  {
3684  std::string detectorrepres;
3685 
3686  if( detectorChain[0] == NULL )
3687  detectorrepres = "user";
3688  else
3689  detectorrepres = (
3690  getNDetectors() != 1 || ! isFinishedByFinisher ? DECdetectorGetName( detectorChain[0] ) :
3691  "(finish)" + std::string( DECdetectorGetName( detectorChain[0] ) ) );
3692 
3693  std::cout << ": " << detectorrepres;
3694 
3695  for( int d = 1; d < getNDetectors(); ++ d )
3696  {
3697  detectorrepres = (
3698  getNDetectors() != d + 1 || ! isFinishedByFinisher ? DECdetectorGetName( detectorChain[d] ) :
3699  "(finish)" + std::string( DECdetectorGetName( detectorChain[d] ) ) );
3700 
3701  std::cout << ", " << detectorrepres;
3702  }
3703  }
3704  std::cout << "\n";
3705 
3706  return SCIP_OKAY;
3707 }
3708 
3710 SCIP_RETCODE Seeed::displayVars(
3711  )
3712 {
3713  for( int b = 0; b < nBlocks; ++ b )
3714  {
3715  if( getNVarsForBlock( b ) != 0 )
3716  {
3717  std::cout << "variable(s) in block " << b << ": ";
3718  std::cout << getVarsForBlock( b )[0] << " ("
3719  << ( seeedpool != NULL ? ( SCIPvarGetName( seeedpool->getVarForIndex( getVarsForBlock( b )[0] ) ) ) : "" )
3720  << ") ";
3721  for( int c = 1; c < getNVarsForBlock( b ); ++ c )
3722  std::cout << ", " << getVarsForBlock( b )[c] << " ("
3723  << ( seeedpool != NULL ? ( SCIPvarGetName( seeedpool->getVarForIndex( getVarsForBlock( b )[c] ) ) ) : "" )
3724  << ") ";
3725  std::cout << "\n";
3726  }
3727  else
3728  std::cout << "0 variables in block " << b << std::endl;
3729  if( getNStairlinkingvars( b ) != 0 )
3730  {
3731  std::cout << "stairlinkingvariable(s) in block " << b << ": ";
3732  std::cout << getStairlinkingvars( b )[0] << " ("
3733  << ( seeedpool != NULL ? ( SCIPvarGetName( seeedpool->getVarForIndex( getStairlinkingvars( b )[0] ) ) ) : "" )
3734  << ") ";
3735  for( int c = 1; c < getNStairlinkingvars( b ); ++ c )
3736  std::cout << ", " << getStairlinkingvars( b )[c] << " ("
3737  << ( seeedpool != NULL ? ( SCIPvarGetName( seeedpool->getVarForIndex( getStairlinkingvars( b )[c] ) ) ) : "" )
3738  << ") ";
3739  std::cout << "\n";
3740  }
3741  else
3742  std::cout << "0 stairlinkingvariables in block " << b << std::endl;
3743  }
3744 
3745  if( getNLinkingvars() != 0 )
3746  {
3747  std::cout << "linkingvariable(s): ";
3748  std::cout << linkingVars[0] << " ("
3749  << ( seeedpool != NULL ? ( SCIPvarGetName( seeedpool->getVarForIndex( linkingVars[0] ) ) ) : "" ) << ") ";
3750  for( int c = 1; c < getNLinkingvars(); ++ c )
3751  std::cout << ", " << linkingVars[c] << " ("
3752  << ( seeedpool != NULL ? ( SCIPvarGetName( seeedpool->getVarForIndex( linkingVars[c] ) ) ) : "" ) << ") ";
3753  std::cout << "\n";
3754  }
3755  else
3756  std::cout << "0 linkingvariables" << std::endl;
3757 
3758  if( getNMastervars() != 0 )
3759  {
3760  std::cout << "mastervariable(s): ";
3761  std::cout << masterVars[0] << " ("
3762  << ( seeedpool != NULL ? ( SCIPvarGetName( seeedpool->getVarForIndex( masterVars[0] ) ) ) : "" ) << ") ";
3763  for( int c = 1; c < getNMastervars(); ++ c )
3764  std::cout << ", " << masterVars[c] << " ("
3765  << ( seeedpool != NULL ? ( SCIPvarGetName( seeedpool->getVarForIndex( masterVars[c] ) ) ) : "" ) << ") ";
3766  std::cout << "\n";
3767  }
3768  else
3769  std::cout << "0 mastervariables" << std::endl;
3770 
3771  if( getNOpenvars() != 0 )
3772  {
3773  std::cout << "open variable(s): ";
3774  std::cout << openVars[0] << " ("
3775  << ( seeedpool != NULL ? ( SCIPvarGetName( seeedpool->getVarForIndex( openVars[0] ) ) ) : "" ) << ") ";
3776  for( int c = 1; c < getNOpenvars(); ++ c )
3777  std::cout << ", " << openVars[c] << " ("
3778  << ( seeedpool != NULL ? ( SCIPvarGetName( seeedpool->getVarForIndex( openVars[c] ) ) ) : "" ) << ") ";
3779  std::cout << "\n";
3780  }
3781  else
3782  std::cout << "0 open variables" << std::endl;
3783 
3784  return SCIP_OKAY;
3785 }
3786 
3790  SCORETYPE sctype
3791  )
3792 {
3793  SCIP_Real borderscore;
3794  SCIP_Real densityscore;
3795  SCIP_Real linkingscore;
3796  SCIP_Real totalscore;
3798  int matrixarea;
3799  int borderarea;
3800  int i;
3801  int j;
3802  int k;
3803  /* int blockarea; */
3804  SCIP_Real varratio;
3805  int* nzblocks;
3806  int* nlinkvarsblocks;
3807  int* nvarsblocks;
3808  SCIP_Real* blockdensities;
3809  int* blocksizes;
3810  SCIP_Real density;
3811 
3812  SCIP_Real alphaborderarea;
3813  SCIP_Real alphalinking;
3814  SCIP_Real alphadensity;
3815 
3816  unsigned long blackarea;
3817 
3818  maxwhitescore = 0.;
3819  alphaborderarea = 0.6;
3820  alphalinking = 0.2;
3821  alphadensity = 0.2;
3822  blackarea = 0;
3823 
3824  assert( checkConsistency() );
3825 
3826  /* calculate bound on max white score */
3827  if( getNOpenconss() != 0 || getNOpenvars() != 0 )
3828  {
3829  blackarea += ( getNLinkingvars() + getNTotalStairlinkingvars() ) * getNConss();
3830  blackarea += (unsigned long) getNMasterconss() * (unsigned long) getNVars();
3831  blackarea -= (unsigned long) getNMastervars() * (unsigned long) getNMasterconss();
3832  for( i = 0; i < nBlocks; ++ i )
3833  {
3834  blackarea += (unsigned long) getNConssForBlock( i ) * (unsigned long) getNVarsForBlock( i );
3835  }
3836 
3837 
3838  maxwhitescore = 1. - ( (SCIP_Real) blackarea / (SCIP_Real) ( (unsigned long) getNConss() * (unsigned long) getNVars() ) );
3839 
3840  return maxwhitescore;
3841 
3842  }
3843 
3844  if( getNOpenconss() != 0 || getNOpenvars() != 0 )
3845  SCIPwarningMessage( scip, "Evaluation for seeeds is not implemented for seeeds with open conss or open vars.\n" );
3846 
3847  // if ( sctype == scoretype::MAX_FORESSEEING_WHITE || sctype == scoretype::SETPART_FWHITE )
3848 
3850 
3851  {
3852  std::vector<int> nlinkingvarsforblock(getNBlocks(), 0);
3853  std::vector<int> nblocksforlinkingvar(getNLinkingvars() + getNTotalStairlinkingvars(), 0);
3854 
3855  int sumblockshittinglinkingvar;
3856  int sumlinkingvarshittingblock;
3857  int newheight;
3858  int newwidth;
3859  int newmasterarea;
3860  int newblockarea;
3861  int newblockareaagg;
3862 
3863 
3864  for( int lv = 0; lv < getNLinkingvars(); ++lv )
3865  {
3866  int linkingvarid = getLinkingvars()[lv];
3867 
3868  for( int b = 0; b < getNBlocks(); ++b )
3869  {
3870  for ( int blc = 0; blc < getNConssForBlock(b); ++blc )
3871  {
3872  int blockcons = getConssForBlock(b)[blc];
3873  if( !SCIPisZero( seeedpool->getScip(), seeedpool->getVal(blockcons, linkingvarid) ) )
3874  {
3876  ++nlinkingvarsforblock[b];
3877  ++nblocksforlinkingvar[lv];
3878  break;
3879  }
3880  }
3881  }
3882  }
3883 
3884  for( int b = 0; b < getNBlocks(); ++b)
3885  {
3886  for( int slv = 0; slv < getNStairlinkingvars(b); ++slv )
3887  {
3888  ++nlinkingvarsforblock[b];
3889  ++nlinkingvarsforblock[b+1];
3890  ++nblocksforlinkingvar[getNLinkingvars() + slv];
3891  ++nblocksforlinkingvar[getNLinkingvars() + slv];
3892  }
3893  }
3894 
3895  sumblockshittinglinkingvar = 0;
3896  sumlinkingvarshittingblock = 0;
3897  for( int b = 0; b < getNBlocks(); ++b )
3898  {
3899  sumlinkingvarshittingblock += nlinkingvarsforblock[b];
3900  }
3901  for( int lv = 0; lv < getNLinkingvars(); ++lv )
3902  {
3903  sumblockshittinglinkingvar += nblocksforlinkingvar[lv];
3904  }
3905 
3906  for( int slv = 0; slv < getNTotalStairlinkingvars(); ++slv )
3907  {
3908  sumblockshittinglinkingvar += nblocksforlinkingvar[getNLinkingvars() + slv];
3909  }
3910 
3911 
3912  newheight = getNConss() + sumblockshittinglinkingvar;
3913  newwidth = getNVars() + sumlinkingvarshittingblock;
3914 
3915  newmasterarea = ( getNMasterconss() + sumblockshittinglinkingvar) * ( getNVars() + sumlinkingvarshittingblock );
3916  newblockarea = 0;
3917  newblockareaagg = 0;
3918 
3919  for( int b = 0; b < getNBlocks(); ++b )
3920  {
3921  newblockarea += getNConssForBlock(b) * ( getNVarsForBlock(b) + nlinkingvarsforblock[b] );
3922  }
3923 
3924  for( int br = 0; br < nrepblocks; ++br )
3925  {
3926  newblockareaagg += getNConssForBlock( reptoblocks[br][0] ) * ( getNVarsForBlock( reptoblocks[br][0] ) + nlinkingvarsforblock[reptoblocks[br][0]] );
3927  }
3928 
3929  maxforeseeingwhitescore = ((SCIP_Real ) newblockarea + (SCIP_Real) newmasterarea) / (SCIP_Real) newwidth;
3930  maxforeseeingwhitescore = maxforeseeingwhitescore / (SCIP_Real) newheight ;
3931 
3932  maxforeseeingwhitescoreagg = ((SCIP_Real ) newblockareaagg + (SCIP_Real) newmasterarea) / (SCIP_Real) newwidth;
3933  maxforeseeingwhitescoreagg = maxforeseeingwhitescoreagg / (SCIP_Real) newheight ;
3934 
3935  maxforeseeingwhitescore = 1. - maxforeseeingwhitescore;
3936  maxforeseeingwhitescoreagg = 1. - maxforeseeingwhitescoreagg;
3937 
3938  }
3939 
3940  if( hasSetppccardMaster() && !isTrivial() && getNBlocks() > 1 )
3941  {
3942  setpartfwhitescore = 0.5 * maxforeseeingwhitescore + 0.5;
3943  setpartfwhitescoreagg = 0.5 * maxforeseeingwhitescoreagg + 0.5;
3944  }
3945  else
3946  {
3947  setpartfwhitescore = 0.5 * maxforeseeingwhitescore;
3948  setpartfwhitescoreagg = 0.5 * maxforeseeingwhitescoreagg;
3949  }
3950 
3951  //if( sctype == scoretype::SETPART_FWHITE )
3952 
3953 
3954 
3955 
3956  SCIP_CALL( SCIPallocBufferArray( scip, & nzblocks, nBlocks ) );
3957  SCIP_CALL( SCIPallocBufferArray( scip, & nlinkvarsblocks, nBlocks ) );
3958  SCIP_CALL( SCIPallocBufferArray( scip, & blockdensities, nBlocks ) );
3959  SCIP_CALL( SCIPallocBufferArray( scip, & blocksizes, nBlocks ) );
3960  SCIP_CALL( SCIPallocBufferArray( scip, & nvarsblocks, nBlocks ) );
3961  /*
3962  * 3 Scores
3963  *
3964  * - Area percentage (min)
3965  * - block density (max)
3966  * - \pi_b {v_b|v_b is linking}/#vb (min)
3967  */
3968 
3969  /* calculate matrix area */
3970  matrixarea = nVars * nConss;
3971 
3972  blackarea += (unsigned long) ( getNLinkingvars() + getNTotalStairlinkingvars() ) * (unsigned long) getNConss();
3973  blackarea += (unsigned long) getNMasterconss() * ( (unsigned long) getNVars() - ( getNLinkingvars() + getNTotalStairlinkingvars() ) ) ;
3974 
3975  //std::cout << " black area without blocks is " << "(" << getNLinkingvars() << " + " << getNTotalStairlinkingvars() << " ) * " << getNConss() << " + " << getNMasterconss() << " * ( " << getNVars() << " - ( " << getNLinkingvars() << " + " << getNTotalStairlinkingvars() << " ) ) "
3976  // << " = " << blackarea << std::endl;
3977 
3978  if( sctype == SCORETYPE::MAX_WHITE)
3979  {
3980  for( i = 0; i < nBlocks; ++ i )
3981  {
3982  blackarea += (unsigned long) getNConssForBlock( i ) * ( (unsigned long) getNVarsForBlock( i ) );
3983  }
3984  }
3985 
3986  if( sctype != SCORETYPE::MAX_WHITE)
3987  {
3988  /* calculate slave sizes, nonzeros and linkingvars */
3989  for( i = 0; i < nBlocks; ++ i )
3990  {
3991  int ncurconss;
3992  int nvarsblock;
3993  SCIP_Bool *ishandled;
3994 
3995  SCIP_CALL( SCIPallocBufferArray( scip, & ishandled, nVars ) );
3996  nvarsblock = 0;
3997  nzblocks[i] = 0;
3998  nlinkvarsblocks[i] = 0;
3999 
4000  // std::cout << "blackarea = " << blackarea << " + " << getNConssForBlock( i ) << " * " << getNVarsForBlock( i ) << " = " << getNConssForBlock( i ) * ( getNVarsForBlock( i ) );
4001 
4002  blackarea += (unsigned long) getNConssForBlock( i ) * ( (unsigned long) getNVarsForBlock( i ) );
4003  // std::cout << " = " << blackarea << std::endl;
4004 
4005  for( j = 0; j < nVars; ++ j )
4006  {
4007  ishandled[j] = FALSE;
4008  }
4009  ncurconss = getNConssForBlock( i );
4010 
4011  for( j = 0; j < ncurconss; ++ j )
4012  {
4013  int cons = getConssForBlock( i )[j];
4014  int ncurvars;
4015  ncurvars = seeedpool->getNVarsForCons( cons );
4016  for( k = 0; k < ncurvars; ++ k )
4017  {
4018  int var = seeedpool->getVarsForCons( cons )[k];
4019  int block = -3;
4020  if( isVarBlockvarOfBlock( var, i ) )
4021  block = i + 1;
4022  else if( isVarLinkingvar( var ) || isVarStairlinkingvar( var ) )
4023  block = nBlocks + 2;
4024  else if( isVarMastervar( var ) )
4025  block = nBlocks + 1;
4026 
4027  ++ ( nzblocks[i] );
4028 
4029  if( block == nBlocks + 1 && ishandled[var] == FALSE )
4030  {
4031  ++ ( nlinkvarsblocks[i] );
4032  }
4033  ishandled[var] = TRUE;
4034  }
4035  }
4036 
4037  for( j = 0; j < nVars; ++ j )
4038  {
4039  if( ishandled[j] )
4040  {
4041  ++ nvarsblock;
4042  }
4043  }
4044 
4045  blocksizes[i] = nvarsblock * ncurconss;
4046  nvarsblocks[i] = nvarsblock;
4047  if( blocksizes[i] > 0 )
4048  {
4049  blockdensities[i] = 1.0 * nzblocks[i] / blocksizes[i];
4050  }
4051  else
4052  {
4053  blockdensities[i] = 0.0;
4054  }
4055 
4056  assert( blockdensities[i] >= 0 && blockdensities[i] <= 1.0 );
4057  SCIPfreeBufferArray( scip, & ishandled );
4058  }
4059  }
4060 
4061  borderarea = getNMasterconss() * nVars
4063 
4064  maxwhitescore = 1. - ( (SCIP_Real) blackarea / (SCIP_Real) ( (unsigned long) getNConss() * (unsigned long) getNVars() ) );
4065 // std::cout << "black area ration = " << blackarea << "/ ( " << getNConss() << " * " << getNVars() << " = " << ( (unsigned long) getNConss() * (unsigned long) getNVars() ) << ") = " << maxwhitescore << std::endl;
4066 
4067  //std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! this seeed has a black area ratio of " << maxwhitescore << std::endl;
4068 
4069  density = 1E20;
4070  varratio = 1.0;
4071  linkingscore = 1.;
4072  borderscore = 1.;
4073  densityscore = 1.;
4074 
4075  if( sctype != SCORETYPE::MAX_WHITE )
4076  {
4077  for( i = 0; i < nBlocks; ++ i )
4078  {
4079  density = MIN( density, blockdensities[i] );
4080 
4082  {
4083  varratio *= 1.0 * nlinkvarsblocks[i] / ( getNLinkingvars() + getNMastervars() + getNTotalStairlinkingvars() );
4084  }
4085  else
4086  {
4087  varratio = 0;
4088  }
4089  }
4090  linkingscore = ( 0.5 + 0.5 * varratio );
4091 
4092  densityscore = ( 1 - density );
4093  }
4094 
4095  borderscore = ( 1.0 * ( borderarea ) / matrixarea );
4096  borderareascore = 1. - borderscore;
4097 
4098  DEC_DECTYPE type;
4100  {
4101  type = DEC_DECTYPE_STAIRCASE;
4102  }
4103  else if( getNLinkingvars() > 0 || getNTotalStairlinkingvars() )
4104  {
4105  type = DEC_DECTYPE_ARROWHEAD;
4106  }
4107  else if( getNMasterconss() > 0 )
4108  {
4109  type = DEC_DECTYPE_BORDERED;
4110  }
4111  else if( getNMasterconss() == 0 && getNTotalStairlinkingvars() == 0 )
4112  {
4113  type = DEC_DECTYPE_DIAGONAL;
4114  }
4115  else
4116  {
4117  type = DEC_DECTYPE_UNKNOWN;
4118  }
4119 
4120  switch( type )
4121  {
4122  case DEC_DECTYPE_ARROWHEAD:
4123  totalscore = 1. - (alphaborderarea * ( borderscore ) + alphalinking * ( linkingscore ) + alphadensity * ( densityscore ) );
4124 // score->totalscore = score->borderscore*score->linkingscore*score->densityscore;
4125  break;
4126  case DEC_DECTYPE_BORDERED:
4127  totalscore = 1. - ( alphaborderarea * ( borderscore ) + alphalinking * ( linkingscore ) + alphadensity * ( densityscore ) );
4128 // score->totalscore = score->borderscore*score->linkingscore*score->densityscore;
4129  break;
4130  case DEC_DECTYPE_DIAGONAL:
4131  if( nBlocks == 1 || nBlocks == 0 )
4132  totalscore = 0.0;
4133  else
4134  totalscore = 1.0;
4135  break;
4136  case DEC_DECTYPE_STAIRCASE:
4137  totalscore = 1. - ( alphaborderarea * ( borderscore ) + alphalinking * ( linkingscore ) + 0.2 * ( densityscore ) );
4138  break;
4139  case DEC_DECTYPE_UNKNOWN:
4140  assert (FALSE);
4141  totalscore = 0.0;
4142  break;
4143  default:
4144  SCIPerrorMessage( "No rule for this decomposition type, cannot compute score\n" );
4145  assert( FALSE );
4146  totalscore = 0.0;
4147  break;
4148  }
4149  if( nBlocks == 0 )
4150  totalscore = 0.0;
4151  if( nBlocks == 1 )
4152  totalscore *= 0.25;
4153  if( totalscore > 1 )
4154  totalscore = 1;
4155 
4156 
4157  SCIPfreeBufferArray( scip, & nvarsblocks );
4158  SCIPfreeBufferArray( scip, & blocksizes );
4159  SCIPfreeBufferArray( scip, & blockdensities );
4160  SCIPfreeBufferArray( scip, & nlinkvarsblocks );
4161  SCIPfreeBufferArray( scip, & nzblocks );
4162  score = totalscore;
4163 
4164  return getScore(sctype);
4165 
4166 }
4167 
4168 
4173 )
4174 {
4175  SCIP_Bool hassetpartmaster;
4176  SCIP_Bool verbose;
4177  hassetpartmaster = TRUE;
4178  verbose = FALSE;
4179 
4180 
4181 
4183  return FALSE;
4184 
4185  for( int l = 0; l < getNMasterconss(); ++l )
4186  {
4187  int consid = getMasterconss()[l];
4188  if( !seeedpool->isConsSetppc(consid) && !seeedpool->isConsCardinalityCons(consid) )
4189  {
4190  hassetpartmaster = FALSE;
4191  if( verbose )
4192  std::cout << " cons with name " << SCIPconsGetName( seeedpool->getConsForIndex(consid) ) << " is no setppccard constraint." << std::endl;
4193  break;
4194  }
4195  }
4196 
4197  return hassetpartmaster;
4198 }
4199 
4200 
4205 )
4206 {
4207  SCIP_Bool hassetpartmaster;
4208  hassetpartmaster = TRUE;
4209 
4211  return FALSE;
4212 
4213 
4214  for( int l = 0; l < getNMasterconss(); ++l )
4215  {
4216  int consid = getMasterconss()[l];
4217  if( !seeedpool->isConsSetppc(consid) )
4218  {
4219  hassetpartmaster = FALSE;
4220  break;
4221  }
4222  }
4223  return hassetpartmaster;
4224 }
4225 
4226 
4231 )
4232 {
4233  SCIP_Bool hassetpartmaster;
4234  hassetpartmaster = TRUE;
4235 
4237  return FALSE;
4238 
4239  for( int l = 0; l < getNMasterconss(); ++l )
4240  {
4241  int consid = getMasterconss()[l];
4242  if( !seeedpool->isConsSetpp(consid) )
4243  {
4244  hassetpartmaster = FALSE;
4245  break;
4246  }
4247  }
4248  return hassetpartmaster;
4249 }
4250 
4251 
4252 
4253 
4258  SCIP_HASHMAP* constoblock,
4259  int givenNBlocks
4260  )
4261 {
4262  assert( givenNBlocks >= 0 );
4263  assert( nBlocks == 0 );
4264  assert( (int) conssForBlocks.size() == nBlocks );
4265  assert( (int) varsForBlocks.size() == nBlocks );
4266  assert( (int) stairlinkingVars.size() == nBlocks );
4267  assert( ! alreadyAssignedConssToBlocks() );
4268  nBlocks = givenNBlocks;
4269  nVars = seeedpool->getNVars();
4270  nConss = seeedpool->getNConss();
4271  int consnum;
4272  int consblock;
4273 
4274  changedHashvalue = true;
4275 
4276  for( int i = 0; i < nConss; ++ i )
4277  {
4278  consnum = i;
4279  consblock = ( (int) (size_t) SCIPhashmapGetImage( constoblock, (void*) (size_t) i ) ) - 1;
4280  assert( consblock >= 0 && consblock <= nBlocks );
4281  if( consblock == nBlocks )
4282  {
4283  setConsToMaster( consnum );
4284  deleteOpencons( consnum );
4285  }
4286  }
4287 
4288  nBlocks = 0;
4289  sort();
4290 
4291  assert( checkConsistency( ) );
4292 
4293  return SCIP_OKAY;
4294 }
4295 
4301  SCIP_HASHMAP* constoblock,
4302  int givenNBlocks
4303  )
4304 {
4305  assert( givenNBlocks >= 0 );
4306  assert( nBlocks == 0 );
4307  assert( (int) conssForBlocks.size() == nBlocks );
4308  assert( (int) varsForBlocks.size() == nBlocks );
4309  assert( (int) stairlinkingVars.size() == nBlocks );
4310  assert( ! alreadyAssignedConssToBlocks() );
4311  nBlocks = givenNBlocks;
4312  nVars = seeedpool->getNVars();
4313  nConss = seeedpool->getNConss();
4314  int consnum;
4315  int consblock;
4316  int varnum;
4317  bool varInBlock;
4318  std::vector<int> varInBlocks = std::vector<int>( 0 );
4319  std::vector<int> emptyVector = std::vector<int>( 0 );
4320 
4321  changedHashvalue = true;
4322 
4323  for( int c = 0; c < nConss; ++ c )
4324  {
4325  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "%d\n", c);
4326  assert( SCIPhashmapExists( constoblock, (void*) (size_t) c ) );
4327  assert( (int) (size_t) SCIPhashmapGetImage( constoblock, (void*) (size_t) c ) - 1 <= nBlocks );
4328  assert( (int) (size_t) SCIPhashmapGetImage( constoblock, (void*) (size_t) c ) - 1 >= 0 );
4329  }
4330 
4331  for( int b = (int) conssForBlocks.size(); b < nBlocks; b ++ )
4332  conssForBlocks.push_back( emptyVector );
4333 
4334  for( int b = (int) varsForBlocks.size(); b < nBlocks; b ++ )
4335  varsForBlocks.push_back( emptyVector );
4336 
4337  for( int b = (int) stairlinkingVars.size(); b < nBlocks; b ++ )
4338  stairlinkingVars.push_back( emptyVector );
4339 
4340  for( int i = 0; i < nConss; ++ i )
4341  {
4342  consnum = i;
4343  consblock = ( (int) (size_t) SCIPhashmapGetImage( constoblock, (void*) (size_t) i ) ) - 1;
4344  assert( consblock >= 0 && consblock <= nBlocks );
4345  if( consblock == nBlocks )
4346  setConsToMaster( consnum );
4347  else
4348  setConsToBlock( consnum, consblock );
4349  }
4350 
4351  for( int i = 0; i < nVars; ++ i )
4352  {
4353  varInBlocks.clear();
4354  varnum = i;
4355 
4357  for( int b = 0; b < nBlocks; ++ b )
4358  {
4359  varInBlock = false;
4360  for( size_t k = 0; k < conssForBlocks[b].size() && ! varInBlock; ++ k )
4361  {
4362  for( int l = 0; l < seeedpool->getNVarsForCons( conssForBlocks[b][k] ) && ! varInBlock; ++ l )
4363  {
4364  if( varnum == ( seeedpool->getVarsForCons( conssForBlocks[b][k] ) )[l] )
4365  {
4366  varInBlocks.push_back( b );
4367  varInBlock = true;
4368  }
4369  }
4370  }
4371  }
4372  if( varInBlocks.size() == 1 )
4373  setVarToBlock( varnum, varInBlocks[0] );
4374  else if( varInBlocks.size() == 2 )
4375  {
4376  if( varInBlocks[0] + 1 == varInBlocks[1] )
4377  setVarToStairlinking( varnum, varInBlocks[0], varInBlocks[1] );
4378  else
4379  setVarToLinking( varnum );
4380  }
4381  else if( varInBlocks.size() > 2 )
4382  setVarToLinking( varnum );
4383  else
4384  assert( varInBlocks.size() == 0 );
4385  setVarToMaster( varnum );
4386  }
4387  sort();
4388  openVars = std::vector<int>( 0 );
4389  openConss = std::vector<int>( 0 );
4390  isvaropen = std::vector<bool>(nVars, false);
4391  isconsopen = std::vector<bool>(nConss, false);
4392 
4393  deleteEmptyBlocks(false);
4394  sort();
4395  assert( checkConsistency( ) );
4396 
4397  return SCIP_OKAY;
4398 }
4399 
4402  )
4403 {
4404  int i;
4405  int j;
4406  const int* varcons;
4407  bool isMasterVar;
4408  const int* lvars = getLinkingvars();
4409  std::vector<int> foundMasterVarIndices;
4410 
4411  changedHashvalue = true;
4412 
4413  // sort Master constraints for binary search
4414  sort();
4415 
4416  for( i = 0; i < getNLinkingvars(); ++ i )
4417  {
4418  isMasterVar = true;
4419  varcons = seeedpool->getConssForVar( lvars[i] );
4420  for( j = 0; j < seeedpool->getNConssForVar( lvars[i] ); ++ j )
4421  {
4422  if( ! isconsmaster[varcons[j]] )
4423  {
4424  isMasterVar = false;
4425  break;
4426  }
4427  }
4428 
4429  if( isMasterVar )
4430  {
4431  foundMasterVarIndices.push_back( i );
4432  }
4433  }
4434 
4435  for( std::vector<int>::reverse_iterator it = foundMasterVarIndices.rbegin(); it != foundMasterVarIndices.rend(); ++ it )
4436  {
4437  masterVars.push_back( lvars[ * it] );
4438  mastervarssorted = false;
4439  isvarmaster[lvars[ * it]] = true;
4440  linkingVars.erase( linkingVars.begin() + * it );
4441  }
4442 
4443  return SCIP_OKAY;
4444 }
4445 
4448  )
4449 {
4450  int i;
4451  int j;
4452  int k;
4453 
4454  int consblock;
4455  int block1 = - 1;
4456  int block2 = - 1;
4457 
4458  const int* varcons;
4459  const int* lvars = getLinkingvars();
4460 
4461  std::vector<int> foundMasterVarIndices;
4462 
4463  sort();
4464 
4465  for( i = 0; i < getNLinkingvars(); ++ i )
4466  {
4467  block1 = - 1;
4468  block2 = - 1;
4469  varcons = seeedpool->getConssForVar( lvars[i] );
4470  for( j = 0; j < seeedpool->getNConssForVar( lvars[i] ); ++ j )
4471  {
4472  consblock = - 1;
4473  for( k = 0; k < nBlocks; ++ k )
4474  {
4475  if( std::binary_search( conssForBlocks[k].begin(), conssForBlocks[k].end(), varcons[j] ) )
4476  {
4477  consblock = k;
4478  break;
4479  }
4480  }
4481 
4482  if( consblock == - 1 )
4483  {
4484  block1 = - 1;
4485  block2 = - 1;
4486  break;
4487  }
4488  else if( block1 == consblock || block2 == consblock )
4489  {
4490  continue;
4491  }
4492  else if( block1 == - 1 )
4493  {
4494  block1 = consblock;
4495  continue;
4496  }
4497  else if( block2 == - 1 )
4498  {
4499  block2 = consblock;
4500  continue;
4501  }
4502  else
4503  {
4504  block1 = - 1;
4505  block2 = - 1;
4506  break;
4507  }
4508  }
4509 
4510  if( block1 != - 1 && block2 != - 1 && ( block1 == block2 + 1 || block1 + 1 == block2 ) )
4511  {
4512 // std::cout << "Var " << lvars[i] << " hits block " << block1 << " and " << block2 << "\n";
4513 
4514  setVarToStairlinking( lvars[i], block1, block2 );
4515  foundMasterVarIndices.push_back( i );
4516  }
4517  }
4518 
4519  for( std::vector<int>::reverse_iterator it = foundMasterVarIndices.rbegin(); it != foundMasterVarIndices.rend(); ++ it )
4520  {
4521  linkingVars.erase( linkingVars.begin() + * it );
4522  }
4523 
4524  return SCIP_OKAY;
4525 }
4526 
4529 std::vector< std::pair< int, std::vector< int > > > Seeed::findLinkingVarsPotentiallyStairlinking(
4530  )
4531 {
4532  std::vector< std::pair< int, std::vector< int > > > blocksOfVars( 0 );
4533  const int* varcons;
4534  const int* lvars;
4535  int blockcounter;
4536 
4537  /* if there is at least one linking variable, then the blocks of vars must be created. */
4538  if( getNLinkingvars() > 0 )
4539  {
4540  lvars = getLinkingvars();
4541  sort();
4542 
4543  /* check every linking var */
4544  for ( int v = 0; v < getNLinkingvars(); ++v )
4545  {
4546  std::vector< int > blocksOfVar( 0 );
4547  blockcounter = 0;
4548 
4549  varcons = seeedpool->getConssForVar( lvars[v] );
4550 
4551  /* find all blocks that are hit by this linking var */
4552  for ( int c = 0; c < seeedpool->getNConssForVar( lvars[v] ) && blockcounter <= 2; ++c )
4553  {
4554  for ( int b = 0; b < nBlocks && blockcounter <= 2; ++b )
4555  {
4556  if ( std::binary_search( conssForBlocks[b].begin(),
4557  conssForBlocks[b].end(), varcons[c] ) )
4558  {
4559  /* if the hit block is new, add it to blockOfVar vector */
4560  if ( std::find( blocksOfVar.begin(), blocksOfVar.end(), b ) == blocksOfVar.end() )
4561  {
4562  //std::cout << "Var " << lvars[v] << " hits block " << b << "\n" ;
4563  ++blockcounter;
4564  blocksOfVar.push_back( b );
4565  }
4566  }
4567  }
4568  }
4569 
4570  /* if the var hits exactly two blocks, it is potentially stairlinking */
4571  if ( blockcounter == 2 )
4572  {
4573  std::pair< int, std::vector< int > > pair( v, blocksOfVar );
4574  blocksOfVars.push_back( pair );
4575  }
4576  }
4577  }
4578 
4579  return blocksOfVars;
4580 }
4581 
4583 SCIP_RETCODE Seeed::flushBooked()
4584 {
4585  std::vector<int>::const_iterator bookedIter;
4586  std::vector<int>::const_iterator bookedIterEnd;
4587  std::vector<std::pair<int, int>>::iterator bookedIter2;
4588  std::vector<std::pair<int, int>>::iterator bookedIterEnd2;
4589 
4590  std::vector < SCIP_Bool > varislinking( getNVars(), FALSE );
4591 
4592  changedHashvalue = true;
4593 
4594  bookedIter = bookedAsMasterConss.begin();
4595  bookedIterEnd = bookedAsMasterConss.end();
4596  for( ; bookedIter != bookedIterEnd; ++ bookedIter )
4597  {
4598  setConsToMaster( * bookedIter );
4599  deleteOpencons( * bookedIter );
4600  }
4601  bookedAsMasterConss.clear();
4602 
4603  bookedIter2 = bookedAsBlockConss.begin();
4604  bookedIterEnd2 = bookedAsBlockConss.end();
4605  for( ; bookedIter2 != bookedIterEnd2; ++ bookedIter2 )
4606  {
4607  setConsToBlock( ( * bookedIter2 ).first, ( * bookedIter2 ).second );
4608  deleteOpencons( ( * bookedIter2 ).first );
4609  }
4610  bookedAsBlockConss.clear();
4611 
4612  bookedIter = bookedAsLinkingVars.begin();
4613  bookedIterEnd = bookedAsLinkingVars.end();
4614  for( ; bookedIter != bookedIterEnd; ++ bookedIter )
4615  {
4616  varislinking[ * bookedIter] = TRUE;
4617  setVarToLinking( * bookedIter );
4618  deleteOpenvar( * bookedIter );
4619  }
4620  bookedAsLinkingVars.clear();
4621 
4622  bookedIter = bookedAsMasterVars.begin();
4623  bookedIterEnd = bookedAsMasterVars.end();
4624 
4625  for( ; bookedIter != bookedIterEnd; ++ bookedIter )
4626  {
4627  setVarToMaster( * bookedIter );
4628  deleteOpenvar( * bookedIter );
4629  }
4630  bookedAsMasterVars.clear();
4631 
4632  bookedIter2 = bookedAsBlockVars.begin();
4633  bookedIterEnd2 = bookedAsBlockVars.end();
4634  for( ; bookedIter2 != bookedIterEnd2; ++ bookedIter2 )
4635  {
4636  if( varislinking[( * bookedIter2 ).first] )
4637  continue;
4638  setVarToBlock( ( * bookedIter2 ).first, ( * bookedIter2 ).second );
4639  deleteOpenvar( ( * bookedIter2 ).first );
4640  }
4641  bookedAsBlockVars.clear();
4642 
4643  bookedIter2 = bookedAsStairlinkingVars.begin();
4644  bookedIterEnd2 = bookedAsStairlinkingVars.end();
4645  for( ; bookedIter2 != bookedIterEnd2; ++ bookedIter2 )
4646  {
4647  setVarToStairlinking( ( * bookedIter2 ).first, ( * bookedIter2 ).second, ( * bookedIter2 ).second + 1 );
4648  deleteOpenvar( ( * bookedIter2 ).first );
4649  }
4650  bookedAsStairlinkingVars.clear();
4651 
4652  sort();
4653 
4654  return SCIP_OKAY;
4655 }
4656 
4659  int ancestorindex
4660  )
4661 {
4662  assert( 0 <= ancestorindex && ancestorindex < (int) listofancestorids.size() );
4663 
4664  return listofancestorids[ancestorindex];
4665 }
4666 
4667 
4669 std::vector<int> Seeed::getAncestorList(
4670  )
4671 {
4672  return listofancestorids;
4673 }
4674 
4675 const std::vector<int> & Seeed::getBlocksForRep(int repid)
4676 {
4677  return reptoblocks[repid];
4678 }
4679 
4680 
4683  std::vector<int> newlist
4684  )
4685 {
4686  listofancestorids = newlist ;
4687 }
4688 
4689 
4690 
4693  int ancestor
4694  )
4695 {
4696  assert( 0 <= ancestor );
4697  listofancestorids.push_back(ancestor);
4698 }
4699 
4700 
4703 {
4704  return detectorchainstring;
4705 }
4706 
4709  int detectorchainindex
4710  )
4711 {
4712  assert( 0 <= detectorchainindex && detectorchainindex < (int) detectorchaininfo.size() );
4713 
4714  return detectorchaininfo[detectorchainindex];
4715 }
4716 
4719  int detectorchainindex
4720  )
4721 {
4722  assert( 0 <= detectorchainindex && detectorchainindex < (int) detectorClockTimes.size() );
4723 
4724  return detectorClockTimes[ detectorchainindex ];
4725 }
4726 
4728 std::vector<SCIP_Real> Seeed::getDetectorClockTimes()
4729 {
4730  return detectorClockTimes;
4731 }
4732 
4733 
4735  ){
4736 
4737  std::stringstream buf;
4738 
4739  int minrow = getNConss();
4740  int maxrow = 0;
4741  SCIP_Real medianrow = 0.;
4742  SCIP_Real meanrow = 0.;
4743  std::vector<int> nrows(getNBlocks(), 0);
4744 
4745  int ntotalcols = getNVars();
4746  int ntotalrows = seeedpool->getNTotalConss();
4747 
4748  int minvar = getNVars();
4749  int maxvar = 0;
4750  SCIP_Real medianvar = 0;
4751  SCIP_Real meanvar = 0.;
4752  std::vector<int> ncols(getNBlocks(), 0);
4753 
4754  for( int b = 0; b < getNBlocks(); ++b )
4755  {
4756  for( int c = 0; c < getNConssForBlock(b); ++c )
4757  {
4758  int cons = getConssForBlock(b)[c];
4759  SCIP_Cons* scipcons = seeedpool->getScipCons(cons);
4760 
4761  nrows[b] += GCGconsIsRanged(scip, scipcons) ? 2 : 1;
4762  meanrow += GCGconsIsRanged(scip, scipcons) ? 2 : 1;
4763  }
4764 
4765  for( int v = 0; v < getNVarsForBlock(b); ++v )
4766  {
4767  ncols[b]++;
4768  meanvar += 1;
4769  }
4770  }
4771 
4772  std::sort(nrows.begin(), nrows.end());
4773  std::sort(ncols.begin(), ncols.end());
4774 
4775  minrow = nrows[0];
4776  minvar = ncols[0];
4777 
4778  maxrow = nrows[getNBlocks()-1];
4779  maxvar = ncols[getNBlocks()-1];
4780 
4781  meanrow = meanrow / getNBlocks();
4782  meanvar = meanvar / getNBlocks();
4783 
4784  if( getNBlocks() % 2 == 0)
4785  {
4786  medianrow = ( nrows[ getNBlocks() / 2 ] + nrows[ getNBlocks() / 2 - 1 ] ) / 2.;
4787  medianvar = ( ncols[ getNBlocks() / 2 ] + ncols[ getNBlocks() / 2 - 1 ] ) / 2.;
4788  }
4789  else
4790  {
4791  medianrow = nrows[ getNBlocks() / 2 ];
4792  medianvar = ncols[ getNBlocks() / 2 ];
4793  }
4794 
4795  buf << getNBlocks() << ", " << ( (SCIP_Real) minrow ) / ntotalrows << ", " << ( (SCIP_Real) maxrow ) / ntotalrows << ", ";
4796  buf << ( (SCIP_Real) medianrow ) / ntotalrows << ", " << ( (SCIP_Real) meanrow ) / ntotalrows << ", ";
4797 
4798  buf << ( (SCIP_Real) minvar ) / ntotalcols << ", " << ( (SCIP_Real) maxvar ) / ntotalcols << ", ";
4799  buf << ( (SCIP_Real) medianvar ) / ntotalcols << ", " << ( (SCIP_Real) meanvar ) / ntotalcols << " ";
4800 
4801 
4802  return buf.str();
4803 }
4804 
4807  int detectorchainindex,
4808  ConsClassifier** classifier,
4809  std::vector<int>& consclassesmaster
4810  )
4811 {
4812  assert( consClassifierUsed( detectorchainindex ) );
4813 
4814  *classifier = dynamic_cast<ConsClassifier*>( usedClassifier[detectorchainindex] );
4815  consclassesmaster = classesToMaster[detectorchainindex];
4816 
4817  return SCIP_OKAY;
4818 }
4819 
4822  std::vector<SCIP_Real> newvector)
4823 {
4824  detectorClockTimes = newvector;
4825 }
4826 
4829  int detectorchainindex
4830  )
4831 {
4832  assert( 0 <= detectorchainindex && detectorchainindex < (int) usedClassifier.size() );
4833 
4834  return ( usedClassifier[detectorchainindex] != NULL )
4835  && ( dynamic_cast<VarClassifier*>( usedClassifier[detectorchainindex] ) != NULL );
4836 }
4837 
4838 
4841  int block
4842  )
4843 {
4844  assert( block >= 0 && block < nBlocks );
4845  return & conssForBlocks[block][0];
4846 }
4847 
4850 {
4851  return & detectorChain[0];
4852 }
4853 
4855 std::vector<DEC_DETECTOR*> Seeed::getDetectorchainVector()
4856 {
4857  return detectorChain;
4858 }
4859 
4862  int detectorchainindex
4863  )
4864 {
4865  std::stringstream output;
4866 
4867  if( (int) getDetectorClockTimes().size() > detectorchainindex )
4868  output << " Detection time: " << getDetectorClockTime( detectorchainindex ) << std::endl;
4869  if( (int) getPctConssFromFreeVector().size() > detectorchainindex )
4870  output << " % newly assigned constraints: " << getPctConssFromFree( detectorchainindex ) << std::endl;
4871  if( (int) getPctConssToBorderVector().size() > detectorchainindex )
4872  output << " % constraints the detector assigned to border: " << getPctConssToBorder( detectorchainindex ) << std::endl;
4873  if( (int) getPctConssToBlockVector().size() > detectorchainindex )
4874  output << " % constraints the detector assigned to blocks: " << getPctConssToBlock( detectorchainindex ) << std::endl;
4875  if( (int) getPctVarsFromFreeVector().size() > detectorchainindex )
4876  output << " % newly assigned variables: " << getPctVarsFromFree( detectorchainindex ) << std::endl;
4877  if( (int) getPctVarsToBorderVector().size() > detectorchainindex )
4878  output << " % variables the detector assigned to border: " << getPctVarsToBorder( detectorchainindex ) << std::endl;
4879  if( (int) getPctVarsToBlockVector().size() > detectorchainindex )
4880  output << " % variables the detector assigned to blocks: " << getPctVarsToBlock( detectorchainindex ) << std::endl;
4881  if( (int) getNNewBlocksVector().size() > detectorchainindex )
4882  output << " New blocks: " << getNNewBlocks( detectorchainindex ) << std::endl;
4883 
4884  return output.str();
4885 }
4886 
4889  int detectorchainindex,
4890  bool displayConssVars
4891  )
4892 {
4893  std::stringstream output;
4894 
4895  if( consClassifierUsed( detectorchainindex ) )
4896  {
4897  ConsClassifier* classifier;
4898  std::vector<int> constomaster;
4899 
4900  getConsClassifierData( detectorchainindex, &classifier, constomaster );
4901 
4902  output << " Used consclassifier: " << classifier->getName() << std::endl;
4903  output << " Pushed to master:";
4904 
4905  if( constomaster.size() > 0 )
4906  {
4907  if( displayConssVars )
4908  {
4909  output << std::endl << " " << classifier->getClassName( constomaster[0] ) << " ("
4910  << classifier->getClassDescription( constomaster[0] ) << "): ";
4911  bool first = true;
4912  for( int c = 0; c < classifier->getNConss(); ++c )
4913  {
4914  if( classifier->getClassOfCons( c ) == constomaster[0] )
4915  {
4916  if( first )
4917  {
4918  output << SCIPconsGetName( seeedpool->getConsForIndex( c ) );
4919  first = false;
4920  }
4921  else
4922  {
4923  output << ", " << SCIPconsGetName( seeedpool->getConsForIndex( c ) );
4924  }
4925  }
4926  }
4927  output << std::endl;
4928  }
4929  else
4930  {
4931  output << " " << classifier->getClassName( constomaster[0] );
4932  }
4933  }
4934 
4935  for( size_t i = 1; i < constomaster.size(); ++i )
4936  {
4937  if( displayConssVars )
4938  {
4939  output << " " << classifier->getClassName( constomaster[i] ) << " ("
4940  << classifier->getClassDescription( constomaster[i] ) << "): ";
4941  bool first = true;
4942  for( int c = 0; c < classifier->getNConss(); ++c )
4943  {
4944  if( classifier->getClassOfCons( c ) == constomaster[i] )
4945  {
4946  if( first )
4947  {
4948  output << SCIPconsGetName( seeedpool->getConsForIndex( c ) );
4949  first = false;
4950  }
4951  else
4952  {
4953  output << ", " << SCIPconsGetName( seeedpool->getConsForIndex( c ) );
4954  }
4955  }
4956  }
4957  output << std::endl;
4958  }
4959  else
4960  {
4961  output << ", " << classifier->getClassName( constomaster[i] );
4962  }
4963  }
4964 
4965  if ( !displayConssVars || constomaster.size() == 0 )
4966  {
4967  output << std::endl;
4968  }
4969  }
4970 
4971  if( varClassifierUsed( detectorchainindex ) )
4972  {
4973  VarClassifier* classifier;
4974  std::vector<int> vartolinking;
4975  std::vector<int> vartomaster;
4976 
4977  getVarClassifierData( detectorchainindex, &classifier, vartolinking, vartomaster );
4978 
4979  output << " Used varclassifier: " << classifier->getName() << std::endl;
4980  output << " Pushed to linking:";
4981 
4982  if( vartolinking.size() > 0 )
4983  {
4984  if( displayConssVars )
4985  {
4986  output << std::endl << " " << classifier->getClassName( vartolinking[0] ) << " ("
4987  << classifier->getClassDescription( vartolinking[0] ) << "): ";
4988  bool first = true;
4989  for( int v = 0; v < classifier->getNVars(); ++v )
4990  {
4991  if( classifier->getClassOfVar( v ) == vartolinking[0] )
4992  {
4993  if( first )
4994  {
4995  output << SCIPvarGetName( seeedpool->getVarForIndex( v ) );
4996  first = false;
4997  }
4998  else
4999  {
5000  output << ", " << SCIPvarGetName( seeedpool->getVarForIndex( v ) );
5001  }
5002  }
5003  }
5004  output << std::endl;
5005  }
5006  else
5007  {
5008  output << " " << classifier->getClassName( vartolinking[0] );
5009  }
5010  }
5011 
5012  for( size_t i = 1; i < vartolinking.size(); ++i )
5013  {
5014  if( displayConssVars )
5015  {
5016  output << " " << classifier->getClassName( vartolinking[i] ) << " ("
5017  << classifier->getClassDescription( vartolinking[i] ) << "): ";
5018  bool first = true;
5019  for( int v = 0; v < classifier->getNVars(); ++v )
5020  {
5021  if( classifier->getClassOfVar( v ) == vartolinking[i] )
5022  {
5023  if( first )
5024  {
5025  output << SCIPvarGetName( seeedpool->getVarForIndex( v ) );
5026  first = false;
5027  }
5028  else
5029  {
5030  output << ", " << SCIPvarGetName( seeedpool->getVarForIndex( v ) );
5031  }
5032  }
5033  }
5034  output << std::endl;
5035  }
5036  else
5037  {
5038  output << ", " << classifier->getClassName( vartolinking[i] );
5039  }
5040  }
5041 
5042  if ( !displayConssVars || vartolinking.size() == 0 )
5043  {
5044  output << std::endl;
5045  }
5046 
5047  output << " Pushed to master:";
5048 
5049  if( vartomaster.size() > 0 )
5050  {
5051  if( displayConssVars )
5052  {
5053  output << std::endl << " " << classifier->getClassName( vartomaster[0] ) << " ("
5054  << classifier->getClassDescription( vartomaster[0] ) << "): ";
5055  bool first = true;
5056  for( int v = 0; v < classifier->getNVars(); ++v )
5057  {
5058  if( classifier->getClassOfVar( v ) == vartomaster[0] )
5059  {
5060  if( first )
5061  {
5062  output << SCIPvarGetName( seeedpool->getVarForIndex( v ) );
5063  first = false;
5064  }
5065  else
5066  {
5067  output << ", " << SCIPvarGetName( seeedpool->getVarForIndex( v ) );
5068  }
5069  }
5070  }
5071  output << std::endl;
5072  }
5073  else
5074  {
5075  output << " " << classifier->getClassName( vartomaster[0] );
5076  }
5077  }
5078 
5079  for( size_t i = 1; i < vartomaster.size(); ++i )
5080  {
5081  if( displayConssVars )
5082  {
5083  output << " " << classifier->getClassName( vartomaster[i] ) << " ("
5084  << classifier->getClassDescription( vartomaster[i] ) << "): ";
5085  bool first = true;
5086  for( int v = 0; v < classifier->getNVars(); ++v )
5087  {
5088  if( classifier->getClassOfVar( v ) == vartolinking[i] )
5089  {
5090  if( first )
5091  {
5092  output << SCIPvarGetName( seeedpool->getVarForIndex( v ) );
5093  first = false;
5094  }
5095  else
5096  {
5097  output << ", " << SCIPvarGetName( seeedpool->getVarForIndex( v ) );
5098  }
5099  }
5100  }
5101  output << std::endl;
5102  }
5103  else
5104  {
5105  output << ", " << classifier->getClassName( vartomaster[i] );
5106  }
5107  }
5108 
5109  if ( !displayConssVars || vartomaster.size() == 0 )
5110  {
5111  output << std::endl;
5112  }
5113  }
5114 
5115  return output.str();
5116 }
5117 
5120 {
5121  return isFinishedByFinisher;
5122 }
5123 
5126 {
5127  return isFinishedByFinisherUnpresolved;
5128 }
5129 
5132 {
5133  return finishedUnpresolvedBy;
5134 }
5135 
5138 {
5139  if( changedHashvalue )
5140  calcHashvalue();
5141  changedHashvalue = false;
5142  return this->hashvalue;
5143 }
5144 
5147 {
5148  return id;
5149 }
5150 
5153 {
5154  return & linkingVars[0];
5155 }
5156 
5159 {
5160  return & masterConss[0];
5161 }
5162 
5165 {
5166  return & masterVars[0];
5167 }
5168 
5171 {
5172 
5174 }
5175 
5176 
5179 {
5180 
5181  return getScore(SCORETYPE::BENDERS);
5182 }
5183 
5184 
5187  int blockid
5188  ){
5189 
5190  if( !calculatedncoeffsforblock )
5191  calcNCoeffsForBlocks();
5192 
5193  return ncoeffsforblock[blockid];
5194 }
5195 
5196 
5199  ){
5200 
5201  if( !calculatedncoeffsforblock )
5202  calcNCoeffsForBlocks();
5203 
5204  return ncoeffsformaster;
5205 }
5206 
5207 
5210  SCORETYPE type
5211  )
5212 {
5214  for( int mc = 0; mc < getNMasterconss(); ++mc )
5215  {
5216  SCIP_CONS* cons;
5217  cons = getSeeedpool()->getScipCons(getMasterconss()[mc]);
5218  if( GCGconsGetType(cons) == consType::indicator )
5219  return 0.;
5220  }
5221 
5223  if( maxwhitescore == -1. )
5224  calcmaxwhitescore();
5225 
5226  if( type == scoretype::MAX_WHITE )
5227  return maxwhitescore;
5228 
5229  if( type == scoretype::CLASSIC )
5230  {
5231  if ( score == -1. )
5232  SCIP_CALL_ABORT(calcclassicscore() );
5233  return score;
5234  }
5235 
5236  if( type == scoretype::BORDER_AREA )
5237  {
5238  if( borderareascore == -1. )
5239  calcborderareascore();
5240  return borderareascore;
5241  }
5242 
5243  if( type == scoretype::MAX_FORESSEEING_WHITE )
5244  {
5245  if( maxforeseeingwhitescore == -1. )
5246  calcmaxforeseeingwhitescore();
5247  return maxforeseeingwhitescore;
5248  }
5249 
5251  {
5252  if( maxforeseeingwhitescoreagg == -1. )
5253  calcmaxforeseeingwhitescoreagg();
5254  return maxforeseeingwhitescoreagg;
5255  }
5256 
5257  if( type == scoretype::SETPART_FWHITE )
5258  {
5259  if( setpartfwhitescore == -1. )
5260  calcsetpartfwhitescore();
5261  return setpartfwhitescore;
5262  }
5263 
5264  if( type == scoretype::SETPART_AGG_FWHITE )
5265  {
5266  if( setpartfwhitescoreagg == -1. )
5267  calcsetpartfwhitescoreagg();
5268  return setpartfwhitescoreagg;
5269  }
5270 
5271  if( type == scoretype::BENDERS )
5272  {
5273  if( bendersscore == -1. )
5274  calcbendersscore();
5275  return bendersscore;
5276  }
5277 
5278 
5279  return 0;
5280 }
5281 
5284 {
5285  return usergiven;
5286 }
5287 
5290 {
5291  return listofancestorids.size();
5292 }
5293 
5296 {
5297  return nBlocks;
5298 }
5299 
5302 {
5303  return nConss;
5304 }
5305 
5308  int block
5309  )
5310 {
5311  assert( block >= 0 && block < nBlocks );
5312  return (int) conssForBlocks[block].size();
5313 }
5314 
5317 {
5318  return detectorchaininfo.size();
5319 }
5320 
5323 {
5324  if ( usergiven == USERGIVEN::NOT )
5325  return (int) detectorChain.size();
5326  else
5327  return 0;
5328 }
5329 
5332 {
5333  return (int) usedClassifier.size();
5334 }
5335 
5336 
5339 {
5340  return (int) linkingVars.size();
5341 }
5342 
5345  int detectorchainindex
5346  )
5347 {
5348  assert( 0 <= detectorchainindex && detectorchainindex < (int) detectorChain.size() );
5349 
5350  return nNewBlocks[detectorchainindex];
5351 }
5352 
5354 std::vector<int> Seeed::getNNewBlocksVector()
5355 {
5356  return nNewBlocks;
5357 }
5358 
5361  std::vector<int> newvector
5362  )
5363 {
5364  nNewBlocks = newvector;
5365 }
5366 
5367 
5370 {
5371  return (int) masterConss.size();
5372 }
5373 
5376 {
5377  return (int) masterVars.size();
5378 }
5379 
5380 
5383 {
5384  int nstairlinkingvars = 0;
5385  for( int b = 0; b < getNBlocks(); ++ b )
5386  nstairlinkingvars += getNStairlinkingvars( b );
5387 
5388  return nstairlinkingvars;
5389 }
5390 
5393 {
5394  return (int) openConss.size();
5395 }
5396 
5399 {
5400  return (int) openVars.size();
5401 }
5402 
5405 
5406  return nrepblocks;
5407 }
5408 
5411  int block
5412  )
5413 {
5414  assert( block >= 0 && block < nBlocks );
5415  return (int) stairlinkingVars[block].size();
5416 }
5417 
5420 {
5421  return nVars;
5422 }
5423 
5426  int block
5427  )
5428 {
5429  assert( block >= 0 && block < nBlocks );
5430  return (int) varsForBlocks[block].size();
5431 }
5432 
5435 {
5436  return & openConss[0];
5437 }
5438 
5440 std::vector<int> Seeed::getOpenconssVec()
5441 {
5442  return openConss;
5443 }
5444 
5445 
5448 {
5449  return & openVars[0];
5450 }
5451 
5453 std::vector<int> Seeed::getOpenvarsVec()
5454 {
5455  return openVars;
5456 }
5457 
5460  int detectorchainindex
5461  )
5462 {
5463  assert( 0 <= detectorchainindex && detectorchainindex < (int) detectorChain.size() );
5464 
5465  return pctVarsToBorder[detectorchainindex];
5466 }
5467 
5469 std::vector<SCIP_Real> Seeed::getPctVarsToBorderVector()
5470 {
5471  return pctVarsToBorder;
5472 }
5473 
5476  std::vector<SCIP_Real> newvector
5477  )
5478 {
5479  pctVarsToBorder = newvector;
5480 }
5481 
5482 
5483 
5486  int detectorchainindex
5487  )
5488 {
5489  assert( 0 <= detectorchainindex && detectorchainindex < (int) detectorChain.size() );
5490 
5491  return pctVarsToBlock[detectorchainindex];
5492 }
5493 
5495 std::vector<SCIP_Real> Seeed::getPctVarsToBlockVector()
5496 {
5497  return pctVarsToBlock;
5498 }
5499 
5500 
5503  std::vector<SCIP_Real> newvector
5504 )
5505 {
5506  pctVarsToBlock = newvector;
5507 }
5508 
5509 
5510 
5513  int detectorchainindex
5514  )
5515 {
5516  assert( 0 <= detectorchainindex && detectorchainindex < (int) detectorChain.size() );
5517 
5518  return pctVarsFromFree[detectorchainindex];
5519 }
5520 
5522 std::vector<SCIP_Real> Seeed::getPctVarsFromFreeVector()
5523 {
5524  return pctVarsFromFree;
5525 }
5526 
5529  std::vector<SCIP_Real> newvector
5530  )
5531 {
5532  pctVarsFromFree = newvector;
5533 }
5534 
5535 
5538  int detectorchainindex
5539  )
5540 {
5541  assert( 0 <= detectorchainindex && detectorchainindex < (int) detectorChain.size() );
5542 
5543  return pctConssToBorder[detectorchainindex];
5544 }
5545 
5547 std::vector<SCIP_Real> Seeed::getPctConssToBorderVector()
5548 {
5549  return pctConssToBorder;
5550 }
5551 
5554  std::vector<SCIP_Real> newvector
5555  )
5556 {
5557  pctConssToBorder = newvector;
5558 }
5559 
5560 
5563  int detectorchainindex
5564  )
5565 {
5566  assert( 0 <= detectorchainindex && detectorchainindex < (int) detectorChain.size() );
5567 
5568  return pctConssToBlock[detectorchainindex];
5569 }
5570 
5572 std::vector<SCIP_Real> Seeed::getPctConssToBlockVector()
5573 {
5574  return pctConssToBlock;
5575 }
5576 
5579  std::vector<SCIP_Real> newvector )
5580 {
5581  pctConssToBlock = newvector;
5582 }
5583 
5584 
5587  int detectorchainindex
5588  )
5589 {
5590  assert( 0 <= detectorchainindex && detectorchainindex < (int) detectorChain.size() );
5591 
5592  return pctConssFromFree[detectorchainindex];
5593 }
5594 
5596 std::vector<SCIP_Real> Seeed::getPctConssFromFreeVector()
5597 {
5598  return pctConssFromFree;
5599 }
5600 
5603  int blockid
5604  ){
5605  return blockstorep[blockid];
5606 }
5607 
5608 std::vector<int> & Seeed::getRepVarmap(
5609  int repid,
5610  int blockrepid
5611  )
5612 {
5613  return pidtopidvarmaptofirst[repid][blockrepid];
5614 }
5615 
5616 
5619 {
5620  return seeedpool;
5621 }
5622 
5623 
5626  std::vector<SCIP_Real> newvector)
5627 {
5628  pctConssFromFree = newvector;
5629 }
5630 
5631 
5634  int block
5635  )
5636 {
5637  assert( block >= 0 && block < nBlocks );
5638  return & stairlinkingVars[block][0];
5639 }
5640 
5643 {
5644  return stemsFromUnpresolved;
5645 }
5646 
5649  int detectorchainindex,
5650  VarClassifier** classifier,
5651  std::vector<int>& varclasseslinking,
5652  std::vector<int>& varclassesmaster
5653  )
5654 {
5655  assert( varClassifierUsed( detectorchainindex ) );
5656 
5657  *classifier = dynamic_cast<VarClassifier*>( usedClassifier[detectorchainindex] );
5658  varclasseslinking = classesToLinking[detectorchainindex];
5659  varclassesmaster = classesToMaster[detectorchainindex];
5660 
5661  return SCIP_OKAY;
5662 }
5663 
5666  int block
5667  )
5668 {
5669  assert( block >= 0 && block < nBlocks );
5670  return & varsForBlocks[block][0];
5671 }
5672 
5675  int varid,
5676  int block
5677 ){
5678  std::vector<int>::iterator lb = lower_bound( varsForBlocks[block].begin(), varsForBlocks[block].end(), varid );
5679 
5680  if( lb != varsForBlocks[block].end() )
5681  return (int) ( lb - varsForBlocks[block].begin() );
5682  else
5683  return -1;
5684 
5685 }
5686 
5687 
5688 
5692 {
5693  return ( 0 == getNOpenconss() && 0 == getNOpenvars() );
5694 }
5695 
5698  int cons,
5699  int block
5700  )
5701 {
5702  assert( cons >= 0 && cons < nConss );
5703  assert( block >= 0 && block < nBlocks );
5704  std::vector<int>::iterator lb = lower_bound( conssForBlocks[block].begin(), conssForBlocks[block].end(), cons );
5705  if( lb != conssForBlocks[block].end() && *lb == cons )
5706  return true;
5707  else
5708  return false;
5709 }
5710 
5713  int cons
5714  )
5715 {
5716  assert( cons >= 0 && cons < nConss );
5717  return isconsmaster[cons];
5718 }
5719 
5722  int cons
5723  )
5724 {
5725  assert( cons >= 0 && cons < nConss );
5726  return isconsopen[cons];
5727 }
5728 
5731 {
5732  return isfromlegacymode;
5733 }
5734 
5737 {
5738  return isfromunpresolved;
5739 }
5740 
5741 
5742 /* method to check whether this seeed is equal to given other seeed (calls isEqual(Seeed*)) */
5743 SCIP_RETCODE Seeed::isEqual(
5744  Seeed* otherseeed,
5745  SCIP_Bool* isequal,
5746  bool sortseeeds
5747  )
5748 {
5749  if( sortseeeds )
5750  {
5751  sort();
5752  otherseeed->sort();
5753  }
5754 
5755  * isequal = isEqual( otherseeed );
5756 
5757  return SCIP_OKAY;
5758 }
5759 
5760 
5761 /* method to check whether this seeed is equal to given other seeed */
5763  Seeed* other
5764  )
5765 {
5766  if( getNMasterconss() != other->getNMasterconss() || getNMastervars() != other->getNMastervars()
5767  || getNBlocks() != other->getNBlocks() || getNLinkingvars() != other->getNLinkingvars() )
5768  return false;
5769 
5770  if( getHashValue() != other->getHashValue() )
5771  return false;
5772 
5773  std::vector<std::pair<int, int>> blockorderthis = std::vector < std::pair<int, int> > ( 0 );
5774  std::vector<std::pair<int, int>> blockorderother = std::vector < std::pair<int, int> > ( 0 );
5775 
5777  for( int i = 0; i < this->nBlocks; ++ i )
5778  {
5779  blockorderthis.push_back( std::pair<int, int>( i, conssForBlocks[i][0] ) );
5780  blockorderother.push_back( std::pair<int, int>( i, other->conssForBlocks[i][0] ) );
5781  }
5782 
5783  std::sort( blockorderthis.begin(), blockorderthis.end(), compare_blocks );
5784  std::sort( blockorderother.begin(), blockorderother.end(), compare_blocks );
5785 
5787  for( int b = 0; b < getNBlocks(); ++ b )
5788  {
5789  int blockthis = blockorderthis[b].first;
5790  int blockother = blockorderother[b].first;
5791 
5792  if( getNStairlinkingvars( blockthis ) != other->getNStairlinkingvars( blockother ) )
5793  return false;
5794  }
5795 
5797  for( int b = 0; b < getNBlocks(); ++ b )
5798  {
5799  int blockthis = blockorderthis[b].first;
5800  int blockother = blockorderother[b].first;
5801 
5802  if( ( getNVarsForBlock( blockthis ) != other->getNVarsForBlock( blockother ) )
5803  || ( getNConssForBlock( blockthis ) != other->getNConssForBlock( blockother ) ) )
5804  return false;
5805  }
5806 
5808  for( int j = 0; j < getNMasterconss(); ++ j )
5809  {
5810  if( getMasterconss()[j] != other->getMasterconss()[j] )
5811  return false;
5812  }
5813 
5815  for( int j = 0; j < getNMastervars(); ++ j )
5816  {
5817  if( getMastervars()[j] != other->getMastervars()[j] )
5818  return false;
5819  }
5820 
5822  for( int b = 0; b < getNBlocks(); ++ b )
5823  {
5824  int blockthis = blockorderthis[b].first;
5825  int blockother = blockorderother[b].first;
5826 
5827  for( int j = 0; j < getNConssForBlock( blockthis ); ++ j )
5828  {
5829  if( getConssForBlock( blockthis )[j] != other->getConssForBlock( blockother )[j] )
5830  return false;
5831  }
5832 
5833  for( int j = 0; j < getNVarsForBlock( blockthis ); ++ j )
5834  {
5835  if( getVarsForBlock( blockthis )[j] != other->getVarsForBlock( blockother )[j] )
5836  return false;
5837  }
5838 
5839  for( int j = 0; j < getNStairlinkingvars( blockthis ); ++ j )
5840  {
5841  if( getStairlinkingvars( blockthis )[j] != other->getStairlinkingvars( blockother )[j] )
5842  return false;
5843  }
5844  }
5845 
5847  for( int j = 0; j < getNLinkingvars(); ++ j )
5848  {
5849  if( getLinkingvars()[j] != other->getLinkingvars()[j] )
5850  return false;
5851  }
5852 
5853  return true;
5854 }
5855 
5856 
5859  DEC_DETECTOR* detectorID
5860  )
5861 {
5862  std::vector<DEC_DETECTOR*>::const_iterator iter = std::find( detectorChain.begin(), detectorChain.end(), detectorID );
5863 
5864  return iter != detectorChain.end();
5865 }
5866 
5870 {
5871  if( getNBlocks() == 1 && (SCIP_Real) getNConssForBlock( 0 ) >= 0.95 * getNConss() )
5872  return true;
5873 
5874  if( getNConss() == getNMasterconss() )
5875  return true;
5876 
5877  if( getNConss() == getNOpenconss() && getNVars() == getNOpenvars() )
5878  return true;
5879 
5880  if( getNVars() == getNMastervars() + getNLinkingvars() )
5881  return true;
5882 
5883  return false;
5884 }
5885 
5886 
5889 {
5890  return isselected;
5891 }
5892 
5893 
5896  int var,
5897  int block
5898  )
5899 {
5900  assert( var >= 0 && var < nVars );
5901  assert( block >= 0 && block < nConss );
5902 
5903  std::vector<int>::iterator lb = lower_bound( varsForBlocks[block].begin(), varsForBlocks[block].end(), var );
5904  if( lb != varsForBlocks[block].end() && *lb == var )
5905  return true;
5906  else
5907  return false;
5908 }
5909 
5912  int var
5913  )
5914 {
5915  assert( var >= 0 && var < nVars );
5916  return isvarmaster[var];
5917 }
5918 
5921  int var
5922  )
5923 {
5924  assert( var >= 0 && var < nVars );
5925  std::vector<int>::iterator lb = lower_bound( linkingVars.begin(), linkingVars.end(), var );
5926  if( lb != linkingVars.end() && *lb == var )
5927  return true;
5928  else
5929  return false;
5930 }
5931 
5934  int var
5935  )
5936 {
5937  assert( var >= 0 && var < nVars );
5938  return isvaropen[var];
5939 }
5940 
5943  int var
5944  )
5945 {
5946  for( int b = 0; b < nBlocks; ++ b )
5947  {
5948  std::vector<int>::iterator lb = lower_bound( stairlinkingVars[b].begin(), stairlinkingVars[b].end(), var );
5949  if( lb != stairlinkingVars[b].end() && *lb == var )
5950  return true;
5951  }
5952  return false;
5953 }
5954 
5957  int var,
5958  int block
5959  )
5960 {
5961  assert( var >= 0 && var < nVars );
5962  assert( block >= 0 && block < nBlocks );
5963  std::vector<int>::iterator lb = lower_bound( stairlinkingVars[block].begin(), stairlinkingVars[block].end(), var );
5964  if( lb != stairlinkingVars[block].end() && *lb == var )
5965  return true;
5966  else
5967  {
5968  if( block == 0 )
5969  return false;
5970  else
5971  {
5972  lb = lower_bound( stairlinkingVars[block - 1].begin(), stairlinkingVars[block - 1].end(), var );
5973  return ( lb != stairlinkingVars[block-1].end() && *lb == var );
5974  }
5975  }
5976 }
5977 
5978 
5980  SCIP* givenscip,
5981  FILE* file
5982  )
5983 {
5984 
5985  int nusedclassifier = (int) getNUsedClassifier();
5986  int nconsclassifier = 0;
5987  int nvarclassifier = 0;
5988 
5989  //SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%d\n", nusedclassifier );
5990 
5991  for( int classif = 0; classif < nusedclassifier; ++classif)
5992  {
5993  if( usedClassifier[classif] == NULL )
5994  continue;
5995 
5996  if( dynamic_cast<ConsClassifier*>( usedClassifier[classif] ) != NULL )
5997  {
5999  ++nconsclassifier;
6000  }
6001  else
6002  {
6004  ++nvarclassifier;
6005  }
6006  }
6007 
6008  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%d\n", nconsclassifier );
6009 
6010  for( int classif = 0; classif < nusedclassifier; ++classif)
6011  {
6012  if( dynamic_cast<ConsClassifier*>( usedClassifier[classif] ) != NULL )
6013  {
6015  int nmasterclasses = (int) classesToMaster[classif].size();
6016  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%s\n", usedClassifier[classif]->getName() );
6017  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%d\n", nmasterclasses );
6018  for ( int mclass = 0; mclass < (int) classesToMaster[classif].size(); ++mclass )
6019  {
6020  int classid = classesToMaster[classif][mclass];
6021  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%s\n", usedClassifier[classif]->getClassName(classid), usedClassifier[classif]->getClassDescription(classid) );
6022  }
6023  }
6024  }
6025 
6026  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%d\n", nvarclassifier );
6027 
6028  for( int classif = 0; classif < nusedclassifier; ++classif)
6029  {
6030  if( dynamic_cast<VarClassifier*>( usedClassifier[classif] ) != NULL )
6031  {
6033  int nmasterclasses = (int) classesToMaster[classif].size();
6034  int nlinkingclasses = (int) classesToLinking[classif].size();
6035  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%s\n", usedClassifier[classif]->getName() );
6036  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%d\n", nmasterclasses );
6037  for ( int mclass = 0; mclass < (int) classesToMaster[classif].size(); ++mclass )
6038  {
6039  int classid = classesToMaster[classif][mclass];
6040  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%s : %s\n", usedClassifier[classif]->getClassName(classid), usedClassifier[classif]->getClassDescription(classid) );
6041  }
6042 
6043  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%d\n", nlinkingclasses );
6044  for ( int linkingclass = 0; linkingclass < nlinkingclasses; ++linkingclass )
6045  {
6046  int classid = classesToLinking[classif][linkingclass];
6047  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "%s : %s\n", usedClassifier[classif]->getClassName(classid), usedClassifier[classif]->getClassDescription(classid) );
6048  }
6049 
6050  }
6051  }
6052 
6053 
6054  return SCIP_OKAY;
6055 }
6056 
6057 
6061  )
6062 {
6063  bool success = true;
6064 
6065  changedHashvalue = true;
6066 
6067  while( success )
6068  success = assignHittingOpenconss( ) || assignHittingOpenvars( );
6069  sort();
6070  return SCIP_OKAY;
6071 }
6072 
6076  )
6077 {
6078  changedHashvalue = true;
6079 
6080  SCIP_CALL( considerImplicits( ) );
6081  SCIP_CALL( assignOpenPartialHittingToMaster( ) );
6082 
6083  return SCIP_OKAY;
6084 }
6085 
6088  int detectorchainindex,
6089  ConsClassifier* classifier,
6090  std::vector<int> consclassesmaster
6091  )
6092 {
6093  assert( 0 <= detectorchainindex );
6094 
6095  if( detectorchainindex >= (int) usedClassifier.size() )
6096  {
6097  usedClassifier.resize(detectorchainindex + 1);
6098  classesToMaster.resize(detectorchainindex + 1);
6099  }
6100 
6101  usedClassifier[detectorchainindex] = classifier;
6102  classesToMaster[detectorchainindex] = consclassesmaster;
6103 }
6104 
6108  int consToBlock,
6109  int block
6110  )
6111 {
6112  assert( consToBlock >= 0 && consToBlock < nConss );
6113  assert( block >= 0 && block < nBlocks );
6114  assert( (int) conssForBlocks.size() > block );
6115 
6116  changedHashvalue = true;
6117 
6118  conssForBlocks[block].push_back( consToBlock );
6119  conssforblocksorted = false;
6120 
6121  return SCIP_OKAY;
6122 }
6123 
6127  int consToMaster
6128  )
6129 {
6130  assert( consToMaster >= 0 && consToMaster < nConss );
6131  masterConss.push_back( consToMaster );
6132  isconsmaster[consToMaster] = true;
6133  masterconsssorted = false;
6134  changedHashvalue = true;
6135 
6136  return SCIP_OKAY;
6137 }
6138 
6141  std::vector<DEC_DETECTOR*> givenDetectorChain
6142  )
6143 {
6144  detectorChain = givenDetectorChain;
6145 }
6146 
6149  DEC_DETECTOR* detectorID
6150  )
6151 {
6152  detectorChain.push_back( detectorID );
6153  detectorChainFinishingUsed.push_back( FALSE );
6154  addEmptyClassifierStatistics();
6155 
6156  return SCIP_OKAY;
6157 }
6158 
6161  DEC_DETECTOR* detectorID
6162  )
6163 {
6164  isFinishedByFinisher = true;
6165  detectorChain.push_back( detectorID );
6166  detectorChainFinishingUsed.push_back( TRUE );
6167  addEmptyClassifierStatistics();
6168 
6169  return SCIP_OKAY;
6170 }
6171 
6174  bool finished
6175  )
6176 {
6177  isFinishedByFinisher = finished;
6178 }
6179 
6180 
6183  bool finishedByFinisherUnpresolved
6184  )
6185 {
6186  isFinishedByFinisherUnpresolved = finishedByFinisherUnpresolved;
6187 }
6188 
6191  DEC_DETECTOR* detector
6192  )
6193 {
6194  finishedUnpresolvedBy = detector;
6195 }
6196 
6199  bool legacymode
6200  )
6201 {
6202  isfromlegacymode = legacymode;
6203 }
6204 
6206 SCIP_RETCODE Seeed::setNBlocks(
6207  int newNBlocks
6208  )
6209 {
6210  assert( newNBlocks >= nBlocks );
6211 
6212  assert( (int) conssForBlocks.size() == nBlocks );
6213  assert( (int) varsForBlocks.size() == nBlocks );
6214  assert( (int) stairlinkingVars.size() == nBlocks );
6217  changedHashvalue = true;
6218 
6219  for( int b = nBlocks; b < newNBlocks; ++ b )
6220  {
6221  conssForBlocks.push_back( std::vector<int>( 0 ) );
6222  varsForBlocks.push_back( std::vector<int>( 0 ) );
6223  stairlinkingVars.push_back( std::vector<int>( 0 ) );
6224  }
6225 
6226  nBlocks = newNBlocks;
6227 
6228  return SCIP_OKAY;
6229 }
6230 
6232 SCIP_RETCODE Seeed::setID(
6233  int newid
6234  )
6235 {
6236  this->id = newid;
6237  return SCIP_OKAY;
6238 }
6239 
6240 
6243  bool unpresolved
6244  )
6245 {
6246  isfromunpresolved = unpresolved;
6247 }
6248 
6251  bool selected
6252  )
6253 {
6254  isselected = selected;
6255 }
6256 
6257 
6260  Seeedpool* givenseeedpool
6261 ){
6262  this->seeedpool = givenseeedpool;
6263 }
6264 
6265 
6268  bool stemsfromunpresolved
6269  )
6270 {
6271  stemsFromUnpresolved = stemsfromunpresolved;
6272 }
6273 
6276  USERGIVEN givenusergiven
6277  )
6278 {
6279  usergiven = givenusergiven;
6280 }
6281 
6284  int detectorchainindex,
6285  VarClassifier* classifier,
6286  std::vector<int> varclasseslinking,
6287  std::vector<int> varclassesmaster
6288  )
6289 {
6290  assert( 0 <= detectorchainindex );
6291 
6292  if( detectorchainindex >= (int) usedClassifier.size() )
6293  {
6294  usedClassifier.resize(detectorchainindex + 1);
6295  classesToMaster.resize(detectorchainindex + 1);
6296  classesToLinking.resize(detectorchainindex + 1);
6297  }
6298 
6299 
6300  usedClassifier[detectorchainindex] = classifier;
6301  classesToLinking[detectorchainindex] = varclasseslinking;
6302  classesToMaster[detectorchainindex] = varclassesmaster;
6303 }
6304 
6308  int varToBlock,
6309  int block
6310  )
6311 {
6312  assert( varToBlock >= 0 && varToBlock < nVars );
6313  assert( block >= 0 && block < nBlocks );
6314  assert( (int) varsForBlocks.size() > block );
6315 
6316  changedHashvalue = true;
6317 
6318  varsForBlocks[block].push_back( varToBlock );
6319  varsforblocksorted = false;
6320 
6321  return SCIP_OKAY;
6322 }
6323 
6327  int varToLinking
6328  )
6329 {
6330  assert( varToLinking >= 0 && varToLinking < nVars );
6331  linkingVars.push_back( varToLinking );
6332  changedHashvalue = true;
6333  linkingvarssorted = false;
6334 
6335  return SCIP_OKAY;
6336 }
6337 
6341  int varToMaster
6342  )
6343 {
6344  assert( varToMaster >= 0 && varToMaster < nVars );
6345  masterVars.push_back( varToMaster );
6346  isvarmaster[varToMaster] = true;
6347  mastervarssorted = false;
6348  changedHashvalue = true;
6349 
6350  return SCIP_OKAY;
6351 }
6352 
6356  int varToStairlinking,
6357  int block1,
6358  int block2
6359  )
6360 {
6361  assert( varToStairlinking >= 0 && varToStairlinking < nVars );
6362  assert( block1 >= 0 && block1 <= nBlocks );
6363  assert( block2 >= 0 && block2 <= nBlocks );
6364  assert( ( block1 + 1 == block2 ) || ( block2 + 1 == block1 ) );
6365 
6366  changedHashvalue = true;
6367 
6368  if( block1 > block2 )
6369  stairlinkingVars[block2].push_back( varToStairlinking );
6370  else
6371  stairlinkingVars[block1].push_back( varToStairlinking );
6372 
6373  stairlinkingvarsforblocksorted = false;
6374 
6375  return SCIP_OKAY;
6376 }
6377 
6380 {
6381  int returnvalue;
6382 
6383  MiscVisualization* miscvisu = new MiscVisualization();
6384 
6385  /* get names for gp file and output file */
6386  char filename[SCIP_MAXSTRLEN];
6387  char outname[SCIP_MAXSTRLEN];
6388  miscvisu->GCGgetVisualizationFilename(scip, this, ".gp", filename);
6389  miscvisu->GCGgetVisualizationFilename(scip, this, ".pdf", outname);
6390 
6391  /* generate gp file */
6392  GCGwriteGpVisualization( scip, filename, outname, getID() );
6393 
6394  /* compile gp file */
6395  char command[SCIP_MAXSTRLEN];
6396  strcpy(command, "gnuplot ");
6397  strcat(command, filename);
6398  SCIPinfoMessage(seeedpool->getScip(), NULL, "%s\n", command);
6399  returnvalue = system(command);
6400  if( returnvalue == -1 )
6401  SCIPwarningMessage(scip, "Unable to write gnuplot file\n");
6402 
6403  /* open outputfile */
6404  strcpy(command, GCGVisuGetPdfReader());
6405  strcat(command, " ");
6406  strcat(command, outname);
6407  strcat(command, " && rm ");
6408  strcat(command, filename);
6409  SCIPinfoMessage(seeedpool->getScip(), NULL, "%s\n", command);
6410  returnvalue = system(command);
6411  if( returnvalue == -1 )
6412  SCIPwarningMessage(scip, "Unable to open gnuplot file\n");
6413  SCIPinfoMessage(seeedpool->getScip(), NULL, "Please note that the generated pdf file was not deleted automatically! \n", command);
6414 
6415  return;
6416 }
6417 
6420 {
6421  return usergiven == USERGIVEN::COMPLETED_CONSTOMASTER;
6422 }
6423 
6426 {
6427  for( int b = 0; b < nBlocks; ++ b )
6428  {
6429  if( ! varsforblocksorted )
6430  std::sort( varsForBlocks[b].begin(), varsForBlocks[b].end() );
6431  if( ! stairlinkingvarsforblocksorted )
6432  std::sort( stairlinkingVars[b].begin(), stairlinkingVars[b].end() );
6433  if( ! conssforblocksorted )
6434  std::sort( conssForBlocks[b].begin(), conssForBlocks[b].end() );
6435  }
6436  if( ! linkingvarssorted )
6437  std::sort( linkingVars.begin(), linkingVars.end() );
6438  if( !mastervarssorted )
6439  std::sort( masterVars.begin(), masterVars.end() );
6440  if( !masterconsssorted )
6441  std::sort( masterConss.begin(), masterConss.end() );
6442 
6443  varsforblocksorted = true;
6444  stairlinkingvarsforblocksorted = true;
6445  conssforblocksorted = true;
6446  linkingvarssorted = true;
6447  mastervarssorted = true;
6448  masterconsssorted = true;
6449 
6450 }
6451 
6452 
6455 {
6456  static char shortcaption[SCIP_MAXSTRLEN];
6457  if( getNOpenconss() + getNOpenvars() > 0 )
6458  sprintf( shortcaption, "id %d; nB %d; maxW$\\geq$ %.2f ", getID(), getNBlocks(), maxwhitescore );
6459  else
6460  sprintf( shortcaption, "id %d; nB %d; maxW %.2f ", getID(), getNBlocks(), maxwhitescore );
6461 
6462  return shortcaption;
6463 }
6464 
6465 
6468  char* givenDetectorchainstring
6469  )
6470 {
6471  if ( this->detectorchainstring != NULL )
6472  SCIPfreeBlockMemoryArray(scip, & detectorchainstring, SCIP_MAXSTRLEN);
6473  SCIP_CALL( SCIPduplicateBlockMemoryArray( scip, & this->detectorchainstring, givenDetectorchainstring, SCIP_MAXSTRLEN ) );
6474  return SCIP_OKAY;
6475 }
6476 
6483  Seeedpool* origseeedpool,
6484  Seeedpool* transseeedpool,
6485  std::vector<int>* consindex,
6486  std::vector<int>* varindex,
6487  SCIP_Bool fromunpresolvedtopresolved,
6488  SCIP_Bool* success
6489 )
6490 {
6491  SCIP* scip;
6492  int norigconss;
6493  int norigvars;
6494  SCIP_CONS** origconss;
6495  SCIP_VAR** origvars;
6496 
6497  scip = origseeedpool->getScip();
6498  norigconss = SCIPgetNOrigConss(scip);
6499  origconss = SCIPgetOrigConss(scip);
6500  norigvars = SCIPgetNOrigVars(scip);
6501  origvars = SCIPgetOrigVars(scip);
6502 
6503  for( size_t oc = 0; oc < consindex->size(); ++oc )
6504  {
6505  consindex->at(oc) = -1;
6506  }
6507 
6508  for( size_t ov = 0; ov < varindex->size(); ++ov )
6509  {
6510  varindex->at(ov) = -1;
6511  }
6512 
6513  for( int oc = 0; oc < norigconss; ++oc )
6514  {
6515  SCIP_CONS* origcons;
6516  SCIP_CONS* transcons;
6517  int origconsid;
6518  int transconsid;
6519 
6520  origconsid = -1;
6521  transconsid = -1;
6522 
6523  origcons = origconss[oc];
6524  origconsid = origseeedpool->getIndexForCons(origcons);
6525 
6526  SCIPgetTransformedCons(scip, origcons, &transcons);
6527  if( transcons == NULL )
6528  {
6529  // std::cout << "consname: " << SCIPconsGetName(origcons) << " ; oc:" << oc << " has no transformed constraint " << std::endl;
6530  continue;
6531  }
6532  transconsid = transseeedpool->getIndexForCons(transcons);
6533 
6534  // std::cout << "consname: " << SCIPconsGetName(origcons) << " ; oc:" << oc << " ;transconsid: " << transconsid << " ; origconsid: " << origconsid << " transformed: " << origseeedpool->getTransformedInfo() << std::endl;
6535 
6536  if( fromunpresolvedtopresolved )
6537  {
6538  consindex->at(origconsid) = transconsid;
6539  }
6540  else
6541  {
6542  consindex->at(transconsid) = origconsid;
6543  }
6544  }
6545 
6546  for( int ov = 0; ov < norigvars; ++ov )
6547  {
6548  SCIP_VAR* origvar;
6549  SCIP_VAR* transvar;
6550  int origvarid;
6551  int transvarid;
6552 
6553  origvarid = -1;
6554  transvarid = -1;
6555 
6556  origvar = origvars[ov];
6557  origvarid = origseeedpool->getIndexForVar(origvar);
6558  SCIPgetTransformedVar(scip, origvar, &transvar);
6559 
6560  if( transvar == NULL)
6561  {
6562  continue;
6563  }
6564 
6565 
6566  transvarid = transseeedpool->getIndexForVar( SCIPvarGetProbvar(transvar) );
6567 
6568  if( fromunpresolvedtopresolved )
6569  {
6570  varindex->at(origvarid) = transvarid;
6571  }
6572  else
6573  {
6574  varindex->at(transvarid) = origvarid;
6575  }
6576  }
6577 
6578  *success = TRUE;
6579 
6580  return SCIP_OKAY;
6581 
6582 }
6583 
6584 SCIP_RETCODE Seeed::writeAsDec(
6585  FILE* file,
6586  Seeedpool* seeedpooltowriteto,
6587  SCIP_RESULT* result
6588  )
6589 {
6590 
6591  Seeed* helpseeed;
6592  static const char commentchars[] = "\\";
6593 
6594  int nconss;
6595  int nvars;
6596  std::vector<int> consindex(0);
6597  std::vector<int> varindex(0);
6598 
6599  assert(seeedpooltowriteto != NULL);
6600 
6601  helpseeed = this;
6602  nconss = seeedpooltowriteto->getNConss();
6603  nvars = seeedpooltowriteto->getNVars();
6604 
6605  consindex = std::vector<int>(nconss);
6606  varindex = std::vector<int>(nvars);
6607 
6608  /* is there no translation needed ? */
6609  if( getSeeedpool() == seeedpooltowriteto )
6610  {
6611  for( int i = 0; i < nconss; ++i )
6612  consindex[i] = i;
6613  for( int i = 0; i < nvars; ++i )
6614  varindex[i] = i;
6615  }
6616  else
6617  {
6618  SCIP_Bool success;
6619 
6620  Seeed* transseeed;
6621  success = FALSE;
6622 
6623  if( isFromUnpresolved() )
6624  findTranslationForDec(getSeeedpool(), seeedpooltowriteto, &consindex, &varindex, isFromUnpresolved() , &success );
6625  else
6626  findTranslationForDec( seeedpooltowriteto, getSeeedpool(), &consindex, &varindex, isFromUnpresolved() , &success );
6627 
6628  transseeed = new Seeed(seeedpooltowriteto->getScip(), -1, seeedpooltowriteto );
6629 
6631  transseeed->setNBlocks(getNBlocks() );
6632 
6633  for( int b = 0; b < getNBlocks(); ++b )
6634  {
6635  for( int c = 0; c < getNConssForBlock(b); ++c )
6636  {
6637  int cons = consindex[getConssForBlock(b)[c] ];
6638  if( cons == -1 )
6639  continue;
6640  transseeed->bookAsBlockCons(cons, b);
6641  }
6642 
6643  for( int v = 0; v < getNVarsForBlock(b); ++v )
6644  {
6645  int var = varindex[getVarsForBlock(b)[v] ];
6646  if( var == -1 )
6647  continue;
6648  transseeed->bookAsBlockVar(var, b);
6649  }
6650 
6651  for( int v = 0; v < getNStairlinkingvars(b); ++v )
6652  {
6653  int var = varindex[getStairlinkingvars(b)[v] ];
6654  if( var == -1 )
6655  continue;
6656  transseeed->bookAsStairlinkingVar(var, b);
6657  }
6658  }
6659 
6660  for( int c = 0; c < getNMasterconss(); ++c )
6661  {
6662  int cons = consindex[getMasterconss()[c] ];
6663  if( cons == -1 )
6664  continue;
6665  transseeed->bookAsMasterCons(cons);
6666  }
6667 
6668  for( int v = 0; v < getNLinkingvars(); ++v )
6669  {
6670  int var = varindex[getLinkingvars()[v] ];
6671  if( var == -1 )
6672  continue;
6673  transseeed->bookAsLinkingVar(var);
6674  }
6675 
6676  for( int v = 0; v < getNMastervars(); ++v )
6677  {
6678  int var = varindex[getMastervars()[v] ];
6679  if( var == -1 )
6680  continue;
6681  transseeed->bookAsMasterVar(var);
6682  }
6683 
6684  transseeed->flushBooked();
6685 
6686  transseeed->considerImplicits();
6687 
6688  transseeed->deleteEmptyBlocks(false);
6689 
6690  //displayInfo(getSeeedpool(), 0 );
6691 
6692  //transseeed->displayInfo(seeedpooltowriteto, 0 );
6693 
6694  if( transseeed->isComplete() != isComplete() )
6695  success = FALSE;
6696 
6697  if( ! success )
6698  {
6699  if( isFromUnpresolved() )
6700  SCIPwarningMessage(seeedpooltowriteto->getScip(), "Writing dec-file is not possible since translation to presolved (transformed) problem failed. Please consider writing for original problem. Ignore next message about written problem if it is there.\n" );
6701  else
6702  SCIPwarningMessage(seeedpooltowriteto->getScip(), "Writing dec-file is not possible since translation to unpresolved (non-transformed) problem failed. Please consider writing for transformed problem. Ignore next message about written problem if it is there.\n" );
6704  *result = SCIP_SUCCESS;
6705  return SCIP_OKAY;
6706  }
6707  else
6708  *result = SCIP_SUCCESS;
6709 
6710  helpseeed = transseeed;
6711 
6712  }
6713 
6715  /* at first: write meta data of decomposition as comment */
6716  SCIPinfoMessage(scip, file, "%s%s ndetectors \n", commentchars, commentchars );
6717  SCIPinfoMessage(scip, file, "%s%s %d \n", commentchars, commentchars, getNDetectorchainInfo() );
6718 
6719  SCIPinfoMessage(scip, file, "%s%s name time nnewblocks %%ofnewborderconss %%ofnewblockconss %%ofnewlinkingvars %%ofnewblockvars \n", commentchars, commentchars );
6720 
6721  for ( int i = 0; i < getNDetectorchainInfo() ; ++i )
6722  {
6723  SCIPinfoMessage(scip, file, "%s%s %s %f %d %f %f %f %f \n", commentchars, commentchars, DECdetectorGetName(getDetectorchain()[i] ), detectorClockTimes[i],
6724  nNewBlocks[i], pctConssToBorder[i], pctConssToBlock[i], pctVarsToBorder[i],
6725  pctVarsToBlock[i]) ;
6726  }
6727 
6728 
6729  if( !helpseeed->isComplete() )
6730  SCIPinfoMessage(scip, file, "INCOMPLETE\n1\n" );
6731 
6732  if( ( isFromUnpresolved() && seeedpooltowriteto == getSeeedpool() ) || ( !isFromUnpresolved() && seeedpooltowriteto != getSeeedpool() ) )
6733  SCIPinfoMessage(scip, file, "PRESOLVED\n0\n" );
6734  else
6735  SCIPinfoMessage(scip, file, "PRESOLVED\n1\n" );
6736 
6737  SCIPinfoMessage(scip, file, "NBLOCKS\n%d\n", getNBlocks() );
6738 
6739 
6740  for( int b = 0; b < helpseeed->getNBlocks(); ++b )
6741  {
6742  SCIPinfoMessage(scip, file, "BLOCK %d\n", b+1 );
6743  for( size_t c = 0; c < helpseeed->conssForBlocks[b].size(); ++c )
6744  {
6745  SCIPinfoMessage(scip, file, "%s\n", SCIPconsGetName(seeedpooltowriteto->getConsForIndex( helpseeed->conssForBlocks[b][c] )) );
6746  }
6747  }
6748 
6749  SCIPinfoMessage(scip, file, "MASTERCONSS\n" );
6750  for( int mc = 0; mc < helpseeed->getNMasterconss(); ++mc )
6751  {
6752  SCIPinfoMessage(scip, file, "%s\n", SCIPconsGetName(seeedpooltowriteto->getConsForIndex( helpseeed->masterConss[mc])) );
6753  }
6754 
6755  if( helpseeed->isComplete() )
6756  {
6757  if( this != helpseeed )
6758  delete helpseeed;
6759  *result = SCIP_SUCCESS;
6760  return SCIP_OKAY;
6761  }
6762  for( int b = 0; b < helpseeed->getNBlocks(); ++b )
6763  {
6764  SCIPinfoMessage(scip, file, "BLOCKVARS %d\n", b+1 );
6765  for( size_t v = 0; v < helpseeed->varsForBlocks[b].size(); ++v )
6766  {
6767  SCIPinfoMessage(scip, file, "%s\n", SCIPvarGetName(seeedpooltowriteto->getVarForIndex( helpseeed->varsForBlocks[b][v])) );
6768  }
6769  }
6770 
6771  SCIPinfoMessage(scip, file, "LINKINGVARS\n" );
6772  for( int lv = 0; lv < helpseeed->getNLinkingvars(); ++lv )
6773  {
6774  SCIPinfoMessage(scip, file, "%s\n", SCIPvarGetName(seeedpooltowriteto->getVarForIndex( helpseeed->linkingVars[lv])) );
6775  }
6776 
6777  SCIPinfoMessage(scip, file, "MASTERVARS\n" );
6778  for( int mv = 0; mv < helpseeed->getNMastervars(); ++mv )
6779  {
6780  SCIPinfoMessage(scip, file, "%s\n", SCIPvarGetName(seeedpooltowriteto->getVarForIndex( helpseeed->masterVars[mv])) );
6781  }
6782 
6783  if( this != helpseeed )
6784  delete helpseeed;
6785 
6786  *result = SCIP_SUCCESS;
6787 
6788  return SCIP_OKAY;
6789 
6790 }
6791 
6792 
6795 {
6796  char decchaininfo[SCIP_MAXSTRLEN];
6798  SCIPsnprintf( decchaininfo, SCIP_MAXSTRLEN, "" );
6799  if( this->usergiven == USERGIVEN::PARTIAL || this->usergiven == USERGIVEN::COMPLETE
6800  || this->usergiven == USERGIVEN::COMPLETED_CONSTOMASTER || this->getDetectorchain() == NULL
6801  || this->getDetectorchain()[0] == NULL )
6802  {
6803  char str1[2] = "\0"; /* gives {\0, \0} */
6804  str1[0] = 'U';
6805  (void) strncat( decchaininfo, str1, 1 );
6806  }
6807  for( int d = 0; d < this->getNDetectors(); ++ d )
6808  {
6809  if( d == 0 && this->getDetectorchain()[d] == NULL )
6810  continue;
6811  char str[2] = "\0"; /* gives {\0, \0} */
6812  str[0] = DECdetectorGetChar( this->getDetectorchain()[d] );
6813  (void) strncat( decchaininfo, str, 1 );
6814  }
6815 
6816  SCIP_CALL( this->setDetectorChainString( decchaininfo ) );
6817 
6818  return SCIP_OKAY;
6819 }
6820 
6821 void Seeed::calcmaxwhitescore(){
6822 
6823  SCIP_CLOCK* clock;
6824 
6825  SCIP_CALL_ABORT( SCIPcreateClock( seeedpool->getScip(), &clock) );
6826 
6827  SCIP_CALL_ABORT( SCIPstartClock( seeedpool->getScip(), clock) );
6828 
6829  if( blockareascore == -1. )
6830  calcblockareascore();
6831 
6832  if( borderareascore == -1. )
6833  calcborderareascore();
6834 
6836  maxwhitescore = blockareascore + borderareascore - 1.;
6837 
6838 
6839 
6840  if( maxwhitescore < 0. )
6841  maxwhitescore = 0.;
6842 
6843  SCIP_CALL_ABORT(SCIPstopClock( seeedpool->getScip(), clock) );
6844  seeedpool->scorecalculatingtime += SCIPgetClockTime( seeedpool->getScip(), clock);
6845  SCIP_CALL_ABORT(SCIPfreeClock( seeedpool->getScip(), &clock) );
6846 
6847  return;
6848 }
6849 
6850 void Seeed::calcbenderareascore()
6851 {
6852  unsigned long nrelevantconss;
6853  unsigned long nrelevantvars;
6854 
6855  unsigned long nrelevantconss2;
6856  unsigned long nrelevantvars2;
6857 
6858  unsigned long badblockvararea;
6859 
6860 
6861  long benderborderarea;
6862  unsigned long totalarea;
6863 
6864  nrelevantconss = 0;
6865  nrelevantvars = 0;
6866 
6867  nrelevantconss2 = 0;
6868  nrelevantvars2 = 0;
6869 
6870  badblockvararea = 0;
6871 
6872  for( int c = 0; c < getNMasterconss(); ++c )
6873  {
6874  bool relevant = true;
6875  int cons = getMasterconss()[c];
6876  for( int v = 0; v < seeedpool->getNVarsForCons(cons); ++v )
6877  {
6878  int var = seeedpool->getVarsForCons(cons)[v];
6879  if ( isVarOpenvar(var) || isVarMastervar(var) || isVarLinkingvar(var) )
6880  {
6881  relevant = false;
6882  break;
6883  }
6884 
6885  }
6886  if( relevant )
6887  ++nrelevantconss;
6888  }
6889 
6890  for( int b = 0; b < getNBlocks(); ++b )
6891  {
6892  for(int v = 0; v < getNVarsForBlock(b); ++v )
6893  {
6894  bool relevant = true;
6895  int var = getVarsForBlock(b)[v];
6896  for( int c = 0; c < seeedpool->getNConssForVar(var); ++c )
6897  {
6898  int cons = seeedpool->getConssForVar(var)[c];
6899  if( isConsMastercons(cons) || isConsOpencons(cons) )
6900  {
6901  relevant = false;
6902  for( int b2 = 0; b2 < getNBlocks(); ++b2 )
6903  {
6904  if( b2 != b )
6905  badblockvararea += getNConssForBlock(b2);
6906  }
6907  break;
6908  }
6909  }
6910  if( relevant )
6911  ++nrelevantvars;
6912  }
6913  }
6914 
6915  for( int v = 0; v < getNLinkingvars(); ++v )
6916  {
6917  bool relevant = true;
6918  int var = getLinkingvars()[v];
6919  for( int c = 0; c < seeedpool->getNConssForVar(var); ++c )
6920  {
6921  int cons = seeedpool->getConssForVar(var)[c];
6922  if ( isConsOpencons(cons) || isConsMastercons(cons) )
6923  {
6924  relevant = false;
6925  break;
6926  }
6927 
6928  }
6929  if( relevant )
6930  ++nrelevantvars2;
6931  }
6932 
6933 
6934  for( int b = 0; b < getNBlocks(); ++b )
6935  {
6936  for(int c = 0; c < getNConssForBlock(b); ++c )
6937  {
6938  bool relevant = true;
6939  int cons = getConssForBlock(b)[c];
6940  for( int v = 0; v < seeedpool->getNVarsForCons(cons); ++v )
6941  {
6942  int var = seeedpool->getVarsForCons(cons)[v];
6943  if( isVarLinkingvar(var) || isVarOpenvar(var) )
6944  {
6945  relevant = false;
6946  break;
6947  }
6948  }
6949  if( relevant )
6950  ++nrelevantconss2;
6951  }
6952  }
6953 
6954 
6955 
6956  benderborderarea = ( nrelevantconss * nrelevantvars ) + ( nrelevantconss2 * nrelevantvars2 ) - badblockvararea;
6957  totalarea = ( (unsigned long) getNConss() * (unsigned long) getNVars() );
6958  benderareascore = ( SCIP_Real) benderborderarea / totalarea;
6959 
6960 }
6961 
6962 void Seeed::calcbendersscore(){
6963 
6964  SCIP_CLOCK* clock;
6965 
6966  SCIP_CALL_ABORT( SCIPcreateClock( seeedpool->getScip(), &clock) );
6967 
6968  SCIP_CALL_ABORT( SCIPstartClock( seeedpool->getScip(), clock) );
6969 
6970  if( blockareascore == -1. )
6971  calcblockareascore();
6972 
6973  if( benderareascore == -1. )
6974  calcbenderareascore();
6975 
6976  if( borderareascore == -1. )
6977  calcborderareascore();
6978 
6980  bendersscore = blockareascore + benderareascore + borderareascore - 1.;
6981 
6982  if( bendersscore < 0. )
6983  bendersscore = 0.;
6984 
6985  SCIP_CALL_ABORT(SCIPstopClock( seeedpool->getScip(), clock) );
6986  seeedpool->scorecalculatingtime += SCIPgetClockTime( seeedpool->getScip(), clock);
6987  SCIP_CALL_ABORT(SCIPfreeClock( seeedpool->getScip(), &clock) );
6988 
6989  return;
6990 }
6991 
6992 
6993 SCIP_RETCODE Seeed::calcclassicscore()
6994 {
6995  int i;
6996  int j;
6997  int k;
6998 
6999  unsigned long matrixarea;
7000  unsigned long borderarea;
7001  SCIP_Real borderscore;
7002  SCIP_Real densityscore;
7003  SCIP_Real linkingscore;
7004  SCIP_Real totalscore;
7006  SCIP_Real varratio;
7007  int* nzblocks;
7008  int* nlinkvarsblocks;
7009  int* nvarsblocks;
7010  SCIP_Real* blockdensities;
7011  int* blocksizes;
7012  SCIP_Real density;
7013 
7014  SCIP_Real alphaborderarea;
7015  SCIP_Real alphalinking;
7016  SCIP_Real alphadensity;
7017 
7018  SCIP_CLOCK* clock;
7019 
7020  SCIP_CALL_ABORT( SCIPcreateClock( seeedpool->getScip(), &clock) );
7021  SCIP_CALL_ABORT( SCIPstartClock( seeedpool->getScip(), clock) );
7022 
7023 
7024 
7025  SCIP_CALL( SCIPallocBufferArray( scip, & nzblocks, nBlocks ) );
7026  SCIP_CALL( SCIPallocBufferArray( scip, & nlinkvarsblocks, nBlocks ) );
7027  SCIP_CALL( SCIPallocBufferArray( scip, & blockdensities, nBlocks ) );
7028  SCIP_CALL( SCIPallocBufferArray( scip, & blocksizes, nBlocks ) );
7029  SCIP_CALL( SCIPallocBufferArray( scip, & nvarsblocks, nBlocks ) );
7030 
7031  alphaborderarea = 0.6;
7032  alphalinking = 0.2;
7033  alphadensity = 0.2;
7034 
7035 
7036  /*
7037  * 3 Scores
7038  *
7039  * - Area percentage (min)
7040  * - block density (max)
7041  * - \pi_b {v_b|v_b is linking}/#vb (min)
7042  */
7043 
7044  /* calculate slave sizes, nonzeros and linkingvars */
7045  for( i = 0; i < nBlocks; ++ i )
7046  {
7047  int ncurconss;
7048  int nvarsblock;
7049  SCIP_Bool *ishandled;
7050 
7051  SCIP_CALL( SCIPallocBufferArray( scip, & ishandled, nVars ) );
7052  nvarsblock = 0;
7053  nzblocks[i] = 0;
7054  nlinkvarsblocks[i] = 0;
7055 
7056  // std::cout << "blackarea = " << blackarea << " + " << getNConssForBlock( i ) << " * " << getNVarsForBlock( i ) << " = " << getNConssForBlock( i ) * ( getNVarsForBlock( i ) );
7057 
7058  // blackarea += (unsigned long) getNConssForBlock( i ) * ( (unsigned long) getNVarsForBlock( i ) );
7059  // std::cout << " = " << blackarea << std::endl;
7060 
7061  for( j = 0; j < nVars; ++ j )
7062  {
7063  ishandled[j] = FALSE;
7064  }
7065  ncurconss = getNConssForBlock( i );
7066 
7067  for( j = 0; j < ncurconss; ++ j )
7068  {
7069  int cons = getConssForBlock( i )[j];
7070  int ncurvars;
7071  ncurvars = seeedpool->getNVarsForCons( cons );
7072  for( k = 0; k < ncurvars; ++ k )
7073  {
7074  int var = seeedpool->getVarsForCons( cons )[k];
7075  int block = -3;
7076  if( isVarBlockvarOfBlock( var, i ) )
7077  block = i + 1;
7078  else if( isVarLinkingvar( var ) || isVarStairlinkingvar( var ) )
7079  block = nBlocks + 2;
7080  else if( isVarMastervar( var ) )
7081  block = nBlocks + 1;
7082 
7083  ++ ( nzblocks[i] );
7084 
7085  if( block == nBlocks + 1 && ishandled[var] == FALSE )
7086  {
7087  ++ ( nlinkvarsblocks[i] );
7088  }
7089  ishandled[var] = TRUE;
7090  }
7091  }
7092 
7093  for( j = 0; j < nVars; ++ j )
7094  {
7095  if( ishandled[j] )
7096  {
7097  ++ nvarsblock;
7098  }
7099  }
7100 
7101  blocksizes[i] = nvarsblock * ncurconss;
7102  nvarsblocks[i] = nvarsblock;
7103  if( blocksizes[i] > 0 )
7104  {
7105  blockdensities[i] = 1.0 * nzblocks[i] / blocksizes[i];
7106  }
7107  else
7108  {
7109  blockdensities[i] = 0.0;
7110  }
7111 
7112  assert( blockdensities[i] >= 0 && blockdensities[i] <= 1.0 );
7113  SCIPfreeBufferArray( scip, & ishandled );
7114  }
7115 
7116 
7117  borderarea = ((unsigned long) getNMasterconss() * nVars ) + ( ((unsigned long) getNLinkingvars() + getNMastervars() + getNTotalStairlinkingvars() ) ) * ( nConss - getNMasterconss() );
7118 
7119  matrixarea = ((unsigned long) nVars ) * ((unsigned long) nConss );
7120 
7121 // std::cout << "black area ration = " << blackarea << "/ ( " << getNConss() << " * " << getNVars() << " = " << ( (unsigned long) getNConss() * (unsigned long) getNVars() ) << ") = " << maxwhitescore << std::endl;
7122 
7123 //std::cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! this seeed has a black area ratio of " << maxwhitescore << std::endl;
7124 
7125  density = 1E20;
7126  varratio = 1.0;
7127  linkingscore = 1.;
7128  borderscore = 1.;
7129  densityscore = 1.;
7130 
7131  for( i = 0; i < nBlocks; ++ i )
7132  {
7133  density = MIN( density, blockdensities[i] );
7134 
7136  {
7137  varratio *= 1.0 * nlinkvarsblocks[i] / ( getNLinkingvars() + getNMastervars() + getNTotalStairlinkingvars() );
7138  }
7139  else
7140  {
7141  varratio = 0.;
7142  }
7143  }
7144  linkingscore = ( 0.5 + 0.5 * varratio );
7145 
7146  densityscore = ( 1. - density );
7147 
7148  borderscore = ( 1.0 * ( borderarea ) / matrixarea );
7149 
7150  totalscore = 1. - (alphaborderarea * ( borderscore ) + alphalinking * ( linkingscore ) + alphadensity * ( densityscore ) );
7151 
7152  score = totalscore;
7153 
7154  SCIPfreeBufferArray( scip, & nzblocks );
7155  SCIPfreeBufferArray( scip, & nlinkvarsblocks) ;
7156  SCIPfreeBufferArray( scip, & blockdensities);
7157  SCIPfreeBufferArray( scip, & blocksizes);
7158  SCIPfreeBufferArray( scip, & nvarsblocks);
7159 
7160  SCIP_CALL_ABORT(SCIPstopClock( seeedpool->getScip(), clock) );
7161  seeedpool->scorecalculatingtime += SCIPgetClockTime( seeedpool->getScip(), clock);
7162  SCIP_CALL_ABORT(SCIPfreeClock( seeedpool->getScip(), &clock) );
7163 
7164  return SCIP_OKAY;
7165 }
7166 
7167 void Seeed::calcborderareascore(){
7168 
7169  unsigned long matrixarea;
7170  unsigned long borderarea;
7171 
7172 
7173  matrixarea = (unsigned long) getNVars() * (unsigned long)getNConss();
7174  borderarea = 0;
7175 
7176  borderarea += (unsigned long) ( getNLinkingvars() + getNTotalStairlinkingvars() ) * (unsigned long) getNConss();
7177  borderarea += (unsigned long) getNMasterconss() * ( (unsigned long) getNVars() - ( getNLinkingvars() + getNTotalStairlinkingvars() ) ) ;
7178 
7179  borderareascore = 1. - ( (SCIP_Real) borderarea / (SCIP_Real) matrixarea );
7180 
7181  return;
7182 }
7183 
7184 void Seeed::calcmaxforeseeingwhitescore(){
7185 
7186  std::vector<int> nlinkingvarsforblock(getNBlocks(), 0);
7187  std::vector<int> nblocksforlinkingvar(getNLinkingvars() + getNTotalStairlinkingvars(), 0);
7188 
7189  unsigned long sumblockshittinglinkingvar;
7190  unsigned long sumlinkingvarshittingblock;
7191  unsigned long newheight;
7192  unsigned long newwidth;
7193  unsigned long newmasterarea;
7194  unsigned long newblockarea;
7195 
7196  SCIP_CLOCK* clock;
7197 
7198  SCIP_CALL_ABORT( SCIPcreateClock( seeedpool->getScip(), &clock) );
7199  SCIP_CALL_ABORT( SCIPstartClock( seeedpool->getScip(), clock) );
7200 
7201  for( int lv = 0; lv < getNLinkingvars(); ++lv )
7202  {
7203  int linkingvarid = getLinkingvars()[lv];
7204 
7205  for( int b = 0; b < getNBlocks(); ++b )
7206  {
7207  for ( int blc = 0; blc < getNConssForBlock(b); ++blc )
7208  {
7209  int blockcons = getConssForBlock(b)[blc];
7210  if( !SCIPisZero( seeedpool->getScip(), seeedpool->getVal(blockcons, linkingvarid) ) )
7211  {
7213  ++nlinkingvarsforblock[b];
7214  ++nblocksforlinkingvar[lv];
7215  break;
7216  }
7217  }
7218  }
7219  }
7220 
7221  for( int b = 0; b < getNBlocks(); ++b)
7222  {
7223  for( int slv = 0; slv < getNStairlinkingvars(b); ++slv )
7224  {
7225  ++nlinkingvarsforblock[b];
7226  ++nlinkingvarsforblock[b+1];
7227  ++nblocksforlinkingvar[getNLinkingvars() + slv];
7228  ++nblocksforlinkingvar[getNLinkingvars() + slv];
7229  }
7230  }
7231 
7232  sumblockshittinglinkingvar = 0;
7233  sumlinkingvarshittingblock = 0;
7234  for( int b = 0; b < getNBlocks(); ++b )
7235  {
7236  sumlinkingvarshittingblock += nlinkingvarsforblock[b];
7237  }
7238  for( int lv = 0; lv < getNLinkingvars(); ++lv )
7239  {
7240  sumblockshittinglinkingvar += nblocksforlinkingvar[lv];
7241  }
7242 
7243  for( int slv = 0; slv < getNTotalStairlinkingvars(); ++slv )
7244  {
7245  sumblockshittinglinkingvar += nblocksforlinkingvar[getNLinkingvars() + slv];
7246  }
7247 
7248 
7249  newheight = getNConss() + sumblockshittinglinkingvar;
7250  newwidth = getNVars() + sumlinkingvarshittingblock;
7251 
7252  newmasterarea = ( getNMasterconss() + sumblockshittinglinkingvar) * ( getNVars() + sumlinkingvarshittingblock );
7253  newblockarea = 0;
7254 
7255  for( int b = 0; b < getNBlocks(); ++b )
7256  {
7257  newblockarea += getNConssForBlock(b) * ( getNVarsForBlock(b) + nlinkingvarsforblock[b] );
7258  }
7259 
7260  maxforeseeingwhitescore = ((SCIP_Real ) newblockarea + (SCIP_Real) newmasterarea) / (SCIP_Real) newwidth;
7261  maxforeseeingwhitescore = maxforeseeingwhitescore / (SCIP_Real) newheight ;
7262 
7263  maxforeseeingwhitescore = 1. - maxforeseeingwhitescore;
7264 
7265  SCIP_CALL_ABORT(SCIPstopClock( seeedpool->getScip(), clock) );
7266  seeedpool->scorecalculatingtime += SCIPgetClockTime( seeedpool->getScip(), clock);
7267  SCIP_CALL_ABORT(SCIPfreeClock( seeedpool->getScip(), &clock) );
7268 
7269  return;
7270 }
7271 
7272 void Seeed::calcmaxforeseeingwhitescoreagg(){
7273 
7274  std::vector<int> nlinkingvarsforblock(getNBlocks(), 0);
7275  std::vector<int> nblocksforlinkingvar(getNLinkingvars() + getNTotalStairlinkingvars(), 0);
7276 
7277  unsigned long sumblockshittinglinkingvar;
7278  unsigned long sumlinkingvarshittingblock;
7279  unsigned long newheight;
7280  unsigned long newwidth;
7281  unsigned long newmasterarea;
7282  unsigned long newblockareaagg;
7283 
7284  SCIP_CLOCK* clock;
7285 
7286  SCIP_CALL_ABORT( SCIPcreateClock( seeedpool->getScip(), &clock) );
7287  SCIP_CALL_ABORT( SCIPstartClock( seeedpool->getScip(), clock) );
7288 
7290 
7291  for( int lv = 0; lv < getNLinkingvars(); ++lv )
7292  {
7293  int linkingvarid = getLinkingvars()[lv];
7294 
7295  for( int b = 0; b < getNBlocks(); ++b )
7296  {
7297  for ( int blc = 0; blc < getNConssForBlock(b); ++blc )
7298  {
7299  int blockcons = getConssForBlock(b)[blc];
7300  if( !SCIPisZero( seeedpool->getScip(), seeedpool->getVal(blockcons, linkingvarid) ) )
7301  {
7303  ++nlinkingvarsforblock[b];
7304  ++nblocksforlinkingvar[lv];
7305  break;
7306  }
7307  }
7308  }
7309  }
7310 
7311  for( int b = 0; b < getNBlocks(); ++b)
7312  {
7313  for( int slv = 0; slv < getNStairlinkingvars(b); ++slv )
7314  {
7315  ++nlinkingvarsforblock[b];
7316  ++nlinkingvarsforblock[b+1];
7317  ++nblocksforlinkingvar[getNLinkingvars() + slv];
7318  ++nblocksforlinkingvar[getNLinkingvars() + slv];
7319  }
7320  }
7321 
7322  sumblockshittinglinkingvar = 0;
7323  sumlinkingvarshittingblock = 0;
7324  for( int b = 0; b < getNBlocks(); ++b )
7325  {
7326  sumlinkingvarshittingblock += nlinkingvarsforblock[b];
7327  }
7328  for( int lv = 0; lv < getNLinkingvars(); ++lv )
7329  {
7330  sumblockshittinglinkingvar += nblocksforlinkingvar[lv];
7331  }
7332 
7333  for( int slv = 0; slv < getNTotalStairlinkingvars(); ++slv )
7334  {
7335  sumblockshittinglinkingvar += nblocksforlinkingvar[getNLinkingvars() + slv];
7336  }
7337 
7338 
7339  newheight = getNConss() + sumblockshittinglinkingvar;
7340  newwidth = getNVars() + sumlinkingvarshittingblock;
7341 
7342  newmasterarea = ( getNMasterconss() + sumblockshittinglinkingvar) * ( getNVars() + sumlinkingvarshittingblock );
7343  newblockareaagg = 0;
7344 
7345  assert(nrepblocks > 0 );
7346  for( int br = 0; br < nrepblocks; ++br )
7347  {
7348  newblockareaagg += getNConssForBlock( reptoblocks[br][0] ) * ( getNVarsForBlock( reptoblocks[br][0] ) + nlinkingvarsforblock[reptoblocks[br][0]] );
7349  }
7350 
7351  maxforeseeingwhitescoreagg = ((SCIP_Real ) newblockareaagg + (SCIP_Real) newmasterarea) / (SCIP_Real) newwidth;
7352  maxforeseeingwhitescoreagg = maxforeseeingwhitescoreagg / (SCIP_Real) newheight ;
7353 
7354  maxforeseeingwhitescoreagg = 1. - maxforeseeingwhitescoreagg;
7355 
7356  SCIP_CALL_ABORT(SCIPstopClock( seeedpool->getScip(), clock) );
7357  seeedpool->scorecalculatingtime += SCIPgetClockTime( seeedpool->getScip(), clock);
7358  SCIP_CALL_ABORT(SCIPfreeClock( seeedpool->getScip(), &clock) );
7359 
7360  return;
7361 }
7362 
7363 void Seeed::calcsetpartfwhitescore(){
7364 
7365  if( maxforeseeingwhitescore == -1. )
7366  calcmaxforeseeingwhitescore();
7367  SCIP_CLOCK* clock;
7368 
7369  SCIP_CALL_ABORT( SCIPcreateClock( seeedpool->getScip(), &clock) );
7370  SCIP_CALL_ABORT( SCIPstartClock( seeedpool->getScip(), clock) );
7371 
7372  if( hasSetppccardMaster() && !isTrivial() && getNBlocks() > 1 )
7373  {
7374  setpartfwhitescore = 0.5 * maxforeseeingwhitescore + 0.5;
7375  }
7376  else
7377  {
7378  setpartfwhitescore = 0.5 * maxforeseeingwhitescore;
7379  }
7380 
7381  SCIP_CALL_ABORT(SCIPstopClock( seeedpool->getScip(), clock) );
7382  seeedpool->scorecalculatingtime += SCIPgetClockTime( seeedpool->getScip(), clock);
7383  SCIP_CALL_ABORT(SCIPfreeClock( seeedpool->getScip(), &clock) );
7384 
7385  return;
7386 }
7387 
7388 void Seeed::calcsetpartfwhitescoreagg(){
7389 
7390  if( maxforeseeingwhitescoreagg == -1. )
7391  calcmaxforeseeingwhitescoreagg();
7392 
7393  SCIP_CLOCK* clock;
7394 
7395  SCIP_CALL_ABORT( SCIPcreateClock( seeedpool->getScip(), &clock) );
7396  SCIP_CALL_ABORT( SCIPstartClock( seeedpool->getScip(), clock) );
7397 
7398  if( hasSetppccardMaster() && !isTrivial() && getNBlocks() > 1 )
7399  {
7400  setpartfwhitescoreagg = 0.5 * maxforeseeingwhitescoreagg + 0.5;
7401  }
7402  else
7403  {
7404  setpartfwhitescoreagg = 0.5 * maxforeseeingwhitescoreagg;
7405  }
7406 
7407  SCIP_CALL_ABORT(SCIPstopClock( seeedpool->getScip(), clock) );
7408  seeedpool->scorecalculatingtime += SCIPgetClockTime( seeedpool->getScip(), clock);
7409  SCIP_CALL_ABORT(SCIPfreeClock( seeedpool->getScip(), &clock) );
7410 
7411  return;
7412 }
7413 
7414 void Seeed::calcblockareascore(){
7415 
7416  unsigned long matrixarea;
7417  unsigned long blockarea;
7418 
7419 
7420  matrixarea = (unsigned long) getNVars() * (unsigned long) getNConss() ;
7421  blockarea = 0;
7422