Scippy

SCIP

Solving Constraint Integer Programs

scip_message.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2019 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 scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file scip_message.c
17  * @brief public methods for message handling
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  * @author Robert Lion Gottwald
22  * @author Stefan Heinz
23  * @author Gregor Hendel
24  * @author Thorsten Koch
25  * @author Alexander Martin
26  * @author Marc Pfetsch
27  * @author Michael Winkler
28  * @author Kati Wolter
29  *
30  * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include <ctype.h>
36 #include <stdarg.h>
37 #include <assert.h>
38 #include <string.h>
39 #if defined(_WIN32) || defined(_WIN64)
40 #else
41 #include <strings.h> /*lint --e{766}*/
42 #endif
43 
44 
45 #include "lpi/lpi.h"
46 #include "nlpi/exprinterpret.h"
47 #include "nlpi/nlpi.h"
48 #include "scip/benders.h"
49 #include "scip/benderscut.h"
50 #include "scip/branch.h"
51 #include "scip/branch_nodereopt.h"
52 #include "scip/clock.h"
53 #include "scip/compr.h"
54 #include "scip/concsolver.h"
55 #include "scip/concurrent.h"
56 #include "scip/conflict.h"
57 #include "scip/conflictstore.h"
58 #include "scip/cons.h"
59 #include "scip/cons_linear.h"
60 #include "scip/cutpool.h"
61 #include "scip/cuts.h"
62 #include "scip/debug.h"
63 #include "scip/def.h"
64 #include "scip/dialog.h"
65 #include "scip/dialog_default.h"
66 #include "scip/disp.h"
67 #include "scip/event.h"
68 #include "scip/heur.h"
69 #include "scip/heur_ofins.h"
70 #include "scip/heur_reoptsols.h"
72 #include "scip/heuristics.h"
73 #include "scip/history.h"
74 #include "scip/implics.h"
75 #include "scip/interrupt.h"
76 #include "scip/lp.h"
77 #include "scip/mem.h"
78 #include "scip/message_default.h"
79 #include "scip/misc.h"
80 #include "scip/nlp.h"
81 #include "scip/nodesel.h"
82 #include "scip/paramset.h"
83 #include "scip/presol.h"
84 #include "scip/presolve.h"
85 #include "scip/pricer.h"
86 #include "scip/pricestore.h"
87 #include "scip/primal.h"
88 #include "scip/prob.h"
89 #include "scip/prop.h"
90 #include "scip/reader.h"
91 #include "scip/relax.h"
92 #include "scip/reopt.h"
93 #include "scip/retcode.h"
94 #include "scip/scipbuildflags.h"
95 #include "scip/scipcoreplugins.h"
96 #include "scip/scipgithash.h"
97 #include "scip/sepa.h"
98 #include "scip/sepastore.h"
99 #include "scip/set.h"
100 #include "scip/sol.h"
101 #include "scip/solve.h"
102 #include "scip/stat.h"
103 #include "scip/syncstore.h"
104 #include "scip/table.h"
105 #include "scip/tree.h"
106 #include "scip/var.h"
107 #include "scip/visual.h"
108 #include "xml/xml.h"
109 
110 #include "scip/scip_message.h"
111 
112 #include "scip/pub_message.h"
113 
114 
115 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
116  * this structure except the interface methods in scip.c.
117  * In optimized mode, the structure is included in scip.h, because some of the methods
118  * are implemented as defines for performance reasons (e.g. the numerical comparisons)
119  */
120 #ifndef NDEBUG
121 #include "scip/struct_scip.h"
122 #endif
123 
124 /** installs the given message handler, such that all messages are passed to this handler. A messages handler can be
125  * created via SCIPmessagehdlrCreate().
126  *
127  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
128  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
129  *
130  * @pre this method can be called in one of the following stages of the SCIP solving process:
131  * - \ref SCIP_STAGE_INIT
132  * - \ref SCIP_STAGE_PROBLEM
133  *
134  * @note The currently installed messages handler gets freed if this SCIP instance is its last user (w.r.t. capture/release).
135  */
137  SCIP* scip, /**< SCIP data structure */
138  SCIP_MESSAGEHDLR* messagehdlr /**< message handler to install, or NULL to suppress all output */
139  )
140 {
141  int i;
142 
143  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetMessagehdlr", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
144 
145  assert(scip != NULL);
146  assert(scip->set != NULL);
147  assert(scip->set->nlpis != NULL || scip->set->nnlpis == 0);
148 
149  /* update message handler in NLP solver interfaces */
150  for( i = 0; i < scip->set->nnlpis; ++i )
151  {
152  assert(scip->set->nlpis[i] != NULL);
153 
154  SCIP_CALL( SCIPnlpiSetMessageHdlr(scip->set->nlpis[i], messagehdlr) );
155  }
156 
157  SCIPmessagehdlrCapture(messagehdlr);
158 
160  assert(scip->messagehdlr == NULL);
161 
162  scip->messagehdlr = messagehdlr;
163 
164  return SCIP_OKAY;
165 }
166 
167 /** returns the currently installed message handler
168  *
169  * @return the currently installed message handler, or NULL if messages are currently suppressed
170  */
172  SCIP* scip /**< SCIP data structure */
173  )
174 {
175  return scip->messagehdlr;
176 }
177 
178 /** sets the log file name for the currently installed message handler */
180  SCIP* scip, /**< SCIP data structure */
181  const char* filename /**< name of log file, or NULL (no log) */
182  )
183 {
184  if( scip->messagehdlr != NULL )
185  {
186  SCIPmessagehdlrSetLogfile(scip->messagehdlr, filename);
187  }
188 }
189 
190 /** sets the currently installed message handler to be quiet (or not) */
192  SCIP* scip, /**< SCIP data structure */
193  SCIP_Bool quiet /**< should screen messages be suppressed? */
194  )
195 {
196  if( scip->messagehdlr != NULL )
197  {
198  SCIPmessagehdlrSetQuiet(scip->messagehdlr, quiet);
199  }
200 }
201 
202 /** prints a warning message via the message handler */
204  SCIP* scip, /**< SCIP data structure */
205  const char* formatstr, /**< format string like in printf() function */
206  ... /**< format arguments line in printf() function */
207  )
208 {
209  va_list ap;
210 
211  assert(scip != NULL);
212 
213  va_start(ap, formatstr); /*lint !e838*/
214  SCIPmessageVFPrintWarning(scip->messagehdlr, formatstr, ap);
215  va_end(ap);
216 }
217 
218 /** prints a debug message */
220  SCIP* scip, /**< SCIP data structure */
221  const char* sourcefile, /**< name of the source file that called the function */
222  int sourceline, /**< line in the source file where the function was called */
223  const char* formatstr, /**< format string like in printf() function */
224  ... /**< format arguments line in printf() function */
225  )
226 {
227  int subscipdepth = 0;
228  va_list ap;
229 
230  assert( sourcefile != NULL );
231  assert( scip != NULL );
232 
233  if ( scip->stat != NULL )
234  subscipdepth = scip->stat->subscipdepth;
235  if ( subscipdepth > 0 )
236  SCIPmessageFPrintInfo(scip->messagehdlr, NULL, "%d: [%s:%d] debug: ", subscipdepth, sourcefile, sourceline);
237  else
238  SCIPmessageFPrintInfo(scip->messagehdlr, NULL, "[%s:%d] debug: ", sourcefile, sourceline);
239 
240  va_start(ap, formatstr); /*lint !e838*/
241  SCIPmessageVFPrintInfo(scip->messagehdlr, NULL, formatstr, ap);
242  va_end(ap);
243 }
244 
245 /** prints a debug message without precode */
247  SCIP* scip, /**< SCIP data structure */
248  const char* formatstr, /**< format string like in printf() function */
249  ... /**< format arguments line in printf() function */
250  )
251 {
252  va_list ap;
253 
254  assert( scip != NULL );
255 
256  va_start(ap, formatstr); /*lint !e838*/
257  SCIPmessageVFPrintInfo(scip->messagehdlr, NULL, formatstr, ap);
258  va_end(ap);
259 }
260 
261 /** prints a dialog message that requests user interaction or is a direct response to a user interactive command */
263  SCIP* scip, /**< SCIP data structure */
264  FILE* file, /**< file stream to print into, or NULL for stdout */
265  const char* formatstr, /**< format string like in printf() function */
266  ... /**< format arguments line in printf() function */
267  )
268 {
269  va_list ap;
270 
271  assert(scip != NULL);
272 
273  va_start(ap, formatstr); /*lint !e838*/
274  SCIPmessageVFPrintDialog(scip->messagehdlr, file, formatstr, ap);
275  va_end(ap);
276 }
277 
278 /** prints a message */
280  SCIP* scip, /**< SCIP data structure */
281  FILE* file, /**< file stream to print into, or NULL for stdout */
282  const char* formatstr, /**< format string like in printf() function */
283  ... /**< format arguments line in printf() function */
284  )
285 {
286  va_list ap;
287 
288  assert(scip != NULL);
289 
290  va_start(ap, formatstr); /*lint !e838*/
291  SCIPmessageVFPrintInfo(scip->messagehdlr, file, formatstr, ap);
292  va_end(ap);
293 }
294 
295 /** prints a message depending on the verbosity level */
297  SCIP* scip, /**< SCIP data structure */
298  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
299  FILE* file, /**< file stream to print into, or NULL for stdout */
300  const char* formatstr, /**< format string like in printf() function */
301  ... /**< format arguments line in printf() function */
302  )
303 {
304  va_list ap;
305 
306  assert(scip != NULL);
307  assert(scip->set != NULL);
308 
309  va_start(ap, formatstr); /*lint !e838*/
310  SCIPmessageVFPrintVerbInfo(scip->messagehdlr, scip->set->disp_verblevel, msgverblevel, file, formatstr, ap);
311  va_end(ap);
312 }
313 
314 /** returns the current message verbosity level
315  *
316  * @return message verbosity level of SCIP
317  *
318  * @see \ref SCIP_VerbLevel "SCIP_VERBLEVEL" for a list of all verbosity levels
319  */
321  SCIP* scip /**< SCIP data structure */
322  )
323 {
324  assert(scip != NULL);
325  assert(scip->set != NULL);
326 
327  return scip->set->disp_verblevel;
328 }
internal methods for separators
SCIP_STAT * stat
Definition: struct_scip.h:69
void SCIPmessageVFPrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr, va_list ap)
Definition: message.c:713
#define NULL
Definition: def.h:246
internal methods for managing events
default message handler
trivialnegation primal heuristic
internal methods for storing primal CIP solutions
methods to interpret (evaluate) an expression tree "fast"
internal methods for branch and bound tree
void SCIPdialogMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:262
methods for implications, variable bounds, and cliques
SCIP_RETCODE SCIPsetMessagehdlr(SCIP *scip, SCIP_MESSAGEHDLR *messagehdlr)
Definition: scip_message.c:136
internal methods for clocks and timing issues
internal methods for NLPI solver interfaces
interface methods for specific LP solvers
internal methods for displaying statistics tables
void SCIPmessagehdlrCapture(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:329
#define FALSE
Definition: def.h:72
methods for the aggregation rows
internal methods for Benders&#39; decomposition
SCIP_VERBLEVEL SCIPgetVerbLevel(SCIP *scip)
Definition: scip_message.c:320
#define TRUE
Definition: def.h:71
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
methods commonly used by primal heuristics
enum SCIP_VerbLevel SCIP_VERBLEVEL
Definition: type_message.h:48
internal methods for branching rules and branching candidate storage
datastructures for concurrent solvers
void SCIPdebugMessagePrint(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:246
SCIP_RETCODE SCIPnlpiSetMessageHdlr(SCIP_NLPI *nlpi, SCIP_MESSAGEHDLR *messagehdlr)
Definition: nlpi.c:720
SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
Definition: scip_message.c:171
internal methods for handling parameter settings
methods for creating output for visualization tools (VBC, BAK)
nodereopt branching rule
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:203
internal methods for LP management
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:279
internal methods for branching and inference history
internal methods for collecting primal CIP solutions and primal informations
internal methods for propagators
SCIP_NLPI ** nlpis
Definition: struct_set.h:89
git hash methods
void SCIPmessagehdlrSetLogfile(SCIP_MESSAGEHDLR *messagehdlr, const char *filename)
Definition: message.c:383
internal methods for storing and manipulating the main problem
methods for block memory pools and memory buffers
register additional core functionality that is designed as plugins
SCIP_RETCODE SCIPcheckStage(SCIP *scip, const char *method, SCIP_Bool init, SCIP_Bool problem, SCIP_Bool transforming, SCIP_Bool transformed, SCIP_Bool initpresolve, SCIP_Bool presolving, SCIP_Bool exitpresolve, SCIP_Bool presolved, SCIP_Bool initsolve, SCIP_Bool solving, SCIP_Bool solved, SCIP_Bool exitsolve, SCIP_Bool freetrans, SCIP_Bool freescip)
Definition: debug.c:2010
internal methods for presolvers
internal methods for NLP management
void SCIPprintDebugMessage(SCIP *scip, const char *sourcefile, int sourceline, const char *formatstr,...)
Definition: scip_message.c:219
internal miscellaneous methods
SCIP_RETCODE SCIPmessagehdlrRelease(SCIP_MESSAGEHDLR **messagehdlr)
Definition: message.c:338
internal methods for node selectors and node priority queues
internal methods for variable pricers
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:358
SCIP main data structure.
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip_message.c:296
internal methods for storing priced variables
internal methods for relaxators
internal methods for storing separated cuts
methods commonly used for presolving
methods for catching the user CTRL-C interrupt
internal methods for problem variables
data structures and methods for collecting reoptimization information
the function declarations for the synchronization store
internal methods for user interface dialog
#define SCIP_Bool
Definition: def.h:69
internal methods for input file readers
void SCIPmessagehdlrSetQuiet(SCIP_MESSAGEHDLR *messagehdlr, SCIP_Bool quiet)
Definition: message.c:401
void SCIPsetMessagehdlrQuiet(SCIP *scip, SCIP_Bool quiet)
Definition: scip_message.c:191
methods for debugging
reoptsols primal heuristic
internal methods for storing cuts in a cut pool
Constraint handler for linear constraints in their most general form, .
helper functions for concurrent scip solvers
internal methods for return codes for SCIP methods
internal methods for conflict analysis
void SCIPmessageVFPrintDialog(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr, va_list ap)
Definition: message.c:539
internal methods for tree compressions
internal methods for main solving loop and node processing
void SCIPmessageVFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr, va_list ap)
Definition: message.c:623
SCIP_VERBLEVEL disp_verblevel
Definition: struct_set.h:261
void SCIPsetMessagehdlrLogfile(SCIP *scip, const char *filename)
Definition: scip_message.c:179
SCIP_SET * set
Definition: struct_scip.h:62
public methods for message output
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:608
SCIP_MESSAGEHDLR * messagehdlr
Definition: struct_scip.h:65
default user interface dialog
internal methods for problem statistics
void SCIPmessageVFPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
Definition: message.c:455
public methods for message handling
int nnlpis
Definition: struct_set.h:130
internal methods for constraints and constraint handlers
declarations for XML parsing
build flags methods
common defines and data types used in all packages of SCIP
internal methods for primal heuristics
internal methods for Benders&#39; decomposition cuts
int subscipdepth
Definition: struct_stat.h:200
internal methods for displaying runtime statistics
OFINS - Objective Function Induced Neighborhood Search - a primal heuristic for reoptimization.