Scippy

SCIP

Solving Constraint Integer Programs

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-2025 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 reader.c
26 * @ingroup OTHER_CFILES
27 * @brief interface for input file readers
28 * @author Tobias Achterberg
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#include <assert.h>
34#include <string.h>
35#ifndef _WIN32
36#include <strings.h> /*lint --e{766}*/
37#endif
38#include <math.h>
39
40#include "scip/def.h"
42#include "scip/set.h"
43#include "scip/clock.h"
44#include "scip/pub_misc.h"
45#include "scip/reader.h"
46#include "scip/prob.h"
47#include "scip/pub_var.h"
48#include "scip/var.h"
49#include "scip/pub_cons.h"
50#include "scip/cons.h"
51#include "scip/pub_message.h"
52#include "scip/struct_reader.h"
53#include "scip/scip_mem.h"
54
55
56/** copies the given reader to a new scip */
58 SCIP_READER* reader, /**< reader */
59 SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
60 )
61{
62 assert(reader != NULL);
63 assert(set != NULL);
64 assert(set->scip != NULL);
65
66 if( reader->readercopy != NULL )
67 {
68 SCIPsetDebugMsg(set, "including reader %s in subscip %p\n", SCIPreaderGetName(reader), (void*)set->scip);
69 SCIP_CALL( reader->readercopy(set->scip, reader) );
70 }
71 return SCIP_OKAY;
72}
73
74/** internal method to create a reader */
75static
77 SCIP_READER** reader, /**< pointer to store reader */
78 const char* name, /**< name of reader */
79 const char* desc, /**< description of reader */
80 const char* extension, /**< file extension that reader processes */
81 SCIP_DECL_READERCOPY ((*readercopy)), /**< copy method of reader or NULL if you don't want to copy your plugin into sub-SCIPs */
82 SCIP_DECL_READERFREE ((*readerfree)), /**< destructor of reader */
83 SCIP_DECL_READERREAD ((*readerread)), /**< read method */
84 SCIP_DECL_READERWRITE ((*readerwrite)), /**< write method */
85 SCIP_READERDATA* readerdata /**< reader data */
86 )
87{
88 assert(reader != NULL);
89 assert(name != NULL);
90 assert(desc != NULL);
91 assert(extension != NULL);
92
93 SCIP_ALLOC( BMSallocMemory(reader) );
94 BMSclearMemory(*reader);
95
96 SCIP_ALLOC( BMSduplicateMemoryArray(&(*reader)->name, name, strlen(name)+1) );
97 SCIP_ALLOC( BMSduplicateMemoryArray(&(*reader)->desc, desc, strlen(desc)+1) );
98 SCIP_ALLOC( BMSduplicateMemoryArray(&(*reader)->extension, extension, strlen(extension)+1) );
99 (*reader)->readercopy = readercopy;
100 (*reader)->readerfree = readerfree;
101 (*reader)->readerread = readerread;
102 (*reader)->readerwrite = readerwrite;
103 (*reader)->readerdata = readerdata;
104 (*reader)->exact = FALSE;
105
106 /* create reading clock */
107 SCIP_CALL( SCIPclockCreate(&(*reader)->readingtime, SCIP_CLOCKTYPE_DEFAULT) );
108
109 return SCIP_OKAY;
110}
111
112/** creates a reader */
114 SCIP_READER** reader, /**< pointer to store reader */
115 SCIP_SET* set, /**< global SCIP settings */
116 const char* name, /**< name of reader */
117 const char* desc, /**< description of reader */
118 const char* extension, /**< file extension that reader processes */
119 SCIP_DECL_READERCOPY ((*readercopy)), /**< copy method of reader or NULL if you don't want to copy your plugin into sub-SCIPs */
120 SCIP_DECL_READERFREE ((*readerfree)), /**< destructor of reader */
121 SCIP_DECL_READERREAD ((*readerread)), /**< read method */
122 SCIP_DECL_READERWRITE ((*readerwrite)), /**< write method */
123 SCIP_READERDATA* readerdata /**< reader data */
124 )
125{
126 assert(reader != NULL);
127 assert(set != NULL);
128 assert(name != NULL);
129 assert(desc != NULL);
130 assert(extension != NULL);
131
132 SCIP_CALL_FINALLY( doReaderCreate(reader, name, desc, extension, readercopy, readerfree, readerread, readerwrite,
133 readerdata), (void) SCIPreaderFree(reader, set) );
134
135 return SCIP_OKAY;
136}
137
138/** frees memory of reader */
140 SCIP_READER** reader, /**< pointer to reader data structure */
141 SCIP_SET* set /**< global SCIP settings */
142 )
143{
144 assert(reader != NULL);
145 assert(set != NULL);
146
147 if( *reader == NULL )
148 return SCIP_OKAY;
149
150 /* call destructor of reader */
151 if( (*reader)->readerfree != NULL )
152 {
153 SCIP_CALL( (*reader)->readerfree(set->scip, *reader) );
154 }
155
156 BMSfreeMemoryArrayNull(&(*reader)->name);
157 BMSfreeMemoryArrayNull(&(*reader)->desc);
158 BMSfreeMemoryArrayNull(&(*reader)->extension);
159
160 /* free clock */
161 SCIPclockFree(&(*reader)->readingtime);
162
163 BMSfreeMemory(reader);
164
165 return SCIP_OKAY;
166}
167
168/** returns TRUE, if reader is responsible for files with the given extension */
169static
171 SCIP_READER* reader, /**< reader */
172 const char* extension /**< extension of the input file name */
173 )
174{
175 assert(reader != NULL);
176 assert(reader->extension != NULL);
177
178 return (extension != NULL && SCIPstrcasecmp(reader->extension, extension) == 0)
179 || (extension == NULL && *(reader->extension) == '\0');
180}
181
182/** reads problem data from file with given reader or returns SCIP_DIDNOTRUN */
184 SCIP_READER* reader, /**< reader */
185 SCIP_SET* set, /**< global SCIP settings */
186 const char* filename, /**< name of the input file */
187 const char* extension, /**< extension of the input file name */
188 SCIP_RESULT* result /**< pointer to store the result of the callback method */
189 )
190{
191 SCIP_RETCODE retcode;
192
193 assert(reader != NULL);
194 assert(set != NULL);
195 assert(filename != NULL);
196 assert(result != NULL);
197
198 /* check, if reader is applicable on the given file */
199 if( readerIsApplicable(reader, extension) && reader->readerread != NULL )
200 {
201 SCIP_CLOCK* readingtime;
202
203 /* only readers marked as exact can read and write in exact solving mode */
204 if( set->exact_enable && !reader->exact )
205 {
206 SCIPerrorMessage("reader %s cannot read problems exactly\n", SCIPreaderGetName(reader));
207 return SCIP_READERROR;
208 }
209
210 /**@note we need temporary clock to measure the reading time correctly since in case of creating a new problem
211 * within the reader all clocks are reset (including the reader clocks); this resetting is necessary for
212 * example for those case we people solve several problems using the (same) interactive shell
213 */
214
215 assert(!SCIPclockIsRunning(reader->readingtime));
216
217 /* create a temporary clock for measuring the reading time */
219
220 /* start timing */
221 SCIPclockStart(readingtime, set);
222
223 /* call reader to read problem */
224 retcode = reader->readerread(set->scip, reader, filename, result);
225
226 /* stop timing */
227 SCIPclockStop(readingtime, set);
228
229 /* add time to reader reading clock */
231
232 /* free the temporary clock */
233 SCIPclockFree(&readingtime);
234 }
235 else
236 {
237 *result = SCIP_DIDNOTRUN;
238 retcode = SCIP_OKAY;
239 }
240
241 /* check for reader errors */
242 if( retcode == SCIP_NOFILE || retcode == SCIP_READERROR )
243 return retcode;
244
245 /* check if the result code is valid in case no reader error occurred */
246 assert(*result == SCIP_DIDNOTRUN || *result == SCIP_SUCCESS);
247
248 SCIP_CALL( retcode );
249
250 return SCIP_OKAY;
251}
252
253
254/* reset the variable name to the given one */
255static
257 SCIP_VAR* var, /**< variable */
258 SCIP_SET* set, /**< global SCIP settings */
259 const char* name /**< variable name */
260 )
261{
262 const char * oldname;
263
264 assert( var != NULL );
265 assert( name != NULL );
266
267 /* get pointer to temporary generic name and free the memory */
268 oldname = SCIPvarGetName(var);
269 SCIPsetFreeBufferArray(set, &oldname);
270
271 /* reset name */
272 SCIPvarSetNamePointer(var, name);
273}
274
275
276/** writes problem data to file with given reader or returns SCIP_DIDNOTRUN */
278 SCIP_READER* reader, /**< reader */
279 SCIP_PROB* prob, /**< problem data */
280 SCIP_SET* set, /**< global SCIP settings */
281 SCIP_MESSAGEHDLR* msghdlr, /**< message handler */
282 FILE* file, /**< output file (or NULL for standard output) */
283 const char* filename, /**< name of output file, or NULL if not available */
284 const char* format, /**< file format */
285 SCIP_Bool genericnames, /**< using generic variable and constraint names? */
286 SCIP_RESULT* result /**< pointer to store the result of the callback method */
287 )
288{
289 SCIP_RETCODE retcode;
290
291 assert(reader != NULL);
292 assert(set != NULL);
293 assert(set->buffer != NULL);
294 assert(format != NULL);
295 assert(result != NULL);
296
297 /* check, if reader is applicable on the given file */
298 if( readerIsApplicable(reader, format) && reader->readerwrite != NULL )
299 {
300 SCIP_VAR** vars;
301 SCIP_VAR** fixedvars;
302 SCIP_CONS** conss;
303 SCIP_CONS* cons;
304 SCIP_Real objoffset;
305 SCIP_Real objscale;
306 SCIP_RATIONAL* objoffsetexact;
307 SCIP_RATIONAL* objscaleexact;
308 const char* consname;
309 const char** varnames = NULL;
310 const char** fixedvarnames = NULL;
311 const char** consnames = NULL;
312 char* name;
313 int nfixedvars;
314 int nconss;
315 int nvars;
316 int i;
317 int nduplicates;
318
319 /* only readers marked as exact can read and write in exact solving mode */
320 if( set->exact_enable && !reader->exact )
321 {
322 SCIPerrorMessage("reader %s cannot write problems exactly\n", SCIPreaderGetName(reader));
323 return SCIP_READERROR;
324 }
325
326 vars = SCIPprobGetVars(prob);
327 nvars = SCIPprobGetNVars(prob);
328 fixedvars = SCIPprobGetFixedVars(prob);
329 nfixedvars = SCIPprobGetNFixedVars(prob);
330
331 /* check if multiple variables have the same name */
332 if ( !genericnames )
333 {
334 nduplicates = 0;
335
336 for( i = 0; i < nvars; ++i )
337 {
338 if( vars[i] != (SCIP_VAR*) SCIPprobFindVar(prob, (void*) SCIPvarGetName(vars[i])) )
339 {
340 if( nduplicates < 3 )
341 {
342 SCIPmessageFPrintWarning(msghdlr, "The same variable name <%s> has been used for at least two different variables.\n", SCIPvarGetName(vars[i]));
343 }
344 ++nduplicates;
345 }
346 }
347
348 for( i = 0; i < nfixedvars; ++i )
349 {
350 if( fixedvars[i] != (SCIP_VAR*) SCIPprobFindVar(prob, (void*) SCIPvarGetName(fixedvars[i])) )
351 {
352 if( nduplicates < 3 )
353 {
354 SCIPmessageFPrintWarning(msghdlr, "The same variable name <%s> has been used for at least two different variables.\n", SCIPvarGetName(fixedvars[i]));
355 }
356 ++nduplicates;
357 }
358 }
359
360 if( nduplicates > 0 )
361 {
362 if( nduplicates > 3 )
363 {
364 SCIPmessageFPrintWarning(msghdlr, "In total %d duplicate variable names.\n", nduplicates);
365 }
366 SCIPmessageFPrintWarning(msghdlr, "This will likely result in wrong output files. Please use unique variable names.\n");
367 }
368 }
369
370 /* case of the transformed problem, we want to write currently valid problem */
371 if( SCIPprobIsTransformed(prob) )
372 {
373 SCIP_CONSHDLR** conshdlrs;
374 int nconshdlrs;
375
376 conshdlrs = set->conshdlrs;
377 nconshdlrs = set->nconshdlrs;
378
379 /* collect number of constraints which have to be enforced; these are the constraints which currency (locally)
380 * enabled; these also includes the local constraints
381 */
382 nconss = 0;
383 for( i = 0; i < nconshdlrs; ++i )
384 {
385 /* check if all constraints of the constraint handler should be written */
386 if( set->write_allconss )
387 nconss += SCIPconshdlrGetNConss(conshdlrs[i]);
388 else
389 nconss += SCIPconshdlrGetNEnfoConss(conshdlrs[i]);
390 }
391
392 SCIPsetDebugMsg(set, "Writing %d constraints.\n", nconss);
393
394 SCIP_CALL( SCIPsetAllocBufferArray(set, &conss, nconss) );
395
396 /* copy the constraints */
397 nconss = 0;
398 for( i = 0; i < nconshdlrs; ++i )
399 {
400 SCIP_CONS** conshdlrconss;
401 int nconshdlrconss;
402 int c;
403
404 /* check if all constraints of the constraint handler should be written */
405 if( set->write_allconss )
406 {
407 conshdlrconss = SCIPconshdlrGetConss(conshdlrs[i]);
408 nconshdlrconss = SCIPconshdlrGetNConss(conshdlrs[i]);
409 }
410 else
411 {
412 conshdlrconss = SCIPconshdlrGetEnfoConss(conshdlrs[i]);
413 nconshdlrconss = SCIPconshdlrGetNEnfoConss(conshdlrs[i]);
414 }
415
416 SCIPsetDebugMsg(set, "Conshdlr <%s> has %d constraints to write from all in all %d constraints.\n", SCIPconshdlrGetName(conshdlrs[i]), nconshdlrconss, SCIPconshdlrGetNConss(conshdlrs[i]));
417
418 for( c = 0; c < nconshdlrconss; ++c )
419 {
420 conss[nconss] = conshdlrconss[c];
421 nconss++;
422 }
423 }
424 }
425 else
426 {
427 conss = SCIPprobGetConss(prob);
428 nconss = SCIPprobGetNConss(prob);
429 }
430
431 /* check if multiple constraints have the same name */
432 if ( !genericnames )
433 {
434 nduplicates = 0;
435
436 for( i = 0; i < nconss; ++i )
437 {
438 if( conss[i] != (SCIP_CONS*) SCIPprobFindCons(prob, (void*) SCIPconsGetName(conss[i])) )
439 {
440 if( nduplicates < 3 )
441 {
442 SCIPmessageFPrintWarning(msghdlr, "The same constraint name <%s> has been used for at least two different constraints.\n", SCIPconsGetName(conss[i]));
443 }
444 ++nduplicates;
445 }
446 }
447
448 if( nduplicates > 0)
449 {
450 if( nduplicates > 3 )
451 {
452 SCIPmessageFPrintWarning(msghdlr, "In total %d duplicate constraint names.\n", nduplicates);
453 }
454 SCIPmessageFPrintWarning(msghdlr, "This can result in wrong output files, especially with indicator constraints.\n");
455 }
456 }
457
458 if( genericnames )
459 {
460 SCIP_VAR* var;
461 int size;
462
463 /* save variable and constraint names and replace these names by generic names */
464
465 /* allocate memory for saving the original variable and constraint names */
466 SCIP_CALL( SCIPsetAllocBufferArray(set, &varnames, nvars) );
467 SCIP_CALL( SCIPsetAllocBufferArray(set, &fixedvarnames, nfixedvars) );
468 SCIP_CALL( SCIPsetAllocBufferArray(set, &consnames, nconss) );
469
470 /* compute length of the generic variable names:
471 * - nvars + 1 to avoid log of zero
472 * - +3 (zero at end + 'x' + 1 because we round down)
473 * Example: 10 -> needs 4 chars ("x10\0")
474 */
475 size = (int) log10(nvars+1.0) + 3;
476
477 for( i = 0; i < nvars; ++i )
478 {
479 var = vars[i];
480 varnames[i] = SCIPvarGetName(var);
481
482 SCIP_CALL( SCIPsetAllocBufferArray(set, &name, size) );
483 (void) SCIPsnprintf(name, size, "x%d", i + set->write_genoffset);
484 SCIPvarSetNamePointer(var, name);
485 }
486
487 /* compute length of the generic variable names */
488 size = (int) log10(nfixedvars+1.0) + 3;
489
490 for( i = 0; i < nfixedvars; ++i )
491 {
492 var = fixedvars[i];
493 fixedvarnames[i] = SCIPvarGetName(var);
494
495 SCIP_CALL( SCIPsetAllocBufferArray(set, &name, size) );
496 (void) SCIPsnprintf(name, size, "y%d", i);
497 SCIPvarSetNamePointer(var, name);
498 }
499
500 /* compute length of the generic constraint names */
501 size = (int) log10(nconss+1.0) + 3;
502
503 for( i = 0; i < nconss; ++i )
504 {
505 cons = conss[i];
506 consnames[i] = SCIPconsGetName(cons);
507
508 SCIP_CALL( SCIPsetAllocBufferArray(set, &name, size) );
509 (void) SCIPsnprintf(name, size, "c%d", i);
510 SCIPconsSetNamePointer(cons, name);
511 }
512 }
513
514 /* get exact objective offset and scale */
515 if( set->exact_enable )
516 {
517 SCIP_CALL( SCIPrationalCreateBuffer(SCIPbuffer(set->scip), &objoffsetexact) );
518 SCIP_CALL( SCIPrationalCreateBuffer(SCIPbuffer(set->scip), &objscaleexact) );
519
522
523 /* adapt exact objective scale for transformed problem (for the original no change is necessary) */
525 SCIPrationalMultReal(objscaleexact, objscaleexact, -1.0);
526 }
527 /* only real objective offset and scale */
528 else
529 {
530 objoffsetexact = NULL;
531 objscaleexact = NULL;
532 }
533
534 objoffset = SCIPprobGetObjoffset(prob);
535 objscale = SCIPprobGetObjscale(prob);
536
537 /* adapt real objective scale for transformed problem (for the original no change is necessary) */
539 objscale *= -1.0;
540
541 /* call reader to write problem */
542 retcode = reader->readerwrite(set->scip, reader, file, filename, SCIPprobGetName(prob), SCIPprobGetData(prob),
543 SCIPprobIsTransformed(prob), SCIPprobGetObjsense(prob), objoffset, objscale, objoffsetexact, objscaleexact,
544 vars, nvars, SCIPprobGetNBinVars(prob), SCIPprobGetNIntVars(prob), SCIPprobGetNImplVars(prob),
545 SCIPprobGetNContVars(prob), fixedvars, nfixedvars, SCIPprobGetStartNVars(prob), conss, nconss,
546 SCIPprobGetMaxNConss(prob), SCIPprobGetStartNConss(prob), genericnames, result);
547
548 if( objscaleexact != NULL )
549 SCIPrationalFreeBuffer(SCIPbuffer(set->scip), &objscaleexact);
550 if( objoffsetexact != NULL )
551 SCIPrationalFreeBuffer(SCIPbuffer(set->scip), &objoffsetexact);
552
553 /* reset variable and constraint names to original names */
554 if( genericnames )
555 {
556 assert(varnames != NULL);
557 assert(fixedvarnames != NULL);
558 assert(consnames != NULL);
559 for( i = nconss - 1; i >= 0; --i )
560 {
561 cons = conss[i];
562
563 /* get pointer to temporary generic name and free the memory */
564 consname = SCIPconsGetName(cons);
565 SCIPsetFreeBufferArray(set, &consname);
566
567 /* reset name */
568 SCIPconsSetNamePointer(cons, consnames[i]);
569 }
570
571 for( i = nfixedvars - 1; i >= 0; --i )
572 resetVarname(fixedvars[i], set, fixedvarnames[i]);
573
574 for( i = nvars - 1; i >= 0; --i )
575 resetVarname(vars[i], set, varnames[i]);
576
577 /* free memory */
578 SCIPsetFreeBufferArray(set, &consnames);
579 SCIPsetFreeBufferArray(set, &fixedvarnames);
580 SCIPsetFreeBufferArray(set, &varnames);
581 }
582
583 if( SCIPprobIsTransformed(prob) )
584 {
585 /* free memory */
587 }
588 }
589 else
590 {
591 *result = SCIP_DIDNOTRUN;
592 retcode = SCIP_OKAY;
593 }
594
595 /* check for reader errors */
596 if( retcode == SCIP_WRITEERROR )
597 return retcode;
598
599 SCIP_CALL( retcode );
600
601 return SCIP_OKAY;
602}
603
604/** gets user data of reader */
606 SCIP_READER* reader /**< reader */
607 )
608{
609 assert(reader != NULL);
610
611 return reader->readerdata;
612}
613
614/** sets user data of reader; user has to free old data in advance! */
616 SCIP_READER* reader, /**< reader */
617 SCIP_READERDATA* readerdata /**< new reader user data */
618 )
619{
620 assert(reader != NULL);
621
622 reader->readerdata = readerdata;
623}
624
625/** sets copy method of reader */
627 SCIP_READER* reader, /**< reader */
628 SCIP_DECL_READERCOPY ((*readercopy)) /**< copy method of reader or NULL if you don't want to copy your plugin into sub-SCIPs */
629 )
630{
631 assert(reader != NULL);
632
633 reader->readercopy = readercopy;
634}
635
636/** sets destructor of reader */
638 SCIP_READER* reader, /**< reader */
639 SCIP_DECL_READERFREE ((*readerfree)) /**< destructor of reader */
640 )
641{
642 assert(reader != NULL);
643
644 reader->readerfree = readerfree;
645}
646
647/** sets read method of reader */
649 SCIP_READER* reader, /**< reader */
650 SCIP_DECL_READERREAD ((*readerread)) /**< read method */
651 )
652{
653 assert(reader != NULL);
654
655 reader->readerread = readerread;
656}
657
658/** sets write method of reader */
660 SCIP_READER* reader, /**< reader */
661 SCIP_DECL_READERWRITE ((*readerwrite)) /**< write method */
662 )
663{
664 assert(reader != NULL);
665
666 reader->readerwrite = readerwrite;
667}
668
669/** marks the reader as safe to use in exact solving mode */
671 SCIP_READER* reader /**< reader */
672 )
673{
674 assert(reader != NULL);
675
676 reader->exact = TRUE;
677}
678
679/** gets name of reader */
681 SCIP_READER* reader /**< reader */
682 )
683{
684 assert(reader != NULL);
685
686 return reader->name;
687}
688
689/** gets description of reader */
691 SCIP_READER* reader /**< reader */
692 )
693{
694 assert(reader != NULL);
695
696 return reader->desc;
697}
698
699/** gets file extension of reader */
701 SCIP_READER* reader /**< reader */
702 )
703{
704 assert(reader != NULL);
705
706 return reader->extension;
707}
708
709/** return whether the reader can read files */
711 SCIP_READER* reader /**< reader */
712 )
713{
714 assert(reader != NULL);
715
716 return (reader->readerread != NULL);
717}
718
719/** return whether the reader can write files */
721 SCIP_READER* reader /**< reader */
722 )
723{
724 assert(reader != NULL);
725
726 return (reader->readerwrite != NULL);
727}
728
729/** gets time in seconds used in this reader for reading */
731 SCIP_READER* reader /**< reader */
732 )
733{
734 assert(reader != NULL);
735
736 return SCIPclockGetTime(reader->readingtime);
737}
738
739/** enables or disables all clocks of \p reader, depending on the value of the flag */
741 SCIP_READER* reader, /**< the reader for which all clocks should be enabled or disabled */
742 SCIP_Bool enable /**< should the clocks be enabled? */
743 )
744{
745 assert(reader != NULL);
746
747 SCIPclockEnableOrDisable(reader->readingtime, enable);
748}
749
750/** resets reading time of reader */
752 SCIP_READER* reader /**< reader */
753 )
754{
755 assert(reader != NULL);
756
757 /* reset reading time/clock */
759
760 return SCIP_OKAY;
761}
762
SCIP_DECL_READERREAD(ReaderTSP::scip_read)
Definition: ReaderTSP.cpp:211
SCIP_DECL_READERWRITE(ReaderTSP::scip_write)
Definition: ReaderTSP.cpp:546
SCIP_DECL_READERFREE(ReaderTSP::scip_free)
Definition: ReaderTSP.cpp:198
void SCIPclockSetTime(SCIP_CLOCK *clck, SCIP_Real sec)
Definition: clock.c:539
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:360
SCIP_Bool SCIPclockIsRunning(SCIP_CLOCK *clck)
Definition: clock.c:427
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
Definition: clock.c:260
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:290
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:438
void SCIPclockReset(SCIP_CLOCK *clck)
Definition: clock.c:209
void SCIPclockFree(SCIP_CLOCK **clck)
Definition: clock.c:185
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
Definition: clock.c:170
internal methods for clocks and timing issues
void SCIPconsSetNamePointer(SCIP_CONS *cons, const char *name)
Definition: cons.c:7007
internal methods for constraints and constraint handlers
common defines and data types used in all packages of SCIP
#define NULL
Definition: def.h:248
#define SCIP_Bool
Definition: def.h:91
#define SCIP_ALLOC(x)
Definition: def.h:366
#define SCIP_Real
Definition: def.h:156
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define SCIP_CALL(x)
Definition: def.h:355
#define SCIP_CALL_FINALLY(x, y)
Definition: def.h:397
SCIP_CONS ** SCIPconshdlrGetEnfoConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4745
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4778
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4316
int SCIPconshdlrGetNEnfoConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4788
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4735
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8389
BMS_BUFMEM * SCIPbuffer(SCIP *scip)
Definition: scip_mem.c:72
void SCIPrationalFreeBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:473
SCIP_RETCODE SCIPrationalCreateBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:123
void SCIPrationalSetRational(SCIP_RATIONAL *res, SCIP_RATIONAL *src)
Definition: rational.cpp:569
void SCIPrationalMultReal(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_Real op2)
Definition: rational.cpp:1097
SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
Definition: reader.c:605
const char * SCIPreaderGetExtension(SCIP_READER *reader)
Definition: reader.c:700
void SCIPreaderSetData(SCIP_READER *reader, SCIP_READERDATA *readerdata)
Definition: reader.c:615
const char * SCIPreaderGetName(SCIP_READER *reader)
Definition: reader.c:680
SCIP_Bool SCIPreaderCanRead(SCIP_READER *reader)
Definition: reader.c:710
SCIP_Bool SCIPreaderCanWrite(SCIP_READER *reader)
Definition: reader.c:720
void SCIPreaderMarkExact(SCIP_READER *reader)
Definition: reader.c:670
const char * SCIPreaderGetDesc(SCIP_READER *reader)
Definition: reader.c:690
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:23267
int SCIPstrcasecmp(const char *s1, const char *s2)
Definition: misc.c:10863
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10827
memory allocation routines
#define BMSfreeMemory(ptr)
Definition: memory.h:145
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:143
#define BMSclearMemory(ptr)
Definition: memory.h:129
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:148
#define BMSallocMemory(ptr)
Definition: memory.h:118
void SCIPmessageFPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:451
int SCIPprobGetNContVars(SCIP_PROB *prob)
Definition: prob.c:2904
SCIP_CONS ** SCIPprobGetConss(SCIP_PROB *prob)
Definition: prob.c:2958
int SCIPprobGetNFixedVars(SCIP_PROB *prob)
Definition: prob.c:2922
const char * SCIPprobGetName(SCIP_PROB *prob)
Definition: prob.c:2859
SCIP_Real SCIPprobGetObjoffset(SCIP_PROB *prob)
Definition: prob.c:2994
int SCIPprobGetNConss(SCIP_PROB *prob)
Definition: prob.c:2949
int SCIPprobGetStartNConss(SCIP_PROB *prob)
Definition: prob.c:2976
SCIP_RATIONAL * SCIPprobGetObjoffsetExact(SCIP_PROB *prob)
Definition: prob.c:3014
SCIP_OBJSENSE SCIPprobGetObjsense(SCIP_PROB *prob)
Definition: prob.c:2985
int SCIPprobGetStartNVars(SCIP_PROB *prob)
Definition: prob.c:2940
SCIP_Real SCIPprobGetObjscale(SCIP_PROB *prob)
Definition: prob.c:3004
SCIP_VAR * SCIPprobFindVar(SCIP_PROB *prob, const char *name)
Definition: prob.c:2626
int SCIPprobGetNImplVars(SCIP_PROB *prob)
Definition: prob.c:2895
SCIP_VAR ** SCIPprobGetFixedVars(SCIP_PROB *prob)
Definition: prob.c:2931
SCIP_CONS * SCIPprobFindCons(SCIP_PROB *prob, const char *name)
Definition: prob.c:2645
int SCIPprobGetNIntVars(SCIP_PROB *prob)
Definition: prob.c:2886
int SCIPprobGetNVars(SCIP_PROB *prob)
Definition: prob.c:2868
SCIP_PROBDATA * SCIPprobGetData(SCIP_PROB *prob)
Definition: prob.c:2849
int SCIPprobGetMaxNConss(SCIP_PROB *prob)
Definition: prob.c:2967
int SCIPprobGetNBinVars(SCIP_PROB *prob)
Definition: prob.c:2877
SCIP_RATIONAL * SCIPprobGetObjscaleExact(SCIP_PROB *prob)
Definition: prob.c:3025
SCIP_VAR ** SCIPprobGetVars(SCIP_PROB *prob)
Definition: prob.c:2913
SCIP_Bool SCIPprobIsTransformed(SCIP_PROB *prob)
Definition: prob.c:2803
internal methods for storing and manipulating the main problem
public methods for managing constraints
public methods for message output
#define SCIPerrorMessage
Definition: pub_message.h:64
public data structures and miscellaneous methods
public methods for problem variables
SCIP_RETCODE SCIPreaderFree(SCIP_READER **reader, SCIP_SET *set)
Definition: reader.c:139
void SCIPreaderSetFree(SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
Definition: reader.c:637
void SCIPreaderSetCopy(SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: reader.c:626
SCIP_RETCODE SCIPreaderWrite(SCIP_READER *reader, SCIP_PROB *prob, SCIP_SET *set, SCIP_MESSAGEHDLR *msghdlr, FILE *file, const char *filename, const char *format, SCIP_Bool genericnames, SCIP_RESULT *result)
Definition: reader.c:277
static SCIP_Bool readerIsApplicable(SCIP_READER *reader, const char *extension)
Definition: reader.c:170
SCIP_Real SCIPreaderGetReadingTime(SCIP_READER *reader)
Definition: reader.c:730
SCIP_RETCODE SCIPreaderCopyInclude(SCIP_READER *reader, SCIP_SET *set)
Definition: reader.c:57
SCIP_RETCODE SCIPreaderRead(SCIP_READER *reader, SCIP_SET *set, const char *filename, const char *extension, SCIP_RESULT *result)
Definition: reader.c:183
void SCIPreaderSetWrite(SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
Definition: reader.c:659
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:113
static SCIP_RETCODE doReaderCreate(SCIP_READER **reader, 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:76
SCIP_RETCODE SCIPreaderResetReadingTime(SCIP_READER *reader)
Definition: reader.c:751
void SCIPreaderEnableOrDisableClocks(SCIP_READER *reader, SCIP_Bool enable)
Definition: reader.c:740
static void resetVarname(SCIP_VAR *var, SCIP_SET *set, const char *name)
Definition: reader.c:256
void SCIPreaderSetRead(SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: reader.c:648
internal methods for input file readers
public methods for memory management
internal methods for global SCIP settings
#define SCIPsetFreeBufferArray(set, ptr)
Definition: set.h:1782
#define SCIPsetAllocBufferArray(set, ptr, num)
Definition: set.h:1775
#define SCIPsetDebugMsg
Definition: set.h:1811
const char * desc
Definition: struct_reader.h:48
const char * extension
Definition: struct_reader.h:49
SCIP_READERDATA * readerdata
Definition: struct_reader.h:54
const char * name
Definition: struct_reader.h:47
SCIP_CLOCK * readingtime
Definition: struct_reader.h:55
SCIP_Bool exact
Definition: struct_reader.h:56
datastructures for input file readers
Definition: heur_padm.c:135
@ SCIP_CLOCKTYPE_DEFAULT
Definition: type_clock.h:43
@ SCIP_OBJSENSE_MAXIMIZE
Definition: type_prob.h:47
struct SCIP_ReaderData SCIP_READERDATA
Definition: type_reader.h:54
#define SCIP_DECL_READERCOPY(x)
Definition: type_reader.h:63
@ SCIP_DIDNOTRUN
Definition: type_result.h:42
@ SCIP_SUCCESS
Definition: type_result.h:58
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
@ SCIP_NOFILE
Definition: type_retcode.h:47
@ SCIP_READERROR
Definition: type_retcode.h:45
@ SCIP_WRITEERROR
Definition: type_retcode.h:46
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
void SCIPvarSetNamePointer(SCIP_VAR *var, const char *name)
Definition: var.c:9102
internal methods for problem variables