Scippy

GCG

Branch-and-Price & Column Generation for Everyone

class_partialdecomp.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program */
4 /* GCG --- Generic Column Generation */
5 /* a Dantzig-Wolfe decomposition based extension */
6 /* of the branch-cut-and-price framework */
7 /* SCIP --- Solving Constraint Integer Programs */
8 /* */
9 /* Copyright (C) 2010-2021 Operations Research, RWTH Aachen University */
10 /* Zuse Institute Berlin (ZIB) */
11 /* */
12 /* This program is free software; you can redistribute it and/or */
13 /* modify it under the terms of the GNU Lesser General Public License */
14 /* as published by the Free Software Foundation; either version 3 */
15 /* of the License, or (at your option) any later version. */
16 /* */
17 /* This program is distributed in the hope that it will be useful, */
18 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
19 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
20 /* GNU Lesser General Public License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with this program; if not, write to the Free Software */
24 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/
25 /* */
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
28 /**@file class_partialdecomp.h
29  * @brief class storing (potentially incomplete) decompositions
30  * @note formerly called "Seeed"
31  * @author Michael Bastubbe
32  * @author Hannah Hechenrieder
33  * @author Hanna Franzen
34  */
35 
36 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
37 
38 #ifndef GCG_CLASS_PARTIALDECOMP_H__
39 #define GCG_CLASS_PARTIALDECOMP_H__
40 
41 #include "objscip/objscip.h"
42 #include "struct_detector.h"
43 
44 #include <vector>
45 #include <string>
46 
47 #include "class_conspartition.h"
48 #include "class_varpartition.h"
49 #include "graph/graph_gcg.h"
50 #include "graph/graph.h"
51 #include "type_scoretype.h"
52 
53 #include "reader_gp.h"
54 
55 namespace gcg {
56 
57 
58 /**
59  * @brief enumeration to display if a decomposition was given by the user and if so, how it was processed after adding
60  */
62 {
63  NOT = 0, /**< this partialdec was not given by the user */
64  PARTIAL = - 1, /**< this partial partialdec was given by the user as it is*/
65  COMPLETE = - 2, /**< this complete partialdec was given by the user as it is*/
66  COMPLETED_CONSTOMASTER = - 3 /**< this partialdec was partially given by the user and then completed by setting all missing constraints to the master*/
67 };
68 
69 class DETPROBDATA;
70 
71 
72 /*!
73  * @brief class to manage partial decompositions
74  *
75  * each partialdec corresponds to one detprobdata which contains the problem information,
76  * there is one detprobdata for the original and the transformed problem.
77  */
79 {
80 private:
81  SCIP* scip; /**< SCIP data structure */
82  int id; /**< unique id of the partialdec, unique */
83  int nblocks; /**< number of blocks the partial decomposition currently has */
84  int nvars; /**< number of variables */
85  int nconss; /**< number of constraints */
86  std::vector<int> masterconss; /**< vector containing indices of master constraints */
87  std::vector<int> mastervars; /**< vector containing indices of master variables (these variables are supposed to have all nonzero entries in master constraints) */
88  std::vector<std::vector<int>> conssforblocks; /**< conssforblocks[k] contains a vector of indices of all
89  *< constraints assigned to block k */
90  std::vector<std::vector<int>> varsforblocks; /**< varsforblocks[k] contains a vector of indices of all
91  *< variables assigned to block k */
92  std::vector<int> linkingvars; /**< vector containing indices of linking variables */
93  std::vector<std::vector<int>> stairlinkingvars; /**< vector containing indices of staircase linking variables
94  *< of the blocks (stair-linking variables are registered only
95  *< in their first block) */
96  std::vector<int> openvars; /**< vector containing indices of variables that are not
97  *< assigned yet*/
98  std::vector<int> openconss; /**< vector containing indices of constraints that are not
99  *< assigned yet*/
100  std::vector<bool> isvaropen; /**< whether ith variable is still open */
101  std::vector<bool> isconsopen; /**< whether ith constraint is still open */
102  std::vector<bool> isvarmaster; /**< whether ith variable is assigned to be a only-master variable */
103  std::vector<bool> isconsmaster; /**< whether ith constraint is assigned to be a master constraint */
104 
105  std::vector<int> ncoeffsforblock; /**< number of coeffs per block */
106 
107  SCIP_Bool calculatedncoeffsforblock; /**< is the number of coeff per block already calculated*/
108  int ncoeffsformaster; /**< number of master coefficients */
109  std::vector<std::vector<int>> ncoeffsforblockformastercons; /**< number of coeffs a block has in a certain master constraint */
110 
111  bool varsforblocksorted; /**< bool to store if the varsforblocks datastructure is sorted atm */
112  bool stairlinkingvarsforblocksorted; /**< bool to store if the stairlinkingvarsforblock datastructure is sorted atm */
113  bool conssforblocksorted; /**< bool to store if the conssforblock datastructure is sorted atm */
114  bool linkingvarssorted; /**< bool to store if the linkingvars datastructure is sorted atm */
115  bool mastervarssorted; /**< bool to store if the mastervars datastructure is sorted atm */
116  bool masterconsssorted; /**< bool to store if the masterconsssorted datastructure is sorted atm */
117 
118  unsigned long hashvalue; /**< hash value of this partial decomposition, decompositions with same has value are considered to be identical */
119  bool hvoutdated; /**< true if the internal structure changed such that the hash value needs to be recalculated */
120 
121  bool isselected; /**< is this partialdec selected */
122 
123  bool isagginfoalreadytoexpensive; /**< is agginfo already known to be to expensive to calculate*/
124 
125  const static int primes[]; /**< an array of prime numbers to calculate the hash value */
126  const static int nprimes; /**< size of the array of prime numbers */
127 
128  bool isfinishedbyfinisher; /**< was this partialdec finished by the finishpartialdec() method of a detector */
129 
130  /* aggregation information */
131  int nrepblocks; /**< number of block representatives */
132  std::vector<std::vector<int>> reptoblocks; /**< translation of the block representatives to (old) blocks */
133  std::vector<int> blockstorep; /**< translation of the (old) blocks to the block representatives */
134  std::vector<std::vector<std::vector<int> > > pidtopidvarmaptofirst; /**< [nrepblocks][blockstorep[k].size()][nvarsforprob] collection of varmaps of probindices from k-th subproblem to the zeroth block that is represented */
135 
136  /* statistic information */
137  std::vector<DEC_DETECTOR*> detectorchain; /**< vector containing detectors that worked on that partialdec */
138  std::vector<std::string> detectorchaininfo; /**< vector containing information about the detector call */
139  std::vector<SCIP_Real> detectorclocktimes; /**< vector containing detector times in seconds */
140  std::vector<SCIP_Real> pctvarstoborder; /**< vector containing the fraction of variables assigned to the
141  *< border for each detector working on that partialdec*/
142  std::vector<SCIP_Real> pctvarstoblock; /**< vector containing the fraction of variables assigned to a block
143  *< for each detector working on that partialdec*/
144  std::vector<SCIP_Real> pctvarsfromfree; /**< vector containing the fraction of variables that are not longer
145  *< open for each detector working on that partialdec*/
146  std::vector<SCIP_Real> pctconsstoborder; /**< vector containing the fraction of constraints assigned to the
147  *< border for each detector working on that partialdec*/
148  std::vector<SCIP_Real> pctconsstoblock; /**< vector containing the fraction of constraints assigned to a block
149  *< for each detector working on that partialdec*/
150  std::vector<SCIP_Real> pctconssfromfree; /**< vector containing the fraction of constraints that are not longer
151  *< open for each detector working on that partialdec*/
152  std::vector<int> nnewblocks; /**< vector containing information how many new blocks a detector has assigned */
153 
154  std::vector<IndexPartition*> usedpartition; /**< vector containing pointer to the cons- or varpartitions
155  *< a detector made use of for each detector working on that partialdec
156  *< (NULL if no partition was used) */
157  std::vector<std::vector<int>> classestomaster; /**< vector containing the vector of classindices that were assigned
158  *< to master by the partition used by a detector
159  *< (empty vector if no partition was used) */
160  std::vector<std::vector<int>> classestolinking; /**< vector containing the vector of classindices that were assigned
161  *< to linking by the partition used by a detector
162  *< (empty vector if no partition was used) */
163 
164  std::vector<int> listofancestorids; /**< vector containing decomposition indices that are ancestors of this partialdec */
165 
166  USERGIVEN usergiven; /**< is this partialdec partially or completely given by user */
167 
168  /* score values (or -1 iff nott computed yet) */
169 
170  SCIP_Real maxwhitescore; /**< score corresponding to the max white measure */
171  SCIP_Real borderareascore; /**< 1 - fraction of border area to complete area */
172  SCIP_Real classicscore; /**< classic score to evaluate the partial */
173  SCIP_Real maxforeseeingwhitescore; /**< 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) */
174  SCIP_Real setpartfwhitescore; /**< 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 )*/
175  SCIP_Real maxforeseeingwhitescoreagg; /**< maximum foreseeing white area score with respect to aggregatable blocks (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) */
176  SCIP_Real setpartfwhitescoreagg; /**< setpartitioning maximum foreseeing white area score with respect to aggregateable (i.e. convex combination of maximum foreseeing white area score and a boolean score rewarding a master containing only setppc and cardinality constraints )*/
177  SCIP_Real bendersscore; /**< score to evaluate the partialdecs */
178  SCIP_Real strongdecompositionscore; /**< strong decomposition score */
179 
180  /* datastructure to store information if this partialdec stems from a partialdec concerning the orig problem */
181  bool stemsfromorig; /**< partialdec has at least one ancestor that is a partialdec from orig problem */
182  bool original; /**< indicates whether partialdec is from original problem */
183  bool isfinishedbyfinisherorig; /**< was the ancestor partialdec for the unpresolved problem finished by the
184  *< finishpartialdec() method of a detector */
185  DEC_DETECTOR* finishedorigby; /**< index of finishing detector of orig ancestor partialdec */
186 
187  int translatedpartialdecid;
188 
189 private:
190  /**< id of the translated partialdec */
191 
192  /**
193  *
194  * @brief simple bliss automorphism check for blocks
195  *
196  * Checks blocks for equality by graph automorphism check, done by bliss
197  * @note equality is only found if variables are in correct order
198  */
199  void checkIdenticalBlocksBliss(
200  int b1, /**< block id of first block */
201  int b2, /**< block id of second block */
202  std::vector<int>& varmap, /**< maps variable indices (corresponding to detprobdata indices) of block 2 to block 1 */
203  SCIP_HASHMAP* varmap2, /**< maps variable pointers of block 2 to those of block 1 if both blocks (problems) are identical*/
204  SCIP_Bool* identical, /**< pointer to store if the subproblems are identical */
205  unsigned int searchnodelimit, /**< bliss search node limit (requires patched bliss version) */
206  unsigned int generatorlimit /**< bliss generator limit (requires patched bliss version) */
207 
208  );
209 
210 
211  /**
212  * @brief brute force equality check for blocks
213  *
214  * Checks blocks for equality by brute force
215  * @note equality is only found if variables are in correct order
216  */
217  void checkIdenticalBlocksBrute(
218  int b1, /**< block id of first block */
219  int b2, /**< block id of second block */
220  std::vector<int>& varmap, /**< maps variable indices (corresponding to detprobdata indices) of prob2 to prob1 */
221  SCIP_HASHMAP* varmap2, /**< maps variable pointers of block 2 to those of block 1 if both blocks (problems) are identical*/
222  SCIP_Bool* identical /**< pointer to store if the subproblems are identical */
223  );
224 
225 
226  /**
227  * @brief plausibility check whether two blocks could be identical
228  *
229  * Check some necessary conditions for two blocks to be identical
230  */
231  void checkIdenticalBlocksTrivial(
232  int b1, /**< block id of first block */
233  int b2, /**< block id of second block */
234  SCIP_Bool* notidentical /**< pointer to store whether or not the non-equality is proven */
235  );
236 
237 public:
238 
239  /**
240  * @brief Standard constructor, creates empty partialdec with unique id
241  * @note initially, all conss and vars are open
242  */
244  SCIP* scip, /**< scip data structure */
245  bool originalProblem /**< true iff partialdec is for presolved problem (else for original problem) */
246  );
247 
248  /**
249  * @brief copy constructor
250  */
252  const PARTIALDECOMP *partialdecToCopy /**< partialdec to be copied */
253  );
254 
255  /**
256  * Standard destructor
257  */
258  ~PARTIALDECOMP();
259 
260  /**
261  * @brief adds a block
262  * @returns the number (id) of the new block
263  * */
264  int addBlock();
265 
266  /**
267  * @brief adds detection time of one detector
268  *
269  * incorporates the needed time of some detector in the detector chain
270  */
271  void addClockTime(
272  SCIP_Real clocktime /**< time to be added */
273  );
274 
275  /**
276  * @brief adds the statistical differences to an ancestor
277  *
278  * incorporates the changes from ancestor partialdec into the statistical data structures
279  */
281  PARTIALDECOMP* ancestor /**< partialdec whose propagation yielded to the current partialdec */
282  );
283 
284  /**
285  * @brief add information about the detector chain
286  *
287  * adds a detectorchain information string to the corresponding vector
288  * (that carries information for each detector call)
289  * */
291  const char* decinfo /**< information string (about the detector call) to add */
292  );
293 
294  /**
295  * @brief adds how many new blocks were introduced
296  *
297  * bookkeeping information: adds number of new blocks created by a detector added to detector chain
298  */
299  void addNNewBlocks(
300  int nnewblocks /**< number of new added blocks by latest detector call */
301  );
302 
303  /**
304  * @brief adds percentage of closed constraints
305  *
306  * bookkeeping information: fraction of constraints that are not longer open for a detector added to detector chain
307  */
308  void addPctConssFromFree(
309  SCIP_Real pct /**< fraction of constraints that are not longer open */
310  );
311 
312  /**
313  * @brief adds percentage of constraints assigned to blocks
314  *
315  * bookkeeping information: adds fraction of constraints assigned to a block for a detector added to detector chain
316  * */
317  void addPctConssToBlock(
318  SCIP_Real pct /**< fraction of constraints assigned to a block */
319  );
320 
321  /**
322  * @brief adds percentage of constraints assigned to border
323  *
324  * bookkeeping information: adds fraction of constraints assigned to the border for a detector added to detector chain
325  */
326  void addPctConssToBorder(
327  SCIP_Real pct /**< fraction constraints assigned to the border */
328  );
329 
330  /**
331  * @brief adds percentage of closed variables
332  *
333  * bookkeeping information: adds fraction of variables that are not longer open for a detector added to detector chain
334  */
335  void addPctVarsFromFree(
336  SCIP_Real pct /**< fraction of variables that are not longer open */
337  );
338 
339 
340  /**
341  * @brief adds percentage of variables assigned to blocks
342  *
343  * bookkeeping information: adds fraction of variables assigned to a block for a detector added to detector chain
344  * */
345  void addPctVarsToBlock(
346  SCIP_Real pct /**< fraction of variables assigned to a block */
347  );
348 
349  /**
350  * @brief adds percentage of variables assigned to border
351  *
352  * bookkeeping information: adds fraction of variables assigned to the border for a detector added to detector chain
353  */
354  void addPctVarsToBorder(
355  SCIP_Real pct /**< fraction of variables assigned to the border */
356  );
357 
358  /**
359  * @brief method to check if at least one constraint is assigned to some block
360  * @returns true iff at least one constraint is assigned to a block
361  * */
363 
364  /**
365  * @brief assigns open conss to master
366  *
367  * assigns open constraints to master according to the cons assignment information given in constoblock hashmap
368  * @returns scip return code
369  * @note for conss assigned to blocks according to constoblock there is no assignment \see assignPartialdecFromConstoblock
370  * @note master assignment is indicated by assigning cons to index additionalNBlocks
371  * */
372  SCIP_RETCODE assignBorderFromConstoblock(
373  SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices */
374  int givenNBlocks /**< number of blocks the hashmap contains */
375  );
376 
377  /**
378  * @brief assigns open vars to stairlinking if appropriate
379  *
380  * assigns open vars to stairlinking if they can be found in exactly two consecutive blocks
381  * @returns true iff at least one stairlinkingvar was assigned
382  */
384  );
385 
386  /**
387  * @brief assigns open conss to master
388  */
390  );
391 
392  /**
393  * @brief assigns conss structure according to given hashmap
394  *
395  * adds blocks and assigns open conss to a new block or to master
396  * according to the cons assignment information given in constoblock hashmap
397  * @returns scip return code
398  * \see assignPartialdecFromConstoblockVector()
399  * @note master assignment is indicated by assigning cons to index additionalNBlocks
400  * */
401  SCIP_RETCODE assignPartialdecFromConstoblock(
402  SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices */
403  int additionalNBlocks /**< number of (additional) blocks the hashmap contains */
404  );
405 
406  /*!
407  * @brief assigns conss structure according to given vector
408  *
409  * adds blocks and assigns open conss to a new block or to master
410  * according to the cons assignment information given in constoblock vector
411  * @returns scip return code
412  * \see assignPartialdecFromConstoblock()
413  * @note master is indicated by assigning cons to index additionalNBlocks */
415  std::vector<int> constoblock, /**< vector containing an assignment of conss to a block or to master */
416  int additionalNBlocks /**< number of (additional) blocks the vector contains */
417  );
418 
419  /**
420  * @brief computes components by connectedness of conss and vars
421  *
422  * computes components corresponding to connectedness of conss and vars
423  * and assigns them accordingly (all but one of largest components)
424  *
425  * strategy: assigns all conss same block if they are connected
426  * two constraints are adjacent if there is a common variable
427  *
428  * @note this relies on the consadjacency structure of the detprobdata
429  * hence it cannot be applied in presence of linking variables
430  */
432  );
433 
434  /**
435  * @brief reassigns linking vars to stairlinkingvars if possible
436  *
437  * potentially reorders blocks for making a maximum number of linking vars stairlinking
438  * if all vars that connect exactly two blocks have a staircase structure, all of them become stairlinkingvars
439  * otherwise, the stairlinking assignment is done greedily
440  * @note precondition: partialdec does not have any stairlinking vars
441  */
443  );
444 
445  /**
446  * @brief checks if all conss are assigned
447  *
448  * returns true iff all constraints are assigned and deletes the vector open conss if so
449  * @return true iff all constraints are assigned
450  * */
451  bool checkAllConssAssigned();
452 
453  /**
454  * @brief Checks whether the assignments in the partialdec are consistent
455  *
456  * The following checks are performed:
457  * - check if nblocks is set appropriately
458  * - check for empty (row- and col-wise) blocks
459  * - every variable is assigned at most once
460  * - check if all not assigned variables are open vars
461  * - check if all open vars are not assigned
462  * - every constraint is assigned at most once
463  * - check if all not assigned constraints are open cons
464  * - check if all open conss are not assigned
465  * - check if the data structures are sorted
466  * - check if variables hitting a cons are either in the cons's block or border or still open
467  * @returns true iff the partialdec seems to be consistent
468  * */
469  bool checkConsistency(
470  );
471 
472  /**
473  * @brief assigns all open constraints and open variables trivially
474  *
475  * strategy: assigns all open conss and vars to blocks if they can be refined there, otherwise to the master
476  *
477  * @note partialdecomps should usually be completed by a detector, only use this function if you know what you are doing.
478  */
479  void complete(
480  );
481 
482  /**
483  * @brief assigns all open constraints and open variables
484  *
485  * strategy: assigns all conss and vars to the same block if they are connected,
486  * a cons and a var are adjacent if the var appears in the cons
487  */
488  void completeByConnected(
489  );
490 
491  /**
492  * @brief assigns all open constraints and open variables
493  *
494  * strategy: assigns all conss and vars to the same block if they are connected
495  * a cons and a var are adjacent if the var appears in the cons
496  * \note this relies on the consadjacency structure of the detprobdata
497  * hence it cannot be applied in presence of linking variables
498  */
500  );
501 
502  /**
503  * @brief assigns all open constraints and open variables
504  *
505  * strategy: assigns a cons (and related vars) to a new block if possible,
506  * if not to an existing block if possible (by means of prior var assignments)
507  * and finally to master, if there does not exist such a block
508  */
509  void completeGreedily(
510  );
511 
512  /** @brief removes the given cons from master
513  */
514  void removeMastercons(
515  int consid /**< id of cons */
516  );
517 
518  /**
519  * @brief: assigns every open cons/var
520  *
521  * Assignments happen as follows:
522  * - to the respective block if it hits exactly one blockvar/blockcons and no open vars/conss
523  * - to master/linking if it hits blockvars/blockconss assigned to different blocks
524  * - and every cons to master that hits a master var
525  * - and every var to master if it does not hit any blockcons and has no open cons
526  * - leave the cons/variableopen if nothing from the above holds
527  * */
528  void considerImplicits(
529  );
530 
531  /**
532  * @brief copies the given partialdec's partition statistics
533  *
534  * @param otherpartialdec partialdec whose partition statistics are to be copied
535  */
537  const PARTIALDECOMP* otherpartialdec
538  );
539 
540  /**
541  * @brief deletes empty blocks and sets nblocks accordingly
542  *
543  * A block is considered to be empty if no constraint is assigned to it,
544  * variables in blocks with no constraints become open
545  *
546  * @param variables if true, then blocks with no constraints but at least one variable are considered to be nonempty
547  */
548  void deleteEmptyBlocks(
549  bool variables
550  );
551 
552  /**
553  * @brief deletes a cons from list of open conss
554  *
555  * @param opencons id of the cons that is not considered open anymore
556  */
557  void deleteOpencons(
558  int opencons
559  );
560 
561  /**
562  * @brief deletes a cons from list of open conss
563  *
564  * @param itr valid iterator pointing to elements of PARTIALDECOMP::openconss
565  */
566  std::vector<int>::const_iterator deleteOpencons(
567  std::vector<int>::const_iterator itr
568  );
569 
570  /**
571  * @brief deletes a var from the list of open vars
572  *
573  * @param openvar id of the var that is not considered open anymore
574  */
575  void deleteOpenvar(
576  int openvar
577  );
578 
579  /**
580  * @brief deletes a var from the list of open vars
581  *
582  * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars
583  */
584  std::vector<int>::const_iterator deleteOpenvar(
585  std::vector<int>::const_iterator itr
586  );
587 
588  /**
589  * @brief displays the relevant information of the partialdec
590  *
591  * @param detailLevel pass a value that indicates how detailed the output should be:
592  * 0: brief overview
593  * 1: block and detector info
594  * 2: cons and var assignments
595  */
596  void displayInfo(
597  int detailLevel
598  );
599 
600  /**
601  * @brief every constraint is either assigned to master or open
602  *
603  * Assignment happens according to the cons assignment information given in constoblock hashmap,
604  * variables are set accordingly
605  * @note precondition: no constraint or variable is already assigned to a block
606  * @return scip return code
607  */
608  SCIP_RETCODE filloutBorderFromConstoblock(
609  SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices
610  *< (master assignment is indicated by assigning cons to index additionalNBlocks) */
611  int givenNBlocks /**< number of blocks the hashmap contains */
612  );
613 
614  /**
615  * @brief assigns all conss to master or a block
616  *
617  * Assignment happens according to the cons assignment information given in constoblock hashmap
618  *
619  * @return scip return code
620  * calculates implicit variable assignment through cons assignment
621  * @note precondition: no cons or var is already assigned to a block and constoblock contains information for every cons */
622 
624  SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices
625  *< (master assignment is indicated by assigning cons to index additionalNBlocks) */
626  int givenNBlocks /**< number of blocks the hashmap contains */
627  );
628 
629  /**
630  * @brief reassigns linking variables to master if appropriate
631  *
632  * Variables are reassigned as master if the variable only hits master conss
633  */
635  );
636 
637  /**
638  * @brief reassigns variables classified as linking to stairlinking if appropriate
639  *
640  * Variables are reassigned as master if the variable hits conss in exactly two consecutive
641  * blocks
642  */
644  );
645 
646  /**
647  * @brief gets partialdec id of given ancestor id
648  * @return partialdec id of given ancestor id
649  */
650  int getAncestorID(
651  int ancestorindex /**< index of ancestor in list of ancestor ids data structure */
652  );
653 
654  /**
655  * @brief get ancestor ids as vector
656  * @return vector of ids of all ancestors id
657  */
658  std::vector<int>& getAncestorList(
659  );
660 
661  /**
662  * set ancestor list directly
663  * @param newlist new list of ancestor ids
664  */
665  void setAncestorList(
666  std::vector<int>& newlist
667  );
668 
669  /** removes ancestor id from list */
670  void removeAncestorID(
671  int ancestorid /**< id to remove */
672  );
673 
674  /**
675  * adds ancestor id to back of list
676  * @param ancestor id of ancestor that is to be added
677  */
678  void addAncestorID(
679  int ancestor
680  );
681 
682  /**
683  * @brief get a vector of block ids that are identical to block with id repid
684  * @param repid id of the representative block
685  * @return vector of block ids that are identical to block with id repid
686  */
687  const std::vector<int> & getBlocksForRep(
688  int repid
689  );
690 
691  /**
692  * @brief returns the time that the detector related to the given detectorchainindex needed for detecting
693  * @return the clock time for the corresponding detector in the chain
694  */
695  SCIP_Real getDetectorClockTime(
696  int detectorchainindex /**< index of the detector in the detectorchain */
697  );
698 
699  /**
700  * @brief returns a vector of the clock times that each detector needed that was involved in this partialdec
701  * @return vector of the clock times
702  */
703  std::vector<SCIP_Real>& getDetectorClockTimes();
704 
705  /**
706  * @brief returns array containing constraints assigned to a block
707  * @param block id of the block the constraint indices are returned
708  * @return array containing constraints assigned to a block
709  */
710  std::vector<int>& getConssForBlock(
711  int block
712  );
713 
714  /**
715  * @brief returns detector chain as vector of detector pointers
716  * @return detector chain as array of detector pointers
717  */
718  std::vector<DEC_DETECTOR*>& getDetectorchain();
719 
720  /**
721  * @brief returns true iff this partialdec was finished by finishPartialdec() method of a detector
722  * @return true iff this partialdec was finished by finishPartialdec() method of a detector
723  */
724  bool getFinishedByFinisher();
725 
726  /**
727  * @brief returns the calculated hash value of this partialdec
728  * @return the calculated hash value of this partialdec
729  */
730  unsigned long getHashValue();
731 
732  /**
733  * @brief returns the unique id of the partialdec
734  * @return the unique id of the partialdec
735  */
736  int getID();
737 
738  /**
739  * @brief returns array containing all linking vars indices
740  * @return vector containing all linking vars indices
741  * @note when accessed it is supposed to be sorted
742  */
743  std::vector<int>& getLinkingvars();
744 
745  /**
746  * @brief Gets array containing all master conss indices
747  * @return array containing all master conss indices
748  * @note when accessed it is supposed to be sorted
749  */
750  std::vector<int>& getMasterconss();
751 
752  /**
753  * @brief Gets array containing all master vars indices
754  *
755  * master vars hit only constraints in the master, aka static variables
756  * @return array containing all master vars indices
757  */
758  std::vector<int>& getMastervars();
759 
760  /**
761  * @brief Gets the number of nonzero coeffs in a certain block
762  * @param blockid of the block the number of nozerors are requested for
763  * @return number of nonzero coeffs in a certain block
764  */
765  int getNCoeffsForBlock(
766  int blockid
767  );
768 
769  /**
770  * Gets the number of nonzero coeffs in master
771  * @return the number of nonzero coeffs in master
772  */
774  );
775 
776  /**
777  * @brief returns the score of the partialdec (depending on used scoretype)
778  * @param type the scoretype
779  * @return the score
780  * @see enum scoretype in cons_decomp.h
781  */
782  SCIP_Real getScore(
783  SCORETYPE type
784  );
785 
786  /**
787  * @brief checks if all master constraints set partitioning, set packing, set cover, or cardinality constraints
788  * @return TRUE iff all master constraints set partitioning, set packing, set cover, or cardinality constraints
789  */
790  SCIP_Bool hasSetppccardMaster(
791  );
792 
793  /**
794  * @brief checks iff all master constraints set partitioning, set packing, or set cover constraints
795  * @return TRUE iff all master constraints set partitioning, set packing, or set cover
796  */
797  SCIP_Bool hasSetppcMaster(
798  );
799 
800  /**
801  * @brief checks iff all master constraints set partitioning, or set packing constraints
802  * @return TRUE iff all master constraints set partitioning, or set packing constraints
803  */
804  SCIP_Bool hasSetppMaster(
805  );
806 
807  /**
808  * @brief Gets the USERGIVEN status of this partialdecs
809  * @return the USERGIVEN status of this partialdecs
810  * @see enum USERGIVEN
811  */
813 
814  /**
815  * @brief Gets number of ancestor partialdecs
816  * @return number of ancestor partialdecs
817  */
818  int getNAncestors();
819 
820  /**
821  * @brief Gets the number of blocks
822  * @return number of blocks
823  */
824  int getNBlocks();
825 
826  /**
827  * @brief Gets the number of constraints
828  * @return number of constraints
829  */
830  int getNConss();
831 
832  /**
833  * @brief Gets size of the vector containing conss assigned to a block
834  * @param block id of the block the number of constraints is asked for
835  * @return size of the vector containing conss assigned to a block
836  */
837  int getNConssForBlock(
838  int block
839  );
840 
841  /**
842  * @brief Gets the detectorchain info vector
843  * @return detectorchain info vector
844  */
845  std::vector<std::string>& getDetectorchainInfo();
846 
847  /**
848  * @brief Gets the number of detectors the partialdec is propagated by
849  * @return number of detectors the partialdec is propagated by
850  */
851  int getNDetectors();
852 
853  /**
854  * @brief Gets size of the vector containing linking vars
855  * @return size of the vector containing linking vars
856  */
857  int getNLinkingvars();
858 
859  /**
860  * @brief Gets size of the vector containing master conss
861  * @returns size of the vector containing master conss
862  */
863  int getNMasterconss();
864 
865  /**
866  * @brief Gets size of the vector containing master vars
867  *
868  * master vars hit only constraints in the master
869  * @return size of the vector containing master vars
870  */
871  int getNMastervars();
872 
873  /**
874  * @brief Gets number of blocks a detector added
875  *
876  * @return number of blocks a detector added
877  */
878  int getNNewBlocks(
879  int detectorchainindex /**< index of the detector in the detectorchain */
880  );
881 
882  /**
883  * @brief gets number of blocks the detectors in the detectorchain added
884  * @return number of blocks the detectors in the detectorchain added
885  */
886  std::vector<int> getNNewBlocksVector();
887 
888  /**
889  * @brief Gets total number of stairlinking vars
890  * @return total number of stairlinking vars
891  */
893 
894  /**
895  * @brief Gets size of vector containing constraints not assigned yet
896  * @return returns size of vector containing constraints not assigned yet
897  */
898  int getNOpenconss();
899 
900  /**
901  * @brief Gets size of vector containing variables not assigned yet
902  * @return size of vector containing variables not assigned yet
903  */
904  int getNOpenvars();
905 
906  /**
907  * @brief Gets the number of blockrepresentatives
908  * @return the number of blockrepresentatives
909  */
910  int getNReps();
911 
912  /**
913  * @brief Gets size of the vector containing stairlinking vars
914  * @param block id of the block the size of the stairlinking vector is asked for
915  * @return size of the vector containing stairlinking vars
916  */
918  int block
919  );
920 
921  /**
922  * @brief Gets number of vars
923  * @return number of vars
924  */
925  int getNVars();
926 
927  /**
928  * @brief Gets size of the vector containing vars assigned to a block
929  * @param block id of the block the number of variables is asked for
930  * @return size of the vector containing vars assigned to a block
931  */
932  int getNVarsForBlock(
933  int block
934  );
935 
936  /**
937  * @brief Gets overall number of vars assigned to a block
938  * @return number of vars that are assigned to any block
939  */
940  int getNVarsForBlocks(
941  );
942 
943  /**
944  * @brief Gets array containing constraints not assigned yet
945  * @return array containing constraints not assigned yet
946  */
947  const int* getOpenconss();
948 
949  /**
950  * @brief Gets a vector containing constraint ids not assigned yet as vector
951  * @return returns a vector containing constraint ids not assigned yet as vector
952  */
953  std::vector<int>& getOpenconssVec();
954 
955  /**
956  * @brief Gets array containing variables not assigned yet
957  * @return returns array containing variables not assigned yet
958  */
959  const int* getOpenvars();
960 
961  /**
962  * Gets array containing variables not assigned yet as vector
963  * @return array containing variables not assigned yet as vector
964  */
965  std::vector<int>& getOpenvarsVec();
966 
967  /**
968  * @brief Gets fraction of variables assigned to the border for a detector
969  *
970  * @return fraction of variables assigned to the border for a detector
971  */
972  SCIP_Real getPctVarsToBorder(
973  int detectorchainindex /**< index of the detector in the detectorchain */
974  );
975 
976  /**
977  * @brief Gets fraction of variables assigned to the border for detectors in detectorchain
978  * @return vector of fractions of variables assigned to the border for detectors in detectorchain
979  */
980  std::vector<SCIP_Real>& getPctVarsToBorderVector();
981 
982  /**
983  * @brief Gets fraction of variables assigned to a block for a detector
984  *
985  * @return fraction of variables assigned to a block for a detector
986  */
987  SCIP_Real getPctVarsToBlock(
988  int detectorchainindex /**< index of the detector in the detectorchain */
989  );
990 
991  /**
992  * @brief returns fraction of variables assigned to a block for detectors in detectorchain
993  * @return vector of fractions of variables assigned to a block for detectors in detectorchain
994  */
995  std::vector<SCIP_Real>& getPctVarsToBlockVector();
996 
997  /**
998  * @brief Gets fraction of variables that are not longer open for a detector
999  *
1000  * @return index of the detector in the detectorchain
1001  */
1002  SCIP_Real getPctVarsFromFree(
1003  int detectorchainindex /**< index of the detector in the detectorchain */
1004  );
1005 
1006  /**
1007  * @brief Gets fraction of variables that are not longer open for detectors in detectorchain
1008  * @return vector or fractions of variables that are not longer open for detectors in detectorchain
1009  */
1010  std::vector<SCIP_Real>& getPctVarsFromFreeVector();
1011 
1012  /**
1013  * @brief Gets fraction of constraints assigned to the border for a detector
1014  * @return returns fraction of constraints assigned to the border for a detector
1015  */
1016  /** */
1017  SCIP_Real getPctConssToBorder(
1018  int detectorchainindex /**< index of the detector in the detectorchain */
1019  );
1020 
1021  /**
1022  * @brief Gets fraction of constraints assigned to the border for detectors in detectorchain
1023  * @return vector of fractions of constraints assigned to the border for detectors in detectorchain
1024  */
1025  std::vector<SCIP_Real>& getPctConssToBorderVector();
1026 
1027  /**
1028  * @brief Gets fraction of constraints assigned to a block for a detector
1029  * @return fraction of constraints assigned to a block for a detector
1030  */
1031  SCIP_Real getPctConssToBlock(
1032  int detectorchainindex /**< index of the detector in the detectorchain */
1033  );
1034 
1035  /**
1036  * @brief Gets fraction of constraints assigned to a block for detectors in detectorchain
1037  * @return vector of fractions of constraints assigned to a block for detectors in detectorchain
1038  */
1039  std::vector<SCIP_Real>& getPctConssToBlockVector();
1040 
1041  /**
1042  * @brief Gets fraction of constraints that are not longer open for a detector
1043  * @return fraction of constraints that are not longer open for a detector
1044  */
1045  SCIP_Real getPctConssFromFree(
1046  int detectorchainindex /**< index of the detector in the detectorchain */
1047  );
1048 
1049  /**
1050  * @brief Gets fraction of constraints that are not longer open for detectors in detectorchain
1051  * @return vector of fractions of constraints that are not longer open for detectors in detectorchain
1052  */
1053  std::vector<SCIP_Real>& getPctConssFromFreeVector();
1054 
1055  /**
1056  * @brief Gets index of the representative block for a block, this might be blockid itself
1057  * @param blockid id of the block the representative is asked for
1058  * @return index of the representative block for a block, this might be blockid itself
1059  */
1060  int getRepForBlock(
1061  int blockid
1062  );
1063 
1064  /**
1065  * @brief Gets the represenation varmap
1066  *
1067  * Var map is vector for represenative repid and the blockrepid-th block that is represented by repid
1068  * @param repid id of representative
1069  * @param blockrepid id of block
1070  * @return the represenation varmap as vector for represenative repid and the blockrepid-th block that is represented by repid
1071  */
1072 
1073  std::vector<int> & getRepVarmap(
1074  int repid,
1075  int blockrepid
1076  );
1077 
1078  /**
1079  * @brief Gets the corresponding detprobdata
1080  * @return corresponding detprobdata
1081  */
1083 
1084  /**
1085  * @brief Gets array containing stairlinking vars,
1086  * @note if a stairlinking variable links block i and i+1 it is only stored in vector of block i
1087  * @param block id of the block the stairlinking variable varctor is asked for
1088  * @return array containing stairlinking vars,
1089  */
1090  const int* getStairlinkingvars(
1091  int block
1092  );
1093 
1094  /**
1095  * @brief Gets array containing vars of a block
1096  * @param block id of the block the vars are requested for
1097  * @return returns array containing vars of a block
1098  */
1099  std::vector<int>& getVarsForBlock(
1100  int block
1101  );
1102 
1103  /**
1104  * @brief Gets index in variables array of a block for a variable
1105  * @param varid the id of the variable the index
1106  * @param block the corresponding block id
1107  * @return returns index in variables array of a block for a variable
1108  */
1110  int varid,
1111  int block
1112  );
1113 
1114  /**
1115  * @brief Gets whether this partialdec is complete,
1116  * i.e. it has no more open constraints and variables
1117  * @return TRUE iff this partialdec is complete
1118  */
1119  bool isComplete();
1120 
1121  /**
1122  * @brief Gets whether the cons is a master cons
1123  * @param cons id of ccons to check if it is master constraint
1124  * @return true iff the cons is a master cons
1125  */
1126  bool isConsMastercons(
1127  int cons
1128  );
1129 
1130  /**
1131  * @brief Gets whether the cons is an open cons
1132  * @param cons id of cons to check
1133  * @return true iff the cons is an open cons
1134  */
1135  bool isConsOpencons(
1136  int cons
1137  );
1138 
1139  /**
1140  * @brief Gets whether the partialdec is from the presolved problem
1141  * @return true iff the partialdec is from the presolved problem
1142  */
1143  bool isAssignedToOrigProb();
1144 
1145  /**
1146  * Gets whether the partialdec is currently selected in explore menue
1147  * @return true iff the partialdec is currently selected in explore menue
1148  */
1149  bool isSelected();
1150 
1151  /**
1152  * @brief method to check whether this partialdec is equal to a given other partialdec ( \see isEqual(PARTIALDECOMP*))
1153 
1154  * @return scip return code
1155  */
1156  SCIP_RETCODE isEqual(
1157  PARTIALDECOMP* otherpartialdec, /**< other partialdec */
1158  SCIP_Bool* isequal, /**< pointer to store whether partialdecs are identical */
1159  bool sortpartialdecs /**< should conss and vars be sorted before comparing the partialdecs? */
1160  );
1161 
1162  /**
1163  * @brief method to check whether this partialdec is equal to a given other partialdec
1164  *
1165  * @return true iff partialdecs are equal
1166  */
1167  bool isEqual(
1168  PARTIALDECOMP* other /**< other partialdec to check equality with */
1169  );
1170 
1171  /**
1172  * @brief Gets whether this partialdec was propagated by specified detector
1173  * @param detector pointer to detector to check for
1174  * @return true iff this partialdec was propagated by detectorID
1175  */
1176  bool isPropagatedBy(
1177  DEC_DETECTOR* detector
1178  );
1179 
1180  /**
1181  * @brief Gets whether this partialdec is considered to be trivial
1182  *
1183  * PARTIALDECOMP is considered trivial if all conss are in one block, all conss are in border,
1184  * all variables linking or mastervars, or all constraints and variables are open
1185  * @return true iff this partialdec is considered to be trivial
1186  */
1187  bool isTrivial();
1188 
1189  /**
1190  * @brief Checks whether the var is assigned to the block
1191  * @param var id of var to check
1192  * @param block id of block to check
1193  * @return true iff the var is assigned to the block
1194  */
1195  bool isVarBlockvarOfBlock(
1196  int var,
1197  int block
1198  );
1199 
1200  /**
1201  * @brief Checks whether the var is a linking var
1202  * @param var id of var to check
1203  * @return true iff the var is a linking var
1204  */
1205  bool isVarLinkingvar(
1206  int var
1207  );
1208 
1209  /**
1210  * @brief Checks whether the var is a master var
1211  * @param var id of var to check
1212  * @return true iff the var is a master var
1213  */
1214  bool isVarMastervar(
1215  int var
1216  );
1217 
1218  /**
1219  * @brief Checks whether the var is an open var
1220  * @param var id of var to check
1221  * @return true iff the var is an open var
1222  */
1223  /** */
1224  bool isVarOpenvar(
1225  int var
1226  );
1227 
1228  /**
1229  * @brief Checks whether the var is a stairlinking var
1230  * @param var id of var to check
1231  * @return true iff the var is a stairlinking var
1232  */
1233  bool isVarStairlinkingvar(
1234  int var
1235  );
1236 
1237  /**
1238  * @brief Checks whether the var is a stairlinkingvar of a specified block
1239  * @param var id of var to check if it is a stairlinking variable hitting specified block
1240  * @param block id of block to check
1241  * @return true iff the var is a stairlinkingvar of a specified block
1242  */
1244  int var,
1245  int block
1246  );
1247 
1248  /**
1249  * @brief prints partition information as described in \see cls reader
1250  * @param givenscip scip data structure
1251  * @param file output file
1252  */
1254  SCIP* givenscip,
1255  FILE* file
1256  );
1257 
1258  /**
1259  * @brief refine partialdec with focus on blocks
1260  *
1261  * strategy: assigns open conss and vars if they can be found in blocks
1262  * (without respect to open vars and conss @see assignHittingOpenconss(), @see assignHittingOpenvars())
1263  * @note partialdec might be not complete
1264  */
1265  void refineToBlocks(
1266  );
1267 
1268  /**
1269  * @brief refine partialdec with focus on master
1270  *
1271  * strategy: do obvious ( @see considerImplicits()) assignments and
1272  * assign other conss and vars to master if possible (@see assignOpenPartialHittingToMaster())
1273  */
1274  void refineToMaster(
1275  );
1276 
1277  /**
1278  * @brief registers statistics for a used conspartition
1279  */
1281  int detectorchainindex, /**< index of the detector in the detectorchain */
1282  ConsPartition* partition, /**< the used conspartition */
1283  std::vector<int>& consclassesmaster /**< vector of classindices that were assigned to master */
1284  );
1285 
1286  /**
1287  * @brief adds a constraint to a block, does not delete this cons from list of open conss
1288  * @param consToBlock id of cons to add
1289  * @param block id of block to add
1290  */
1291  void setConsToBlock(
1292  int consToBlock,
1293  int block
1294  );
1295 
1296  /**
1297  * @brief adds a constraint to a block
1298  * @param cons id of cons to add
1299  * @param block id of block to add
1300  */
1301  void fixConsToBlock(
1302  int cons,
1303  int block
1304  );
1305 
1306  /**
1307  * @brief adds a constraint to a block
1308  * @param cons pointer of cons to add
1309  * @param block id of block to add
1310  * @returns true iff successful
1311  */
1312  bool fixConsToBlock(
1313  SCIP_CONS* cons,
1314  int block
1315  );
1316 
1317  /**
1318  * @brief adds a constraint to the master constraints, does not delete this cons from list of open conss
1319  * @param consToMaster id of cons to add
1320  */
1321  void setConsToMaster(
1322  int consToMaster
1323  );
1324 
1325  /**
1326  * @brief fixes a constraint to the master constraints
1327  * @param itr valid iterator pointing to elements of PARTIALDECOMP::openconss
1328  * @return iterator that points to the next element of PARTIALDECOMP::openconss
1329  * @warning This method modifies the vector PARTIALDECOMP::openconss! Hence, any kind of iterator might be invalid afterwards!
1330  */
1331  std::vector<int>::const_iterator fixConsToMaster(
1332  std::vector<int>::const_iterator itr
1333  );
1334 
1335  /**
1336  * @brief fixes a constraint to the master constraints
1337  * @param cons id of cons to add
1338  * @warning This method modifies the vector PARTIALDECOMP::openconss! Hence, any kind of iterator might be invalid afterwards!
1339  */
1340  void fixConsToMaster(
1341  int cons
1342  );
1343 
1344  /**
1345  * @brief fixes a constraint to the master constraints
1346  * @param cons pointer of cons to add
1347  * @warning This method modifies the vector PARTIALDECOMP::openconss! Hence, any kind of iterator might be invalid afterwards!
1348  * @returns true iff successful
1349  */
1350  bool fixConsToMaster(
1351  SCIP_CONS* cons
1352  );
1353 
1354  /**
1355  * @brief sets the detectorchain with the given vector of detector pointers
1356  * @param givenDetectorChain vector of detector pointers
1357  */
1358  void setDetectorchain(
1359  std::vector<DEC_DETECTOR*>& givenDetectorChain
1360  );
1361 
1362  /**
1363  * @brief sets partialdec to be propagated by a detector
1364  * @param detector pointer to detector that is registered for this partialdec
1365  */
1366  void setDetectorPropagated(
1367  DEC_DETECTOR* detector
1368  );
1369 
1370  /**
1371  * @brief sets detector that finished the partialdec
1372  * @param detector pointer to detector that has finished this partialdecs
1373  */
1374  void setDetectorFinished(
1375  DEC_DETECTOR* detector
1376  );
1377 
1378  /**
1379  * @brief sets detector that finished the partialdec in the original problem
1380  * @param detectorID pointer to detector that has finished this partialdecs
1381  * @note does not add the detector to the detectorchain and does not modify partition statistics
1382  */
1384  DEC_DETECTOR* detectorID
1385  );
1386 
1387  /**
1388  * @brief sets whether this partialdec was finished by a finishing detector
1389  * @param finished is this partialdecs finished by a finishing detector
1390  */
1391  void setFinishedByFinisher(
1392  bool finished
1393  );
1394 
1395  /**
1396  * @brief sets whether this partialdec was finished by a finishing detector in the original problem
1397  *
1398  * (in case this partialdec was translated)
1399  * @param finished was this partialdecs finished by a finishing detector in orig
1400  */
1402  bool finished
1403  );
1404 
1405  /**
1406  * @brief sets number of blocks, only increasing number allowed
1407  * @param nblocks new number of blocks
1408  */
1409  void setNBlocks(
1410  int nblocks
1411  );
1412 
1413  /**
1414  * @brief set the selection status of this partialdecs
1415  * @param selected whether the partialdec is selected
1416  */
1417  void setSelected(
1418  bool selected
1419  );
1420 
1421  /**
1422  * @brief sets whether this partialdec stems from an orig problem partialdec
1423  * @param fromorig has this partialdec ancestors from the orig problem
1424  */
1425  void setStemsFromOrig(
1426  bool fromorig
1427  );
1428 
1429  /**
1430  * @brief sets whether this partialdec is user given
1431  * @param usergiven is this partialdec user given
1432  */
1433  void setUsergiven(
1434  USERGIVEN usergiven
1435  );
1436 
1437  /**
1438  * @brief registers statistics for a used varpartition
1439  */
1441  int detectorchainindex, /**< index of the detector in the detectorchain */
1442  VarPartition* partition, /**< the used varpartition */
1443  std::vector<int>& varclasseslinking, /**< vector of classindices that were assigned to linking */
1444  std::vector<int>& varclassesmaster /**< vector of classindices that were assigned to master */
1445  );
1446 
1447  /**
1448  * @brief adds a variable to the linking variables, does not delete this var from list of open vars
1449  * @param varToBlock id of var to be added
1450  * @param block id of block to be added
1451  */
1452  void setVarToBlock(
1453  int varToBlock,
1454  int block
1455  );
1456 
1457  /**
1458  * @brief adds a variable to the linking variables
1459  * @param var id of var to be added
1460  * @param block id of block to be added
1461  */
1462  void fixVarToBlock(
1463  int var,
1464  int block
1465  );
1466 
1467  /**
1468  * @brief adds a variable to the linking variables
1469  * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars
1470  * @param block id of block to be added
1471  * @return iterator that points to the next element of PARTIALDECOMP::openvars
1472  * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards!
1473  */
1474  std::vector<int>::const_iterator fixVarToBlock(
1475  std::vector<int>::const_iterator itr,
1476  int block
1477  );
1478 
1479  /**
1480  * @brief adds a variable to the linking variables, does not delete this var from list of open vars
1481  * @param varToLinking var to be set to linking
1482  */
1483  void setVarToLinking(
1484  int varToLinking
1485  );
1486 
1487  /**
1488  * @brief adds a variable to the linking variables
1489  * @param var var to be set to linking
1490  */
1491  void fixVarToLinking(
1492  int var
1493  );
1494 
1495  /**
1496  * @brief adds a variable to the linking variables
1497  * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars
1498  * @return iterator that points to the next element of PARTIALDECOMP::openvars
1499  * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards!
1500  */
1501  std::vector<int>::const_iterator fixVarToLinking(
1502  std::vector<int>::const_iterator itr
1503  );
1504 
1505  /** @brief adds a variable to the master variables, does not delete this var from list of open vars
1506  *
1507  * master variables hit only constraints in the master
1508  */
1509  void setVarToMaster(
1510  int varToMaster /**< var to be set to master */
1511  );
1512 
1513  /** @brief adds a variable to the master variables
1514  *
1515  * master variables hit only constraints in the master
1516  */
1517  void fixVarToMaster(
1518  int var /**< var to be set to master */
1519  );
1520 
1521  /** @brief adds a variable to the master variables
1522  *
1523  * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars
1524  * @return iterator that points to the next element of PARTIALDECOMP::openvars
1525  * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards!
1526  */
1527  std::vector<int>::const_iterator fixVarToMaster(
1528  std::vector<int>::const_iterator itr /**< var to be set to master */
1529  );
1530 
1531  /**
1532  * @brief adds a variable to the stairlinking variables, does not delete this var from list of open vars
1533  * @param varToStairLinking id of variable to be added
1534  * @param block1 id of block one
1535  * @param block2 id of block two
1536  * @note stairlinking variables are only registered in block with smaller index
1537  */
1538  void setVarToStairlinking(
1539  int varToStairLinking,
1540  int block1,
1541  int block2
1542  );
1543 
1544  /**
1545  * @brief adds a variable to the stairlinking variables
1546  * @param var id of variable to be added
1547  * @param firstblock stairlinking variables hit exactly two consecutive blocks, this is the index of the first of these blocks
1548  * @note stairlinking variables are only registered in block with smaller index
1549  */
1550  void fixVarToStairlinking(
1551  int var,
1552  int firstblock
1553  );
1554 
1555  /**
1556  * @brief adds a variable to the stairlinking variables
1557  * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars
1558  * @param firstblock stairlinking variables hit exactly two consecutive blocks, this is the index of the first of these blocks
1559  * @return iterator that points to the next element of PARTIALDECOMP::openvars
1560  * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards!
1561  * @note stairlinking variables are only registered in block with smaller index
1562  */
1563  std::vector<int>::const_iterator fixVarToStairlinking(
1564  std::vector<int>::const_iterator itr,
1565  int firstblock
1566  );
1567 
1568  /**
1569  * @brief assigns a constraint by name to a block
1570  * @see fixConsToBlock
1571  * @returns true iff successful
1572  */
1573  bool fixConsToBlockByName(
1574  const char* consname, /**< name of the constraint */
1575  int blockid /**< block index (counting from 0) */
1576  );
1577 
1578  /**
1579  * @brief assigns a variable by name to a block
1580  * @see fixVarToBlock
1581  * @returns true iff successful
1582  */
1583  bool fixVarToBlockByName(
1584  const char* varname, /**< name of the variable */
1585  int blockid /**< block index (counting from 0) */
1586  );
1587 
1588  /**
1589  * @brief assgins a constraint by name as master
1590  * @see fixConsToMaster
1591  * @returns true iff successful
1592  */
1593  bool fixConsToMasterByName(
1594  const char* consname /**< name of cons to fix as master cons */
1595  );
1596 
1597  /**
1598  * @brief assigns a variable with given name as master
1599  * @see fixVarToMaster
1600  * @returns true iff successful
1601  */
1602  bool fixVarToMasterByName(
1603  const char* varname /**< name of the variable */
1604  );
1605 
1606  /**
1607  * @brief assigns a variable by name to the linking variables
1608  * @see fixVarToLinking
1609  * @returns true iff successful
1610  */
1611  bool fixVarToLinkingByName(
1612  const char* varname /**< name of the variable */
1613  );
1614 
1615  /**
1616  * @brief generates and opens a gp visualization of the partialdec
1617  * @see visual/pdfreader and
1618  * @note linux only
1619  */
1620  void showVisualization();
1621 
1622  /**
1623  * @brief generates a visualization of the partialdec using gnuplot
1624  * @param filename Path where to store the gp file
1625  * @param outname Path at which gnuplot will output its result
1626  * @param outputformat The format of the gnuplot output. Should match the file extension of outname
1627  * @note linux only, requires gnuplot
1628  */
1629  void generateVisualization(
1630  char* filename,
1631  char* outname,
1632  GP_OUTPUT_FORMAT outputformat = GP_OUTPUT_FORMAT_PDF
1633  );
1634 
1635  /**
1636  * @brief writes a gp visualization of the partialdec to a file
1637  * @param filename Path where to store the gp file
1638  * @param outname Path at which gnuplot will output its result
1639  * @param outputformat The format of the gnuplot output. Should match the file extension of outname
1640  */
1642  char* filename,
1643  char* outname,
1644  GP_OUTPUT_FORMAT outputformat = GP_OUTPUT_FORMAT_PDF
1645  );
1646 
1647  /**
1648  * @brief generates a gp visualization of the partialdec without compilation or opening
1649  */
1650  void exportVisualization();
1651 
1652  /**
1653  * @brief Checks whether this partialdec is a userpartialdec that should be completed
1654  *
1655  * the completion should be done by setting unspecified constraints to master
1656  * @return TRUE iff this partialdec is a userpartialdec that should be completed
1657  */
1658  SCIP_Bool shouldCompletedByConsToMaster();
1659 
1660  /**
1661  * @brief sorts the vars and conss data structures by their indices
1662  * @returns true if the internal order of variables or constraints changed
1663  */
1664  bool sort();
1665 
1666  /**
1667  * @brief set statistical vector of fractions of constraints set to blocks per involved detector
1668  * @param newvector vector of fractions of constraints set to blocks per involved detector
1669  */
1671  std::vector<SCIP_Real>& newvector
1672  );
1673 
1674  /**
1675  * @brief set statistical vector of fractions of constraints that are not longer open per involved detector
1676  * @param newvector vector of fractions of constraints that are not longer open per involved detector
1677  */
1679  std::vector<SCIP_Real>& newvector
1680  );
1681 
1682  /**
1683  * @brief set statistical vector of fractions of constraints assigned to the border per involved detector
1684  * @param newvector vector of fractions of constraints assigned to the border per involved detector
1685  */
1687  std::vector<SCIP_Real>& newvector
1688  );
1689 
1690  /**
1691  * @brief set statistical vector of fraction of variables assigned to the border per involved detector
1692  * @param newvector vector of fractions of variables assigned to the border per involved detector
1693  */
1695  std::vector<SCIP_Real>& newvector
1696  );
1697 
1698  /**
1699  * @brief set statistical vector of fractions of variables assigned to a block per involved detector
1700  * @param newvector vector of fractions of variables assigned to a block per involved detector
1701  */
1703  std::vector<SCIP_Real>& newvector
1704  );
1705 
1706  /**
1707  * @brief set statistical vector of variables that are not longer open per involved detector
1708  * @param newvector vector of fractions of variables that are not longer open per involved detector
1709  */
1711  std::vector<SCIP_Real>& newvector
1712  );
1713 
1714  /**
1715  * @brief set statistical vector of the times that the detectors needed for detecting per involved detector
1716  * @param newvector vector of the times that the detectors needed for detecting per involved detector
1717  */
1718  void setDetectorClockTimes(
1719  std::vector<SCIP_Real>& newvector
1720  );
1721 
1722  /** @brief gets the classic score
1723  *
1724  * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcClassicScore
1725  * @returns border area score
1726  */
1727  SCIP_Real getClassicScore();
1728 
1729  /** @brief set the classic score
1730  */
1731  void setClassicScore(
1732  SCIP_Real score /**< new score value in [0,1] */
1733  );
1734 
1735  /** @brief gets the border area score
1736  *
1737  * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcBorderAreaScore
1738  * @returns border area score
1739  */
1740  SCIP_Real getBorderAreaScore();
1741 
1742  /** @brief set the border area score
1743  */
1744  void setBorderAreaScore(
1745  SCIP_Real score /**< new score value in [0,1] */
1746  );
1747 
1748  /** @brief gets the maximum white area score
1749  *
1750  * "maximum white score" is fraction of the area of the decomposed matrix that is neither block or border
1751  * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcMaxWhiteScore
1752  * @returns maximum white area score
1753  * */
1754  SCIP_Real getMaxWhiteScore();
1755 
1756  /** @brief set the maximum white area score
1757  */
1758  void setMaxWhiteScore(
1759  SCIP_Real score /**< new score value in [0,1] */
1760  );
1761 
1762  /** @brief gets the maximum foreseeing white area score
1763  *
1764  * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcMaxForseeingWhiteScore
1765  * @returns maximum foreseeing white area score
1766  * */
1767  SCIP_Real getMaxForWhiteScore();
1768 
1769  /** @brief set the maximum foreseeing white area score
1770  */
1771  void setMaxForWhiteScore(
1772  SCIP_Real score /**< new score value in [0,1] */
1773  );
1774 
1775  /** @brief gets the setpartitioning maximum foreseeing white area score
1776  *
1777  * @note -1 iff not calculated yet, \see GGCGconshdlrDecompCalcSetPartForseeingWhiteScore
1778  * @returns setpartitioning maximum foreseeing white area score
1779  * */
1780  SCIP_Real getSetPartForWhiteScore();
1781 
1782  /** @brief set the setpartitioning maximum foreseeing white area score
1783  */
1785  SCIP_Real score /**< new score value in [0,1] */
1786  );
1787 
1788  /** @brief gets the maximum foreseeing white area score with respect to aggregatable blocks
1789  *
1790  * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcMaxForeseeingWhiteAggScore
1791  * @returns maximum foreseeing white area score with respect to aggregatable blocks
1792  * */
1793  SCIP_Real getMaxForWhiteAggScore();
1794 
1795  /** @brief set the maximum foreseeing white area score with respect to aggregatable blocks
1796  */
1798  SCIP_Real score /**< new score value in [0,1] */
1799  );
1800 
1801  /** @brief gets the setpartitioning maximum foreseeing white area score with respect to aggregateable
1802  *
1803  * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcSetPartForWhiteAggScore
1804  * @returns setpartitioning maximum foreseeing white area score with respect to aggregateable
1805  */
1806  SCIP_Real getSetPartForWhiteAggScore();
1807 
1808  /** @brief set the setpartitioning maximum foreseeing white area score with respect to aggregateable
1809  */
1811  SCIP_Real score /**< new score value in [0,1] */
1812  );
1813 
1814  /** @brief gets the benders score
1815  *
1816  * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcBendersScore
1817  * @returns benders score
1818  */
1819  SCIP_Real getBendersScore();
1820 
1821  /** @brief set the benders score
1822  */
1823  void setBendersScore(
1824  SCIP_Real score /**< new score value in [0,1] */
1825  );
1826 
1827  /** @brief gets the strong decomposition score
1828  *
1829  * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcStrongDecompositionScore
1830  * @returns strong decomposition score
1831  */
1832  SCIP_Real getStrongDecompScore();
1833 
1834  /** @brief set the strong decomposition score
1835  */
1836  void setStrongDecompScore(
1837  SCIP_Real score /**< new score value in [0,1] */
1838  );
1839 
1840  /** sorts the partialdec and calculates a its implicit assignments, hashvalue and evaluation
1841  *
1842  * @returns SCIP_OKAY if the result is consistent, SCIP_ERROR if there was an inconsistency
1843  */
1844  void prepare();
1845 
1846  /**
1847  * @brief Checks if the aggregation information was already calculated
1848  * @return true iff the aggregation information was already calculated
1849  */
1850  bool aggInfoCalculated();
1851 
1852  /**
1853  * @brief computes if aggregation of sub problems is possible
1854  *
1855  * checks if aggregation of sub problems is possible and stores the corresponding aggregation information
1856  *
1857  * @param ignoreDetectionLimits Set to true if computation should ignore detection limits. This parameter is ignored if the patched bliss version is not present.
1858  */
1860  bool ignoreDetectionLimits
1861  );
1862 
1863  /**< @brief gets vector of indices of all constraints assigned to blocks
1864  *
1865  * @note conssforblocks[k] contains a vector of indices of all constraints assigned to block k
1866  * @returns vector of a vector of indices for each block */
1867  std::vector<std::vector<int>>& getConssForBlocks(
1868  );
1869 
1870  int getTranslatedpartialdecid() const;
1871 
1873  int decid
1874  );
1875 
1876  /**
1877  * @brief creates a detector chain short string for this partialdec, is built from detector chain
1878  */
1879  void buildDecChainString(
1880  char* buffer /**< will contain string of detector chars in chronological order afterwards*/
1881  );
1882 
1883 private:
1884 
1885  /**
1886  * @brief adds empty entries for all partition statistics for a detector added to the detector chain
1887  */
1888  void addEmptyPartitionStatistics();
1889 
1890  /** @brief assigns open cons
1891  *
1892  * Assignments as follows:
1893  * - to master if it hits blockvars of different blocks
1894  * - to the respective block if it hits a blockvar of exactly one block and no stairlinking var
1895  * - to master if it hits a stairlinking var but there is no block the cons may be assigned to
1896  * - to the block with the lowest number of conss if it hits a stairlinking var and there are blocks the cons may be
1897  * assigned to
1898  * - leave it open if it hits no blocks yet
1899  * @return true iff some assignment was made by the method
1900  */
1901  bool assignHittingOpenconss(
1902  );
1903 
1904  /** @brief assigns every open var
1905  *
1906  * Assignments as follows:
1907  * - to the respective block if it hits blockconss of exactly one block
1908  * - to linking if it hits blockconss of more than one different blocks
1909  * - leave the var open otherwise
1910  * @return true iff there is a var that has been assigned in this call*/
1911  bool assignHittingOpenvars(
1912  );
1913 
1914  /**
1915  * @brief assigns every open cons to master that hits
1916  *
1917  * Assignments as follows:
1918  * - exactly one block var and at least one open var or
1919  * - a master var
1920  * - or leave it open elsewise
1921  */
1922  void assignOpenPartialHittingConsToMaster(
1923  );
1924 
1925  /**
1926  * @brief assigns open conss/vars that hit exactly one block and at least one open var/cons to border
1927  */
1928  void assignOpenPartialHittingToMaster(
1929  );
1930 
1931  /**
1932  * @brief assigns every open var to linking that hits
1933  *
1934  * Assignments as follows:
1935  * - exactly one block cons and at least one open cons
1936  * - leave it open otherwise
1937  */
1938  void assignOpenPartialHittingVarsToMaster(
1939  );
1940 
1941  /**
1942  * @brief calculates the number of nonzero coefficients for the blocks
1943  */
1944  void calcNCoeffsForBlocks(
1945  );
1946 
1947  /**
1948  * @brief calculates the hash value of the partialdec for comparing
1949  */
1950  void calcHashvalue();
1951 
1952  /**
1953  * @brief blockwise calculation of how many master conss contain the block vars
1954  *
1955  * counts for each pair of block and master constraint, how many nonzero entries the variables of the blocks
1956  * have in the master constraint
1957  */
1958  void calcNCoeffsForBlockForMastercons(
1959  );
1960 
1961  /**
1962  * @brief optimizes block order to max stairlinking vars
1963  *
1964  * changes the block order in a way such that all linking vars that are potentially stairlinking
1965  * may be reassigned to stairlinking
1966  * @note precondition: all potentially stairlinking vars have a staircase structure */
1967  void changeBlockOrderStaircase(
1968  GraphGCG* g /**< graph with blocks as nodes and weighted edges for the number of
1969  potentially stairlinkingvars connecting two blocks */
1970  );
1971 
1972  /**
1973  * @brief changes the order of the blocks according to the given mapping
1974  *
1975  * \note precondition: given mapping needs to be an adequately sized permutation */
1976  void changeBlockOrder(
1977  std::vector<int> oldToNewBlockIndex /**< the mapping from old to new block indices */
1978  );
1979 
1980  /**
1981  * @brief returns true if the given detector used a conspartition
1982  * @return true iff the given detector used a conspartition
1983  */
1984  bool consPartitionUsed(
1985  int detectorchainindex /**< index of the detector in the detectorchain */
1986  );
1987 
1988  /**
1989  * @brief prints out the current aggregation information
1990  *
1991  * aggregation information: if there has been identified identical blocks
1992  */
1993  void displayAggregationInformation();
1994 
1995  /**
1996  * @brief calculates potential stairlinking variables with their blocks
1997  *
1998  * @return a vector of pairs of var index and vector of (two) block indices
1999  * the related linking variable hits exactly these two blocks given in the related vector
2000  */
2001  std::vector< std::pair< int, std::vector< int > > > findLinkingVarsPotentiallyStairlinking(
2002  );
2003 
2004  /**
2005  * @brief returns the data of the conspartition that the given detector made use of
2006  */
2007  void getConsPartitionData(
2008  int detectorchainindex, /**< index of the detector in the detectorchain */
2009  ConsPartition** partition, /**< a pointer to the used conspartition (set by method)*/
2010  std::vector<int>& consclassesmaster /**< a vector containing all indices of the consclasses assigned to master
2011  * (set by method) */
2012  );
2013 
2014  /**
2015  * @brief returns a string displaying all detector-related clock times and assignment data
2016  *
2017  * @return string displaying all detector-related clock times and assignment data
2018  */
2019  std::string getDetectorStatistics(
2020  int detectorchainindex /**< index of the detector in the detectorchain */
2021  );
2022 
2023  /**
2024  * @brief returns a string displaying partition information if a partition was used
2025  *
2026  * @return string displaying partition information if a partition was used
2027  */
2028  std::string getDetectorPartitionInfo(
2029  int detectorchainindex, /**< index of the detector in the detectorchain */
2030  bool displayConssVars /**< pass true if constraints and variables of the respective classes should be displayed */
2031  );
2032 
2033  /**
2034  * @brief Gets the number used partitions
2035  * @return number used partitions
2036  */
2037  int getNUsedPartitions();
2038 
2039  /**
2040  * @brief Gets the data of the varpartition that the given detector made use of
2041  * @return data of the varpartition that the given detector made use of
2042  */
2043  void getVarPartitionData(
2044  int detectorchainindex, /**< index of the detector in the detectorchain */
2045  VarPartition** partition, /**< a pointer to the used varpartition (set by method) */
2046  std::vector<int>& varclasseslinking, /**< a vector containing all indices of the varclasses assigned to linking (set by method) */
2047  std::vector<int>& varclassesmaster /**< a vector containing all indices of the varclasses assigned to master (set by method)*/
2048  );
2049 
2050  /**
2051  * @brief checks if calculation of aggregation information is considered to be too expensive
2052  * @return TRUE iff calculation of aggregation information is considered to be too expensive
2053  */
2054  SCIP_Bool isAgginfoTooExpensive();
2055 
2056  /**
2057  * @brief Gets whether the cons is a cons of the block
2058  * @param cons id of constraint to check
2059  * @param block id of the blocks
2060  * @return true iff the cons is a cons of the block
2061  */
2062  /** */
2063  bool isConsBlockconsOfBlock(
2064  int cons,
2065  int block
2066  );
2067 
2068  /**
2069  * @brief returns true if the given detector used a varpartition
2070  *
2071  * @return true if the given detector used a varpartition
2072  */
2073  bool varPartitionUsed(
2074  int detectorchainindex /**< index of the detector in the detectorchain */
2075  );
2076 
2077 };
2078 
2079 
2080 } /* namespace gcg */
2081 #endif /* GCG_CLASS_PARTIALDECOMP_H__ */
void addClockTime(SCIP_Real clocktime)
adds detection time of one detector
void removeAncestorID(int ancestorid)
void setFinishedByFinisher(bool finished)
sets whether this partialdec was finished by a finishing detector
bool aggInfoCalculated()
Checks if the aggregation information was already calculated.
SCIP_Real getClassicScore()
gets the classic score
SCIP_Bool hasSetppMaster()
checks iff all master constraints set partitioning, or set packing constraints
std::vector< int > & getMastervars()
Gets array containing all master vars indices.
bool isVarStairlinkingvar(int var)
Checks whether the var is a stairlinking var.
std::vector< int > & getVarsForBlock(int block)
Gets array containing vars of a block.
void fixVarToMaster(int var)
adds a variable to the master variables
void setVarToStairlinking(int varToStairLinking, int block1, int block2)
adds a variable to the stairlinking variables, does not delete this var from list of open vars
int getNOpenvars()
Gets size of vector containing variables not assigned yet.
std::vector< int > & getOpenvarsVec()
void copyPartitionStatistics(const PARTIALDECOMP *otherpartialdec)
copies the given partialdec's partition statistics
SCIP_Real getBendersScore()
gets the benders score
std::vector< int >::const_iterator fixConsToMaster(std::vector< int >::const_iterator itr)
fixes a constraint to the master constraints
class representing a partition of a set of variables
void setMaxForWhiteAggScore(SCIP_Real score)
set the maximum foreseeing white area score with respect to aggregatable blocks
void addDetectorChainInfo(const char *decinfo)
add information about the detector chain
void setAncestorList(std::vector< int > &newlist)
USERGIVEN
enumeration to display if a decomposition was given by the user and if so, how it was processed after...
SCIP_Real getPctVarsFromFree(int detectorchainindex)
Gets fraction of variables that are not longer open for a detector.
SCIP_Real getPctConssFromFree(int detectorchainindex)
Gets fraction of constraints that are not longer open for a detector.
void setNBlocks(int nblocks)
sets number of blocks, only increasing number allowed
void setFinishedByFinisherOrig(bool finished)
sets whether this partialdec was finished by a finishing detector in the original problem
std::vector< int > & getOpenconssVec()
Gets a vector containing constraint ids not assigned yet as vector.
bool checkAllConssAssigned()
checks if all conss are assigned
void setVarToMaster(int varToMaster)
adds a variable to the master variables, does not delete this var from list of open vars
SCIP_Real getMaxForWhiteAggScore()
gets the maximum foreseeing white area score with respect to aggregatable blocks
void displayInfo(int detailLevel)
displays the relevant information of the partialdec
void writeVisualizationFile(char *filename, char *outname, GP_OUTPUT_FORMAT outputformat=GP_OUTPUT_FORMAT_PDF)
writes a gp visualization of the partialdec to a file
bool isVarOpenvar(int var)
Checks whether the var is an open var.
std::vector< SCIP_Real > & getPctConssToBlockVector()
Gets fraction of constraints assigned to a block for detectors in detectorchain.
void setPctVarsToBlockVector(std::vector< SCIP_Real > &newvector)
set statistical vector of fractions of variables assigned to a block per involved detector
int getVarProbindexForBlock(int varid, int block)
Gets index in variables array of a block for a variable.
bool isVarBlockvarOfBlock(int var, int block)
Checks whether the var is assigned to the block.
void setVarToLinking(int varToLinking)
adds a variable to the linking variables, does not delete this var from list of open vars
void findVarsLinkingToStairlinking()
reassigns variables classified as linking to stairlinking if appropriate
void addPctConssToBorder(SCIP_Real pct)
adds percentage of constraints assigned to border
std::vector< int > & getMasterconss()
Gets array containing all master conss indices.
bool isComplete()
Gets whether this partialdec is complete, i.e. it has no more open constraints and variables.
class representing a partition of a set of constraints
void fixVarToLinking(int var)
adds a variable to the linking variables
type definition for score type
void setTranslatedpartialdecid(int decid)
void setDetectorClockTimes(std::vector< SCIP_Real > &newvector)
set statistical vector of the times that the detectors needed for detecting per involved detector
std::vector< SCIP_Real > & getPctVarsToBlockVector()
returns fraction of variables assigned to a block for detectors in detectorchain
USERGIVEN getUsergiven()
Gets the USERGIVEN status of this partialdecs.
int getNVarsForBlock(int block)
Gets size of the vector containing vars assigned to a block.
void setDetectorchain(std::vector< DEC_DETECTOR * > &givenDetectorChain)
sets the detectorchain with the given vector of detector pointers
SCIP_RETCODE filloutBorderFromConstoblock(SCIP_HASHMAP *constoblock, int givenNBlocks)
every constraint is either assigned to master or open
void showVisualization()
generates and opens a gp visualization of the partialdec
bool getFinishedByFinisher()
returns true iff this partialdec was finished by finishPartialdec() method of a detector
std::vector< int > getNNewBlocksVector()
gets number of blocks the detectors in the detectorchain added
void setMaxForWhiteScore(SCIP_Real score)
set the maximum foreseeing white area score
void complete()
assigns all open constraints and open variables trivially
bool fixVarToMasterByName(const char *varname)
assigns a variable with given name as master
data structures for detectors
void addPctVarsFromFree(SCIP_Real pct)
adds percentage of closed variables
SCIP_Real getSetPartForWhiteScore()
gets the setpartitioning maximum foreseeing white area score
int getNTotalStairlinkingvars()
Gets total number of stairlinking vars.
void fixVarToStairlinking(int var, int firstblock)
adds a variable to the stairlinking variables
void deleteOpencons(int opencons)
deletes a cons from list of open conss
void completeByConnected()
assigns all open constraints and open variables
void buildDecChainString(char *buffer)
creates a detector chain short string for this partialdec, is built from detector chain
void addAncestorID(int ancestor)
bool fixVarToLinkingByName(const char *varname)
assigns a variable by name to the linking variables
void setSetPartForWhiteScore(SCIP_Real score)
set the setpartitioning maximum foreseeing white area score
void setMaxWhiteScore(SCIP_Real score)
set the maximum white area score
SCIP_Real getMaxWhiteScore()
gets the maximum white area score
void setUsergiven(USERGIVEN usergiven)
sets whether this partialdec is user given
bool isConsMastercons(int cons)
Gets whether the cons is a master cons.
SCIP_Bool hasSetppccardMaster()
checks if all master constraints set partitioning, set packing, set cover, or cardinality constraints
std::vector< int > & getRepVarmap(int repid, int blockrepid)
Gets the represenation varmap.
void setDetectorFinished(DEC_DETECTOR *detector)
sets detector that finished the partialdec
void considerImplicits()
: assigns every open cons/var
void calcStairlinkingVars()
reassigns linking vars to stairlinkingvars if possible
int getNStairlinkingvars(int block)
Gets size of the vector containing stairlinking vars.
int getNConssForBlock(int block)
Gets size of the vector containing conss assigned to a block.
static SCIP_RETCODE partition(SCIP *scip, SCIP_VAR **J, int *Jsize, SCIP_Longint *priority, SCIP_VAR **F, int Fsize, SCIP_VAR **origvar, SCIP_Real *median)
void deleteOpenvar(int openvar)
deletes a var from the list of open vars
int getNAncestors()
Gets number of ancestor partialdecs.
SCIP_Bool hasSetppcMaster()
checks iff all master constraints set partitioning, set packing, or set cover constraints
void setStrongDecompScore(SCIP_Real score)
set the strong decomposition score
SCIP_Bool shouldCompletedByConsToMaster()
Checks whether this partialdec is a userpartialdec that should be completed.
SCIP_Real getPctConssToBorder(int detectorchainindex)
Gets fraction of constraints assigned to the border for a detector.
void addDecChangesFromAncestor(PARTIALDECOMP *ancestor)
adds the statistical differences to an ancestor
void exportVisualization()
generates a gp visualization of the partialdec without compilation or opening
void setConsToBlock(int consToBlock, int block)
adds a constraint to a block, does not delete this cons from list of open conss
void setPctVarsToBorderVector(std::vector< SCIP_Real > &newvector)
set statistical vector of fraction of variables assigned to the border per involved detector
SCIP_RETCODE filloutPartialdecFromConstoblock(SCIP_HASHMAP *constoblock, int givenNBlocks)
assigns all conss to master or a block
void addPctVarsToBorder(SCIP_Real pct)
adds percentage of variables assigned to border
void addPctConssToBlock(SCIP_Real pct)
adds percentage of constraints assigned to blocks
SCIP_Real getPctConssToBlock(int detectorchainindex)
Gets fraction of constraints assigned to a block for a detector.
bool isVarStairlinkingvarOfBlock(int var, int block)
Checks whether the var is a stairlinkingvar of a specified block.
SCIP_Real getSetPartForWhiteAggScore()
gets the setpartitioning maximum foreseeing white area score with respect to aggregateable
void completeGreedily()
assigns all open constraints and open variables
SCIP_Real getBorderAreaScore()
gets the border area score
SCIP_RETCODE assignBorderFromConstoblock(SCIP_HASHMAP *constoblock, int givenNBlocks)
assigns open conss to master
void setStemsFromOrig(bool fromorig)
sets whether this partialdec stems from an orig problem partialdec
int getRepForBlock(int blockid)
Gets index of the representative block for a block, this might be blockid itself.
int getNLinkingvars()
Gets size of the vector containing linking vars.
bool assignCurrentStairlinking()
assigns open vars to stairlinking if appropriate
void setConsPartitionStatistics(int detectorchainindex, ConsPartition *partition, std::vector< int > &consclassesmaster)
registers statistics for a used conspartition
void setPctConssToBorderVector(std::vector< SCIP_Real > &newvector)
set statistical vector of fractions of constraints assigned to the border per involved detector
bool sort()
sorts the vars and conss data structures by their indices
void setPctConssFromFreeVector(std::vector< SCIP_Real > &newvector)
set statistical vector of fractions of constraints that are not longer open per involved detector
void refineToBlocks()
refine partialdec with focus on blocks
SCIP_Real getStrongDecompScore()
gets the strong decomposition score
std::vector< SCIP_Real > & getPctConssFromFreeVector()
Gets fraction of constraints that are not longer open for detectors in detectorchain.
void setConsToMaster(int consToMaster)
adds a constraint to the master constraints, does not delete this cons from list of open conss
void printPartitionInformation(SCIP *givenscip, FILE *file)
prints partition information as described in
const int * getStairlinkingvars(int block)
Gets array containing stairlinking vars,.
void findVarsLinkingToMaster()
reassigns linking variables to master if appropriate
int getNReps()
Gets the number of blockrepresentatives.
SCIP_Real getPctVarsToBorder(int detectorchainindex)
Gets fraction of variables assigned to the border for a detector.
const int * getOpenconss()
Gets array containing constraints not assigned yet.
int getNConss()
Gets the number of constraints.
void assignSmallestComponentsButOneConssAdjacency()
computes components by connectedness of conss and vars
@ GP_OUTPUT_FORMAT_PDF
Definition: reader_gp.h:53
const std::vector< int > & getBlocksForRep(int repid)
get a vector of block ids that are identical to block with id repid
int getNNewBlocks(int detectorchainindex)
Gets number of blocks a detector added.
unsigned long getHashValue()
returns the calculated hash value of this partialdec
int getTranslatedpartialdecid() const
std::vector< SCIP_Real > & getPctConssToBorderVector()
Gets fraction of constraints assigned to the border for detectors in detectorchain.
void setSelected(bool selected)
set the selection status of this partialdecs
void addNNewBlocks(int nnewblocks)
adds how many new blocks were introduced
int getAncestorID(int ancestorindex)
gets partialdec id of given ancestor id
bool checkConsistency()
Checks whether the assignments in the partialdec are consistent.
int getNDetectors()
Gets the number of detectors the partialdec is propagated by.
int addBlock()
adds a block
void setBorderAreaScore(SCIP_Real score)
set the border area score
std::vector< std::string > & getDetectorchainInfo()
Gets the detectorchain info vector.
int getNCoeffsForBlock(int blockid)
Gets the number of nonzero coeffs in a certain block.
void setPctConssToBlockVector(std::vector< SCIP_Real > &newvector)
set statistical vector of fractions of constraints set to blocks per involved detector
PARTIALDECOMP(SCIP *scip, bool originalProblem)
Standard constructor, creates empty partialdec with unique id.
enum GPOutputFormat GP_OUTPUT_FORMAT
Definition: reader_gp.h:57
std::vector< SCIP_Real > & getDetectorClockTimes()
returns a vector of the clock times that each detector needed that was involved in this partialdec
std::vector< int > & getConssForBlock(int block)
returns array containing constraints assigned to a block
int getNVarsForBlocks()
Gets overall number of vars assigned to a block.
bool fixConsToMasterByName(const char *consname)
assgins a constraint by name as master
class to manage partial decompositions
bool isVarMastervar(int var)
Checks whether the var is a master var.
int getNBlocks()
Gets the number of blocks.
void setClassicScore(SCIP_Real score)
set the classic score
miscellaneous graph methods for structure detection
void fixVarToBlock(int var, int block)
adds a variable to the linking variables
SCIP_Real getScore(SCORETYPE type)
returns the score of the partialdec (depending on used scoretype)
void setVarToBlock(int varToBlock, int block)
adds a variable to the linking variables, does not delete this var from list of open vars
DETPROBDATA * getDetprobdata()
Gets the corresponding detprobdata.
void removeMastercons(int consid)
removes the given cons from master
SCIP_RETCODE assignPartialdecFromConstoblockVector(std::vector< int > constoblock, int additionalNBlocks)
assigns conss structure according to given vector
void assignOpenConssToMaster()
assigns open conss to master
bool isVarLinkingvar(int var)
Checks whether the var is a linking var.
void setVarPartitionStatistics(int detectorchainindex, VarPartition *partition, std::vector< int > &varclasseslinking, std::vector< int > &varclassesmaster)
registers statistics for a used varpartition
void setSetPartForWhiteAggScore(SCIP_Real score)
set the setpartitioning maximum foreseeing white area score with respect to aggregateable
std::vector< int > & getLinkingvars()
returns array containing all linking vars indices
void addPctConssFromFree(SCIP_Real pct)
adds percentage of closed constraints
bool fixVarToBlockByName(const char *varname, int blockid)
assigns a variable by name to a block
Implementation of the graph which supports both node and edge weights.
int getNOpenconss()
Gets size of vector containing constraints not assigned yet.
SCIP_RETCODE assignPartialdecFromConstoblock(SCIP_HASHMAP *constoblock, int additionalNBlocks)
assigns conss structure according to given hashmap
bool isConsOpencons(int cons)
Gets whether the cons is an open cons.
SCIP_RETCODE isEqual(PARTIALDECOMP *otherpartialdec, SCIP_Bool *isequal, bool sortpartialdecs)
method to check whether this partialdec is equal to a given other partialdec (
bool isPropagatedBy(DEC_DETECTOR *detector)
Gets whether this partialdec was propagated by specified detector.
int getID()
returns the unique id of the partialdec
void addPctVarsToBlock(SCIP_Real pct)
adds percentage of variables assigned to blocks
void setPctVarsFromFreeVector(std::vector< SCIP_Real > &newvector)
set statistical vector of variables that are not longer open per involved detector
void calcAggregationInformation(bool ignoreDetectionLimits)
computes if aggregation of sub problems is possible
bool fixConsToBlockByName(const char *consname, int blockid)
assigns a constraint by name to a block
void setDetectorPropagated(DEC_DETECTOR *detector)
sets partialdec to be propagated by a detector
SCIP_Real getPctVarsToBlock(int detectorchainindex)
Gets fraction of variables assigned to a block for a detector.
std::vector< int > & getAncestorList()
get ancestor ids as vector
GP file reader writing decompositions to gnuplot files.
bool alreadyAssignedConssToBlocks()
method to check if at least one constraint is assigned to some block
std::vector< DEC_DETECTOR * > & getDetectorchain()
returns detector chain as vector of detector pointers
bool isTrivial()
Gets whether this partialdec is considered to be trivial.
void setBendersScore(SCIP_Real score)
set the benders score
int getNMasterconss()
Gets size of the vector containing master conss.
bool isAssignedToOrigProb()
Gets whether the partialdec is from the presolved problem.
std::vector< SCIP_Real > & getPctVarsToBorderVector()
Gets fraction of variables assigned to the border for detectors in detectorchain.
void refineToMaster()
refine partialdec with focus on master
const int * getOpenvars()
Gets array containing variables not assigned yet.
SCIP_Real getDetectorClockTime(int detectorchainindex)
returns the time that the detector related to the given detectorchainindex needed for detecting
void setDetectorFinishedOrig(DEC_DETECTOR *detectorID)
sets detector that finished the partialdec in the original problem
enum scoretype SCORETYPE
void deleteEmptyBlocks(bool variables)
deletes empty blocks and sets nblocks accordingly
int getNMastervars()
Gets size of the vector containing master vars.
std::vector< SCIP_Real > & getPctVarsFromFreeVector()
Gets fraction of variables that are not longer open for detectors in detectorchain.
void fixConsToBlock(int cons, int block)
adds a constraint to a block
void completeByConnectedConssAdjacency()
assigns all open constraints and open variables
SCIP_Real getMaxForWhiteScore()
gets the maximum foreseeing white area score
void generateVisualization(char *filename, char *outname, GP_OUTPUT_FORMAT outputformat=GP_OUTPUT_FORMAT_PDF)
generates a visualization of the partialdec using gnuplot
@ COMPLETED_CONSTOMASTER
std::vector< std::vector< int > > & getConssForBlocks()
int getNVars()
Gets number of vars.