cons_decomp.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 
40 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
41 
42 //#define SCIP_DEBUG
43 
44 #include "cons_decomp.h"
45 
46 #include "reader_gp.h"
47 
48 #include <assert.h>
49 #include <stddef.h>
50 #include <stdio.h>
51 #include <string.h>
52 #include <algorithm>
53 #include <cstdlib>
54 #include <fstream>
55 #include <iostream>
56 #include <iterator>
57 #include <sstream>
58 #include <string>
59 #include <utility>
60 #include <regex>
61 #include <vector>
62 
63 #include <scip/clock.h>
64 #include <scip/def.h>
65 #include <scip/pub_cons.h>
66 #include <scip/pub_dialog.h>
67 #include <scip/pub_message.h>
68 #include <scip/pub_misc.h>
69 #include <scip/type_clock.h>
70 #include <scip/type_cons.h>
71 #include <scip/type_dialog.h>
72 #include <scip/type_message.h>
73 #include <scip/type_misc.h>
74 #include <scip/type_paramset.h>
75 #include <scip/type_result.h>
76 #include <scip/type_retcode.h>
77 #include <scip/type_scip.h>
78 #include <scip/type_set.h>
79 #include "class_consclassifier.h"
80 #include "class_seeed.h"
81 #include "class_seeedpool.h"
82 #include "class_varclassifier.h"
84 #include "pub_decomp.h"
85 #include "type_decomp.h"
86 #include "wrapper_seeed.h"
87 #include "reader_tex.h"
88 #include "scip_misc.h"
89 #include "relax_gcg.h"
90 
92 
93 
94 /* constraint handler properties */
95 #define CONSHDLR_NAME "decomp"
96 #define CONSHDLR_DESC "constraint handler for structure detection"
97 #define CONSHDLR_ENFOPRIORITY 0
98 #define CONSHDLR_CHECKPRIORITY 0
99 #define CONSHDLR_EAGERFREQ -1
101 #define CONSHDLR_NEEDSCONS FALSE
103 #define MAXNDECOMPS 5000
105 #define DEFAULT_CREATEBASICDECOMP FALSE
106 #define DEFAULT_DUALVALRANDOMMETHOD 1
107 #define DEFAULT_COEFFACTORORIGVSRANDOM 0.5
109 #define DEFAULT_ALLOWCLASSIFIERDUPLICATES FALSE
110 #define DEFAULT_MAXDETECTIONROUNDS 1
111 #define DEFAULT_MAXNCLASSESLARGEPROBS 5
112 #define DEFAULT_MAXNCLASSES 9
113 #define DEFAULT_MAXNCLASSESFORNBLOCKCANDIDATES 18
114 #define DEFAULT_ENABLEORIGDETECTION FALSE
115 #define DEFAULT_CONSSADJCALCULATED TRUE
116 #define DEFAULT_ENABLEORIGCLASSIFICATION FALSE
117 #define DEFAULT_CONSSCLASSNNONZENABLED TRUE
118 #define DEFAULT_CONSSCLASSNNONZENABLEDORIG TRUE
120 #define DEFAULT_CONSSCLASSSCIPCONSTYPEENABLED TRUE
121 #define DEFAULT_CONSSCLASSSCIPCONSTYPEENABLEDORIG TRUE
123 #define DEFAULT_AGGREGATIONLIMITNCONSSPERBLOCK 300
124 #define DEFAULT_AGGREGATIONLIMITNVARSPERBLOCK 300
127 #define DEFAULT_CONSSCLASSMIPLIBCONSTYPEENABLED TRUE
128 #define DEFAULT_CONSSCLASSMIPLIBCONSTYPEENABLEDORIG TRUE
130 #define DEFAULT_CONSSCLASSCONSNAMENONUMBERENABLED FALSE
131 #define DEFAULT_CONSSCLASSCONSNAMENONUMBERENABLEDORIG FALSE
133 #define DEFAULT_CONSSCLASSLEVENSHTEINENABLED FALSE
134 #define DEFAULT_CONSSCLASSLEVENSHTEINENABLEDORIG FALSE
136 #define DEFAULT_VARCLASSSCIPVARTYPESENABLED TRUE
137 #define DEFAULT_VARCLASSSCIPVARTYPESENABLEDORIG TRUE
138 #define DEFAULT_BENDERSONLYCONTSUBPR FALSE
139 #define DEFAULT_BENDERSONLYBINMASTER FALSE
141 #define DEFAULT_VARCLASSOBJVALSENABLED TRUE
142 #define DEFAULT_VARCLASSOBJVALSENABLEDORIG TRUE
144 #define DEFAULT_VARCLASSOBJVALSIGNSENABLED TRUE
145 #define DEFAULT_VARCLASSOBJVALSIGNSENABLEDORIG TRUE
147 #define DEFAULT_LEVENSHTEIN_MAXMATRIXHALFPERIMETER 10000
148 #define AGGRESSIVE_LEVENSHTEIN_MAXMATRIXHALFPERIMETER 80000
149 #define FAST_LEVENSHTEIN_MAXMATRIXHALFPERIMETER 2000
151 #define DEFAULT_ONLYLEGACYMODE FALSE
152 #define DEFAULT_LEGACYMODE FALSE
153 #define DEFAULT_STAIRLINKINGHEUR FALSE
155 #define DEFAULT_WRITEMIPLIB2017FEATURES FALSE
156 #define DEFAULT_WRITEMIPLIB2017PLOTSANDDECS FALSE
157 #define DEFAULT_WRITEMIPLIB2017SHORTBASEFEATURES TRUE
158 #define DEFAULT_WRITEMIPLIB2017FEATUREFILEPATH "."
160 #define DEFAULT_WRITEMIPLIB2017MATRIXFILEPATH "."
162 #define DEFAULT_WRITEMIPLIB2017DECOMPFILEPATH "."
165 #define DEFAULT_DETECTBENDERS FALSE
168 /*
169  * Data structures
170  */
171 
173 struct SCIP_ConshdlrData
174 {
178  int* priorities;
180  SCIP_CLOCK* detectorclock;
182  SCIP_Bool hasrun;
183  int ndecomps;
195  SCIP_Bool createbasicdecomp;
197  SCIP_Bool conssadjcalculated;
214  SCIP_Bool detectbenders;
219  SCIP_Bool onlylegacymode;
220  SCIP_Bool legacymodeenabled;
221  SCIP_Bool stairlinkingheur;
230  int** candidatesNBlocks;
231  int* nCandidates;
233  int ncallscreatedecomp;
248  SCIP_Bool unpresolveduserseeedadded;
251  int startidvisu;
253  std::vector<SeeedPtr>* listall;
254  std::vector<int>* selected;
255  SCIP_Bool selectedexists;
257  std::vector<std::pair<SeeedPtr, SCIP_Real> >* candidates;
268  SCIP_Bool nonfinalfreetransform;
269  std::vector<int>* userblocknrcandidates;
274 };
275 
276 
278  NO_MODIF = 0,
282 };
283 
284 /*
285  * Local methods
286  */
287 
291 SCIP_Real calcLogarithm(SCIP_Real val)
292 {
293  return log(val) / log(2);
294 }
295 
296 
302  SCIP* scip
303  )
304 {
305  SCIP_CONSHDLR* conshdlr;
306  SCIP_CONSHDLRDATA* conshdlrdata;
307 
308  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
309 
310  if( conshdlr == NULL )
311  {
312  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
313  return SCIP_ERROR;
314  }
315 
316  conshdlrdata = SCIPconshdlrGetData(conshdlr);
317  assert(conshdlrdata != NULL);
318 
319  std::vector<int>::const_iterator selectediter = conshdlrdata->selected->begin();
320  std::vector<int>::const_iterator selectediterend = conshdlrdata->selected->end();
321 
322  for( ; selectediter != selectediterend; ++selectediter )
323  {
324  conshdlrdata->listall->at(*selectediter)->setSelected(false);
325  }
326 
327  conshdlrdata->selected->clear();
328 
329  conshdlrdata->selectedexists = FALSE;
330 
331  return SCIP_OKAY;
332 }
333 
338  SCIP_CONSHDLRDATA* conshdlrdata
339 )
340 {
341  return static_cast<scoretype>(conshdlrdata->currscoretype);
342 }
343 
344 
350  SCIP* scip,
351  SCORETYPE sctype
352  )
353 {
354  char scoretypename[SCIP_MAXSTRLEN];
355  char* copy;
357  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "") ;
358 
359 
360  if( sctype == scoretype::MAX_WHITE )
361  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "maxwhi") ;
362 
363  if( sctype == scoretype::CLASSIC )
364  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "classi") ;
365 
366  if( sctype == scoretype::BORDER_AREA )
367  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "border") ;
368 
369  if( sctype == scoretype::MAX_FORESSEEING_WHITE )
370  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "forswh") ;
371 
373  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "fawh") ;
374 
375 
376  if( sctype == scoretype::SETPART_FWHITE )
377  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "spfwh ") ;
378 
379  if( sctype == scoretype::SETPART_AGG_FWHITE )
380  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "spfawh") ;
381 
382 
383  if( sctype == scoretype::BENDERS )
384  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "bender") ;
385 
386 
387  SCIP_CALL_ABORT ( SCIPduplicateBlockMemoryArray(scip, &copy, scoretypename, SCIP_MAXSTRLEN ) );
388 
389  return copy;
390 
391 }
392 
401  SCIP* scip,
402  SCORETYPE sctype
403  )
404 {
405  char scoretypename[SCIP_MAXSTRLEN];
406  char* copy;
408  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "") ;
409 
410 
411  if( sctype == scoretype::MAX_WHITE)
412  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "maximum white area score (i.e. maximize fraction of white area score; white area is nonblock and nonborder area, stairlinking variables count as linking)") ;
413 
414  if( sctype == scoretype::CLASSIC)
415  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "classical score") ;
416 
417  if( sctype == scoretype::BORDER_AREA)
418  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "minimum border score (i.e. minimizes fraction of border area score; )") ;
419 
420  if( sctype == scoretype::MAX_FORESSEEING_WHITE)
421  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "maximum foreseeing white area score (i.e. maximize fraction of white area score considering problem with copied linking variables and corresponding master constraints; white area is nonblock and nonborder area, stairlinking variables count as linking)") ;
422 
424  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "maximum foreseeing white area score with aggregation information(i.e. maximize fraction of white area score considering problem with copied linking variables and corresponding master constraints; white area is nonblock and nonborder area, stairlinking variables count as linking)") ;
425 
426 
427  if( sctype == scoretype::SETPART_FWHITE)
428  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "setpartitioning maximum foreseeing white area score (i.e. convex combination of maximum foreseeing white area score and a boolean score rewarding a master containing only setppc and cardinality constraints )") ;
429 
430  if( sctype == scoretype::SETPART_AGG_FWHITE)
431  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "setpartitioning maximum foreseeing white area score with aggregation information (i.e. convex combination of maximum foreseeing white area score and a boolean score rewarding a master containing only setppc and cardinality constraints )") ;
432 
433  if( sctype == scoretype::BENDERS)
434  SCIPsnprintf( scoretypename, SCIP_MAXSTRLEN, "experimental score to evaluate benders decompositions") ;
435 
436 
437  SCIP_CALL_ABORT ( SCIPduplicateBlockMemoryArray(scip, &copy, scoretypename, SCIP_MAXSTRLEN ) );
438 
439  return copy;
440 
441 }
442 
448 SCIP_Bool unfinishedchildexists(std::vector<SCIP_Bool> const& childsfinished)
449 {
450  for( size_t s = 0; s < childsfinished.size(); ++s )
451  {
452  if( !childsfinished[s] )
453  return true;
454  }
455  return false;
456 }
457 
466  std::vector<SCIP_Bool> const& childsfinished,
467  std::vector<int> const& childs
468  )
469 {
470  for( size_t s = 0; s < childsfinished.size(); ++s )
471  {
472  if( !childsfinished[s] )
473  return childs[s];
474  }
475  return -1;
476 }
477 
483 int getfirstunfinishedchildid(std::vector<SCIP_Bool> const& childsfinished, std::vector<int> const& childs)
484 {
485  for( size_t s = 0; s < childsfinished.size(); ++s )
486  {
487  if( !childsfinished[s] )
488  return (int)s;
489  }
490  return -1;
491 }
492 
493 
497 SCIP_Bool finishnextchild( std::vector<int>& childs, std::vector<SCIP_Bool>& childsfinished, int child )
498 {
499  for( size_t s = 0; s < childsfinished.size(); ++s )
500  {
501  if( !childsfinished[s] )
502  {
503  assert(childs[s] == child);
504  childsfinished[s] = TRUE;
505  return s == childsfinished.size() - 1;
506  }
507  }
508  return FALSE;
509 }
510 
511 
514  SCIP* scip,
515  SeeedPtr seeed
516  ){
517 
518  SCIP_CONSHDLR* conshdlr;
519  SCIP_CONSHDLRDATA* conshdlrdata;
520  SCIP_Bool success;
521  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
522 
523  if( conshdlr == NULL )
524  {
525  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
526  return SCIP_ERROR;
527  }
528 
529  conshdlrdata = SCIPconshdlrGetData(conshdlr);
530  assert(conshdlrdata != NULL);
531 
532  assert( seeed->isComplete() );
533  assert( seeed->isFromUnpresolved() );
534 
535  conshdlrdata->seeedpoolunpresolved->addSeeedToFinished(seeed, &success);
536 
537 
538  return SCIP_OKAY;
539  }
540 
543  SCIP* scip,
544  SeeedPtr seeed
545  ){
546 
547  SCIP_CONSHDLR* conshdlr;
548  SCIP_CONSHDLRDATA* conshdlrdata;
549  SCIP_Bool success;
550 
551  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
552 
553  if( conshdlr == NULL )
554  {
555  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
556  return SCIP_ERROR;
557  }
558 
559  conshdlrdata = SCIPconshdlrGetData(conshdlr);
560  assert(conshdlrdata != NULL);
561 
562  assert( seeed->isComplete() );
563  assert( !seeed->isFromUnpresolved() );
564 
565  conshdlrdata->seeedpool->addSeeedToFinished(seeed, &success);
566 
567  if( !success )
568  SCIPinfoMessage(scip, NULL, " Added decomposition is already in!!!!!!!!!!!!!!!!!!!!!\n");
569 
570  return SCIP_OKAY;
571  }
572 
575  SCIP* scip,
576  SeeedPtr seeed
577  ){
578 
579  SCIP_CONSHDLR* conshdlr;
580  SCIP_CONSHDLRDATA* conshdlrdata;
581  SCIP_Bool success;
582 
583  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
584 
585  if( conshdlr == NULL )
586  {
587  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
588  return SCIP_ERROR;
589  }
590 
591  conshdlrdata = SCIPconshdlrGetData(conshdlr);
592  assert(conshdlrdata != NULL);
593 
594  assert( !seeed->isComplete() );
595  assert( seeed->isFromUnpresolved() );
596 
597  conshdlrdata->seeedpoolunpresolved->addSeeedToIncomplete(seeed, &success);
598 
599  return SCIP_OKAY;
600  }
601 
604  SCIP* scip,
605  SeeedPtr seeed
606  ){
607 
608  SCIP_CONSHDLR* conshdlr;
609  SCIP_CONSHDLRDATA* conshdlrdata;
610 
611  SCIP_Bool success;
612  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
613 
614  if( conshdlr == NULL )
615  {
616  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
617  return SCIP_ERROR;
618  }
619 
620  conshdlrdata = SCIPconshdlrGetData(conshdlr);
621  assert(conshdlrdata != NULL);
622 
623  assert( !seeed->isComplete() );
624  assert( !seeed->isFromUnpresolved() );
625 
626  conshdlrdata->seeedpool->addSeeedToIncomplete(seeed, &success);
627 
628  return SCIP_OKAY;
629  }
630 
631 
633 SCIP_RETCODE SCIPconshdlrDecompAddSeeed(
634  SCIP* scip,
635  SeeedPtr seeed
636  ){
637 
638 
639  if( seeed->isComplete() )
640  {
641  if( seeed->isFromUnpresolved() )
643  else
645  }
646  else
647  {
648  if( seeed->isFromUnpresolved() )
650  else
652  }
653 
654  return SCIP_OKAY;
655  }
656 
659  SCIP* scip,
660  int seeedid
661  ){
662 
663  SCIP_CONSHDLR* conshdlr;
664  SCIP_CONSHDLRDATA* conshdlrdata;
665 
666  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
667 
668  if( conshdlr == NULL )
669  {
670  SCIPerrorMessage("Decomp constraint handler is not included, cannot find Seeed!\n");
671  return NULL;
672  }
673 
674  conshdlrdata = SCIPconshdlrGetData(conshdlr);
675  assert(conshdlrdata != NULL);
676 
677  if( conshdlrdata->seeedpool == NULL )
678  return NULL;
679 
680  for( int i = 0; i < conshdlrdata->seeedpool->getNAncestorSeeeds(); ++i)
681  {
682  if( conshdlrdata->seeedpool->getAncestorSeeed( i ) != NULL && conshdlrdata->seeedpool->getAncestorSeeed( i )->getID() == seeedid )
683  return conshdlrdata->seeedpool->getAncestorSeeed( i );
684  }
685 
686  for( int i = 0; i < conshdlrdata->seeedpool->getNIncompleteSeeeds(); ++i)
687  {
688  if( conshdlrdata->seeedpool->getIncompleteSeeed( i )->getID() == seeedid )
689  return conshdlrdata->seeedpool->getIncompleteSeeed( i );
690  }
691 
692  for( int i = 0; i < conshdlrdata->seeedpool->getNFinishedSeeeds(); ++i)
693  {
694  if( conshdlrdata->seeedpool->getFinishedSeeed( i )->getID() == seeedid )
695  return conshdlrdata->seeedpool->getFinishedSeeed( i );
696  }
697 
698  return NULL;
699 
700 }
701 
704  SCIP* scip,
705  int seeedid
706  ){
707 
708  SCIP_CONSHDLR* conshdlr;
709  SCIP_CONSHDLRDATA* conshdlrdata;
710 
711  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
712 
713  if( conshdlr == NULL )
714  {
715  SCIPerrorMessage("Decomp constraint handler is not included, cannot find Seeed!\n");
716  return NULL;
717  }
718 
719  conshdlrdata = SCIPconshdlrGetData(conshdlr);
720  assert(conshdlrdata != NULL);
721 
722  for( int i = 0; i < conshdlrdata->seeedpoolunpresolved->getNIncompleteSeeeds(); ++i)
723  {
724  if( conshdlrdata->seeedpoolunpresolved->getIncompleteSeeed( i )->getID() == seeedid )
725  return conshdlrdata->seeedpoolunpresolved->getIncompleteSeeed( i );
726  }
727 
728  for( int i = 0; i < conshdlrdata->seeedpoolunpresolved->getNAncestorSeeeds(); ++i)
729  {
730  if( conshdlrdata->seeedpoolunpresolved->getAncestorSeeed( i )!= NULL && conshdlrdata->seeedpoolunpresolved->getAncestorSeeed( i )->getID() == seeedid )
731  return conshdlrdata->seeedpoolunpresolved->getAncestorSeeed( i );
732  }
733 
734  for( int i = 0; i < conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds(); ++i)
735  {
736  if( conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i )->getID() == seeedid )
737  return conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i );
738  }
739 
740  return NULL;
741 }
742 
743 
746  SCIP* scip,
747  int seeedid
748  ){
749 
750  SeeedPtr seeed = NULL;
751 
753 
754  if( seeed == NULL)
756  else
757  return seeed;
758 }
759 
760 
761 struct sort_pred {
762  bool operator()(const std::pair<SeeedPtr, SCIP_Real> &left, const std::pair<SeeedPtr, SCIP_Real> &right) {
763  return left.second > right.second;
764  }
765 };
766 
767 
768 #ifdef ADDONEBLOCKDECOMP
769 
772 static
773 SCIP_RETCODE createOneBlockDecomp(
774  SCIP* scip
775  )
776 {
777  SCIP_HASHMAP* newconstoblock;
778  DEC_DECOMP* newdecomp;
779  SCIP_CONS** conss;
780  int nconss;
781  int i;
782 
783  conss = SCIPgetConss(scip);
784  nconss = SCIPgetNConss(scip);
785 
786  SCIP_CALL( SCIPhashmapCreate(&newconstoblock, SCIPblkmem(scip), nconss ) );
787 
788  /* assign each constraint to (the only) block 1 */
789  for( i = 0; i < nconss; i++ )
790  {
791  assert(!SCIPhashmapExists(newconstoblock, conss[i]));
792  SCIP_CALL( SCIPhashmapInsert(newconstoblock, conss[i], (void*) (size_t) 1) );
793  }
794 
795  /* create the decomposition data structure and add it to SCIP */
796  SCIP_CALL( DECdecompCreate(scip, &newdecomp) );
797  assert(newdecomp != NULL);
798  SCIP_CALL( DECfilloutDecompFromConstoblock(scip, newdecomp, newconstoblock, 1, FALSE) );
799 
800  SCIP_CALL( SCIPconshdlrDecompAddDecdecomp(scip, newdecomp) );
801 
802  SCIP_CALL( SCIPhashmapFree(&newconstoblock ) );
803 
804  SCIP_CALL( DECdecompFree(scip, &newdecomp ));
805 
806  return SCIP_OKAY;
807 }
808 
809 #endif
810 
811 /*
812  * Callback methods of constraint handler
813  */
814 
816 static
817 SCIP_DECL_CONSINIT(consInitDecomp)
818 { /*lint --e{715}*/
819  SCIP_CONSHDLRDATA* conshdlrdata;
820  int i;
821  conshdlrdata = SCIPconshdlrGetData(conshdlr);
822  assert(conshdlrdata != NULL);
823 
824  conshdlrdata->hasrun = FALSE;
825  conshdlrdata->seeedpool = NULL;
826 
827  for( i = 0; i < conshdlrdata->ndetectors; ++i )
828  {
829  DEC_DETECTOR *detector;
830  detector = conshdlrdata->detectors[i];
831  assert(detector != NULL);
832 
833  detector->dectime = 0.;
834  if( detector->initDetector != NULL )
835  {
836  SCIPdebugMessage("Calling initDetector of %s\n", detector->name);
837  SCIP_CALL( (*detector->initDetector)(scip, detector) );
838  }
839  }
840 
841  return SCIP_OKAY;
842 }
843 
844 
845 
847 static
848 SCIP_DECL_CONSEXIT(consExitDecomp)
849 { /*lint --e{715}*/
850  SCIP_CONSHDLRDATA* conshdlrdata;
851  int i;
852 
853  assert(conshdlr != NULL);
854  assert(scip != NULL);
855 
856  conshdlrdata = SCIPconshdlrGetData(conshdlr);
857  assert(conshdlrdata != NULL);
858 
859  if( conshdlrdata->useddecomp != NULL )
860  SCIP_CALL( DECdecompFree(scip, &conshdlrdata->useddecomp) );
861 
862 
863  if( conshdlrdata->ndecomps > 0 && conshdlrdata->decdecomps != NULL )
864  {
865  for( int dec = 0; dec < conshdlrdata->ndecomps; ++dec )
866  {
867 
868  DECdecompFree(scip, &conshdlrdata->decdecomps[conshdlrdata->ndecomps - dec - 1]);
869  }
870 
871  SCIPfreeBlockMemoryArray(scip, &conshdlrdata->decdecomps, conshdlrdata->ndecomps);
872  conshdlrdata->ndecomps = 0;
873  conshdlrdata->decdecomps = NULL;
874  }
875 
876 
877  conshdlrdata->hasrun = FALSE;
878 
879  for( i = 0; i < conshdlrdata->ndetectors; ++i )
880  {
881  DEC_DETECTOR *detector;
882  detector = conshdlrdata->detectors[i];
883  assert(detector != NULL);
884 
885 // detector->ndecomps = 0;
886  SCIPfreeMemoryArrayNull(scip, &detector->decomps);
887  if( detector->exitDetector != NULL )
888  {
889  SCIPdebugMessage("Calling exitDetector of %s\n", detector->name);
890  SCIP_CALL( (*detector->exitDetector)(scip, detector) );
891  }
892  }
893 
894  delete conshdlrdata->seeedpool;
895  conshdlrdata->seeedpool = NULL;
896 
897  if( !conshdlrdata->nonfinalfreetransform )
898  {
899  if( conshdlrdata->seeedpoolunpresolved != NULL )
900  delete conshdlrdata->seeedpoolunpresolved;
901  conshdlrdata->seeedpoolunpresolved = NULL;
902  }
903 
905  conshdlrdata->listall->clear();
906 
907 
908  return SCIP_OKAY;
909 }
910 
912 static
913 SCIP_DECL_CONSFREE(consFreeDecomp)
914 {
915  SCIP_CONSHDLRDATA* conshdlrdata;
916  int i;
917  conshdlrdata = SCIPconshdlrGetData(conshdlr);
918  assert(conshdlrdata != NULL);
919 
920  SCIP_CALL( SCIPfreeClock(scip, &conshdlrdata->detectorclock) );
921  SCIP_CALL( SCIPfreeClock(scip, &conshdlrdata->completedetectionclock) );
922 
923 
924 
925 
926  for( i = 0; i < conshdlrdata->ndetectors; ++i )
927  {
928  DEC_DETECTOR *detector;
929  detector = conshdlrdata->detectors[i];
930  assert(detector != NULL);
931 
932  if( detector->freeDetector != NULL )
933  {
934  SCIPdebugMessage("Calling freeDetector of %s\n", detector->name);
935  SCIP_CALL( (*detector->freeDetector)(scip, detector) );
936  }
937  SCIPfreeBlockMemory(scip, &detector);
938  }
939 
940 
941 
942  /* @todo: This is also done in consExitDecomp() and therefore probably makes no sense here. */
943  if ( conshdlrdata->useddecomp != NULL )
944  SCIP_CALL( DECdecompFree(scip, &conshdlrdata->useddecomp) );
945 
946  if( conshdlrdata->candidates != NULL )
947  delete conshdlrdata->candidates;
948 
949  SCIPfreeMemoryArray(scip, &conshdlrdata->priorities);
950  SCIPfreeMemoryArray(scip, &conshdlrdata->detectors);
951 
952  delete conshdlrdata->selected;
953  delete conshdlrdata->listall;
954  delete conshdlrdata->userblocknrcandidates;
955 
956  SCIPfreeMemory(scip, &conshdlrdata);
957 
958  return SCIP_OKAY;
959 }
960 
962 static
963 SCIP_DECL_CONSENFORELAX(consEnforeDecomp)
964 { /*lint --e{715}*/
965  *result = SCIP_FEASIBLE;
966  return SCIP_OKAY;
967 }
968 
969 
971 static
972 SCIP_DECL_CONSENFOLP(consEnfolpDecomp)
973 { /*lint --e{715}*/
974  *result = SCIP_FEASIBLE;
975  return SCIP_OKAY;
976 }
977 
979 static
980 SCIP_DECL_CONSENFOPS(consEnfopsDecomp)
981 { /*lint --e{715}*/
982  *result = SCIP_FEASIBLE;
983  return SCIP_OKAY;
984 }
985 
987 static
988 SCIP_DECL_CONSCHECK(consCheckDecomp)
989 {
990  /*lint --e{715}*/
991  *result = SCIP_FEASIBLE;
992  return SCIP_OKAY;
993 }
994 
996 static
997 SCIP_DECL_CONSLOCK(consLockDecomp)
998 { /*lint --e{715}*/
999  return SCIP_OKAY;
1000 }
1001 
1002 /*
1003  * constraint specific interface methods
1004  */
1005 
1007 SCIP_RETCODE SCIPincludeConshdlrDecomp(
1008  SCIP* scip
1009  )
1010 {
1011  SCIP_CONSHDLR* conshdlr;
1012  SCIP_CONSHDLRDATA* conshdlrdata;
1013 
1014  /* create decomp constraint handler data */
1015  SCIP_CALL( SCIPallocMemory(scip, &conshdlrdata) );
1016  assert(conshdlrdata != NULL);
1017 
1018  conshdlrdata->useddecomp = NULL;
1019  conshdlrdata->ndetectors = 0;
1020  conshdlrdata->priorities = NULL;
1021  conshdlrdata->detectors = NULL;
1022  conshdlrdata->hasrun = FALSE;
1023  conshdlrdata->decdecomps = NULL;
1024  conshdlrdata->ndecomps = 0;
1025  conshdlrdata->maxndetectionrounds = 0;
1026  conshdlrdata->maxnclassesperclassifier = 0;
1027  conshdlrdata->maxnclassesperclassifierforlargeprobs = 0;
1028  conshdlrdata->aggregationlimitnconssperblock = 0;
1029  conshdlrdata->aggregationlimitnvarsperblock = 0;
1030  conshdlrdata->enableorigdetection = FALSE;
1031  conshdlrdata->seeedpoolunpresolved = NULL;
1032  conshdlrdata->seeedpool = NULL;
1033  conshdlrdata->ncallscreatedecomp = 0;
1034 
1035  conshdlrdata->curruserseeed = NULL;
1036  conshdlrdata->lastuserseeed = NULL;
1037  conshdlrdata->unpresolveduserseeedadded = FALSE;
1038  conshdlrdata->startidvisu = 0;
1039  conshdlrdata->selectvisulength = 10;
1040  conshdlrdata->listall = new std::vector<SeeedPtr>(0, NULL);
1041  conshdlrdata->selected = new std::vector<int>(0, -1);
1042  conshdlrdata->candidates = new std::vector<std::pair<SeeedPtr, SCIP_Real > >(0);
1043  conshdlrdata->selectedexists = FALSE;
1044  conshdlrdata->sizedecomps = 10;
1045  conshdlrdata->seeedcounter = 0;
1046  conshdlrdata->currscoretype = scoretype::MAX_WHITE;
1047  conshdlrdata->nonfinalfreetransform = FALSE;
1048  conshdlrdata->userblocknrcandidates = new std::vector<int>(0);
1049  conshdlrdata->seeedtowrite = NULL;
1050 
1051  conshdlrdata->writemiplib2017featurefilepath = NULL;
1052  conshdlrdata->writemiplib2017matrixfilepath = NULL;
1053  conshdlrdata->writemiplib2017decompfilepath = NULL;
1054 
1055  SCIP_CALL( SCIPcreateClock(scip, &conshdlrdata->detectorclock) );
1056  SCIP_CALL( SCIPcreateClock(scip, &conshdlrdata->completedetectionclock) );
1057  /* include constraint handler */
1058  SCIP_CALL( SCIPincludeConshdlrBasic(scip, &conshdlr, CONSHDLR_NAME, CONSHDLR_DESC,
1060  consEnfolpDecomp, consEnfopsDecomp, consCheckDecomp, consLockDecomp,
1061  conshdlrdata) );
1062  assert(conshdlr != FALSE);
1063 
1064  SCIP_CALL( SCIPsetConshdlrEnforelax(scip, conshdlr, consEnforeDecomp) );
1065  SCIP_CALL( SCIPsetConshdlrFree(scip, conshdlr, consFreeDecomp) );
1066  SCIP_CALL( SCIPsetConshdlrInit(scip, conshdlr, consInitDecomp) );
1067  SCIP_CALL( SCIPsetConshdlrExit(scip, conshdlr, consExitDecomp) );
1068 
1069 
1070  SCIP_CALL( SCIPaddBoolParam(scip, "constraints/decomp/createbasicdecomp", "indicates whether to create a decomposition with all constraints in the master if no other specified", &conshdlrdata->createbasicdecomp, FALSE, DEFAULT_CREATEBASICDECOMP, NULL, NULL) );
1071  SCIP_CALL( SCIPaddBoolParam(scip, "detection/allowclassifierduplicates/enabled", "indicates whether classifier duplicates are allowed (for statistical reasons)", &conshdlrdata->allowclassifierduplicates, FALSE, DEFAULT_ALLOWCLASSIFIERDUPLICATES, NULL, NULL) );
1072  SCIP_CALL( SCIPaddBoolParam(scip, "detection/conssadjcalculated", "conss adjecency datastructures should be calculated", &conshdlrdata->conssadjcalculated, FALSE, DEFAULT_CONSSADJCALCULATED, NULL, NULL) );
1073  SCIP_CALL( SCIPaddBoolParam(scip, "detection/origprob/enabled", "indicates whether to start detection for the original problem", &conshdlrdata->enableorigdetection, FALSE, DEFAULT_ENABLEORIGDETECTION, NULL, NULL) );
1074  SCIP_CALL( SCIPaddBoolParam(scip, "detection/origprob/classificationenabled", "indicates whether to classify constraints and variables for the original problem", &conshdlrdata->enableorigclassification, FALSE, DEFAULT_ENABLEORIGCLASSIFICATION, NULL, NULL) );
1075  SCIP_CALL( SCIPaddBoolParam(scip, "detection/consclassifier/nnonzeros/enabled", "indicates whether constraint classifier for nonzero entries is enabled", &conshdlrdata->conssclassnnonzenabled, FALSE, DEFAULT_CONSSCLASSNNONZENABLED, NULL, NULL) );
1076  SCIP_CALL( SCIPaddBoolParam(scip, "detection/consclassifier/nnonzeros/origenabled", "indicates whether constraint classifier for nonzero entries is enabled for the original problem", &conshdlrdata->conssclassnnonzenabledorig, FALSE, DEFAULT_CONSSCLASSNNONZENABLEDORIG, NULL, NULL) );
1077  SCIP_CALL( SCIPaddBoolParam(scip, "detection/consclassifier/scipconstype/enabled", "indicates whether constraint classifier for scipconstype is enabled", &conshdlrdata->conssclassnconstypeenabled, FALSE, DEFAULT_CONSSCLASSSCIPCONSTYPEENABLED, NULL, NULL) );
1078  SCIP_CALL( SCIPaddBoolParam(scip, "detection/consclassifier/scipconstype/origenabled", "indicates whether constraint classifier for scipconsstype is enabled for the original problem", &conshdlrdata->conssclassnconstypeenabledorig, FALSE, DEFAULT_CONSSCLASSSCIPCONSTYPEENABLEDORIG, NULL, NULL) );
1079  SCIP_CALL( SCIPaddBoolParam(scip, "detection/consclassifier/miplibconstype/enabled", "indicates whether constraint classifier for miplib constypes is enabled", &conshdlrdata->conssclassnmiplibconstypeenabled, FALSE, DEFAULT_CONSSCLASSMIPLIBCONSTYPEENABLED, NULL, NULL) );
1080  SCIP_CALL( SCIPaddBoolParam(scip, "detection/consclassifier/miplibconstype/origenabled", "indicates whether constraint classifier for miplib consstype is enabled for the original problem", &conshdlrdata->conssclassnmiplibconstypeenabledorig, FALSE, DEFAULT_CONSSCLASSMIPLIBCONSTYPEENABLEDORIG, NULL, NULL) );
1081  SCIP_CALL( SCIPaddBoolParam(scip, "detection/consclassifier/consnamenonumbers/enabled", "indicates whether constraint classifier for constraint names (remove digits; check for identity) is enabled", &conshdlrdata->consnamenonumbersenabled, FALSE, DEFAULT_CONSSCLASSCONSNAMENONUMBERENABLED, NULL, NULL) );
1082  SCIP_CALL( SCIPaddBoolParam(scip, "detection/consclassifier/consnamenonumbers/origenabled", "indicates whether constraint classifier for constraint names (remove digits; check for identity) is enabled for the original problem", &conshdlrdata->consnamenonumbersenabledorig, FALSE, DEFAULT_CONSSCLASSCONSNAMENONUMBERENABLEDORIG, NULL, NULL) );
1083  SCIP_CALL( SCIPaddBoolParam(scip, "detection/consclassifier/consnamelevenshtein/enabled", "indicates whether constraint classifier for constraint names (according to levenshtein distance graph) is enabled", &conshdlrdata->conssclasslevenshteinabled, FALSE, DEFAULT_CONSSCLASSLEVENSHTEINENABLED, NULL, NULL) );
1084  SCIP_CALL( SCIPaddBoolParam(scip, "detection/consclassifier/consnamelevenshtein/origenabled", "indicates whether constraint classifier for constraint names (according to levenshtein distance graph) is enabled for the original problem", &conshdlrdata->conssclasslevenshteinenabledorig, FALSE, DEFAULT_CONSSCLASSLEVENSHTEINENABLEDORIG, NULL, NULL) );
1085  SCIP_CALL( SCIPaddBoolParam(scip, "detection/varclassifier/scipvartype/enabled", "indicates whether variable classifier for scipvartypes is enabled", &conshdlrdata->varclassvartypesenabled, FALSE, DEFAULT_VARCLASSSCIPVARTYPESENABLED, NULL, NULL) );
1086  SCIP_CALL( SCIPaddBoolParam(scip, "detection/varclassifier/scipvartype/origenabled", "indicates whether variable classifier for scipvartypes is enabled for the original problem", &conshdlrdata->varclassvartypesenabledorig, FALSE, DEFAULT_VARCLASSSCIPVARTYPESENABLEDORIG, NULL, NULL) );
1087  SCIP_CALL( SCIPaddBoolParam(scip, "detection/varclassifier/objectivevalues/enabled", "indicates whether variable classifier for objective function values is enabled", &conshdlrdata->varclassobjvalsenabled, FALSE, DEFAULT_VARCLASSOBJVALSENABLED, NULL, NULL) );
1088  SCIP_CALL( SCIPaddBoolParam(scip, "detection/benders/onlycontsubpr", "indicates whether only decomposition with only continiuous variables in the subproblems should be searched", &conshdlrdata->bendersonlycontsubpr, FALSE, DEFAULT_BENDERSONLYCONTSUBPR, NULL, NULL) );
1089  SCIP_CALL( SCIPaddBoolParam(scip, "detection/benders/onlybinmaster", "indicates whether only decomposition with only binary variables in the master should be searched", &conshdlrdata->bendersonlybinmaster, FALSE, DEFAULT_BENDERSONLYBINMASTER, NULL, NULL) );
1090  SCIP_CALL( SCIPaddBoolParam(scip, "detection/varclassifier/objectivevalues/origenabled", "indicates whether variable classifier for objective function values is enabled for the original problem", &conshdlrdata->varclassobjvalsenabledorig, FALSE, DEFAULT_VARCLASSOBJVALSENABLEDORIG, NULL, NULL) );
1091  SCIP_CALL( SCIPaddBoolParam(scip, "detection/varclassifier/objectivevaluesigns/enabled", "indicates whether variable classifier for objective function value signs is enabled", &conshdlrdata->varclassobjvalsignsenabled, FALSE, DEFAULT_VARCLASSOBJVALSIGNSENABLED, NULL, NULL) );
1092  SCIP_CALL( SCIPaddBoolParam(scip, "detection/varclassifier/objectivevaluesigns/origenabled", "indicates whether variable classifier for objective function value signs is enabled for the original problem", &conshdlrdata->varclassobjvalsignsenabledorig, FALSE, DEFAULT_VARCLASSOBJVALSIGNSENABLEDORIG, NULL, NULL) );
1093  SCIP_CALL( SCIPaddBoolParam(scip, "detection/legacymode/onlylegacymode", "indicates whether detection should only consist of legacy mode detection", &conshdlrdata->onlylegacymode, FALSE, DEFAULT_ONLYLEGACYMODE, NULL, NULL) );
1094  SCIP_CALL( SCIPaddBoolParam(scip, "detection/legacymode/enabled", "indicates whether detection consist of legacy mode detection", &conshdlrdata->legacymodeenabled, FALSE, DEFAULT_LEGACYMODE, NULL, NULL) );
1095  SCIP_CALL( SCIPaddBoolParam(scip, "detection/legacymode/stairlinkingheur", "indicates whether heuristic to reassign linking vars to stairlinking in legacy mode should be activated", &conshdlrdata->stairlinkingheur, FALSE, DEFAULT_STAIRLINKINGHEUR, NULL, NULL) );
1096  SCIP_CALL( SCIPaddBoolParam(scip, "write/miplib2017features", "indicates whether miplib2017 features should be written", &conshdlrdata->writemiplib2017features, FALSE, DEFAULT_WRITEMIPLIB2017FEATURES, NULL, NULL) );
1097  SCIP_CALL( SCIPaddBoolParam(scip, "write/miplib2017plotsanddecs", "indicates whether dec and gp files are written for miplib2017", &conshdlrdata->writemiplib2017plotsanddecs, FALSE, DEFAULT_WRITEMIPLIB2017PLOTSANDDECS, NULL, NULL) );
1098  SCIP_CALL( SCIPaddBoolParam(scip, "write/miplib2017shortbasefeatures", "indicates whether base features for miplib 2017 should be shortened", &conshdlrdata->writemiplib2017shortbasefeatures, FALSE, DEFAULT_WRITEMIPLIB2017SHORTBASEFEATURES, NULL, NULL) );
1099  SCIP_CALL( SCIPaddBoolParam(scip, "detection/benders/enabled", "indicates whether benders detection is enabled", &conshdlrdata->detectbenders, FALSE, DEFAULT_DETECTBENDERS, NULL, NULL) );
1100 
1101  SCIP_CALL( SCIPaddStringParam(scip, "write/miplib2017featurefilepath", "path to the file for miplib2017 feature output", &conshdlrdata->writemiplib2017featurefilepath, FALSE, DEFAULT_WRITEMIPLIB2017FEATUREFILEPATH, NULL, NULL) );
1102  SCIP_CALL( SCIPaddStringParam(scip, "write/miplib2017matrixfilepath", "path to matrix gp file that is to write", &conshdlrdata->writemiplib2017matrixfilepath, FALSE, DEFAULT_WRITEMIPLIB2017MATRIXFILEPATH, NULL, NULL) );
1103  SCIP_CALL( SCIPaddStringParam(scip, "write/miplib2017decompfilepath", "path to decomp dec and gp files to write", &conshdlrdata->writemiplib2017decompfilepath, FALSE, DEFAULT_WRITEMIPLIB2017DECOMPFILEPATH, NULL, NULL) );
1104 
1105 
1106  SCIP_CALL( SCIPaddIntParam(scip, "detection/strong_detection/dualvalrandommethod",
1107  "Method for random dual values use for strong decomposition: 1) naive, 2) expected equality exponential distributed, 3) expected overestimation exponential distributed ", &conshdlrdata->strongdetectiondualvalrandommethod, FALSE,
1108  DEFAULT_DUALVALRANDOMMETHOD, 1, 3, NULL, NULL) );
1109 
1110  SCIP_CALL( SCIPaddRealParam(scip, "detection/strong_detection/coeffactororigvsrandom",
1111  " convex coefficient for orig dual val (1-this coef is factor for random dual value) ", &conshdlrdata->coeffactororigvsrandom, FALSE,
1112  DEFAULT_COEFFACTORORIGVSRANDOM, 0., 1., NULL, NULL) );
1113 
1114  SCIP_CALL( SCIPaddIntParam(scip, "detection/maxrounds",
1115  "Maximum number of detection loop rounds", &conshdlrdata->maxndetectionrounds, FALSE,
1116  DEFAULT_MAXDETECTIONROUNDS, 0, INT_MAX, NULL, NULL) );
1117 
1118  SCIP_CALL( SCIPaddIntParam(scip, "detection/maxnclassesfornblockcandidates",
1119  "Maximum number of classes a classifier can have to be used for voting nblockcandidates", &conshdlrdata->maxnclassesfornblockcandidates, FALSE,
1120  DEFAULT_MAXNCLASSESFORNBLOCKCANDIDATES, 0, INT_MAX, NULL, NULL) );
1121 
1122  SCIP_CALL( SCIPaddIntParam(scip, "detection/maxnclassesperclassifier",
1123  "Maximum number of classes per classifier", &conshdlrdata->maxnclassesperclassifier, FALSE,
1124  DEFAULT_MAXNCLASSES, 0, INT_MAX, NULL, NULL) );
1125 
1126  SCIP_CALL( SCIPaddIntParam(scip, "detection/aggregation/limitnconssperblock",
1127  "if this limit on the number of constraints of a block is exceeded the aggregation information for this block is not calculated ", &conshdlrdata->aggregationlimitnconssperblock, FALSE,
1128  DEFAULT_AGGREGATIONLIMITNCONSSPERBLOCK, 0, INT_MAX, NULL, NULL) );
1129 
1130  SCIP_CALL( SCIPaddIntParam(scip, "detection/aggregation/limitnvarsperblock",
1131  "if this limit on the number of variables of a block is exceeded the aggregation information for this block is not calculated ", &conshdlrdata->aggregationlimitnvarsperblock, FALSE,
1132  DEFAULT_AGGREGATIONLIMITNVARSPERBLOCK, 0, INT_MAX, NULL, NULL) );
1133 
1134 
1135  SCIP_CALL( SCIPaddIntParam(scip, "detection/maxnclassesperclassifierforlargeprobs",
1136  "Maximum number of classes per classifier for large problems (nconss + nvars >= 50000)", &conshdlrdata->maxnclassesperclassifierforlargeprobs, FALSE,
1137  DEFAULT_MAXNCLASSESLARGEPROBS, 0, INT_MAX, NULL, NULL) );
1138 
1139  SCIP_CALL( SCIPaddIntParam(scip, "detection/origprob/weightinggpresolvedoriginaldecomps",
1140  "Weighting method when comparing decompositions for presolved and unpresolved problem", &conshdlrdata->weightinggpresolvedoriginaldecomps, TRUE,
1141  NO_MODIF, 0, 3, NULL, NULL) );
1142 
1143  SCIP_CALL( SCIPaddIntParam(scip, "detection/scoretype",
1144  "indicates which score should be used for comparing (partial) decompositions (0:max white, 1: border area, 2:classic, 3:max foreseeing white, 4: ppc-max-white, 5:max foreseeing white with aggregation info, 6: ppc-max-white with aggregation info, 7: experimental benders score): ", &conshdlrdata->currscoretype, FALSE,
1145  scoretype::SETPART_FWHITE, 0, 7, NULL, NULL) );
1146 
1147 
1148 
1149  assert(conshdlrdata->candidates != NULL);
1150 
1151  return SCIP_OKAY;
1152 }
1153 
1155  SCIP* scip
1156  )
1157 {
1158  SCIP_CONSHDLR* conshdlr;
1159  SCIP_CONSHDLRDATA* conshdlrdata;
1160  assert(scip != NULL);
1161  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1162  assert( conshdlr != NULL );
1163 
1164  int ndetectedpresolved;
1165  int ndetectedunpresolved;
1166  int nuserpresolvedfull;
1167  int nuserpresolvedpartial;
1168  int nuserunpresolvedfull;
1169  int nuserunpresolvedpartial;
1170 
1171  char* scorename;
1172 
1173  size_t i;
1174 
1175  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1176  assert(conshdlrdata != NULL);
1177 
1179 
1180  ndetectedpresolved = 0;
1181  ndetectedunpresolved = 0;
1182  nuserpresolvedfull = 0;
1183  nuserpresolvedpartial = 0;
1184  nuserunpresolvedfull = 0;
1185  nuserunpresolvedpartial = 0;
1186 
1187 // std::sort( conshdlrdata->listall->size(), conshdlrdata->listall->size(), sort_pred() );
1188 
1190  for ( i = 0; i < conshdlrdata->listall->size(); ++i )
1191  {
1192  SeeedPtr seeed;
1193  seeed = conshdlrdata->listall->at(i);
1194  if( seeed->isComplete() && seeed->getUsergiven() == gcg::USERGIVEN::NOT && !seeed->isFromUnpresolved() )
1195  ++ndetectedpresolved;
1196  if( seeed->isComplete() && seeed->getUsergiven() == gcg::USERGIVEN::NOT && seeed->isFromUnpresolved() )
1197  ++ndetectedunpresolved;
1199  ++nuserpresolvedfull;
1200  if( !seeed->isComplete() && seeed->getUsergiven() == gcg::USERGIVEN::PARTIAL && !seeed->isFromUnpresolved() )
1201  ++nuserpresolvedpartial;
1203  ++nuserunpresolvedfull;
1204  if( !seeed->isComplete() && seeed->getUsergiven() == gcg::USERGIVEN::PARTIAL && seeed->isFromUnpresolved() )
1205  ++nuserunpresolvedpartial;
1206 
1207  }
1208 
1209  SCIPdialogMessage(scip, NULL, "\n");
1210  SCIPdialogMessage(scip, NULL, "============================================================================================= ");
1211  SCIPdialogMessage(scip, NULL, "\n");
1212  SCIPdialogMessage(scip, NULL, "Summary presolved original \n");
1213  SCIPdialogMessage(scip, NULL, " --------- -------- \n");
1214  SCIPdialogMessage(scip, NULL, "detected ");
1215  SCIPdialogMessage(scip, NULL, "%9d ", ndetectedpresolved );
1216  SCIPdialogMessage(scip, NULL, "%8d\n", ndetectedunpresolved );
1217  SCIPdialogMessage(scip, NULL, "user given (partial) ");
1218  SCIPdialogMessage(scip, NULL, "%9d ", nuserpresolvedpartial );
1219  SCIPdialogMessage(scip, NULL, "%8d\n", nuserunpresolvedpartial );
1220  SCIPdialogMessage(scip, NULL, "user given (full) ");
1221  SCIPdialogMessage(scip, NULL, "%9d ", nuserpresolvedfull );
1222  SCIPdialogMessage(scip, NULL, "%8d\n", nuserunpresolvedfull );
1223 
1224  SCIPdialogMessage(scip, NULL, "============================================================================================= \n");
1225  SCIPdialogMessage(scip, NULL, " id nbloc nmacon nlivar nmavar nstlva %.6s history pre nopcon nopvar usr sel \n", scorename );
1226  SCIPdialogMessage(scip, NULL, " ---- ----- ------ ------ ------ ------ ------ ------- --- ------ ------ --- --- \n");
1227 
1228  SCIPfreeBlockMemoryArrayNull(scip, &scorename, SCIP_MAXSTRLEN);
1229 
1230 
1231  return SCIP_OKAY;
1232 }
1233 
1234 
1236 (
1237  SCIP* scip
1238  )
1239 {
1240  SCIP_CONSHDLR* conshdlr;
1241  SCIP_CONSHDLRDATA* conshdlrdata;
1242  assert(scip != NULL);
1243  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1244  assert( conshdlr != NULL );
1245 
1246  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1247  assert(conshdlrdata != NULL);
1248 
1249  if ( conshdlrdata->curruserseeed->isFromUnpresolved() )
1250  conshdlrdata->curruserseeed->displaySeeed();
1251  else
1252  conshdlrdata->curruserseeed->displaySeeed();
1253 
1254 
1255  return SCIP_OKAY;
1256 }
1257 
1263  SCIP* scip
1264  )
1265 {
1266  SCIP_CONSHDLR* conshdlr;
1267  SCIP_CONSHDLRDATA* conshdlrdata;
1268  assert(scip != NULL);
1269  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1270  assert( conshdlr != NULL );
1271 
1272  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1273  assert(conshdlrdata != NULL);
1274 
1275 
1276  size_t i;
1277 
1278  for( i = conshdlrdata->startidvisu; i < (size_t) conshdlrdata->startidvisu + (size_t) conshdlrdata->selectvisulength && i < conshdlrdata->listall->size(); ++i)
1279  {
1280  SeeedPtr seeed;
1281 
1282  seeed = conshdlrdata->listall->at(i);
1283 
1284  assert( seeed->checkConsistency( ) );
1285 
1286  SCIPdialogMessage(scip, NULL, " %4d ", i );
1287  SCIPdialogMessage(scip, NULL, "%5d ", seeed->getNBlocks() );
1288  SCIPdialogMessage(scip, NULL, "%6d ", seeed->getNMasterconss() );
1289  SCIPdialogMessage(scip, NULL, "%6d ", seeed->getNLinkingvars() );
1290  SCIPdialogMessage(scip, NULL, "%6d ", seeed->getNMastervars() );
1291  SCIPdialogMessage(scip, NULL, "%6d ", seeed->getNTotalStairlinkingvars() );
1292  if( seeed->isComplete() )
1293  SCIPdialogMessage(scip, NULL, "%.4f ", seeed->getScore(SCIPconshdlrdataGetScoretype(conshdlrdata)) );
1294  else
1295  SCIPdialogMessage(scip, NULL, "<=%.2f ", seeed->getScore(SCIPconshdlrdataGetScoretype(conshdlrdata)) );
1296  SCIPdialogMessage(scip, NULL, "%7s ", seeed->getDetectorChainString() );
1297  SCIPdialogMessage(scip, NULL, "%3s ", (seeed->isFromUnpresolved() ? "no" : "yes") );
1298  SCIPdialogMessage(scip, NULL, "%6d ", seeed->getNOpenconss() );
1299  SCIPdialogMessage(scip, NULL, "%6d ", seeed->getNOpenvars() );
1300  SCIPdialogMessage(scip, NULL, "%3s ", (seeed->getUsergiven() == gcg::USERGIVEN::NOT ? "no" : "yes") );
1301  SCIPdialogMessage(scip, NULL, "%3s \n", (seeed->isSelected() ? "yes" : "no") );
1302  }
1303 
1304  SCIPdialogMessage(scip, NULL, "============================================================================================= \n");
1305 
1306  return SCIP_OKAY;
1307 }
1308 
1309 
1314 SCIP_RETCODE SCIPconshdlrDecompAddDecdecomp(
1315  SCIP* scip,
1316  DEC_DECOMP* decdecomp
1317  )
1318 {
1319  SCIP_CONSHDLR* conshdlr;
1320  SCIP_CONSHDLRDATA* conshdlrdata;
1321  assert(scip != NULL);
1322  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1323  assert( conshdlr != NULL );
1324 
1325  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1326  assert(conshdlrdata != NULL);
1327 
1328  SeeedPtr seeed;
1329 
1330  if( conshdlrdata->seeedpool == NULL )
1332 
1333  DECdecompSetPresolved(decdecomp, TRUE);
1334 
1335  SCIP_CALL( conshdlrdata->seeedpool->createSeeedFromDecomp(decdecomp, &seeed) );
1336 
1337  SCIP_CALL( SCIPconshdlrDecompAddSeeed(scip, seeed) );
1338 
1339  DECdecompFree(scip, &decdecomp);
1340 
1341  return SCIP_OKAY;
1342 }
1343 
1345 //SCIP_RETCODE SCIPconshdlrDecompAddConsToBlock(
1346 // SCIP* scip, /**< SCIP data structure */
1347 // SCIP_HASHMAP* consToBlock, /**< possible incomplete detection info */
1348 // SCIP_HASHMAP* varsToBlock /**< possible incomplete detection info stored as two hashmaps*/
1349 // )
1350 //{
1351 // SCIP_CONSHDLR* conshdlr;
1352 // SCIP_CONSHDLRDATA* conshdlrdata;
1353 // assert(scip != NULL);
1354 // conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1355 // assert( conshdlr != NULL );
1356 //
1357 // conshdlrdata = SCIPconshdlrGetData(conshdlr);
1358 // assert(conshdlrdata != NULL);
1359 //
1360 // return SCIP_ERROR;
1361 //
1363 //
1364 // }
1365 
1366 SCIP_RETCODE SCIPconshdlrDecompShowLegend(
1367  SCIP* scip
1368  )
1369 {
1370 
1371  SCIP_CONSHDLR* conshdlr;
1372  SCIP_CONSHDLRDATA* conshdlrdata;
1373  assert(scip != NULL);
1374  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1375  assert( conshdlr != NULL );
1376  char * scorename;
1377  char * scoredescr;
1378 
1379  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1380  assert(conshdlrdata != NULL);
1381 
1384 
1385 
1386  SCIPdialogMessage(scip, NULL, "List of included detectors for decompositions histories: \n" );
1387 
1388  SCIPdialogMessage(scip, NULL, "\n%30s %4s\n", "detector" , "char" );
1389  SCIPdialogMessage(scip, NULL, "%30s %4s\n", "--------" , "----" );
1390 
1391  for( int det = 0; det < conshdlrdata->ndetectors; ++det )
1392  {
1393  DEC_DETECTOR* detector;
1394 
1395  detector = conshdlrdata->detectors[det];
1396 
1397  SCIPdialogMessage(scip, NULL, "%30s %4c\n", DECdetectorGetName(detector), DECdetectorGetChar(detector) );
1398  }
1399  SCIPdialogMessage(scip, NULL, "%30s %4s\n", "given by user" , "U" );
1400 
1401  SCIPdialogMessage(scip, NULL, "\n" );
1402 
1403  SCIPdialogMessage(scip, NULL, "============================================================================================= \n");
1404 
1405 // SCIPdialogMessage(scip, NULL, " id nbloc nmacon nlivar nmavar nstlva maxwhi history pre nopcon nopvar"
1406 // " usr"
1407 // " sel \n");
1408 // SCIPdialogMessage(scip, NULL, " ---- ----- ------ ------ ------ ------ ------ ------- --- ------ ------"
1409 // " ---"
1410 // " --- \n");
1411 
1412  SCIPdialogMessage(scip, NULL, "\n" );
1413 
1414  SCIPdialogMessage(scip, NULL, "List of abbreviations of decomposition table \n" );
1415  SCIPdialogMessage(scip, NULL, "\n" );
1416  SCIPdialogMessage(scip, NULL, "%30s %s\n", "abbreviation", "description");
1417  SCIPdialogMessage(scip, NULL, "%30s %s\n", "------------", "-----------");
1418  SCIPdialogMessage(scip, NULL, "%30s %s\n", "id", "id of the decomposition");
1419  SCIPdialogMessage(scip, NULL, "%30s %s\n", "nbloc", "number of blocks");
1420  SCIPdialogMessage(scip, NULL, "%30s %s\n", "nmacon", "number of master constraints");
1421  SCIPdialogMessage(scip, NULL, "%30s %s\n", "nlivar", "number of linking variables");
1422  SCIPdialogMessage(scip, NULL, "%30s %s\n", "nmavar", "number of master variables (do not occur in blocks)");
1423  SCIPdialogMessage(scip, NULL, "%30s %s\n", "nstlva", "number of stairlinking variables (disjoint from linking variables)");
1424  SCIPdialogMessage(scip, NULL, "%30s %s\n", scorename, scoredescr);
1425  SCIPdialogMessage(scip, NULL, "%30s %s\n", "history", "list of detector chars worked on this decomposition ");
1426  SCIPdialogMessage(scip, NULL, "%30s %s\n", "pre", "is this decomposition for the presolved problem");
1427  SCIPdialogMessage(scip, NULL, "%30s %s\n", "nopcon", "number of open constraints");
1428  SCIPdialogMessage(scip, NULL, "%30s %s\n", "nopvar", "number of open variables");
1429  SCIPdialogMessage(scip, NULL, "%30s %s\n", "usr", "was this decomposition given by the user");
1430  SCIPdialogMessage(scip, NULL, "%30s %s\n", "sel", "is this decomposition selected at the moment");
1431 
1432  SCIPdialogMessage(scip, NULL, "\n============================================================================================= \n");
1433 
1434 
1435 SCIPfreeBlockMemoryArrayNull(scip, &scorename, SCIP_MAXSTRLEN);
1436 SCIPfreeBlockMemoryArrayNull(scip, &scoredescr, SCIP_MAXSTRLEN);
1437 
1438 return SCIP_OKAY;
1439 }
1440 
1442  SCIP* scip
1443  )
1444 {
1445 
1446  assert(scip != NULL);
1447 
1448  SCIPdialogMessage(scip, NULL, "Options to proceed: \n" );
1449  SCIPdialogMessage(scip, NULL, "\n" );
1450  SCIPdialogMessage(scip, NULL, "%30s %s\n", "option", "description");
1451  SCIPdialogMessage(scip, NULL, "%30s %s\n", "------", "-----------");
1452  SCIPdialogMessage(scip, NULL, "%30s %s\n", "conss", "assign unassigned constraints to master/blocks");
1453  SCIPdialogMessage(scip, NULL, "%30s %s\n", "vars", "assign unassigned variables to master(only)/linking/blocks");
1454  SCIPdialogMessage(scip, NULL, "%30s %s\n", "refine", "refine implicit constraint and variables assignments");
1455  SCIPdialogMessage(scip, NULL, "%30s %s\n", "finish", "choose a finishing detector that completes the decomposition");
1456  SCIPdialogMessage(scip, NULL, "%30s %s\n", "quit", "quit the modification process and returns to main menu");
1457  SCIPdialogMessage(scip, NULL, "%30s %s\n", "undo", "last modification is undone (atm only the last modification can be undone)");
1458  SCIPdialogMessage(scip, NULL, "%30s %s\n", "visualize", "shows a visualization of the current decomposition ");
1459  SCIPdialogMessage(scip, NULL, "%30s %s\n", "propagate", "list all detectors that can propagate the current seeed and apply one to propagate it");
1460  SCIPdialogMessage(scip, NULL, "%30s %s\n", "finish", "list all detectors that can finish the current seeed and apply one to finish it");
1461  SCIPdialogMessage(scip, NULL, "%30s %s\n", "postprocess", "apply postprocessing to a finished seeed by selecting a suitable postprocessor");
1462  SCIPdialogMessage(scip, NULL, "\n============================================================================================= \n");
1463 
1464 
1465 
1466 return SCIP_OKAY;
1467 }
1468 
1469 
1470 
1472  SCIP* scip,
1473  SCIP_DIALOGHDLR* dialoghdlr,
1474  SCIP_DIALOG* dialog
1475  )
1476 {
1477  SCIP_CONSHDLR* conshdlr;
1478  SCIP_CONSHDLRDATA* conshdlrdata;
1479  char* ntovisualize;
1480  SCIP_Bool endoffile;
1481  int newval;
1482 
1483  int commandlen;
1484 
1485  assert(scip != NULL);
1486  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1487  assert( conshdlr != NULL );
1488 
1489  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1490  assert(conshdlrdata != NULL);
1491 
1492  SCIPdialogMessage(scip, NULL, "Please specify the maximum number of decompositions displayed at once in the table [%d]:\n", conshdlrdata->selectvisulength );
1493  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, " ", &ntovisualize, &endoffile) );
1494  commandlen = strlen(ntovisualize);
1495 
1496  newval = conshdlrdata->selectvisulength;
1497  if( commandlen != 0)
1498  newval = atoi(ntovisualize);
1499 
1500  if (newval != 0)
1501  conshdlrdata->selectvisulength = newval;
1502 
1503  return SCIP_OKAY;
1504 }
1505 
1507  SCIP* scip,
1508  SCIP_DIALOGHDLR* dialoghdlr,
1509  SCIP_DIALOG* dialog
1510  )
1511 {
1512  SCIP_CONSHDLR* conshdlr;
1513  SCIP_CONSHDLRDATA* conshdlrdata;
1514  char* ntovisualize;
1515  SCIP_Bool endoffile;
1516  int idtovisu;
1517 
1518  int commandlen;
1519 
1520  assert(scip != NULL);
1521  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1522  assert( conshdlr != NULL );
1523 
1524  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1525  assert(conshdlrdata != NULL);
1526 
1527  SCIPdialogMessage(scip, NULL, "Please specify the id of the decomposition to be visualized:\n");
1528  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, " ", &ntovisualize, &endoffile) );
1529  commandlen = strlen(ntovisualize);
1530 
1531  idtovisu = -1;
1532  if( commandlen != 0 )
1533  idtovisu = atoi(ntovisualize);
1534 
1535  /* check whether ID is in valid range */
1536  if( (int)conshdlrdata->listall->size() == 0 )
1537  {
1538  SCIPinfoMessage(scip, NULL, "No decompositions available. Please detect first.\n");
1539  return SCIP_OKAY;
1540  }
1541  if( commandlen == 0 || idtovisu < 0 || idtovisu >= (int)conshdlrdata->listall->size() )
1542  {
1543  SCIPdialogMessage( scip, NULL, "This id is out of range." );
1544  return SCIP_OKAY;
1545  }
1546 
1547 
1548 // conshdlrdata->listall->at(idtovisu)->displaySeeed(seeedpool);
1549 // conshdlrdata->listall->at(idtovisu)->displayConss(seeedpool);
1550 // conshdlrdata->listall->at(idtovisu)->displayVars(seeedpool);
1551 
1552  conshdlrdata->listall->at(idtovisu)->showVisualisation();
1553 
1554  return SCIP_OKAY;
1555 }
1556 
1557 
1562 (
1563  SCIP* scip,
1564  SCIP_DIALOGHDLR* dialoghdlr,
1565  SCIP_DIALOG* dialog
1566  )
1567 {
1568  SCIP_CONSHDLR* conshdlr;
1569  SCIP_CONSHDLRDATA* conshdlrdata;
1570  char* ntocalcstrong;
1571  SCIP_Bool endoffile;
1572  int idtocalcstrong;
1573  int commandlen;
1574 
1575  assert( scip != NULL );
1576  conshdlr = SCIPfindConshdlr( scip, CONSHDLR_NAME );
1577  assert( conshdlr != NULL );
1578 
1579  conshdlrdata = SCIPconshdlrGetData( conshdlr );
1580  assert( conshdlrdata != NULL );
1581 
1582  /* read the id of the decomposition to be calculate strong decomp score */
1583  SCIPdialogMessage( scip, NULL, "Please specify the id of the decomposition that should be evaluated by strong decomposition score:\n" );
1584  SCIP_CALL( SCIPdialoghdlrGetWord( dialoghdlr, dialog, " ", &ntocalcstrong, &endoffile ) );
1585  commandlen = strlen( ntocalcstrong );
1586 
1587  idtocalcstrong = -1;
1588  if( commandlen != 0 )
1589  {
1590  std::stringstream convert( ntocalcstrong );
1591  convert >> idtocalcstrong;
1592 
1593  if ( idtocalcstrong == 0 && ntocalcstrong[0] != '0' )
1594  {
1595  idtocalcstrong = -1;
1596  }
1597  }
1598 
1599  /* call calculation strong decomp score method according to chosen parameters */
1600  if( 0 <= idtocalcstrong && idtocalcstrong < (int)conshdlrdata->listall->size() )
1601  {
1602  SCIP_Real score;
1603  gcg::Seeedpool* seeedpool = ( conshdlrdata->listall->at( idtocalcstrong )->isFromUnpresolved() ?
1604  conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool );
1605  seeedpool->calcStrongDecompositionScore(conshdlrdata->listall->at( idtocalcstrong ), &score);
1606  SCIPdialogMessage( scip, NULL, "Strong decomposition score of this decomposition is %f.", score) ;
1607  }
1608  else
1609  {
1610  SCIPdialogMessage( scip, NULL, "This is not an existing id." );
1611  }
1612 
1613  return SCIP_OKAY;
1614 }
1615 
1616 
1617 
1621 SCIP_RETCODE SCIPconshdlrDecompSelectInspect(
1622  SCIP* scip,
1623  SCIP_DIALOGHDLR* dialoghdlr,
1624  SCIP_DIALOG* dialog
1625  )
1626 {
1627  SCIP_CONSHDLR* conshdlr;
1628  SCIP_CONSHDLRDATA* conshdlrdata;
1629  char* ntoinspect;
1630  char* ndetaillevel;
1631  SCIP_Bool endoffile;
1632  int idtoinspect;
1633  int detaillevel;
1634 
1635  int commandlen;
1636 
1637  assert( scip != NULL );
1638  conshdlr = SCIPfindConshdlr( scip, CONSHDLR_NAME );
1639  assert( conshdlr != NULL );
1640 
1641  conshdlrdata = SCIPconshdlrGetData( conshdlr );
1642  assert( conshdlrdata != NULL );
1643 
1644  /* read the id of the decomposition to be inspected */
1645  SCIPdialogMessage( scip, NULL, "Please specify the id of the decomposition to be inspected:\n");
1646  SCIP_CALL( SCIPdialoghdlrGetWord( dialoghdlr, dialog, " ", &ntoinspect, &endoffile ) );
1647  commandlen = strlen( ntoinspect );
1648 
1649  idtoinspect = -1;
1650  if( commandlen != 0 )
1651  idtoinspect = atoi( ntoinspect );
1652 
1653  /* check whether ID is in valid range */
1654  if( idtoinspect < 0 || idtoinspect >= (int)conshdlrdata->listall->size() )
1655  {
1656  SCIPdialogMessage( scip, NULL, "This id is out of range." );
1657  return SCIP_PARAMETERWRONGVAL;
1658  }
1659 
1660  /* read the desired detail level; for wrong input, it is set to 1 by default */
1661  SCIPdialogMessage( scip, NULL, "Please specify the detail level:\n 0 - brief overview\n 1 - block and detector info (default)\n 2 - cons and var assignments\n" );
1662  SCIP_CALL( SCIPdialoghdlrGetWord( dialoghdlr, dialog, " ", &ndetaillevel, &endoffile ) );
1663  commandlen = strlen( ndetaillevel );
1664 
1665  detaillevel = 1;
1666  if( commandlen != 0 )
1667  {
1668  std::stringstream convert( ndetaillevel );
1669  convert >> detaillevel;
1670 
1671  if ( detaillevel < 0 || ( detaillevel == 0 && ndetaillevel[0] != '0' ) )
1672  {
1673  detaillevel = 1;
1674  }
1675  }
1676 
1677  /* call displayInfo method according to chosen parameters */
1678  assert( 0 <= idtoinspect && idtoinspect < (int)conshdlrdata->listall->size() );
1679  conshdlrdata->listall->at( idtoinspect )->displayInfo( detaillevel );
1680 
1681  return SCIP_OKAY;
1682 }
1683 
1685 (
1686  SCIP* scip,
1687  SCIP_DIALOGHDLR* dialoghdlr,
1688  SCIP_DIALOG* dialog
1689  )
1690 {
1691  SCIP_CONSHDLR* conshdlr;
1692  SCIP_CONSHDLRDATA* conshdlrdata;
1693 
1694  assert(scip != NULL);
1695  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1696  assert( conshdlr != NULL );
1697 
1698  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1699  assert(conshdlrdata != NULL);
1700 
1701  conshdlrdata->curruserseeed->showVisualisation();
1702 
1703  return SCIP_OKAY;
1704 }
1705 
1706 SCIP_RETCODE SCIPconshdlrDecompToolboxChoose(
1707  SCIP* scip,
1708  SCIP_DIALOGHDLR* dialoghdlr,
1709  SCIP_DIALOG* dialog
1710  )
1711 {
1712  SCIP_CONSHDLR* conshdlr;
1713  SCIP_CONSHDLRDATA* conshdlrdata;
1714  char* ntochoose;
1715  SCIP_Bool endoffile;
1716  int idtochoose;
1717 
1718  int commandlen;
1719 
1720  assert(scip != NULL);
1721  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1722  assert( conshdlr != NULL );
1723 
1724  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1725  assert(conshdlrdata != NULL);
1726 
1727  SCIPdialogMessage(scip, NULL, "Please specify the id of the (partial) decomposition to be chosen for modification:\n", conshdlrdata->selectvisulength );
1728  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, " ", &ntochoose, &endoffile) );
1729  commandlen = strlen(ntochoose);
1730 
1731  idtochoose = conshdlrdata->selectvisulength;
1732  if( commandlen != 0)
1733  idtochoose = atoi(ntochoose);
1734 
1735  if ( commandlen == 0 || idtochoose < 0 || idtochoose >= (int)conshdlrdata->listall->size() )
1736  {
1737  SCIPdialogMessage( scip, NULL, "This id is out of range." );
1738  return SCIP_PARAMETERWRONGVAL;
1739  }
1740 
1741  if( conshdlrdata->curruserseeed != NULL )
1742  delete conshdlrdata->curruserseeed;
1743 
1744  conshdlrdata->curruserseeed = new gcg::Seeed( conshdlrdata->listall->at(idtochoose) );
1745 
1746  return SCIP_OKAY;
1747 }
1748 
1749 
1750 SCIP_RETCODE SCIPconshdlrDecompExploreSelect(
1751  SCIP* scip,
1752  SCIP_DIALOGHDLR* dialoghdlr,
1753  SCIP_DIALOG* dialog
1754  )
1755 {
1756  SCIP_CONSHDLR* conshdlr;
1757  SCIP_CONSHDLRDATA* conshdlrdata;
1758  char* ntovisualize;
1759  SCIP_Bool endoffile;
1760  int idtovisu;
1761  SeeedPtr toselect;
1762 
1763  int commandlen;
1764 
1765  assert(scip != NULL);
1766  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1767  assert( conshdlr != NULL );
1768 
1769  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1770  assert(conshdlrdata != NULL);
1771 
1772  SCIPdialogMessage(scip, NULL, "Please specify the id of the decomposition to be selected:\n", conshdlrdata->selectvisulength );
1773  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, " ", &ntovisualize, &endoffile) );
1774  commandlen = strlen(ntovisualize);
1775 
1776  idtovisu = conshdlrdata->selectvisulength;
1777  if( commandlen != 0)
1778  idtovisu = atoi(ntovisualize);
1779 
1780 // seeedpool = (conshdlrdata->listall->at(idtovisu)->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool );
1781  toselect = conshdlrdata->listall->at(idtovisu);
1782 
1783  toselect->setSelected(!toselect->isSelected() );
1784 
1785  if( !toselect->isSelected() )
1786  {
1787  conshdlrdata->selected->erase( find( conshdlrdata->selected->begin(), conshdlrdata->selected->end(), idtovisu) );
1788  }
1789  else
1790  {
1791  std::cout << "is selected !!!!!!!!" << toselect->isSelected() <<std::endl;
1792  conshdlrdata->selected->push_back(idtovisu);
1793  assert(toselect->isSelected());
1794  }
1795 
1796  conshdlrdata->selectedexists = (conshdlrdata->selected->size() > 0);
1797 
1798  return SCIP_OKAY;
1799 }
1800 
1801 
1802 SCIP_RETCODE SCIPconshdlrDecompShowHelp(
1803  SCIP* scip
1804  )
1805 {
1806 
1807  assert(scip != NULL);
1808 
1809  SCIPdialogMessage(scip, NULL, "============================================================================================= \n");
1810  SCIPdialogMessage(scip, NULL, "\n" );
1811  SCIPdialogMessage(scip, NULL, "List of selection commands \n" );
1812  SCIPdialogMessage(scip, NULL, "\n" );
1813  SCIPdialogMessage(scip, NULL, "%30s %s\n", "command", "description");
1814  SCIPdialogMessage(scip, NULL, "%30s %s\n", "-------", "-----------");
1815  SCIPdialogMessage(scip, NULL, "%30s %s\n", "select", "selects/unselects decomposition with given id");
1816 // SCIPdialogMessage(scip, NULL, "%30s %s\n", "toolbox", "calls the decomposition toolbox to modify or create a decomposition");
1817  SCIPdialogMessage(scip, NULL, "%30s %s\n", "modify", "modify an existing decomposition");
1818  SCIPdialogMessage(scip, NULL, "%30s %s\n", "create", "create a new decomposition");
1819  SCIPdialogMessage(scip, NULL, "%30s %s\n", "back", "displays the preceding decompositions (if there are any)");
1820  SCIPdialogMessage(scip, NULL, "%30s %s\n", "next", "displays the subsequent decompositions (if there are any)");
1821  SCIPdialogMessage(scip, NULL, "%30s %s\n", "top", "displays the first decompositions");
1822  SCIPdialogMessage(scip, NULL, "%30s %s\n", "end", "displays the last decompositions");
1823  SCIPdialogMessage(scip, NULL, "%30s %s\n", "legend", "displays the legend for table header and history abbreviations");
1824  SCIPdialogMessage(scip, NULL, "%30s %s\n", "help", "displays this help");
1825  SCIPdialogMessage(scip, NULL, "%30s %s\n", "dispNEntries", "modifies the number of displayed decompositions ");
1826  SCIPdialogMessage(scip, NULL, "%30s %s\n", "quit", "finishes decomposition explorer and goes back to main menu");
1827  SCIPdialogMessage(scip, NULL, "%30s %s\n", "visualize", "experimental feature: visualizes the specified decomposition ");
1828  SCIPdialogMessage(scip, NULL, "%30s %s\n", "inspect", "displays detailed information for the specified decomposition ");
1829  SCIPdialogMessage(scip, NULL, "%30s %s\n", "calc_strong", "calculates and displays the strong decomposition score for this decomposition");
1830 
1831  SCIPdialogMessage(scip, NULL, "\n============================================================================================= \n");
1832 
1833 
1834  return SCIP_OKAY;
1835 }
1836 
1838  SCIP* scip
1839  )
1840 {
1841  SCIP_Bool benders;
1842 
1843  SCIPgetBoolParam(scip, "detection/benders/enabled", &benders);
1844 
1845  return benders;
1846 }
1847 
1848 
1850  SCIP* scip
1851  )
1852 {
1853 
1854  SCIP_CONSHDLR* conshdlr;
1855  SCIP_CONSHDLRDATA* conshdlrdata;
1856 
1857 
1858  assert(scip != NULL);
1859  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1860  assert( conshdlr != NULL );
1861 
1862  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1863  assert(conshdlrdata != NULL);
1864 
1865  if( conshdlrdata->candidates->size() == 0 )
1866  return FALSE;
1867 
1868  return conshdlrdata->candidates->at(0).first->isFromUnpresolved();
1869 }
1870 
1871 
1872 SCIP_RETCODE SCIPconshdlrDecompExecSelect(
1873  SCIP* scip,
1874  SCIP_DIALOGHDLR* dialoghdlr,
1875  SCIP_DIALOG* dialog )
1876 {
1877 
1878  SCIP_CONSHDLR* conshdlr;
1879  SCIP_CONSHDLRDATA* conshdlrdata;
1880  SCIP_Bool finished;
1881  char* command;
1882  SCIP_Bool endoffile;
1883 
1884  assert(scip != NULL);
1885  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
1886  assert( conshdlr != NULL );
1887  finished = FALSE;
1888 
1889  conshdlrdata = SCIPconshdlrGetData(conshdlr);
1890  assert(conshdlrdata != NULL);
1891 
1892 
1896  while ( !finished )
1897  {
1898  int commandlen;
1899 
1901  // SCIP_CALL( SCIPconshdlrDecompUpdateSeeedlist(scip) );
1902 
1904 
1906 
1907 
1908 
1909  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Please enter command or decomposition id to select (or \"h\" for help) : \nGCG/explore> ", &command, &endoffile) );
1910 
1911  commandlen = strlen(command);
1912 
1913  if( strncmp( command, "back", commandlen) == 0 )
1914  {
1915  conshdlrdata->startidvisu -= conshdlrdata->selectvisulength;
1916  if(conshdlrdata->startidvisu < 0 )
1917  conshdlrdata->startidvisu = 0;
1918  continue;
1919  }
1920  if( strncmp( command, "next", commandlen) == 0 )
1921  {
1922  conshdlrdata->startidvisu += conshdlrdata->selectvisulength;
1923  if( conshdlrdata->startidvisu > (int) conshdlrdata->listall->size() - conshdlrdata->selectvisulength )
1924  conshdlrdata->startidvisu = conshdlrdata->listall->size() - conshdlrdata->selectvisulength ;
1925  continue;
1926  }
1927  if( strncmp( command, "top", commandlen) == 0 )
1928  {
1929  conshdlrdata->startidvisu = 0;
1930  continue;
1931  }
1932  if( strncmp( command, "end", commandlen) == 0 )
1933  {
1934  conshdlrdata->startidvisu = conshdlrdata->listall->size() - conshdlrdata->selectvisulength ;
1935  continue;
1936  }
1937 
1938  if( strncmp( command, "quit", commandlen) == 0 )
1939  {
1940  finished = TRUE;
1942  continue;
1943  }
1944 
1945  if( strncmp( command, "legend", commandlen) == 0 )
1946  {
1947  SCIP_CALL(SCIPconshdlrDecompShowLegend(scip) );
1948  continue;
1949  }
1950 
1951  if( strncmp( command, "dispNEntries", commandlen) == 0 )
1952  {
1953  SCIP_CALL(SCIPconshdlrDecompModifyNVisualized(scip, dialoghdlr, dialog) );
1954  continue;
1955  }
1956 
1957  if( strncmp( command, "help", commandlen) == 0 )
1958  {
1959  SCIP_CALL(SCIPconshdlrDecompShowHelp(scip) );
1960  continue;
1961  }
1962 
1963  if( strncmp( command, "visualize", commandlen) == 0 )
1964  {
1965  SCIP_CALL(SCIPconshdlrDecompSelectVisualize(scip, dialoghdlr, dialog ) );
1966  continue;
1967  }
1968 
1969  if( strncmp( command, "inspect", commandlen) == 0 )
1970  {
1971  SCIP_CALL( SCIPconshdlrDecompSelectInspect( scip, dialoghdlr, dialog ) );
1972  continue;
1973  }
1974 
1975  if( strncmp( command, "calc_strong", commandlen) == 0 )
1976  {
1977  SCIP_CALL( SCIPconshdlrDecompSelectCalcStrongDecompositionScore( scip, dialoghdlr, dialog ) );
1978  continue;
1979  }
1980 
1981  if( strncmp( command, "select", commandlen) == 0 )
1982  {
1983  SCIP_CALL(SCIPconshdlrDecompExploreSelect(scip, dialoghdlr, dialog ) );
1984  continue;
1985  }
1986 
1987  if( strncmp( command, "toolbox", commandlen) == 0 )
1988  {
1989  // deprecated, use create/modify instead
1990  SCIP_CALL( SCIPconshdlrDecompExecToolbox(scip, dialoghdlr, dialog) );
1992  continue;
1993  }
1994  if( strncmp( command, "modify", commandlen) == 0 )
1995  {
1996  SCIP_CALL( SCIPconshdlrDecompExecToolboxModify(scip, dialoghdlr, dialog) );
1998  continue;
1999  }
2000  if( strncmp( command, "create", commandlen) == 0 )
2001  {
2002  SCIP_CALL( SCIPconshdlrDecompExecToolboxCreate(scip, dialoghdlr, dialog) );
2004  continue;
2005  }
2006  }
2007 
2008  return SCIP_OKAY;
2009 }
2010 
2012 SCIP* scip,
2013 SCIP_DIALOGHDLR* dialoghdlr,
2014 SCIP_DIALOG* dialog )
2015 {
2016 
2017  SCIP_CONSHDLR* conshdlr;
2018  SCIP_CONSHDLRDATA* conshdlrdata;
2019  SCIP_Bool matching;
2020  char* consregex;
2021  char* command;
2022  char* command2;
2023  SCIP_Bool endoffile;
2024  int commandlen;
2025 
2026  assert(scip != NULL);
2027  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
2028  assert( conshdlr != NULL );
2029  matching = FALSE;
2030 
2031 
2032  conshdlrdata = SCIPconshdlrGetData(conshdlr);
2033  assert(conshdlrdata != NULL);
2034 
2035  SeeedPtr seeed = conshdlrdata->curruserseeed;
2037  std::vector<int> matchingconss = std::vector<int>(0);
2038 
2039  seeedpool = seeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool;
2041  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Please specify a regular expression (modified ECMAScript regular expression grammar) matching the names of unassigned constraints you want to assign : \nGCG/toolbox> ", &consregex, &endoffile) );
2042 
2045  std::regex expr;
2046  try {
2047  expr = std::regex(consregex);//, std::regex_constants::extended);
2048  }
2049  catch (const std::regex_error& e) {
2050  std::cout << "regex_error caught: " << e.what() << '\n';
2051  if (e.code() == std::regex_constants::error_brack) {
2052  std::cout << "The code was error_brack\n";
2053  }
2054  }
2055 
2056  for( int oc = 0; oc < seeed->getNOpenconss(); ++oc )
2057  {
2058  const char* consname;
2059 
2060  consname = SCIPconsGetName( seeedpool->getConsForIndex(seeed->getOpenconss()[oc] ) );
2061 
2062 
2063  if( std::regex_match(consname, expr) )
2064  {
2065  matching = TRUE;
2066  matchingconss.push_back(seeed->getOpenconss()[oc]);
2067  SCIPdebugMessage(" consname %s matches regex %s \n", consname, consregex );
2068  } else
2069  SCIPdebugMessage(" consname %s does not match regex %s \n", consname, consregex);
2070  }
2071 
2072  if( !matching )
2073  {
2074  SCIPdialogMessage(scip, NULL, " There are no unassigned constraints with names matching given regular expression. Return to toolbox main menu.\n");
2075  return SCIP_OKAY;
2076  }
2077 
2078  if( conshdlrdata->lastuserseeed != NULL)
2079  delete conshdlrdata->lastuserseeed;
2080  conshdlrdata->lastuserseeed = new gcg::Seeed( conshdlrdata->curruserseeed) ;
2081 
2082 
2083  if( matchingconss.size() > 10 )
2084  SCIPdebugMessage(" There are %d unassigned constraints with names matching given regular expression. Showing the first 10:\n", (int) matchingconss.size());
2085  else
2086  SCIPdebugMessage(" There are %d unassigned constraints with names matching given regular expression: \n", (int) matchingconss.size());
2087 
2088  for( size_t mc = 0 ; mc < 10 && mc < matchingconss.size(); ++mc )
2089  SCIPdialogMessage(scip, NULL, " %s \n", SCIPconsGetName( seeedpool->getConsForIndex( matchingconss[mc] ) ));
2090 
2091  SCIPdialogMessage(scip, NULL, "\n Should these constraints be added to: \n");
2092  SCIPdialogMessage(scip, NULL, " master \n");
2093  SCIPdialogMessage(scip, NULL, " block (to be specified) \n");
2094  SCIPdialogMessage(scip, NULL, " nothing (return to toolbox main menu)? \n");
2095 
2096 
2097  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Please specify how to proceed: \nGCG/toolbox> ", &command, &endoffile) );
2098 
2099  commandlen = strlen(command);
2100 
2102  if( strncmp( command, "master", commandlen) == 0 )
2103  {
2104  for( size_t mc = 0 ; mc < matchingconss.size(); ++mc )
2105  {
2106  seeed->bookAsMasterCons( matchingconss[mc] );
2107  }
2108  }
2109  else if( strncmp( command, "block", commandlen) == 0 )
2110  {
2111  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Please specify the block number these constraints should be assigned to: \nGCG/toolbox> ", &command2, &endoffile) );
2112  char* tail;
2113  int blockid = strtol(command2, &tail, 10);
2114  for( size_t mc = 0 ; mc < matchingconss.size(); ++mc )
2115  {
2116  seeed->bookAsBlockCons( matchingconss[mc], blockid );
2117  }
2118  }
2119  else
2120  return SCIP_OKAY;
2121 
2122  seeed->flushBooked();
2123 
2124 
2125  return SCIP_OKAY;
2126 }
2127 
2129 (
2130 SCIP* scip,
2131 SCIP_DIALOGHDLR* dialoghdlr,
2132 SCIP_DIALOG* dialog )
2133 {
2134 
2135  SCIP_CONSHDLR* conshdlr;
2136  SCIP_CONSHDLRDATA* conshdlrdata;
2137  SCIP_Bool choosenfinisher;
2138 
2139  char* command;
2140  SCIP_Bool endoffile;
2141  char* tail;
2142  int finisherid;
2143  SEEED_PROPAGATION_DATA* seeedPropData;
2144  DEC_DETECTOR* finisher;
2145  SCIP_Result result;
2146 
2147  assert(scip != NULL);
2148  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
2149  assert( conshdlr != NULL );
2150 
2151  conshdlrdata = SCIPconshdlrGetData(conshdlr);
2152  assert(conshdlrdata != NULL);
2153 
2154  SeeedPtr seeed = conshdlrdata->curruserseeed;
2156  std::vector<int> matchingvars = std::vector<int>(0);
2157 
2158  seeedpool = seeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool;
2159  choosenfinisher = FALSE;
2160  while ( !choosenfinisher )
2161  {
2162  SCIPdialogMessage(scip, NULL, " Available finisher: \n");
2164  SCIPdialogMessage(scip, NULL, "%d : %s \n", -1, "abort" );
2165  for( int fi = 0; fi < seeedpool->getNFinishingDetectors(); ++fi )
2166  {
2167  SCIPdialogMessage(scip, NULL, "%d : %s \n", fi, DECdetectorGetName(seeedpool->getFinishingDetectorForIndex(fi) ) );
2168  }
2169 
2171  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Please specify the index of the finisher to use : \nGCG/toolbox> ", &command, &endoffile) );
2172 
2173  finisherid = strtol(command, &tail, 10);
2174 
2175  if( finisherid >= seeedpool->getNFinishingDetectors() || finisherid < -1 )
2176  {
2177  SCIPdialogMessage(scip, NULL, "The specified id is invalid \n" );
2178  continue;
2179  }
2180  choosenfinisher = TRUE;
2181  }
2182 
2183  seeedPropData = new SEEED_PROPAGATION_DATA();
2184  seeedPropData->seeedpool = seeedpool;
2185  seeedPropData->nNewSeeeds = 0;
2186  seeedPropData->seeedToPropagate = new gcg::Seeed(conshdlrdata->curruserseeed);
2187 
2188  if( conshdlrdata->lastuserseeed != NULL)
2189  delete conshdlrdata->lastuserseeed;
2190  conshdlrdata->lastuserseeed = new gcg::Seeed( conshdlrdata->curruserseeed) ;
2191 
2192  finisher = seeedpool->getFinishingDetectorForIndex(finisherid);
2193  finisher->finishSeeed(scip, finisher, seeedPropData, &result);
2194 
2195  delete conshdlrdata->curruserseeed;
2196 
2197  for( int i = 0; i < seeedPropData->nNewSeeeds; ++i)
2198  {
2199  delete seeedPropData->newSeeeds[i];
2200  }
2201 
2202  delete seeedPropData->seeedToPropagate;
2203  delete seeedPropData;
2204 
2205  return SCIP_OKAY;
2206 }
2207 
2208 
2210 SCIP* scip,
2211 SCIP_DIALOGHDLR* dialoghdlr,
2212 SCIP_DIALOG* dialog )
2213 {
2214 
2215  SCIP_CONSHDLR* conshdlr;
2216  SCIP_CONSHDLRDATA* conshdlrdata;
2217  SCIP_Bool matching;
2218  char* varregex;
2219  char* command;
2220  char* command2;
2221  SCIP_Bool endoffile;
2222  int commandlen;
2223 
2224  assert(scip != NULL);
2225  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
2226  assert( conshdlr != NULL );
2227  matching = FALSE;
2228 
2229 
2230  conshdlrdata = SCIPconshdlrGetData(conshdlr);
2231  assert(conshdlrdata != NULL);
2232 
2233  SeeedPtr seeed = conshdlrdata->curruserseeed;
2235  std::vector<int> matchingvars = std::vector<int>(0);
2236 
2237  seeedpool = seeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool;
2239  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Please specify a regular expression (modified ECMAScript regular expression grammar) matching the names of unassigned variables you want to assign : \nGCG/toolbox> ", &varregex, &endoffile) );
2240 
2241 
2244  std::regex expr;
2245  try {
2246  expr = std::regex(varregex);//, std::regex_constants::extended);
2247  }
2248  catch (const std::regex_error& e) {
2249  std::cout << "regex_error caught: " << e.what() << '\n';
2250  if (e.code() == std::regex_constants::error_brack) {
2251  SCIPdebugMessage("The code was error_brack\n");
2252  }
2253  }
2254 
2255  for( int oc = 0; oc < seeed->getNOpenvars(); ++oc )
2256  {
2257  const char* varname;
2258 
2259  varname = SCIPvarGetName( seeedpool->getVarForIndex(seeed->getOpenvars()[oc] ) );
2260 
2261 
2262  if( std::regex_match(varname, expr) )
2263  {
2264  matching = TRUE;
2265  matchingvars.push_back(seeed->getOpenconss()[oc]);
2266  SCIPdebugMessage( " varname %s matches regex %s \n", varname, varregex );
2267  } else
2268  SCIPdebugMessage(" varname %s does not match regex %s \n", varname, varregex);
2269  }
2270 
2271  if( !matching )
2272  {
2273  SCIPdialogMessage(scip, NULL, " There are no unassigned constraints with names matching given regular expression. Return to toolbox main menu.\n");
2274  return SCIP_OKAY;
2275  }
2276 
2277  if( conshdlrdata->lastuserseeed != NULL)
2278  delete conshdlrdata->lastuserseeed;
2279  conshdlrdata->lastuserseeed = new gcg::Seeed( conshdlrdata->curruserseeed) ;
2280 
2281 
2282  if( matchingvars.size() > 10 )
2283  SCIPdialogMessage(scip, NULL, " There are %d unassigned constraints with names matching given regular expression. Showing the first 10:\n", matchingvars.size());
2284  else
2285  SCIPdialogMessage(scip, NULL, " There are %d unassigned constraints with names matching given regular expression: \n", matchingvars.size());
2286 
2287  for( size_t mc = 0 ; mc < 10 && mc < matchingvars.size(); ++mc )
2288  SCIPdialogMessage(scip, NULL, " %s \n", SCIPvarGetName( seeedpool->getVarForIndex( matchingvars[mc] ) ));
2289 
2290  SCIPdialogMessage(scip, NULL, "\n Should these constraints be added to: \n");
2291  SCIPdialogMessage(scip, NULL, " master \n");
2292  SCIPdialogMessage(scip, NULL, " block (to be specified) \n");
2293  SCIPdialogMessage(scip, NULL, " nothing (return to toolbox main menu)? \n");
2294 
2295 
2296  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Please specify how to proceed: \nGCG/toolbox> ", &command, &endoffile) );
2297 
2298  commandlen = strlen(command);
2299 
2301  if( strncmp( command, "master", commandlen) == 0 )
2302  {
2303  for( size_t mc = 0 ; mc < matchingvars.size(); ++mc )
2304  {
2305  seeed->bookAsMasterVar( matchingvars[mc] );
2306  }
2307  } else
2308  if( strncmp( command, "linking", commandlen) == 0 )
2309  {
2310  for( size_t mc = 0 ; mc < matchingvars.size(); ++mc )
2311  {
2312  seeed->bookAsLinkingVar( matchingvars[mc] );
2313  }
2314  }
2315  else if( strncmp( command, "block", commandlen) == 0 )
2316  {
2317  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Please specify the block number these variables should be assigned to: \nGCG/toolbox> ", &command2, &endoffile) );
2318  char* tail;
2319  int blockid = strtol(command2, &tail, 10);
2320  for( size_t mc = 0 ; mc < matchingvars.size(); ++mc )
2321  {
2322  seeed->bookAsBlockVar( matchingvars[mc], blockid );
2323  }
2324  }
2325  else
2326  return SCIP_OKAY;
2327 
2328  seeed->flushBooked();
2329  seeed->deleteEmptyBlocks(true);
2330 
2331 
2332  return SCIP_OKAY;
2333 }
2334 
2335 /* Apply propagation, finishing or postprocessing to the current user seeed via dialog */
2337  SCIP* scip,
2338  SCIP_DIALOGHDLR* dialoghdlr,
2339  SCIP_DIALOG* dialog,
2340  toolboxtype action )
2341 {
2342  char* command;
2343  int commandlen;
2344  SCIP_Bool endoffile;
2345  SCIP_CONSHDLR* conshdlr;
2346  SCIP_CONSHDLRDATA* conshdlrdata;
2347  SCIP_Result result;
2348  DEC_Detector** detectors;
2349  int ndetectors;
2350  int i, j;
2351  SEEED_PROPAGATION_DATA* seeedPropData;
2353  SCIP_Bool finished, displayinfo;
2354  char stri[SCIP_MAXSTRLEN];
2355  const char* actiontype;
2356 
2357  /* set string for dialog */
2358  if( action == PROPAGATE )
2359  actiontype = "propagated";
2360  else if( action == FINISH )
2361  actiontype = "finished";
2362  else if( action == POSTPROCESS )
2363  actiontype = "postprocessed";
2364  else
2365  actiontype = "UNDEFINED_ACTION";
2366 
2367  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
2368  conshdlrdata = SCIPconshdlrGetData(conshdlr);
2369 
2370  if( action == POSTPROCESS && conshdlrdata->curruserseeed->isComplete() == FALSE )
2371  {
2372  SCIPinfoMessage(scip, NULL, "The currently selected seeed is not finished, postprocessing not possible.\n");
2373  return SCIP_OKAY;
2374  }
2375 
2376  if( conshdlrdata->ndetectors == 0 )
2377  {
2378  SCIPinfoMessage(scip, NULL, "No detector available!\n\n");
2379  return SCIP_OKAY;
2380  }
2381 
2382  SCIP_CALL( SCIPallocBufferArray(scip, &detectors, conshdlrdata->ndetectors) );
2383 
2384  /* determine the detectors that implement the specified callback */
2385  ndetectors = 0;
2386  for( i = 0; i < conshdlrdata->ndetectors; ++i )
2387  {
2388  if( (action == PROPAGATE && conshdlrdata->detectors[i]->propagateFromToolbox)
2389  || (action == FINISH && conshdlrdata->detectors[i]->finishFromToolbox)
2390  || (action == POSTPROCESS && conshdlrdata->detectors[i]->postprocessSeeed) )
2391  {
2392  detectors[ndetectors] = conshdlrdata->detectors[i];
2393  ++ndetectors;
2394  }
2395  }
2396 
2397  if( ndetectors == 0 )
2398  {
2399  SCIPinfoMessage(scip, NULL, "No detector implements this callback, returning!\n\n");
2400  return SCIP_OKAY;
2401  }
2402 
2403  /* build seeed propagation data needed in callbacks */
2404  seeedpool = conshdlrdata->curruserseeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool;
2405 
2406  seeedPropData = new SEEED_PROPAGATION_DATA();
2407  seeedPropData->seeedpool = seeedpool;
2408  seeedPropData->nNewSeeeds = 0;
2409  seeedPropData->seeedToPropagate = new gcg::Seeed(conshdlrdata->curruserseeed);
2410  seeedPropData->seeedToPropagate->setSeeedpool(seeedpool);
2411  if( action != POSTPROCESS )
2412  {
2413  SCIP_CALL( SCIPallocMemoryArray(scip, &(seeedPropData->newSeeeds), 1) );
2414  seeedPropData->newSeeeds[0] = NULL;
2415  }
2416 
2417  /* user dialog to select wanted detector, apply it and handle the returned seeeds, if any */
2418  finished = FALSE;
2419  while( !finished )
2420  {
2421  result = SCIP_DIDNOTFIND;
2422  /* list the detectors implementing the specified callback by name with a leading number */
2423  j = 1;
2424  SCIPinfoMessage(scip, NULL, "Available detectors:\n");
2425  for( i = 0; i < ndetectors; ++i )
2426  {
2427  SCIPinfoMessage(scip, NULL, "%d)", j);
2428  SCIPinfoMessage(scip, NULL, "%s\n", detectors[i]->name);
2429  ++j;
2430  }
2431  commandlen = 0;
2432  while( commandlen == 0 )
2433  {
2434  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Type in the name or number of the detector that you want to use (or \"none\"): \nGCG/toolbox> ", &command, &endoffile) );
2435  commandlen = strlen(command);
2436  }
2437 
2438  if( !strncmp( command, "none", commandlen) == 0 && !strncmp( command, "quit", commandlen) == 0 )
2439  {
2440  for( i = 0; i < ndetectors; ++i )
2441  {
2442  sprintf(stri, "%d", i+1); //used for matching numberings in the list, off-by-one since detectors start with 0
2443  if( strncmp( command, detectors[i]->name, commandlen) == 0 || strncmp( command, stri, commandlen ) == 0 )
2444  {
2445  if( action == PROPAGATE )
2446  SCIP_CALL( detectors[i]->propagateFromToolbox(scip, detectors[i], seeedPropData, &result, dialoghdlr, dialog) );
2447  else if( action == FINISH )
2448  SCIP_CALL( detectors[i]->finishFromToolbox(scip, detectors[i], seeedPropData, &result, dialoghdlr, dialog) );
2449  else if( action == POSTPROCESS )
2450  SCIP_CALL( detectors[i]->postprocessSeeed(scip, detectors[i], seeedPropData, &result) );
2451  break;
2452  }
2453  }
2454  }
2455  else
2456  {
2457  finished = TRUE;
2458  continue;
2459  }
2460  if( result == SCIP_SUCCESS )
2461  {
2462  if( action != POSTPROCESS )
2463  {
2464  SCIPinfoMessage(scip, NULL, "Considering implicits of newly found seeed(s)...\n");
2465  for( i = 0; i < seeedPropData->nNewSeeeds; ++i )
2466  {
2467  assert(seeedPropData->newSeeeds[i] != NULL);
2468  seeedPropData->newSeeeds[i]->considerImplicits( ); //There may be open vars/cons left that were not matched
2469  }
2470 
2471  SCIPinfoMessage(scip, NULL, "\nSeeed was successfully %s, %d potentially new seeed(s) found.\n", actiontype, seeedPropData->nNewSeeeds);
2472 
2473  displayinfo = TRUE;
2474  if( seeedPropData->nNewSeeeds > 1 )
2475  {
2476  commandlen = 0;
2477  while( commandlen == 0 )
2478  {
2479  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog,
2480  "More than one seeed found. Do you want to display information about all found seeeds anyway? (\"yes\"/\"no\")?\nGCG/toolbox> ", &command, &endoffile) );
2481  commandlen = strlen(command);
2482  }
2483  if( strncmp( command, "no", commandlen) == 0 )
2484  {
2485  displayinfo = FALSE;
2486  }
2487  else if( strncmp( command, "quit", commandlen) == 0 )
2488  {
2489  finished = TRUE;
2490  continue;
2491  }
2492  }
2493 
2494  if( displayinfo )
2495  {
2496  for( i = 0; i < seeedPropData->nNewSeeeds; ++i )
2497  {
2498  seeedPropData->newSeeeds[i]->displayInfo( 0 );
2499  }
2500  }
2501 
2502  if( seeedPropData->nNewSeeeds == 1 )
2503  {
2504  commandlen = 0;
2505  while( commandlen == 0 )
2506  {
2507  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog,
2508  "Do you want to visualize the new seeed (\"yes\"/\"no\")?\nGCG/toolbox> ", &command, &endoffile) );
2509  commandlen = strlen(command);
2510  }
2511  if( strncmp( command, "yes", commandlen) == 0 )
2512  {
2513  SCIP_CALL( SCIPconshdlrDecompSelectVisualize(scip, dialoghdlr, dialog ) );
2514  }
2515  else if( strncmp( command, "quit", commandlen) == 0 )
2516  {
2517  finished = TRUE;
2518  continue;
2519  }
2520  }
2521 
2522  SCIPinfoMessage(scip, NULL, "\nSaving newly found seeeds...\n\n");
2523  for( i = 0; i < seeedPropData->nNewSeeeds; ++i )
2524  {
2525  conshdlrdata->curruserseeed = new gcg::Seeed( seeedPropData->newSeeeds[i] );
2526  SCIP_CALL( SCIPconshdlrDecompUserSeeedFlush(scip) );
2527  assert(conshdlrdata->curruserseeed == NULL);
2528  }
2529 
2530  if( seeedPropData->nNewSeeeds == 1 )
2531  {
2532  commandlen = 0;
2533  while( commandlen == 0 )
2534  {
2535  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog,
2536  "\nDo you want to continue the decomposition with the new Seeed (\"continue\"), \
2537 or continue with the previous Seeed (\"previous\")?\nGCG/toolbox> ", &command, &endoffile) );
2538  commandlen = strlen(command);
2539  }
2540  if( strncmp( command, "continue", commandlen) == 0 )
2541  {
2542  conshdlrdata->curruserseeed = new gcg::Seeed(seeedPropData->newSeeeds[0]);
2543  }
2544  else
2545  {
2546  conshdlrdata->curruserseeed = new gcg::Seeed(seeedPropData->seeedToPropagate);
2547  }
2548  }
2549  else
2550  {
2551  conshdlrdata->curruserseeed = new gcg::Seeed(seeedPropData->seeedToPropagate);
2552  }
2553  finished = TRUE;
2554  continue;
2555  }
2556  else if( action == POSTPROCESS )
2557  {
2558  SCIPinfoMessage(scip, NULL, "\nSeeed successfully %s. %d seeed(s) found in the process.\n", actiontype, seeedPropData->nNewSeeeds);
2559 
2560  commandlen = 0;
2561  while( commandlen == 0 )
2562  {
2563  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Do you want to save all found seeeds (\"all\") or none (\"none\")?\nGCG/toolbox> ", &command, &endoffile) );
2564  commandlen = strlen(command);
2565  }
2566  if( strncmp(command, "all", commandlen) == 0 )
2567  {
2568  SCIPinfoMessage(scip, NULL, "Storing seeeds...\n");
2569  for( i = 0; i < seeedPropData->nNewSeeeds; ++i )
2570  {
2571  conshdlrdata->curruserseeed = new gcg::Seeed(seeedPropData->newSeeeds[i]);
2572  SCIP_CALL( SCIPconshdlrDecompUserSeeedFlush(scip) );
2573  }
2574  conshdlrdata->curruserseeed = new gcg::Seeed(seeedPropData->seeedToPropagate);
2575  SCIPinfoMessage(scip, NULL, "\nAll seeeds stored successfully!\n");
2576  }
2577  finished = TRUE;
2578  continue;
2579  }
2580  }
2581  else
2582  {
2583  SCIPinfoMessage(scip, NULL, "Seeed could not be %s.\n", actiontype);
2584 
2585  commandlen = 0;
2586  while( commandlen == 0 )
2587  {
2588  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Do you want to select another detector (\"detector\") or \
2589 return to the previous menu (\"previous\")?\nGCG/toolbox> ", &command, &endoffile) );
2590  commandlen = strlen(command);
2591  }
2592  if( strncmp( command, "detector", commandlen) == 0 )
2593  {
2594  continue;
2595  }
2596  else
2597  {
2598  finished = TRUE;
2599  continue;
2600  }
2601  }
2602  }
2603 
2604  SCIPfreeMemoryArrayNull( scip, &(seeedPropData->newSeeeds) );
2605  delete seeedPropData->seeedToPropagate;
2606  seeedPropData->newSeeeds = NULL;
2607  seeedPropData->nNewSeeeds = 0;
2608  delete seeedPropData;
2609 
2610  SCIPfreeBufferArray(scip, &detectors);
2611  return SCIP_OKAY;
2612 }
2613 
2615  SCIP* scip,
2616  SCIP_DIALOGHDLR* dialoghdlr,
2617  SCIP_DIALOG* dialog )
2618 {
2619  return SCIPconshdlrDecompToolboxActOnSeeed(scip, dialoghdlr, dialog, FINISH);
2620 }
2621 
2623  SCIP* scip,
2624  SCIP_DIALOGHDLR* dialoghdlr,
2625  SCIP_DIALOG* dialog )
2626 {
2627  return SCIPconshdlrDecompToolboxActOnSeeed(scip, dialoghdlr, dialog, PROPAGATE);
2628 }
2629 
2631  SCIP* scip,
2632  SCIP_DIALOGHDLR* dialoghdlr,
2633  SCIP_DIALOG* dialog )
2634 {
2635  return SCIPconshdlrDecompToolboxActOnSeeed(scip, dialoghdlr, dialog, POSTPROCESS);
2636 }
2637 
2639  SCIP* scip,
2640  SCIP_DIALOGHDLR* dialoghdlr,
2641  SCIP_DIALOG* dialog )
2642 {
2643  SCIP_CONSHDLR* conshdlr;
2644  SCIP_Bool finished;
2645  char* command;
2646  SCIP_Bool endoffile;
2647  int commandlen;
2648  SCIP_CONSHDLRDATA* conshdlrdata;
2649  SCIP_Bool selectedsomeseeed;
2650 
2651  selectedsomeseeed = TRUE;
2652 
2653  assert(scip != NULL);
2654  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
2655  assert( conshdlr != NULL );
2656  finished = FALSE;
2657 
2658  conshdlrdata = SCIPconshdlrGetData(conshdlr);
2659  assert(conshdlrdata != NULL);
2660 
2661  if( SCIPgetStage(scip) == SCIP_STAGE_INIT )
2662  {
2663  SCIPinfoMessage(scip, NULL, "No problem is loaded. Please read in a model first.\n");
2664  return SCIP_OKAY;
2665  }
2666  if( (int)conshdlrdata->listall->size() == 0 )
2667  {
2668  SCIPinfoMessage(scip, NULL, "No decompositions available. Please detect first.\n");
2669  return SCIP_OKAY;
2670  }
2671  if( SCIPgetStage(scip) < SCIP_STAGE_TRANSFORMED )
2672  {
2673  SCIP_CALL( SCIPtransformProb(scip) );
2674  SCIPinfoMessage(scip, NULL, "Applied tranformation to problem.\n");
2675  }
2678 
2680  while ( !finished )
2681  {
2682 
2684 
2686 
2687  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Please choose an existing partial decomposition for modification (type \"choose <id>\" or \"h\" for help) : \nGCG/toolbox> ", &command, &endoffile) );
2688 
2689  commandlen = strlen(command);
2690 
2692  if( strncmp( command, "back", commandlen) == 0 )
2693  {
2694  conshdlrdata->startidvisu -= conshdlrdata->selectvisulength;
2695  if(conshdlrdata->startidvisu < 0 )
2696  conshdlrdata->startidvisu = 0;
2697  continue;
2698  }
2699  if( strncmp( command, "next", commandlen) == 0 )
2700  {
2701  conshdlrdata->startidvisu += conshdlrdata->selectvisulength;
2702  if( conshdlrdata->startidvisu > (int) conshdlrdata->listall->size() - conshdlrdata->selectvisulength )
2703  conshdlrdata->startidvisu = conshdlrdata->listall->size() - conshdlrdata->selectvisulength ;
2704  continue;
2705  }
2706  if( strncmp( command, "top", commandlen) == 0 )
2707  {
2708  conshdlrdata->startidvisu = 0;
2709  continue;
2710  }
2711  if( strncmp( command, "end", commandlen) == 0 )
2712  {
2713  conshdlrdata->startidvisu = conshdlrdata->listall->size() - conshdlrdata->selectvisulength ;
2714  continue;
2715  }
2716 
2717  if( strncmp( command, "quit", commandlen) == 0 )
2718  {
2719  finished = TRUE;
2720  selectedsomeseeed = FALSE;
2721  continue;
2722  }
2723 
2724  if( strncmp( command, "choose", commandlen) == 0 )
2725  {
2726  SCIP_RETCODE retcode = SCIPconshdlrDecompToolboxChoose(scip, dialoghdlr, dialog );
2727  if (retcode != SCIP_OKAY)
2728  {
2729  selectedsomeseeed = FALSE;
2730  continue;
2731  }
2732  else
2733  {
2734  selectedsomeseeed = TRUE;
2735  finished = TRUE;
2736  break;
2737  }
2738  }
2739 
2740  if( strncmp( command, "abort", commandlen) == 0 )
2741  {
2742  finished = TRUE;
2743  selectedsomeseeed = FALSE;
2744  continue;
2745  }
2746 
2747  if( strncmp( command, "change number displayed", commandlen) == 0 )
2748  {
2749  SCIP_CALL(SCIPconshdlrDecompModifyNVisualized(scip, dialoghdlr, dialog) );
2750  continue;
2751  }
2752 
2753  if( strncmp( command, "help", commandlen) == 0 )
2754  {
2755  SCIP_CALL(SCIPconshdlrDecompShowHelp(scip) );
2756  continue;
2757  }
2758 
2759  if( strncmp( command, "visualize", commandlen) == 0 )
2760  {
2761  SCIP_CALL(SCIPconshdlrDecompSelectVisualize(scip, dialoghdlr, dialog ) );
2762  continue;
2763  }
2764 
2765  if( strncmp( command, "propagate", commandlen) == 0 )
2766  {
2767  SCIP_CALL( SCIPconshdlrDecompToolboxPropagateSeeed(scip, dialoghdlr, dialog) );
2768  continue;
2769  }
2770 
2771  if( strncmp( command, "finishseeed", commandlen) == 0 )
2772  {
2773  SCIP_CALL( SCIPconshdlrDecompToolboxFinishSeeed(scip, dialoghdlr, dialog) );
2774  continue;
2775  }
2776 
2777  if( strncmp( command, "postprocess", commandlen) == 0 )
2778  {
2779  SCIP_CALL( SCIPconshdlrDecompToolboxPostprocessSeeed(scip, dialoghdlr, dialog) );
2780  continue;
2781  }
2782  }
2783  finished = FALSE;
2784  while ( !finished && selectedsomeseeed )
2785  {
2786  int commandlen2;
2787  SCIP_Bool success;
2788 
2790 
2792 
2793  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "How do you want to proceed the with the current decomposition? (or \"h\" for help) : \nGCG/toolbox> ", &command, &endoffile) );
2794 
2795  commandlen2 = strlen(command);
2796 
2798  if( strncmp( command, "conss", commandlen2) == 0 )
2799  {
2800  SCIPconshdlrDecompToolboxModifyConss(scip, dialoghdlr, dialog);
2801  continue;
2802  }
2803  if( strncmp( command, "vars", commandlen2) == 0 )
2804  {
2805  SCIPconshdlrDecompToolboxModifyVars(scip, dialoghdlr, dialog);
2806  continue;
2807  }
2808  if( strncmp( command, "finish", commandlen2) == 0 )
2809  {
2810  SCIPconshdlrDecompToolboxModifyFinish(scip, dialoghdlr, dialog);
2811  continue;
2812  }
2813  if( strncmp( command, "refine", commandlen2) == 0 )
2814  {
2815  if( conshdlrdata->lastuserseeed != NULL)
2816  delete conshdlrdata->lastuserseeed;
2817  conshdlrdata->lastuserseeed = new gcg::Seeed( conshdlrdata->curruserseeed) ;
2818  conshdlrdata->curruserseeed->considerImplicits();
2819  continue;
2820  }
2821 
2822  if( strncmp( command, "quit", commandlen2) == 0 )
2823  {
2825  if( !conshdlrdata->curruserseeed->isFromUnpresolved() && conshdlrdata->seeedpool == NULL )
2827 
2828  seeedpool = ( conshdlrdata->curruserseeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool);
2829  if( seeedpool == NULL )
2830 
2831  conshdlrdata->curruserseeed->sort();
2832  conshdlrdata->curruserseeed->considerImplicits();
2833  conshdlrdata->curruserseeed->calcHashvalue();
2834  assert( conshdlrdata->curruserseeed->checkConsistency() );
2835 
2836 
2837 
2838  if( conshdlrdata->curruserseeed->isComplete() )
2839  {
2840  seeedpool->addSeeedToFinished(conshdlrdata->curruserseeed, &success);
2841  if( !success )
2842  {
2843  delete conshdlrdata->curruserseeed;
2844  }
2845  } else
2846  {
2847  seeedpool->addSeeedToIncomplete(conshdlrdata->curruserseeed, &success);
2848  if( !success )
2849  {
2850  delete conshdlrdata->curruserseeed;
2851  }
2852  }
2853  conshdlrdata->curruserseeed = NULL;
2854  finished = TRUE;
2855 
2856 
2857  continue;
2858  }
2859 
2860  if( strncmp( command, "undo", commandlen2) == 0 )
2861  {
2862  if ( conshdlrdata->lastuserseeed == NULL )
2863  SCIPdialogMessage(scip, NULL, " nothing to be undone \n");
2864  else
2865  {
2866  delete conshdlrdata->curruserseeed;
2867  conshdlrdata->curruserseeed = conshdlrdata->lastuserseeed;
2868  conshdlrdata->lastuserseeed = NULL;
2869  }
2870  continue;
2871  }
2872 
2873 
2874  if( strncmp( command, "visualize", commandlen2) == 0 )
2875  {
2876  SCIP_CALL(SCIPconshdlrDecompSelectVisualizeCurrentUserSeeed(scip, dialoghdlr, dialog ) );
2877  continue;
2878  }
2879 
2880  if( strncmp( command, "propagate", commandlen2) == 0 )
2881  {
2882  SCIP_CALL( SCIPconshdlrDecompToolboxPropagateSeeed(scip, dialoghdlr, dialog) );
2883  continue;
2884  }
2885  if( strncmp( command, "finishseeed", commandlen2) == 0 )
2886  {
2887  SCIP_CALL( SCIPconshdlrDecompToolboxFinishSeeed(scip, dialoghdlr, dialog) );
2888  continue;
2889  }
2890 
2891  if( strncmp( command, "postprocess", commandlen2) == 0 )
2892  {
2893  SCIP_CALL( SCIPconshdlrDecompToolboxPostprocessSeeed(scip, dialoghdlr, dialog) );
2894  continue;
2895  }
2896  }
2897  return SCIP_OKAY;
2898 }
2899 
2901  SCIP* scip,
2902  SCIP_DIALOGHDLR* dialoghdlr,
2903  SCIP_DIALOG* dialog )
2904 {
2905  SCIP_CONSHDLR* conshdlr;
2906  char* command;
2907  SCIP_Bool endoffile;
2908  SCIP_Bool finished;
2909  int commandlen;
2910  SCIP_CONSHDLRDATA* conshdlrdata;
2911 
2912  assert(scip != NULL);
2913  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
2914  assert( conshdlr != NULL );
2915 
2916  conshdlrdata = SCIPconshdlrGetData(conshdlr);
2917  assert(conshdlrdata != NULL);
2918 
2919  if( SCIPgetStage(scip) == SCIP_STAGE_INIT )
2920  {
2921  SCIPinfoMessage(scip, NULL, "No problem is loaded. Please read in a model first.\n");
2922  return SCIP_OKAY;
2923  }
2924  if( (int)conshdlrdata->listall->size() == 0 )
2925  {
2926  SCIPinfoMessage(scip, NULL, "No decompositions available. Please detect first.\n");
2927  return SCIP_OKAY;
2928  }
2929  if( SCIPgetStage(scip) < SCIP_STAGE_TRANSFORMED )
2930  {
2931  SCIP_CALL( SCIPtransformProb(scip) );
2932  SCIPinfoMessage(scip, NULL, "Applied tranformation to problem.\n");
2933  }
2934 
2935  /* create new decomposition */
2936  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Should the new partial decomposition be for the presolved or the unpresolved problem? (type \"presolved\" or \"unpresolved\") : \nGCG/toolbox> ", &command, &endoffile) );
2937  commandlen = strlen(command);
2938 
2939  if( conshdlrdata->curruserseeed != NULL )
2940  delete conshdlrdata->curruserseeed;
2941 
2943  SCIP_Bool isfromunpresolved;
2944 
2945  while( (strncmp( command, "presolved", commandlen) != 0 && strncmp( command, "unpresolved", commandlen) != 0) || commandlen == 0)
2946  {
2947  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Invalid input. Should the new partial decomposition be for the presolved or the unpresolved problem? (type \"presolved\" or \"unpresolved\") : \nGCG/toolbox> ", &command, &endoffile) );
2948  commandlen = strlen(command);
2949  }
2950 
2952  if( strncmp( command, "presolved", commandlen) == 0 )
2953  {
2954  isfromunpresolved = FALSE;
2955  if (conshdlrdata->seeedpool != NULL )
2956  seeedpool = conshdlrdata->seeedpool;
2957  else
2958  {
2959  if( SCIPgetStage(scip) < SCIP_STAGE_PRESOLVED )
2960  {
2961  SCIPinfoMessage(scip, NULL, "Problem is not presolved yet. Please presolve it first!\n");
2962  return SCIP_OKAY;
2963  }
2964 
2965  conshdlrdata->seeedpool = new gcg::Seeedpool(scip, CONSHDLR_NAME, TRUE, SCIPconshdlrDecompDetectBenders(scip));
2966  seeedpool = conshdlrdata->seeedpool;
2967  }
2968  }
2969  else
2970  {
2971  isfromunpresolved = TRUE;
2972  if ( conshdlrdata->seeedpoolunpresolved == NULL )
2973  conshdlrdata->seeedpoolunpresolved = new gcg::Seeedpool(scip, CONSHDLR_NAME, FALSE, SCIPconshdlrDecompDetectBenders(scip));
2974  seeedpool = conshdlrdata->seeedpoolunpresolved;
2975 
2976  }
2977  if( seeedpool == NULL )
2978  {
2979  if( SCIPgetStage(scip) >= SCIP_STAGE_PRESOLVED )
2980 
2981  {
2982  if (conshdlrdata->seeedpool == NULL )
2983  conshdlrdata->seeedpool = new gcg::Seeedpool(scip, CONSHDLR_NAME, TRUE, SCIPconshdlrDecompDetectBenders(scip));
2984  seeedpool = conshdlrdata->seeedpool;
2985  }
2986  else
2987  {
2988  if ( conshdlrdata->seeedpoolunpresolved == NULL)
2989  conshdlrdata->seeedpoolunpresolved = new gcg::Seeedpool(scip, CONSHDLR_NAME, FALSE, SCIPconshdlrDecompDetectBenders(scip));
2990  seeedpool = conshdlrdata->seeedpoolunpresolved;
2991  }
2992 
2993  }
2994  conshdlrdata->curruserseeed = new gcg::Seeed( scip, SCIPconshdlrDecompGetNextSeeedID(scip), seeedpool );
2995  conshdlrdata->curruserseeed->setIsFromUnpresolved(isfromunpresolved);
2996  finished = FALSE;
2997  while ( !finished )
2998  {
2999  int commandlen2;
3000  SCIP_Bool success;
3001 
3003 
3005 
3006  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "How do you want to proceed the with the current decomposition? (or \"h\" for help) : \nGCG/toolbox> ", &command, &endoffile) );
3007 
3008  commandlen2 = strlen(command);
3009 
3011  if( strncmp( command, "conss", commandlen2) == 0 )
3012  {
3013  SCIPconshdlrDecompToolboxModifyConss(scip, dialoghdlr, dialog);
3014  continue;
3015  }
3016  if( strncmp( command, "vars", commandlen2) == 0 )
3017  {
3018  SCIPconshdlrDecompToolboxModifyVars(scip, dialoghdlr, dialog);
3019  continue;
3020  }
3021 /* if( strncmp( command, "finish", commandlen2) == 0 )
3022  {
3023  SCIPconshdlrDecompToolboxModifyFinish(scip, dialoghdlr, dialog);
3024  continue;
3025  }*/
3026  if( strncmp( command, "refine", commandlen2) == 0 )
3027  {
3028  if( conshdlrdata->curruserseeed->isFromUnpresolved() )
3029  seeedpool = conshdlrdata->seeedpoolunpresolved;
3030  else
3031  seeedpool = conshdlrdata->seeedpool;
3032  if( conshdlrdata->lastuserseeed != NULL)
3033  delete conshdlrdata->lastuserseeed;
3034  conshdlrdata->lastuserseeed = new gcg::Seeed( conshdlrdata->curruserseeed) ;
3035  conshdlrdata->curruserseeed->considerImplicits();
3036  //SCIPconshdlrDecompToolboxModifyFinish(scip, dialoghdlr, dialog);
3037  continue;
3038  }
3039 
3040  if( strncmp( command, "quit", commandlen2) == 0 )
3041  {
3042  if( !conshdlrdata->curruserseeed->isFromUnpresolved() && conshdlrdata->seeedpool == NULL )
3044 
3045  seeedpool = ( conshdlrdata->curruserseeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool);
3046  if( seeedpool == NULL )
3047 
3048  conshdlrdata->curruserseeed->sort();
3049  conshdlrdata->curruserseeed->considerImplicits();
3050  conshdlrdata->curruserseeed->calcHashvalue();
3051  assert( conshdlrdata->curruserseeed->checkConsistency() );
3052 
3053 
3054 
3055  if( conshdlrdata->curruserseeed->isComplete() )
3056  {
3057  seeedpool->addSeeedToFinished(conshdlrdata->curruserseeed, &success);
3058  if( !success )
3059  {
3060  delete conshdlrdata->curruserseeed;
3061  }
3062  } else
3063  {
3064  seeedpool->addSeeedToIncomplete(conshdlrdata->curruserseeed, &success);
3065  if( !success )
3066  {
3067  delete conshdlrdata->curruserseeed;
3068  }
3069  }
3070  conshdlrdata->curruserseeed = NULL;
3071  finished = TRUE;
3072 
3073 
3074  continue;
3075  }
3076 
3077  if( strncmp( command, "undo", commandlen2) == 0 )
3078  {
3079  if ( conshdlrdata->lastuserseeed == NULL )
3080  SCIPdialogMessage(scip, NULL, " nothing to be undone \n");
3081  else
3082  {
3083  delete conshdlrdata->curruserseeed;
3084  conshdlrdata->curruserseeed = conshdlrdata->lastuserseeed;
3085  conshdlrdata->lastuserseeed = NULL;
3086  }
3087  continue;
3088  }
3089 
3090 
3091  if( strncmp( command, "visualize", commandlen2) == 0 )
3092  {
3093  SCIP_CALL(SCIPconshdlrDecompSelectVisualizeCurrentUserSeeed(scip, dialoghdlr, dialog ) );
3094  continue;
3095  }
3096 
3097  if( strncmp( command, "propagate", commandlen2) == 0 )
3098  {
3099  SCIP_CALL( SCIPconshdlrDecompToolboxPropagateSeeed(scip, dialoghdlr, dialog) );
3100  continue;
3101  }
3102 
3103  if( strncmp( command, "finish", commandlen2) == 0 )
3104  {
3105  SCIP_CALL( SCIPconshdlrDecompToolboxFinishSeeed(scip, dialoghdlr, dialog) );
3106  continue;
3107  }
3108 
3109  if( strncmp( command, "postprocess", commandlen2) == 0 )
3110  {
3111  SCIP_CALL( SCIPconshdlrDecompToolboxPostprocessSeeed(scip, dialoghdlr, dialog) );
3112  continue;
3113  }
3114  }
3115  return SCIP_OKAY;
3116 }
3117 
3118 SCIP_RETCODE SCIPconshdlrDecompExecToolbox(
3119  SCIP* scip,
3120  SCIP_DIALOGHDLR* dialoghdlr,
3121  SCIP_DIALOG* dialog )
3122 {
3123 
3124  SCIP_CONSHDLR* conshdlr;
3125  SCIP_CONSHDLRDATA* conshdlrdata;
3126  SCIP_Bool finished;
3127  char* command;
3128  SCIP_Bool endoffile;
3129  int commandlen;
3130  SCIP_Bool selectedsomeseeed;
3131 
3132  assert(scip != NULL);
3133  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3134  assert( conshdlr != NULL );
3135  finished = FALSE;
3136 
3137  selectedsomeseeed = TRUE;
3138  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3139  assert(conshdlrdata != NULL);
3140 
3141  if( SCIPgetStage(scip) == SCIP_STAGE_INIT )
3142  {
3143  SCIPinfoMessage(scip, NULL, "No problem is loaded. Please read in a model first.\n");
3144  return SCIP_OKAY;
3145  }
3146  if( (int)conshdlrdata->listall->size() == 0 )
3147  {
3148  SCIPinfoMessage(scip, NULL, "No decompositions available. Please detect first.\n");
3149  return SCIP_OKAY;
3150  }
3151  if( SCIPgetStage(scip) < SCIP_STAGE_TRANSFORMED )
3152  {
3153  SCIP_CALL( SCIPtransformProb(scip) );
3154  SCIPinfoMessage(scip, NULL, "Applied tranformation to problem.\n");
3155  }
3156 
3157  commandlen = 0;
3159  while( (strncmp( command, "modify", commandlen) != 0 && strncmp( command, "create", commandlen) != 0) || commandlen == 0)
3160  {
3161  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Do you want to modify an existing (\"modify\") or create a new partial decomposition (\"create\")? : \nGCG/toolbox> ", &command, &endoffile) );
3162  commandlen = strlen(command);
3163  }
3164 
3165 
3167  if( strncmp( command, "modify", commandlen) == 0 )
3168  {
3172 
3173 
3176  while ( !finished )
3177  {
3178  int commandlen2;
3179 
3181 
3183 
3184  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Please choose an existing partial decomposition for modification (type \"choose <id>\" or \"h\" for help) : \nGCG/toolbox> ", &command, &endoffile) );
3185 
3186  commandlen2 = strlen(command);
3187 
3189  if( strncmp( command, "back", commandlen2) == 0 )
3190  {
3191  conshdlrdata->startidvisu -= conshdlrdata->selectvisulength;
3192  if(conshdlrdata->startidvisu < 0 )
3193  conshdlrdata->startidvisu = 0;
3194  continue;
3195  }
3196  if( strncmp( command, "next", commandlen2) == 0 )
3197  {
3198  conshdlrdata->startidvisu += conshdlrdata->selectvisulength;
3199  if( conshdlrdata->startidvisu > (int) conshdlrdata->listall->size() - conshdlrdata->selectvisulength )
3200  conshdlrdata->startidvisu = conshdlrdata->listall->size() - conshdlrdata->selectvisulength ;
3201  continue;
3202  }
3203  if( strncmp( command, "top", commandlen2) == 0 )
3204  {
3205  conshdlrdata->startidvisu = 0;
3206  continue;
3207  }
3208  if( strncmp( command, "end", commandlen2) == 0 )
3209  {
3210  conshdlrdata->startidvisu = conshdlrdata->listall->size() - conshdlrdata->selectvisulength ;
3211  continue;
3212  }
3213 
3214  if( strncmp( command, "quit", commandlen2) == 0 )
3215  {
3216  finished = TRUE;
3217  selectedsomeseeed = FALSE;
3218  continue;
3219  }
3220 
3221 
3222  if( strncmp( command, "choose", commandlen2) == 0 )
3223  {
3224  SCIP_RETCODE retcode = SCIPconshdlrDecompToolboxChoose(scip, dialoghdlr, dialog );
3225  if (retcode != SCIP_OKAY)
3226  {
3227  selectedsomeseeed = FALSE;
3228  continue;
3229  }
3230  else
3231  {
3232  finished = TRUE;
3233  break;
3234  }
3235  }
3236 
3237 
3238  if( strncmp( command, "abort", commandlen2) == 0 )
3239  {
3240  finished = TRUE;
3241  selectedsomeseeed = FALSE;
3242  continue;
3243  }
3244 
3245  if( strncmp( command, "change number displayed", commandlen2) == 0 )
3246  {
3247  SCIP_CALL(SCIPconshdlrDecompModifyNVisualized(scip, dialoghdlr, dialog) );
3248  continue;
3249  }
3250 
3251  if( strncmp( command, "help", commandlen2) == 0 )
3252  {
3253  SCIP_CALL(SCIPconshdlrDecompShowHelp(scip) );
3254  continue;
3255  }
3256 
3257  if( strncmp( command, "visualize", commandlen2) == 0 )
3258  {
3259  SCIP_CALL(SCIPconshdlrDecompSelectVisualize(scip, dialoghdlr, dialog ) );
3260  continue;
3261  }
3262 
3263  if( strncmp( command, "propagate", commandlen2) == 0 )
3264  {
3265  SCIP_CALL( SCIPconshdlrDecompToolboxPropagateSeeed(scip, dialoghdlr, dialog) );
3266  continue;
3267  }
3268 
3269  if( strncmp( command, "finishseeed", commandlen2) == 0 )
3270  {
3271  SCIP_CALL( SCIPconshdlrDecompToolboxFinishSeeed(scip, dialoghdlr, dialog) );
3272  continue;
3273  }
3274 
3275  if( strncmp( command, "postprocess", commandlen2) == 0 )
3276  {
3277  SCIP_CALL( SCIPconshdlrDecompToolboxPostprocessSeeed(scip, dialoghdlr, dialog) );
3278  continue;
3279  }
3280  }
3281  } /* finished yes == modify */
3282  else
3283  {
3284  /* create new decomposition */
3285  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Should the new partial decomposition be for the presolved or the unpresolved problem? (type \"presolved\" or \"unpresolved\") : \nGCG/toolbox> ", &command, &endoffile) );
3286  commandlen = strlen(command);
3287 
3288  if( conshdlrdata->curruserseeed != NULL )
3289  delete conshdlrdata->curruserseeed;
3290 
3292  SCIP_Bool isfromunpresolved;
3293 
3294  while( (strncmp( command, "presolved", commandlen) != 0 && strncmp( command, "unpresolved", commandlen) != 0) || commandlen == 0)
3295  {
3296  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "Invalid input. Should the new partial decomposition be for the presolved or the unpresolved problem? (type \"presolved\" or \"unpresolved\") : \nGCG/toolbox> ", &command, &endoffile) );
3297  commandlen = strlen(command);
3298  }
3299 
3301  if( strncmp( command, "presolved", commandlen) == 0 )
3302  {
3303  isfromunpresolved = FALSE;
3304  if (conshdlrdata->seeedpool != NULL )
3305  seeedpool = conshdlrdata->seeedpool;
3306  else
3307  {
3308  if( SCIPgetStage(scip) < SCIP_STAGE_PRESOLVED )
3309  {
3310  SCIPinfoMessage(scip, NULL, "Problem is not presolved yet. Please presolve it first!\n");
3311  return SCIP_OKAY;
3312  }
3313 
3314  conshdlrdata->seeedpool = new gcg::Seeedpool(scip, CONSHDLR_NAME, TRUE, SCIPconshdlrDecompDetectBenders(scip));
3315  seeedpool = conshdlrdata->seeedpool;
3316  }
3317  }
3318  else
3319  {
3320  isfromunpresolved = TRUE;
3321  if ( conshdlrdata->seeedpoolunpresolved == NULL )
3322  conshdlrdata->seeedpoolunpresolved = new gcg::Seeedpool(scip, CONSHDLR_NAME, FALSE,SCIPconshdlrDecompDetectBenders(scip));
3323  seeedpool = conshdlrdata->seeedpoolunpresolved;
3324 
3325  }
3326  if( seeedpool == NULL )
3327  {
3328  if( SCIPgetStage(scip) >= SCIP_STAGE_PRESOLVED )
3329 
3330  {
3331  if (conshdlrdata->seeedpool == NULL )
3332  conshdlrdata->seeedpool = new gcg::Seeedpool(scip, CONSHDLR_NAME, TRUE, SCIPconshdlrDecompDetectBenders(scip));
3333  seeedpool = conshdlrdata->seeedpool;
3334  }
3335  else
3336  {
3337  if ( conshdlrdata->seeedpoolunpresolved == NULL)
3338  conshdlrdata->seeedpoolunpresolved = new gcg::Seeedpool(scip, CONSHDLR_NAME, FALSE, SCIPconshdlrDecompDetectBenders(scip));
3339  seeedpool = conshdlrdata->seeedpoolunpresolved;
3340  }
3341 
3342  }
3343  conshdlrdata->curruserseeed = new gcg::Seeed( scip, SCIPconshdlrDecompGetNextSeeedID(scip), seeedpool );
3344  conshdlrdata->curruserseeed->setIsFromUnpresolved(isfromunpresolved);
3345  }
3346 
3349  finished = FALSE;
3350  while ( !finished && selectedsomeseeed )
3351  {
3352  int commandlen2;
3353  SCIP_Bool success;
3354 
3356 
3358 
3359  SCIP_CALL( SCIPdialoghdlrGetWord(dialoghdlr, dialog, "How do you want to proceed the with the current decomposition? (or \"h\" for help) : \nGCG/toolbox> ", &command, &endoffile) );
3360 
3361  commandlen2 = strlen(command);
3362 
3364  if( strncmp( command, "conss", commandlen2) == 0 )
3365  {
3366  SCIPconshdlrDecompToolboxModifyConss(scip, dialoghdlr, dialog);
3367  continue;
3368  }
3369  if( strncmp( command, "vars", commandlen2) == 0 )
3370  {
3371  SCIPconshdlrDecompToolboxModifyVars(scip, dialoghdlr, dialog);
3372  continue;
3373  }
3374 /* if( strncmp( command, "finish", commandlen2) == 0 )
3375  {
3376  SCIPconshdlrDecompToolboxModifyFinish(scip, dialoghdlr, dialog);
3377  continue;
3378  }*/
3379  if( strncmp( command, "refine", commandlen2) == 0 )
3380  {
3381  if( conshdlrdata->lastuserseeed != NULL)
3382  delete conshdlrdata->lastuserseeed;
3383  conshdlrdata->lastuserseeed = new gcg::Seeed( conshdlrdata->curruserseeed) ;
3384  conshdlrdata->curruserseeed->considerImplicits();
3385  continue;
3386  }
3387 
3388  if( strncmp( command, "quit", commandlen2) == 0 )
3389  {
3391  if( !conshdlrdata->curruserseeed->isFromUnpresolved() && conshdlrdata->seeedpool == NULL )
3393 
3394  seeedpool = ( conshdlrdata->curruserseeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool);
3395  assert( seeedpool != NULL );
3396 
3397  conshdlrdata->curruserseeed->sort();
3398  conshdlrdata->curruserseeed->considerImplicits();
3399  conshdlrdata->curruserseeed->calcHashvalue();
3400  assert( conshdlrdata->curruserseeed->checkConsistency() );
3401 
3402 
3403 
3404  if( conshdlrdata->curruserseeed->isComplete() )
3405  {
3406  seeedpool->addSeeedToFinished(conshdlrdata->curruserseeed, &success);
3407  if( !success )
3408  {
3409  delete conshdlrdata->curruserseeed;
3410  }
3411  } else
3412  {
3413  seeedpool->addSeeedToIncomplete(conshdlrdata->curruserseeed, &success);
3414  if( !success )
3415  {
3416  delete conshdlrdata->curruserseeed;
3417  }
3418  }
3419  conshdlrdata->curruserseeed = NULL;
3420  finished = TRUE;
3421 
3422 
3423  continue;
3424  }
3425 
3426  if( strncmp( command, "undo", commandlen2) == 0 )
3427  {
3428  if ( conshdlrdata->lastuserseeed == NULL )
3429  SCIPdialogMessage(scip, NULL, " nothing to be undone \n");
3430  else
3431  {
3432  delete conshdlrdata->curruserseeed;
3433  conshdlrdata->curruserseeed = conshdlrdata->lastuserseeed;
3434  conshdlrdata->lastuserseeed = NULL;
3435  }
3436  continue;
3437  }
3438 
3439 
3440  if( strncmp( command, "visualize", commandlen2) == 0 )
3441  {
3442  SCIP_CALL(SCIPconshdlrDecompSelectVisualizeCurrentUserSeeed(scip, dialoghdlr, dialog ) );
3443  continue;
3444  }
3445 
3446  if( strncmp( command, "propagate", commandlen2) == 0 )
3447  {
3448  SCIP_CALL( SCIPconshdlrDecompToolboxPropagateSeeed(scip, dialoghdlr, dialog) );
3449  continue;
3450  }
3451  if( strncmp( command, "finish", commandlen2) == 0 )
3452  {
3453  SCIP_CALL( SCIPconshdlrDecompToolboxFinishSeeed(scip, dialoghdlr, dialog) );
3454  continue;
3455  }
3456 
3457  if( strncmp( command, "postprocess", commandlen2) == 0 )
3458  {
3459  SCIP_CALL( SCIPconshdlrDecompToolboxPostprocessSeeed(scip, dialoghdlr, dialog) );
3460  continue;
3461  }
3462  }
3463 
3464 
3465  return SCIP_OKAY;
3466 }
3467 
3468 
3471  SCIP* scip
3472  )
3473 {
3474  SCIP_CONSHDLR* conshdlr;
3475  SCIP_CONSHDLRDATA* conshdlrdata;
3476  int decompcounter;
3477 
3478  decompcounter = 0;
3479  assert(scip != NULL);
3480  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3481  assert( conshdlr != NULL );
3482 
3483  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3484  assert(conshdlrdata != NULL);
3485 
3486 
3487  for( int i = 0; i < conshdlrdata->ndecomps; ++i )
3488  {
3489  DECdecompFree(scip, &conshdlrdata->decdecomps[conshdlrdata->ndecomps - i - 1]);
3490  }
3491 
3492  SCIPfreeBlockMemoryArray(scip, &conshdlrdata->decdecomps, conshdlrdata->ndecomps);
3493 
3494  SCIP_CALL_ABORT( SCIPallocBlockMemoryArray(scip, &conshdlrdata->decdecomps, SCIPconshdlrDecompGetNDecdecomps(scip) ) );
3495 
3496  conshdlrdata->ndecomps = SCIPconshdlrDecompGetNDecdecomps(scip) ;
3497 
3498  if( conshdlrdata->seeedpoolunpresolved != NULL )
3499  {
3500  for( int i = 0; i < conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds(); ++i )
3501  {
3502  gcg::Seeed* seeed = conshdlrdata->seeedpoolunpresolved->getFinishedSeeed(i);
3503  conshdlrdata->seeedpoolunpresolved->createDecompFromSeeed(seeed, &conshdlrdata->decdecomps[decompcounter] );
3504  ++decompcounter;
3505  }
3506  }
3507  if( conshdlrdata->seeedpool != NULL )
3508  {
3509  for( int i = 0; i < conshdlrdata->seeedpool->getNFinishedSeeeds(); ++i )
3510  {
3511  gcg::Seeed* seeed = conshdlrdata->seeedpool->getFinishedSeeed(i);
3512  conshdlrdata->seeedpool->createDecompFromSeeed(seeed, &conshdlrdata->decdecomps[decompcounter] );
3513  ++decompcounter;
3514  }
3515  }
3516  return conshdlrdata->decdecomps;
3517 }
3518 
3521  SCIP* scip
3522  )
3523 {
3524  SCIP_CONSHDLR* conshdlr;
3525  SCIP_CONSHDLRDATA* conshdlrdata;
3526  int ndecomps;
3527 
3528  assert(scip != NULL);
3529  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3530  assert( conshdlr != NULL );
3531 
3532  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3533  assert(conshdlrdata != NULL);
3534 
3535  ndecomps = 0;
3536 
3537  if( conshdlrdata->seeedpoolunpresolved != NULL )
3538  ndecomps += conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds();
3539 
3540  if( conshdlrdata->seeedpool != NULL )
3541  ndecomps += conshdlrdata->seeedpool->getNFinishedSeeeds();
3542 
3543  //SCIPinfoMessage
3544 
3545  return ndecomps;
3546  }
3547 
3550  DEC_DETECTOR* detector
3551  )
3552 {
3553  assert(detector != NULL);
3554  return detector->decdata;
3555 
3556 }
3557 
3558 
3561  SCIP* scip,
3562  int id
3563  ){
3564 
3565  SCIP_CONSHDLR* conshdlr;
3566  SCIP_CONSHDLRDATA* conshdlrdata;
3567  gcg::Seeedpool* currseeedpool;
3568  gcg::Seeed* seeed;
3569 
3570  assert(scip != NULL);
3571  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3572  assert( conshdlr != NULL );
3573 
3574  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3575  assert(conshdlrdata != NULL);
3576 
3577  seeed = conshdlrdata->seeedpool->findFinishedSeeedByID(id);
3578  currseeedpool = conshdlrdata->seeedpool;
3579 
3580  if ( seeed == NULL )
3581  {
3582  seeed = conshdlrdata->seeedpoolunpresolved->findFinishedSeeedByID(id);
3583  currseeedpool = conshdlrdata->seeedpoolunpresolved;
3584  }
3585 
3587  if (seeed == NULL)
3588  return -1;
3589 
3590  return currseeedpool->getNConss();
3591 
3592 
3593 }
3594 
3595 
3598  SCIP* scip
3599  )
3600 {
3601  SCIP_CONSHDLR* conshdlr;
3602  SCIP_CONSHDLRDATA* conshdlrdata;
3603  assert(scip != NULL);
3604  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3605  assert( conshdlr != NULL );
3606 
3607  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3608  assert(conshdlrdata != NULL);
3609 
3610  return conshdlrdata->seeedpool;
3611 }
3612 
3615  SCIP* scip
3616  )
3617 {
3618  SCIP_CONSHDLR* conshdlr;
3619  SCIP_CONSHDLRDATA* conshdlrdata;
3620  assert(scip != NULL);
3621  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3622  assert( conshdlr != NULL );
3623 
3624  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3625  assert(conshdlrdata != NULL);
3626 
3627  return conshdlrdata->seeedpoolunpresolved;
3628 }
3629 
3632  SCIP* scip
3633  )
3634 {
3635  SCIP_CONSHDLR* conshdlr;
3636  SCIP_CONSHDLRDATA* conshdlrdata;
3637  assert(scip != NULL);
3638  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3639  assert( conshdlr != NULL );
3640 
3641  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3642  assert(conshdlrdata != NULL);
3643 
3644  if( conshdlrdata->seeedpool == NULL )
3645  conshdlrdata->seeedpool = new gcg::Seeedpool(scip, CONSHDLR_NAME, TRUE, SCIPconshdlrDecompDetectBenders(scip));
3646 
3647 
3648  return SCIP_OKAY;
3649 }
3650 
3653  SCIP* scip
3654  )
3655 {
3656  SCIP_CONSHDLR* conshdlr;
3657  SCIP_CONSHDLRDATA* conshdlrdata;
3658  assert(scip != NULL);
3659  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3660  assert( conshdlr != NULL );
3661 
3662  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3663  assert(conshdlrdata != NULL);
3664 
3665  if( conshdlrdata->seeedpoolunpresolved == NULL )
3666  conshdlrdata->seeedpoolunpresolved = new gcg::Seeedpool(scip, CONSHDLR_NAME, FALSE, SCIPconshdlrDecompDetectBenders(scip));
3667 
3668  return SCIP_OKAY;
3669 }
3670 
3673  SCIP* scip
3674  ){
3675  SCIP_CONSHDLR* conshdlr;
3676  SCIP_CONSHDLRDATA* conshdlrdata;
3677  SEEEDPOOL_WRAPPER* help;
3678 
3679  assert(scip != NULL);
3680  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3681  assert( conshdlr != NULL );
3682 
3683  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3684  assert(conshdlrdata != NULL);
3685 
3686  help = (SEEEDPOOL_WRAPPER*) conshdlrdata->seeedpoolunpresolved;
3687 
3688  return (SEEEDPOOL_WRAPPER*) help;
3689 }
3690 
3693  SCIP* scip
3694  )
3695 {
3696 
3697  SCIP_CONSHDLR* conshdlr;
3698  SCIP_CONSHDLRDATA* conshdlrdata;
3699  SEEEDPOOL_WRAPPER* help;
3700  assert(scip != NULL);
3701  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3702  assert( conshdlr != NULL );
3703 
3704  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3705  assert(conshdlrdata != NULL);
3706 
3707  help = (SEEEDPOOL_WRAPPER*) conshdlrdata->seeedpool;
3708 
3709  return (SEEEDPOOL_WRAPPER*) help;
3710 
3711 }
3712 
3713 
3716  SCIP* scip
3717  )
3718 {
3719  SCIP_CONSHDLR* conshdlr;
3720  SCIP_CONSHDLRDATA* conshdlrdata;
3721  assert(scip != NULL);
3722  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3723  assert( conshdlr != NULL );
3724 
3725  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3726  assert(conshdlrdata != NULL);
3727 
3728  ++conshdlrdata->ncallscreatedecomp;
3729 
3730  return conshdlrdata->ncallscreatedecomp;
3731 }
3732 
3735  SCIP* scip
3736  )
3737 {
3738  SCIP_CONSHDLR* conshdlr;
3739  SCIP_CONSHDLRDATA* conshdlrdata;
3740  assert(scip != NULL);
3741  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3742  assert( conshdlr != NULL );
3743 
3744  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3745  assert(conshdlrdata != NULL);
3746 
3747  --conshdlrdata->ncallscreatedecomp;
3748 
3749  return conshdlrdata->ncallscreatedecomp;
3750 }
3751 
3752 
3753 
3755 const char* DECdetectorGetName(
3756  DEC_DETECTOR* detector
3757  )
3758 {
3759  assert(detector != NULL);
3760  return detector->name;
3761 }
3762 
3765  SCIP* scip,
3766  const char* name
3767  )
3768 {
3769  SCIP_CONSHDLR* conshdlr;
3770  SCIP_CONSHDLRDATA* conshdlrdata;
3771  int i;
3772  assert(scip != NULL);
3773  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3774  if( conshdlr == NULL )
3775  return NULL;
3776 
3777  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3778  assert(conshdlrdata != NULL);
3779 
3780  for( i = 0; i < conshdlrdata->ndetectors; ++i )
3781  {
3782  DEC_DETECTOR *detector;
3783  detector = conshdlrdata->detectors[i];
3784  assert(detector != NULL);
3785  if( strcmp(detector->name, name) == 0 )
3786  {
3787  return detector;
3788  }
3789  }
3790 
3791  return NULL;
3792 }
3793 
3795 SCIP_RETCODE DECincludeDetector(
3796  SCIP* scip,
3797  const char* name,
3798  const char decchar,
3799  const char* description,
3800  int freqCallRound,
3801  int maxCallRound,
3802  int minCallRound,
3803  int freqCallRoundOriginal,
3804  int maxCallRoundOriginal,
3805  int minCallRoundOriginal,
3806  int priority,
3807  SCIP_Bool enabled,
3808  SCIP_Bool enabledOriginal,
3809  SCIP_Bool enabledFinishing,
3810  SCIP_Bool enabledPostprocessing,
3811  SCIP_Bool skip,
3812  SCIP_Bool usefulRecall,
3813  SCIP_Bool legacymode,
3814  DEC_DETECTORDATA* detectordata,
3815  DEC_DECL_DETECTSTRUCTURE((*detectStructure)),
3816  DEC_DECL_FREEDETECTOR((*freeDetector)),
3817  DEC_DECL_INITDETECTOR((*initDetector)),
3818  DEC_DECL_EXITDETECTOR((*exitDetector)),
3819  DEC_DECL_PROPAGATESEEED((*propagateSeeedDetector)),
3820  DEC_DECL_PROPAGATEFROMTOOLBOX((*propagateFromToolboxDetector)),
3821  DEC_DECL_FINISHFROMTOOLBOX((*finishFromToolboxDetector)),
3822  DEC_DECL_FINISHSEEED((*finishSeeedDetector)),
3823  DEC_DECL_POSTPROCESSSEEED((*postprocessSeeedDetector)),
3824  DEC_DECL_SETPARAMAGGRESSIVE((*setParamAggressiveDetector)),
3825  DEC_DECL_SETPARAMDEFAULT((*setParamDefaultDetector)),
3826  DEC_DECL_SETPARAMFAST((*setParamFastDetector))
3827  )
3828 {
3829  SCIP_CONSHDLR* conshdlr;
3830  SCIP_CONSHDLRDATA* conshdlrdata;
3831  DEC_DETECTOR *detector;
3832  char setstr[SCIP_MAXSTRLEN];
3833  char descstr[SCIP_MAXSTRLEN];
3834 
3835  assert(scip != NULL);
3836  assert(name != NULL);
3837  assert(description != NULL);
3838 // assert(detectStructure != NULL);
3839  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3840 
3841  if( conshdlr == NULL )
3842  {
3843  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
3844  return SCIP_ERROR;
3845  }
3846 
3847 // assert(detectStructure != NULL);
3848 
3849  conshdlrdata = SCIPconshdlrGetData(conshdlr);
3850  assert(conshdlrdata != NULL);
3851 
3852  SCIP_CALL( SCIPallocBlockMemory(scip, &detector) );
3853  assert(detector != NULL);
3854 
3855  SCIPdebugMessage("Adding detector %i: %s\n", conshdlrdata->ndetectors+1, name);
3856 
3857 #ifndef NDEBUG
3858  assert(DECfindDetector(scip, name) == NULL);
3859 #endif
3860 
3861  detector->decdata = detectordata;
3862  detector->name = name;
3863  detector->description = description;
3864  detector->decchar = decchar;
3865 
3866  detector->freeDetector = freeDetector;
3867  detector->initDetector = initDetector;
3868  detector->exitDetector = exitDetector;
3869  detector->detectStructure = detectStructure;
3870 
3871  detector->propagateSeeed = propagateSeeedDetector;
3872  detector->propagateFromToolbox = propagateFromToolboxDetector;
3873  detector->finishFromToolbox = finishFromToolboxDetector;
3874  detector->finishSeeed = finishSeeedDetector;
3875  detector->postprocessSeeed = postprocessSeeedDetector;
3876  detector->setParamAggressive = setParamAggressiveDetector;
3877  detector->setParamDefault = setParamDefaultDetector;
3878  detector->setParamFast = setParamFastDetector;
3879 
3880  detector->decchar = decchar;
3881 
3882  detector->freqCallRound = freqCallRound;
3883  detector->maxCallRound = maxCallRound;
3884  detector->minCallRound = minCallRound;
3885  detector->freqCallRoundOriginal = freqCallRoundOriginal;
3886  detector->maxCallRoundOriginal = maxCallRoundOriginal;
3887  detector->minCallRoundOriginal= minCallRoundOriginal;
3888  detector->priority = priority;
3889  detector->enabled = enabled;
3890  detector->enabledOrig = enabledOriginal;
3891  detector->enabledFinishing = enabledFinishing;
3892  detector->enabledPostprocessing = enabledPostprocessing;
3893  detector->skip = skip;
3894  detector->usefulRecall = usefulRecall;
3895  detector->legacymode = legacymode;
3896  detector->overruleemphasis = FALSE;
3897  detector->ndecomps = 0;
3898  detector->decomps = NULL;
3899  detector->dectime = 0.;
3900 
3901  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", name);
3902  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "flag to indicate whether detector <%s> is enabled", name);
3903  SCIP_CALL( SCIPaddBoolParam(scip, setstr, descstr, &(detector->enabled), FALSE, enabled, NULL, NULL) );
3904 
3905  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/origenabled", name);
3906  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "flag to indicate whether detector <%s> is enabled for detecting in the original problem", name);
3907  SCIP_CALL( SCIPaddBoolParam(scip, setstr, descstr, &(detector->enabledOrig), FALSE, enabled, NULL, NULL) );
3908 
3909  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/finishingenabled", name);
3910  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "flag to indicate whether detector <%s> is enabled for finishing of incomplete decompositions", name);
3911  SCIP_CALL( SCIPaddBoolParam(scip, setstr, descstr, &(detector->enabledFinishing), FALSE, enabledFinishing, NULL, NULL) );
3912 
3913  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/postprocessingenabled", name);
3914  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "flag to indicate whether detector <%s> is enabled for postprocessing of finished decompositions", name);
3915  SCIP_CALL( SCIPaddBoolParam(scip, setstr, descstr, &(detector->enabledPostprocessing), FALSE, enabledPostprocessing, NULL, NULL) );
3916 
3917  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/skip", name);
3918  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "flag to indicate whether detector <%s> should be skipped if others found decompositions", name);
3919  SCIP_CALL( SCIPaddBoolParam(scip, setstr, descstr, &(detector->skip), FALSE, skip, NULL, NULL) );
3920 
3921  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/usefullrecall", name);
3922  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "flag to indicate whether detector <%s> should be called on descendants of the current seeed", name);
3923  SCIP_CALL( SCIPaddBoolParam(scip, setstr, descstr, &(detector->usefulRecall), FALSE, usefulRecall, NULL, NULL) );
3924 
3925  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/legacymode", name);
3926  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "flag to indicate whether (old) DETECTSTRUCTURE method of detector <%s> should also be used for detection", name);
3927  SCIP_CALL( SCIPaddBoolParam(scip, setstr, descstr, &(detector->legacymode), FALSE, legacymode, NULL, NULL) );
3928 
3929  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/overruleemphasis", name);
3930  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "flag to indicate whether emphasis settings for detector <%s> should be overruled by normal settings", name);
3931  SCIP_CALL( SCIPaddBoolParam(scip, setstr, descstr, &(detector->overruleemphasis), FALSE, FALSE, NULL, NULL) );
3932 
3933 
3934  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/freqcallround", name);
3935  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "frequency the detector gets called in detection loop ,ie it is called in round r if and only if minCallRound <= r <= maxCallRound AND (r - minCallRound) mod freqCallRound == 0 <%s>", name);
3936  SCIP_CALL( SCIPaddIntParam(scip, setstr, descstr, &(detector->freqCallRound), FALSE, freqCallRound, 0, INT_MAX, NULL, NULL) );
3937 
3938  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/maxcallround", name);
3939  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "maximum round the detector gets called in detection loop <%s>", name);
3940  SCIP_CALL( SCIPaddIntParam(scip, setstr, descstr, &(detector->maxCallRound), FALSE, maxCallRound, 0, INT_MAX, NULL, NULL) );
3941 
3942  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/mincallround", name);
3943  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "minimum round the detector gets called in detection loop <%s>", name);
3944  SCIP_CALL( SCIPaddIntParam(scip, setstr, descstr, &(detector->minCallRound), FALSE, minCallRound, 0, INT_MAX, NULL, NULL) );
3945 
3946  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/origfreqcallround", name);
3947  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "frequency the detector gets called in detection loop,i.e., it is called in round r if and only if minCallRound <= r <= maxCallRound AND (r - minCallRound) mod freqCallRound == 0 <%s>", name);
3948  SCIP_CALL( SCIPaddIntParam(scip, setstr, descstr, &(detector->freqCallRoundOriginal), FALSE, freqCallRoundOriginal, 0, INT_MAX, NULL, NULL) );
3949 
3950  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/origmaxcallround", name);
3951  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "maximum round the detector gets called in detection loop <%s>", name);
3952  SCIP_CALL( SCIPaddIntParam(scip, setstr, descstr, &(detector->maxCallRoundOriginal), FALSE, maxCallRoundOriginal, 0, INT_MAX, NULL, NULL) );
3953 
3954  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/origmincallround", name);
3955  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "minimum round the detector gets called in detection loop <%s>", name);
3956  SCIP_CALL( SCIPaddIntParam(scip, setstr, descstr, &(detector->minCallRoundOriginal), FALSE, minCallRoundOriginal, 0, INT_MAX, NULL, NULL) );
3957 
3958  (void) SCIPsnprintf(setstr, SCIP_MAXSTRLEN, "detection/detectors/%s/priority", name);
3959  (void) SCIPsnprintf(descstr, SCIP_MAXSTRLEN, "priority of detector <%s>", name);
3960  SCIP_CALL( SCIPaddIntParam(scip, setstr, descstr, &(detector->priority), FALSE, priority, INT_MIN, INT_MAX, NULL, NULL) );
3961 
3962 
3963 
3964  SCIP_CALL( SCIPreallocMemoryArray(scip, &conshdlrdata->detectors, (size_t)conshdlrdata->ndetectors+1) );
3965  SCIP_CALL( SCIPreallocMemoryArray(scip, &conshdlrdata->priorities,(size_t) conshdlrdata->ndetectors+1) );
3966 
3967  conshdlrdata->detectors[conshdlrdata->ndetectors] = detector;
3968  conshdlrdata->ndetectors = conshdlrdata->ndetectors+1;
3969 
3970  return SCIP_OKAY;
3971 
3972 }
3973 
3975 SCIP_Real DECgetRemainingTime(
3976  SCIP* scip
3977  )
3978 {
3979  SCIP_Real timelimit;
3980  assert(scip != NULL);
3981  SCIP_CALL_ABORT(SCIPgetRealParam(scip, "limits/time", &timelimit));
3982  if( !SCIPisInfinity(scip, timelimit) )
3983  timelimit -= SCIPgetSolvingTime(scip);
3984  return timelimit;
3985 }
3986 
3989  SCIP* scip,
3990  int seeedid,
3991  int probnr1,
3992  int probnr2,
3993  SCIP_Bool* identical
3994  )
3995 {
3996 
3997  SCIP_CONSHDLR* conshdlr;
3998  SCIP_CONSHDLRDATA* conshdlrdata;
3999  gcg::Seeed* seeed;
4000 
4001  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4002 
4003  if( conshdlr == NULL )
4004  {
4005  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4006  return SCIP_ERROR;
4007  }
4008 
4009  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4010  assert(conshdlrdata != NULL);
4011 
4012  seeed = conshdlrdata->seeedpool->findFinishedSeeedByID(seeedid);
4013 
4014  if ( seeed == NULL )
4015  {
4016  seeed = conshdlrdata->seeedpoolunpresolved->findFinishedSeeedByID(seeedid);
4017  }
4018 
4019 
4020  if( seeed->getNReps() == 0 )
4021  {
4022  SCIPdebugMessage("calc aggregation information for seeed!\n");
4023  seeed->calcAggregationInformation();
4024  }
4025 
4026  assert(seeed != NULL);
4027 
4028  if( seeed->getRepForBlock(probnr1) == seeed->getRepForBlock(probnr2) )
4029  *identical = TRUE;
4030  else
4031  *identical = FALSE;
4032 
4033  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, " block %d and block %d are represented by %d and %d hence they are identical=%d.\n", probnr1, probnr2, seeed->getRepForBlock(probnr1), seeed->getRepForBlock(probnr2), *identical );
4034 
4035  return SCIP_OKAY;
4036 }
4037 
4040  SCIP* scip,
4041  SCIP_HASHMAP** hashorig2pricingvar,
4042  int seeedid,
4043  int probnr1,
4044  int probnr2,
4045  SCIP* scip1,
4046  SCIP* scip2,
4047  SCIP_HASHMAP* varmap
4048  )
4049 {
4050  gcg::Seeed* seeed;
4051  SCIP_CONSHDLR* conshdlr;
4052  SCIP_CONSHDLRDATA* conshdlrdata;
4053  gcg::Seeedpool* currseeedpool;
4054 
4055  int blockid1;
4056  int blockid2;
4057  int representative;
4058  int repid1;
4059  int repid2;
4060  int nblocksforrep;
4061  std::vector<int> pidtopid;
4062 
4063  repid1 = -1;
4064  repid2 = -1;
4065 
4066  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4067 
4068  if( conshdlr == NULL )
4069  {
4070  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4071  return SCIP_ERROR;
4072  }
4073 
4074  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4075  assert(conshdlrdata != NULL);
4076 
4077  seeed = conshdlrdata->seeedpool->findFinishedSeeedByID(seeedid);
4078  currseeedpool = conshdlrdata->seeedpool;
4079 
4080  if ( seeed == NULL )
4081  {
4082  seeed = conshdlrdata->seeedpoolunpresolved->findFinishedSeeedByID(seeedid);
4083  currseeedpool = conshdlrdata->seeedpoolunpresolved;
4084  }
4085 
4086  assert(seeed != NULL);
4087 
4088  if( probnr1 > probnr2 )
4089  {
4090  blockid1 = probnr2;
4091  blockid2 = probnr1;
4092  }
4093  else
4094  {
4095  blockid1 = probnr1;
4096  blockid2 = probnr2;
4097  }
4098 
4099  representative = seeed->getRepForBlock(blockid1);
4100  assert( representative == seeed->getRepForBlock(blockid2) );
4101  nblocksforrep = (int) seeed->getBlocksForRep(representative).size();
4102 
4104  for( int i = 0; i < nblocksforrep; ++i )
4105  {
4106  if( seeed->getBlocksForRep(representative)[i] == blockid1 )
4107  repid1 = i;
4108  if( seeed->getBlocksForRep(representative)[i] == blockid2 )
4109  {
4110  repid2 = i;
4111  break;
4112  }
4113  }
4114 
4116  if( repid1 != 0 )
4117  {
4118  SCIPhashmapFree(&varmap);
4119  varmap = NULL;
4120  SCIPwarningMessage(scip, NULL, "blockid1 should be the representative (hence has id=0 in reptoblocksarray but in fact has %d) \n", repid1);
4121  return SCIP_OKAY;
4122  }
4123 
4124  pidtopid = seeed->getRepVarmap(representative, repid2);
4125 
4126  for( int v = 0; v < SCIPgetNVars(scip2); ++v )
4127  {
4128  SCIP_VAR* var1;
4129  SCIP_VAR* var2;
4130  SCIP_VAR* var1orig;
4131  SCIP_VAR* var2orig;
4132  int var1origid;
4133  int var2origid;
4134  int var1originblockid;
4135  int var2originblockid;
4136 
4137  var2 = SCIPgetVars(scip2)[v];
4138  assert(var2 != NULL);
4139  var2orig = GCGpricingVarGetOriginalVar(var2);
4140  assert(var2orig!=NULL);
4141  var2origid = currseeedpool->getIndexForVar(var2orig) ;
4142  assert(var2origid>=0);
4143  var2originblockid = seeed->getVarProbindexForBlock(var2origid, blockid2) ;
4144  assert(var2originblockid >= 0);
4145  var1originblockid = pidtopid[var2originblockid];
4146  assert(var1originblockid>=0);
4147  var1origid = seeed->getVarsForBlock(blockid1)[var1originblockid];
4148  assert(var1origid>=0);
4149  var1orig = currseeedpool->getVarForIndex(var1origid) ;
4150  assert(var1orig != NULL);
4151  var1 = (SCIP_VAR*) SCIPhashmapGetImage(hashorig2pricingvar[blockid1], (void*) var1orig ) ;
4152  assert(var1 != NULL);
4153 
4154  SCIPhashmapInsert(varmap, (void*) var2, (void*) var1);
4155  }
4156 
4157  return SCIP_OKAY;
4158 }
4159 
4160 
4161 
4164  SCIP* scip,
4165  SCIP_Bool presolved,
4166  SCIP_Bool markedincomplete
4167  )
4168 {
4169  SCIP_CONSHDLR* conshdlr;
4170  SCIP_CONSHDLRDATA* conshdlrdata;
4171  gcg::Seeedpool* currseeedpool;
4172 
4173  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4174 
4175  if( conshdlr == NULL )
4176  {
4177  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4178  return SCIP_ERROR;
4179  }
4180 
4181  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4182  assert(conshdlrdata != NULL);
4183 
4184  if( conshdlrdata->curruserseeed != NULL )
4185  {
4186  SCIPwarningMessage(scip, "there is a current user seeed, it is going to be flushed..!\n");
4187  SCIP_CALL( SCIPconshdlrDecompUserSeeedFlush(scip) );
4188  }
4189 
4190  currseeedpool = presolved ? conshdlrdata->seeedpool : conshdlrdata->seeedpoolunpresolved;
4191 
4192  assert( currseeedpool != NULL );
4193  assert( conshdlrdata->curruserseeed == NULL );
4194 
4195  conshdlrdata->curruserseeed = new gcg::Seeed(scip, currseeedpool->getNewIdForSeeed(), currseeedpool );
4196 
4197  conshdlrdata->curruserseeed->setIsFromUnpresolved( !presolved );
4198 
4199  if( markedincomplete )
4200  conshdlrdata->curruserseeed->setUsergiven(USERGIVEN::PARTIAL);
4201  else
4202  conshdlrdata->curruserseeed->setUsergiven(USERGIVEN::COMPLETED_CONSTOMASTER);
4203 
4204  return SCIP_OKAY;
4205 }
4206 
4208  SCIP* scip
4209  ){
4210  SCIP_CONSHDLR* conshdlr;
4211  SCIP_CONSHDLRDATA* conshdlrdata;
4212 
4213  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4214 
4215  if( conshdlr == NULL )
4216  {
4217  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4218  return SCIP_ERROR;
4219  }
4220 
4221  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4222  assert(conshdlrdata != NULL);
4223 
4224  return conshdlrdata->unpresolveduserseeedadded;
4225 }
4226 
4228  SCIP* scip
4229  ){
4230  SCIP_CONSHDLR* conshdlr;
4231  SCIP_CONSHDLRDATA* conshdlrdata;
4232 
4233  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4234 
4235  if( conshdlr == NULL )
4236  {
4237  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4238  return SCIP_ERROR;
4239  }
4240 
4241  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4242  assert(conshdlrdata != NULL);
4243 
4244  if ( conshdlrdata->seeedpoolunpresolved == NULL )
4245  return FALSE;
4246 
4247 
4248  return ( conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds() > 0 );
4249 
4250 }
4251 
4252 
4253 
4254 
4256  SCIP* scip
4257  )
4258 {
4259 
4260  SCIP_CONSHDLR* conshdlr;
4261  SCIP_CONSHDLRDATA* conshdlrdata;
4262  std::vector<SeeedPtr> unfinishedunpresolved(0);
4263  std::vector<SeeedPtr> unfinishedpresolved(0);
4264  SCIP_Bool selectedexists;
4265  size_t i;
4266 
4267  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4268 
4269  if( conshdlr == NULL )
4270  {
4271  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4272  return SCIP_ERROR;
4273  }
4274 
4275  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4276  assert(conshdlrdata != NULL);
4277 
4278  assert( SCIPconshdlrDecompCheckConsistency(scip) );
4279 
4280  selectedexists = SCIPconshdlrDecompExistsSelected(scip);
4281 
4283  if( conshdlrdata->seeedpoolunpresolved == NULL)
4285 
4286  if( conshdlrdata->seeedpool == NULL)
4288 
4289 
4291  for( i = 0; conshdlrdata->seeedpoolunpresolved != NULL && i < (size_t) conshdlrdata->seeedpoolunpresolved->getNIncompleteSeeeds(); ++i)
4292  {
4293  SeeedPtr seeed;
4294  seeed = conshdlrdata->seeedpoolunpresolved->getIncompleteSeeed( i );
4295  seeed->setIsFromUnpresolved( TRUE );
4296 
4297  if( seeed->isSelected() || (!selectedexists && seeed->getUsergiven() != gcg::USERGIVEN::NOT && !seeed->isComplete() ) )
4298  unfinishedunpresolved.push_back(seeed);
4299  }
4300 
4302  if( unfinishedunpresolved.size() > 0)
4303  SCIPsetBoolParam(scip, "detection/origprob/enabled", TRUE );
4304 
4305 
4307  for( i = 0; i < (size_t) conshdlrdata->seeedpool->getNIncompleteSeeeds(); ++i )
4308  {
4309  SeeedPtr seeed;
4310  seeed = conshdlrdata->seeedpool->getIncompleteSeeed( i );
4311 
4312  if( seeed->isSelected() || (!selectedexists && seeed->getUsergiven() != gcg::USERGIVEN::NOT && !seeed->isComplete() ) )
4313  unfinishedpresolved.push_back(seeed);
4314  }
4315 
4317  conshdlrdata->seeedpoolunpresolved->clearCurrentSeeeds();
4318  conshdlrdata->seeedpool->clearCurrentSeeeds();
4319  // conshdlrdata->seeedpoolunpresolved->incompleteSeeeds.clear();
4320  // conshdlrdata->seeedpool->incompleteSeeeds.clear();
4321 
4323  for( i = 0 ; i < unfinishedunpresolved.size() ; ++i)
4324  {
4325  conshdlrdata->seeedpoolunpresolved->populate(unfinishedunpresolved);
4326  }
4327 
4329  for( i = 0 ; i < unfinishedpresolved.size() ; ++i)
4330  {
4331  conshdlrdata->seeedpool->populate(unfinishedpresolved);
4332  }
4333 
4334  return SCIP_OKAY;
4335 }
4336 
4337 
4338 /*@todo implement */
4339 SCIP_RETCODE SCIPconshdlrDecompgetNSeeeds(
4340  SCIP* scip,
4341  int* nseeeds
4342  )
4343 {
4344  return SCIP_OKAY;
4345 }
4346 
4347 
4349  SCIP* scip
4350  )
4351 {
4352  SCIP_CONSHDLR* conshdlr;
4353  SCIP_CONSHDLRDATA* conshdlrdata;
4354 
4355  int i;
4356 
4357  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4358 
4359  if( conshdlr == NULL )
4360  {
4361  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4362  return SCIP_ERROR;
4363  }
4364 
4365  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4366  assert(conshdlrdata != NULL);
4367 
4368  assert( SCIPconshdlrDecompCheckConsistency(scip) );
4369 
4370  conshdlrdata->startidvisu = 0;
4372  conshdlrdata->listall->clear();
4373 
4374 
4375  if( conshdlrdata->hasrun && conshdlrdata->seeedpool == NULL && conshdlrdata->seeedpoolunpresolved == NULL)
4376  return SCIP_OKAY;
4377 
4379  SCIP_CALL( DECconshdlrDecompSortDecompositionsByScore(scip) );
4380 
4383  for( i = 0; conshdlrdata->seeedpool != NULL && i < conshdlrdata->seeedpool->getNFinishedSeeeds(); ++i )
4384  {
4385  SeeedPtr seeed;
4386  seeed = conshdlrdata->seeedpool->getFinishedSeeed( i );
4387 
4388  conshdlrdata->listall->push_back(seeed);
4389  }
4390 
4392  for( i = 0; conshdlrdata->seeedpool != NULL && i < conshdlrdata->seeedpool->getNIncompleteSeeeds(); ++i)
4393  {
4394  SeeedPtr seeed;
4395  seeed = conshdlrdata->seeedpool->getIncompleteSeeed( i );
4396 
4397  conshdlrdata->listall->push_back(seeed);
4398  }
4399 
4400 
4402  for( i = 0; conshdlrdata->seeedpoolunpresolved != NULL && i < conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds() ; ++i)
4403  {
4404  SeeedPtr seeed;
4405  seeed = conshdlrdata->seeedpoolunpresolved->getFinishedSeeed(i);
4406  seeed->setIsFromUnpresolved( TRUE );
4407  conshdlrdata->listall->push_back(seeed);
4408  }
4409 
4411  for( i = 0; conshdlrdata->seeedpoolunpresolved != NULL && i < conshdlrdata->seeedpoolunpresolved->getNIncompleteSeeeds(); ++i )
4412  {
4413  SeeedPtr seeed;
4414  seeed = conshdlrdata->seeedpoolunpresolved->getIncompleteSeeed( i );
4415  seeed->setIsFromUnpresolved( TRUE );
4416 
4417  conshdlrdata->listall->push_back(seeed);
4418  }
4419 
4420 
4421  return SCIP_OKAY;
4422 }
4423 
4424 
4427  SCIP* scip,
4428  int nblocks
4429  )
4430 {
4431 
4432  SCIP_CONSHDLR* conshdlr;
4433  SCIP_CONSHDLRDATA* conshdlrdata;
4434 
4435  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4436 
4437  if( conshdlr == NULL )
4438  {
4439  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4440  return SCIP_ERROR;
4441  }
4442 
4443  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4444  assert(conshdlrdata != NULL);
4445 
4446  if( conshdlrdata->curruserseeed == NULL )
4447  {
4448  SCIPwarningMessage(scip, "there is no current user seeed, you have to create one..!\n");
4449  return SCIP_OKAY;
4450  }
4451 
4452  conshdlrdata->curruserseeed->setNBlocks(nblocks);
4453 
4454  return SCIP_OKAY;
4455 }
4456 
4459  SCIP* scip
4460  ){
4461  SCIP_CONSHDLR* conshdlr;
4462  SCIP_CONSHDLRDATA* conshdlrdata;
4463 
4464  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4465 
4466  if( conshdlr == NULL )
4467  {
4468  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4469  return SCIP_ERROR;
4470  }
4471 
4472  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4473  assert(conshdlrdata != NULL);
4474 
4475  return conshdlrdata->curruserseeed != NULL;
4476 }
4477 
4478 
4481  SCIP* scip,
4482  SCIP_Bool consdefaulttomaster
4483  )
4484 {
4485 
4486  SCIP_CONSHDLR* conshdlr;
4487  SCIP_CONSHDLRDATA* conshdlrdata;
4488 
4489  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4490 
4491  if( conshdlr == NULL )
4492  {
4493  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4494  return SCIP_ERROR;
4495  }
4496 
4497  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4498  assert(conshdlrdata != NULL);
4499 
4500  if( conshdlrdata->curruserseeed == NULL )
4501  {
4502  SCIPwarningMessage(scip, "there is no current user seeed, you have to create one..!\n");
4503  return SCIP_OKAY;
4504  }
4505 
4506 
4507  conshdlrdata->curruserseeed->setUsergiven( gcg::USERGIVEN::COMPLETED_CONSTOMASTER );
4508 
4509 
4510  return SCIP_OKAY;
4511 }
4512 
4513 
4514 
4517  SCIP* scip,
4518  const char* consname,
4519  int blockid /* block index ( counting from 0) */
4520  )
4521 {
4522  SCIP_CONSHDLR* conshdlr;
4523  SCIP_CONSHDLRDATA* conshdlrdata;
4524  SCIP_CONS* cons;
4525  gcg::Seeedpool* currseeedpool;
4526  int consindex;
4527 
4528  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4529 
4530  if( conshdlr == NULL )
4531  {
4532  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4533  return SCIP_ERROR;
4534  }
4535 
4536  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4537 
4538  assert(conshdlrdata != NULL);
4539 
4540  if( conshdlrdata->curruserseeed == NULL )
4541  {
4542  SCIPwarningMessage(scip, "there is no current user seeed, you have to create one..!\n");
4543  return SCIP_OKAY;
4544  }
4545 
4546  currseeedpool = conshdlrdata->curruserseeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool;
4547  cons = conshdlrdata->curruserseeed->isFromUnpresolved() ? (SCIPfindOrigCons(scip, consname ) == NULL ? SCIPfindCons(scip, consname ): SCIPfindOrigCons(scip, consname )) : SCIPfindCons(scip, consname );
4548  consindex = currseeedpool->getIndexForCons( cons ) ;
4549 
4550  if( blockid >= conshdlrdata->curruserseeed->getNBlocks() )
4551  conshdlrdata->curruserseeed->setNBlocks(blockid+1);
4552  conshdlrdata->curruserseeed->bookAsBlockCons(consindex, blockid);
4553 
4554  return SCIP_OKAY;
4555 }
4556 
4557 
4560  SCIP* scip,
4561  const char* consname
4562  )
4563 {
4564  SCIP_CONSHDLR* conshdlr;
4565  SCIP_CONSHDLRDATA* conshdlrdata;
4566  gcg::Seeedpool* currseeedpool;
4567  int consindex;
4568  SCIP_CONS* cons;
4569 
4570  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4571 
4572  if( conshdlr == NULL )
4573  {
4574  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4575  return SCIP_ERROR;
4576  }
4577 
4578  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4579  assert(conshdlrdata != NULL);
4580 
4581  if( conshdlrdata->curruserseeed == NULL )
4582  {
4583  SCIPwarningMessage(scip, "there is no current user seeed, you have to create one..!\n");
4584  return SCIP_OKAY;
4585  }
4586 
4587  currseeedpool = conshdlrdata->curruserseeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool;
4588 
4589  cons = conshdlrdata->curruserseeed->isFromUnpresolved() ? SCIPfindOrigCons(scip, consname ) : SCIPfindCons(scip, consname );
4590  consindex = currseeedpool->getIndexForCons( cons );
4591 
4592  conshdlrdata->curruserseeed->bookAsMasterCons(consindex);
4593 
4594  return SCIP_OKAY;
4595 
4596 }
4597 
4598 
4601  SCIP* scip,
4602  const char* varname,
4603  int blockid
4604  )
4605 {
4606  SCIP_CONSHDLR* conshdlr;
4607  SCIP_CONSHDLRDATA* conshdlrdata;
4608  gcg::Seeedpool* currseeedpool;
4609  int varindex;
4610 
4611  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4612 
4613  if( conshdlr == NULL )
4614  {
4615  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4616  return SCIP_ERROR;
4617  }
4618 
4619  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4620  assert(conshdlrdata != NULL);
4621 
4622  if( conshdlrdata->curruserseeed == NULL )
4623  {
4624  SCIPwarningMessage(scip, "there is no current user seeed, you have to create one..!\n");
4625  return SCIP_OKAY;
4626  }
4627 
4628  currseeedpool = conshdlrdata->curruserseeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool;
4629  varindex = currseeedpool->getIndexForVar( SCIPfindVar(scip, varname ) );
4630 
4631  if( blockid >= conshdlrdata->curruserseeed->getNBlocks() )
4632  conshdlrdata->curruserseeed->setNBlocks(blockid+1);
4633  conshdlrdata->curruserseeed->bookAsBlockVar(varindex, blockid);
4634 
4635  return SCIP_OKAY;
4636 }
4637 
4638 
4641  SCIP* scip,
4642  const char* varname
4643  )
4644 {
4645  SCIP_CONSHDLR* conshdlr;
4646  SCIP_CONSHDLRDATA* conshdlrdata;
4647  gcg::Seeedpool* currseeedpool;
4648  int varindex;
4649 
4650  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4651 
4652  if( conshdlr == NULL )
4653  {
4654  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4655  return SCIP_ERROR;
4656  }
4657 
4658  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4659  assert(conshdlrdata != NULL);
4660 
4661  if( conshdlrdata->curruserseeed == NULL )
4662  {
4663  SCIPwarningMessage(scip, "there is no current user seeed, you have to create one..!\n");
4664  return SCIP_OKAY;
4665  }
4666 
4667  currseeedpool = conshdlrdata->curruserseeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool;
4668  varindex = currseeedpool->getIndexForVar( SCIPfindVar(scip, varname ) );
4669 
4670  conshdlrdata->curruserseeed->bookAsMasterVar(varindex);
4671 
4672  return SCIP_OKAY;
4673 
4674 }
4675 
4677  SCIP* scip,
4678  int blockNumberCandidate
4679  ){
4680 
4681  SCIP_CONSHDLR* conshdlr;
4682  SCIP_CONSHDLRDATA* conshdlrdata;
4683 
4684  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4685 
4686  if( conshdlr == NULL )
4687  {
4688  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4689  return SCIP_ERROR;
4690  }
4691 
4692  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4693  assert(conshdlrdata != NULL);
4694 
4695  conshdlrdata->userblocknrcandidates->push_back(blockNumberCandidate);
4696 
4697  if( conshdlrdata->seeedpool != NULL ){
4698  conshdlrdata->seeedpool->addUserCandidatesNBlocks(blockNumberCandidate);
4699  }
4700 
4701  if( conshdlrdata->seeedpoolunpresolved != NULL )
4702  conshdlrdata->seeedpoolunpresolved->addUserCandidatesNBlocks(blockNumberCandidate);
4703 
4704  return SCIP_OKAY;
4705 }
4706 
4707 
4709  SCIP* scip
4710  ){
4711  SCIP_CONSHDLR* conshdlr;
4712  SCIP_CONSHDLRDATA* conshdlrdata;
4713 
4714  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4715 
4716  if( conshdlr == NULL )
4717  {
4718  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4719  return SCIP_ERROR;
4720  }
4721 
4722  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4723  assert(conshdlrdata != NULL);
4724 
4725 
4726  return (int) conshdlrdata->userblocknrcandidates->size();
4727 }
4728 
4730  SCIP* scip,
4731  int index
4732  ){
4733  SCIP_CONSHDLR* conshdlr;
4734  SCIP_CONSHDLRDATA* conshdlrdata;
4735 
4736  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4737 
4738  if( conshdlr == NULL )
4739  {
4740  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4741  return SCIP_ERROR;
4742  }
4743 
4744  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4745  assert(conshdlrdata != NULL);
4746 
4747 
4748  return conshdlrdata->userblocknrcandidates->at(index);
4749 }
4750 
4752  SCIP* scip
4753  ){
4754 
4755  SCIP_CONSHDLR* conshdlr;
4756  SCIP_CONSHDLRDATA* conshdlrdata;
4757 
4758  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4759 
4760  if( conshdlr == NULL )
4761  {
4762  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4763  return SCIP_ERROR;
4764  }
4765 
4766  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4767  assert(conshdlrdata != NULL);
4768 
4769  return SCIPclockGetTime( conshdlrdata->completedetectionclock );
4770 }
4771 
4772 
4774  SCIP* scip,
4775  SCIP_Bool transformed
4776  ){
4777 
4778  SCIP_CONSHDLR* conshdlr;
4779  SCIP_CONSHDLRDATA* conshdlrdata;
4780 
4781  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4782 
4783  if( conshdlr == NULL )
4784  {
4785  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4786  return SCIP_ERROR;
4787  }
4788 
4789  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4790  assert(conshdlrdata != NULL);
4791 
4792 
4793  for ( size_t i = 0; i < conshdlrdata->userblocknrcandidates->size(); ++i )
4794  {
4795  if( transformed )
4796  conshdlrdata->seeedpool->addUserCandidatesNBlocks(conshdlrdata->userblocknrcandidates->at(i) );
4797  else
4798  conshdlrdata->seeedpoolunpresolved->addUserCandidatesNBlocks(conshdlrdata->userblocknrcandidates->at(i) );
4799  }
4800 
4801  return SCIP_OKAY;
4802 }
4803 
4804 
4807  SCIP* scip,
4808  const char* varname
4809  )
4810 {
4811  SCIP_CONSHDLR* conshdlr;
4812  SCIP_CONSHDLRDATA* conshdlrdata;
4813  gcg::Seeedpool* currseeedpool;
4814  int varindex;
4815 
4816  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4817 
4818  if( conshdlr == NULL )
4819  {
4820  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4821  return SCIP_ERROR;
4822  }
4823 
4824  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4825  assert(conshdlrdata != NULL);
4826 
4827  if( conshdlrdata->curruserseeed == NULL )
4828  {
4829  SCIPwarningMessage(scip, "there is no current user seeed, you have to create one..!\n");
4830  return SCIP_OKAY;
4831  }
4832 
4833  currseeedpool = conshdlrdata->curruserseeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool;
4834  varindex = currseeedpool->getIndexForVar( SCIPfindVar(scip, varname ) );
4835 
4836  conshdlrdata->curruserseeed->bookAsLinkingVar(varindex);
4837 
4838  return SCIP_OKAY;
4839 
4840 }
4841 
4844  SCIP* scip
4845  )
4846 {
4847  SCIP_CONSHDLR* conshdlr;
4848  SCIP_CONSHDLRDATA* conshdlrdata;
4849  gcg::Seeedpool* currseeedpool;
4850  SeeedPtr seeed;
4851 
4852  char const * usergiveninfo;
4853  char const * presolvedinfo;
4854 
4855  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
4856 
4857  if( conshdlr == NULL )
4858  {
4859  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
4860  return SCIP_ERROR;
4861  }
4862 
4863  conshdlrdata = SCIPconshdlrGetData(conshdlr);
4864  assert(conshdlrdata != NULL);
4865 
4866  if( conshdlrdata->curruserseeed == NULL )
4867  {
4868  SCIPwarningMessage(scip, "there is no current user seeed, you have to create one..!\n");
4869  return SCIP_OKAY;
4870  }
4871 
4872  seeed = conshdlrdata->curruserseeed;
4873  currseeedpool = seeed->isFromUnpresolved() ? conshdlrdata->seeedpoolunpresolved : conshdlrdata->seeedpool;
4874  seeed->setSeeedpool(currseeedpool);
4875  seeed->flushBooked();
4876 
4877  if( seeed->shouldCompletedByConsToMaster() )
4878  {
4879  for( int opencons = 0; opencons < seeed->getNOpenconss(); ++opencons)
4880  seeed->bookAsMasterCons( seeed->getOpenconss()[opencons] );
4881  seeed->flushBooked();
4882  }
4883 
4884  seeed->considerImplicits();
4885  currseeedpool->prepareSeeed(conshdlrdata->curruserseeed);
4886 
4887  if( !seeed->checkConsistency() )
4888  {
4890  SCIPwarningMessage(scip, "seeed that was given by the user was rejected because of inconsistencies! \n");
4891  return SCIP_OKAY;
4892  }
4893  conshdlrdata->curruserseeed->buildDecChainString();
4894  if( conshdlrdata->curruserseeed->isComplete() )
4895  {
4896  if( !seeed->shouldCompletedByConsToMaster() )
4897  conshdlrdata->curruserseeed->setUsergiven( gcg::USERGIVEN::COMPLETE );
4899  if( !conshdlrdata->curruserseeed->isFromUnpresolved() )
4900  {
4901  SCIP_CALL( SCIPconshdlrDecompAddCompleteSeeedForPresolved(scip, conshdlrdata->curruserseeed));
4902 
4903  }
4905  else
4906  {
4907  SCIP_Bool success;
4908  conshdlrdata->seeedpoolunpresolved->addSeeedToFinished(seeed, &success);
4909  conshdlrdata->unpresolveduserseeedadded = TRUE;
4910 
4911  if ( conshdlrdata->seeedpool != NULL ) /* seeedpool for presolved problem already exist try to translate seeed */
4912  {
4913  std::vector<SeeedPtr> seeedtotranslate(0);
4914  std::vector<SeeedPtr> newseeeds(0);
4915  seeedtotranslate.push_back(seeed);
4916  conshdlrdata->seeedpool->translateSeeeds(conshdlrdata->seeedpoolunpresolved, seeedtotranslate, newseeeds);
4917  if( newseeeds.size() != 0 )
4918  {
4919  SCIP_Bool successfullyadded;
4920  conshdlrdata->seeedpool->addSeeedToFinished(newseeeds[0], &successfullyadded);
4921  if ( !successfullyadded )
4922  SCIPinfoMessage(scip, NULL, "Given decomposition is already known to gcg! \n");
4923  }
4924  }
4925  }
4926 
4927  }
4928  else
4929  {
4930  assert( !seeed->shouldCompletedByConsToMaster() );
4931  conshdlrdata->curruserseeed->setUsergiven( gcg::USERGIVEN::PARTIAL );
4932  SCIP_Bool success;
4933 
4934  if ( !conshdlrdata->curruserseeed->isFromUnpresolved() )
4935  SCIP_CALL(SCIPconshdlrDecompAddPartialSeeedForPresolved(scip, conshdlrdata->curruserseeed) );
4936  else
4937  conshdlrdata->seeedpoolunpresolved->addSeeedToIncomplete( conshdlrdata->curruserseeed, &success );
4938 
4939  }
4940 
4944  {
4945  int nvarstoblock = 0;
4946  int nconsstoblock = 0;
4947 
4948  for ( int b = 0; b < conshdlrdata->curruserseeed->getNBlocks(); ++b )
4949  {
4950  nvarstoblock += conshdlrdata->curruserseeed->getNVarsForBlock(b);
4951  nconsstoblock += conshdlrdata->curruserseeed->getNConssForBlock(b);
4952  }
4953  conshdlrdata->curruserseeed->setDetectorPropagated(NULL);
4954 
4955  conshdlrdata->curruserseeed->addClockTime(0.);
4956  conshdlrdata->curruserseeed->addPctVarsFromFree( (nvarstoblock + conshdlrdata->curruserseeed->getNMastervars() +conshdlrdata->curruserseeed->getNLinkingvars())/(SCIP_Real) conshdlrdata->curruserseeed->getNVars() );
4957  conshdlrdata->curruserseeed->addPctVarsToBlock((nvarstoblock )/(SCIP_Real) conshdlrdata->curruserseeed->getNVars() );
4958  conshdlrdata->curruserseeed->addPctVarsToBorder( (conshdlrdata->curruserseeed->getNMastervars() +conshdlrdata->curruserseeed->getNLinkingvars())/(SCIP_Real) conshdlrdata->curruserseeed->getNVars() ) ;
4959  conshdlrdata->curruserseeed->addPctConssToBorder( (conshdlrdata->curruserseeed->getNMasterconss() ) / (SCIP_Real) conshdlrdata->curruserseeed->getNConss() ) ;
4960  conshdlrdata->curruserseeed->addPctConssFromFree( (conshdlrdata->curruserseeed->getNMasterconss() + nconsstoblock ) / (SCIP_Real) conshdlrdata->curruserseeed->getNConss() ) ;
4961  conshdlrdata->curruserseeed->addPctConssToBlock( (nconsstoblock ) / (SCIP_Real) conshdlrdata->curruserseeed->getNConss() );
4962  conshdlrdata->curruserseeed->addNNewBlocks(conshdlrdata->curruserseeed->getNBlocks());
4963  }
4964 
4965  conshdlrdata->curruserseeed->findVarsLinkingToMaster();
4966  conshdlrdata->curruserseeed->findVarsLinkingToStairlinking();
4967 
4968 
4969  if( conshdlrdata->curruserseeed->getUsergiven() == gcg::USERGIVEN::PARTIAL )
4970  usergiveninfo = "partial";
4971  if( conshdlrdata->curruserseeed->getUsergiven() == gcg::USERGIVEN::COMPLETE )
4972  usergiveninfo = "complete";
4973  if( conshdlrdata->curruserseeed->getUsergiven() == gcg::USERGIVEN::COMPLETED_CONSTOMASTER )
4974  usergiveninfo = "complete";
4975  if( conshdlrdata->curruserseeed->isFromUnpresolved() )
4976  presolvedinfo = "unpresolved";
4977  else presolvedinfo = "presolved";
4978 
4979 
4980  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " added %s decomp for %s problem with %d blocks and %d masterconss, %d linkingvars, "
4981  "%d mastervars, and max white score of %s %f \n", usergiveninfo, presolvedinfo,
4982  conshdlrdata->curruserseeed->getNBlocks(), conshdlrdata->curruserseeed->getNMasterconss(),
4983  conshdlrdata->curruserseeed->getNLinkingvars(), conshdlrdata->curruserseeed->getNMastervars(), (conshdlrdata->curruserseeed->isComplete() ? " " : " at best "),
4984  conshdlrdata->curruserseeed->getScore(SCORETYPE::MAX_WHITE) );
4985 
4986  conshdlrdata->curruserseeed = NULL;
4987 
4988  return SCIP_OKAY;
4989 }
4990 
4993  SCIP* scip
4994  )
4995 {
4996  SCIP_CONSHDLR* conshdlr;
4997  SCIP_CONSHDLRDATA* conshdlrdata;
4998 
4999  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5000 
5001  if( conshdlr == NULL )
5002  {
5003  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5004  return SCIP_ERROR;
5005  }
5006 
5007  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5008  assert(conshdlrdata != NULL);
5009 
5010  if( conshdlrdata->curruserseeed == NULL )
5011  {
5012  SCIPwarningMessage(scip, "there is no current user seeed, you have to create one before you can reject it\n");
5013  return SCIP_OKAY;
5014  }
5015 
5016  delete conshdlrdata->curruserseeed;
5017 
5018  conshdlrdata->curruserseeed = NULL;
5019 
5020  return SCIP_OKAY;
5021 }
5022 
5023 
5024 
5025 
5027  SCIP* scip,
5028  SCIP_Bool* success
5029  )
5030 {
5031  SCIP_CONSHDLR* conshdlr;
5032  SCIP_CONSHDLRDATA* conshdlrdata;
5035  std::vector<SeeedPtr> seeedstotranslate(0);
5036  std::vector<SeeedPtr> seeedstranslated(0);
5037  std::vector<SeeedPtr>::iterator seeediter;
5038  std::vector<SeeedPtr>::iterator seeediterend;
5039 
5040  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5041 
5042  *success = FALSE;
5043 
5044  if( conshdlr == NULL )
5045  {
5046  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5047  return SCIP_ERROR;
5048  }
5049 
5050  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5051  assert(conshdlrdata != NULL);
5052 
5053 
5054 
5055  seeedpool = conshdlrdata->seeedpool;
5056  seeedpoolunpresolved = conshdlrdata->seeedpoolunpresolved;
5057 
5058  if( seeedpool == NULL )
5060 
5061  seeedpool = conshdlrdata->seeedpool;
5062 
5063  assert(seeedpool != NULL);
5064  assert(seeedpoolunpresolved != NULL);
5065 
5066  for( int i = 0; i < seeedpoolunpresolved->getNFinishedSeeeds(); ++i )
5067  {
5068  SeeedPtr finseeed = seeedpoolunpresolved->getFinishedSeeed(i);
5069  if( finseeed->isComplete() )
5070  {
5071  assert( finseeed->checkConsistency( ) );
5072  seeedstotranslate.push_back(finseeed);
5073  }
5074  }
5075 
5076 
5077  seeedpool->translateSeeeds(seeedpoolunpresolved, seeedstotranslate, seeedstranslated);
5078 
5079  seeediter = seeedstranslated.begin();
5080  seeediterend = seeedstranslated.end();
5081 
5082 
5083  for(; seeediter != seeediterend; ++seeediter )
5084  {
5085  seeedpool->prepareSeeed( *seeediter);
5086  if( (*seeediter)->isComplete() )
5087  {
5088  SCIP_CALL(SCIPconshdlrDecompAddCompleteSeeedForPresolved(scip, *seeediter ) );
5089  *success = TRUE;
5090 // SCIPdebugMessagePrint(scip, " SUCCESS: unpresolved complete seeed did translate to complete presolved one \n");
5091  }
5092  else {
5093 // SCIPdebugMessagePrint(scip, " unpresolved complete seeed did not translate to complete presolved one \n");
5094  (*seeediter)->completeByConnected();
5095  if ( (*seeediter)->isComplete() )
5096  {
5097  SCIP_CALL(SCIPconshdlrDecompAddCompleteSeeedForPresolved(scip, *seeediter ) );
5098  *success = TRUE;
5099  }
5100  else
5101  SCIP_CALL(SCIPconshdlrDecompAddPartialSeeedForPresolved(scip, *seeediter ) );
5102  }
5103  }
5104 
5105  return SCIP_OKAY;
5106 }
5107 
5110  SCIP* scip,
5111  SCIP_Real oldscore
5112  )
5113 {
5114  SCIP_Real score = oldscore;
5115  int method;
5116 
5117  SCIP_CONSHDLR* conshdlr;
5118  SCIP_CONSHDLRDATA* conshdlrdata;
5119  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5122 
5123  if( conshdlr == NULL )
5124  {
5125  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5126  return SCIP_ERROR;
5127  }
5128 
5129  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5130  assert(conshdlrdata != NULL);
5131 
5132  seeedpool = conshdlrdata->seeedpool;
5133  seeedpoolunpresolved = conshdlrdata->seeedpoolunpresolved;
5134 
5135  SCIP_CALL(SCIPgetIntParam(scip, "detection/origprob/weightinggpresolvedoriginaldecomps", &method) );
5136 
5137  if( method == FRACTION_OF_NNONZEROS )
5138  {
5139  if ( seeedpool == NULL || seeedpoolunpresolved == NULL )
5140  return score;
5141 
5142  score *= (SCIP_Real) seeedpoolunpresolved->getNNonzeros() / seeedpool->getNNonzeros();
5143  }
5144 
5145  if( method == FRACTION_OF_NROWS )
5146  {
5147  if ( seeedpool == NULL || seeedpoolunpresolved == NULL )
5148  return score;
5149 
5150  score *= (SCIP_Real) seeedpoolunpresolved->getNConss() / seeedpool->getNConss();
5151 
5152  }
5153 
5154  if( method == FAVOUR_PRESOLVED )
5155  {
5156  score += 1.;
5157  }
5158 
5159  return score;
5160 }
5161 
5162 SCIP_Bool SCIPconshdlrDecompHasDecomp(
5163  SCIP* scip
5164  )
5165 {
5166  SCIP_CONSHDLR* conshdlr;
5167  SCIP_CONSHDLRDATA* conshdlrdata;
5168  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5169 
5170  if( conshdlr == NULL )
5171  {
5172  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5173  return SCIP_ERROR;
5174  }
5175 
5176  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5177  assert(conshdlrdata != NULL);
5178 
5179  return ( (conshdlrdata->seeedpool != NULL && conshdlrdata->seeedpool->getNFinishedSeeeds() > 0 ) ||
5180  ( conshdlrdata->seeedpool != NULL && conshdlrdata->seeedpool->getNIncompleteSeeeds() > 0 ) ||
5181  ( conshdlrdata->seeedpoolunpresolved != NULL && conshdlrdata->seeedpoolunpresolved->getNIncompleteSeeeds() > 0 ) ||
5182  ( conshdlrdata->seeedpoolunpresolved != NULL && conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds() > 0 ) ) ;
5183 }
5184 
5187  SCIP* scip
5188  )
5189 {
5190  SCIP_CONSHDLR* conshdlr;
5191  SCIP_CONSHDLRDATA* conshdlrdata;
5192  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5193 
5194  if( conshdlr == NULL )
5195  {
5196  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5197  return SCIP_ERROR;
5198  }
5199 
5200  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5201  assert(conshdlrdata != NULL);
5202 
5203  return (conshdlrdata->ndecomps > 0 || (conshdlrdata->seeedpoolunpresolved != NULL && conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds() > 0 ) ) ;
5204 }
5205 
5206 
5208  SCIP* scip
5209  ){
5210  SCIP_CONSHDLR* conshdlr;
5211  SCIP_CONSHDLRDATA* conshdlrdata;
5212 
5213  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5214 
5215  if( conshdlr == NULL )
5216  {
5217  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5218  return SCIP_ERROR;
5219  }
5220 
5221  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5222  assert(conshdlrdata != NULL);
5223 
5224  return conshdlrdata->selectedexists;
5225 }
5226 
5228  SCIP* scip,
5229  SCIP_Bool updatelist
5230  ){
5231 
5232  SCIP_CONSHDLR* conshdlr;
5233  SCIP_CONSHDLRDATA* conshdlrdata;
5234  std::vector<SeeedPtr>::iterator seeediter;
5235  std::vector<SeeedPtr>::iterator seeediterend;
5236 
5237 
5238  std::vector<SeeedPtr> tofinishpresolved(0);
5239  std::vector<SeeedPtr> tofinishunpresolved(0);
5240  std::vector<SeeedPtr> selectedseeeds(0);
5241  std::vector<SeeedPtr> finished(0);
5242  std::vector<SeeedPtr> finishedunpresolved(0);
5243 
5244  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5245 
5246  if( conshdlr == NULL )
5247  {
5248  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5249  return SCIP_ERROR;
5250  }
5251 
5252  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5253  assert(conshdlrdata != NULL);
5254 
5255  SCIPdebugMessage("Starting decomposition candidate choosing \n");
5256 
5257  assert(conshdlrdata->candidates != NULL);
5258 
5259  // std::vector<std::pair<SeeedPtr, SCIP_Real> > candidates(0);
5260  conshdlrdata->candidates->clear();
5261 
5262  if( updatelist )
5264 
5265  for( size_t selid = 0; selid < conshdlrdata->selected->size(); ++selid )
5266  {
5267  selectedseeeds.push_back(conshdlrdata->listall->at(conshdlrdata->selected->at(selid) ) );
5268  }
5269 
5270  if ( selectedseeeds.size() == 0 )
5271  {
5272  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "currently no decomposition is selected, hence every known decomposition is considered: \n");
5273  selectedseeeds = *conshdlrdata->listall;
5274  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "number that is examined: %d \n", selectedseeeds.size() );
5275  }
5276 
5278  seeediter = selectedseeeds.begin();
5279  seeediterend = selectedseeeds.end();
5280 
5281  for( ; seeediter != seeediterend; ++seeediter)
5282  {
5283  if( !(*seeediter)->isComplete() && (*seeediter)->isFromUnpresolved() )
5284  {
5285  tofinishunpresolved.push_back(*seeediter);
5286  }
5287 
5288  if( !(*seeediter)->isComplete() && !(*seeediter)->isFromUnpresolved() )
5289  {
5290  tofinishpresolved.push_back(*seeediter);
5291  }
5292  }
5293 
5294  finished = conshdlrdata->seeedpool->finishIncompleteSeeeds(tofinishpresolved);
5295  if( conshdlrdata->seeedpoolunpresolved != NULL )
5296  finishedunpresolved = conshdlrdata->seeedpoolunpresolved->finishIncompleteSeeeds(tofinishunpresolved);
5297 
5298  seeediter = selectedseeeds.begin();
5299  seeediterend = selectedseeeds.end();
5300 
5301 
5303  for( ; seeediter != seeediterend; ++seeediter )
5304  {
5305  SeeedPtr seeed = *seeediter ;
5306  if( seeed->isComplete() && !seeed->isFromUnpresolved() )
5307  {
5308  conshdlrdata->candidates->push_back( std::pair<SeeedPtr, SCIP_Real>(seeed, seeed->getScore(SCIPconshdlrdataGetScoretype(conshdlrdata)) ) );
5309  }
5310  if( seeed->isComplete() && seeed->isFromUnpresolved() )
5311  {
5312  conshdlrdata->candidates->push_back( std::pair<SeeedPtr, SCIP_Real>(seeed, SCIPconshdlrDecompAdaptScore(scip, seeed->getScore(SCIPconshdlrdataGetScoretype(conshdlrdata)) ) ) );
5313  }
5314  }
5315 
5316  seeediter = finished.begin();
5317  seeediterend = finished.end();
5318 
5319  for( ; seeediter != seeediterend; ++seeediter )
5320  {
5321  conshdlrdata->candidates->push_back(std::pair<SeeedPtr, SCIP_Real>(*seeediter, (*seeediter)->getScore(SCIPconshdlrdataGetScoretype(conshdlrdata)) ) );
5322  }
5323 
5324  seeediter = finishedunpresolved.begin();
5325  seeediterend = finishedunpresolved.end();
5326 
5327  for( ; seeediter != seeediterend; ++seeediter )
5328  {
5329  conshdlrdata->candidates->push_back(std::pair<SeeedPtr, SCIP_Real>(*seeediter, SCIPconshdlrDecompAdaptScore(scip, (*seeediter)->getScore(SCIPconshdlrdataGetScoretype(conshdlrdata)) ) ) );
5330  }
5331 
5332  /* sort decomp candidates according score */
5333  std::sort( conshdlrdata->candidates->begin(), conshdlrdata->candidates->end(), sort_pred() );
5334 
5335  return SCIP_OKAY;
5336 }
5337 
5341  SCIP* scip,
5342  SCIP_RESULT* result
5343  )
5344 {
5345  /* access to relevant data structures of the conshdlr */
5346  SCIP_CONSHDLR* conshdlr;
5347  SCIP_CONSHDLRDATA* conshdlrdata;
5349 
5350  /* detector data and their detection results */
5351  char detectorchaininfo[SCIP_MAXSTRLEN];
5352  int d;
5353  DEC_DETECTOR* detector;
5355  int ndecdecomps;
5356  SCIP_CLOCK* detectorclock;
5357  SCIP_RESULT decResult;
5358 
5359  /* decompositions and seeeds */
5360  gcg::SeeedPtr dummyAncestor;
5361  int dec;
5362  gcg::SeeedPtr seeed;
5363  int dupcount;
5364  SCIP_Bool legacyenabled;
5365  SCIP_Bool onlylegacy;
5366 
5367 
5368  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5369 
5370  if( conshdlr == NULL )
5371  {
5372  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5373  return SCIP_ERROR;
5374  }
5375 
5376  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5377  assert(conshdlrdata != NULL);
5378 
5379  /* check whether legacymode of at least one detector is enabled */
5380  SCIPgetBoolParam(scip, "detection/legacymode/enabled", &legacyenabled);
5381  SCIPgetBoolParam(scip, "detection/legacymode/onlylegacymode", &onlylegacy);
5382 
5383  if( !legacyenabled && !onlylegacy )
5384  return SCIP_OKAY;
5385 
5386  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Start legacy mode detection.\n");
5387 
5388  /* do transformations and initializations if necessary */
5389  if( SCIPgetStage(scip) < SCIP_STAGE_TRANSFORMED )
5390  SCIP_CALL( SCIPtransformProb( scip ) );
5391 
5392  if ( SCIPgetStage(scip) < SCIP_STAGE_PRESOLVED )
5393  SCIP_CALL( SCIPpresolve( scip ) );
5394 
5395  if( SCIPgetStage(scip) == SCIP_STAGE_INIT || SCIPgetNVars(scip) == 0 || SCIPgetNConss(scip) == 0 )
5396  {
5397  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "No problem exists, cannot detect structure!\n");
5398 
5399  *result = SCIP_DIDNOTRUN;
5400  return SCIP_OKAY;
5401  }
5402 
5403  if ( conshdlrdata->seeedpool == NULL )
5404  conshdlrdata->seeedpool = new gcg::Seeedpool( scip, CONSHDLR_NAME, TRUE, SCIPconshdlrDecompDetectBenders(scip) );
5405 
5406  seeedpool = conshdlrdata->seeedpool;
5407 
5408  dummyAncestor = new gcg::Seeed( scip, seeedpool->getNewIdForSeeed(), seeedpool );
5409  seeedpool->addSeeedToAncestor( dummyAncestor );
5410 
5411  SCIPdebugMessagePrint(scip, "Checking %d detectors for legacy mode.\n", conshdlrdata->ndetectors);
5412 
5413  /* for each detector: check whether legacymode is enabled */
5414  for( d = 0; d < conshdlrdata->ndetectors; ++d )
5415  {
5416  decdecomps = NULL;
5417  ndecdecomps = -1;
5418  detector = conshdlrdata->detectors[d];
5419  assert(detector != NULL);
5420 
5421  if( detector->legacymode )
5422  {
5423  if( detector->detectStructure == NULL )
5424  {
5425  SCIPverbMessage( scip, SCIP_VERBLEVEL_NORMAL , NULL,
5426  "Legacy mode is not supported by detector <%s>.\n", detector->name );
5427  }
5428  else
5429  {
5430  SCIPverbMessage( scip, SCIP_VERBLEVEL_NORMAL , NULL,
5431  "Start legacy mode detection for detector <%s>.\n", detector->name );
5432 
5433  /* measure time detector needs for detecting decompositions */
5434  SCIPcreateClock( scip, & detectorclock );
5435  SCIP_CALL_ABORT( SCIPstartClock( scip, detectorclock ) );
5436 
5437  /* call old detectStructure callback method */
5438  SCIP_CALL( (*detector->detectStructure)( scip, detector->decdata, &decdecomps, &ndecdecomps, &decResult ) );
5439 
5440  SCIP_CALL_ABORT( SCIPstopClock( scip, detectorclock ) );
5441 
5442  if( decResult == SCIP_SUCCESS )
5443  {
5444  /* check for duplicates and redundant information */
5445  for( dec = 0; dec < ndecdecomps; ++dec )
5446  {
5447  assert( decdecomps[dec] != NULL );
5448  }
5449  if( ndecdecomps > 2 )
5450  {
5451  int nunique = DECfilterSimilarDecompositions(scip, decdecomps, ndecdecomps);
5452 
5453  for( dec = nunique; dec < ndecdecomps; ++dec )
5454  {
5455  SCIP_CALL( DECdecompFree(scip, &(decdecomps[dec])) );
5456  decdecomps[dec] = NULL;
5457  }
5458 
5459  ndecdecomps = nunique;
5460  }
5461 
5462  SCIPdebugMessagePrint( scip, "Translate %d non-redundant decompositions into seeeds.\n", ndecdecomps );
5463 
5464  /* set up detectorchaininfo */
5465  SCIPsnprintf( detectorchaininfo, SCIP_MAXSTRLEN, "%c(lgc)", detector->decchar );
5466 
5467  dupcount = 0;
5468 
5469  /* translate found decompositions to seeeds and add them to (presolved) seeedpool */
5470  for( dec = 0; dec < ndecdecomps; ++dec )
5471  {
5472  seeedpool->createSeeedFromDecomp( decdecomps[dec], &seeed );
5473 
5474  seeed->setDetectorChainString( detectorchaininfo );
5475 
5476  /* set statistical data */
5477  seeed->setDetectorPropagated(detector);
5478  /* @todo this is actually the whole detector time! in propagate seeeds methods, time of each seeed
5479  * is set after detecting this seeed */
5480  seeed->addClockTime( SCIPgetClockTime( scip, detectorclock ) );
5481  seeed->addDecChangesFromAncestor( dummyAncestor );
5482  seeed->setLegacymode( true );
5483 
5484  SCIP_Bool success = TRUE;
5485  seeedpool->addSeeedToFinished( seeed, &success );
5486 
5487  if( success == FALSE )
5488  {
5489  ++dupcount;
5490  }
5491  }
5492 
5493  if ( dupcount > 0 )
5494  {
5495  SCIPdebugMessagePrint( scip, "%d of the resulting seeeds are already contained in the seeedpool.\n", dupcount );
5496  }
5497 
5498  SCIPfreeClock( scip, & detectorclock );
5499  }
5500  else
5501  {
5502  SCIPdebugPrintf( "Failure!\n" );
5503  }
5504  SCIPfreeMemoryArrayNull( scip, &decdecomps ); // @todo necessary/correct?
5505  }
5506  }
5507  }
5508 
5509  seeedpool->sortFinishedForScore();
5510 
5511  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Finished legacy mode detection.\n");
5512 
5513  *result = SCIP_SUCCESS;
5514  return SCIP_OKAY;
5515 }
5516 
5517 
5518 
5525  SCIP* scip
5526  ){
5527 
5528  SCIP_CONSHDLR* conshdlr;
5529  SCIP_CONSHDLRDATA* conshdlrdata;
5530  int i;
5531  int selectedcounter;
5532 
5533  std::vector<int> livingnoncompleteseeedids(0);
5534  std::vector<int>::const_iterator selectediter;
5535  std::vector<int>::const_iterator selectediterend;
5536 
5537  std::vector<SeeedPtr>::const_iterator seeediter;
5538  std::vector<SeeedPtr>::const_iterator seeediterend;
5539 
5540 
5541  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5542 
5543  if( conshdlr == NULL )
5544  {
5545  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5546  return SCIP_ERROR;
5547  }
5548 
5549  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5550  assert(conshdlrdata != NULL);
5551 
5553  if( conshdlrdata->seeedpool != NULL)
5554  {
5555  for( i = 0; i < conshdlrdata->seeedpool->getNFinishedSeeeds(); ++i )
5556  {
5557  SeeedPtr seeed = conshdlrdata->seeedpool->getFinishedSeeed( i );
5558 
5559  for( int j = 0; j < seeed->getNAncestors(); ++j )
5560  {
5561  int id = seeed->getAncestorID( j );
5562  if( SCIPconshdlrDecompGetSeeed(scip, id) == NULL )
5563  {
5564  SCIPwarningMessage(scip, "Warning: presolved seeed %d has an ancestor (id: %d) that is not found! \n", seeed->getID(), id );
5565  return FALSE;
5566  }
5567  }
5568  }
5569  }
5570 
5571 
5572  if( conshdlrdata->seeedpoolunpresolved != NULL )
5573  {
5574  for( i = 0; i < conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds(); ++i )
5575  {
5576  SeeedPtr seeed = conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i );
5577 
5578  for( int j = 0; j < seeed->getNAncestors(); ++j )
5579  {
5580  int id = seeed->getAncestorID( j );
5581  if( SCIPconshdlrDecompGetSeeed(scip, id) == NULL )
5582  {
5583  SCIPwarningMessage(scip, "Warning: unpresolved seeed %d has an ancestor (id: %d) that is not found! \n", seeed->getID(), id );
5584  return FALSE;
5585  }
5586  }
5587  }
5588  }
5589 
5592  selectediter = conshdlrdata->selected->begin();
5593  selectediterend = conshdlrdata->selected->end();
5594 
5595  selectedcounter = 0;
5596 
5597  for( ; selectediter != selectediterend; ++selectediter )
5598  {
5599  SeeedPtr seeed = conshdlrdata->listall->at(*selectediter);
5600 
5601  if( !seeed->isSelected() )
5602  {
5603  SCIPwarningMessage(scip, "Warning: seeed %d is not selected but in slected list \n", seeed->getID() );
5604  return FALSE;
5605  }
5606  }
5607 
5608  seeediter = conshdlrdata->listall->begin();
5609  seeediterend = conshdlrdata->listall->end();
5610 
5611  for( ; seeediter != seeediterend; ++seeediter )
5612  {
5613  if( (*seeediter)->isSelected() )
5614  ++selectedcounter;
5615  }
5616 
5617  if( (size_t) selectedcounter != conshdlrdata->selected->size() )
5618  {
5619  SCIPwarningMessage(scip, "Warning: there are selected seeeds not part of the list (selectedcounter: %d, nselected list> %d) \n", selectedcounter, (int) conshdlrdata->selected->size() );
5620  return FALSE;
5621  }
5622 
5623 
5626  if( conshdlrdata->selectedexists != (conshdlrdata->selected->size() > 0) )
5627  {
5628  SCIPwarningMessage(scip, "Warning: selectedexists is %d but number of selected is %d \n", conshdlrdata->selectedexists, conshdlrdata->selected->size() );
5629  return FALSE;
5630  }
5631 
5632 
5633 
5634  return TRUE;
5635 }
5636 
5639  SCIP* scip
5640  ){
5641 
5642  SCIP_CONSHDLR* conshdlr;
5643  SCIP_CONSHDLRDATA* conshdlrdata;
5644 
5645  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5646 
5647  if( conshdlr == NULL )
5648  {
5649  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5650  return SCIP_ERROR;
5651  }
5652 
5653  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5654  assert(conshdlrdata != NULL);
5655 
5656  return ++conshdlrdata->seeedcounter;
5657  }
5658 
5659 
5661  SCIP* scip
5662  )
5663 {
5664 
5665  SCIP_CONSHDLR* conshdlr;
5666  SCIP_CONSHDLRDATA* conshdlrdata;
5667 
5668  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5669 
5670  if( conshdlr == NULL )
5671  {
5672  SCIPerrorMessage("Decomp constraint handler is not included, cannot add detector!\n");
5673  return SCIP_ERROR;
5674  }
5675 
5676  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5677  assert(conshdlrdata != NULL);
5678 
5679  if( conshdlrdata->seeedpool != NULL )
5680  conshdlrdata->seeedpool->sortFinishedForScore();
5681 
5682 
5683  if( conshdlrdata->seeedpoolunpresolved != NULL )
5684  conshdlrdata->seeedpoolunpresolved->sortFinishedForScore();
5685 
5686 
5687 
5688  return SCIP_OKAY;
5689 }
5690 
5692 SCIP_RETCODE DECdetectStructure(
5693  SCIP* scip,
5694  SCIP_RESULT* result
5695  )
5696 {
5697  SCIP_CONSHDLR* conshdlr;
5698  SCIP_CONSHDLRDATA* conshdlrdata;
5699  SCIP_Bool onlylegacymode;
5700 
5701  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
5702  assert(conshdlr != NULL);
5703 
5704  conshdlrdata = SCIPconshdlrGetData(conshdlr);
5705  assert(conshdlrdata != NULL);
5706 
5707  if( conshdlrdata->seeedpool != NULL )
5708  {
5709  delete conshdlrdata->seeedpool;
5710  conshdlrdata->seeedpool = NULL;
5711  }
5712 
5713  *result = SCIP_DIDNOTRUN;
5714 
5715 
5716  if( SCIPgetNOrigVars(scip) == 0 && SCIPgetNOrigConss(scip) == 0 )
5717  return SCIP_OKAY;
5718 
5719  /* if the original problem should be solved, then no decomposition will be performed */
5721  return SCIP_OKAY;
5722 
5723  SCIP_CALL(SCIPresetClock(scip, conshdlrdata->completedetectionclock));
5724  SCIP_CALL(SCIPstartClock(scip, conshdlrdata->completedetectionclock));
5725 
5726 
5727  /* check whether only legacy mode should be executed */
5728  SCIPgetBoolParam(scip, "detection/legacymode/onlylegacymode", &onlylegacymode);
5729 
5730  SCIPdebugMessage("start only legacy mode? %s \n", (onlylegacymode ? "yes": "no") );
5731  if( !onlylegacymode )
5732  {
5733  std::vector<std::pair<int, int>> candidatesNBlocks(0);
5734  std::vector<gcg::ConsClassifier*> consClassDistributions;
5735  std::vector<gcg::VarClassifier*> varClassDistributions;
5737  std::vector<SCIP_CONS*> indexToCons;
5738  std::vector<gcg::SeeedPtr> seeedsunpresolved(0);
5739  int i;
5740  SCIP_Bool presolveOrigProblem;
5741  SCIP_Bool calculateOrigDecomps;
5742  SCIP_Bool classifyOrig;
5743 
5745  SCIP_Bool detectonlyorig;
5746 
5747  assert(scip != NULL);
5748 
5749  presolveOrigProblem = TRUE;
5750  detectonlyorig = FALSE;
5751 
5752  SCIPgetBoolParam(scip, "detection/origprob/enabled", &calculateOrigDecomps);
5753  SCIPgetBoolParam(scip, "detection/origprob/classificationenabled", &classifyOrig);
5754 
5756  SCIPdebugMessage("is seeedpoolunpresolved not initilized yet but needed ? %s -> %s create it \n", (conshdlrdata->seeedpoolunpresolved == NULL ? "yes" : "no"), (conshdlrdata->seeedpoolunpresolved == NULL ? "" : "Do not") );
5757 
5759  if( SCIPgetStage(scip) < SCIP_STAGE_PRESOLVED )
5760  detectonlyorig = TRUE;
5761 
5762  if ( conshdlrdata->seeedpoolunpresolved == NULL && ( classifyOrig || calculateOrigDecomps || detectonlyorig) )
5763  conshdlrdata->seeedpoolunpresolved = new gcg::Seeedpool(scip, CONSHDLR_NAME, FALSE, SCIPconshdlrDecompDetectBenders(scip));
5766  SCIP_CALL(SCIPstopClock(scip, conshdlrdata->completedetectionclock));
5767 
5768  SCIPdebugMessage("is stage < transformed ? %s -> do %s transformProb() ", (SCIPgetStage(scip) < SCIP_STAGE_TRANSFORMED ? "yes" : "no"), (SCIPgetStage(scip) < SCIP_STAGE_TRANSFORMED ? "" : "not") );
5769  if( SCIPgetStage(scip) < SCIP_STAGE_TRANSFORMED )
5770  SCIP_CALL(SCIPtransformProb(scip));
5771 
5772  SCIP_CALL(SCIPstartClock(scip, conshdlrdata->completedetectionclock));
5773 
5775  if( classifyOrig || detectonlyorig )
5776  {
5777  SCIPdebugMessage("classification for orig problem enabled: calc classifier and nblock candidates \n" );
5778  conshdlrdata->seeedpoolunpresolved->calcClassifierAndNBlockCandidates(scip);
5779  candidatesNBlocks = conshdlrdata->seeedpoolunpresolved->getSortedCandidatesNBlocksFull();
5780  if( conshdlrdata->seeedpoolunpresolved != NULL && SCIPgetVerbLevel(scip) >= SCIP_VERBLEVEL_FULL )
5781  conshdlrdata->seeedpoolunpresolved->printBlockcandidateInformation(scip, NULL);
5782  }
5783  else
5784  SCIPdebugMessage("classification for orig problem disabled \n" );
5785 
5787  if( calculateOrigDecomps || detectonlyorig )
5788  {
5789  SCIPdebugMessage("start finding decompositions for original problem!\n" );
5790  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "start finding decompositions for original problem!\n");
5791  seeedsunpresolved = conshdlrdata->seeedpoolunpresolved->findSeeeds();
5792  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "finished finding decompositions for original problem!\n");
5793  SCIPdebugMessage("finished finding decompositions for original problem!\n" );
5794  } else
5795  SCIPdebugMessage("finding decompositions for original problem is NOT enabled!\n" );
5796 
5798  if( classifyOrig )
5799  {
5800  for( i = 0; i < conshdlrdata->seeedpoolunpresolved->getNConsClassifiers(); ++i )
5801  {
5802  gcg::ConsClassifier* classifier = new gcg::ConsClassifier(
5803  conshdlrdata->seeedpoolunpresolved->getConsClassifier(i));
5804  consClassDistributions.push_back(classifier);
5805  }
5806  for( i = 0; i < conshdlrdata->seeedpoolunpresolved->getNVarClassifiers(); ++i )
5807  {
5808  gcg::VarClassifier* classifier = new gcg::VarClassifier(conshdlrdata->seeedpoolunpresolved->getVarClassifier(i));
5809  varClassDistributions.push_back(classifier);
5810  }
5811  }
5812 
5813  SCIP_CALL(SCIPstopClock(scip, conshdlrdata->completedetectionclock));
5814 
5815  if( !detectonlyorig )
5816  {
5817 
5818  //Presolving
5819  if( presolveOrigProblem )
5820  SCIP_CALL(SCIPpresolve(scip));
5821 
5824  if( SCIPgetStage(scip) == SCIP_STAGE_INIT || SCIPgetNVars(scip) == 0 || SCIPgetNConss(scip) == 0 )
5825  {
5826  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "No problem exists, cannot detect structure!\n");
5827 
5829  if( SCIPgetNVars(scip) == 0 || SCIPgetNConss(scip) == 0 )
5830  conshdlrdata->hasrun = TRUE;
5831 
5832  *result = SCIP_DIDNOTRUN;
5833  return SCIP_OKAY;
5834  }
5835 
5837  SCIP_CALL(SCIPresetClock(scip, conshdlrdata->detectorclock));
5838  SCIP_CALL(SCIPstartClock(scip, conshdlrdata->detectorclock));
5839  SCIP_CALL(SCIPstartClock(scip, conshdlrdata->completedetectionclock));
5840  if( conshdlrdata->seeedpool == NULL )
5841  {
5842  SCIPdebugMessagePrint(scip, "start creating seeedpool for current problem \n");
5843  conshdlrdata->seeedpool = new gcg::Seeedpool(scip, CONSHDLR_NAME, TRUE, SCIPconshdlrDecompDetectBenders(scip));
5844  SCIPdebugMessagePrint(scip, "created seeedpool for current problem, n detectors: %d \n", conshdlrdata->ndetectors);
5845  }
5846  else
5847  SCIPdebugMessagePrint(scip, "seeedpool is not NULL \n");
5848 
5849  conshdlrdata->seeedpool->calcClassifierAndNBlockCandidates(scip);
5850 
5852  if( calculateOrigDecomps || classifyOrig )
5853  {
5854  std::vector<gcg::Seeed*> translatedSeeeds(0);
5855  std::vector<gcg::ConsClassifier*> translatedConsDistributions(0);
5856  std::vector<gcg::VarClassifier*> translatedVarDistributions(0);
5857 
5858  conshdlrdata->seeedpool->translateSeeedData(conshdlrdata->seeedpoolunpresolved, seeedsunpresolved,
5859  translatedSeeeds, consClassDistributions, translatedConsDistributions, varClassDistributions,
5860  translatedVarDistributions);
5861 
5862  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL , NULL, "number of translated original seeeds: %d \n " , translatedSeeeds.size() );
5863 
5864  conshdlrdata->seeedpool->populate(translatedSeeeds);
5865 
5866  for( size_t d = 0; d < translatedConsDistributions.size(); ++d )
5867  conshdlrdata->seeedpool->addConsClassifier(translatedConsDistributions[d]);
5868 
5869  for( size_t d = 0; d < translatedVarDistributions.size(); ++d )
5870  conshdlrdata->seeedpool->addVarClassifier(translatedVarDistributions[d]);
5871 
5872  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL , NULL, "finished translate seeed method!\n");
5873 
5874  for( size_t c = 0; c < candidatesNBlocks.size(); ++c )
5875  conshdlrdata->seeedpool->addCandidatesNBlocksNVotes(candidatesNBlocks[c].first, candidatesNBlocks[c].second );
5876  }
5877  }
5878 
5879  for( int j = 0; j < (int) consClassDistributions.size(); ++j )
5880  delete consClassDistributions[j];
5881 
5882  for( int j = 0; j < (int) varClassDistributions.size(); ++j )
5883  delete varClassDistributions[j];
5884 
5885  if( !detectonlyorig )
5886  {
5887  conshdlrdata->seeedpool->findDecompositions();
5888  SCIP_CALL(SCIPstopClock(scip, conshdlrdata->detectorclock));
5889  }
5890 
5891  if( conshdlrdata->seeedpool != NULL && conshdlrdata->seeedpool->getNFinishedSeeeds() > 0 )
5892  *result = SCIP_SUCCESS;
5893 
5894 // SCIPdebugMessage("Sorting %i detectors\n", conshdlrdata->ndetectors);
5895 // SCIPsortIntPtr(conshdlrdata->priorities, (void**)conshdlrdata->detectors, conshdlrdata->ndetectors);
5896 
5897  // seeedpool.freeCurrSeeeds();
5898 
5899  if( conshdlrdata->seeedpoolunpresolved != NULL && conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds() > 0 )
5900  *result = SCIP_SUCCESS;
5901 
5902  SCIPdebugMessage("Detection took %fs\n", SCIPclockGetTime(conshdlrdata->detectorclock));
5903 
5904  } /* end of if( !onlylegacy ) */
5905 
5906 
5907  if( conshdlrdata->seeedpool != NULL && SCIPgetVerbLevel(scip) >= SCIP_VERBLEVEL_FULL )
5908  conshdlrdata->seeedpool->printBlockcandidateInformation(scip, NULL);
5909 
5910  SCIP_CALL(SCIPstartClock(scip, conshdlrdata->completedetectionclock) );
5912  SCIP_CALL(SCIPstopClock(scip, conshdlrdata->completedetectionclock) );
5913 
5914  if( *result == SCIP_DIDNOTRUN )
5915  {
5916  return SCIP_OKAY;
5917  }
5918 
5919 // if( conshdlrdata->ndecomps > 0 )
5920 // {
5921 // SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Chosen decomposition with %d blocks of type %s.\n",
5922 // DECdecompGetNBlocks(conshdlrdata->decdecomps[0]), DECgetStrType(DECdecompGetType(conshdlrdata->decdecomps[0])));
5923 // // SCIP_CALL( GCGsetStructDecdecomp(scip, conshdlrdata->decdecomps[0]) );
5924 // *result = SCIP_SUCCESS;
5925 // }
5926 // else
5927 // {
5928 // assert(conshdlrdata->ndecomps == 0);
5929 // SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "No decomposition found -- solving with one single block.\n");
5930 // SCIP_CALL( createOneBlockDecomp(scip) );
5931 // *result = SCIP_SUCCESS;
5932 // }
5933 
5934  /* show that we done our duty */
5935  conshdlrdata->hasrun = TRUE;
5936  *result = SCIP_SUCCESS;
5938 
5939 
5940 // SCIPhashmapFree( &consToIndex );
5941 
5942  return SCIP_OKAY;
5943 }
5944 
5946 //SCIP_RETCODE DECgetSeeedpoolData(
5947 // SCIP* scip, /**< SCIP data structure */
5948 // int** candidatesNBlocks, /**< pointer to store candidates for number of blocks calculated by the seeedpool */
5949 // int* nCandidates, /**< pointer to store number of candidates for number of blocks calculated by the seeedpool */
5950 // int*** consClasses, /**< pointer to store the collection of different constraint class distributions */
5951 // int* nConsClassDistributions, /**< pointer to store number of constraint class distributions */
5952 // int** nClassesOfDistribution, /**< pointer to store numbers of classes of the distributions */
5953 // SCIP_HASHMAP* consToIndex, /**< hashmap from constraints to indices, to be filled */
5954 // int* nConss /**< pointer to store number of constraints */
5955 // )
5956 //{
5957 // std::cout << "SEEEDPOOL 1" << std::endl;
5958 // gcg::Seeedpool seeedpool(scip, CONSHDLR_NAME, TRUE);
5959 //
5960 // std::vector<int> candidatesNBlocksVector = seeedpool.getCandidatesNBlocks();
5961 // *nCandidates = (int)candidatesNBlocksVector.size();
5962 // SCIP_CALL( SCIPallocMemoryArray(scip, &(candidatesNBlocks), *nCandidates) );
5963 // for( int i = 0; i < *nCandidates; ++i )
5964 // (*candidatesNBlocks)[i] = candidatesNBlocksVector[i];
5965 //
5966 // std::vector<std::vector<int>> consClassesVector;
5967 // for( int i = 0; i < seeedpool.getNConssClassDistributions(); ++i )
5968 // consClassesVector.push_back(seeedpool.getConssClassDistributionVector(i));
5969 // *nConsClassDistributions = seeedpool.getNConssClassDistributions();
5970 // SCIP_CALL( SCIPallocMemoryArray(scip, &(consClasses), *nConsClassDistributions) );
5971 // SCIP_CALL( SCIPallocMemoryArray(scip, &(nClassesOfDistribution), *nConsClassDistributions) );
5972 // for( int i = 0; i < *nConsClassDistributions; ++i )
5973 // {
5974 // (*nClassesOfDistribution)[i] = seeedpool.getNClassesOfDistribution(i);
5975 // SCIP_CALL( SCIPallocMemoryArray(scip, &(consClasses[i]), (*nClassesOfDistribution)[i]) );
5976 // }
5977 // for( int i = 0; i < (int)consClassesVector.size(); ++i )
5978 // {
5979 // for( int j = 0; j < (int)consClassesVector[i].size(); ++j )
5980 // {
5981 // (*consClasses)[i][j] = consClassesVector[i][j];
5982 // }
5983 // }
5984 //
5985 // *nConss = seeedpool.getNConss();
5986 // SCIP_CALL_ABORT( SCIPhashmapCreate( &consToIndex, SCIPblkmem(scip), *nConss ) );
5987 // for( int i = 0; i < seeedpool.getNConss(); ++i )
5988 // SCIP_CALL_ABORT( SCIPhashmapInsert(consToIndex, seeedpool.getConsForIndex(i), (void*) (size_t) i ) );
5989 //
5990 //
5991 // return SCIP_OKAY;
5992 //}
5993 
5995 SCIP_RETCODE DECwriteAllDecomps(
5996  SCIP* scip,
5997  char* directory,
5998  char* extension,
5999  SCIP_Bool original,
6000  SCIP_Bool presolved
6002  )
6003 {
6004  MiscVisualization* misc = new MiscVisualization();
6005  SCIP_CONSHDLR* conshdlr;
6006  SCIP_CONSHDLRDATA* conshdlrdata;
6007  char outname[SCIP_MAXSTRLEN];
6008  char tempstring[SCIP_MAXSTRLEN];
6009  int i;
6010  SCIP_Bool nodecomps;
6011 
6012  int maxtowrite;
6013  int nwritten;
6014 
6015  assert(scip != NULL);
6016  assert(extension != NULL);
6017 
6018  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6019  assert(conshdlr != NULL);
6020 
6021  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6022  assert(conshdlrdata != NULL);
6023 
6024  maxtowrite = -1;
6025  nwritten = 0;
6026 
6027  nodecomps = ( conshdlrdata->seeedpool == NULL && conshdlrdata->seeedpoolunpresolved == NULL );
6028 
6029  nodecomps = nodecomps || ( !presolved && !original );
6030 
6031  nodecomps = nodecomps || (
6032  ( presolved && conshdlrdata->seeedpool != NULL && conshdlrdata->seeedpool->getNFinishedSeeeds() == 0) &&
6033  ( original && conshdlrdata->seeedpoolunpresolved != NULL && conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds() == 0)
6034  )
6035  ;
6036 
6037 
6038  if( presolved && conshdlrdata->seeedpool != NULL && conshdlrdata->seeedpool->getNFinishedSeeeds() == 0 )
6039  {
6040  SCIPwarningMessage(scip, "No decomposition available.\n");
6041  return SCIP_OKAY;
6042  }
6043 
6044  SCIPgetIntParam(scip, "visual/nmaxdecompstowrite", &maxtowrite );
6045 
6047  for( i = 0; presolved && conshdlrdata->seeedpool!= NULL && i < conshdlrdata->seeedpool->getNFinishedSeeeds(); ++i )
6048  {
6049  SeeedPtr seeed;
6050 
6051  seeed = conshdlrdata->seeedpool->getFinishedSeeed( i );
6052 
6053  misc->GCGgetVisualizationFilename(scip, seeed, extension, tempstring);
6054  if( directory != NULL )
6055  {
6056  (void) SCIPsnprintf(outname, SCIP_MAXSTRLEN, "%s/%s.%s", directory, tempstring, extension);
6057  }
6058  else
6059  {
6060  (void) SCIPsnprintf(outname, SCIP_MAXSTRLEN, "%s.%s", tempstring, extension);
6061  }
6062 
6063  conshdlrdata->seeedtowrite = seeed;
6064 
6065  SCIP_CALL( SCIPwriteTransProblem(scip, outname, extension, FALSE) );
6066 
6067  ++nwritten;
6068 
6069  conshdlrdata->seeedtowrite = NULL;
6070 
6071  if( maxtowrite != -1 && nwritten >= maxtowrite )
6072  break;
6073 
6074 
6075  }
6076 
6077 
6078 
6080  for( i = 0; original && conshdlrdata->seeedpoolunpresolved != NULL && i < conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds() ; ++i )
6081  {
6082  SeeedPtr seeed;
6083 
6084  seeed = conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i );
6085 
6086  misc->GCGgetVisualizationFilename(scip, seeed, extension, tempstring);
6087  if( directory != NULL )
6088  {
6089  (void) SCIPsnprintf(outname, SCIP_MAXSTRLEN, "%s/%s.%s", directory, tempstring, extension);
6090  }
6091  else
6092  {
6093  (void) SCIPsnprintf(outname, SCIP_MAXSTRLEN, "%s.%s", tempstring, extension);
6094  }
6095 
6096  conshdlrdata->seeedtowrite = seeed;
6097 
6098  SCIP_CALL( SCIPwriteOrigProblem(scip, outname, extension, FALSE) );
6099  ++nwritten;
6100  conshdlrdata->seeedtowrite = NULL;
6101 
6102  if( maxtowrite != -1 && nwritten >= maxtowrite )
6103  break;
6104  }
6105 
6106 
6107  return SCIP_OKAY;
6108 }
6109 
6110 SCIP_Bool GCGdetectionTookPlace(
6111  SCIP* scip
6112  ){
6113  SCIP_CONSHDLR* conshdlr;
6114  SCIP_CONSHDLRDATA* conshdlrdata;
6115 
6116  assert(scip != NULL);
6117 
6118  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6119  assert(conshdlr != NULL);
6120 
6121  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6122  assert(conshdlrdata != NULL);
6123 
6124  return (conshdlrdata->seeedpool != NULL ) || (conshdlrdata->seeedpoolunpresolved != NULL );
6125 }
6126 
6127 
6129  SCIP* scip
6130  )
6131 {
6132  SCIP_CONSHDLR* conshdlr;
6133  SCIP_CONSHDLRDATA* conshdlrdata;
6134 
6135  assert(scip != NULL);
6136 
6137  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6138  assert(conshdlr != NULL);
6139 
6140  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6141  assert(conshdlrdata != NULL);
6142 
6143  return conshdlrdata->ndetectors;
6144 }
6145 
6146 
6148  SCIP* scip
6149  )
6150 {
6151  SCIP_CONSHDLR* conshdlr;
6152  SCIP_CONSHDLRDATA* conshdlrdata;
6153 
6154  assert(scip != NULL);
6155 
6156  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6157  assert(conshdlr != NULL);
6158 
6159  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6160  assert(conshdlrdata != NULL);
6161 
6162  return conshdlrdata->detectors;
6163 }
6164 
6165 const char* SCIPconshdlrDecompGetPdfReader(
6166  SCIP* scip
6167  )
6168 {
6169  int ret = 1;
6170  std::string viewers[] = { "okular", "acroread", "evince" };
6171  int nviewers = 3;
6172 
6173  for( int i = 0; i < nviewers; ++i )
6174  {
6175  std::string command = "which ";
6176  command.append(viewers[i].c_str() );
6177  ret = system(command.c_str());
6178  if( ret == 0 )
6179  return viewers[i].c_str();
6180  }
6181  return "no pdf viewer found ";
6182 }
6183 
6185  SCIP* scip
6186  )
6187 {
6188  SCIP_CONSHDLR* conshdlr;
6189  SCIP_CONSHDLRDATA* conshdlrdata;
6190 
6191  assert(scip != NULL);
6192 
6193  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6194  assert(conshdlr != NULL);
6195 
6196  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6197  assert(conshdlrdata != NULL);
6198 
6199  conshdlrdata->nonfinalfreetransform = TRUE;
6200 
6201  return SCIP_OKAY;
6202 }
6203 
6205  SCIP* scip
6206  )
6207 {
6208 
6209  SCIP_CONSHDLR* conshdlr;
6210  SCIP_CONSHDLRDATA* conshdlrdata;
6211 
6212  assert(scip != NULL);
6213 
6214  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6215  assert(conshdlr != NULL);
6216 
6217  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6218  assert(conshdlrdata != NULL);
6219 
6220  conshdlrdata->nonfinalfreetransform = FALSE;
6221 
6222  return SCIP_OKAY;
6223 }
6224 
6225 
6226 
6232  SCIP* scip,
6233  SEEED_WRAPPER** seeedswr,
6234  int* nseeeds
6235  )
6236 {
6237  SCIP_CONSHDLR* conshdlr;
6238  SCIP_CONSHDLRDATA* conshdlrdata;
6239 
6240  assert(scip != NULL);
6241  assert(seeedswr != NULL);
6242 
6243  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6244  assert(conshdlr != NULL);
6245 
6246  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6247  assert(conshdlrdata != NULL);
6248 
6249  /* get the current max id */
6250  int maxid = 0;
6251 
6252  for( int i = 0; conshdlrdata->seeedpool != NULL && i < conshdlrdata->seeedpool->getNAncestorSeeeds(); ++i )
6253  {
6254  if( conshdlrdata->seeedpool->getAncestorSeeed( i ) != NULL &&
6255  conshdlrdata->seeedpool->getAncestorSeeed( i )->getID() > maxid )
6256  maxid = conshdlrdata->seeedpool->getAncestorSeeed( i )->getID();
6257  }
6258 
6259  for( int i = 0; conshdlrdata->seeedpoolunpresolved != NULL && i < conshdlrdata->seeedpoolunpresolved->getNAncestorSeeeds(); ++i )
6260  {
6261  if( conshdlrdata->seeedpoolunpresolved->getAncestorSeeed( i ) != NULL &&
6262  conshdlrdata->seeedpoolunpresolved->getAncestorSeeed( i )->getID() > maxid )
6263  maxid = conshdlrdata->seeedpoolunpresolved->getAncestorSeeed( i )->getID();
6264  }
6265 
6266  for( int i = 0; conshdlrdata->seeedpool != NULL && i < conshdlrdata->seeedpool->getNFinishedSeeeds(); ++i )
6267  {
6268  if( conshdlrdata->seeedpool->getFinishedSeeed( i ) != NULL &&
6269  conshdlrdata->seeedpool->getFinishedSeeed( i )->getID() > maxid )
6270  maxid = conshdlrdata->seeedpool->getFinishedSeeed( i )->getID();
6271  }
6272 
6273  for( int i = 0; conshdlrdata->seeedpoolunpresolved != NULL && i < conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds(); ++i )
6274  {
6275  if( conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i ) != NULL &&
6276  conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i )->getID() > maxid )
6277  maxid = conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i )->getID();
6278  }
6279 
6280  /* initialize the output array with NULL */
6281  *nseeeds = maxid+1;
6282 
6283  for( int i = 0; i < *nseeeds; i++ )
6284  {
6285  SCIP_CALL( SCIPallocBlockMemory( scip, &(seeedswr[i]) ) );
6286  seeedswr[i]->seeed = NULL;
6287  seeedswr[i]->seeedpool = NULL; /* not needed, initialization just for safety reasons */
6288  }
6289 
6290  /* fill the output array with relevant seeeds */
6291  for( int i = 0; conshdlrdata->seeedpoolunpresolved != NULL && i < conshdlrdata->seeedpoolunpresolved->getNAncestorSeeeds(); ++i )
6292  {
6293  if( conshdlrdata->seeedpoolunpresolved->getAncestorSeeed( i ) == NULL ||
6294  conshdlrdata->seeedpoolunpresolved->getAncestorSeeed( i )->getID() < 0 )
6295  continue;
6296  seeedswr[conshdlrdata->seeedpoolunpresolved->getAncestorSeeed( i )->getID()]->seeed =
6297  conshdlrdata->seeedpoolunpresolved->getAncestorSeeed( i );
6298  }
6299 
6300  for( int i = 0; conshdlrdata->seeedpool != NULL && i < conshdlrdata->seeedpool->getNAncestorSeeeds(); ++i )
6301  {
6302  if( conshdlrdata->seeedpool->getAncestorSeeed( i ) == NULL ||
6303  conshdlrdata->seeedpool->getAncestorSeeed( i )->getID() < 0 )
6304  continue;
6305  seeedswr[conshdlrdata->seeedpool->getAncestorSeeed( i )->getID()]->seeed =
6306  conshdlrdata->seeedpool->getAncestorSeeed( i );
6307  }
6308 
6309  for( int i = 0; conshdlrdata->seeedpoolunpresolved != NULL && i < conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds(); ++i )
6310  {
6311  if( conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i ) == NULL ||
6312  conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i )->getID() < 0 )
6313  continue;
6314  seeedswr[conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i )->getID()]->seeed =
6315  conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i );
6316  }
6317 
6318  for( int i = 0; conshdlrdata->seeedpool != NULL && i < conshdlrdata->seeedpool->getNFinishedSeeeds(); ++i )
6319  {
6320  if( conshdlrdata->seeedpool->getFinishedSeeed( i ) == NULL ||
6321  conshdlrdata->seeedpool->getFinishedSeeed( i )->getID() < 0 )
6322  continue;
6323  seeedswr[conshdlrdata->seeedpool->getFinishedSeeed( i )->getID()]->seeed =
6324  conshdlrdata->seeedpool->getFinishedSeeed( i );
6325  }
6326 
6327  return SCIP_OKAY;
6328 }
6329 
6330 
6332 SCIP_RETCODE DECwriteFamilyTree(
6333  SCIP* scip,
6334  const char* filename,
6335  const char* workfolder,
6336  int ndecompositions,
6337  SCIP_Bool draft
6338  )
6339 {
6340 
6341  SCIP_CONSHDLR* conshdlr;
6342  SCIP_CONSHDLRDATA* conshdlrdata;
6343  assert(scip != NULL);
6344 
6345  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6346  assert(conshdlr != NULL);
6347 
6348  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6349 
6350  std::vector<SeeedPtr> tovisualize(0);
6351  assert(conshdlrdata != NULL);
6352 
6354  {
6355  for ( size_t i = 0; tovisualize.size() <= (size_t) ndecompositions && i < conshdlrdata->selected->size(); ++i )
6356  {
6357  if( conshdlrdata->listall->at(conshdlrdata->selected->at(i))->isComplete() )
6358  tovisualize.push_back( conshdlrdata->listall->at(conshdlrdata->selected->at(i) ) );
6359  }
6360  }
6361  else
6362  {
6364  for( size_t i = 0; tovisualize.size() <= (size_t) ndecompositions && i < conshdlrdata->listall->size(); ++i )
6365  {
6366  if( conshdlrdata->listall->at(i)->isComplete() )
6367  tovisualize.push_back( conshdlrdata->listall->at(i) );
6368  }
6369  }
6370 
6371  SCIPdebugMessage("Checking list of seeeds to visualize: \n");
6372  for( size_t i = 0; i < tovisualize.size(); ++i )
6373  {
6374  SCIPdebugMessage( "%d th seeed: id: %d has ancestors from unpresolved: %d \n", (int) i, tovisualize[i]->getID(), tovisualize[i]->getStemsFromUnpresolved() );
6375  }
6376 
6377  /* let tex reader handle the visualization of the family tree */
6378  int ntovisualize = tovisualize.size();
6379  SEEED_WRAPPER** tovisualizewr;
6380  SCIP_CALL( SCIPallocBufferArray(scip, &tovisualizewr, ntovisualize) );
6381 
6382  for( size_t i = 0; i < tovisualize.size(); ++i )
6383  {
6384  SCIP_CALL( SCIPallocBlockMemory( scip, &(tovisualizewr[i]) ) );
6385  tovisualizewr[i]->seeed = tovisualize[i];
6386  }
6387 
6388  FILE* helpfile = fopen(filename, "w");
6389  GCGwriteTexFamilyTree(scip, helpfile, workfolder, tovisualizewr, &ntovisualize);
6390  fclose(helpfile);
6391 
6392  for( size_t i = 0; i < tovisualize.size(); ++i )
6393  {
6394  SCIPfreeBlockMemory( scip, &(tovisualizewr[i]) );
6395  }
6396  SCIPfreeBufferArray(scip, &tovisualizewr);
6397 
6398  return SCIP_OKAY;
6399 }
6400 
6401 SCIP_RETCODE SCIPconshdlrDecompWriteDec(
6402  SCIP* scip,
6403  FILE* file,
6404  SCIP_Bool transformed,
6405  SCIP_RESULT* result
6406  ){
6407 
6408  SCIP_CONSHDLR* conshdlr;
6409  SCIP_CONSHDLRDATA* conshdlrdata;
6410  assert(scip != NULL);
6412 
6413  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6414  seeedpool = NULL;
6415  assert(conshdlr != NULL);
6416 
6417  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6418  assert(conshdlrdata != NULL);
6419 
6420  if( transformed )
6421  {
6422  if (conshdlrdata->seeedpool == NULL )
6423  conshdlrdata->seeedpool = new gcg::Seeedpool(scip, CONSHDLR_NAME, TRUE, SCIPconshdlrDecompDetectBenders(scip));
6424  seeedpool = conshdlrdata->seeedpool;
6425  }
6426  else
6427  {
6428  if (conshdlrdata->seeedpoolunpresolved == NULL )
6429  conshdlrdata->seeedpoolunpresolved = new gcg::Seeedpool(scip, CONSHDLR_NAME, FALSE, SCIPconshdlrDecompDetectBenders(scip));
6430  seeedpool = conshdlrdata->seeedpoolunpresolved;
6431  }
6432 
6433  if( conshdlrdata->seeedtowrite != NULL )
6434  {
6435  conshdlrdata->seeedtowrite->writeAsDec(file, seeedpool, result);
6436  return SCIP_OKAY;
6437  }
6438 
6439  if( conshdlrdata->candidates->size() == 0 )
6440  {
6442  }
6443 
6444 
6445  if( conshdlrdata->candidates->size() == 0 )
6446  {
6447  SCIPwarningMessage(scip, "There are no candidate decompositions!\n");
6448  return SCIP_OKAY;
6449  }
6450 
6451  conshdlrdata->candidates->at(0).first->writeAsDec(file, seeedpool, result);
6452 
6453 
6454  return SCIP_OKAY;
6455 }
6456 
6459  SCIP* scip
6460  )
6461 {
6462  SCIP_CONSHDLR* conshdlr;
6463  SCIP_CONSHDLRDATA* conshdlrdata;
6464  assert(scip != NULL);
6465 
6466  DEC_DECOMP* decomp;
6469  SeeedPtr seeed;
6470 
6471 
6472  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6473  assert(conshdlr != NULL);
6474 
6475  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6476  assert(conshdlrdata != NULL);
6477 
6478 
6479  if( conshdlrdata->seeedpool == NULL )
6480  conshdlrdata->seeedpool = new gcg::Seeedpool(scip, CONSHDLR_NAME, TRUE, SCIPconshdlrDecompDetectBenders(scip));
6481 
6482  seeedpool = conshdlrdata->seeedpool;
6483  seeedpoolunpresolved = conshdlrdata->seeedpoolunpresolved;
6484 
6485  if( conshdlrdata->candidates->size() == 0 && conshdlrdata->useddecomp == NULL)
6486  {
6488  if (conshdlrdata->candidates->size() == 0)
6489  return NULL;
6490  }
6491 
6492 
6493  if( conshdlrdata->useddecomp != NULL )
6494  return conshdlrdata->useddecomp;
6495 
6496  seeed = conshdlrdata->candidates->at( 0 ).first;
6497 
6498  SCIPdebugMessage("In get bestdecomp\n");
6499 
6501  {
6502  std::vector<SeeedPtr> seeedtotranslate(0);
6503  std::vector<SeeedPtr> translatedseeeds(0);
6504 
6505  seeedtotranslate.push_back(seeed);
6506  seeedpool->translateSeeeds(seeedpoolunpresolved, seeedtotranslate, translatedseeeds);
6507  seeed = translatedseeeds[0];
6508  }
6509 
6510  seeedpool->createDecompFromSeeed(seeed, &decomp);
6511 
6512 
6513  return decomp;
6514 }
6515 
6517 SCIP_RETCODE DECgetSeeedToWrite(
6518  SCIP* scip,
6519  SCIP_Bool transformed,
6520  SEEED_WRAPPER* seeedwrapper
6521  )
6522 {
6523 
6524  SCIP_CONSHDLR* conshdlr;
6525  SCIP_CONSHDLRDATA* conshdlrdata;
6526  assert(scip != NULL);
6527  int dec;
6528 
6529  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6530  assert(conshdlr != NULL);
6531 
6532  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6533  assert(conshdlrdata != NULL);
6534 
6535  if( conshdlrdata->seeedtowrite != NULL )
6536  {
6537  seeedwrapper->seeed = conshdlrdata->seeedtowrite;
6538 
6539  return SCIP_OKAY;
6540  }
6541 
6542  if( conshdlrdata->candidates->size() == 0 )
6543  {
6545  }
6546 
6547  if( conshdlrdata->candidates->size() == 0 )
6548  {
6549  SCIPwarningMessage(scip, "There are no candidate decompositions!\n");
6550  seeedwrapper->seeed = NULL;
6551  return SCIP_OKAY;
6552  }
6553 
6554  for( dec = 0; dec < (int) conshdlrdata->candidates->size(); ++dec )
6555  {
6556  if ( conshdlrdata->candidates->at(dec).first->isFromUnpresolved() == !transformed )
6557  break;
6558  }
6559  if( dec != (int) conshdlrdata->candidates->size() )
6560  seeedwrapper->seeed = conshdlrdata->candidates->at(dec).first;
6561  else
6562  SCIPwarningMessage(scip, "There is no candidate decomposition for the %s problem we can write information for!\n", transformed ? "transformed" : "untransformed");
6563 
6564  return SCIP_OKAY;
6565 }
6566 
6569  SCIP* scip
6570  )
6571 {
6572  SCIP_CONSHDLR* conshdlr;
6573  SCIP_CONSHDLRDATA* conshdlrdata;
6574  int ndetectors;
6575  int i;
6576 
6577  assert(scip != NULL);
6578 
6579  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6580  assert(conshdlr != NULL);
6581 
6582  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6583  assert(conshdlrdata != NULL);
6584 
6585  ndetectors = conshdlrdata->ndetectors;
6586 
6587  SCIPdialogMessage(scip, NULL, " detector char priority enabled description\n");
6588  SCIPdialogMessage(scip, NULL, " -------------- ---- -------- ------- -----------\n");
6589 
6590  for( i = 0; i < ndetectors; ++i )
6591  {
6592  SCIPdialogMessage(scip, NULL, " %-20s", conshdlrdata->detectors[i]->name);
6593  SCIPdialogMessage(scip, NULL, " %c", conshdlrdata->detectors[i]->decchar);
6594  SCIPdialogMessage(scip, NULL, " %8d", conshdlrdata->detectors[i]->priority);
6595  SCIPdialogMessage(scip, NULL, " %7s", conshdlrdata->detectors[i]->enabled ? "TRUE" : "FALSE");
6596  SCIPdialogMessage(scip, NULL, " %s\n", conshdlrdata->detectors[i]->description);
6597  }
6598 }
6599 
6600 
6602  SCIP* scip
6603 ){
6604  SCIP_CONSHDLR* conshdlr;
6605  SCIP_CONSHDLRDATA* conshdlrdata;
6606  assert(scip != NULL);
6607 
6608 
6609  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6610  assert(conshdlr != NULL);
6611 
6612  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6613  assert(conshdlrdata != NULL);
6614 
6615  return static_cast<scoretype>(conshdlrdata->currscoretype);
6616 
6617 }
6618 
6619 
6620 
6621 
6623 SCIP_Bool DEChasDetectionRun(
6624  SCIP* scip
6625  )
6626 {
6627  SCIP_CONSHDLR* conshdlr;
6628  SCIP_CONSHDLRDATA* conshdlrdata;
6629 
6630  assert(scip != NULL);
6631 
6632  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6633  assert(conshdlr != NULL);
6634 
6635  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6636  assert(conshdlrdata != NULL);
6637 
6638  return conshdlrdata->hasrun;
6639 }
6640 
6642 char DECdetectorGetChar(
6643  DEC_DETECTOR* detector
6644 )
6645 {
6646  if( detector == NULL )
6647  return '0';
6648  else
6649  return detector->decchar;
6650 }
6651 
6656  SCIP* scip
6657 ){
6658 
6659  SCIP_CONSHDLR* conshdlr;
6660  SCIP_CONSHDLRDATA* conshdlrdata;
6661 
6662  DEC_DECOMP** decomps;
6663 
6664  int ndecomps;
6665 
6666  assert(scip != NULL);
6667 
6668  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6669  assert(conshdlr != NULL);
6670 
6671  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6672  assert(conshdlrdata != NULL);
6673 
6675 
6676  SCIP_CALL_ABORT( SCIPallocMemoryArray(scip, &decomps, ndecomps) );
6677 
6678  if ( conshdlrdata->seeedpool != NULL )
6679  {
6680  for( int i = 0; i < conshdlrdata->seeedpool->getNFinishedSeeeds(); ++i )
6681  {
6682  DEC_DECOMP* decomp;
6683  SCIP_CALL_ABORT(conshdlrdata->seeedpool->createDecompFromSeeed(conshdlrdata->seeedpool->getFinishedSeeed( i ), &decomp ) );
6684 
6685  decomps[i] = decomp;
6686  }
6687  }
6688  if ( conshdlrdata->seeedpoolunpresolved != NULL )
6689  {
6691  for( int i = 0; i < conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds(); ++i )
6692  {
6693  DEC_DECOMP* decomp;
6694  int offset = 0;
6695  conshdlrdata->seeedpoolunpresolved->createDecompFromSeeed(conshdlrdata->seeedpoolunpresolved->getFinishedSeeed( i ), &decomp );
6696 
6697  if( conshdlrdata->seeedpool != NULL )
6698  offset = conshdlrdata->seeedpool->getNFinishedSeeeds();
6699  decomps[i + offset] = decomp;
6700  }
6701  }
6702  return decomps;
6703 }
6704 
6705 /* returns number of finished Seeeds */
6707  SCIP* scip
6708  )
6709 {
6710  SCIP_CONSHDLR* conshdlr;
6711  SCIP_CONSHDLRDATA* conshdlrdata;
6712 
6713  assert(scip != NULL);
6714 
6715  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6716  assert(conshdlr != NULL);
6717 
6718  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6719  assert(conshdlrdata != NULL);
6720 
6721  /* case if there is no seeedpool in data yet */
6722  if( conshdlrdata->seeedpool == NULL && conshdlrdata->seeedpoolunpresolved == NULL )
6723  return 0;
6724 
6725  if( conshdlrdata->seeedpool == NULL )
6726  return conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds();
6727 
6728  if( conshdlrdata->seeedpoolunpresolved == NULL )
6729  return conshdlrdata->seeedpool->getNFinishedSeeeds();
6730 
6731  /* all other cases */
6732  return (int) conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds() + conshdlrdata->seeedpool->getNFinishedSeeeds();
6733 }
6734 
6735 /* returns number of all Seeeds */
6737  SCIP* scip
6738  )
6739 {
6740  SCIP_CONSHDLR* conshdlr;
6741  SCIP_CONSHDLRDATA* conshdlrdata;
6742  int nseeeds;
6743 
6744  assert(scip != NULL);
6745 
6746  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6747  assert(conshdlr != NULL);
6748 
6749  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6750  assert(conshdlrdata != NULL);
6751 
6752  nseeeds = 0;
6753  if( conshdlrdata->seeedpoolunpresolved != NULL )
6754  nseeeds += (int)
6755  conshdlrdata->seeedpoolunpresolved->getNAncestorSeeeds() +
6756  conshdlrdata->seeedpoolunpresolved->getNCurrentSeeeds() +
6757  conshdlrdata->seeedpoolunpresolved->getNFinishedSeeeds();
6758 
6759 
6760 
6761  if( conshdlrdata->seeedpool != NULL )
6762  nseeeds += (int)
6763  conshdlrdata->seeedpool->getNAncestorSeeeds() +
6764  conshdlrdata->seeedpool->getNCurrentSeeeds() +
6765  conshdlrdata->seeedpool->getNFinishedSeeeds();
6766 
6767  return nseeeds;
6768 }
6769 
6771 SCIP_RETCODE GCGprintDetectorStatistics(
6772  SCIP* scip,
6773  FILE* file
6774  )
6775 {
6776  SCIP_CONSHDLR* conshdlr;
6777  SCIP_CONSHDLRDATA* conshdlrdata;
6778  int i;
6779  int j;
6780  assert(scip != NULL);
6781 
6782  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
6783  assert(conshdlr != NULL);
6784 
6785  conshdlrdata = SCIPconshdlrGetData(conshdlr);
6786  assert(conshdlrdata != NULL);
6787  assert(scip != NULL);
6788 
6789  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "Detector statistics: time number blocks\n");
6790  for( i = 0; i < conshdlrdata->ndetectors; ++i )
6791  {
6792  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, " %-10.10s : %8.2f %10d ", conshdlrdata->detectors[i]->name, conshdlrdata->detectors[i]->dectime, conshdlrdata->detectors[i]->ndecomps );
6793  for( j = 0; j < conshdlrdata->detectors[i]->ndecomps; ++j )
6794  {
6795  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, " %d", DECdecompGetNBlocks(conshdlrdata->detectors[i]->decomps[j]));
6796  }
6797  SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "\n");
6798  }
6799  return SCIP_OKAY;
6800 }
6801 
6803 static
6804 SCIP_RETCODE setDetectionDefault(
6805  SCIP* scip,
6806  SCIP_CONSHDLRDATA* conshdlrdata,
6807  SCIP_Bool quiet
6808  )
6809 { /*lint --e{715}*/
6810  int i;
6811  assert(scip != NULL);
6812  assert(conshdlrdata != NULL);
6813 
6814  SCIP_CALL (SCIPsetIntParam(scip, "detection/maxrounds", 2) );
6815  SCIP_CALL (SCIPsetBoolParam(scip, "detection/origprob/enabled", FALSE) );
6816 
6817  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/nnonzeros/enabled", TRUE) );
6818  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/scipconstype/enabled", TRUE) );
6819  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/miplibconstype/enabled", TRUE) );
6820  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/consnamenonumbers/enabled", TRUE) );
6821 
6822  if( SCIPgetStage(scip) >= SCIP_STAGE_PROBLEM && SCIPgetNVars(scip) + SCIPgetNConss(scip) < DEFAULT_LEVENSHTEIN_MAXMATRIXHALFPERIMETER )
6823  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/consnamelevenshtein/enabled", TRUE) );
6824  else
6825  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/consnamelevenshtein/enabled", FALSE) );
6826 
6827  for( i = 0; i < conshdlrdata->ndetectors; ++i )
6828  {
6829  SCIP_Result result;
6830 
6831  char paramname[SCIP_MAXSTRLEN];
6832  SCIP_Bool paramval;
6833  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", conshdlrdata->detectors[i]->name);
6834 
6835  SCIP_CALL( SCIPresetParam(scip, paramname) );
6836 
6837  result = SCIP_DIDNOTRUN;
6838  if( conshdlrdata->detectors[i]->setParamDefault != NULL )
6839  conshdlrdata->detectors[i]->setParamDefault(scip, conshdlrdata->detectors[i], &result);
6840  if( !quiet )
6841  {
6842  SCIP_Bool written = FALSE;
6843 
6844  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", conshdlrdata->detectors[i]->name);
6845  SCIP_CALL( SCIPgetBoolParam(scip, paramname, &paramval) );
6846  if( paramval == TRUE )
6847  {
6848  SCIPinfoMessage(scip, NULL, "%s = %s\n", paramname, paramval == TRUE ? "TRUE" : "FALSE");
6849  written = TRUE;
6850  }
6851 
6852  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "detection/detectors/%s/origenabled", conshdlrdata->detectors[i]->name);
6853  SCIP_CALL( SCIPgetBoolParam(scip, paramname, &paramval) );
6854  if( paramval == TRUE )
6855  {
6856  SCIPinfoMessage(scip, NULL, "%s = %s\n", paramname, paramval == TRUE ? "TRUE" : "FALSE");
6857  written = TRUE;
6858  }
6859 
6860  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "detection/detectors/%s/finishingenabled", conshdlrdata->detectors[i]->name);
6861  SCIP_CALL( SCIPgetBoolParam(scip, paramname, &paramval) );
6862  if( paramval == TRUE )
6863  {
6864  SCIPinfoMessage(scip, NULL, "%s = %s\n", paramname, paramval == TRUE ? "TRUE" : "FALSE");
6865  written = TRUE;
6866  }
6867 
6868  if( written )
6869  SCIPinfoMessage(scip, NULL, "\n", paramname, paramval == TRUE ? "TRUE" : "FALSE");
6870 
6871  }
6872  }
6873 
6874  return SCIP_OKAY;
6875 }
6876 
6878 static
6879 SCIP_RETCODE setDetectionAggressive(
6880  SCIP* scip,
6881  SCIP_CONSHDLRDATA* conshdlrdata,
6882  SCIP_Bool quiet
6883  )
6884 { /*lint --e{715}*/
6885  int i;
6886 
6887  assert(scip != NULL);
6888  assert(conshdlrdata != NULL);
6889 
6890 
6891  SCIP_CALL (SCIPsetIntParam(scip, "detection/maxrounds", 3) );
6892 
6893  SCIP_CALL (SCIPsetBoolParam(scip, "detection/origprob/enabled", TRUE) );
6894 
6895  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/nnonzeros/enabled", TRUE) );
6896  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/scipconstype/enabled", TRUE) );
6897  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/miplibconstype/enabled", TRUE) );
6898  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/consnamenonumbers/enabled", TRUE) );
6899 
6900  if( SCIPgetStage(scip) >= SCIP_STAGE_PROBLEM && SCIPgetNVars(scip) + SCIPgetNConss(scip) < AGGRESSIVE_LEVENSHTEIN_MAXMATRIXHALFPERIMETER)
6901  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/consnamelevenshtein/enabled", TRUE) );
6902  else
6903  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/consnamelevenshtein/enabled", FALSE) );
6904 
6905  for( i = 0; i < conshdlrdata->ndetectors; ++i )
6906  {
6907  SCIP_Result result;
6908 
6909  result = SCIP_DIDNOTRUN;
6910  if( conshdlrdata->detectors[i]->setParamAggressive != NULL )
6911  conshdlrdata->detectors[i]->setParamAggressive(scip, conshdlrdata->detectors[i], &result);
6912 
6913  if( !quiet )
6914  {
6915  char paramname[SCIP_MAXSTRLEN];
6916  SCIP_Bool paramval;
6917  SCIP_Bool written = FALSE;
6918 
6919  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", conshdlrdata->detectors[i]->name);
6920  SCIP_CALL( SCIPgetBoolParam(scip, paramname, &paramval) );
6921  if( paramval == TRUE )
6922  {
6923  SCIPinfoMessage(scip, NULL, "%s = %s\n", paramname, paramval == TRUE ? "TRUE" : "FALSE");
6924  written = TRUE;
6925  }
6926 
6927  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "detection/detectors/%s/origenabled", conshdlrdata->detectors[i]->name);
6928  SCIP_CALL( SCIPgetBoolParam(scip, paramname, &paramval) );
6929  if( paramval == TRUE )
6930  {
6931  SCIPinfoMessage(scip, NULL, "%s = %s\n", paramname, paramval == TRUE ? "TRUE" : "FALSE");
6932  written = TRUE;
6933  }
6934 
6935  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "detection/detectors/%s/finishingenabled", conshdlrdata->detectors[i]->name);
6936  SCIP_CALL( SCIPgetBoolParam(scip, paramname, &paramval) );
6937  if( paramval == TRUE )
6938  {
6939  SCIPinfoMessage(scip, NULL, "%s = %s\n", paramname, paramval == TRUE ? "TRUE" : "FALSE");
6940  written = TRUE;
6941  }
6942 
6943  if( written )
6944  SCIPinfoMessage(scip, NULL, "\n", paramname, paramval == TRUE ? "TRUE" : "FALSE");
6945 
6946  }
6947  }
6948 
6949  return SCIP_OKAY;
6950 }
6951 
6953 static
6954 SCIP_RETCODE setDetectionOff(
6955  SCIP* scip,
6956  SCIP_CONSHDLRDATA* conshdlrdata,
6957  SCIP_Bool quiet
6958  )
6959 { /*lint --e{715}*/
6960  int i;
6961  assert(scip != NULL);
6962  assert(conshdlrdata != NULL);
6963 
6964  for( i = 0; i < conshdlrdata->ndetectors; ++i )
6965  {
6966  char paramname[SCIP_MAXSTRLEN];
6967  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "detection/detectors/%s/enabled", conshdlrdata->detectors[i]->name);
6968 
6969  SCIP_CALL( SCIPsetBoolParam(scip, paramname, FALSE) );
6970  if( !quiet )
6971  {
6972  SCIPinfoMessage(scip, NULL, "%s = FALSE\n", paramname);
6973  }
6974  }
6975 
6976  for( i = 0; i < conshdlrdata->ndetectors; ++i )
6977  {
6978  char paramname[SCIP_MAXSTRLEN];
6979  (void)SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "detection/detectors/%s/origenabled", conshdlrdata->detectors[i]->name);
6980 
6981  SCIP_CALL(SCIPsetBoolParam(scip, paramname, FALSE));
6982  if( !quiet )
6983  {
6984  SCIPinfoMessage(scip, NULL, "%s = FALSE\n", paramname);
6985  }
6986  }
6987 
6988  for( i = 0; i < conshdlrdata->ndetectors; ++i )
6989  {
6990  char paramname[SCIP_MAXSTRLEN];
6991  (void)SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "detection/detectors/%s/legacymode", conshdlrdata->detectors[i]->name);
6992 
6993  SCIP_CALL(SCIPsetBoolParam(scip, paramname, FALSE));
6994  if( !quiet )
6995  {
6996  SCIPinfoMessage(scip, NULL, "%s = FALSE\n", paramname);
6997  }
6998  }
6999 
7000  return SCIP_OKAY;
7001 }
7002 
7004 static
7005 SCIP_RETCODE setDetectionFast(
7006  SCIP* scip,
7007  SCIP_CONSHDLRDATA* conshdlrdata,
7008  SCIP_Bool quiet
7009  )
7010 { /*lint --e{715} */
7011  int i;
7012 
7013  assert(scip != NULL);
7014  assert(conshdlrdata != NULL);
7015 
7016  SCIP_CALL (SCIPsetIntParam(scip, "detection/maxrounds", 1) );
7017 
7018 
7019  SCIP_CALL (SCIPsetBoolParam(scip, "detection/origprob/enabled", FALSE) );
7020  SCIP_CALL (SCIPsetBoolParam(scip, "detection/origprob/classificationenabled", FALSE) );
7021 
7022 
7023  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/nnonzeros/enabled", TRUE) );
7024  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/scipconstype/enabled", TRUE) );
7025  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/miplibconstype/enabled", TRUE) );
7026  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/consnamenonumbers/enabled", TRUE) );
7027 
7028  if( SCIPgetStage(scip) >= SCIP_STAGE_PROBLEM && SCIPgetNVars(scip) + SCIPgetNConss(scip) < FAST_LEVENSHTEIN_MAXMATRIXHALFPERIMETER )
7029  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/consnamelevenshtein/enabled", TRUE) );
7030  else
7031  SCIP_CALL(SCIPsetBoolParam(scip, "detection/consclassifier/consnamelevenshtein/enabled", FALSE) );
7032 
7033  for( i = 0; i < conshdlrdata->ndetectors; ++i )
7034  {
7035  SCIP_Result result;
7036 
7037  result = SCIP_DIDNOTRUN;
7038  if( conshdlrdata->detectors[i]->overruleemphasis )
7039  continue;