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