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