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_history.h 26 * @ingroup PUBLICCOREAPI 27 * @brief public methods for branching and inference history structure 28 * @author Stefan Heinz 29 */ 30 31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 32 33 #ifndef __SCIP_PUB_HISTORY_H__ 34 #define __SCIP_PUB_HISTORY_H__ 35 36 #include "scip/def.h" 37 #include "scip/type_history.h" 38 39 #ifdef NDEBUG 40 #include "scip/struct_history.h" 41 #endif 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** gets the conflict score of the history entry */ 48 SCIP_EXPORT 49 SCIP_Real SCIPhistoryGetVSIDS( 50 SCIP_HISTORY* history, /**< branching and inference history */ 51 SCIP_BRANCHDIR dir /**< branching direction */ 52 ); 53 54 /** gets the average conflict length of the history entry */ 55 SCIP_EXPORT 56 SCIP_Real SCIPhistoryGetAvgConflictlength( 57 SCIP_HISTORY* history, /**< branching and inference history */ 58 SCIP_BRANCHDIR dir /**< branching direction */ 59 ); 60 61 /** get number of cutoffs counter */ 62 SCIP_EXPORT 63 SCIP_Real SCIPhistoryGetCutoffSum( 64 SCIP_HISTORY* history, /**< branching and inference history */ 65 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */ 66 ); 67 68 /** get number of inferences counter */ 69 SCIP_EXPORT 70 SCIP_Real SCIPhistoryGetInferenceSum( 71 SCIP_HISTORY* history, /**< branching and inference history */ 72 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */ 73 ); 74 75 /** return the number of (domain) values for which a history exists */ 76 SCIP_EXPORT 77 int SCIPvaluehistoryGetNValues( 78 SCIP_VALUEHISTORY* valuehistory /**< value based history */ 79 ); 80 81 /** return the array containing the histories for the individual (domain) values */ 82 SCIP_EXPORT 83 SCIP_HISTORY** SCIPvaluehistoryGetHistories( 84 SCIP_VALUEHISTORY* valuehistory /**< value based history */ 85 ); 86 87 /** return the array containing the (domain) values for which a history exists */ 88 SCIP_EXPORT 89 SCIP_Real* SCIPvaluehistoryGetValues( 90 SCIP_VALUEHISTORY* valuehistory /**< value based history */ 91 ); 92 93 #ifdef NDEBUG 94 95 /* In optimized mode, the methods are implemented as defines to reduce the number of function calls and 96 * speed up the algorithms. 97 */ 98 99 #define SCIPhistoryGetVSIDS(history,dir) ((history)->vsids[dir]) 100 #define SCIPhistoryGetAvgConflictlength(history,dir) ((history)->conflengthsum[dir] > 0.0 \ 101 ? (SCIP_Real)(history)->nactiveconflicts[dir]/(SCIP_Real)(history)->conflengthsum[dir] : 0.0) 102 #define SCIPhistoryGetCutoffSum(history,dir) ((history)->cutoffsum[dir]) 103 #define SCIPhistoryGetInferenceSum(history,dir) ((history)->inferencesum[dir]) 104 #define SCIPvaluehistoryGetNValues(valuehistory) (valuehistory)->nvalues 105 #define SCIPvaluehistoryGetHistories(valuehistory) (valuehistory)->histories 106 #define SCIPvaluehistoryGetValues(valuehistory) (valuehistory)->values 107 108 #endif 109 110 111 #ifdef __cplusplus 112 } 113 #endif 114 115 #endif 116