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 and library */
4/* GCG --- Generic Column Generation */
5/* a Dantzig-Wolfe decomposition based extension */
6/* of the branch-cut-and-price framework */
7/* SCIP --- Solving Constraint Integer Programs */
8/* */
9/* Copyright (C) 2010-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file class_partialdecomp.h
30 * @ingroup DECOMP
31 * @brief class storing (potentially incomplete) decompositions
32 * @note formerly called "Seeed"
33 * @author Michael Bastubbe
34 * @author Hannah Hechenrieder
35 * @author Hanna Franzen
36 * @author Erik Muehmer
37 */
38
39/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
40
41#ifndef GCG_CLASS_PARTIALDECOMP_H__
42#define GCG_CLASS_PARTIALDECOMP_H__
43
44#include "objscip/objscip.h"
45#include "gcg/struct_detector.h"
46
47#include <vector>
48#include <string>
49#include <functional>
50#include <unordered_map>
51
52
55#include "graph/graph_gcg.h"
56#include "graph/graph.h"
57#include "gcg/type_score.h"
58
59#include "gcg/reader_gp.h"
60
61namespace gcg {
62
63
64/**
65 * @brief enumeration to display if a decomposition was given by the user and if so, how it was processed after adding
66 */
68{
69 NOT = 0, /**< this partialdec was not given by the user */
70 PARTIAL = - 1, /**< this partial partialdec was given by the user as it is*/
71 COMPLETE = - 2, /**< this complete partialdec was given by the user as it is*/
72 COMPLETED_CONSTOMASTER = - 3 /**< this partialdec was partially given by the user and then completed by setting all missing constraints to the master*/
73};
74
75class DETPROBDATA;
76class PARTIALDECOMP;
77
78/**
79 * a lightweight struct that stores nested structure information of a block
80 */
82{
83 /** destructor */
85
86 /**
87 * Creates a partialdec using the stored structure information.
88 * The new partialdec is created using the constraint and variable names of a pricing problem created by GCG.
89 */
91 DETPROBDATA* parentdetprobdata, /**< parent detprobdata (the one that fits to the stored con/var ids) */
92 DETPROBDATA* newdetprobdata, /**< detprobdata used to create the new partialdec */
93 int probnr /**< the number of the pricing problem the partialdec is created for */
94 );
95
96 /** translates the structure using provided mappings */
98 std::vector<int>& rowmapping, /**< row mapping used to translate data */
99 std::vector<int>& colmapping, /**< column mapping used to translate data */
100 SCIP_Bool translatesymmetry /**< translate symmetry information? */
101 );
102
103 std::vector<int> masterconss; /**< vector containing the master constraints */
104 std::vector<std::vector<int>> blockconss; /**< vector of vectors (for each block) containing the block constraints */
105 std::vector<BLOCK_STRUCTURE*> blockstructures; /**< vector containing pointers to block structures for each block (if available) */
106 std::vector<int> symmetricalblocks; /**< vector containing for each block an id of a block that is symmetrical */
107 std::unordered_map<int, int> symmetryvardata; /**< symmetry information of variables (mapping) */
108};
109
110
111/*!
112 * @brief class to manage partial decompositions
113 * @ingroup DECOMP
114 *
115 * each partialdec corresponds to one detprobdata which contains the problem information,
116 * there is one detprobdata for the original and the transformed problem.
117 */
119{
120private:
121 GCG* gcg; /**< GCG data structure */
122 SCIP* scip; /**< SCIP data structure */
123 int id; /**< unique id of the partialdec, unique */
124 int nblocks; /**< number of blocks the partial decomposition currently has */
125 int nvars; /**< number of variables */
126 int nconss; /**< number of constraints */
127 std::vector<int> masterconss; /**< vector containing indices of master constraints */
128 std::vector<int> mastervars; /**< vector containing indices of master variables (these variables are supposed to have all nonzero entries in master constraints) */
129 std::vector<std::vector<int>> conssforblocks; /**< conssforblocks[k] contains a vector of indices of all
130 *< constraints assigned to block k */
131 std::vector<std::vector<int>> varsforblocks; /**< varsforblocks[k] contains a vector of indices of all
132 *< variables assigned to block k */
133 std::vector<int> linkingvars; /**< vector containing indices of linking variables */
134 std::vector<std::vector<int>> linkingvarsforblocks; /**< vector of vectors containing indices of linking variables for each block */
135 std::vector<std::vector<int>> stairlinkingvars; /**< vector containing indices of staircase linking variables
136 *< of the blocks (stair-linking variables are registered only
137 *< in their first block) */
138 std::vector<int> openvars; /**< vector containing indices of variables that are not
139 *< assigned yet*/
140 std::vector<int> openconss; /**< vector containing indices of constraints that are not
141 *< assigned yet*/
142 std::vector<bool> isvaropen; /**< whether ith variable is still open */
143 std::vector<bool> isconsopen; /**< whether ith constraint is still open */
144 std::vector<bool> isvarmaster; /**< whether ith variable is assigned to be a only-master variable */
145 std::vector<bool> isconsmaster; /**< whether ith constraint is assigned to be a master constraint */
146
147 std::vector<int> ncoeffsforblock; /**< number of coeffs per block */
148
149 int ncoeffsformaster; /**< number of master coefficients */
150 std::vector<std::vector<int>> ncoeffsforblockformastercons; /**< number of coeffs a block has in a certain master constraint */
151
152 bool varsforblocksorted; /**< bool to store if the varsforblocks datastructure is sorted atm */
153 bool stairlinkingvarsforblocksorted; /**< bool to store if the stairlinkingvarsforblock datastructure is sorted atm */
154 bool conssforblocksorted; /**< bool to store if the conssforblock datastructure is sorted atm */
155 bool linkingvarssorted; /**< bool to store if the linkingvars datastructure is sorted atm */
156 bool mastervarssorted; /**< bool to store if the mastervars datastructure is sorted atm */
157 bool masterconsssorted; /**< bool to store if the masterconsssorted datastructure is sorted atm */
158
159 unsigned long hashvalue; /**< hash value of this partial decomposition, decompositions with same has value are considered to be identical */
160 bool hvoutdated; /**< true if the internal structure changed such that the hash value needs to be recalculated */
161
162 bool isselected; /**< is this partialdec selected */
163
164 bool isagginfoalreadytoexpensive; /**< is agginfo already known to be to expensive to calculate*/
165
166 const static int primes[]; /**< an array of prime numbers to calculate the hash value */
167 const static int nprimes; /**< size of the array of prime numbers */
168
169 bool isfinishedbyfinisher; /**< was this partialdec finished by the finishpartialdec() method of a detector */
170
171 /* aggregation information */
172 int nequivalenceclasses; /**< number of equivalence classes */
173 std::vector<std::vector<int>> eqclasstoblocks; /**< translation of the equivalence classes to blocks (first block at index 0 is the representative block of the class) */
174 std::vector<int> blockstoeqclasses; /**< translation of the blocks to the equivalence classes */
175 std::vector<std::vector<std::vector<int>>> eqclassesvarmappings; /**< stores for each equivalence class (first index) and for each block of the class (second index) a mapping that maps the indices of the probvars (third index) of the block to the indices of the probvars (actual value) of the representative block */
176
177 /* statistic information */
178 std::vector<GCG_DETECTOR*> detectorchain; /**< vector containing detectors that worked on that partialdec */
179 std::vector<std::string> detectorchaininfo; /**< vector containing information about the detector call */
180 std::vector<SCIP_Real> detectorclocktimes; /**< vector containing detector times in seconds */
181 std::vector<SCIP_Real> pctvarstoborder; /**< vector containing the fraction of variables assigned to the
182 *< border for each detector working on that partialdec*/
183 std::vector<SCIP_Real> pctvarstoblock; /**< vector containing the fraction of variables assigned to a block
184 *< for each detector working on that partialdec*/
185 std::vector<SCIP_Real> pctvarsfromfree; /**< vector containing the fraction of variables that are not longer
186 *< open for each detector working on that partialdec*/
187 std::vector<SCIP_Real> pctconsstoborder; /**< vector containing the fraction of constraints assigned to the
188 *< border for each detector working on that partialdec*/
189 std::vector<SCIP_Real> pctconsstoblock; /**< vector containing the fraction of constraints assigned to a block
190 *< for each detector working on that partialdec*/
191 std::vector<SCIP_Real> pctconssfromfree; /**< vector containing the fraction of constraints that are not longer
192 *< open for each detector working on that partialdec*/
193 std::vector<int> nnewblocks; /**< vector containing information how many new blocks a detector has assigned */
194
195 std::vector<IndexPartition*> usedpartition; /**< vector containing pointer to the cons- or varpartitions
196 *< a detector made use of for each detector working on that partialdec
197 *< (NULL if no partition was used) */
198 std::vector<std::vector<int>> classestomaster; /**< vector containing the vector of classindices that were assigned
199 *< to master by the partition used by a detector
200 *< (empty vector if no partition was used) */
201 std::vector<std::vector<int>> classestolinking; /**< vector containing the vector of classindices that were assigned
202 *< to linking by the partition used by a detector
203 *< (empty vector if no partition was used) */
204
205 std::vector<int> listofancestorids; /**< vector containing decomposition indices that are ancestors of this partialdec */
206
207 USERGIVEN usergiven; /**< is this partialdec partially or completely given by user */
208
209 /* datastructure to store the score values of a score ( SCIP_INVALID iff score not computed yet) */
210 SCIP_HASHMAP* maptoscores; /**< maps score to its corresponding value*/
211
212 /* datastructure to store information if this partialdec stems from a partialdec concerning the orig problem */
213 bool stemsfromorig; /**< partialdec has at least one ancestor that is a partialdec from orig problem */
214 bool original; /**< indicates whether partialdec is from original problem */
215 bool isfinishedbyfinisherorig; /**< was the ancestor partialdec for the unpresolved problem finished by the
216 *< finishpartialdec() method of a detector */
217 GCG_DETECTOR* finishedorigby; /**< index of finishing detector of orig ancestor partialdec */
218
219 int translatedpartialdecid;
220 std::vector<BLOCK_STRUCTURE*> blockstructures; /**< structure information for each block (empty iff decomposition is not nested)*/
221
222private:
223 /**< id of the translated partialdec */
224
225 /**
226 *
227 * @brief simple bliss automorphism check for blocks
228 *
229 * Checks blocks for equality by graph automorphism check, done by bliss
230 * @note equality is only found if variables are in correct order
231 */
232 void checkIdenticalBlocksAutomorphism(
233 int b1, /**< block id of first block */
234 int b2, /**< block id of second block */
235 std::vector<int>& varmap, /**< maps variable indices (corresponding to detprobdata indices) of block 2 to block 1 */
236 SCIP_HASHMAP* varmap2, /**< maps variable pointers of block 2 to those of block 1 if both blocks (problems) are identical*/
237 SCIP_Bool* identical, /**< pointer to store if the subproblems are identical */
238 unsigned int searchnodelimit, /**< bliss search node limit (requires patched bliss version) */
239 unsigned int generatorlimit /**< bliss generator limit (requires patched bliss version) */
240 );
241
242
243 /**
244 * @brief brute force equality check for blocks
245 *
246 * Checks blocks for equality by brute force
247 * @note equality is only found if variables are in correct order
248 */
249 void checkIdenticalBlocksBrute(
250 int b1, /**< block id of first block */
251 int b2, /**< block id of second block */
252 std::vector<int>& varmap, /**< maps variable indices (corresponding to detprobdata indices) of prob2 to prob1 */
253 SCIP_HASHMAP* varmap2, /**< maps variable pointers of block 2 to those of block 1 if both blocks (problems) are identical*/
254 SCIP_Bool* identical /**< pointer to store if the subproblems are identical */
255 );
256
257
258 /**
259 * @brief plausibility check whether two blocks could be identical
260 *
261 * Check some necessary conditions for two blocks to be identical
262 */
263 void checkIdenticalBlocksTrivial(
264 int b1, /**< block id of first block */
265 int b2, /**< block id of second block */
266 SCIP_Bool* notidentical /**< pointer to store whether or not the non-equality is proven */
267 );
268
269public:
270
271 /**
272 * @brief Standard constructor, creates empty partialdec with unique id
273 * @note initially, all conss and vars are open
274 */
277 GCG* gcgstruct, /**< GCG data structure */
278 bool originalProblem /**< true iff partialdec is for presolved problem (else for original problem) */
279 );
280
281 /**
282 * @brief copy constructor
283 */
286 const PARTIALDECOMP *partialdecToCopy /**< partialdec to be copied */
287 );
288
289 /**
290 * Standard destructor
291 */
294
295 /**
296 * @brief adds a block
297 * @returns the number (id) of the new block
298 * */
300 int addBlock();
301
302 /**
303 * @brief adds detection time of one detector
304 *
305 * incorporates the needed time of some detector in the detector chain
306 */
308 void addClockTime(
309 SCIP_Real clocktime /**< time to be added */
310 );
311
312 /**
313 * @brief adds the statistical differences to an ancestor
314 *
315 * incorporates the changes from ancestor partialdec into the statistical data structures
316 */
319 PARTIALDECOMP* ancestor /**< partialdec whose propagation yielded to the current partialdec */
320 );
321
322 /**
323 * @brief add information about the detector chain
324 *
325 * adds a detectorchain information string to the corresponding vector
326 * (that carries information for each detector call)
327 * */
330 const char* decinfo /**< information string (about the detector call) to add */
331 );
332
333 /**
334 * @brief adds how many new blocks were introduced
335 *
336 * bookkeeping information: adds number of new blocks created by a detector added to detector chain
337 */
339 void addNNewBlocks(
340 int nnewblocks /**< number of new added blocks by latest detector call */
341 );
342
343 /**
344 * @brief adds percentage of closed constraints
345 *
346 * bookkeeping information: fraction of constraints that are not longer open for a detector added to detector chain
347 */
350 SCIP_Real pct /**< fraction of constraints that are not longer open */
351 );
352
353 /**
354 * @brief adds percentage of constraints assigned to blocks
355 *
356 * bookkeeping information: adds fraction of constraints assigned to a block for a detector added to detector chain
357 * */
360 SCIP_Real pct /**< fraction of constraints assigned to a block */
361 );
362
363 /**
364 * @brief adds percentage of constraints assigned to border
365 *
366 * bookkeeping information: adds fraction of constraints assigned to the border for a detector added to detector chain
367 */
370 SCIP_Real pct /**< fraction constraints assigned to the border */
371 );
372
373 /**
374 * @brief adds percentage of closed variables
375 *
376 * bookkeeping information: adds fraction of variables that are not longer open for a detector added to detector chain
377 */
380 SCIP_Real pct /**< fraction of variables that are not longer open */
381 );
382
383
384 /**
385 * @brief adds percentage of variables assigned to blocks
386 *
387 * bookkeeping information: adds fraction of variables assigned to a block for a detector added to detector chain
388 * */
391 SCIP_Real pct /**< fraction of variables assigned to a block */
392 );
393
394 /**
395 * @brief adds percentage of variables assigned to border
396 *
397 * bookkeeping information: adds fraction of variables assigned to the border for a detector added to detector chain
398 */
401 SCIP_Real pct /**< fraction of variables assigned to the border */
402 );
403
404 /**
405 * @brief method to check if at least one constraint is assigned to some block
406 * @returns true iff at least one constraint is assigned to a block
407 * */
410
411 /**
412 * @brief assigns open conss to master
413 *
414 * assigns open constraints to master according to the cons assignment information given in constoblock hashmap
415 * @returns scip return code
416 * @note for conss assigned to blocks according to constoblock there is no assignment \see assignPartialdecFromConstoblock
417 * @note master assignment is indicated by assigning cons to index additionalNBlocks
418 * */
421 SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices */
422 int givenNBlocks /**< number of blocks the hashmap contains */
423 );
424
425 /**
426 * @brief assigns open vars to stairlinking if appropriate
427 *
428 * assigns open vars to stairlinking if they can be found in exactly two consecutive blocks
429 * @returns true iff at least one stairlinkingvar was assigned
430 */
433
434 /**
435 * @brief assigns open conss to master
436 */
439
440 /**
441 * @brief assigns conss structure according to given hashmap
442 *
443 * adds blocks and assigns open conss to a new block or to master
444 * according to the cons assignment information given in constoblock hashmap
445 * @returns scip return code
446 * \see assignPartialdecFromConstoblockVector()
447 * @note master assignment is indicated by assigning cons to index additionalNBlocks
448 * */
451 SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices */
452 int additionalNBlocks /**< number of (additional) blocks the hashmap contains */
453 );
454
455 /*!
456 * @brief assigns conss structure according to given vector
457 *
458 * adds blocks and assigns open conss to a new block or to master
459 * according to the cons assignment information given in constoblock vector
460 * @returns scip return code
461 * \see assignPartialdecFromConstoblock()
462 * @note master is indicated by assigning cons to index additionalNBlocks */
465 std::vector<int> constoblock, /**< vector containing an assignment of conss to a block or to master */
466 int additionalNBlocks /**< number of (additional) blocks the vector contains */
467 );
468
469 /**
470 * @brief computes components by connectedness of conss and vars
471 *
472 * computes components corresponding to connectedness of conss and vars
473 * and assigns them accordingly (all but one of largest components)
474 *
475 * strategy: assigns all conss same block if they are connected
476 * two constraints are adjacent if there is a common variable
477 *
478 * @note this relies on the consadjacency structure of the detprobdata
479 * hence it cannot be applied in presence of linking variables
480 */
483
484 /**
485 * @brief reorders blocks for making a maximum number of linking vars stairlinking
486 *
487 * reorders blocks for making a maximum number of linking vars stairlinking
488 * if all vars that connect exactly two blocks have a staircase structure, all of them become stairlinkingvars
489 * otherwise, the stairlinking assignment is done greedily
490 * call PARTIALDEC::findVarsLinkingToStairlinking afterwards (this is also done by PARTIALDEC::prepare())
491 * @note precondition: partialdec does not have any stairlinking vars
492 */
495
496 /**
497 * @brief checks if all conss are assigned
498 *
499 * returns true iff all constraints are assigned and deletes the vector open conss if so
500 * @return true iff all constraints are assigned
501 * */
504
505 /**
506 * @brief Checks whether the assignments in the partialdec are consistent
507 *
508 * The following checks are performed:
509 * - check if nblocks is set appropriately
510 * - check for empty (row- and col-wise) blocks
511 * - every variable is assigned at most once
512 * - check if all not assigned variables are open vars
513 * - check if all open vars are not assigned
514 * - every constraint is assigned at most once
515 * - check if all not assigned constraints are open cons
516 * - check if all open conss are not assigned
517 * - check if the data structures are sorted
518 * - check if variables hitting a cons are either in the cons's block or border or still open
519 * @returns true iff the partialdec seems to be consistent
520 * */
522 bool checkConsistency();
523
524 /**
525 * @brief assigns all open constraints and open variables trivially
526 *
527 * strategy: assigns all open conss and vars to blocks if they can be refined there, otherwise to the master
528 *
529 * @note partialdecomps should usually be completed by a detector, only use this function if you know what you are doing.
530 */
532 void complete();
533
534 /**
535 * @brief assigns all open constraints and open variables
536 *
537 * strategy: assigns all conss and vars to the same block if they are connected,
538 * a cons and a var are adjacent if the var appears in the cons
539 */
541 void completeByConnected();
542
543 /**
544 * @brief assigns all open constraints and open variables
545 *
546 * strategy: assigns all conss and vars to the same block if they are connected
547 * a cons and a var are adjacent if the var appears in the cons
548 * \note this relies on the consadjacency structure of the detprobdata
549 * hence it cannot be applied in presence of linking variables
550 */
553
554 /**
555 * @brief assigns all open constraints and open variables
556 *
557 * strategy: assigns a cons (and related vars) to a new block if possible,
558 * if not to an existing block if possible (by means of prior var assignments)
559 * and finally to master, if there does not exist such a block
560 */
562 void completeGreedily();
563
564 /** @brief removes the given cons from master
565 */
567 void removeMastercons(
568 int consid /**< id of cons */
569 );
570
571 /**
572 * @brief: assigns every open cons/var
573 *
574 * Assignments happen as follows:
575 * - to the respective block if it hits exactly one blockvar/blockcons and no open vars/conss
576 * - to master/linking if it hits blockvars/blockconss assigned to different blocks
577 * - and every cons to master that hits a master var
578 * - and every var to master if it does not hit any blockcons and has no open cons
579 * - leave the cons/variableopen if nothing from the above holds
580 * */
582 void considerImplicits();
583
584 /**
585 * @brief copies the given partialdec's partition statistics
586 *
587 * @param otherpartialdec partialdec whose partition statistics are to be copied
588 */
591 const PARTIALDECOMP* otherpartialdec
592 );
593
594 /**
595 * @brief deletes empty blocks and sets nblocks accordingly
596 *
597 * A block is considered to be empty if no constraint is assigned to it,
598 * variables in blocks with no constraints become open
599 *
600 * @param variables if true, then blocks with no constraints but at least one variable are considered to be nonempty
601 */
604 bool variables
605 );
606
607 /**
608 * @brief deletes a cons from list of open conss
609 *
610 * @param opencons id of the cons that is not considered open anymore
611 */
613 void deleteOpencons(
614 int opencons
615 );
616
617 /**
618 * @brief deletes a cons from list of open conss
619 *
620 * @param itr valid iterator pointing to elements of PARTIALDECOMP::openconss
621 */
623 std::vector<int>::const_iterator deleteOpencons(
624 std::vector<int>::const_iterator itr
625 );
626
627 /**
628 * @brief deletes a var from the list of open vars
629 *
630 * @param openvar id of the var that is not considered open anymore
631 */
633 void deleteOpenvar(
634 int openvar
635 );
636
637 /**
638 * @brief deletes a var from the list of open vars
639 *
640 * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars
641 */
643 std::vector<int>::const_iterator deleteOpenvar(
644 std::vector<int>::const_iterator itr
645 );
646
647 /**
648 * @brief displays the relevant information of the partialdec
649 *
650 * @param detailLevel pass a value that indicates how detailed the output should be:
651 * 0: brief overview
652 * 1: block and detector info
653 * 2: cons and var assignments
654 */
656 void displayInfo(
657 int detailLevel
658 );
659
660 /**
661 * @brief every constraint is either assigned to master or open
662 *
663 * Assignment happens according to the cons assignment information given in constoblock hashmap,
664 * variables are set accordingly
665 * @note precondition: no constraint or variable is already assigned to a block
666 * @return scip return code
667 */
670 SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices
671 *< (master assignment is indicated by assigning cons to index additionalNBlocks) */
672 int givenNBlocks /**< number of blocks the hashmap contains */
673 );
674
675 /**
676 * @brief assigns all conss to master or a block
677 *
678 * Assignment happens according to the cons assignment information given in constoblock hashmap
679 *
680 * @return scip return code
681 * calculates implicit variable assignment through cons assignment
682 * @note precondition: no cons or var is already assigned to a block and constoblock contains information for every cons */
685 SCIP_HASHMAP* constoblock, /**< hashmap assigning cons indices (not SCIP_Cons*) to block indices
686 *< (master assignment is indicated by assigning cons to index additionalNBlocks) */
687 int givenNBlocks /**< number of blocks the hashmap contains */
688 );
689
690 /**
691 * @brief reassigns linking variables to master if appropriate
692 *
693 * Variables are reassigned as master if the variable only hits master conss
694 */
697
698 /**
699 * @brief reassigns variables classified as linking to stairlinking if appropriate
700 *
701 * Variables are reassigned as master if the variable hits conss in exactly two consecutive
702 * blocks
703 */
706
707 /**
708 * @brief gets partialdec id of given ancestor id
709 * @return partialdec id of given ancestor id
710 */
712 int getAncestorID(
713 int ancestorindex /**< index of ancestor in list of ancestor ids data structure */
714 );
715
716 /**
717 * @brief get ancestor ids as vector
718 * @return vector of ids of all ancestors id
719 */
721 std::vector<int>& getAncestorList();
722
723 /**
724 * set ancestor list directly
725 * @param newlist new list of ancestor ids
726 */
728 void setAncestorList(
729 std::vector<int>& newlist
730 );
731
732 /** removes ancestor id from list */
734 void removeAncestorID(
735 int ancestorid /**< id to remove */
736 );
737
738 /**
739 * adds ancestor id to back of list
740 * @param ancestor id of ancestor that is to be added
741 */
743 void addAncestorID(
744 int ancestor
745 );
746
747 /**
748 * @brief get a vector of block ids that are contained in the equivalence class eqclass
749 * @param eqclass id of the equivalence class
750 * @return vector of block ids
751 */
753 const std::vector<int>& getBlocksForEqClass(
754 int eqclass
755 );
756
757 /**
758 * @brief get the representative block of the given equivalence class
759 * @param eqclass id of the equivalence class
760 * @return id of the representative block
761 */
764 int eqclass
765 );
766
767 /**
768 * @brief returns the time that the detector related to the given detectorchainindex needed for detecting
769 * @return the clock time for the corresponding detector in the chain
770 */
773 int detectorchainindex /**< index of the detector in the detectorchain */
774 );
775
776 /**
777 * @brief returns a vector of the clock times that each detector needed that was involved in this partialdec
778 * @return vector of the clock times
779 */
781 std::vector<SCIP_Real>& getDetectorClockTimes();
782
783 /**
784 * @brief returns array containing constraints assigned to a block
785 * @param block id of the block the constraint indices are returned
786 * @return array containing constraints assigned to a block
787 */
789 std::vector<int>& getConssForBlock(
790 int block
791 );
792
793 /**
794 * @brief returns detector chain as vector of detector pointers
795 * @return detector chain as array of detector pointers
796 */
798 std::vector<GCG_DETECTOR*>& getDetectorchain();
799
800 /**
801 * @brief returns true iff this partialdec was finished by finishPartialdec() method of a detector
802 * @return true iff this partialdec was finished by finishPartialdec() method of a detector
803 */
806
807 /**
808 * @brief returns the calculated hash value of this partialdec
809 * @return the calculated hash value of this partialdec
810 */
812 unsigned long getHashValue();
813
814 /**
815 * @brief returns the unique id of the partialdec
816 * @return the unique id of the partialdec
817 */
819 int getID();
820
821 /**
822 * @brief returns array containing all linking vars indices
823 * @return vector containing all linking vars indices
824 * @note when accessed it is supposed to be sorted
825 */
827 std::vector<int>& getLinkingvars();
828
829 /**
830 * @brief returns vector of all linking var indices contained by the block
831 * @return vector of var indices
832 * @note when accessed the vector is supposed to be sorted
833 */
835 std::vector<int>& getLinkingvarsForBlock(
836 int block
837 );
838
839 /**
840 * @brief Gets array containing all master conss indices
841 * @return array containing all master conss indices
842 * @note when accessed it is supposed to be sorted
843 */
845 std::vector<int>& getMasterconss();
846
847 /**
848 * @brief Gets array containing all master vars indices
849 *
850 * master vars hit only constraints in the master, aka static variables
851 * @return array containing all master vars indices
852 */
854 std::vector<int>& getMastervars();
855
856 /**
857 * @brief Gets the number of nonzero coeffs in a certain block
858 * @param blockid of the block the number of nozerors are requested for
859 * @return number of nonzero coeffs in a certain block
860 */
863 int blockid
864 );
865
866 /**
867 * Gets the number of nonzero coeffs in master
868 * @return the number of nonzero coeffs in master
869 */
872
873 /**
874 * @brief returns the score of the partialdec
875 * @param score the score
876 * @return the score
877 */
880 GCG_SCORE* score
881 );
882
883 /**
884 * @brief returns the score of the partialdec (depending on enabled score)
885 * @return the score
886 */
889
890 /**
891 * @brief gets an intermediate score value for the blocks of a partialdec
892 *
893 * Used by several score calculations,
894 * computed as (1 - fraction of block area to complete area)
895 *
896 * @returns intermediate score value
897 */
899
900 /**
901 * @brief sets the scorevalue of score
902 * @param score the score
903 * @param scorevalue value of the score
904 */
905 void setScore(
906 GCG_SCORE* score,
907 SCIP_Real scorevalue
908 );
909
910 /**
911 * @brief checks if all master constraints set partitioning, set packing, set cover, or cardinality constraints
912 * @return TRUE iff all master constraints set partitioning, set packing, set cover, or cardinality constraints
913 */
916
917
918 /**
919 * @brief checks iff all master constraints set partitioning, set packing, or set cover constraints
920 * @return TRUE iff all master constraints set partitioning, set packing, or set cover
921 */
924
925 /**
926 * @brief checks iff all master constraints set partitioning, or set packing constraints
927 * @return TRUE iff all master constraints set partitioning, or set packing constraints
928 */
931
932 /**
933 * @brief Gets the USERGIVEN status of this partialdecs
934 * @return the USERGIVEN status of this partialdecs
935 * @see enum USERGIVEN
936 */
939
940 /**
941 * @brief Gets number of ancestor partialdecs
942 * @return number of ancestor partialdecs
943 */
945 int getNAncestors();
946
947 /**
948 * @brief Gets the number of blocks
949 * @return number of blocks
950 */
952 int getNBlocks();
953
954 /**
955 * @brief Gets the number of constraints
956 * @return number of constraints
957 */
959 int getNConss();
960
961 /**
962 * @brief Gets size of the vector containing conss assigned to a block
963 * @param block id of the block the number of constraints is asked for
964 * @return size of the vector containing conss assigned to a block
965 */
968 int block
969 );
970
971 /**
972 * @brief Gets the detectorchain info vector
973 * @return detectorchain info vector
974 */
976 std::vector<std::string>& getDetectorchainInfo();
977
978 /**
979 * @brief Gets the number of detectors the partialdec is propagated by
980 * @return number of detectors the partialdec is propagated by
981 */
983 int getNDetectors();
984
985 /**
986 * @brief Returns the structure information of a specific block
987 */
989 int block /**< block id */
990 );
991
992 /**
993 * @brief Returns the structure information of all blocks
994 */
995 std::vector<BLOCK_STRUCTURE*>& getBlockStructures();
996
997 /**
998 * @brief Gets size of the vector containing linking vars
999 * @return size of the vector containing linking vars
1000 */
1002 int getNLinkingvars();
1003
1004 /**
1005 * @brief Gets size of the vector containing master conss
1006 * @returns size of the vector containing master conss
1007 */
1009 int getNMasterconss();
1010
1011 /**
1012 * @brief Gets size of the vector containing master vars
1013 *
1014 * master vars hit only constraints in the master
1015 * @return size of the vector containing master vars
1016 */
1018 int getNMastervars();
1019
1020 /**
1021 * @brief Gets number of blocks a detector added
1022 *
1023 * @return number of blocks a detector added
1024 */
1026 int getNNewBlocks(
1027 int detectorchainindex /**< index of the detector in the detectorchain */
1028 );
1029
1030 /**
1031 * @brief gets number of blocks the detectors in the detectorchain added
1032 * @return number of blocks the detectors in the detectorchain added
1033 */
1035 std::vector<int> getNNewBlocksVector();
1036
1037 /**
1038 * @brief Gets total number of stairlinking vars
1039 * @return total number of stairlinking vars
1040 */
1043
1044 /**
1045 * @brief Gets size of vector containing constraints not assigned yet
1046 * @return returns size of vector containing constraints not assigned yet
1047 */
1049 int getNOpenconss();
1050
1051 /**
1052 * @brief Gets size of vector containing variables not assigned yet
1053 * @return size of vector containing variables not assigned yet
1054 */
1056 int getNOpenvars();
1057
1058 /**
1059 * @brief Gets the number of blockrepresentatives
1060 * @return the number of blockrepresentatives
1061 */
1064
1065 /**
1066 * @brief Gets size of the vector containing stairlinking vars
1067 * @param block id of the block the size of the stairlinking vector is asked for
1068 * @return size of the vector containing stairlinking vars
1069 */
1072 int block
1073 );
1074
1075 /**
1076 * @brief Gets number of vars
1077 * @return number of vars
1078 */
1080 int getNVars();
1081
1082 /**
1083 * @brief Gets size of the vector containing vars assigned to a block
1084 * @param block id of the block the number of variables is asked for
1085 * @return size of the vector containing vars assigned to a block
1086 */
1088 int getNVarsForBlock(
1089 int block
1090 );
1091
1092 /**
1093 * @brief Gets overall number of vars assigned to a block
1094 * @return number of vars that are assigned to any block
1095 */
1097 int getNVarsForBlocks();
1098
1099 /**
1100 * @brief Gets vector containing constraints not assigned yet
1101 * @return vector containing constraints not assigned yet
1102 */
1104 std::vector<int>& getOpenconss();
1105
1106 /**
1107 * @brief Gets vector containing variables not assigned yet
1108 * @return returns vector containing variables not assigned yet
1109 */
1111 std::vector<int>& getOpenvars();
1112
1113 /**
1114 * @brief Gets fraction of variables assigned to the border for a detector
1115 *
1116 * @return fraction of variables assigned to the border for a detector
1117 */
1120 int detectorchainindex /**< index of the detector in the detectorchain */
1121 );
1122
1123 /**
1124 * @brief Gets fraction of variables assigned to the border for detectors in detectorchain
1125 * @return vector of fractions of variables assigned to the border for detectors in detectorchain
1126 */
1128 std::vector<SCIP_Real>& getPctVarsToBorderVector();
1129
1130 /**
1131 * @brief Gets fraction of variables assigned to a block for a detector
1132 *
1133 * @return fraction of variables assigned to a block for a detector
1134 */
1137 int detectorchainindex /**< index of the detector in the detectorchain */
1138 );
1139
1140 /**
1141 * @brief returns fraction of variables assigned to a block for detectors in detectorchain
1142 * @return vector of fractions of variables assigned to a block for detectors in detectorchain
1143 */
1145 std::vector<SCIP_Real>& getPctVarsToBlockVector();
1146
1147 /**
1148 * @brief Gets fraction of variables that are not longer open for a detector
1149 *
1150 * @return index of the detector in the detectorchain
1151 */
1154 int detectorchainindex /**< index of the detector in the detectorchain */
1155 );
1156
1157 /**
1158 * @brief Gets fraction of variables that are not longer open for detectors in detectorchain
1159 * @return vector or fractions of variables that are not longer open for detectors in detectorchain
1160 */
1162 std::vector<SCIP_Real>& getPctVarsFromFreeVector();
1163
1164 /**
1165 * @brief Gets fraction of constraints assigned to the border for a detector
1166 * @return returns fraction of constraints assigned to the border for a detector
1167 */
1170 int detectorchainindex /**< index of the detector in the detectorchain */
1171 );
1172
1173 /**
1174 * @brief Gets fraction of constraints assigned to the border for detectors in detectorchain
1175 * @return vector of fractions of constraints assigned to the border for detectors in detectorchain
1176 */
1178 std::vector<SCIP_Real>& getPctConssToBorderVector();
1179
1180 /**
1181 * @brief Gets fraction of constraints assigned to a block for a detector
1182 * @return fraction of constraints assigned to a block for a detector
1183 */
1186 int detectorchainindex /**< index of the detector in the detectorchain */
1187 );
1188
1189 /**
1190 * @brief Gets fraction of constraints assigned to a block for detectors in detectorchain
1191 * @return vector of fractions of constraints assigned to a block for detectors in detectorchain
1192 */
1194 std::vector<SCIP_Real>& getPctConssToBlockVector();
1195
1196 /**
1197 * @brief Gets fraction of constraints that are not longer open for a detector
1198 * @return fraction of constraints that are not longer open for a detector
1199 */
1202 int detectorchainindex /**< index of the detector in the detectorchain */
1203 );
1204
1205 /**
1206 * @brief Gets fraction of constraints that are not longer open for detectors in detectorchain
1207 * @return vector of fractions of constraints that are not longer open for detectors in detectorchain
1208 */
1210 std::vector<SCIP_Real>& getPctConssFromFreeVector();
1211
1212 /**
1213 * @brief Gets index of the representative block for a block, this might be blockid itself
1214 * @param blockid id of the block the representative is asked for
1215 * @return index of the representative block for a block, this might be blockid itself
1216 */
1219 int blockid
1220 );
1221
1222 /**
1223 * @brief Returns a vector that maps probvar indices of a block contained in an equivalence class to the probvar indices of the representative block of the class
1224 *
1225 * @param eqclass id of the equivalence class
1226 * @param eqclassblock index of block (with respect to eqclass)
1227 * @return probvar indices mapping
1228 */
1230 std::vector<int> & getRepVarmap(
1231 int eqclass,
1232 int eqclassblock
1233 );
1234
1235 /**
1236 * @brief Gets the corresponding detprobdata
1237 * @return corresponding detprobdata
1238 */
1241
1242 /**
1243 * @brief Gets vector containing stairlinking vars,
1244 * @note if a stairlinking variable links block i and i+1 it is only stored in vector of block i
1245 * @param block id of the block the stairlinking variable varctor is asked for
1246 * @return vector containing stairlinking vars,
1247 */
1249 std::vector<int>& getStairlinkingvars(
1250 int block
1251 );
1252
1253 /**
1254 * @brief Gets array containing vars of a block
1255 * @param block id of the block the vars are requested for
1256 * @return returns array containing vars of a block
1257 */
1259 std::vector<int>& getVarsForBlock(
1260 int block
1261 );
1262
1263 /**
1264 * @brief Gets the index of a variable in the vector returned by PARTIALDECOMP::getVarsForBlock.
1265 * @param varid the id of the variable
1266 * @param block the corresponding block id
1267 * @return the index of the variable or -1 if var is not in block
1268 */
1271 int varid,
1272 int block
1273 );
1274
1275 /**
1276 * @brief Gets whether this partialdec is complete,
1277 * i.e. it has no more open constraints and variables
1278 * @return TRUE iff this partialdec is complete
1279 */
1281 bool isComplete();
1282
1283 /**
1284 * @brief Gets whether the cons is a master cons
1285 * @param cons id of ccons to check if it is master constraint
1286 * @return true iff the cons is a master cons
1287 */
1289 bool isConsMastercons(
1290 int cons
1291 );
1292
1293 /**
1294 * @brief Gets whether the cons is an open cons
1295 * @param cons id of cons to check
1296 * @return true iff the cons is an open cons
1297 */
1299 bool isConsOpencons(
1300 int cons
1301 );
1302
1303 /**
1304 * @brief Gets whether the partialdec is from the original problem
1305 * @return true iff the partialdec is from the original problem
1306 */
1308 bool isAssignedToOrigProb();
1309
1310 /**
1311 * @brief Gets whether the partialdec is from the presolved problem
1312 * @return true iff the partialdec is from the presolved problem
1313 */
1316
1317 /**
1318 * Gets whether the partialdec is currently selected in explore menue
1319 * @return true iff the partialdec is currently selected in explore menue
1320 */
1322 bool isSelected();
1323
1324 /**
1325 * @brief method to check whether this partialdec is equal to a given other partialdec ( \see isEqual(PARTIALDECOMP*))
1326 *
1327 * @return scip return code
1328 */
1331 PARTIALDECOMP* otherpartialdec, /**< other partialdec */
1332 SCIP_Bool* isequal, /**< pointer to store whether partialdecs are identical */
1333 bool sortpartialdecs /**< should conss and vars be sorted before comparing the partialdecs? */
1334 );
1335
1336 /**
1337 * @brief method to check whether this partialdec is equal to a given other partialdec
1338 *
1339 * @return true iff partialdecs are equal
1340 */
1342 bool isEqual(
1343 PARTIALDECOMP* other /**< other partialdec to check equality with */
1344 );
1345
1346 /**
1347 * @brief Checks whether this is a nested decomposition
1348 * @returns true iff the decomposition is nested
1349 */
1350 bool isNested();
1351
1352 /**
1353 * @brief Gets whether this partialdec was propagated by specified detector
1354 * @param detector pointer to detector to check for
1355 * @return true iff this partialdec was propagated by detectorID
1356 */
1358 bool isPropagatedBy(
1359 GCG_DETECTOR* detector
1360 );
1361
1362 /**
1363 * @brief Gets whether this partialdec is considered to be trivial
1364 *
1365 * PARTIALDECOMP is considered trivial if all conss are in one block, all conss are in border,
1366 * all variables linking or mastervars, or all constraints and variables are open
1367 * @return true iff this partialdec is considered to be trivial
1368 */
1370 bool isTrivial();
1371
1372 /**
1373 * @brief Checks whether the var is assigned to the block
1374 * @param var id of var to check
1375 * @param block id of block to check
1376 * @return true iff the var is assigned to the block
1377 */
1380 int var,
1381 int block
1382 );
1383
1384 /**
1385 * @brief Checks whether the var is a linking var
1386 * @param var id of var to check
1387 * @return true iff the var is a linking var
1388 */
1390 bool isVarLinkingvar(
1391 int var
1392 );
1393
1394 /**
1395 * @brief Checks whether the var is a linking var contained by the block
1396 * @param var id of var to check
1397 * @param block id of block to check
1398 * @return true iff the var is a linking var
1399 */
1402 int var,
1403 int block
1404 );
1405
1406 /**
1407 * @brief Checks whether the var is a master var
1408 * @param var id of var to check
1409 * @return true iff the var is a master var
1410 */
1412 bool isVarMastervar(
1413 int var
1414 );
1415
1416 /**
1417 * @brief Checks whether the var is an open var
1418 * @param var id of var to check
1419 * @return true iff the var is an open var
1420 */
1422 bool isVarOpenvar(
1423 int var
1424 );
1425
1426 /**
1427 * @brief Checks whether the var is a stairlinking var
1428 * @param var id of var to check
1429 * @return true iff the var is a stairlinking var
1430 */
1433 int var
1434 );
1435
1436 /**
1437 * @brief Checks whether the var is a stairlinkingvar of a specified block
1438 * @param var id of var to check if it is a stairlinking variable hitting specified block
1439 * @param block id of block to check
1440 * @return true iff the var is a stairlinkingvar of a specified block
1441 */
1444 int var,
1445 int block
1446 );
1447
1448 /**
1449 * @brief prints partition information as described in \see cls reader
1450 * @param file output file
1451 */
1454 FILE* file
1455 );
1456
1457 /**
1458 * @brief refine partialdec with focus on blocks
1459 *
1460 * strategy: assigns open conss and vars if they can be found in blocks
1461 * (without respect to open vars and conss @see assignHittingOpenconss(), @see assignHittingOpenvars())
1462 * @note partialdec might be not complete
1463 */
1465 void refineToBlocks();
1466
1467 /**
1468 * @brief refine partialdec with focus on master
1469 *
1470 * strategy: do obvious ( @see considerImplicits()) assignments and
1471 * assign other conss and vars to master if possible (@see assignOpenPartialHittingToMaster())
1472 */
1474 void refineToMaster();
1475
1476 /**
1477 * @brief registers statistics for a used conspartition
1478 */
1481 int detectorchainindex, /**< index of the detector in the detectorchain */
1482 ConsPartition* partition, /**< the used conspartition */
1483 std::vector<int>& consclassesmaster /**< vector of classindices that were assigned to master */
1484 );
1485
1486 /**
1487 * @brief adds a constraint to a block, does not delete this cons from list of open conss
1488 * @param consToBlock id of cons to add
1489 * @param block id of block to add
1490 */
1492 void setConsToBlock(
1493 int consToBlock,
1494 int block
1495 );
1496
1497 /**
1498 * @brief adds a constraint to a block
1499 * @param cons id of cons to add
1500 * @param block id of block to add
1501 */
1503 void fixConsToBlock(
1504 int cons,
1505 int block
1506 );
1507
1508 /**
1509 * @brief adds a constraint to a block
1510 * @param cons pointer of cons to add
1511 * @param block id of block to add
1512 * @returns true iff successful
1513 */
1515 bool fixConsToBlock(
1516 SCIP_CONS* cons,
1517 int block
1518 );
1519
1520 /**
1521 * @brief adds a constraint to the master constraints, does not delete this cons from list of open conss
1522 * @param consToMaster id of cons to add
1523 */
1525 void setConsToMaster(
1526 int consToMaster
1527 );
1528
1529 /**
1530 * @brief fixes a constraint to the master constraints
1531 * @param itr valid iterator pointing to elements of PARTIALDECOMP::openconss
1532 * @return iterator that points to the next element of PARTIALDECOMP::openconss
1533 * @warning This method modifies the vector PARTIALDECOMP::openconss! Hence, any kind of iterator might be invalid afterwards!
1534 */
1536 std::vector<int>::const_iterator fixConsToMaster(
1537 std::vector<int>::const_iterator itr
1538 );
1539
1540 /**
1541 * @brief fixes a constraint to the master constraints
1542 * @param cons id of cons to add
1543 * @warning This method modifies the vector PARTIALDECOMP::openconss! Hence, any kind of iterator might be invalid afterwards!
1544 */
1546 void fixConsToMaster(
1547 int cons
1548 );
1549
1550 /**
1551 * @brief fixes a constraint to the master constraints
1552 * @param cons pointer of cons to add
1553 * @warning This method modifies the vector PARTIALDECOMP::openconss! Hence, any kind of iterator might be invalid afterwards!
1554 * @returns true iff successful
1555 */
1557 bool fixConsToMaster(
1558 SCIP_CONS* cons
1559 );
1560
1561 /**
1562 * @brief sets the detectorchain with the given vector of detector pointers
1563 * @param givenDetectorChain vector of detector pointers
1564 */
1566 void setDetectorchain(
1567 std::vector<GCG_DETECTOR*>& givenDetectorChain
1568 );
1569
1570 /**
1571 * @brief sets partialdec to be propagated by a detector
1572 * @param detector pointer to detector that is registered for this partialdec
1573 */
1576 GCG_DETECTOR* detector
1577 );
1578
1579 /**
1580 * @brief sets detector that finished the partialdec
1581 * @param detector pointer to detector that has finished this partialdecs
1582 */
1585 GCG_DETECTOR* detector
1586 );
1587
1588 /**
1589 * @brief sets detector that finished the partialdec in the original problem
1590 * @note does not add the detector to the detectorchain and does not modify partition statistics
1591 */
1594 );
1595
1596 /**
1597 * @brief sets whether this partialdec was finished by a finishing detector
1598 * @param finished is this partialdecs finished by a finishing detector
1599 */
1602 bool finished
1603 );
1604
1605 /**
1606 * @brief sets whether this partialdec was finished by a finishing detector in the original problem
1607 *
1608 * (in case this partialdec was translated)
1609 * @param finished was this partialdecs finished by a finishing detector in orig
1610 */
1613 bool finished
1614 );
1615
1616 /**
1617 * @brief sets number of blocks, only increasing number allowed
1618 * @param nblocks new number of blocks
1619 */
1621 void setNBlocks(
1622 int nblocks
1623 );
1624
1625 /**
1626 * @brief sets structure information of a specific block
1627 */
1628 void setBlockStructure(
1629 int block, /**< block id */
1630 BLOCK_STRUCTURE* blockstructure /**< structure information */
1631 );
1632
1633 /**
1634 * @brief set the selection status of this partialdecs
1635 * @param selected whether the partialdec is selected
1636 */
1638 void setSelected(
1639 bool selected
1640 );
1641
1642 /**
1643 * @brief sets whether this partialdec stems from an orig problem partialdec
1644 * @param fromorig has this partialdec ancestors from the orig problem
1645 */
1647 void setStemsFromOrig(
1648 bool fromorig
1649 );
1650
1651 /**
1652 * @brief sets whether this partialdec is user given
1653 * @param usergiven is this partialdec user given
1654 */
1656 void setUsergiven(
1657 USERGIVEN usergiven
1658 );
1659
1660 /**
1661 * @brief registers statistics for a used varpartition
1662 */
1665 int detectorchainindex, /**< index of the detector in the detectorchain */
1666 VarPartition* partition, /**< the used varpartition */
1667 std::vector<int>& varclasseslinking, /**< vector of classindices that were assigned to linking */
1668 std::vector<int>& varclassesmaster /**< vector of classindices that were assigned to master */
1669 );
1670
1671 /**
1672 * @brief adds a variable to the linking variables, does not delete this var from list of open vars
1673 * @param varToBlock id of var to be added
1674 * @param block id of block to be added
1675 */
1677 void setVarToBlock(
1678 int varToBlock,
1679 int block
1680 );
1681
1682 /**
1683 * @brief adds a variable to the linking variables
1684 * @param var id of var to be added
1685 * @param block id of block to be added
1686 */
1688 void fixVarToBlock(
1689 int var,
1690 int block
1691 );
1692
1693 /**
1694 * @brief adds a variable to the linking variables
1695 * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars
1696 * @param block id of block to be added
1697 * @return iterator that points to the next element of PARTIALDECOMP::openvars
1698 * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards!
1699 */
1701 std::vector<int>::const_iterator fixVarToBlock(
1702 std::vector<int>::const_iterator itr,
1703 int block
1704 );
1705
1706 /**
1707 * @brief adds a variable to the linking variables, does not delete this var from list of open vars
1708 * @param varToLinking var to be set to linking
1709 */
1711 void setVarToLinking(
1712 int varToLinking
1713 );
1714
1715 /**
1716 * @brief adds a variable to the linking variables
1717 * @param var var to be set to linking
1718 */
1720 void fixVarToLinking(
1721 int var
1722 );
1723
1724 /**
1725 * @brief adds a variable to the linking variables
1726 * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars
1727 * @return iterator that points to the next element of PARTIALDECOMP::openvars
1728 * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards!
1729 */
1731 std::vector<int>::const_iterator fixVarToLinking(
1732 std::vector<int>::const_iterator itr
1733 );
1734
1735 /** @brief adds a variable to the master variables, does not delete this var from list of open vars
1736 *
1737 * master variables hit only constraints in the master
1738 */
1740 void setVarToMaster(
1741 int varToMaster /**< var to be set to master */
1742 );
1743
1744 /** @brief adds a variable to the master variables
1745 *
1746 * master variables hit only constraints in the master
1747 */
1749 void fixVarToMaster(
1750 int var /**< var to be set to master */
1751 );
1752
1753 /** @brief adds a variable to the master variables
1754 *
1755 * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars
1756 * @return iterator that points to the next element of PARTIALDECOMP::openvars
1757 * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards!
1758 */
1760 std::vector<int>::const_iterator fixVarToMaster(
1761 std::vector<int>::const_iterator itr /**< var to be set to master */
1762 );
1763
1764 /**
1765 * @brief adds a variable to the stairlinking variables, does not delete this var from list of open vars
1766 * @param varToStairLinking id of variable to be added
1767 * @param block1 id of block one
1768 * @param block2 id of block two
1769 * @note stairlinking variables are only registered in block with smaller index
1770 */
1773 int varToStairLinking,
1774 int block1,
1775 int block2
1776 );
1777
1778 /**
1779 * @brief adds a variable to the stairlinking variables
1780 * @param var id of variable to be added
1781 * @param firstblock stairlinking variables hit exactly two consecutive blocks, this is the index of the first of these blocks
1782 * @note stairlinking variables are only registered in block with smaller index
1783 */
1786 int var,
1787 int firstblock
1788 );
1789
1790 /**
1791 * @brief adds a variable to the stairlinking variables
1792 * @param itr valid iterator pointing to elements of PARTIALDECOMP::openvars
1793 * @param firstblock stairlinking variables hit exactly two consecutive blocks, this is the index of the first of these blocks
1794 * @return iterator that points to the next element of PARTIALDECOMP::openvars
1795 * @warning This method modifies the vector PARTIALDECOMP::openvars! Hence, any kind of iterator might be invalid afterwards!
1796 * @note stairlinking variables are only registered in block with smaller index
1797 */
1799 std::vector<int>::const_iterator fixVarToStairlinking(
1800 std::vector<int>::const_iterator itr,
1801 int firstblock
1802 );
1803
1804 /**
1805 * @brief assigns a constraint by name to a block
1806 * @see fixConsToBlock
1807 * @returns true iff successful
1808 */
1811 const char* consname, /**< name of the constraint */
1812 int blockid /**< block index (counting from 0) */
1813 );
1814
1815 /**
1816 * @brief assigns a variable by name to a block
1817 * @see fixVarToBlock
1818 * @returns true iff successful
1819 */
1822 const char* varname, /**< name of the variable */
1823 int blockid /**< block index (counting from 0) */
1824 );
1825
1826 /**
1827 * @brief assgins a constraint by name as master
1828 * @see fixConsToMaster
1829 * @returns true iff successful
1830 */
1833 const char* consname /**< name of cons to fix as master cons */
1834 );
1835
1836 /**
1837 * @brief assigns a variable with given name as master
1838 * @see fixVarToMaster
1839 * @returns true iff successful
1840 */
1843 const char* varname /**< name of the variable */
1844 );
1845
1846 /**
1847 * @brief assigns a variable by name to the linking variables
1848 * @see fixVarToLinking
1849 * @returns true iff successful
1850 */
1853 const char* varname /**< name of the variable */
1854 );
1855
1856 /**
1857 * @brief generates and opens a gp visualization of the partialdec
1858 * @see visual/pdfreader and
1859 * @note linux only
1860 */
1862 void showVisualization();
1863
1864 /**
1865 * @brief generates a visualization of the partialdec using gnuplot
1866 * @param filename Path where to store the gp file
1867 * @param outname Path at which gnuplot will output its result
1868 * @param outputformat The format of the gnuplot output. Should match the file extension of outname
1869 * @note linux only, requires gnuplot
1870 */
1873 char* filename,
1874 char* outname,
1876 );
1877
1878 /**
1879 * @brief writes a gp visualization of the partialdec to a file
1880 * @param filename Path where to store the gp file
1881 * @param outname Path at which gnuplot will output its result
1882 * @param outputformat The format of the gnuplot output. Should match the file extension of outname
1883 */
1886 char* filename,
1887 char* outname,
1889 );
1890
1891 /**
1892 * @brief generates a gp visualization of the partialdec without compilation or opening
1893 */
1895 void exportVisualization();
1896
1897 /**
1898 * @brief Checks whether this partialdec is a userpartialdec that should be completed
1899 *
1900 * the completion should be done by setting unspecified constraints to master
1901 * @return TRUE iff this partialdec is a userpartialdec that should be completed
1902 */
1905
1906 /**
1907 * @brief sorts the vars and conss data structures by their indices
1908 * @returns true if the internal order of variables or constraints changed
1909 */
1911 bool sort();
1912
1913 /**
1914 * @brief set statistical vector of fractions of constraints set to blocks per involved detector
1915 * @param newvector vector of fractions of constraints set to blocks per involved detector
1916 */
1919 std::vector<SCIP_Real>& newvector
1920 );
1921
1922 /**
1923 * @brief set statistical vector of fractions of constraints that are not longer open per involved detector
1924 * @param newvector vector of fractions of constraints that are not longer open per involved detector
1925 */
1928 std::vector<SCIP_Real>& newvector
1929 );
1930
1931 /**
1932 * @brief set statistical vector of fractions of constraints assigned to the border per involved detector
1933 * @param newvector vector of fractions of constraints assigned to the border per involved detector
1934 */
1937 std::vector<SCIP_Real>& newvector
1938 );
1939
1940 /**
1941 * @brief set statistical vector of fraction of variables assigned to the border per involved detector
1942 * @param newvector vector of fractions of variables assigned to the border per involved detector
1943 */
1946 std::vector<SCIP_Real>& newvector
1947 );
1948
1949 /**
1950 * @brief set statistical vector of fractions of variables assigned to a block per involved detector
1951 * @param newvector vector of fractions of variables assigned to a block per involved detector
1952 */
1955 std::vector<SCIP_Real>& newvector
1956 );
1957
1958 /**
1959 * @brief set statistical vector of variables that are not longer open per involved detector
1960 * @param newvector vector of fractions of variables that are not longer open per involved detector
1961 */
1964 std::vector<SCIP_Real>& newvector
1965 );
1966
1967 /**
1968 * @brief set statistical vector of the times that the detectors needed for detecting per involved detector
1969 * @param newvector vector of the times that the detectors needed for detecting per involved detector
1970 */
1973 std::vector<SCIP_Real>& newvector
1974 );
1975
1976 /** @brief gets the maximum white area score
1977 *
1978 * "maximum white score" is fraction of the area of the decomposed matrix that is neither block or border
1979 * @note -1 iff not calculated yet, \see GCGconshdlrDecompCalcMaxWhiteScore
1980 * @returns maximum white area score
1981 */
1984
1985 /** sorts the partialdec and calculates a its implicit assignments, hashvalue and evaluation
1986 *
1987 */
1989 void prepare();
1990
1991 /**
1992 * @brief Checks if the aggregation information was already calculated
1993 * @return true iff the aggregation information was already calculated
1994 */
1996 bool aggInfoCalculated();
1997
1998 /**
1999 * @brief computes if aggregation of sub problems is possible
2000 *
2001 * checks if aggregation of sub problems is possible and stores the corresponding aggregation information
2002 *
2003 * @param ignoreDetectionLimits Set to true if computation should ignore detection limits. This parameter is ignored if the patched bliss version is not present.
2004 */
2007 bool ignoreDetectionLimits
2008 );
2009
2010 /** @brief gets vector of indices of all constraints assigned to blocks
2011 *
2012 * @note conssforblocks[k] contains a vector of indices of all constraints assigned to block k
2013 * @returns vector of a vector of indices for each block
2014 */
2016 std::vector<std::vector<int>>& getConssForBlocks();
2017
2019 int getTranslatedpartialdecid() const;
2020
2023 int decid
2024 );
2025
2026 /**
2027 * @brief creates a detector chain short string for this partialdec, is built from detector chain
2028 */
2031 char* buffer /**< will contain string of detector chars in chronological order afterwards*/
2032 );
2033
2034 /**
2035 * @brief returns the number of block vars contained in a master constraint
2036 */
2038 int masterconsindex, /**< index of master constraint */
2039 int block /**< block id */
2040 );
2041
2042 /**
2043 * @brief creates a detector chain short string for this partialdec, is built from detector chain
2044 */
2046 std::string buildDecChainString();
2047
2048 /**
2049 * @brief sets symmetry information
2050 *
2051 * Each block b must be mapped to its representative block rb with rb <= b. Furthermore, rb must be mapped to itself.
2052 * It is assumed that a variable assigned to a representative block is mapped to itself (varmapping does not have
2053 * to cover this case).
2054 *
2055 * @param blockmapping function that maps block ids to the ids of the representative blocks
2056 * @param varmapping function that maps tuples (block, variable index (in the block)) to the indices of the representative variables (in their blocks)
2057 *
2058 * @returns true iff symmetry information was stored successfully
2059 */
2062 std::function<int(int)> blockmapping,
2063 std::function<int(int, int)> varmapping
2064 );
2065
2066private:
2067
2068 /**
2069 * @brief adds empty entries for all partition statistics for a detector added to the detector chain
2070 */
2071 void addEmptyPartitionStatistics();
2072
2073 /** @brief assigns open cons
2074 *
2075 * Assignments as follows:
2076 * - to master if it hits blockvars of different blocks
2077 * - to the respective block if it hits a blockvar of exactly one block and no stairlinking var
2078 * - to master if it hits a stairlinking var but there is no block the cons may be assigned to
2079 * - to the block with the lowest number of conss if it hits a stairlinking var and there are blocks the cons may be
2080 * assigned to
2081 * - leave it open if it hits no blocks yet
2082 * @return true iff some assignment was made by the method
2083 */
2084 bool assignHittingOpenconss();
2085
2086 /** @brief assigns every open var
2087 *
2088 * Assignments as follows:
2089 * - to the respective block if it hits blockconss of exactly one block
2090 * - to linking if it hits blockconss of more than one different blocks
2091 * - leave the var open otherwise
2092 * @return true iff there is a var that has been assigned in this call*/
2093 bool assignHittingOpenvars();
2094
2095 /**
2096 * @brief assigns every open cons to master that hits
2097 *
2098 * Assignments as follows:
2099 * - exactly one block var and at least one open var or
2100 * - a master var
2101 * - or leave it open elsewise
2102 */
2103 void assignOpenPartialHittingConsToMaster();
2104
2105 /**
2106 * @brief assigns open conss/vars that hit exactly one block and at least one open var/cons to border
2107 */
2108 void assignOpenPartialHittingToMaster();
2109
2110 /**
2111 * @brief assigns every open var to linking that hits
2112 *
2113 * Assignments as follows:
2114 * - exactly one block cons and at least one open cons
2115 * - leave it open otherwise
2116 */
2117 void assignOpenPartialHittingVarsToMaster();
2118
2119 /**
2120 * @brief calculates the number of nonzero coefficients for the blocks
2121 */
2122 void calcNCoeffsForBlocks();
2123
2124 /**
2125 * @brief calculates the hash value of the partialdec for comparing
2126 */
2127 void calcHashvalue();
2128
2129 /**
2130 * @brief blockwise calculation of how many master conss contain the block vars
2131 *
2132 * counts for each pair of block and master constraint, how many nonzero entries the variables of the blocks
2133 * have in the master constraint
2134 */
2135 void calcNCoeffsForBlockForMastercons();
2136
2137 /**
2138 * @brief optimizes block order to max stairlinking vars
2139 *
2140 * changes the block order in a way such that all linking vars that are potentially stairlinking
2141 * may be reassigned to stairlinking
2142 * @note precondition: all potentially stairlinking vars have a staircase structure */
2143 void changeBlockOrderStaircase(
2144 GraphGCG* g /**< graph with blocks as nodes and weighted edges for the number of
2145 potentially stairlinkingvars connecting two blocks */
2146 );
2147
2148 /**
2149 * @brief changes the order of the blocks according to the given mapping
2150 *
2151 * \note precondition: given mapping needs to be an adequately sized permutation */
2152 void changeBlockOrder(
2153 std::vector<int> oldToNewBlockIndex /**< the mapping from old to new block indices */
2154 );
2155
2156 /**
2157 * @brief returns true if the given detector used a conspartition
2158 * @return true iff the given detector used a conspartition
2159 */
2160 bool consPartitionUsed(
2161 int detectorchainindex /**< index of the detector in the detectorchain */
2162 );
2163
2164 /**
2165 * @brief prints out the current aggregation information
2166 *
2167 * aggregation information: if there has been identified identical blocks
2168 */
2169 void displayAggregationInformation();
2170
2171 /**
2172 * @brief calculates the linking vars for the blocks
2173 */
2174 void findLinkingvarBlocks();
2175
2176 /**
2177 * @brief calculates potential stairlinking variables with their blocks
2178 *
2179 * @return a vector of pairs of var index and vector of (two) block indices
2180 * the related linking variable hits exactly these two blocks given in the related vector
2181 */
2182 std::vector< std::pair< int, std::vector< int > > > findLinkingVarsPotentiallyStairlinking();
2183
2184 /**
2185 * @brief returns the data of the conspartition that the given detector made use of
2186 */
2187 void getConsPartitionData(
2188 int detectorchainindex, /**< index of the detector in the detectorchain */
2189 ConsPartition** partition, /**< a pointer to the used conspartition (set by method)*/
2190 std::vector<int>& consclassesmaster /**< a vector containing all indices of the consclasses assigned to master
2191 * (set by method) */
2192 );
2193
2194 /**
2195 * @brief returns a string displaying all detector-related clock times and assignment data
2196 *
2197 * @return string displaying all detector-related clock times and assignment data
2198 */
2199 std::string getDetectorStatistics(
2200 int detectorchainindex /**< index of the detector in the detectorchain */
2201 );
2202
2203 /**
2204 * @brief returns a string displaying partition information if a partition was used
2205 *
2206 * @return string displaying partition information if a partition was used
2207 */
2208 std::string getDetectorPartitionInfo(
2209 int detectorchainindex, /**< index of the detector in the detectorchain */
2210 bool displayConssVars /**< pass true if constraints and variables of the respective classes should be displayed */
2211 );
2212
2213 /**
2214 * @brief Gets the number used partitions
2215 * @return number used partitions
2216 */
2217 int getNUsedPartitions();
2218
2219 /**
2220 * @brief Gets the data of the varpartition that the given detector made use of
2221 * @return data of the varpartition that the given detector made use of
2222 */
2223 void getVarPartitionData(
2224 int detectorchainindex, /**< index of the detector in the detectorchain */
2225 VarPartition** partition, /**< a pointer to the used varpartition (set by method) */
2226 std::vector<int>& varclasseslinking, /**< a vector containing all indices of the varclasses assigned to linking (set by method) */
2227 std::vector<int>& varclassesmaster /**< a vector containing all indices of the varclasses assigned to master (set by method)*/
2228 );
2229
2230 /**
2231 * @brief checks if calculation of aggregation information is considered to be too expensive
2232 * @return TRUE iff calculation of aggregation information is considered to be too expensive
2233 */
2234 SCIP_Bool isAgginfoTooExpensive();
2235
2236 /**
2237 * @brief Gets whether the cons is a cons of the block
2238 * @param cons id of constraint to check
2239 * @param block id of the blocks
2240 * @return true iff the cons is a cons of the block
2241 */
2242 /** */
2243 bool isConsBlockconsOfBlock(
2244 int cons,
2245 int block
2246 );
2247
2248 /**
2249 * @brief returns true if the given detector used a varpartition
2250 *
2251 * @return true if the given detector used a varpartition
2252 */
2253 bool varPartitionUsed(
2254 int detectorchainindex /**< index of the detector in the detectorchain */
2255 );
2256};
2257
2258
2259} /* namespace gcg */
2260#endif /* GCG_CLASS_PARTIALDECOMP_H__ */
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)
class representing a partition of a set of constraints
class representing a partition of a set of variables
class to manage partial decompositions
GCG_EXPORT std::vector< SCIP_Real > & getPctVarsToBorderVector()
Gets fraction of variables assigned to the border for detectors in detectorchain.
GCG_EXPORT SCIP_Real getDetectorClockTime(int detectorchainindex)
returns the time that the detector related to the given detectorchainindex needed for detecting
GCG_EXPORT int getNConss()
Gets the number of constraints.
GCG_EXPORT int getNMasterconss()
Gets size of the vector containing master conss.
GCG_EXPORT bool fixVarToMasterByName(const char *varname)
assigns a variable with given name as master
GCG_EXPORT SCIP_Bool shouldCompletedByConsToMaster()
Checks whether this partialdec is a userpartialdec that should be completed.
GCG_EXPORT SCIP_Bool hasSetppcMaster()
checks iff all master constraints set partitioning, set packing, or set cover constraints
GCG_EXPORT bool isVarStairlinkingvarOfBlock(int var, int block)
Checks whether the var is a stairlinkingvar of a specified block.
GCG_EXPORT bool fixConsToMasterByName(const char *consname)
assgins a constraint by name as master
GCG_EXPORT std::vector< GCG_DETECTOR * > & getDetectorchain()
returns detector chain as vector of detector pointers
GCG_EXPORT void fixVarToStairlinking(int var, int firstblock)
adds a variable to the stairlinking variables
GCG_EXPORT int getNEquivalenceClasses()
Gets the number of blockrepresentatives.
GCG_EXPORT void assignSmallestComponentsButOneConssAdjacency()
computes components by connectedness of conss and vars
GCG_EXPORT bool isConsMastercons(int cons)
Gets whether the cons is a master cons.
GCG_EXPORT SCIP_RETCODE filloutBorderFromConstoblock(SCIP_HASHMAP *constoblock, int givenNBlocks)
every constraint is either assigned to master or open
GCG_EXPORT std::vector< int > & getStairlinkingvars(int block)
Gets vector containing stairlinking vars,.
GCG_EXPORT void setVarToBlock(int varToBlock, int block)
adds a variable to the linking variables, does not delete this var from list of open vars
GCG_EXPORT void prepare()
GCG_EXPORT void setAncestorList(std::vector< int > &newlist)
GCG_EXPORT void completeByConnectedConssAdjacency()
assigns all open constraints and open variables
GCG_EXPORT void setTranslatedpartialdecid(int decid)
GCG_EXPORT void setPctVarsToBlockVector(std::vector< SCIP_Real > &newvector)
set statistical vector of fractions of variables assigned to a block per involved detector
GCG_EXPORT void refineToMaster()
refine partialdec with focus on master
GCG_EXPORT int getAncestorID(int ancestorindex)
gets partialdec id of given ancestor id
GCG_EXPORT 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
GCG_EXPORT SCIP_Real getPctConssToBorder(int detectorchainindex)
Gets fraction of constraints assigned to the border for a detector.
GCG_EXPORT void setVarToLinking(int varToLinking)
adds a variable to the linking variables, does not delete this var from list of open vars
GCG_EXPORT bool checkConsistency()
Checks whether the assignments in the partialdec are consistent.
GCG_EXPORT void setSelected(bool selected)
set the selection status of this partialdecs
GCG_EXPORT void setPctVarsToBorderVector(std::vector< SCIP_Real > &newvector)
set statistical vector of fraction of variables assigned to the border per involved detector
GCG_EXPORT void addAncestorID(int ancestor)
GCG_EXPORT SCIP_Real getPctVarsToBorder(int detectorchainindex)
Gets fraction of variables assigned to the border for a detector.
GCG_EXPORT int getNStairlinkingvars(int block)
Gets size of the vector containing stairlinking vars.
GCG_EXPORT void exportVisualization()
generates a gp visualization of the partialdec without compilation or opening
GCG_EXPORT bool fixConsToBlockByName(const char *consname, int blockid)
assigns a constraint by name to a block
GCG_EXPORT std::vector< SCIP_Real > & getPctConssToBlockVector()
Gets fraction of constraints assigned to a block for detectors in detectorchain.
GCG_EXPORT USERGIVEN getUsergiven()
Gets the USERGIVEN status of this partialdecs.
GCG_EXPORT void setNBlocks(int nblocks)
sets number of blocks, only increasing number allowed
GCG_EXPORT std::vector< SCIP_Real > & getDetectorClockTimes()
returns a vector of the clock times that each detector needed that was involved in this partialdec
GCG_EXPORT bool isAssignedToPresolvedProb()
Gets whether the partialdec is from the presolved problem.
GCG_EXPORT bool fixVarToLinkingByName(const char *varname)
assigns a variable by name to the linking variables
std::vector< BLOCK_STRUCTURE * > & getBlockStructures()
Returns the structure information of all blocks.
GCG_EXPORT void fixConsToBlock(int cons, int block)
adds a constraint to a block
GCG_EXPORT int getNOpenvars()
Gets size of vector containing variables not assigned yet.
GCG_EXPORT void displayInfo(int detailLevel)
displays the relevant information of the partialdec
GCG_EXPORT bool isVarLinkingvar(int var)
Checks whether the var is a linking var.
GCG_EXPORT int getNCoeffsForBlock(int blockid)
Gets the number of nonzero coeffs in a certain block.
GCG_EXPORT bool fixVarToBlockByName(const char *varname, int blockid)
assigns a variable by name to a block
GCG_EXPORT void removeAncestorID(int ancestorid)
GCG_EXPORT int getVarProbindexForBlock(int varid, int block)
Gets the index of a variable in the vector returned by PARTIALDECOMP::getVarsForBlock.
GCG_EXPORT bool setSymmetryInformation(std::function< int(int)> blockmapping, std::function< int(int, int)> varmapping)
sets symmetry information
GCG_EXPORT unsigned long getHashValue()
returns the calculated hash value of this partialdec
GCG_EXPORT std::vector< int > & getMasterconss()
Gets array containing all master conss indices.
GCG_EXPORT PARTIALDECOMP(GCG *gcgstruct, bool originalProblem)
Standard constructor, creates empty partialdec with unique id.
GCG_EXPORT bool checkAllConssAssigned()
checks if all conss are assigned
GCG_EXPORT void addPctVarsToBorder(SCIP_Real pct)
adds percentage of variables assigned to border
GCG_EXPORT int getNDetectors()
Gets the number of detectors the partialdec is propagated by.
GCG_EXPORT void completeGreedily()
assigns all open constraints and open variables
GCG_EXPORT std::string buildDecChainString()
creates a detector chain short string for this partialdec, is built from detector chain
GCG_EXPORT bool alreadyAssignedConssToBlocks()
method to check if at least one constraint is assigned to some block
GCG_EXPORT std::vector< int > & getConssForBlock(int block)
returns array containing constraints assigned to a block
GCG_EXPORT const std::vector< int > & getBlocksForEqClass(int eqclass)
get a vector of block ids that are contained in the equivalence class eqclass
GCG_EXPORT void setVarToMaster(int varToMaster)
adds a variable to the master variables, does not delete this var from list of open vars
GCG_EXPORT void addDetectorChainInfo(const char *decinfo)
add information about the detector chain
GCG_EXPORT void removeMastercons(int consid)
removes the given cons from master
void setBlockStructure(int block, BLOCK_STRUCTURE *blockstructure)
sets structure information of a specific block
GCG_EXPORT DETPROBDATA * getDetprobdata()
Gets the corresponding detprobdata.
GCG_EXPORT bool isComplete()
Gets whether this partialdec is complete, i.e. it has no more open constraints and variables.
GCG_EXPORT void setFinishedByFinisher(bool finished)
sets whether this partialdec was finished by a finishing detector
GCG_EXPORT void setPctConssFromFreeVector(std::vector< SCIP_Real > &newvector)
set statistical vector of fractions of constraints that are not longer open per involved detector
GCG_EXPORT void addPctVarsFromFree(SCIP_Real pct)
adds percentage of closed variables
int getNVarsOfBlockInMasterCons(int masterconsindex, int block)
returns the number of block vars contained in a master constraint
GCG_EXPORT SCIP_Real getPctVarsToBlock(int detectorchainindex)
Gets fraction of variables assigned to a block for a detector.
GCG_EXPORT bool isVarMastervar(int var)
Checks whether the var is a master var.
GCG_EXPORT int getNOpenconss()
Gets size of vector containing constraints not assigned yet.
GCG_EXPORT void calcAggregationInformation(bool ignoreDetectionLimits)
computes if aggregation of sub problems is possible
bool isNested()
Checks whether this is a nested decomposition.
GCG_EXPORT int getNVarsForBlock(int block)
Gets size of the vector containing vars assigned to a block.
GCG_EXPORT bool isVarOpenvar(int var)
Checks whether the var is an open var.
GCG_EXPORT void setDetectorFinished(GCG_DETECTOR *detector)
sets detector that finished the partialdec
GCG_EXPORT void fixVarToLinking(int var)
adds a variable to the linking variables
GCG_EXPORT bool aggInfoCalculated()
Checks if the aggregation information was already calculated.
GCG_EXPORT std::vector< int > & getLinkingvars()
returns array containing all linking vars indices
SCIP_Real calcBlockAreaScore()
gets an intermediate score value for the blocks of a partialdec
GCG_EXPORT void fixVarToMaster(int var)
adds a variable to the master variables
GCG_EXPORT void addPctConssToBorder(SCIP_Real pct)
adds percentage of constraints assigned to border
GCG_EXPORT void assignOpenConssToMaster()
assigns open conss to master
GCG_EXPORT int getEqClassForBlock(int blockid)
Gets index of the representative block for a block, this might be blockid itself.
GCG_EXPORT SCIP_Bool hasSetppccardMaster()
checks if all master constraints set partitioning, set packing, set cover, or cardinality constraints
GCG_EXPORT bool isAssignedToOrigProb()
Gets whether the partialdec is from the original problem.
GCG_EXPORT int getNVars()
Gets number of vars.
GCG_EXPORT void setDetectorPropagated(GCG_DETECTOR *detector)
sets partialdec to be propagated by a detector
GCG_EXPORT SCIP_Real getScore()
returns the score of the partialdec (depending on enabled score)
GCG_EXPORT void addPctConssToBlock(SCIP_Real pct)
adds percentage of constraints assigned to blocks
GCG_EXPORT void completeByConnected()
assigns all open constraints and open variables
GCG_EXPORT SCIP_RETCODE isEqual(PARTIALDECOMP *otherpartialdec, SCIP_Bool *isequal, bool sortpartialdecs)
method to check whether this partialdec is equal to a given other partialdec (
GCG_EXPORT std::vector< int > & getMastervars()
Gets array containing all master vars indices.
GCG_EXPORT void setStemsFromOrig(bool fromorig)
sets whether this partialdec stems from an orig problem partialdec
GCG_EXPORT void setUsergiven(USERGIVEN usergiven)
sets whether this partialdec is user given
GCG_EXPORT std::vector< SCIP_Real > & getPctConssToBorderVector()
Gets fraction of constraints assigned to the border for detectors in detectorchain.
GCG_EXPORT SCIP_RETCODE assignPartialdecFromConstoblock(SCIP_HASHMAP *constoblock, int additionalNBlocks)
assigns conss structure according to given hashmap
GCG_EXPORT void setDetectorFinishedOrig()
sets detector that finished the partialdec in the original problem
GCG_EXPORT SCIP_Real getPctConssToBlock(int detectorchainindex)
Gets fraction of constraints assigned to a block for a detector.
GCG_EXPORT int getNLinkingvars()
Gets size of the vector containing linking vars.
GCG_EXPORT std::vector< SCIP_Real > & getPctVarsFromFreeVector()
Gets fraction of variables that are not longer open for detectors in detectorchain.
GCG_EXPORT void deleteEmptyBlocks(bool variables)
deletes empty blocks and sets nblocks accordingly
GCG_EXPORT void refineToBlocks()
refine partialdec with focus on blocks
GCG_EXPORT SCIP_Real getMaxWhiteScore()
gets the maximum white area score
GCG_EXPORT SCIP_Real getPctVarsFromFree(int detectorchainindex)
Gets fraction of variables that are not longer open for a detector.
GCG_EXPORT bool isSelected()
GCG_EXPORT void setVarPartitionStatistics(int detectorchainindex, VarPartition *partition, std::vector< int > &varclasseslinking, std::vector< int > &varclassesmaster)
registers statistics for a used varpartition
GCG_EXPORT void setConsToBlock(int consToBlock, int block)
adds a constraint to a block, does not delete this cons from list of open conss
GCG_EXPORT std::vector< int > & getRepVarmap(int eqclass, int eqclassblock)
Returns a vector that maps probvar indices of a block contained in an equivalence class to the probva...
GCG_EXPORT int addBlock()
adds a block
GCG_EXPORT void setDetectorClockTimes(std::vector< SCIP_Real > &newvector)
set statistical vector of the times that the detectors needed for detecting per involved detector
void setScore(GCG_SCORE *score, SCIP_Real scorevalue)
sets the scorevalue of score
GCG_EXPORT void deleteOpencons(int opencons)
deletes a cons from list of open conss
GCG_EXPORT SCIP_RETCODE assignPartialdecFromConstoblockVector(std::vector< int > constoblock, int additionalNBlocks)
assigns conss structure according to given vector
GCG_EXPORT SCIP_RETCODE filloutPartialdecFromConstoblock(SCIP_HASHMAP *constoblock, int givenNBlocks)
assigns all conss to master or a block
GCG_EXPORT void generateVisualization(char *filename, char *outname, GP_OUTPUT_FORMAT outputformat=GP_OUTPUT_FORMAT_PDF)
generates a visualization of the partialdec using gnuplot
GCG_EXPORT void setDetectorchain(std::vector< GCG_DETECTOR * > &givenDetectorChain)
sets the detectorchain with the given vector of detector pointers
GCG_EXPORT void addNNewBlocks(int nnewblocks)
adds how many new blocks were introduced
GCG_EXPORT void findVarsLinkingToMaster()
reassigns linking variables to master if appropriate
GCG_EXPORT bool isVarLinkingvarOfBlock(int var, int block)
Checks whether the var is a linking var contained by the block.
GCG_EXPORT int getNAncestors()
Gets number of ancestor partialdecs.
GCG_EXPORT SCIP_RETCODE assignBorderFromConstoblock(SCIP_HASHMAP *constoblock, int givenNBlocks)
assigns open conss to master
GCG_EXPORT std::vector< SCIP_Real > & getPctConssFromFreeVector()
Gets fraction of constraints that are not longer open for detectors in detectorchain.
GCG_EXPORT bool getFinishedByFinisher()
returns true iff this partialdec was finished by finishPartialdec() method of a detector
GCG_EXPORT int getReprBlockForEqClass(int eqclass)
get the representative block of the given equivalence class
GCG_EXPORT void considerImplicits()
: assigns every open cons/var
GCG_EXPORT int getNNewBlocks(int detectorchainindex)
Gets number of blocks a detector added.
GCG_EXPORT std::vector< std::vector< int > > & getConssForBlocks()
gets vector of indices of all constraints assigned to blocks
GCG_EXPORT int getNCoeffsForMaster()
GCG_EXPORT int getNTotalStairlinkingvars()
Gets total number of stairlinking vars.
GCG_EXPORT int getNMastervars()
Gets size of the vector containing master vars.
GCG_EXPORT int getNConssForBlock(int block)
Gets size of the vector containing conss assigned to a block.
GCG_EXPORT void showVisualization()
generates and opens a gp visualization of the partialdec
GCG_EXPORT void addDecChangesFromAncestor(PARTIALDECOMP *ancestor)
adds the statistical differences to an ancestor
GCG_EXPORT void addPctConssFromFree(SCIP_Real pct)
adds percentage of closed constraints
GCG_EXPORT void setConsPartitionStatistics(int detectorchainindex, ConsPartition *partition, std::vector< int > &consclassesmaster)
registers statistics for a used conspartition
GCG_EXPORT void setFinishedByFinisherOrig(bool finished)
sets whether this partialdec was finished by a finishing detector in the original problem
GCG_EXPORT bool isVarBlockvarOfBlock(int var, int block)
Checks whether the var is assigned to the block.
GCG_EXPORT int getID()
returns the unique id of the partialdec
GCG_EXPORT void addClockTime(SCIP_Real clocktime)
adds detection time of one detector
GCG_EXPORT int getTranslatedpartialdecid() const
GCG_EXPORT SCIP_Real getPctConssFromFree(int detectorchainindex)
Gets fraction of constraints that are not longer open for a detector.
GCG_EXPORT void setPctVarsFromFreeVector(std::vector< SCIP_Real > &newvector)
set statistical vector of variables that are not longer open per involved detector
GCG_EXPORT SCIP_Bool hasSetppMaster()
checks iff all master constraints set partitioning, or set packing constraints
GCG_EXPORT std::vector< int > & getOpenconss()
Gets vector containing constraints not assigned yet.
GCG_EXPORT std::vector< std::string > & getDetectorchainInfo()
Gets the detectorchain info vector.
GCG_EXPORT void writeVisualizationFile(char *filename, char *outname, GP_OUTPUT_FORMAT outputformat=GP_OUTPUT_FORMAT_PDF)
writes a gp visualization of the partialdec to a file
GCG_EXPORT void copyPartitionStatistics(const PARTIALDECOMP *otherpartialdec)
copies the given partialdec's partition statistics
GCG_EXPORT bool isConsOpencons(int cons)
Gets whether the cons is an open cons.
GCG_EXPORT void findVarsLinkingToStairlinking()
reassigns variables classified as linking to stairlinking if appropriate
GCG_EXPORT int getNVarsForBlocks()
Gets overall number of vars assigned to a block.
GCG_EXPORT void reorderBlocksForStairlinkingVars()
reorders blocks for making a maximum number of linking vars stairlinking
GCG_EXPORT void printPartitionInformation(FILE *file)
prints partition information as described in
GCG_EXPORT std::vector< SCIP_Real > & getPctVarsToBlockVector()
returns fraction of variables assigned to a block for detectors in detectorchain
GCG_EXPORT std::vector< int >::const_iterator fixConsToMaster(std::vector< int >::const_iterator itr)
fixes a constraint to the master constraints
GCG_EXPORT void deleteOpenvar(int openvar)
deletes a var from the list of open vars
GCG_EXPORT bool isTrivial()
Gets whether this partialdec is considered to be trivial.
GCG_EXPORT void setPctConssToBlockVector(std::vector< SCIP_Real > &newvector)
set statistical vector of fractions of constraints set to blocks per involved detector
GCG_EXPORT bool sort()
sorts the vars and conss data structures by their indices
GCG_EXPORT bool isVarStairlinkingvar(int var)
Checks whether the var is a stairlinking var.
BLOCK_STRUCTURE * getBlockStructure(int block)
Returns the structure information of a specific block.
GCG_EXPORT std::vector< int > getNNewBlocksVector()
gets number of blocks the detectors in the detectorchain added
GCG_EXPORT std::vector< int > & getOpenvars()
Gets vector containing variables not assigned yet.
GCG_EXPORT std::vector< int > & getVarsForBlock(int block)
Gets array containing vars of a block.
GCG_EXPORT void addPctVarsToBlock(SCIP_Real pct)
adds percentage of variables assigned to blocks
GCG_EXPORT void complete()
assigns all open constraints and open variables trivially
GCG_EXPORT bool isPropagatedBy(GCG_DETECTOR *detector)
Gets whether this partialdec was propagated by specified detector.
GCG_EXPORT void setPctConssToBorderVector(std::vector< SCIP_Real > &newvector)
set statistical vector of fractions of constraints assigned to the border per involved detector
GCG_EXPORT bool assignCurrentStairlinking()
assigns open vars to stairlinking if appropriate
GCG_EXPORT int getNBlocks()
Gets the number of blocks.
GCG_EXPORT void fixVarToBlock(int var, int block)
adds a variable to the linking variables
GCG_EXPORT void setConsToMaster(int consToMaster)
adds a constraint to the master constraints, does not delete this cons from list of open conss
GCG_EXPORT std::vector< int > & getAncestorList()
get ancestor ids as vector
GCG_EXPORT std::vector< int > & getLinkingvarsForBlock(int block)
returns vector of all linking var indices contained by the block
#define GCG_EXPORT
Definition: def.h:59
#define SCIP_Bool
#define SCIP_Real
miscellaneous graph methods for structure detection
Implementation of the graph which supports both node and edge weights.
USERGIVEN
enumeration to display if a decomposition was given by the user and if so, how it was processed after...
@ COMPLETED_CONSTOMASTER
GP file reader writing decompositions to gnuplot files.
@ GP_OUTPUT_FORMAT_PDF
Definition: reader_gp.h:54
enum GPOutputFormat GP_OUTPUT_FORMAT
Definition: reader_gp.h:58
Definition: struct_gcg.h:55
data structures for detectors
BLOCK_STRUCTURE * translateStructure(std::vector< int > &rowmapping, std::vector< int > &colmapping, SCIP_Bool translatesymmetry)
std::vector< std::vector< int > > blockconss
std::vector< int > masterconss
std::unordered_map< int, int > symmetryvardata
std::vector< int > symmetricalblocks
PARTIALDECOMP * createPartialdec(DETPROBDATA *parentdetprobdata, DETPROBDATA *newdetprobdata, int probnr)
std::vector< BLOCK_STRUCTURE * > blockstructures
enum SCIP_Retcode SCIP_RETCODE
type definitions for score