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 scip_table.c 26 * @ingroup OTHER_CFILES 27 * @brief public methods for statistics table plugins 28 * @author Tobias Achterberg 29 * @author Timo Berthold 30 * @author Gerald Gamrath 31 * @author Leona Gottwald 32 * @author Stefan Heinz 33 * @author Gregor Hendel 34 * @author Thorsten Koch 35 * @author Alexander Martin 36 * @author Marc Pfetsch 37 * @author Michael Winkler 38 * @author Kati Wolter 39 * 40 * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE 41 */ 42 43 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 44 45 #include "scip/debug.h" 46 #include "scip/pub_message.h" 47 #include "scip/scip_table.h" 48 #include "scip/set.h" 49 #include "scip/struct_mem.h" 50 #include "scip/struct_scip.h" 51 #include "scip/struct_set.h" 52 #include "scip/table.h" 53 54 55 /** creates a statistics table and includes it in SCIP */ 56 SCIP_RETCODE SCIPincludeTable( 57 SCIP* scip, /**< SCIP data structure */ 58 const char* name, /**< name of statistics table */ 59 const char* desc, /**< description of statistics table */ 60 SCIP_Bool active, /**< should the table be activated by default? */ 61 SCIP_DECL_TABLECOPY ((*tablecopy)), /**< copy method of statistics table or NULL if you don't want to copy your plugin into sub-SCIPs */ 62 SCIP_DECL_TABLEFREE ((*tablefree)), /**< destructor of statistics table */ 63 SCIP_DECL_TABLEINIT ((*tableinit)), /**< initialize statistics table */ 64 SCIP_DECL_TABLEEXIT ((*tableexit)), /**< deinitialize statistics table */ 65 SCIP_DECL_TABLEINITSOL ((*tableinitsol)), /**< solving process initialization method of statistics table */ 66 SCIP_DECL_TABLEEXITSOL ((*tableexitsol)), /**< solving process deinitialization method of statistics table */ 67 SCIP_DECL_TABLEOUTPUT ((*tableoutput)), /**< output method */ 68 SCIP_TABLEDATA* tabledata, /**< statistics table data */ 69 int position, /**< position of statistics table */ 70 SCIP_STAGE earlieststage /**< output of the statistics table is only printed from this stage onwards */ 71 ) 72 { 73 SCIP_TABLE* table; 74 75 SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeTable", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) ); 76 77 /* check whether statistics table is already present */ 78 if( SCIPfindTable(scip, name) != NULL ) 79 { 80 SCIPerrorMessage("statistics table <%s> already included.\n", name); 81 return SCIP_INVALIDDATA; 82 } 83 84 SCIP_CALL( SCIPtableCreate(&table, scip->set, scip->messagehdlr, scip->mem->setmem, 85 name, desc, active, tablecopy, 86 tablefree, tableinit, tableexit, tableinitsol, tableexitsol, tableoutput, tabledata, 87 position, earlieststage) ); 88 SCIP_CALL( SCIPsetIncludeTable(scip->set, table) ); 89 90 return SCIP_OKAY; 91 } 92 93 /** returns the statistics table of the given name, or NULL if not existing */ 94 SCIP_TABLE* SCIPfindTable( 95 SCIP* scip, /**< SCIP data structure */ 96 const char* name /**< name of statistics table */ 97 ) 98 { 99 assert(scip != NULL); 100 assert(scip->set != NULL); 101 assert(name != NULL); 102 103 return SCIPsetFindTable(scip->set, name); 104 } 105 106 /** returns the array of currently available statistics tables */ 107 SCIP_TABLE** SCIPgetTables( 108 SCIP* scip /**< SCIP data structure */ 109 ) 110 { 111 assert(scip != NULL); 112 assert(scip->set != NULL); 113 114 return scip->set->tables; 115 } 116 117 /** returns the number of currently available statistics tables */ 118 int SCIPgetNTables( 119 SCIP* scip /**< SCIP data structure */ 120 ) 121 { 122 assert(scip != NULL); 123 assert(scip->set != NULL); 124 125 return scip->set->ntables; 126 } 127