Scippy

GCG

Branch-and-Price & Column Generation for Everyone

reader_blk.cpp
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* GCG --- Generic Column Generation */
5/* a Dantzig-Wolfe decomposition based extension */
6/* of the branch-cut-and-price framework */
7/* SCIP --- Solving Constraint Integer Programs */
8/* */
9/* Copyright (C) 2010-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file reader_blk.cpp
30 * @brief BLK file reader for structure information
31 * @author Gerald Gamrath
32 * @author Martin Bergner
33 * @author Christian Puchert
34 *
35 * This reader reads in a blk-file that defines the structur to be used for the decomposition.
36 * The structure is defined variable-wise, i.e., the number of blocks and the variables belonging to each block are
37 * defined. Afterwards, each constraint that has only variables of one block is added to that block,
38 * constraints having variables of more than one block go into the master. If needed, constraints can also be
39 * forced into the master, even if they could be transferred to one block.
40 *
41 * The keywords are:
42 * - Presolved: to be followed by either 0 or 1 indicating that the decomposition is for the presolved or unpresolved problem
43 * - NBlocks: to be followed by a line giving the number of blocks
44 * - Block i with 1 <= i <= nblocks: to be followed by the names of the variables belonging to block i, one per line.
45 * - Masterconss: to be followed by names of constraints, one per line, that should go into the master,
46 * even if they only contain variables of one block and could thus be added to this block.
47 */
48
49/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
50
51#include <stdlib.h>
52#include <assert.h>
53#include <string.h>
54#include <ctype.h>
55
56#include "gcg/reader_blk.h"
57#include "gcg/relax_gcg.h"
58#include "gcg/pub_gcgvar.h"
59#include "gcg/pub_decomp.h"
60#include "gcg/cons_decomp.h"
61#include "gcg/cons_decomp.hpp"
62#include "gcg/scip_misc.h"
64
65#define READER_NAME "blkreader"
66#define READER_DESC "file reader for structures in blk format"
67#define READER_EXTENSION "blk"
68
69/*
70 * Data structures
71 */
72#define BLK_MAX_LINELEN 65536
73#define BLK_MAX_PUSHEDTOKENS 2
74
75/** section in BLK File */
77{
79};
81
82/** exponent indicator of the a value */
84{
86};
88
89
90/** BLK reading data */
92{
93 SCIP_FILE* file; /**< file to read */
94 char linebuf[BLK_MAX_LINELEN]; /**< line buffer */
95 char* token; /**< current token */
96 char* tokenbuf; /**< token buffer */
97 char* pushedtokens[BLK_MAX_PUSHEDTOKENS]; /**< token stack */
98 int npushedtokens; /**< size of token buffer */
99 int linenumber; /**< current line number */
100 int linepos; /**< current line position (column) */
101 SCIP_Bool presolved; /**< does the decomposition refer to the presolved problem? */
102 SCIP_Bool haspresolvesection; /**< does the decomposition have a presolved section */
103 int nblocks; /**< number of blocks */
104 int blocknr; /**< number of the currentblock between 0 and Nblocks-1*/
105 BLKSECTION section; /**< current section */
106 SCIP_Bool haserror; /**< flag to indicate an error occurence */
107};
108typedef struct BlkInput BLKINPUT;
109
110/** data for blk reader */
112{
113 GCG* gcg; /**< GCG data structure */
114 int* varstoblock; /**< index=varid; value= -1 or blockID or -2 for multipleblocks */
115 int* nblockvars; /**< number of variable per block that are not linkingvars */
116 int** linkingvarsblocks; /**< array with blocks assigned to one linking var */
117 int* nlinkingvarsblocks; /**< array with number of blocks assigned to each linking var */
118 SCIP_HASHMAP* constoblock; /**< hashmap key=constaint value=block*/
119 SCIP_CONS*** blockcons; /**< array of assignments from constraints to their blocks [blocknr][consid] */
120 int* nblockcons; /**< number of block-constraints for blockID*/
121 int nlinkingcons; /**< number of linking constraints*/
122 int nlinkingvars; /**< number of linking vars*/
123};
124
125static const int NOVALUE = -1;
126static const int LINKINGVALUE = -2;
127static const char delimchars[] = " \f\n\r\t\v";
128static const char tokenchars[] = "-+:<>=";
129static const char commentchars[] = "\\";
130
131
132
133
134/*
135 * Local methods (for reading)
136 */
137
138/** issues an error message and marks the BLK data to have errors */
139static
141 SCIP* scip, /**< SCIP data structure */
142 BLKINPUT* blkinput, /**< BLK reading data */
143 const char* msg /**< error message */
144 )
145{
146 char formatstr[256];
147
148 assert(blkinput != NULL);
149
150 SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, "Syntax error in line %d: %s ('%s')\n",
151 blkinput->linenumber, msg, blkinput->token);
152 if( blkinput->linebuf[strlen(blkinput->linebuf)-1] == '\n' )
153 {
154 SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, " input: %s", blkinput->linebuf);
155 }
156 else
157 {
158 SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, " input: %s\n", blkinput->linebuf);
159 }
160 (void) SCIPsnprintf(formatstr, 256, " %%%ds\n", blkinput->linepos);
162 blkinput->section = BLK_END;
163 blkinput->haserror = TRUE;
164}
165
166/** returns whether a syntax error was detected */
167static
169 BLKINPUT* blkinput /**< BLK reading data */
170 )
171{
172 assert(blkinput != NULL);
173
174 return blkinput->haserror;
175}
176
177/** returns whether the given character is a token delimiter */
178static
180 char c /**< input character */
181 )
182{
183 return (c == '\0') || (strchr(delimchars, c) != NULL);
184}
185
186/** returns whether the given character is a single token */
187static
189 char c /**< input character */
190 )
191{
192 return (strchr(tokenchars, c) != NULL);
193}
194
195/** returns whether the current character is member of a value string */
196static
198 char c, /**< input character */
199 char nextc, /**< next input character */
200 SCIP_Bool firstchar, /**< is the given character the first char of the token? */
201 SCIP_Bool* hasdot, /**< pointer to update the dot flag */
202 BLKEXPTYPE* exptype /**< pointer to update the exponent type */
203 )
204{
205 assert(hasdot != NULL);
206 assert(exptype != NULL);
207
208 if( isdigit(c) )
209 return TRUE;
210 else if( (*exptype == BLK_EXP_NONE) && !(*hasdot) && (c == '.') )
211 {
212 *hasdot = TRUE;
213 return TRUE;
214 }
215 else if( !firstchar && (*exptype == BLK_EXP_NONE) && (c == 'e' || c == 'E') )
216 {
217 if( nextc == '+' || nextc == '-' )
218 {
219 *exptype = BLK_EXP_SIGNED;
220 return TRUE;
221 }
222 else if( isdigit(nextc) )
223 {
224 *exptype = BLK_EXP_UNSIGNED;
225 return TRUE;
226 }
227 }
228 else if( (*exptype == BLK_EXP_SIGNED) && (c == '+' || c == '-') )
229 {
230 *exptype = BLK_EXP_UNSIGNED;
231 return TRUE;
232 }
233
234 return FALSE;
235}
236
237/** reads the next line from the input file into the line buffer; skips comments;
238 * returns whether a line could be read
239 */
240static
242 BLKINPUT* blkinput /**< BLK reading data */
243 )
244{
245 int i;
246
247 assert(blkinput != NULL);
248
249 /* clear the line */
251
252 /* read next line */
253 blkinput->linepos = 0;
254 blkinput->linebuf[BLK_MAX_LINELEN-2] = '\0';
255 if( SCIPfgets(blkinput->linebuf, BLK_MAX_LINELEN, blkinput->file) == NULL )
256 return FALSE;
257 blkinput->linenumber++;
258 if( blkinput->linebuf[BLK_MAX_LINELEN-2] != '\0' )
259 {
260 SCIPerrorMessage("Error: line %d exceeds %d characters\n", blkinput->linenumber, BLK_MAX_LINELEN-2);
261 blkinput->haserror = TRUE;
262 return FALSE;
263 }
264 blkinput->linebuf[BLK_MAX_LINELEN-1] = '\0';
265 blkinput->linebuf[BLK_MAX_LINELEN-2] = '\0'; /* we want to use lookahead of one char -> we need two \0 at the end */
266
267 /* skip characters after comment symbol */
268 for( i = 0; commentchars[i] != '\0'; ++i )
269 {
270 char* commentstart;
271
272 commentstart = strchr(blkinput->linebuf, commentchars[i]);
273 if( commentstart != NULL )
274 {
275 *commentstart = '\0';
276 *(commentstart+1) = '\0'; /* we want to use lookahead of one char -> we need two \0 at the end */
277 }
278 }
279
280 return TRUE;
281}
282
283/** swaps the addresses of two pointers */
284static
286 char** pointer1, /**< first pointer */
287 char** pointer2 /**< second pointer */
288 )
289{
290 char* tmp;
291
292 tmp = *pointer1;
293 *pointer1 = *pointer2;
294 *pointer2 = tmp;
295}
296
297/** reads the next token from the input file into the token buffer; returns whether a token was read */
298static
300 BLKINPUT* blkinput /**< BLK reading data */
301 )
302{
303 SCIP_Bool hasdot;
304 BLKEXPTYPE exptype;
305 char* buf;
306 int tokenlen;
307
308 assert(blkinput != NULL);
309 assert(blkinput->linepos < BLK_MAX_LINELEN);
310
311 /* check the token stack */
312 if( blkinput->npushedtokens > 0 )
313 {
314 swapPointers(&blkinput->token, &blkinput->pushedtokens[blkinput->npushedtokens-1]);
315 blkinput->npushedtokens--;
316 SCIPdebugMessage("(line %d) read token again: '%s'\n", blkinput->linenumber, blkinput->token);
317 return TRUE;
318 }
319
320 /* skip delimiters */
321 buf = blkinput->linebuf;
322 while( isDelimChar(buf[blkinput->linepos]) )
323 {
324 if( buf[blkinput->linepos] == '\0' )
325 {
326 if( !getNextLine(blkinput) )
327 {
328 blkinput->section = BLK_END;
329 SCIPdebugMessage("(line %d) end of file\n", blkinput->linenumber);
330 return FALSE;
331 }
332 assert(blkinput->linepos == 0);
333 }
334 else
335 blkinput->linepos++;
336 }
337 assert(blkinput->linepos < BLK_MAX_LINELEN);
338 assert(!isDelimChar(buf[blkinput->linepos]));
339
340 /* check if the token is a value */
341 hasdot = FALSE;
342 exptype = BLK_EXP_NONE;
343 if( isValueChar(buf[blkinput->linepos], buf[blkinput->linepos+1], TRUE, &hasdot, &exptype) ) /*lint !e679*/
344 {
345 /* read value token */
346 tokenlen = 0;
347 do
348 {
349 assert(tokenlen < BLK_MAX_LINELEN);
350 assert(!isDelimChar(buf[blkinput->linepos]));
351 blkinput->token[tokenlen] = buf[blkinput->linepos];
352 ++tokenlen;
353 ++(blkinput->linepos);
354 assert(blkinput->linepos < BLK_MAX_LINELEN);
355 }
356 while( isValueChar(buf[blkinput->linepos], buf[blkinput->linepos+1], FALSE, &hasdot, &exptype) ); /*lint !e679*/
357 }
358 else
359 {
360 /* read non-value token */
361 tokenlen = 0;
362 do
363 {
364 assert(tokenlen < BLK_MAX_LINELEN);
365 blkinput->token[tokenlen] = buf[blkinput->linepos];
366 tokenlen++;
367 blkinput->linepos++;
368 if( tokenlen == 1 && isTokenChar(blkinput->token[0]) )
369 break;
370 }
371 while( !isDelimChar(buf[blkinput->linepos]) && !isTokenChar(buf[blkinput->linepos]) );
372
373 /* if the token is an equation sense '<', '>', or '=', skip a following '='
374 * if the token is an equality token '=' and the next character is a '<' or '>', replace the token by the inequality sense
375 */
376 if( tokenlen >= 1
377 && (blkinput->token[tokenlen-1] == '<' || blkinput->token[tokenlen-1] == '>' || blkinput->token[tokenlen-1] == '=')
378 && buf[blkinput->linepos] == '=' )
379 {
380 blkinput->linepos++;
381 }
382 else if( blkinput->token[tokenlen-1] == '=' && (buf[blkinput->linepos] == '<' || buf[blkinput->linepos] == '>') )
383 {
384 blkinput->token[tokenlen-1] = buf[blkinput->linepos];
385 blkinput->linepos++;
386 }
387 }
388 assert(tokenlen < BLK_MAX_LINELEN);
389 blkinput->token[tokenlen] = '\0';
390
391 SCIPdebugMessage("(line %d) read token: '%s'\n", blkinput->linenumber, blkinput->token);
392
393 return TRUE;
394}
395
396/** puts the current token on the token stack, such that it is read at the next call to getNextToken() */
397static
399 BLKINPUT* blkinput /**< BLK reading data */
400 )
401{
402 assert(blkinput != NULL);
403 assert(blkinput->npushedtokens < BLK_MAX_PUSHEDTOKENS);
404
405 swapPointers(&blkinput->pushedtokens[blkinput->npushedtokens], &blkinput->token);
406 blkinput->npushedtokens++;
407}
408
409/** swaps the current token with the token buffer */
410static
412 BLKINPUT* blkinput /**< BLK reading data */
413 )
414{
415 assert(blkinput != NULL);
416
417 swapPointers(&blkinput->token, &blkinput->tokenbuf);
418}
419
420/** returns whether the current token is a value */
421static
423 SCIP* scip, /**< SCIP data structure */
424 BLKINPUT* blkinput, /**< BLK reading data */
425 int* value /**< pointer to store the value (unchanged, if token is no value) */
426 )
427{
428 long val;
429 char* endptr;
430
431 assert(blkinput != NULL);
432 assert(value != NULL);
433 assert(!(SCIPstrcasecmp(blkinput->token, "INFINITY") == 0) && !(SCIPstrcasecmp(blkinput->token, "INF") == 0));
434
435 val = strtol(blkinput->token, &endptr, 0);
436 if( endptr != blkinput->token && *endptr == '\0' )
437 {
438 if(val < INT_MIN || val > INT_MAX ) /*lint !e685*/
439 return FALSE;
440
441 *value = (int) val;
442 return TRUE;
443 }
444
445 return FALSE;
446}
447
448/** checks whether the current token is a section identifier, and if yes, switches to the corresponding section */
449static
451 SCIP* scip, /**< SCIP data structure */
452 BLKINPUT* blkinput /**< BLK reading data */
453 )
454{
455 SCIP_Bool iscolon;
456
457 assert(blkinput != NULL);
458
459 /* remember first token by swapping the token buffer */
460 swapTokenBuffer(blkinput);
461
462 /* look at next token: if this is a ':', the first token is a name and no section keyword */
463 iscolon = FALSE;
464 if( getNextToken(blkinput) )
465 {
466 iscolon = (strcmp(blkinput->token, ":") == 0);
467 pushToken(blkinput);
468 }
469
470 /* reinstall the previous token by swapping back the token buffer */
471 swapTokenBuffer(blkinput);
472
473 /* check for ':' */
474 if( iscolon )
475 return FALSE;
476
477 if( SCIPstrcasecmp(blkinput->token, "PRESOLVED") == 0 )
478 {
479 SCIPdebugMessage("(line %d) new section: PRESOLVED\n", blkinput->linenumber);
480 blkinput->section = BLK_PRESOLVED;
481 return TRUE;
482 }
483
484 if( SCIPstrcasecmp(blkinput->token, "NBLOCKS") == 0 )
485 {
486 SCIPdebugMessage("(line %d) new section: NBLOCKS\n", blkinput->linenumber);
487 blkinput->section = BLK_NBLOCKS;
488 return TRUE;
489 }
490
491 if( SCIPstrcasecmp(blkinput->token, "BLOCK") == 0 )
492 {
493 int blocknr;
494
495 blkinput->section = BLK_BLOCK;
496
497 if( getNextToken(blkinput) )
498 {
499 /* read block number */
500 if( isInt(scip, blkinput, &blocknr) )
501 {
502 assert(blocknr >= 0);
503 assert(blocknr <= blkinput->nblocks);
504
505 blkinput->blocknr = blocknr-1;
506 }
507 else
508 syntaxError(scip, blkinput, "no block number after block keyword!\n");
509 }
510 else
511 syntaxError(scip, blkinput, "no block number after block keyword!\n");
512
513 SCIPdebugMessage("new section: BLOCK %d\n", blkinput->blocknr);
514
515 return TRUE;
516
517 }
518
519 if( SCIPstrcasecmp(blkinput->token, "MASTERCONSS") == 0 )
520 {
521 blkinput->section = BLK_MASTERCONSS;
522
523 SCIPdebugMessage("new section: MASTERCONSS\n");
524
525 return TRUE;
526 }
527
528 if( SCIPstrcasecmp(blkinput->token, "END") == 0 )
529 {
530 SCIPdebugMessage("(line %d) new section: END\n", blkinput->linenumber);
531 blkinput->section = BLK_END;
532 return TRUE;
533 }
534
535 return FALSE;
536}
537
538/** reads the header of the file */
539static
541 SCIP* scip, /**< SCIP data structure */
542 BLKINPUT* blkinput /**< BLK reading data */
543 )
544{
545 assert(blkinput != NULL);
546
547 /* everything before first section is treated as comment */
548 do
549 {
550 /* get token */
551 if( !getNextToken(blkinput) )
552 return SCIP_OKAY;
553 }
554 while( !isNewSection(scip, blkinput) );
555
556 return SCIP_OKAY;
557}
558
559/** reads the presolved section */
560static
562 SCIP* scip, /**< SCIP data structure */
563 BLKINPUT* blkinput /**< DEC reading data */
564 )
565{
566 int presolved;
567
568 assert(scip != NULL);
569 assert(blkinput != NULL);
570
571 while( getNextToken(blkinput) )
572 {
573 /* check if we reached a new section */
574 if( isNewSection(scip, blkinput) )
575 return SCIP_OKAY;
576
577 /* read number of blocks */
578 if( isInt(scip, blkinput, &presolved) )
579 {
580 blkinput->haspresolvesection = TRUE;
581 if( presolved == 1 )
582 blkinput->presolved = TRUE;
583 else if ( presolved == 0 )
584 blkinput->presolved = FALSE;
585 else
586 syntaxError(scip, blkinput, "presolved parameter must be 0 or 1");
587 SCIPdebugMessage("Decomposition is%s from presolved problem\n",
588 blkinput->presolved ? "" : " not");
589 }
590 }
591
592 return SCIP_OKAY;
593}
594
595/** reads the nblocks section */
596static
598 SCIP* scip, /**< SCIP data structure */
599 gcg::PARTIALDECOMP* partialdec, /**< partialdec to edit */
600 BLKINPUT* blkinput /**< BLK reading data */
601 )
602{
603 int nblocks;
604
605 assert(scip != NULL);
606 assert(blkinput != NULL);
607 assert(partialdec != NULL);
608
609 while( getNextToken(blkinput) )
610 {
611 /* check if we reached a new section */
612 if( isNewSection(scip, blkinput) )
613 {
614 if( blkinput->nblocks == NOVALUE )
615 syntaxError(scip, blkinput, "no integer value in nblocks section");
616 else
617 return SCIP_OKAY;
618 }
619
620 /* read number of blocks */
621 if( isInt(scip, blkinput, &nblocks) )
622 {
623 if( blkinput->nblocks == NOVALUE )
624 {
625 blkinput->nblocks = nblocks;
626 partialdec->setNBlocks(nblocks);
627 }
628 else
629 syntaxError(scip, blkinput, "2 integer values in nblocks section");
630 SCIPdebugMessage("Number of blocks = %d\n", blkinput->nblocks);
631 }
632 }
633
634 return SCIP_OKAY;
635}
636
637/** reads a block section */
638static
640 SCIP* scip, /**< SCIP data structure */
641 BLKINPUT* blkinput, /**< BLK reading data */
642 gcg::PARTIALDECOMP* partialdec, /**< partialdec to edit */
643 SCIP_READERDATA* readerdata /**< reader data */
644 )
645{
646 int blockid;
647
648 assert(blkinput != NULL);
649 assert(partialdec != NULL);
650
651 blockid = blkinput->blocknr;
652
653 while( getNextToken(blkinput) )
654 {
655 SCIP_VAR* var;
656 int varidx;
657 int oldblock;
658
659 /* check if we reached a new section */
660 if( isNewSection(scip, blkinput) )
661 return SCIP_OKAY;
662
663 /* the token must be the name of an existing variable */
664 var = SCIPfindVar(scip, blkinput->token);
665 if( var == NULL )
666 {
667 syntaxError(scip, blkinput, "unknown variable in block section");
668 return SCIP_OKAY;
669 }
670
671 varidx = SCIPvarGetProbindex(var);
672 oldblock = readerdata->varstoblock[varidx];
673
674 /* set the block number of the variable to the number of the current block */
675 if( oldblock == NOVALUE )
676 {
677 SCIPdebugMessage("\tVar %s temporary in block %d.\n", SCIPvarGetName(var), blockid);
678 readerdata->varstoblock[varidx] = blockid;
679 ++(readerdata->nblockvars[blockid]);
680 partialdec->fixVarToBlockByName(blkinput->token, blockid);
681 }
682 /* variable was assigned to another (non-linking) block before, so it becomes a linking variable, now */
683 else if( (oldblock != LINKINGVALUE) )
684 {
685 assert(oldblock != blockid);
686 SCIPdebugMessage("\tVar %s is linking (old %d != %d new).\n", SCIPvarGetName(var), oldblock, blockid);
687
688 readerdata->varstoblock[varidx] = LINKINGVALUE;
689
690 /* decrease the number of variables in the old block and increase the number of linking variables */
691 --(readerdata->nblockvars[oldblock]);
692 ++(readerdata->nlinkingvars);
693
694 assert(readerdata->nlinkingvarsblocks[varidx] == 0);
695 assert(readerdata->linkingvarsblocks[varidx] == NULL);
696 SCIP_CALL( SCIPallocMemoryArray(scip, &readerdata->linkingvarsblocks[varidx], 2) ); /*lint !e506 !e866*/
697 readerdata->linkingvarsblocks[varidx][0] = oldblock;
698 readerdata->linkingvarsblocks[varidx][1] = blockid;
699 readerdata->nlinkingvarsblocks[varidx] = 2;
700
701 partialdec->fixVarToLinkingByName(blkinput->token);
702 }
703 /* variable is a linking variable already, store the new block to which it belongs */
704 else
705 {
706 assert(oldblock == LINKINGVALUE);
707 assert(readerdata->nlinkingvarsblocks[varidx] >= 2);
708 assert(readerdata->linkingvarsblocks[varidx] != NULL);
709 SCIP_CALL( SCIPreallocMemoryArray(scip, &readerdata->linkingvarsblocks[varidx], (size_t) readerdata->nlinkingvarsblocks[varidx] + 1) ); /*lint !e866*/
710 readerdata->linkingvarsblocks[varidx][readerdata->nlinkingvarsblocks[varidx]] = blockid;
711 ++(readerdata->nlinkingvarsblocks[varidx]);
712 }
713 }
714
715 return SCIP_OKAY;
716}
717
718/** reads the masterconss section */
719static
721 SCIP* scip, /**< SCIP data structure */
722 BLKINPUT* blkinput, /**< BLK reading data */
723 gcg::PARTIALDECOMP* partialdec, /**< PARTIALDECOMP to edit */
724 SCIP_READERDATA* readerdata /**< reader data */
725 )
726{
727 assert(blkinput != NULL);
728 assert(partialdec != NULL);
729
730 while( getNextToken(blkinput) )
731 {
732 SCIP_CONS* cons;
733
734 /* check if we reached a new section */
735 if( isNewSection(scip, blkinput) )
736 return SCIP_OKAY;
737
738 /* the token must be the name of an existing constraint */
739 cons = SCIPfindCons(scip, blkinput->token);
740 if( cons == NULL )
741 {
742 syntaxError(scip, blkinput, "unknown constraint in masterconss section");
743 return SCIP_OKAY;
744 }
745 else
746 {
747 assert(SCIPhashmapGetImage(readerdata->constoblock, cons) == (void*) (size_t) NOVALUE);
748 SCIP_CALL( SCIPhashmapSetImage(readerdata->constoblock, cons, (void*) (size_t) (blkinput->nblocks +1)) );
749 partialdec->fixConsToMasterByName(blkinput->token);
750 }
751 }
752
753 return SCIP_OKAY;
754}
755
756/** fills the whole Decomp struct after the blk file has been read */
757static
759 SCIP* scip, /**< SCIP data structure */
760 BLKINPUT* blkinput, /**< blk reading data */
761 GCG_DECOMP* decomp, /**< GCG_DECOMP structure to fill */
762 gcg::PARTIALDECOMP* partialdec, /**< partialdec to fill for internal handling */
763 SCIP_READERDATA* readerdata /**< reader data*/
764 )
765{
766 SCIP_HASHMAP* constoblock = NULL;
767 SCIP_CONS** allcons = NULL;
768 SCIP_VAR** allvars = NULL;
769
770 SCIP_VAR** consvars = NULL;
771 SCIP_RETCODE retcode;
772 int i;
773 int j;
774 int nvars;
775 int blocknr;
776 int nconss;
777 int nblocks;
778
779 assert(scip != NULL);
780 assert(blkinput != NULL);
781 assert(readerdata != NULL);
782 assert(partialdec != NULL);
783
784 allcons = SCIPgetConss(scip);
785 allvars = SCIPgetVars(scip);
786 nvars = SCIPgetNVars(scip);
787 nconss = SCIPgetNConss(scip);
788 nblocks = blkinput->nblocks;
789
790 GCGdecompSetPresolved(decomp, blkinput->presolved);
791 GCGdecompSetNBlocks(decomp, nblocks);
792 GCGdecompSetDetector(decomp, NULL);
793
795
796 /* hashmaps */
797 SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(scip), nconss) );
798 SCIP_CALL( SCIPallocMemoryArray(scip, &consvars, nvars) );
799
800 /* assign unassigned variables as master variables */
801 for( i = 0; i < nvars; ++i)
802 {
803 SCIP_VAR* var;
804 var = allvars[i];
805 if( readerdata->varstoblock[i] == NOVALUE )
806 {
807 partialdec->fixVarToMasterByName(SCIPvarGetName(var));
808 }
809 }
810
811 /* assign constraints to blocks or declare them linking */
812 for( i = 0; i < nconss; ++i )
813 {
814 SCIP_CONS* cons;
815
816 cons = allcons[i];
817
818 if( SCIPhashmapGetImage(readerdata->constoblock, cons) == (void*) (size_t) LINKINGVALUE )
819 {
820 SCIP_CALL( SCIPhashmapInsert(constoblock, cons, (void*) (size_t) (nblocks+1)) );
821
822 SCIPdebugMessage("cons %s is linking\n", SCIPconsGetName(cons));
823 }
824 /* check whether all variables in the constraint belong to one block */
825 else
826 {
827 int nconsvars;
828
829 nconsvars = GCGconsGetNVars(scip, cons);
830 assert(nconsvars < nvars);
831
832 SCIP_CALL( GCGconsGetVars(scip, cons, consvars, nvars) );
833
834 blocknr = -1;
835
836 /* find the first unique assignment of a contained variable to a block */
837 for( j = 0; j < nconsvars; ++j )
838 {
839 /* if a contained variable is directly transferred to the master, the constraint is a linking constraint */
840 if( readerdata->varstoblock[SCIPvarGetProbindex(consvars[j])] == NOVALUE )
841 {
842 blocknr = -1;
843 break;
844 }
845 /* assign the constraint temporarily to the block of the variable, if it is unique */
846 if( blocknr == -1 && readerdata->varstoblock[SCIPvarGetProbindex(consvars[j])] != LINKINGVALUE )
847 {
848 blocknr = readerdata->varstoblock[SCIPvarGetProbindex(consvars[j])];
849 }
850 }
851 if( blocknr != -1 )
852 {
853 /* check whether all contained variables are copied into the assigned block;
854 * if not, the constraint is treated as a linking constraint
855 */
856 for( j = 0; j < nconsvars; ++j )
857 {
858 int varidx = SCIPvarGetProbindex(consvars[j]);
859 int varblock = readerdata->varstoblock[varidx];
860 assert(varblock != NOVALUE);
861
862 if( varblock != LINKINGVALUE && varblock != blocknr )
863 {
864 blocknr = -1;
865 break;
866 }
867 else if( varblock == LINKINGVALUE )
868 {
869 int k;
870
871 for( k = 0; k < readerdata->nlinkingvarsblocks[varidx]; ++k )
872 {
873 if( readerdata->linkingvarsblocks[varidx][k] == blocknr )
874 break;
875 }
876 /* we did not break, so the variable is not assigned to the block */
877 if( k == readerdata->nlinkingvarsblocks[varidx] )
878 {
879 blocknr = -1;
880 break;
881 }
882 }
883 }
884 }
885
886 if( blocknr == -1 )
887 {
888 SCIP_CALL( SCIPhashmapInsert(constoblock, cons, (void*) (size_t) (nblocks+1)) );
889 partialdec->fixConsToMasterByName(SCIPconsGetName(cons));
890
891 SCIPdebugMessage("constraint <%s> is a linking constraint\n",
892 SCIPconsGetName(cons));
893 }
894 else
895 {
896 SCIP_CALL( SCIPhashmapInsert(constoblock, cons, (void*) (size_t) (blocknr+1)) );
897 partialdec->fixConsToBlockByName(SCIPconsGetName(cons), blocknr);
898 SCIPdebugMessage("constraint <%s> is assigned to block %d\n", SCIPconsGetName(cons), blocknr);
899 }
900 }
901 }
902
903 SCIPinfoMessage(scip, NULL, "just read blk file:\n");
904
905 retcode = GCGfilloutDecompFromConstoblock(readerdata->gcg, decomp, constoblock, nblocks, FALSE);
906 SCIPfreeMemoryArray(scip, &consvars);
907
908 return retcode;
909}
910
911/** reads an BLK file */
912static
914 SCIP* scip, /**< SCIP data structure */
915 SCIP_READER* reader, /**< reader data structure */
916 BLKINPUT* blkinput, /**< BLK reading data */
917 const char* filename /**< name of the input file */
918 )
919{
920 SCIP_RETCODE retcode = SCIP_ERROR;
921 GCG_DECOMP *decdecomp;
922 int i;
923 int nconss;
924 int nblocksread;
925 int nvars;
926 SCIP_READERDATA* readerdata;
927 SCIP_CONS** conss;
928 nblocksread = FALSE;
929
930 assert(scip != NULL);
931 assert(reader != NULL);
932 assert(blkinput != NULL);
933
936
937 readerdata = SCIPreaderGetData(reader);
938 assert(readerdata != NULL);
939
940 readerdata->nlinkingcons = SCIPgetNConss(scip);
941 readerdata->nlinkingvars = 0;
942 nvars = SCIPgetNVars(scip);
943 conss = SCIPgetConss(scip);
944 nconss = SCIPgetNConss(scip);
945
946 /* alloc: var -> block mapping */
947 SCIP_CALL( SCIPallocMemoryArray(scip, &readerdata->varstoblock, nvars) );
948 for( i = 0; i < nvars; i ++ )
949 {
950 readerdata->varstoblock[i] = NOVALUE;
951 }
952
953 /* alloc: linkingvar -> blocks mapping */
954 SCIP_CALL( SCIPallocMemoryArray(scip, &readerdata->linkingvarsblocks, nvars) );
955 SCIP_CALL( SCIPallocMemoryArray(scip, &readerdata->nlinkingvarsblocks, nvars) );
956 BMSclearMemoryArray(readerdata->linkingvarsblocks, nvars);
957 BMSclearMemoryArray(readerdata->nlinkingvarsblocks, nvars);
958
959 /* cons -> block mapping */
960 SCIP_CALL( SCIPhashmapCreate(&readerdata->constoblock, SCIPblkmem(scip), nconss) );
961 for( i = 0; i < SCIPgetNConss(scip); i ++ )
962 {
963 SCIP_CALL( SCIPhashmapInsert(readerdata->constoblock, conss[i], (void*)(size_t) NOVALUE) );
964 }
965
966 /* open file */
967 blkinput->file = SCIPfopen(filename, "r");
968 if( blkinput->file == NULL )
969 {
970 SCIPerrorMessage("cannot open file <%s> for reading\n", filename);
971 SCIPprintSysError(filename);
972 return SCIP_NOFILE;
973 }
974
975 /* parse the file */
976 blkinput->section = BLK_START;
977 gcg::PARTIALDECOMP* newpartialdec = NULL;
978 while( blkinput->section != BLK_END && !hasError(blkinput) )
979 {
980 switch( blkinput->section )
981 {
982 case BLK_START:
983 SCIP_CALL( readStart(scip, blkinput) );
984 break;
985
986 case BLK_PRESOLVED:
987 SCIP_CALL( readPresolved(scip, blkinput) );
988 if( blkinput->presolved && SCIPgetStage(scip) < SCIP_STAGE_PRESOLVED )
989 {
991 assert(blkinput->haspresolvesection);
992
993 /** @bug GCG should be able to presolve the problem first */
994
995 // SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, "decomposition belongs to the presolved problem, please presolve the problem first.\n");
996 }
997 break;
998
999 case BLK_NBLOCKS:
1000 if( blkinput->haspresolvesection )
1001 {
1002 newpartialdec = new gcg::PARTIALDECOMP(readerdata->gcg, !blkinput->presolved);
1004 }
1005 SCIP_CALL( readNBlocks(scip, newpartialdec, blkinput) );
1006 if( blkinput->haspresolvesection && !blkinput->presolved && SCIPgetStage(scip) >= SCIP_STAGE_PRESOLVED )
1007 {
1008 SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, "decomposition belongs to the original problem, please re-read the problem and read the decomposition without presolving.\n");
1009 goto TERMINATE;
1010 }
1011 if( !blkinput->haspresolvesection )
1012 {
1013 SCIPwarningMessage(scip, "decomposition has no presolve section at beginning. It is assumed to belong to the unpresolved problem but the behaviour is undefined. See the FAQ for further information.\n");
1014 blkinput->presolved = FALSE;
1015 newpartialdec = new gcg::PARTIALDECOMP(readerdata->gcg, !blkinput->presolved);
1017 }
1018
1019 break;
1020
1021 case BLK_BLOCK:
1022 if( nblocksread == FALSE )
1023 {
1024 /* alloc n vars per block */
1025 SCIP_CALL( SCIPallocMemoryArray(scip, &readerdata->nblockvars, blkinput->nblocks) );
1026 SCIP_CALL( SCIPallocMemoryArray(scip, &readerdata->nblockcons, blkinput->nblocks) );
1027 SCIP_CALL( SCIPallocMemoryArray(scip, &readerdata->blockcons, blkinput->nblocks) );
1028 for( i = 0; i < blkinput->nblocks; ++i )
1029 {
1030 readerdata->nblockvars[i] = 0;
1031 readerdata->nblockcons[i] = 0;
1032 SCIP_CALL( SCIPallocMemoryArray(scip, &(readerdata->blockcons[i]), nconss) ); /*lint !e866*/
1033 }
1034 nblocksread = TRUE;
1035 }
1036 SCIP_CALL( readBlock(scip, blkinput, newpartialdec, readerdata) );
1037 break;
1038
1039 case BLK_MASTERCONSS:
1040 SCIP_CALL( readMasterconss(scip, blkinput, newpartialdec, readerdata) );
1041 break;
1042
1043 case BLK_END: /* this is already handled in the while() loop */
1044 default:
1045 SCIPerrorMessage("invalid BLK file section <%d>\n", blkinput->section);
1046 return SCIP_INVALIDDATA;
1047 }
1048 }
1049
1050 SCIP_CALL( GCGdecompCreate(readerdata->gcg, &decdecomp) );
1051
1052 /* fill decomp */
1053 retcode = fillDecompStruct(scip, blkinput, decdecomp, newpartialdec, readerdata);
1054
1055 GCGconshdlrDecompAddPreexisitingPartialDec(readerdata->gcg, newpartialdec);
1056
1057 SCIP_CALL( GCGdecompFree(readerdata->gcg, &decdecomp) );
1058
1059 for( i = 0; i < nvars; ++i )
1060 {
1061 assert(readerdata->linkingvarsblocks[i] != NULL || readerdata->nlinkingvarsblocks[i] == 0);
1062 if( readerdata->nlinkingvarsblocks[i] > 0 )
1063 {
1064 SCIPfreeMemoryArray(scip, &readerdata->linkingvarsblocks[i]);
1065 }
1066 }
1067
1068 TERMINATE:
1069 if( nblocksread )
1070 {
1071 for( i = blkinput->nblocks - 1; i >= 0; --i )
1072 {
1073 SCIPfreeMemoryArray(scip, &(readerdata->blockcons[i]));
1074 }
1075 SCIPfreeMemoryArray(scip, &readerdata->blockcons);
1076 SCIPfreeMemoryArray(scip, &readerdata->nblockcons);
1077 SCIPfreeMemoryArray(scip, &readerdata->nblockvars);
1078 }
1079
1080 SCIPhashmapFree(&readerdata->constoblock);
1081
1084 SCIPfreeMemoryArray(scip, &readerdata->varstoblock);
1085
1086 /* close file */
1087 SCIPfclose(blkinput->file);
1088
1089 return retcode;
1090}
1091
1092/* reads problem from file */
1093static
1095 SCIP* scip, /**< SCIP data structure */
1096 const char* filename, /**< full path and name of file to read, or NULL if stdin should be used */
1097 SCIP_RESULT* result /**< pointer to store the result of the file reading call */
1098 )
1099{
1100 SCIP_RETCODE retcode;
1101 SCIP_READER* reader;
1102 BLKINPUT blkinput;
1103 int i;
1104 char* ext;
1105 char copyfilename[SCIP_MAXSTRLEN];
1106
1107 reader = SCIPfindReader(scip, READER_NAME);
1108 assert(reader != NULL);
1109
1110 (void) SCIPsnprintf(copyfilename, SCIP_MAXSTRLEN, "%s", filename);
1111 SCIPsplitFilename(copyfilename, NULL, NULL, &ext, NULL);
1112
1113 if ( strcmp(ext, "blk") != 0 )
1114 {
1115 return SCIP_READERROR;
1116 }
1117
1118 /* initialize BLK input data */
1119 blkinput.file = NULL;
1120 blkinput.linebuf[0] = '\0';
1121 SCIP_CALL( SCIPallocMemoryArray(scip, &blkinput.token, BLK_MAX_LINELEN) ); /*lint !e506*/
1122 blkinput.token[0] = '\0';
1123 SCIP_CALL( SCIPallocMemoryArray(scip, &blkinput.tokenbuf, BLK_MAX_LINELEN) ); /*lint !e506*/
1124 blkinput.tokenbuf[0] = '\0';
1125 for( i = 0; i < BLK_MAX_PUSHEDTOKENS; ++i )
1126 {
1127 SCIP_CALL( SCIPallocMemoryArray(scip, &blkinput.pushedtokens[i], BLK_MAX_LINELEN) ); /*lint !e506 !e866*/
1128 }
1129
1130 blkinput.npushedtokens = 0;
1131 blkinput.linenumber = 0;
1132 blkinput.linepos = 0;
1133 blkinput.section = BLK_START;
1134 blkinput.presolved = FALSE;
1135 blkinput.haspresolvesection = FALSE;
1136 blkinput.nblocks = -1;
1137 blkinput.blocknr = -2;
1138 blkinput.haserror = FALSE;
1139
1140 /* read the file */
1141 retcode = readBLKFile(scip, reader, &blkinput, filename);
1142
1143 /* free dynamically allocated memory */
1144 SCIPfreeMemoryArray(scip, &blkinput.token);
1145 SCIPfreeMemoryArray(scip, &blkinput.tokenbuf);
1146 for( i = 0; i < BLK_MAX_PUSHEDTOKENS; ++i )
1147 {
1148 SCIPfreeMemoryArray(scip, &blkinput.pushedtokens[i]);
1149 }
1150
1151 /* evaluate the result */
1152 if( blkinput.haserror )
1153 return SCIP_READERROR;
1154 else if( retcode == SCIP_OKAY )
1155 {
1156 *result = SCIP_SUCCESS;
1157 }
1158
1159 return SCIP_OKAY;
1160}
1161
1162
1163/*
1164 * Callback methods of reader
1165 */
1166
1167/** destructor of reader to free user data (called when SCIP is exiting) */
1168static
1170{
1171 SCIP_READERDATA* readerdata;
1172
1173 readerdata = SCIPreaderGetData(reader);
1174 assert(readerdata != NULL);
1175
1176 SCIPfreeMemory(scip, &readerdata);
1177
1178 return SCIP_OKAY;
1179}
1180
1181
1182/** problem reading method of reader */
1183static
1185{ /*lint --e{715} */
1186
1188 {
1189 SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "Please read in a problem before reading in the corresponding structure file!\n");
1190 return SCIP_OKAY;
1191 }
1192 SCIP_CALL( readBlk(scip, filename, result) );
1193
1194 return SCIP_OKAY;
1195}
1196
1197
1198/** problem writing method of reader */
1199static
1201{ /*lint --e{715}*/
1202 return SCIP_OKAY;
1203}
1204
1205/*
1206 * reader specific interface methods
1207 */
1208
1209/** includes the blk file reader in SCIP */
1211 GCG* gcg /**< GCG data structure */
1212 )
1213{
1214 SCIP_READERDATA* readerdata = NULL;
1215 SCIP* origprob = GCGgetOrigprob(gcg);
1216 assert(origprob != NULL);
1217
1218 /* create blk reader data */
1219 SCIP_CALL( SCIPallocMemory(origprob, &readerdata) );
1220 readerdata->gcg = gcg;
1221
1222 /* include blk reader */
1224 readerFreeBlk, readerReadBlk, readerWriteBlk, readerdata) );
1225
1226 return SCIP_OKAY;
1227}
class storing (potentially incomplete) decompositions
class to manage partial decompositions
GCG_EXPORT bool fixVarToMasterByName(const char *varname)
assigns a variable with given name as master
GCG_EXPORT bool fixConsToMasterByName(const char *consname)
assgins a constraint by name as master
GCG_EXPORT bool fixConsToBlockByName(const char *consname, int blockid)
assigns a constraint by name to a block
GCG_EXPORT void setNBlocks(int nblocks)
sets number of blocks, only increasing number allowed
GCG_EXPORT bool fixVarToLinkingByName(const char *varname)
assigns a variable by name to the linking variables
GCG_EXPORT bool fixVarToBlockByName(const char *varname, int blockid)
assigns a variable by name to a block
GCG_EXPORT void setUsergiven(USERGIVEN usergiven)
sets whether this partialdec is user given
SCIP_RETCODE GCGconshdlrDecompAddPreexisitingPartialDec(GCG *gcg, PARTIALDECOMP *partialdec)
adds a preexisting partial dec to be considered at the beginning of the detection
constraint handler for structure detection
C++ interface of cons_decomp.
void GCGdecompSetPresolved(GCG_DECOMP *decomp, SCIP_Bool presolved)
Definition: decomp.c:724
void GCGdecompSetDetector(GCG_DECOMP *decomp, GCG_DETECTOR *detector)
Definition: decomp.c:1605
SCIP_RETCODE GCGdecompSetType(GCG_DECOMP *decomp, GCG_DECTYPE type)
Definition: decomp.c:659
SCIP_RETCODE GCGfilloutDecompFromConstoblock(GCG *gcg, GCG_DECOMP *decomp, SCIP_HASHMAP *constoblock, int nblocks, SCIP_Bool staircase)
Definition: decomp.c:1479
SCIP_RETCODE GCGdecompCreate(GCG *gcg, GCG_DECOMP **decdecomp)
Definition: decomp.c:480
void GCGdecompSetNBlocks(GCG_DECOMP *decomp, int nblocks)
Definition: decomp.c:745
SCIP_RETCODE GCGdecompFree(GCG *gcg, GCG_DECOMP **decdecomp)
Definition: decomp.c:541
#define SCIP_MAXSTRLEN
#define SCIP_Bool
#define SCIP_CALL(x)
#define TRUE
#define FALSE
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
int SCIPfclose(SCIP_FILE *fp)
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
void SCIPsplitFilename(char *filename, char **path, char **name, char **extension, char **compression)
SCIP * GCGgetOrigprob(GCG *gcg)
Definition: gcg.cpp:87
SCIP_STAGE SCIPgetStage(SCIP *scip)
SCIP_CONS ** SCIPgetConss(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
int SCIPgetNConss(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
SCIP_CONS * SCIPfindCons(SCIP *scip, const char *name)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
SCIP_RETCODE SCIPhashmapSetImage(SCIP_HASHMAP *hashmap, void *origin, void *image)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
SCIP_RETCODE GCGconsGetVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int nvars)
Definition: scip_misc.c:487
int GCGconsGetNVars(SCIP *scip, SCIP_CONS *cons)
Definition: scip_misc.c:433
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
const char * SCIPconsGetName(SCIP_CONS *cons)
#define SCIPreallocMemoryArray(scip, ptr, newnum)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
#define SCIPallocMemoryArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
#define SCIPfreeMemoryArray(scip, ptr)
#define SCIPfreeMemory(scip, ptr)
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)
SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
SCIP_READER * SCIPfindReader(SCIP *scip, const char *name)
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
SCIP_RETCODE SCIPpresolve(SCIP *scip)
int SCIPvarGetProbindex(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
int SCIPstrcasecmp(const char *s1, const char *s2)
int SCIPsnprintf(char *t, int len, const char *s,...)
void SCIPprintSysError(const char *message)
#define NULL
#define BMSclearMemoryArray(ptr, num)
@ COMPLETED_CONSTOMASTER
public methods for working with decomposition structures
struct SCIP_File SCIP_FILE
public methods for GCG variables
#define SCIPerrorMessage
#define SCIPdebugMessage
static SCIP_RETCODE readBLKFile(SCIP *scip, SCIP_READER *reader, BLKINPUT *blkinput, const char *filename)
Definition: reader_blk.cpp:913
static void syntaxError(SCIP *scip, BLKINPUT *blkinput, const char *msg)
Definition: reader_blk.cpp:140
static const int NOVALUE
Definition: reader_blk.cpp:125
enum BlkExpType BLKEXPTYPE
Definition: reader_blk.cpp:87
static SCIP_Bool hasError(BLKINPUT *blkinput)
Definition: reader_blk.cpp:168
static const char tokenchars[]
Definition: reader_blk.cpp:128
static SCIP_RETCODE readBlock(SCIP *scip, BLKINPUT *blkinput, gcg::PARTIALDECOMP *partialdec, SCIP_READERDATA *readerdata)
Definition: reader_blk.cpp:639
BlkExpType
Definition: reader_blk.cpp:84
@ BLK_EXP_NONE
Definition: reader_blk.cpp:85
@ BLK_EXP_UNSIGNED
Definition: reader_blk.cpp:85
@ BLK_EXP_SIGNED
Definition: reader_blk.cpp:85
static SCIP_RETCODE fillDecompStruct(SCIP *scip, BLKINPUT *blkinput, GCG_DECOMP *decomp, gcg::PARTIALDECOMP *partialdec, SCIP_READERDATA *readerdata)
Definition: reader_blk.cpp:758
#define BLK_MAX_LINELEN
Definition: reader_blk.cpp:72
static void pushToken(BLKINPUT *blkinput)
Definition: reader_blk.cpp:398
static const char commentchars[]
Definition: reader_blk.cpp:129
static SCIP_RETCODE readPresolved(SCIP *scip, BLKINPUT *blkinput)
Definition: reader_blk.cpp:561
static const int LINKINGVALUE
Definition: reader_blk.cpp:126
#define READER_DESC
Definition: reader_blk.cpp:66
static SCIP_RETCODE readMasterconss(SCIP *scip, BLKINPUT *blkinput, gcg::PARTIALDECOMP *partialdec, SCIP_READERDATA *readerdata)
Definition: reader_blk.cpp:720
BlkSection
Definition: reader_blk.cpp:77
@ BLK_MASTERCONSS
Definition: reader_blk.cpp:78
@ BLK_NBLOCKS
Definition: reader_blk.cpp:78
@ BLK_PRESOLVED
Definition: reader_blk.cpp:78
@ BLK_START
Definition: reader_blk.cpp:78
@ BLK_BLOCK
Definition: reader_blk.cpp:78
@ BLK_END
Definition: reader_blk.cpp:78
static SCIP_Bool isInt(SCIP *scip, BLKINPUT *blkinput, int *value)
Definition: reader_blk.cpp:422
#define READER_EXTENSION
Definition: reader_blk.cpp:67
#define BLK_MAX_PUSHEDTOKENS
Definition: reader_blk.cpp:73
enum BlkSection BLKSECTION
Definition: reader_blk.cpp:80
static void swapTokenBuffer(BLKINPUT *blkinput)
Definition: reader_blk.cpp:411
static SCIP_RETCODE readStart(SCIP *scip, BLKINPUT *blkinput)
Definition: reader_blk.cpp:540
static SCIP_Bool isValueChar(char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, BLKEXPTYPE *exptype)
Definition: reader_blk.cpp:197
#define READER_NAME
Definition: reader_blk.cpp:65
static SCIP_Bool getNextToken(BLKINPUT *blkinput)
Definition: reader_blk.cpp:299
static SCIP_Bool isDelimChar(char c)
Definition: reader_blk.cpp:179
static SCIP_RETCODE readNBlocks(SCIP *scip, gcg::PARTIALDECOMP *partialdec, BLKINPUT *blkinput)
Definition: reader_blk.cpp:597
SCIP_RETCODE GCGincludeReaderBlk(GCG *gcg)
static SCIP_RETCODE readBlk(SCIP *scip, const char *filename, SCIP_RESULT *result)
static SCIP_DECL_READERREAD(readerReadBlk)
static void swapPointers(char **pointer1, char **pointer2)
Definition: reader_blk.cpp:285
static SCIP_DECL_READERFREE(readerFreeBlk)
static const char delimchars[]
Definition: reader_blk.cpp:127
static SCIP_Bool isNewSection(SCIP *scip, BLKINPUT *blkinput)
Definition: reader_blk.cpp:450
static SCIP_Bool getNextLine(BLKINPUT *blkinput)
Definition: reader_blk.cpp:241
static SCIP_Bool isTokenChar(char c)
Definition: reader_blk.cpp:188
static SCIP_DECL_READERWRITE(readerWriteBlk)
BLK file reader for structure information.
GCG relaxator.
various SCIP helper methods
char * pushedtokens[BLK_MAX_PUSHEDTOKENS]
Definition: reader_blk.cpp:97
int linenumber
Definition: reader_blk.cpp:99
SCIP_Bool haserror
Definition: reader_blk.cpp:106
SCIP_Bool haspresolvesection
Definition: reader_blk.cpp:102
char * token
Definition: reader_blk.cpp:95
char * tokenbuf
Definition: reader_blk.cpp:96
char linebuf[BLK_MAX_LINELEN]
Definition: reader_blk.cpp:94
BLKSECTION section
Definition: reader_blk.cpp:105
SCIP_Bool presolved
Definition: reader_blk.cpp:101
int npushedtokens
Definition: reader_blk.cpp:98
SCIP_FILE * file
Definition: reader_blk.cpp:93
Definition: struct_gcg.h:55
int * nlinkingvarsblocks
Definition: reader_blk.cpp:117
SCIP_HASHMAP * constoblock
Definition: reader_blk.cpp:118
SCIP_CONS *** blockcons
Definition: reader_blk.cpp:119
int ** linkingvarsblocks
Definition: reader_blk.cpp:116
@ GCG_DECTYPE_ARROWHEAD
Definition: type_decomp.h:51
SCIP_VERBLEVEL_DIALOG
SCIP_VERBLEVEL_MINIMAL
SCIP_SUCCESS
enum SCIP_Result SCIP_RESULT
SCIP_NOFILE
SCIP_READERROR
SCIP_INVALIDDATA
SCIP_OKAY
SCIP_ERROR
enum SCIP_Retcode SCIP_RETCODE
SCIP_STAGE_TRANSFORMED
SCIP_STAGE_INIT
SCIP_STAGE_PRESOLVED