After solving a constraint integer program, SCIP can display statistics tables with information about, e.g., the solving time, number of nodes, LP iterations or the number of calls and successes of different plugins via "display statistics" in the shell or via SCIPprintStatistics() in the C-interface. There already exists a wide variety of statistics tables which can be activated or deactivated on demand, see src/scip/table_default.c. Additionally, the user can implement his/her own statistics tables in order to display problem or algorithm specific values.
A complete list of all statistics tables contained in this release can be found here.
We now explain how users can add their own statistics tables. We give the explanation for creating your own source file for each additional statistics table. Of course, you can collect different additional statistics tables in one source file. Take src/scip/table_default.c, where all default statistics tables are collected, as an example. As all other default plugins, the default statistics table plugins and the statistics table template are written in C. C++ users can easily adapt the code by using the scip::ObjTable wrapper base class and implement the scip_...() virtual methods instead of the SCIP_DECL_TABLE... callback methods.
Additional documentation for the callback methods of a statistics table can be found in the file type_table.h.
Here is what you have to do to implement a statistics table (assuming your statistics table is named "mystatisticstable"):
At the top of the new file "table_mystatisticstable.c" you can find the statistics table properties. These are given as compiler defines. In the C++ wrapper class, you have to provide the statistics table properties by calling the constructor of the abstract base class scip::ObjTable from within your constructor. The properties you have to set have the following meaning:
Below the header "Data structures" you can find a struct which is called "struct SCIP_TableData". In this data structure, you can store the data of your statistics table. For example, you should store the adjustable parameters of the statistics table in this data structure. If you are using C++, you can add statistics table data as usual as object variables to your class.
Defining statistics table data is optional. You can leave the struct empty.
At the bottom of "table_mystatisticstable.c" you can find the interface method SCIPincludeTableMystatisticstable(), which also appears in "table_mystatisticstable.h".
This method only has to be adjusted slightly. It is responsible for notifying SCIP of the presence of the statistics table by calling the method SCIPincludeTable().
The interface method is called by the user, if (s)he wants to include the statistics table, i.e., if (s)he wants to use the statistics table in an application.
If you are using statistics table data, you have to allocate the memory for the data at this point. You can do this by calling:
You also have to initialize the fields in struct SCIP_TableData afterwards.
Statistics table plugins have only one fundamental callback method, namely the TABLEOUTPUT method. This method has to be implemented for every display column; the other callback methods are optional. In the C++ wrapper class scip::ObjTable, the scip_output() method (which corresponds to the TABLEOUTPUT callback) is a virtual abstract member function. You have to implement it in order to be able to construct an object of your statistics table class.
Additional documentation for the callback methods can be found in type_table.h.
The TABLEOUTPUT callback is called whenever SCIP is asked to print statistics (because the user typed "display statistics" in the shell or called SCIPprintStatistics()). In this callback, the table should print all of its information to the given file (which may be NULL if the output should be printed to the console).
The additional callback methods do not need to be implemented in every case. They can be used, for example, to initialize and free private data.
The TABLECOPY callback is executed when a SCIP instance is copied, e.g. to solve a sub-SCIP. By defining this callback as
NULL the user disables the execution of the specified column. In general it is probably not needed to implement that callback since the output of the copied instance is usually suppressed. In the other case or for debugging the callback should be implement.
If you are using statistics table data, you have to implement this method in order to free the statistics table data. This can be done by the following procedure:
If you have allocated memory for fields in your statistics table data, remember to free this memory before freeing the statistics table data itself. If you are using the C++ wrapper class, this method is not available. Instead, just use the destructor of your class to free the member variables of your class.
The TABLEINIT callback is executed after the problem is transformed. The statistics table may, e.g., use this call to initialize its statistics table data.
The TABLEEXIT callback is executed before the transformed problem is freed. In this method, the statistics table should free all resources that have been allocated for the solving process in TABLEINIT.
The TABLEINITSOL callback is executed when the presolving is finished and the branch-and-bound process is about to begin. The statistics table may use this call to initialize its branch-and-bound specific data.
The TABLEEXITSOL callback is executed before the branch-and-bound process is freed. The statistics table should use this call to clean up its branch-and-bound specific data.