Scippy

SCIP

Solving Constraint Integer Programs

scip_reader.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_reader.c
17  * @brief public methods for reader plugins
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_reader.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 /** creates a reader and includes it in SCIP
125  *
126  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
127  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
128  *
129  * @pre This method can be called if SCIP is in one of the following stages:
130  * - \ref SCIP_STAGE_INIT
131  * - \ref SCIP_STAGE_PROBLEM
132  *
133  * @note method has all reader callbacks as arguments and is thus changed every time a new callback is added
134  * in future releases; consider using SCIPincludeReaderBasic() and setter functions
135  * if you seek for a method which is less likely to change in future releases
136  */
138  SCIP* scip, /**< SCIP data structure */
139  const char* name, /**< name of reader */
140  const char* desc, /**< description of reader */
141  const char* extension, /**< file extension that reader processes */
142  SCIP_DECL_READERCOPY ((*readercopy)), /**< copy method of reader or NULL if you don't want to copy your plugin into sub-SCIPs */
143  SCIP_DECL_READERFREE ((*readerfree)), /**< destructor of reader */
144  SCIP_DECL_READERREAD ((*readerread)), /**< read method */
145  SCIP_DECL_READERWRITE ((*readerwrite)), /**< write method */
146  SCIP_READERDATA* readerdata /**< reader data */
147  )
148 {
149  SCIP_READER* reader;
150 
151  SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeReader", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
152 
153  /* check whether reader is already present */
154  if( SCIPfindReader(scip, name) != NULL )
155  {
156  SCIPerrorMessage("reader <%s> already included.\n", name);
157  return SCIP_INVALIDDATA;
158  }
159 
160  SCIP_CALL( SCIPreaderCreate(&reader, scip->set, name, desc, extension, readercopy, readerfree, readerread,
161  readerwrite, readerdata) );
162  SCIP_CALL( SCIPsetIncludeReader(scip->set, reader) );
163 
164  return SCIP_OKAY;
165 }
166 
167 /** creates a reader and includes it in SCIP. All non-fundamental (or optional) callbacks will be set to NULL.
168  * Optional callbacks can be set via specific setter functions, see
169  * SCIPsetReaderCopy(), SCIPsetReaderFree(), SCIPsetReaderRead(), SCIPsetReaderWrite().
170  *
171  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
172  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
173  *
174  * @pre This method can be called if SCIP is in one of the following stages:
175  * - \ref SCIP_STAGE_INIT
176  * - \ref SCIP_STAGE_PROBLEM
177  *
178  * @note if you want to set all callbacks with a single method call, consider using SCIPincludeReader() instead
179  */
181  SCIP* scip, /**< SCIP data structure */
182  SCIP_READER** readerptr, /**< reference to reader pointer, or NULL */
183  const char* name, /**< name of reader */
184  const char* desc, /**< description of reader */
185  const char* extension, /**< file extension that reader processes */
186  SCIP_READERDATA* readerdata /**< reader data */
187  )
188 {
189  SCIP_READER* reader;
190 
191  SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeReaderBasic", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
192 
193  /* check whether reader is already present */
194  if( SCIPfindReader(scip, name) != NULL )
195  {
196  SCIPerrorMessage("reader <%s> already included.\n", name);
197  return SCIP_INVALIDDATA;
198  }
199 
200  SCIP_CALL( SCIPreaderCreate(&reader, scip->set, name, desc, extension, NULL, NULL, NULL, NULL, readerdata) );
201  SCIP_CALL( SCIPsetIncludeReader(scip->set, reader) );
202 
203  if( readerptr != NULL )
204  *readerptr = reader;
205 
206  return SCIP_OKAY;
207 }
208 
209 /** set copy method of reader
210  *
211  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
212  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
213  *
214  * @pre This method can be called if SCIP is in one of the following stages:
215  * - \ref SCIP_STAGE_INIT
216  * - \ref SCIP_STAGE_PROBLEM
217  */
219  SCIP* scip, /**< SCIP data structure */
220  SCIP_READER* reader, /**< reader */
221  SCIP_DECL_READERCOPY ((*readercopy)) /**< copy method of reader or NULL if you don't want to copy your plugin into sub-SCIPs */
222  )
223 {
224  assert(scip != NULL);
225 
226  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetReaderCopy", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
227 
228  SCIPreaderSetCopy(reader, readercopy);
229 
230  return SCIP_OKAY;
231 }
232 
233 /** set deinitialization method of reader
234  *
235  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
236  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
237  *
238  * @pre This method can be called if SCIP is in one of the following stages:
239  * - \ref SCIP_STAGE_INIT
240  * - \ref SCIP_STAGE_PROBLEM
241  */
243  SCIP* scip, /**< SCIP data structure */
244  SCIP_READER* reader, /**< reader */
245  SCIP_DECL_READERFREE ((*readerfree)) /**< destructor of reader */
246  )
247 {
248  assert(scip != NULL);
249 
250  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetReaderFree", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
251 
252  SCIPreaderSetFree(reader, readerfree);
253 
254  return SCIP_OKAY;
255 }
256 
257 /** set read method of reader
258  *
259  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
260  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
261  *
262  * @pre This method can be called if SCIP is in one of the following stages:
263  * - \ref SCIP_STAGE_INIT
264  * - \ref SCIP_STAGE_PROBLEM
265  */
267  SCIP* scip, /**< SCIP data structure */
268  SCIP_READER* reader, /**< reader */
269  SCIP_DECL_READERREAD ((*readerread)) /**< read method of reader */
270  )
271 {
272  assert(scip != NULL);
273 
274  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetReaderRead", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
275 
276  SCIPreaderSetRead(reader, readerread);
277 
278  return SCIP_OKAY;
279 }
280 
281 /** set write method of reader
282  *
283  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
284  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
285  *
286  * @pre This method can be called if SCIP is in one of the following stages:
287  * - \ref SCIP_STAGE_INIT
288  * - \ref SCIP_STAGE_PROBLEM
289  */
291  SCIP* scip, /**< SCIP data structure */
292  SCIP_READER* reader, /**< reader */
293  SCIP_DECL_READERWRITE ((*readerwrite)) /**< write method of reader */
294  )
295 {
296  assert(scip != NULL);
297 
298  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetReaderWrite", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
299 
300  SCIPreaderSetWrite(reader, readerwrite);
301 
302  return SCIP_OKAY;
303 }
304 
305 /** returns the reader of the given name, or NULL if not existing */
307  SCIP* scip, /**< SCIP data structure */
308  const char* name /**< name of reader */
309  )
310 {
311  assert(scip != NULL);
312  assert(scip->set != NULL);
313  assert(name != NULL);
314 
315  return SCIPsetFindReader(scip->set, name);
316 }
317 
318 /** returns the array of currently available readers */
320  SCIP* scip /**< SCIP data structure */
321  )
322 {
323  assert(scip != NULL);
324  assert(scip->set != NULL);
325 
326  return scip->set->readers;
327 }
328 
329 /** returns the number of currently available readers */
331  SCIP* scip /**< SCIP data structure */
332  )
333 {
334  assert(scip != NULL);
335  assert(scip->set != NULL);
336 
337  return scip->set->nreaders;
338 }
internal methods for separators
#define NULL
Definition: def.h:246
internal methods for managing events
SCIP_READER ** readers
Definition: struct_set.h:68
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
methods for implications, variable bounds, and cliques
void SCIPreaderSetCopy(SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: reader.c:503
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 SCIPreaderSetFree(SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
Definition: reader.c:514
#define FALSE
Definition: def.h:72
methods for the aggregation rows
internal methods for Benders&#39; decomposition
#define TRUE
Definition: def.h:71
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
methods commonly used by primal heuristics
SCIP_DECL_READERWRITE(ReaderTSP::scip_write)
Definition: ReaderTSP.cpp:483
internal methods for branching rules and branching candidate storage
datastructures for concurrent solvers
SCIP_READER * SCIPfindReader(SCIP *scip, const char *name)
Definition: scip_reader.c:306
internal methods for handling parameter settings
SCIP_RETCODE SCIPreaderCreate(SCIP_READER **reader, SCIP_SET *set, const char *name, const char *desc, const char *extension, SCIP_DECL_READERCOPY((*readercopy)), SCIP_DECL_READERFREE((*readerfree)), SCIP_DECL_READERREAD((*readerread)), SCIP_DECL_READERWRITE((*readerwrite)), SCIP_READERDATA *readerdata)
Definition: reader.c:103
methods for creating output for visualization tools (VBC, BAK)
nodereopt branching rule
internal methods for LP management
internal methods for branching and inference history
internal methods for collecting primal CIP solutions and primal informations
internal methods for propagators
SCIP_READER ** SCIPgetReaders(SCIP *scip)
Definition: scip_reader.c:319
git hash methods
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
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
void SCIPreaderSetRead(SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: reader.c:525
internal methods for NLP management
internal miscellaneous methods
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.
internal methods for storing priced variables
internal methods for relaxators
internal methods for storing separated cuts
SCIP_READER * SCIPsetFindReader(SCIP_SET *set, const char *name)
Definition: set.c:3575
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
struct SCIP_ReaderData SCIP_READERDATA
Definition: type_reader.h:37
internal methods for user interface dialog
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip_reader.c:180
void SCIPreaderSetWrite(SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
Definition: reader.c:536
internal methods for input file readers
int nreaders
Definition: struct_set.h:97
methods for debugging
SCIP_RETCODE SCIPincludeReader(SCIP *scip, const char *name, const char *desc, const char *extension, SCIP_DECL_READERCOPY((*readercopy)), SCIP_DECL_READERFREE((*readerfree)), SCIP_DECL_READERREAD((*readerread)), SCIP_DECL_READERWRITE((*readerwrite)), SCIP_READERDATA *readerdata)
Definition: scip_reader.c:137
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
Definition: scip_reader.c:290
reoptsols primal heuristic
internal methods for storing cuts in a cut pool
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: scip_reader.c:218
helper functions for concurrent scip solvers
#define SCIP_DECL_READERCOPY(x)
Definition: type_reader.h:46
internal methods for return codes for SCIP methods
internal methods for conflict analysis
internal methods for tree compressions
internal methods for main solving loop and node processing
int SCIPgetNReaders(SCIP *scip)
Definition: scip_reader.c:330
SCIP_SET * set
Definition: struct_scip.h:62
public methods for message output
default user interface dialog
internal methods for problem statistics
SCIP_RETCODE SCIPsetIncludeReader(SCIP_SET *set, SCIP_READER *reader)
Definition: set.c:3553
#define SCIP_DECL_READERREAD(x)
Definition: type_reader.h:71
internal methods for constraints and constraint handlers
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: scip_reader.c:266
declarations for XML parsing
build flags methods
common defines and data types used in all packages of SCIP
internal methods for primal heuristics
public methods for reader plugins
internal methods for Benders&#39; decomposition cuts
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
Definition: scip_reader.c:242
#define SCIP_DECL_READERFREE(x)
Definition: type_reader.h:55
internal methods for displaying runtime statistics
OFINS - Objective Function Induced Neighborhood Search - a primal heuristic for reoptimization.