Detailed Description
BLK file reader for structure information.
This reader reads in a blk-file that defines the structur to be used for the decomposition. The structure is defined variable-wise, i.e., the number of blocks and the variables belonging to each block are defined. Afterwards, each constraint that has only variables of one block is added to that block, constraints having variables of more than one block go into the master. If needed, constraints can also be forced into the master, even if they could be transferred to one block.
The keywords are:
- Presolved: to be followed by either 0 or 1 indicating that the decomposition is for the presolved or unpresolved problem
- NBlocks: to be followed by a line giving the number of blocks
- Block i with 1 <= i <= nblocks: to be followed by the names of the variables belonging to block i, one per line.
- Masterconss: to be followed by names of constraints, one per line, that should go into the master, even if they only contain variables of one block and could thus be added to this block.
Definition in file reader_blk.cpp.
#include <stdlib.h>#include <assert.h>#include <string.h>#include <ctype.h>#include "gcg/reader_blk.h"#include "gcg/relax_gcg.h"#include "gcg/pub_gcgvar.h"#include "gcg/pub_decomp.h"#include "gcg/cons_decomp.h"#include "gcg/cons_decomp.hpp"#include "gcg/scip_misc.h"#include "gcg/class_partialdecomp.h"Go to the source code of this file.
Data Structures | |
| struct | BlkInput |
| struct | SCIP_ReaderData |
Macros | |
| #define | READER_NAME "blkreader" |
| #define | READER_DESC "file reader for structures in blk format" |
| #define | READER_EXTENSION "blk" |
| #define | BLK_MAX_LINELEN 65536 |
| #define | BLK_MAX_PUSHEDTOKENS 2 |
Functions | |
| static void | syntaxError (SCIP *scip, BLKINPUT *blkinput, const char *msg) |
| static SCIP_Bool | hasError (BLKINPUT *blkinput) |
| static SCIP_Bool | isDelimChar (char c) |
| static SCIP_Bool | isTokenChar (char c) |
| static SCIP_Bool | isValueChar (char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, BLKEXPTYPE *exptype) |
| static SCIP_Bool | getNextLine (BLKINPUT *blkinput) |
| static void | swapPointers (char **pointer1, char **pointer2) |
| static SCIP_Bool | getNextToken (BLKINPUT *blkinput) |
| static void | pushToken (BLKINPUT *blkinput) |
| static void | swapTokenBuffer (BLKINPUT *blkinput) |
| static SCIP_Bool | isInt (SCIP *scip, BLKINPUT *blkinput, int *value) |
| static SCIP_Bool | isNewSection (SCIP *scip, BLKINPUT *blkinput) |
| static SCIP_RETCODE | readStart (SCIP *scip, BLKINPUT *blkinput) |
| static SCIP_RETCODE | readPresolved (SCIP *scip, BLKINPUT *blkinput) |
| static SCIP_RETCODE | readNBlocks (SCIP *scip, gcg::PARTIALDECOMP *partialdec, BLKINPUT *blkinput) |
| static SCIP_RETCODE | readBlock (SCIP *scip, BLKINPUT *blkinput, gcg::PARTIALDECOMP *partialdec, SCIP_READERDATA *readerdata) |
| static SCIP_RETCODE | readMasterconss (SCIP *scip, BLKINPUT *blkinput, gcg::PARTIALDECOMP *partialdec, SCIP_READERDATA *readerdata) |
| static SCIP_RETCODE | fillDecompStruct (SCIP *scip, BLKINPUT *blkinput, GCG_DECOMP *decomp, gcg::PARTIALDECOMP *partialdec, SCIP_READERDATA *readerdata) |
| static SCIP_RETCODE | readBLKFile (SCIP *scip, SCIP_READER *reader, BLKINPUT *blkinput, const char *filename) |
| static SCIP_RETCODE | readBlk (SCIP *scip, const char *filename, SCIP_RESULT *result) |
| static | SCIP_DECL_READERFREE (readerFreeBlk) |
| static | SCIP_DECL_READERREAD (readerReadBlk) |
| static | SCIP_DECL_READERWRITE (readerWriteBlk) |
| SCIP_RETCODE | GCGincludeReaderBlk (GCG *gcg) |
Variables | |
| static const int | NOVALUE = -1 |
| static const int | LINKINGVALUE = -2 |
| static const char | delimchars [] = " \f\n\r\t\v" |
| static const char | tokenchars [] = "-+:<>=" |
| static const char | commentchars [] = "\\" |
Macro Definition Documentation
◆ READER_NAME
| #define READER_NAME "blkreader" |
Definition at line 65 of file reader_blk.cpp.
Referenced by GCGincludeReaderBlk(), GCGincludeReaderCls(), GCGincludeReaderDec(), GCGincludeReaderGp(), GCGincludeReaderJDec(), GCGincludeReaderRef(), GCGincludeReaderTex(), readBlk(), readDec(), SCIP_DECL_READERFREE(), and SCIP_DECL_READERFREE().
◆ READER_DESC
| #define READER_DESC "file reader for structures in blk format" |
Definition at line 66 of file reader_blk.cpp.
Referenced by GCGincludeReaderBlk(), GCGincludeReaderCls(), GCGincludeReaderDec(), GCGincludeReaderGp(), GCGincludeReaderJDec(), GCGincludeReaderRef(), and GCGincludeReaderTex().
◆ READER_EXTENSION
| #define READER_EXTENSION "blk" |
Definition at line 67 of file reader_blk.cpp.
Referenced by GCGincludeReaderBlk(), GCGincludeReaderCls(), GCGincludeReaderDec(), GCGincludeReaderGp(), GCGincludeReaderJDec(), GCGincludeReaderRef(), and GCGincludeReaderTex().
◆ BLK_MAX_LINELEN
| #define BLK_MAX_LINELEN 65536 |
Definition at line 72 of file reader_blk.cpp.
Referenced by getNextLine(), getNextToken(), and readBlk().
◆ BLK_MAX_PUSHEDTOKENS
| #define BLK_MAX_PUSHEDTOKENS 2 |
Definition at line 73 of file reader_blk.cpp.
Referenced by pushToken(), and readBlk().
Typedef Documentation
◆ BLKSECTION
| typedef enum BlkSection BLKSECTION |
Definition at line 80 of file reader_blk.cpp.
◆ BLKEXPTYPE
| typedef enum BlkExpType BLKEXPTYPE |
Definition at line 87 of file reader_blk.cpp.
◆ BLKINPUT
Definition at line 108 of file reader_blk.cpp.
Enumeration Type Documentation
◆ BlkSection
| enum BlkSection |
section in BLK File
| Enumerator | |
|---|---|
| BLK_START | |
| BLK_PRESOLVED | |
| BLK_NBLOCKS | |
| BLK_BLOCK | |
| BLK_MASTERCONSS | |
| BLK_END | |
Definition at line 76 of file reader_blk.cpp.
◆ BlkExpType
| enum BlkExpType |
exponent indicator of the a value
| Enumerator | |
|---|---|
| BLK_EXP_NONE | |
| BLK_EXP_UNSIGNED | |
| BLK_EXP_SIGNED | |
Definition at line 83 of file reader_blk.cpp.
Function Documentation
◆ syntaxError()
issues an error message and marks the BLK data to have errors
- Parameters
-
scip SCIP data structure blkinput BLK reading data msg error message
Definition at line 140 of file reader_blk.cpp.
References assert(), BLK_END, BlkInput::haserror, BlkInput::linebuf, BlkInput::linenumber, BlkInput::linepos, BlkInput::section, syntaxError(), and BlkInput::token.
Referenced by isNewSection(), isNewSection(), readBlock(), readBlockconss(), readBlocks(), readBlockSizes(), readBlockvars(), readIncomplete(), readLinkingvars(), readMasterconss(), readMasterconss(), readMastervars(), readNBlocks(), readNBlocks(), readNBlocks(), readPresolved(), readPresolved(), syntaxError(), syntaxError(), and syntaxError().
◆ hasError()
returns whether a syntax error was detected
- Parameters
-
blkinput BLK reading data
Definition at line 168 of file reader_blk.cpp.
References assert(), hasError(), and BlkInput::haserror.
Referenced by hasError(), hasError(), hasError(), readBLKFile(), readDECFile(), and readREFFile().
◆ isDelimChar()
|
static |
returns whether the given character is a token delimiter
- Parameters
-
c input character
Definition at line 179 of file reader_blk.cpp.
References c, delimchars, and isDelimChar().
Referenced by getNextToken(), getNextToken(), getNextToken(), isDelimChar(), isDelimChar(), and isDelimChar().
◆ isTokenChar()
|
static |
returns whether the given character is a single token
- Parameters
-
c input character
Definition at line 188 of file reader_blk.cpp.
References c, isTokenChar(), and tokenchars.
Referenced by getNextToken(), getNextToken(), getNextToken(), isTokenChar(), isTokenChar(), and isTokenChar().
◆ isValueChar()
|
static |
returns whether the current character is member of a value string
- Parameters
-
c input character nextc next input character firstchar is the given character the first char of the token? hasdot pointer to update the dot flag exptype pointer to update the exponent type
Definition at line 197 of file reader_blk.cpp.
References assert(), BLK_EXP_NONE, BLK_EXP_SIGNED, BLK_EXP_UNSIGNED, c, and isValueChar().
Referenced by getNextToken(), getNextToken(), getNextToken(), isValueChar(), isValueChar(), and isValueChar().
◆ getNextLine()
reads the next line from the input file into the line buffer; skips comments; returns whether a line could be read
- Parameters
-
blkinput BLK reading data
Definition at line 241 of file reader_blk.cpp.
References assert(), BLK_MAX_LINELEN, commentchars, BlkInput::file, getNextLine(), BlkInput::haserror, i, BlkInput::linebuf, BlkInput::linenumber, and BlkInput::linepos.
Referenced by getNextLine(), getNextLine(), getNextLine(), getNextToken(), getNextToken(), and getNextToken().
◆ swapPointers()
|
static |
swaps the addresses of two pointers
- Parameters
-
pointer1 first pointer pointer2 second pointer
Definition at line 285 of file reader_blk.cpp.
References swapPointers().
Referenced by getNextToken(), getNextToken(), pushToken(), pushToken(), swapPointers(), swapPointers(), swapTokenBuffer(), and swapTokenBuffer().
◆ getNextToken()
reads the next token from the input file into the token buffer; returns whether a token was read
- Parameters
-
blkinput BLK reading data
Definition at line 299 of file reader_blk.cpp.
References assert(), BLK_END, BLK_EXP_NONE, BLK_MAX_LINELEN, getNextLine(), getNextToken(), isDelimChar(), isTokenChar(), isValueChar(), BlkInput::linebuf, BlkInput::linenumber, BlkInput::linepos, BlkInput::npushedtokens, BlkInput::pushedtokens, SCIPdebugMessage(), BlkInput::section, swapPointers(), and BlkInput::token.
Referenced by getNextToken(), getNextToken(), getNextToken(), isNewSection(), isNewSection(), readBlock(), readBlockconss(), readBlocks(), readBlockSizes(), readBlockvars(), readDECFile(), readIncomplete(), readLinkingvars(), readMasterconss(), readMasterconss(), readMastervars(), readNBlocks(), readNBlocks(), readNBlocks(), readPresolved(), readPresolved(), readStart(), readStart(), readStart(), and setPresolved().
◆ pushToken()
|
static |
puts the current token on the token stack, such that it is read at the next call to getNextToken()
- Parameters
-
blkinput BLK reading data
Definition at line 398 of file reader_blk.cpp.
References assert(), BLK_MAX_PUSHEDTOKENS, BlkInput::npushedtokens, BlkInput::pushedtokens, pushToken(), swapPointers(), and BlkInput::token.
Referenced by isNewSection(), isNewSection(), pushToken(), and pushToken().
◆ swapTokenBuffer()
|
static |
swaps the current token with the token buffer
- Parameters
-
blkinput BLK reading data
Definition at line 411 of file reader_blk.cpp.
References assert(), swapPointers(), swapTokenBuffer(), BlkInput::token, and BlkInput::tokenbuf.
Referenced by isNewSection(), isNewSection(), swapTokenBuffer(), and swapTokenBuffer().
◆ isInt()
returns whether the current token is a value
- Parameters
-
scip SCIP data structure blkinput BLK reading data value pointer to store the value (unchanged, if token is no value)
Definition at line 422 of file reader_blk.cpp.
References assert(), isInt(), and BlkInput::token.
Referenced by isInt(), isInt(), isInt(), isNewSection(), isNewSection(), readBlocks(), readBlockSizes(), readIncomplete(), readNBlocks(), readNBlocks(), readNBlocks(), readPresolved(), and readPresolved().
◆ isNewSection()
checks whether the current token is a section identifier, and if yes, switches to the corresponding section
- Parameters
-
scip SCIP data structure blkinput BLK reading data
Definition at line 450 of file reader_blk.cpp.
References assert(), BLK_BLOCK, BLK_END, BLK_MASTERCONSS, BLK_NBLOCKS, BLK_PRESOLVED, BlkInput::blocknr, getNextToken(), isInt(), isNewSection(), BlkInput::linenumber, pushToken(), SCIPdebugMessage(), BlkInput::section, swapTokenBuffer(), syntaxError(), and BlkInput::token.
Referenced by isNewSection(), isNewSection(), readBlock(), readBlockconss(), readBlockvars(), readDECFile(), readIncomplete(), readLinkingvars(), readMasterconss(), readMasterconss(), readMastervars(), readNBlocks(), readNBlocks(), readPresolved(), readPresolved(), readStart(), readStart(), and setPresolved().
◆ readStart()
|
static |
reads the header of the file
- Parameters
-
scip SCIP data structure blkinput BLK reading data
Definition at line 540 of file reader_blk.cpp.
References assert(), getNextToken(), isNewSection(), and readStart().
Referenced by readBLKFile(), readDECFile(), readREFFile(), readStart(), readStart(), and readStart().
◆ readPresolved()
|
static |
reads the presolved section
- Parameters
-
scip SCIP data structure blkinput DEC reading data
Definition at line 561 of file reader_blk.cpp.
References assert(), getNextToken(), BlkInput::haspresolvesection, isInt(), isNewSection(), BlkInput::presolved, readPresolved(), SCIPdebugMessage(), and syntaxError().
Referenced by readBLKFile(), readPresolved(), readPresolved(), and setPresolved().
◆ readNBlocks()
|
static |
reads the nblocks section
- Parameters
-
scip SCIP data structure partialdec partialdec to edit blkinput BLK reading data
Definition at line 597 of file reader_blk.cpp.
References assert(), getNextToken(), isInt(), isNewSection(), BlkInput::nblocks, NOVALUE, readNBlocks(), SCIPdebugMessage(), gcg::PARTIALDECOMP::setNBlocks(), and syntaxError().
Referenced by readBLKFile(), readDECFile(), readNBlocks(), readNBlocks(), readNBlocks(), and readREFFile().
◆ readBlock()
|
static |
reads a block section
- Parameters
-
scip SCIP data structure blkinput BLK reading data partialdec partialdec to edit readerdata reader data
Definition at line 639 of file reader_blk.cpp.
References assert(), BlkInput::blocknr, gcg::PARTIALDECOMP::fixVarToBlockByName(), gcg::PARTIALDECOMP::fixVarToLinkingByName(), getNextToken(), isNewSection(), LINKINGVALUE, SCIP_ReaderData::linkingvarsblocks, SCIP_ReaderData::nblockvars, SCIP_ReaderData::nlinkingvars, SCIP_ReaderData::nlinkingvarsblocks, NOVALUE, readBlock(), SCIP_CALL(), SCIPdebugMessage(), syntaxError(), BlkInput::token, var, and SCIP_ReaderData::varstoblock.
Referenced by readBLKFile(), and readBlock().
◆ readMasterconss()
|
static |
reads the masterconss section
- Parameters
-
scip SCIP data structure blkinput BLK reading data partialdec PARTIALDECOMP to edit readerdata reader data
Definition at line 720 of file reader_blk.cpp.
References assert(), SCIP_ReaderData::constoblock, gcg::PARTIALDECOMP::fixConsToMasterByName(), getNextToken(), isNewSection(), BlkInput::nblocks, NOVALUE, readMasterconss(), SCIP_CALL(), syntaxError(), and BlkInput::token.
Referenced by readBLKFile(), readDECFile(), readMasterconss(), and readMasterconss().
◆ fillDecompStruct()
|
static |
fills the whole Decomp struct after the blk file has been read
- Parameters
-
scip SCIP data structure blkinput blk reading data decomp GCG_DECOMP structure to fill partialdec partialdec to fill for internal handling readerdata reader data
Definition at line 758 of file reader_blk.cpp.
References assert(), SCIP_ReaderData::constoblock, fillDecompStruct(), gcg::PARTIALDECOMP::fixConsToBlockByName(), gcg::PARTIALDECOMP::fixConsToMasterByName(), gcg::PARTIALDECOMP::fixVarToMasterByName(), SCIP_ReaderData::gcg, GCG_DECTYPE_ARROWHEAD, GCGconsGetNVars(), GCGconsGetVars(), GCGdecompSetDetector(), GCGdecompSetNBlocks(), GCGdecompSetPresolved(), GCGdecompSetType(), GCGfilloutDecompFromConstoblock(), i, j, LINKINGVALUE, SCIP_ReaderData::linkingvarsblocks, BlkInput::nblocks, SCIP_ReaderData::nlinkingvarsblocks, NOVALUE, nvars, BlkInput::presolved, retcode, SCIP_CALL(), SCIPdebugMessage(), var, and SCIP_ReaderData::varstoblock.
Referenced by fillDecompStruct(), and readBLKFile().
◆ readBLKFile()
|
static |
reads an BLK file
- Parameters
-
scip SCIP data structure reader reader data structure blkinput BLK reading data filename name of the input file
Definition at line 913 of file reader_blk.cpp.
References assert(), BLK_BLOCK, BLK_END, BLK_MASTERCONSS, BLK_NBLOCKS, BLK_PRESOLVED, BLK_START, SCIP_ReaderData::blockcons, gcg::COMPLETED_CONSTOMASTER, SCIP_ReaderData::constoblock, BlkInput::file, fillDecompStruct(), SCIP_ReaderData::gcg, GCGconshdlrDecompAddPreexisitingPartialDec(), GCGdecompCreate(), GCGdecompFree(), hasError(), BlkInput::haspresolvesection, i, SCIP_ReaderData::linkingvarsblocks, SCIP_ReaderData::nblockcons, BlkInput::nblocks, SCIP_ReaderData::nblockvars, SCIP_ReaderData::nlinkingcons, SCIP_ReaderData::nlinkingvars, SCIP_ReaderData::nlinkingvarsblocks, NOVALUE, nvars, BlkInput::presolved, readBLKFile(), readBlock(), readMasterconss(), readNBlocks(), readPresolved(), readStart(), retcode, SCIP_CALL(), BlkInput::section, gcg::PARTIALDECOMP::setUsergiven(), and SCIP_ReaderData::varstoblock.
Referenced by readBlk(), and readBLKFile().
◆ readBlk()
|
static |
- Parameters
-
scip SCIP data structure filename full path and name of file to read, or NULL if stdin should be used result pointer to store the result of the file reading call
Definition at line 1094 of file reader_blk.cpp.
References assert(), BLK_MAX_LINELEN, BLK_MAX_PUSHEDTOKENS, BLK_START, BlkInput::blocknr, BlkInput::file, BlkInput::haserror, BlkInput::haspresolvesection, i, BlkInput::linebuf, BlkInput::linenumber, BlkInput::linepos, BlkInput::nblocks, BlkInput::npushedtokens, BlkInput::presolved, BlkInput::pushedtokens, readBlk(), readBLKFile(), READER_NAME, result, retcode, SCIP_CALL(), BlkInput::section, BlkInput::token, and BlkInput::tokenbuf.
Referenced by readBlk(), and SCIP_DECL_READERREAD().
◆ SCIP_DECL_READERFREE()
|
static |
destructor of reader to free user data (called when SCIP is exiting)
Definition at line 1169 of file reader_blk.cpp.
References assert(), and SCIPfreeMemory().
◆ SCIP_DECL_READERREAD()
|
static |
problem reading method of reader
Definition at line 1184 of file reader_blk.cpp.
References readBlk(), result, and SCIP_CALL().
◆ SCIP_DECL_READERWRITE()
|
static |
problem writing method of reader
Definition at line 1200 of file reader_blk.cpp.
◆ GCGincludeReaderBlk()
| SCIP_RETCODE GCGincludeReaderBlk | ( | GCG * | gcg | ) |
includes the blk file reader in SCIP
includes the blk file reader into SCIP
- Parameters
-
gcg GCG data structure
Definition at line 1210 of file reader_blk.cpp.
References assert(), SCIP_ReaderData::gcg, GCGgetOrigprob(), GCGincludeReaderBlk(), origprob, READER_DESC, READER_EXTENSION, READER_NAME, and SCIP_CALL().
Referenced by GCGincludeGcgPlugins(), and GCGincludeReaderBlk().
Variable Documentation
◆ NOVALUE
|
static |
Definition at line 125 of file reader_blk.cpp.
Referenced by fillDecompStruct(), readBLKFile(), readBlock(), readDec(), readMasterconss(), readNBlocks(), and readNBlocks().
◆ LINKINGVALUE
|
static |
Definition at line 126 of file reader_blk.cpp.
Referenced by fillDecompStruct(), and readBlock().
◆ delimchars
|
static |
Definition at line 127 of file reader_blk.cpp.
Referenced by isDelimChar(), isDelimChar(), and isDelimChar().
◆ tokenchars
|
static |
Definition at line 128 of file reader_blk.cpp.
Referenced by isTokenChar(), isTokenChar(), and isTokenChar().
◆ commentchars
|
static |
Definition at line 129 of file reader_blk.cpp.
Referenced by getNextLine(), getNextLine(), getNextLine(), and writePartialdec().