Scippy

GCG

Branch-and-Price & Column Generation for Everyone

class_detprobdata.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program */
4 /* GCG --- Generic Column Generation */
5 /* a Dantzig-Wolfe decomposition based extension */
6 /* of the branch-cut-and-price framework */
7 /* SCIP --- Solving Constraint Integer Programs */
8 /* */
9 /* Copyright (C) 2010-2021 Operations Research, RWTH Aachen University */
10 /* Zuse Institute Berlin (ZIB) */
11 /* */
12 /* This program is free software; you can redistribute it and/or */
13 /* modify it under the terms of the GNU Lesser General Public License */
14 /* as published by the Free Software Foundation; either version 3 */
15 /* of the License, or (at your option) any later version. */
16 /* */
17 /* This program is distributed in the hope that it will be useful, */
18 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
19 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
20 /* GNU Lesser General Public License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with this program; if not, write to the Free Software */
24 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/
25 /* */
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
28 /**@file class_detprobdata.h
29  * @ingroup DECOMP
30  * @brief class storing partialdecs and the problem matrix
31  * @note formerly called "Seeedpool"
32  * @author Michael Bastubbe
33  * @author Julius Hense
34  * @author Hanna Franzen
35  */
36 
37 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
38 
39 #ifndef GCG_CLASS_DETPROBDATA_H__
40 #define GCG_CLASS_DETPROBDATA_H__
41 
42 #include <vector>
43 
44 #if __cplusplus >= 201103L
45 #include <unordered_map>
46 using std::unordered_map;
47 #else
48 #include <tr1/unordered_map>
49 using std::tr1::unordered_map;
50 #endif
51 
52 #include <functional>
53 #include <string>
54 #include <utility>
55 #include "gcg.h"
56 
57 #include "class_partialdecomp.h"
58 #include "class_conspartition.h"
59 #include "class_varpartition.h"
60 
61 /** constraint type */
63 {
64  SCIP_CONSTYPE_EMPTY = 0, /**< */
65  SCIP_CONSTYPE_FREE = 1, /**< */
76  SCIP_CONSTYPE_KNAPSACK = 12, /**< */
79  SCIP_CONSTYPE_GENERAL = 15 /**< */
80 };
82 
83 
84 namespace gcg{
85 
86 /**
87  * @brief combine two hash function of objects of a pair to get a vaulue for the pair
88  */
89 struct pair_hash
90 {
91  template<class T1, class T2>
92  std::size_t operator()(
93  const std::pair<T1, T2> &p) const
94  {
95  auto h1 = std::hash<T1>{}( p.first );
96  auto h2 = std::hash<T2>{}( p.second );
97 
98  /* overly simple hash combination */
99  return h1 ^ h2;
100  }
101 };
102 
103 /**
104  * class to manage the detection process and data for one coefficient matrix of a MIP, usually there is one detprobdata for the original and one detprobdata for the presolved problem
105  */
107 { /*lint -esym(1712,DETPROBDATA)*/
108 
109 private:
110  SCIP* scip; /**< SCIP data structure */
111  std::vector<PARTIALDECOMP*> openpartialdecs; /**< vector of open partialdecs */
112  std::vector<PARTIALDECOMP*> finishedpartialdecs; /**< vector of finished partialdecs */
113  std::vector<PARTIALDECOMP*> ancestorpartialdecs; /**< old partialdecs that were previously used */
114 
115  std::vector<SCIP_CONS*> relevantconss; /**< stores all constraints that are not marked as deleted or obsolete */
116  std::vector<SCIP_VAR*> relevantvars; /**< stores all prob variables that are not fixed to 0 */
117  std::vector<std::vector<int>> varsforconss; /**< stores for every constraint the indices of variables
118  *< that are contained in the constraint */
119  std::vector<std::vector<double>> valsforconss; /**< stores for every constraint the coefficients of
120  *< variables that are contained in the constraint (i.e.
121  *< have a nonzero coefficient) */
122  std::vector<std::vector<int>> conssforvars; /**< stores for every variable the indices of constraints
123  *< containing this variable */
124 
125  std::vector<std::vector<int>> conssadjacencies;
126  unordered_map<SCIP_CONS*, int> constoindex; /**< maps SCIP_CONS* to the corresponding internal index */
127  unordered_map<SCIP_VAR*, int> vartoindex; /**< maps SCIP_VAR* to the corresponding internal index */
128 
129  unordered_map<std::pair<int, int>, SCIP_Real, pair_hash> valsMap; /**< maps an entry of the matrix to its
130  *< value, zeros are omitted */
131 
132  std::vector<SCIP_VAR*> origfixedtozerovars; /**< collection of SCIP_VAR* that are fixed to zero in transformed problem*/
133 
134  int nvars; /**< number of variables */
135  int nconss; /**< number of constraints */
136  int nnonzeros; /**< number of nonzero entries in the coefficient matrix */
137 
138  SCIP_Bool original; /**< corresponds the matrix data structure to the original
139  *< problem */
140 
141 public:
142  std::vector<std::pair<int, int>> candidatesNBlocks; /**< candidate for the number of blocks, second int indicates how often a candidate was added */
143 
144  std::vector<ConsPartition*> conspartitioncollection; /**< collection of different constraint class distributions */
145  std::vector<VarPartition*> varpartitioncollection; /**< collection of different variable class distributions */
146 
147  SCIP_Real classificationtime; /**< time that was consumed by the classification of the constraint and variables classifiers */
148  SCIP_Real nblockscandidatescalctime; /**< time that was used to calulate the candidates of te block number */
149  SCIP_Real postprocessingtime; /**< time that was spent in postproceesing decomposigtions */
150  SCIP_Real translatingtime; /**< time that was spent by transforming partialdecs between presolved and orig problem */
151 
152 private:
153 
154  /**
155  * @brief calculates necessary data for translating partialdecs and partitions
156  */
157  void calcTranslationMapping(
158  DETPROBDATA* origdata, /** original detprobdata */
159  std::vector<int>& rowothertothis, /** constraint index mapping from old to new detprobdata */
160  std::vector<int>& rowthistoother, /** constraint index mapping new to old detprobdata */
161  std::vector<int>& colothertothis, /** variable index mapping from old to new detprobdata */
162  std::vector<int>& colthistoother, /** variable index mapping from new to old detprobdata */
163  std::vector<int>& missingrowinthis /** missing constraint indices in new detprobdata */
164  );
165 
166  /**
167  * @brief returns translated partialdecs derived from given mapping data
168 
169  * @return vector of translated partialdec pointers
170  */
171  void getTranslatedPartialdecs(
172  std::vector<PARTIALDECOMP*>& otherpartialdecs, /**< partialdecs to be translated */
173  std::vector<int>& rowothertothis, /** constraint index mapping from old to new detprobdata */
174  std::vector<int>& rowthistoother, /** constraint index mapping new to old detprobdata */
175  std::vector<int>& colothertothis, /** variable index mapping from old to new detprobdata */
176  std::vector<int>& colthistoother, /** variable index mapping from new to old detprobdata */
177  std::vector<PARTIALDECOMP*>& translatedpartialdecs /**< will contain translated partialdecs */
178  );
179 
180 public:
181 
182  /**
183  * @brief constructor
184  * @param scip SCIP data structure
185  * @param _originalProblem true iff the detprobdata is created for the presolved problem
186  */
187  DETPROBDATA(
188  SCIP* scip,
189  SCIP_Bool _originalProblem
190  );
191 
192  /**
193  * destructor
194  */
195  ~DETPROBDATA();
196 
197  /**
198  * @brief adds a constraint partition if it is no duplicate of an existing constraint partition
199  */
200  void addConsPartition(
201  ConsPartition* partition /**< conspartition to be added*/
202  );
203 
204  /**
205  * @brief adds a candidate for block number and counts how often a candidate is added
206  */
208  int candidate, /**< candidate for block size */
209  int nvotes /**< number of votes this candidates will get */
210  );
211 
212  /**
213  * @brief adds a partialdec to ancestor partialdecs
214  * @param partialdec partialdec that is added to the ancestor partialdecs
215  */
217  PARTIALDECOMP* partialdec
218  );
219 
220  /**
221  * @brief adds a partialdec to current partialdecs (data structure for partialdecs that are goin to processed in the propagation rounds)
222  * @param partialdec pointer of partialdec to be added
223  * @returns TRUE if the partialdecs was successfully added (i.e. it is no duplicate of a known partialdec)
224  */
225  bool addPartialdecToOpen(
226  PARTIALDECOMP* partialdec
227  );
228 
229  /**
230  * @brief adds a partialdec to finished partialdecs
231  * @param partialdec pointer of partialdec that is going to be added to the finished partialdecs (data structure to carry finished decompositions)
232  * @returns TRUE if the partialdecs was successfully added (i.e. it is no duplicate of a known partialdec)
233  * @see addPartialdecToFinishedUnchecked()
234  */
236  PARTIALDECOMP* partialdec
237  );
238 
239  /**
240  * @brief adds a partialdec to finished partialdecs without checking for duplicates, dev has to check this on his own
241  * @param partialdec pointer of partialdec that is going to be added unchecked to the finished partialdecs (data structure to carry finished decompositions)
242  * @see addPartialdecToFinished()
243  */
245  PARTIALDECOMP* partialdec
246  );
247 
248  /**
249  * @brief adds a variable partition if it is no duplicate of an existing variable partition
250  * @param partition varpartition to be added
251  */
252  void addVarPartition(
254  );
255 
256  /**
257  * @brief clears ancestor partialdec data structure,
258  * @note does not free the partialdecs themselves
259  */
261 
262  /**
263  * @brief clears current partialdec data structure
264  * @note does not free the partialdecs themselves
265  */
267 
268  /**
269  * @brief clears finished partialdec data structure
270  *
271  * @note does not free the partialdecs themselves
272  */
274 
275  /**
276  * @brief create the constraint adjacency datastructure that is used (if created) for some methods to faster access the constarints that have variables in common
277  */
278  void createConssAdjacency();
279 
280  /**
281  * @brief frees temporary data that is only needed during the detection process
282  */
283  void freeTemporaryData();
284 
285  /**
286  * @brief returns a partialdec from ancestor partialdec data structure with given index
287  *
288  * @returns partialdec from ancestor partialdec data structure
289  */
291  int partialdecindex /**< index of partialdec in ancestor partialdec data structure */
292  );
293 
294  /**
295  * @brief returns pointer to a constraint partition
296  * @return pointer to a cosntraint partition with the given index
297  */
299  int partitionIndex /**< index of constraint partition */
300  );
301 
302  /**
303  * @brief returns the SCIP constraint related to a constraint index
304  * @return the SCIP constraint related to a constraint index
305  */
306  SCIP_CONS* getCons(
307  int consIndex /**< index of the constraint to be considered */
308  );
309 
310  /**
311  * @brief return array of constraint indices that have a common variable with the given constraint
312  * @return return vector of constraint indices that have a common variable with the given constraint
313  * @note constraint adjacency data structure has to initilized
314  */
315  std::vector<int>& getConssForCons(
316  int consIndex /**< index of the constraint to be considered */
317  );
318 
319  /**
320  * \brief returns the constraint indices of the coefficient matrix for a variable
321  * @return vector of constraint indices that have a nonzero entry with this variable
322  */
323  std::vector<int>& getConssForVar(
324  int varIndex /**< index of the variable to be considered */
325  );
326 
327  /**
328  * @brief determines all partialdecs from current (open) partialdec data structure
329  * @returns all partialdecs in current (open) partialdec data structure
330  */
331  /** */
332  std::vector<PARTIALDECOMP*>& getOpenPartialdecs();
333 
334  /**
335  * @brief returns a partialdec from finished partialdec data structure
336  * @return partialdec from finished partialdec data structure
337  */
339  int partialdecindex /**< index of partialdec in finished partialdec data structure */
340  );
341 
342  /**
343  * @brief gets all finished partialdecs
344  * @returns all finished partialdecs
345  */
346  std::vector<PARTIALDECOMP*>& getFinishedPartialdecs();
347 
348  /**
349  * @brief returns the constraint index related to a SCIP constraint
350  * @param cons the SCIP constraint pointer the index is asked for
351  * @return the constraint index related to a SCIP constraint
352  */
353  int getIndexForCons(
354  SCIP_CONS* cons
355  );
356 
357  /**
358  * @brief returns the constraint index related to a SCIP constraint
359  * @param consname name of the constraint the index is asked for
360  * @return the constraint index related to a SCIP constraint
361  */
362  int getIndexForCons(
363  const char* consname
364  );
365 
366  /**
367  * @brief returns the variable index related to a SCIP variable
368  * @param var variable pointer the index is asked for
369  * @return the variable index related to a SCIP variable
370  */
371  int getIndexForVar(
372  SCIP_VAR* var
373  );
374 
375  /**
376  * @brief returns the variable index related to a SCIP variable
377  * @param varname name of the variable the index is asked for
378  * @return the variable index related to a SCIP variable
379  */
380  int getIndexForVar(
381  const char* varname
382  );
383 
384  /**
385  * @brief returns size of ancestor partialdec data structure
386  * @return size of ancestor partialdec data structure
387  */
389 
390  /**
391  * @brief returns number of different constraint partitions
392  * @return number of different constraint partitions
393  */
394  int getNConsPartitions();
395 
396  /**
397  * @brief returns the number of variables considered in the detprobdata
398  * @return number of variables considered in the detprobdata
399  */
400  int getNConss();
401 
402  /**
403  * @brief returns the number of constraints for a given constraint
404  * @return the number of constraints for a given constraint
405  */
406  int getNConssForCons(
407  int consIndex /**< index of the constraint to be considered */
408  );
409 
410  /**
411  * @brief returns the number of constraints for a given variable where the var has a nonzero entry in
412  * @return the number of constraints for a given variable
413  */
414  int getNConssForVar(
415  int varIndex /**< index of the variable to be considered */
416  );
417 
418  /**
419  * @brief returns size of current (open) partialdec data structure
420  * @return size of current (open) partialdec data structure
421  */
422  int getNOpenPartialdecs();
423 
424  /**
425  * returns size of finished partialdec data structure
426  * @return size of finished partialdec data structure
427  */
429 
430  /**
431  * returns the number of stored partialdecs
432  * @return number of stored partialdecs
433  */
434  int getNPartialdecs();
435 
436  /**
437  * @brief returns the number of nonzero entries in the coefficient matrix
438  * @return the number of nonzero entries in the coefficient matrix
439  */
440  int getNNonzeros();
441 
442  /**
443  * @brief returns number of different variable partitions
444  * @return number of different variable partitions
445  */
446  int getNVarPartitions();
447 
448  /**
449  * @brief return the number of variables considered in the detprobdata
450  * @return the number of variables considered in the detprobdata
451  */
452  int getNVars();
453 
454  /**
455  * @brief returns the number of variables for a given constraint
456  * @return the number of variables for a given constraint
457  */
458  int getNVarsForCons(
459  int consIndex /**< index of the constraint to be considered */
460  );
461 
462  /**
463  * @brief returns pointers to all orig vars that are fixed to zero
464  * @returns vector of vars
465  */
466  std::vector<SCIP_VAR*> getOrigVarsFixedZero();
467 
468  /**
469  * @brief returns pointers to all constraints that are not marked as deleted or obsolete
470  * @returns vector of conss
471  */
472  std::vector<SCIP_CONS*> getRelevantConss();
473 
474  /**
475  * @brief returns pointers to all problem vars that are not fixed to 0
476  * @returns vector of vars
477  */
478  std::vector<SCIP_VAR*> getRelevantVars();
479 
480  /**
481  * @brief returns the corresponding scip data structure
482  * @return the corresponding scip data structure
483  */
484  SCIP* getScip();
485 
486  /**
487  * @brief gets the candidates for number of blocks added by the user followed by the found ones sorted in descending order by how often a candidate was proposed
488  * @param candidates will contain the candidates for number of blocks sorted in descending order by how often a candidate was added
489  */
491  std::vector<int>& candidates
492  );
493 
494  /**
495  * @brief returns a coefficient from the coefficient matrix
496  * @return a coefficient from the coefficient matrix
497  */
498  SCIP_Real getVal(
499  int row, /**< index of the constraint to be considered */
500  int col /**< index of the variable to be considered */
501  );
502 
503  /**
504  * @brief returns the nonzero coefficients of the coefficient matrix for a constraint
505  * @return vector of coefficients of in matrix for constraints
506  * @note same order as in @see getVarsForCons()
507  */
508  std::vector<SCIP_Real>& getValsForCons(
509  int consIndex /**< index of the constraint to be considered */
510  );
511 
512  /**
513  * @brief returns pointer to a variable partition with given index
514  * @return pointer to a variable partition with given index
515  */
517  int partitionIndex /**< index of variable partition */
518  );
519 
520  /**
521  * @brief returns vector to stored variable partitions
522  * @return returns vector to stored variable partitions
523  */
524  std::vector<VarPartition*> getVarPartitions();
525 
526  /**
527  * @brief returns SCIP variable related to a variable index
528  * @return SCIP variable pointer related to a variable index
529  */
530  SCIP_VAR* getVar(
531  int varIndex /**< index of the variable to be considered */
532  );
533 
534  /**
535  * @brief returns the variable indices of the coefficient matrix for a constraint
536  * @return the variable indices of the coefficient matrix for a constraint
537  */
538  std::vector<int>& getVarsForCons(
539  int consIndex /**< index of the constraint to be considered */
540  );
541 
542  /**
543  * @brief returns whether a constraint is a cardinality constraint, i.e. of the \f$\sum_{i} x_i = b\f$
544  * @param consindexd index of constraint that is be checked
545  * @return returns whether a constraint is a cardinality constraint
546  */
548  int consindexd
549  );
550 
551  /**
552  * @brief determines whether or not the constraint-constraint adjacency data structure is initilized
553  *
554  * @returns true iff the constraint-constraint adjacency data structure is initilized
555  */
556  SCIP_Bool isConssAdjInitialized();
557 
558  /**
559  * @brief is cons with specified indec partitioning, or packing covering constraint?
560  * @param consindexd index of the given cons
561  * @return is cons with specified indec partitioning, or packing covering constraint
562  */
563  bool isConsSetpp(
564  int consindexd
565  );
566 
567  /**
568  * @brief is cons with specified index partitioning packing, or covering constraint?
569  * @param consindexd index of cons to be checked
570  * @return whether a constraint is partitioning packing, or covering constraint?
571  */
572  bool isConsSetppc(
573  int consindexd
574  );
575 
576  /** @brief is constraint ranged row, i.e., -inf < lhs < rhs < inf?
577  *
578  * @returns whether val is ranged row
579  */
580  SCIP_Bool isFiniteNonnegativeIntegral(
581  SCIP* scip, /**< SCIP data structure */
582  SCIP_Real x /**< value */
583  );
584 
585  /**
586  * @brief check if partialdec is a duplicate of an existing finished partialdec
587  * @param partialdec partialdec to be checked
588  * @returns TRUE iff partialdec is a duplicate of an existing finished partialdec
589  */
591  PARTIALDECOMP* partialdec
592  );
593 
594  /**
595  * @brief returns true if the matrix structure corresponds to the presolved problem
596  * @return TRUE if the matrix structure corresponds to the presolved problem
597  */
598  SCIP_Bool isAssignedToOrigProb();
599 
600  /** @brief is constraint ranged row, i.e., -inf < lhs < rhs < inf?
601  * @returns whether constraint is ranged row
602  */
603  SCIP_Bool isRangedRow(
604  SCIP* scip, /**< SCIP data structure */
605  SCIP_Real lhs, /**< left hand side */
606  SCIP_Real rhs /**< right hand side */
607  );
608 
609  /**
610  * @brief check if partialdec is a duplicate of any given partialdecs
611  * @param comppartialdec partialdec to be checked
612  * @param partialdecs partialdecs to compare with
613  * @param sort sort the vars and conss data structures in the partialdecs by their indices
614  * @return TRUE iff partialdec is no duplicate of any given partialdecs
615  */
617  PARTIALDECOMP* comppartialdec,
618  std::vector<PARTIALDECOMP*> const & partialdecs,
619  bool sort
620  );
621 
622  /**
623  * @brief output method for json file writer to write block candidate information
624  * @param scip SCIP data structure
625  * @param file output file or NULL for standard output
626  */
628  SCIP* scip, /**< SCIP data structure */
629  FILE* file /**< output file or NULL for standard output */
630  );
631 
632  /**
633  * @brief output method for json file writer to write partition candidate information
634  * @param file output file or NULL for standard output
635  */
637  FILE* file /**< output file or NULL for standard output */
638  );
639 
640  /**
641  * @brief sorts partialdecs in finished partialdecs data structure according to the current scoretype
642  */
643  void sortFinishedForScore();
644 
645  /**
646  * @brief translates partialdecs if the index structure of the problem has changed, e.g. due to presolving
647  * @return translated partialdecs
648  */
649  std::vector<PARTIALDECOMP*> translatePartialdecs(
650  DETPROBDATA* otherdata, /**< old detprobdata */
651  std::vector<PARTIALDECOMP*> otherpartialdecs /**< partialdecs to be translated */
652  );
653 
654  /**
655  * @brief translates partialdecs if the index structure of the problem has changed, e.g. due to presolving
656  * @return translated partialdecs
657  */
658  std::vector<PARTIALDECOMP*> translatePartialdecs(
659  DETPROBDATA* otherdata /**< old detprobdata */
660  );
661 
662 
663 };
664 /* class DETPROBDATA */
665 
666 
667 } /* namespace gcg */
668 
669 /**
670  * \brief interface data structure for the detector calling methods
671  */
673 {
674  gcg::DETPROBDATA* detprobdata; /**< current detprobdata to consider */
675  gcg::PARTIALDECOMP* workonpartialdec; /**< partialdec (aka partial decomposition) to be propagted in next detector call */
676  gcg::PARTIALDECOMP** newpartialdecs; /**< array of new partialdecs to filled by the detetcor methods */
677  int nnewpartialdecs; /**< number of new neeed, set by the detector methods */
678  double detectiontime; /**< time spent on detection */
679 };
680 
681 #endif /* GCG_CLASS_DETPROBDATA_H__ */
bool isConsSetppc(int consindexd)
is cons with specified index partitioning packing, or covering constraint?
int getNConss()
returns the number of variables considered in the detprobdata
GCG interface methods.
@ SCIP_CONSTYPE_SETCOVERING
class representing a partition of a set of variables
SCIP_Real classificationtime
std::vector< int > & getConssForCons(int consIndex)
return array of constraint indices that have a common variable with the given constraint
void printPartitionInformation(FILE *file)
output method for json file writer to write partition candidate information
SCIP_Bool isAssignedToOrigProb()
returns true if the matrix structure corresponds to the presolved problem
SCIP * getScip()
returns the corresponding scip data structure
std::size_t operator()(const std::pair< T1, T2 > &p) const
std::vector< PARTIALDECOMP * > translatePartialdecs(DETPROBDATA *otherdata, std::vector< PARTIALDECOMP * > otherpartialdecs)
translates partialdecs if the index structure of the problem has changed, e.g. due to presolving
@ SCIP_CONSTYPE_BINPACKING
@ SCIP_CONSTYPE_VARBOUND
int getNAncestorPartialdecs()
returns size of ancestor partialdec data structure
SCIP_Real nblockscandidatescalctime
class representing a partition of a set of constraints
SCIP_Bool partialdecIsNoDuplicateOfPartialdecs(PARTIALDECOMP *comppartialdec, std::vector< PARTIALDECOMP * > const &partialdecs, bool sort)
check if partialdec is a duplicate of any given partialdecs
void getSortedCandidatesNBlocks(std::vector< int > &candidates)
gets the candidates for number of blocks added by the user followed by the found ones sorted in desce...
@ SCIP_CONSTYPE_SINGLETON
SCIP_Bool isPartialdecDuplicateofFinished(PARTIALDECOMP *partialdec)
check if partialdec is a duplicate of an existing finished partialdec
PARTIALDECOMP * getAncestorPartialdec(int partialdecindex)
returns a partialdec from ancestor partialdec data structure with given index
void clearCurrentPartialdecs()
clears current partialdec data structure
@ SCIP_CONSTYPE_INVKNAPSACK
void clearFinishedPartialdecs()
clears finished partialdec data structure
@ SCIP_CONSTYPE_MIXEDBINARY
std::vector< int > & getConssForVar(int varIndex)
returns the constraint indices of the coefficient matrix for a variable
@ SCIP_CONSTYPE_AGGREGATION
void addPartialdecToAncestor(PARTIALDECOMP *partialdec)
adds a partialdec to ancestor partialdecs
std::vector< SCIP_VAR * > getOrigVarsFixedZero()
returns pointers to all orig vars that are fixed to zero
int getNOpenPartialdecs()
returns size of current (open) partialdec data structure
static SCIP_RETCODE partition(SCIP *scip, SCIP_VAR **J, int *Jsize, SCIP_Longint *priority, SCIP_VAR **F, int Fsize, SCIP_VAR **origvar, SCIP_Real *median)
SCIP_CONS * getCons(int consIndex)
returns the SCIP constraint related to a constraint index
int getNNonzeros()
returns the number of nonzero entries in the coefficient matrix
bool addPartialdecToFinished(PARTIALDECOMP *partialdec)
adds a partialdec to finished partialdecs
PARTIALDECOMP * getFinishedPartialdec(int partialdecindex)
returns a partialdec from finished partialdec data structure
std::vector< std::pair< int, int > > candidatesNBlocks
std::vector< VarPartition * > getVarPartitions()
returns vector to stored variable partitions
std::vector< SCIP_Real > & getValsForCons(int consIndex)
returns the nonzero coefficients of the coefficient matrix for a constraint
int getNVars()
return the number of variables considered in the detprobdata
interface data structure for the detector calling methods
int getIndexForCons(SCIP_CONS *cons)
returns the constraint index related to a SCIP constraint
SCIP_Constype_orig
@ SCIP_CONSTYPE_INTKNAPSACK
void addCandidatesNBlocksNVotes(int candidate, int nvotes)
adds a candidate for block number and counts how often a candidate is added
int getIndexForVar(SCIP_VAR *var)
returns the variable index related to a SCIP variable
int getNConsPartitions()
returns number of different constraint partitions
void freeTemporaryData()
frees temporary data that is only needed during the detection process
int getNConssForCons(int consIndex)
returns the number of constraints for a given constraint
gcg::DETPROBDATA * detprobdata
void createConssAdjacency()
create the constraint adjacency datastructure that is used (if created) for some methods to faster ac...
ConsPartition * getConsPartition(int partitionIndex)
returns pointer to a constraint partition
@ SCIP_CONSTYPE_EQKNAPSACK
@ SCIP_CONSTYPE_EMPTY
@ SCIP_CONSTYPE_SETPARTITION
void addVarPartition(VarPartition *partition)
adds a variable partition if it is no duplicate of an existing variable partition
bool isConsCardinalityCons(int consindexd)
returns whether a constraint is a cardinality constraint, i.e. of the
std::vector< PARTIALDECOMP * > & getFinishedPartialdecs()
gets all finished partialdecs
bool isConsSetpp(int consindexd)
is cons with specified indec partitioning, or packing covering constraint?
@ SCIP_CONSTYPE_KNAPSACK
void addPartialdecToFinishedUnchecked(PARTIALDECOMP *partialdec)
adds a partialdec to finished partialdecs without checking for duplicates, dev has to check this on h...
SCIP_Real postprocessingtime
@ SCIP_CONSTYPE_GENERAL
std::vector< SCIP_VAR * > getRelevantVars()
returns pointers to all problem vars that are not fixed to 0
SCIP_Bool isFiniteNonnegativeIntegral(SCIP *scip, SCIP_Real x)
is constraint ranged row, i.e., -inf < lhs < rhs < inf?
VarPartition * getVarPartition(int partitionIndex)
returns pointer to a variable partition with given index
class to manage partial decompositions
gcg::PARTIALDECOMP ** newpartialdecs
enum SCIP_Constype_orig SCIP_CONSTYPE_ORIG
SCIP_Bool isRangedRow(SCIP *scip, SCIP_Real lhs, SCIP_Real rhs)
is constraint ranged row, i.e., -inf < lhs < rhs < inf?
@ SCIP_CONSTYPE_SETPACKING
int getNVarsForCons(int consIndex)
returns the number of variables for a given constraint
SCIP_Bool isConssAdjInitialized()
determines whether or not the constraint-constraint adjacency data structure is initilized
std::vector< ConsPartition * > conspartitioncollection
@ SCIP_CONSTYPE_FREE
class storing (potentially incomplete) decompositions
@ SCIP_CONSTYPE_CARDINALITY
std::vector< VarPartition * > varpartitioncollection
SCIP_Real getVal(int row, int col)
returns a coefficient from the coefficient matrix
int getNConssForVar(int varIndex)
returns the number of constraints for a given variable where the var has a nonzero entry in
std::vector< int > & getVarsForCons(int consIndex)
returns the variable indices of the coefficient matrix for a constraint
bool addPartialdecToOpen(PARTIALDECOMP *partialdec)
adds a partialdec to current partialdecs (data structure for partialdecs that are goin to processed i...
combine two hash function of objects of a pair to get a vaulue for the pair
void clearAncestorPartialdecs()
clears ancestor partialdec data structure,
SCIP_VAR * getVar(int varIndex)
returns SCIP variable related to a variable index
void sortFinishedForScore()
sorts partialdecs in finished partialdecs data structure according to the current scoretype
void addConsPartition(ConsPartition *partition)
adds a constraint partition if it is no duplicate of an existing constraint partition
DETPROBDATA(SCIP *scip, SCIP_Bool _originalProblem)
constructor
gcg::PARTIALDECOMP * workonpartialdec
std::vector< PARTIALDECOMP * > & getOpenPartialdecs()
determines all partialdecs from current (open) partialdec data structure
std::vector< SCIP_CONS * > getRelevantConss()
returns pointers to all constraints that are not marked as deleted or obsolete
int getNVarPartitions()
returns number of different variable partitions
void printBlockcandidateInformation(SCIP *scip, FILE *file)
output method for json file writer to write block candidate information