1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 2 /* */ 3 /* This file is part of the program and library */ 4 /* SCIP --- Solving Constraint Integer Programs */ 5 /* */ 6 /* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */ 7 /* */ 8 /* Licensed under the Apache License, Version 2.0 (the "License"); */ 9 /* you may not use this file except in compliance with the License. */ 10 /* You may obtain a copy of the License at */ 11 /* */ 12 /* http://www.apache.org/licenses/LICENSE-2.0 */ 13 /* */ 14 /* Unless required by applicable law or agreed to in writing, software */ 15 /* distributed under the License is distributed on an "AS IS" BASIS, */ 16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ 17 /* See the License for the specific language governing permissions and */ 18 /* limitations under the License. */ 19 /* */ 20 /* You should have received a copy of the Apache-2.0 license */ 21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ 22 /* */ 23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 24 25 /**@file pub_dcmp.h 26 * @ingroup DecompMethods 27 * @brief public methods for decompositions 28 * @author Gregor Hendel 29 */ 30 31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 32 33 #ifndef SCIP_PUB_DECOMP_H_ 34 #define SCIP_PUB_DECOMP_H_ 35 36 37 #include "blockmemshell/memory.h" 38 #include "scip/type_cons.h" 39 #include "scip/type_dcmp.h" 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 /**@addtogroup DecompMethods 46 * 47 * @{ 48 */ 49 50 /** creates a decomposition */ 51 SCIP_EXPORT 52 SCIP_RETCODE SCIPdecompCreate( 53 SCIP_DECOMP** decomp, /**< pointer to store the decomposition data structure */ 54 BMS_BLKMEM* blkmem, /**< block memory */ 55 int nblocks, /**< the number of blocks (without the linking block) */ 56 SCIP_Bool original, /**< is this a decomposition in the original (TRUE) or transformed space? */ 57 SCIP_Bool benderslabels /**< should the variables be labeled for the application of Benders' decomposition */ 58 ); 59 60 /** frees a decomposition */ 61 SCIP_EXPORT 62 void SCIPdecompFree( 63 SCIP_DECOMP** decomp, /**< pointer to store the decomposition data structure */ 64 BMS_BLKMEM* blkmem /**< block memory */ 65 ); 66 67 /** returns TRUE if decomposition is in the original space */ 68 SCIP_EXPORT 69 SCIP_Bool SCIPdecompIsOriginal( 70 SCIP_DECOMP* decomp /**< decomposition data structure */ 71 ); 72 73 /** sets the parameter that indicates whether the variables must be labeled for the application of Benders' 74 * decomposition 75 */ 76 SCIP_EXPORT 77 void SCIPdecompSetUseBendersLabels( 78 SCIP_DECOMP* decomp, /**< decomposition data structure */ 79 SCIP_Bool benderslabels /**< whether Benders' variable labels should be used */ 80 ); 81 82 /** returns TRUE if the variables must be labeled for the application of Benders' decomposition */ 83 SCIP_EXPORT 84 SCIP_Bool SCIPdecompUseBendersLabels( 85 SCIP_DECOMP* decomp /**< decomposition data structure */ 86 ); 87 88 /** gets number of blocks of this decomposition */ 89 SCIP_EXPORT 90 int SCIPdecompGetNBlocks( 91 SCIP_DECOMP* decomp /**< decomposition data structure */ 92 ); 93 94 /** gets area score of this decomposition */ 95 SCIP_EXPORT 96 SCIP_Real SCIPdecompGetAreaScore( 97 SCIP_DECOMP* decomp /**< decomposition data structure */ 98 ); 99 100 /** gets modularity of this decomposition */ 101 SCIP_EXPORT 102 SCIP_Real SCIPdecompGetModularity( 103 SCIP_DECOMP* decomp /**< decomposition data structure */ 104 ); 105 106 /** gets variable size for each block, sorted by increasing block label 107 * 108 * To get all variable sizes, set nlabels to SCIPdecompGetNBlocks() + 1. 109 * The first entry corresponds to the number of border variables. 110 * 111 * @note Ensure that SCIPcomputeDecompStats() has been called before. 112 * If the decomposition was read from a file, this was done automatically. 113 */ 114 SCIP_EXPORT 115 SCIP_RETCODE SCIPdecompGetVarsSize( 116 SCIP_DECOMP* decomp, /**< decomposition data structure */ 117 int* varssize, /**< array to store variable sizes of blocks*/ 118 int nblocks /**< length of variable sizes array */ 119 ); 120 121 /** gets constraint size for each block, sorted by increasing block label 122 * 123 * To get all constraint sizes, set nlabels to SCIPdecompGetNBlocks() + 1. 124 * The first entry corresponds to the number of border constraints. 125 * 126 * @note Ensure that SCIPcomputeDecompStats() has been called before. 127 * If the decomposition was read from a file, this was done automatically. 128 */ 129 SCIP_EXPORT 130 SCIP_RETCODE SCIPdecompGetConssSize( 131 SCIP_DECOMP* decomp, /**< decomposition data structure */ 132 int* consssize, /**< array to store constraint sizes of blocks*/ 133 int nblocks /**< length of constraint sizes array */ 134 ); 135 136 /** gets number of border variables of this decomposition 137 * 138 * @note Ensure that SCIPcomputeDecompStats() has been called before. 139 * If the decomposition was read from a file, this was done automatically. 140 */ 141 SCIP_EXPORT 142 int SCIPdecompGetNBorderVars( 143 SCIP_DECOMP* decomp /**< decomposition data structure */ 144 ); 145 146 /** gets number of border constraints of this decomposition 147 * 148 * @note Ensure that SCIPcomputeDecompStats() has been called before. 149 * If the decomposition was read from a file, this was done automatically. 150 */ 151 SCIP_EXPORT 152 int SCIPdecompGetNBorderConss( 153 SCIP_DECOMP* decomp /**< decomposition data structure */ 154 ); 155 156 /** gets number of edges in the block-decomposition graph of this decomposition */ 157 SCIP_EXPORT 158 int SCIPdecompGetNBlockGraphEdges( 159 SCIP_DECOMP* decomp /**< decomposition data structure */ 160 ); 161 162 /** gets number of connected components in the block-decomposition graph of this decomposition */ 163 SCIP_EXPORT 164 int SCIPdecompGetNBlockGraphComponents( 165 SCIP_DECOMP* decomp /**< decomposition data structure */ 166 ); 167 168 /** gets number of articulation points in the block-decomposition graph of this decomposition */ 169 SCIP_EXPORT 170 int SCIPdecompGetNBlockGraphArticulations( 171 SCIP_DECOMP* decomp /**< decomposition data structure */ 172 ); 173 174 /** gets the maximum degree of the block-decomposition graph of this decomposition */ 175 SCIP_EXPORT 176 int SCIPdecompGetBlockGraphMaxDegree( 177 SCIP_DECOMP* decomp /**< decomposition data structure */ 178 ); 179 180 /** gets the minimum degree of the block-decomposition graph of this decomposition */ 181 SCIP_EXPORT 182 int SCIPdecompGetBlockGraphMinDegree( 183 SCIP_DECOMP* decomp /**< decomposition data structure */ 184 ); 185 186 /** sets labels for an array of variables */ 187 SCIP_EXPORT 188 SCIP_RETCODE SCIPdecompSetVarsLabels( 189 SCIP_DECOMP* decomp, /**< decomposition data structure */ 190 SCIP_VAR** vars, /**< array of variables */ 191 int* labels, /**< array of labels, one per variable */ 192 int nvars /**< length of variables array */ 193 ); 194 195 /** queries labels for an array of variables */ 196 SCIP_EXPORT 197 void SCIPdecompGetVarsLabels( 198 SCIP_DECOMP* decomp, /**< decomposition data structure */ 199 SCIP_VAR** vars, /**< array of variables */ 200 int* labels, /**< buffer to store labels, one per variable */ 201 int nvars /**< length of variables array */ 202 ); 203 204 /** sets labels for an array of constraints */ 205 SCIP_EXPORT 206 SCIP_RETCODE SCIPdecompSetConsLabels( 207 SCIP_DECOMP* decomp, /**< decomposition data structure */ 208 SCIP_CONS** conss, /**< array of constraints */ 209 int* labels, /**< array of labels, one per constraint */ 210 int nconss /**< length of constraints array */ 211 ); 212 213 /** queries labels for an array of constraints */ 214 SCIP_EXPORT 215 void SCIPdecompGetConsLabels( 216 SCIP_DECOMP* decomp, /**< decomposition data structure */ 217 SCIP_CONS** conss, /**< array of constraints */ 218 int* labels, /**< array of labels, one per constraint */ 219 int nconss /**< length of constraints array */ 220 ); 221 222 /** clears the corresponding labeling (constraints, variables, or both) of this decomposition */ 223 SCIP_EXPORT 224 SCIP_RETCODE SCIPdecompClear( 225 SCIP_DECOMP* decomp, /**< decomposition data structure */ 226 SCIP_Bool clearvarlabels, /**< should the variable labels be cleared? */ 227 SCIP_Bool clearconslabels /**< should the constraint labels be cleared? */ 228 ); 229 230 /** prints decomposition statistics into string buffer */ 231 SCIP_EXPORT 232 char* SCIPdecompPrintStats( 233 SCIP_DECOMP* decomp, /**< decomposition data structure */ 234 char* strbuf /**< string buffer storage */ 235 ); 236 237 /** @} */ 238 239 #ifdef __cplusplus 240 } 241 #endif 242 243 #endif 244