Scippy

SCIP

Solving Constraint Integer Programs

scip_message.h
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-2024 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_message.h
26  * @ingroup PUBLICCOREAPI
27  * @brief public methods for message handling
28  * @author Tobias Achterberg
29  * @author Timo Berthold
30  * @author Thorsten Koch
31  * @author Alexander Martin
32  * @author Marc Pfetsch
33  * @author Kati Wolter
34  * @author Gregor Hendel
35  * @author Leona Gottwald
36  */
37 
38 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
39 
40 #ifndef __SCIP_SCIP_MESSAGE_H__
41 #define __SCIP_SCIP_MESSAGE_H__
42 
43 
44 #include "scip/def.h"
45 #include "scip/type_message.h"
46 #include "scip/type_retcode.h"
47 #include "scip/type_scip.h"
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 /**@addtogroup MessageOutputMethods
54  *
55  * @{
56  */
57 
58 /* if we have a C99 compiler */
59 #ifdef SCIP_HAVE_VARIADIC_MACROS
60 
61 /** prints a debugging message if SCIP_DEBUG flag is set */
62 #ifdef SCIP_DEBUG
63 #define SCIPdebugMsg(scip, ...) SCIPprintDebugMessage(scip, __FILE__, __LINE__, __VA_ARGS__)
64 #define SCIPdebugMsgPrint(scip, ...) SCIPdebugMessagePrint(scip, __VA_ARGS__)
65 #else
66 #define SCIPdebugMsg(scip, ...) while ( FALSE ) SCIPprintDebugMessage(scip, __FILE__, __LINE__, __VA_ARGS__)
67 #define SCIPdebugMsgPrint(scip, ...) while ( FALSE ) SCIPdebugMessagePrint(scip, __VA_ARGS__)
68 #endif
69 
70 #else
71 /* if we do not have a C99 compiler, use a workaround that prints a message, but not the file and linenumber */
72 
73 /** prints a debugging message if SCIP_DEBUG flag is set */
74 #ifdef SCIP_DEBUG
75 #define SCIPdebugMsg printf("debug: "), SCIPdebugMessagePrint
76 #define SCIPdebugMsgPrint SCIPdebugMessagePrint
77 #else
78 #define SCIPdebugMsg while ( FALSE ) SCIPdebugMessagePrint
79 #define SCIPdebugMsgPrint while ( FALSE ) SCIPdebugMessagePrint
80 #endif
81 
82 #endif
83 
84 
85 /** installs the given message handler, such that all messages are passed to this handler. A messages handler can be
86  * created via SCIPmessagehdlrCreate().
87  *
88  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
89  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
90  *
91  * @pre this method can be called in one of the following stages of the SCIP solving process:
92  * - \ref SCIP_STAGE_INIT
93  * - \ref SCIP_STAGE_PROBLEM
94  *
95  * @note The currently installed messages handler gets freed if this SCIP instance is its last user (w.r.t. capture/release).
96  */
97 SCIP_EXPORT
99  SCIP* scip, /**< SCIP data structure */
100  SCIP_MESSAGEHDLR* messagehdlr /**< message handler to install, or NULL to suppress all output */
101  );
102 
103 /** returns the currently installed message handler
104  *
105  * @return the currently installed message handler, or NULL if messages are currently suppressed
106  */
107 SCIP_EXPORT
109  SCIP* scip /**< SCIP data structure */
110  );
111 
112 /** sets the log file name for the currently installed message handler */
113 SCIP_EXPORT
115  SCIP* scip, /**< SCIP data structure */
116  const char* filename /**< name of log file, or NULL (no log) */
117  );
118 
119 /** sets the currently installed message handler to be quiet (or not) */
120 SCIP_EXPORT
122  SCIP* scip, /**< SCIP data structure */
123  SCIP_Bool quiet /**< should screen messages be suppressed? */
124  );
125 
126 /** prints a warning message via the message handler */
127 #ifdef __GNUC__
128 __attribute__((format(printf, 2, 3)))
129 #endif
130 SCIP_EXPORT
131 void SCIPwarningMessage(
132  SCIP* scip, /**< SCIP data structure */
133  const char* formatstr, /**< format string like in printf() function */
134  ... /**< format arguments line in printf() function */
135  );
136 
137 /** prints a debug message */
138 #ifdef __GNUC__
139 __attribute__((format(printf, 4, 5)))
140 #endif
141 SCIP_EXPORT
143  SCIP* scip, /**< SCIP data structure */
144  const char* sourcefile, /**< name of the source file that called the function */
145  int sourceline, /**< line in the source file where the function was called */
146  const char* formatstr, /**< format string like in printf() function */
147  ... /**< format arguments line in printf() function */
148  );
149 
150 /** prints a debug message without precode */
151 #ifdef __GNUC__
152 __attribute__((format(printf, 2, 3)))
153 #endif
154 SCIP_EXPORT
156  SCIP* scip, /**< SCIP data structure */
157  const char* formatstr, /**< format string like in printf() function */
158  ... /**< format arguments line in printf() function */
159  );
160 
161 /** prints a dialog message that requests user interaction or is a direct response to a user interactive command */
162 #ifdef __GNUC__
163 __attribute__((format(printf, 3, 4)))
164 #endif
165 SCIP_EXPORT
166 void SCIPdialogMessage(
167  SCIP* scip, /**< SCIP data structure */
168  FILE* file, /**< file stream to print into, or NULL for stdout */
169  const char* formatstr, /**< format string like in printf() function */
170  ... /**< format arguments line in printf() function */
171  );
172 
173 /** prints a message */
174 #ifdef __GNUC__
175 __attribute__((format(printf, 3, 4)))
176 #endif
177 SCIP_EXPORT
178 void SCIPinfoMessage(
179  SCIP* scip, /**< SCIP data structure */
180  FILE* file, /**< file stream to print into, or NULL for stdout */
181  const char* formatstr, /**< format string like in printf() function */
182  ... /**< format arguments line in printf() function */
183  );
184 
185 /** prints a message depending on the verbosity level */
186 #ifdef __GNUC__
187 __attribute__((format(printf, 4, 5)))
188 #endif
189 SCIP_EXPORT
190 void SCIPverbMessage(
191  SCIP* scip, /**< SCIP data structure */
192  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
193  FILE* file, /**< file stream to print into, or NULL for stdout */
194  const char* formatstr, /**< format string like in printf() function */
195  ... /**< format arguments line in printf() function */
196  );
197 
198 /** returns the current message verbosity level
199  *
200  * @return message verbosity level of SCIP
201  *
202  * @see \ref SCIP_VerbLevel "SCIP_VERBLEVEL" for a list of all verbosity levels
203  */
204 SCIP_EXPORT
206  SCIP* scip /**< SCIP data structure */
207  );
208 
209 
210 /**@} */
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif
void SCIPdialogMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:191
SCIP_RETCODE SCIPsetMessagehdlr(SCIP *scip, SCIP_MESSAGEHDLR *messagehdlr)
Definition: scip_message.c:64
SCIP_VERBLEVEL SCIPgetVerbLevel(SCIP *scip)
Definition: scip_message.c:249
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
enum SCIP_VerbLevel SCIP_VERBLEVEL
Definition: type_message.h:59
void SCIPdebugMessagePrint(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:175
type definitions for return codes for SCIP methods
SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
Definition: scip_message.c:88
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:120
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:208
type definitions for SCIP&#39;s main datastructure
void SCIPprintDebugMessage(SCIP *scip, const char *sourcefile, int sourceline, const char *formatstr,...)
Definition: scip_message.c:136
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip_message.c:225
#define SCIP_Bool
Definition: def.h:91
void SCIPsetMessagehdlrQuiet(SCIP *scip, SCIP_Bool quiet)
Definition: scip_message.c:108
void SCIPsetMessagehdlrLogfile(SCIP *scip, const char *filename)
Definition: scip_message.c:96
type definitions for message output methods
common defines and data types used in all packages of SCIP