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_sol.h 26 * @ingroup PUBLICCOREAPI 27 * @brief public methods for primal CIP solutions 28 * @author Tobias Achterberg 29 * @author Timo Berthold 30 */ 31 32 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 33 34 #ifndef __SCIP_PUB_SOL_H__ 35 #define __SCIP_PUB_SOL_H__ 36 37 38 #include "scip/def.h" 39 #include "scip/type_sol.h" 40 #include "scip/type_heur.h" 41 #include "scip/type_relax.h" 42 43 #ifdef NDEBUG 44 #include "scip/struct_sol.h" 45 #endif 46 47 #ifdef __cplusplus 48 extern "C" { 49 #endif 50 51 /**@addtogroup PublicSolutionMethods 52 * 53 * @{ 54 */ 55 56 57 /** gets origin of solution */ 58 SCIP_EXPORT 59 SCIP_SOLORIGIN SCIPsolGetOrigin( 60 SCIP_SOL* sol /**< primal CIP solution */ 61 ); 62 63 /** returns whether the given solution is defined on original variables */ 64 SCIP_EXPORT 65 SCIP_Bool SCIPsolIsOriginal( 66 SCIP_SOL* sol /**< primal CIP solution */ 67 ); 68 69 /** returns whether the given solution is partial */ 70 SCIP_EXPORT 71 SCIP_Bool SCIPsolIsPartial( 72 SCIP_SOL* sol /**< primal CIP solution */ 73 ); 74 75 /** gets objective value of primal CIP solution which lives in the original problem space */ 76 SCIP_EXPORT 77 SCIP_Real SCIPsolGetOrigObj( 78 SCIP_SOL* sol /**< primal CIP solution */ 79 ); 80 81 /** gets clock time, when this solution was found */ 82 SCIP_EXPORT 83 SCIP_Real SCIPsolGetTime( 84 SCIP_SOL* sol /**< primal CIP solution */ 85 ); 86 87 /** gets branch and bound run number, where this solution was found */ 88 SCIP_EXPORT 89 int SCIPsolGetRunnum( 90 SCIP_SOL* sol /**< primal CIP solution */ 91 ); 92 93 /** gets node number of the specific branch and bound run, where this solution was found */ 94 SCIP_EXPORT 95 SCIP_Longint SCIPsolGetNodenum( 96 SCIP_SOL* sol /**< primal CIP solution */ 97 ); 98 99 /** gets node's depth, where this solution was found */ 100 SCIP_EXPORT 101 int SCIPsolGetDepth( 102 SCIP_SOL* sol /**< primal CIP solution */ 103 ); 104 105 /** gets information if solution was found by the LP, a primal heuristic, or a custom relaxator */ 106 SCIP_EXPORT 107 SCIP_SOLTYPE SCIPsolGetType( 108 SCIP_SOL* sol /**< primal CIP solution */ 109 ); 110 111 /** gets heuristic that found this solution, or NULL if solution has type different than SCIP_SOLTYPE_HEUR */ 112 SCIP_EXPORT 113 SCIP_HEUR* SCIPsolGetHeur( 114 SCIP_SOL* sol /**< primal CIP solution */ 115 ); 116 117 /** gets relaxation handler that found this solution, or NULL if solution has different type than SCIP_SOLTYPE_RELAX */ 118 SCIP_EXPORT 119 SCIP_RELAX* SCIPsolGetRelax( 120 SCIP_SOL* sol /**< primal CIP solution */ 121 ); 122 123 /** informs the solution that it now belongs to the given primal heuristic. For convenience and backwards compatibility, 124 * the method accepts NULL as input for \p heur, in which case the solution type is set to SCIP_SOLTYPE_LPRELAX. 125 * 126 * @note Relaxation handlers should use SCIPsolSetRelax() instead. 127 */ 128 SCIP_EXPORT 129 void SCIPsolSetHeur( 130 SCIP_SOL* sol, /**< primal CIP solution */ 131 SCIP_HEUR* heur /**< primal heuristic that found the solution, or NULL for LP solutions */ 132 ); 133 134 /** informs the solution that it now belongs to the given relaxation handler */ 135 SCIP_EXPORT 136 void SCIPsolSetRelax( 137 SCIP_SOL* sol, /**< primal CIP solution */ 138 SCIP_RELAX* relax /**< relaxator that found the solution */ 139 ); 140 141 /** informs the solution that it is an LP relaxation solution */ 142 SCIP_EXPORT 143 void SCIPsolSetLPRelaxation( 144 SCIP_SOL* sol /**< primal CIP solution */ 145 ); 146 147 /** informs the solution that it is a solution found during strong branching */ 148 SCIP_EXPORT 149 void SCIPsolSetStrongbranching( 150 SCIP_SOL* sol /**< primal CIP solution */ 151 ); 152 153 /** informs the solution that it originates from a pseudo solution */ 154 SCIP_EXPORT 155 void SCIPsolSetPseudo( 156 SCIP_SOL* sol /**< primal CIP solution */ 157 ); 158 159 /** returns unique index of given solution */ 160 SCIP_EXPORT 161 int SCIPsolGetIndex( 162 SCIP_SOL* sol /**< primal CIP solution */ 163 ); 164 165 /** get maximum absolute bound violation of solution */ 166 SCIP_EXPORT 167 SCIP_Real SCIPsolGetAbsBoundViolation( 168 SCIP_SOL* sol /**< primal CIP solution */ 169 ); 170 171 /** get maximum relative bound violation of solution */ 172 SCIP_EXPORT 173 SCIP_Real SCIPsolGetRelBoundViolation( 174 SCIP_SOL* sol /**< primal CIP solution */ 175 ); 176 177 /** get maximum absolute integrality violation of solution */ 178 SCIP_EXPORT 179 SCIP_Real SCIPsolGetAbsIntegralityViolation( 180 SCIP_SOL* sol /**< primal CIP solution */ 181 ); 182 183 /** get maximum absolute LP row violation of solution */ 184 SCIP_EXPORT 185 SCIP_Real SCIPsolGetAbsLPRowViolation( 186 SCIP_SOL* sol /**< primal CIP solution */ 187 ); 188 189 /** get maximum relative LP row violation of solution */ 190 SCIP_EXPORT 191 SCIP_Real SCIPsolGetRelLPRowViolation( 192 SCIP_SOL* sol /**< primal CIP solution */ 193 ); 194 195 /** get maximum absolute constraint violation of solution */ 196 SCIP_EXPORT 197 SCIP_Real SCIPsolGetAbsConsViolation( 198 SCIP_SOL* sol /**< primal CIP solution */ 199 ); 200 201 /** get maximum relative constraint violation of solution */ 202 SCIP_EXPORT 203 SCIP_Real SCIPsolGetRelConsViolation( 204 SCIP_SOL* sol /**< primal CIP solution */ 205 ); 206 207 #ifdef NDEBUG 208 209 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and 210 * speed up the algorithms. 211 */ 212 213 #define SCIPsolGetOrigin(sol) ((sol)->solorigin) 214 #define SCIPsolIsOriginal(sol) ((sol)->solorigin == SCIP_SOLORIGIN_ORIGINAL || (sol)->solorigin == SCIP_SOLORIGIN_PARTIAL) 215 #define SCIPsolGetOrigObj(sol) (sol)->obj 216 #define SCIPsolGetTime(sol) (sol)->time 217 #define SCIPsolGetNodenum(sol) (sol)->nodenum 218 #define SCIPsolGetRunnum(sol) (sol)->runnum 219 #define SCIPsolGetDepth(sol) (sol)->depth 220 #define SCIPsolGetHeur(sol) ((sol)->type == SCIP_SOLTYPE_HEUR ? (sol)->creator.heur : NULL) 221 #define SCIPsolGetRelax(sol) ((sol)->type == SCIP_SOLTYPE_RELAX ? (sol)->creator.relax : NULL) 222 #define SCIPsolGetIndex(sol) (sol)->index 223 #define SCIPsolGetType(sol) (sol)->type 224 #define SCIPsolSetLPRelaxation(sol) ((sol)->type = SCIP_SOLTYPE_LPRELAX) 225 #define SCIPsolSetStrongbranching(sol) ((sol)->type = SCIP_SOLTYPE_STRONGBRANCH) 226 #define SCIPsolSetPseudo(sol) ((sol)->type = SCIP_SOLTYPE_PSEUDO) 227 #endif 228 229 /** @} */ 230 231 #ifdef __cplusplus 232 } 233 #endif 234 235 #endif 236