Detailed Description
DEC file reader for structure information.
Definition in file reader_dec.cpp.
#include <assert.h>#include <string.h>#include <ctype.h>#include "gcg/reader_dec.h"#include "gcg/scip_misc.h"#include "gcg/pub_gcgvar.h"#include "gcg/cons_decomp.h"#include "gcg/cons_decomp.hpp"#include "gcg/pub_decomp.h"#include "gcg/class_partialdecomp.h"#include "gcg/class_detprobdata.h"Go to the source code of this file.
Data Structures | |
| struct | DecInput |
| struct | SCIP_ReaderData |
Macros | |
| #define | READER_NAME "decreader" |
| #define | READER_DESC "file reader for blocks in dec format" |
| #define | READER_EXTENSION "dec" |
| #define | DEC_MAX_LINELEN 65536 |
| #define | DEC_MAX_PUSHEDTOKENS 2 |
Typedefs | |
| typedef enum DecSection | DECSECTION |
| typedef enum DecExpType | DECEXPTYPE |
| typedef struct DecInput | DECINPUT |
Enumerations | |
| enum | DecSection { DEC_START , DEC_INCOMPLETE , DEC_PRESOLVED , DEC_NBLOCKS , DEC_BLOCKCONSS , DEC_MASTERCONSS , DEC_BLOCKVARS , DEC_MASTERVARS , DEC_LINKINGVARS , DEC_END } |
| enum | DecExpType { DEC_EXP_NONE } |
Functions | |
| static void | syntaxError (SCIP *scip, DECINPUT *decinput, const char *msg) |
| static SCIP_Bool | hasError (DECINPUT *decinput) |
| 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, DECEXPTYPE *exptype) |
| static SCIP_Bool | getNextLine (DECINPUT *decinput) |
| static void | swapPointers (char **pointer1, char **pointer2) |
| static SCIP_Bool | getNextToken (DECINPUT *decinput) |
| static void | pushToken (DECINPUT *decinput) |
| static void | swapTokenBuffer (DECINPUT *decinput) |
| static SCIP_Bool | isInt (SCIP *scip, DECINPUT *decinput, int *value) |
| static SCIP_Bool | isNewSection (SCIP *scip, DECINPUT *decinput) |
| static SCIP_RETCODE | readStart (SCIP *scip, DECINPUT *decinput) |
| static SCIP_RETCODE | readIncomplete (SCIP *scip, DECINPUT *decinput) |
| static SCIP_RETCODE | readPresolved (SCIP *scip, DECINPUT *decinput) |
| static SCIP_RETCODE | readNBlocks (SCIP *scip, DECINPUT *decinput) |
| static SCIP_RETCODE | readBlockconss (SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata) |
| static SCIP_RETCODE | readBlockvars (SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata) |
| static SCIP_RETCODE | readMasterconss (SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata) |
| static SCIP_RETCODE | readMastervars (SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata) |
| static SCIP_RETCODE | readLinkingvars (SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata) |
| static SCIP_RETCODE | setPresolved (SCIP *scip, DECINPUT *decinput) |
| static SCIP_RETCODE | readDECFile (SCIP *scip, SCIP_READER *reader, DECINPUT *decinput, const char *filename) |
| static SCIP_RETCODE | writePartialdec (SCIP *scip, FILE *file, gcg::PARTIALDECOMP *partialdec, SCIP_RESULT *result) |
| write partialdec to file in dec format More... | |
| SCIP_RETCODE | readDec (SCIP *scip, const char *filename, SCIP_RESULT *result) |
| static | SCIP_DECL_READERFREE (readerFreeDec) |
| static | SCIP_DECL_READERREAD (readerReadDec) |
| static | SCIP_DECL_READERWRITE (readerWriteDec) |
| SCIP_RETCODE | GCGincludeReaderDec (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 "decreader" |
Definition at line 57 of file reader_dec.cpp.
◆ READER_DESC
| #define READER_DESC "file reader for blocks in dec format" |
Definition at line 58 of file reader_dec.cpp.
◆ READER_EXTENSION
| #define READER_EXTENSION "dec" |
Definition at line 59 of file reader_dec.cpp.
◆ DEC_MAX_LINELEN
| #define DEC_MAX_LINELEN 65536 |
Definition at line 65 of file reader_dec.cpp.
◆ DEC_MAX_PUSHEDTOKENS
| #define DEC_MAX_PUSHEDTOKENS 2 |
Definition at line 66 of file reader_dec.cpp.
Typedef Documentation
◆ DECSECTION
| typedef enum DecSection DECSECTION |
Definition at line 73 of file reader_dec.cpp.
◆ DECEXPTYPE
| typedef enum DecExpType DECEXPTYPE |
Definition at line 80 of file reader_dec.cpp.
◆ DECINPUT
Definition at line 102 of file reader_dec.cpp.
Enumeration Type Documentation
◆ DecSection
| enum DecSection |
section in DEC File
| Enumerator | |
|---|---|
| DEC_START | |
| DEC_INCOMPLETE | |
| DEC_PRESOLVED | |
| DEC_NBLOCKS | |
| DEC_BLOCKCONSS | |
| DEC_MASTERCONSS | |
| DEC_BLOCKVARS | |
| DEC_MASTERVARS | |
| DEC_LINKINGVARS | |
| DEC_END | |
Definition at line 69 of file reader_dec.cpp.
◆ DecExpType
| enum DecExpType |
exponent indicator of the a value
| Enumerator | |
|---|---|
| DEC_EXP_NONE | |
Definition at line 76 of file reader_dec.cpp.
Function Documentation
◆ syntaxError()
issues an error message and marks the DEC data to have errors
- Parameters
-
scip SCIP data structure decinput DEC reading data msg error message
Definition at line 122 of file reader_dec.cpp.
References DEC_END, DecInput::haserror, DecInput::linebuf, DecInput::linenumber, DecInput::linepos, NULL, SCIP_VERBLEVEL_MINIMAL, SCIPsnprintf(), SCIPverbMessage(), DecInput::section, DecInput::token, and TRUE.
Referenced by isNewSection(), readBlockconss(), readBlockvars(), readIncomplete(), readLinkingvars(), readMasterconss(), readMastervars(), readNBlocks(), and readPresolved().
◆ hasError()
returns whether a syntax error was detected
- Parameters
-
decinput DEC reading data
Definition at line 150 of file reader_dec.cpp.
References DecInput::haserror, NULL, and SCIP_Bool.
Referenced by readDECFile().
◆ isDelimChar()
|
static |
returns whether the given character is a token delimiter
- Parameters
-
c input character
Definition at line 160 of file reader_dec.cpp.
References delimchars, NULL, and SCIP_Bool.
Referenced by getNextToken().
◆ isTokenChar()
|
static |
returns whether the given character is a single token
- Parameters
-
c input character
Definition at line 169 of file reader_dec.cpp.
References NULL, SCIP_Bool, and tokenchars.
Referenced by getNextToken().
◆ 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 178 of file reader_dec.cpp.
References FALSE, NULL, SCIP_Bool, and TRUE.
Referenced by getNextToken().
◆ getNextLine()
reads the next line from the input file into the line buffer; skips comments; returns whether a line could be read
- Parameters
-
decinput DEC reading data
Definition at line 199 of file reader_dec.cpp.
References BMSclearMemoryArray, commentchars, DEC_MAX_LINELEN, FALSE, DecInput::file, DecInput::haserror, DecInput::linebuf, DecInput::linenumber, DecInput::linepos, NULL, SCIP_Bool, SCIPerrorMessage, SCIPfgets(), and TRUE.
Referenced by getNextToken().
◆ swapPointers()
|
static |
swaps the addresses of two pointers
- Parameters
-
pointer1 first pointer pointer2 second pointer
Definition at line 243 of file reader_dec.cpp.
Referenced by getNextToken(), pushToken(), and swapTokenBuffer().
◆ getNextToken()
reads the next token from the input file into the token buffer; returns whether a token was read
- Parameters
-
decinput DEC reading data
Definition at line 257 of file reader_dec.cpp.
References DEC_END, DEC_EXP_NONE, DEC_MAX_LINELEN, FALSE, getNextLine(), isDelimChar(), isTokenChar(), isValueChar(), DecInput::linebuf, DecInput::linenumber, DecInput::linepos, DecInput::npushedtokens, NULL, DecInput::pushedtokens, SCIP_Bool, SCIPdebugMessage, DecInput::section, swapPointers(), DecInput::token, and TRUE.
Referenced by isNewSection(), readBlockconss(), readBlockvars(), readDECFile(), readIncomplete(), readLinkingvars(), readMasterconss(), readMastervars(), readNBlocks(), readPresolved(), 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
-
decinput DEC reading data
Definition at line 356 of file reader_dec.cpp.
References DEC_MAX_PUSHEDTOKENS, DecInput::npushedtokens, NULL, DecInput::pushedtokens, swapPointers(), and DecInput::token.
Referenced by isNewSection().
◆ swapTokenBuffer()
|
static |
swaps the current token with the token buffer
- Parameters
-
decinput DEC reading data
Definition at line 369 of file reader_dec.cpp.
References NULL, swapPointers(), DecInput::token, and DecInput::tokenbuf.
Referenced by isNewSection().
◆ isInt()
returns whether the current token is a value
- Parameters
-
scip SCIP data structure decinput DEC reading data value pointer to store the value (unchanged, if token is no value)
Definition at line 380 of file reader_dec.cpp.
References FALSE, NULL, SCIP_Bool, SCIPstrcasecmp(), DecInput::token, and TRUE.
Referenced by isNewSection(), readIncomplete(), readNBlocks(), 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 decinput DEC reading data
Definition at line 408 of file reader_dec.cpp.
References DecInput::blocknr, DEC_BLOCKCONSS, DEC_BLOCKVARS, DEC_INCOMPLETE, DEC_LINKINGVARS, DEC_MASTERCONSS, DEC_MASTERVARS, DEC_NBLOCKS, DEC_PRESOLVED, FALSE, getNextToken(), isInt(), DecInput::linenumber, NULL, pushToken(), SCIP_Bool, SCIPdebugMessage, SCIPstrcasecmp(), DecInput::section, swapTokenBuffer(), syntaxError(), DecInput::token, and TRUE.
Referenced by readBlockconss(), readBlockvars(), readDECFile(), readIncomplete(), readLinkingvars(), readMasterconss(), readMastervars(), readNBlocks(), readPresolved(), readStart(), and setPresolved().
◆ readStart()
|
static |
reads the header of the file
- Parameters
-
scip SCIP data structure decinput DEC reading data
Definition at line 538 of file reader_dec.cpp.
References getNextToken(), isNewSection(), NULL, and SCIP_OKAY.
Referenced by readDECFile().
◆ readIncomplete()
|
static |
reads the incomplete section
- Parameters
-
scip SCIP data structure decinput DEC reading data
Definition at line 559 of file reader_dec.cpp.
References FALSE, getNextToken(), DecInput::incomplete, isInt(), isNewSection(), NULL, SCIP_OKAY, SCIPdebugMessage, syntaxError(), and TRUE.
Referenced by readDECFile().
◆ readPresolved()
|
static |
reads the presolved section
- Parameters
-
scip SCIP data structure decinput DEC reading data
Definition at line 596 of file reader_dec.cpp.
References FALSE, getNextToken(), DecInput::haspresolvesection, isInt(), isNewSection(), NULL, DecInput::presolved, SCIP_OKAY, SCIPdebugMessage, syntaxError(), and TRUE.
Referenced by setPresolved().
◆ readNBlocks()
|
static |
reads the nblocks section
- Parameters
-
scip SCIP data structure decinput DEC reading data
Definition at line 636 of file reader_dec.cpp.
References getNextToken(), isInt(), isNewSection(), DecInput::nblocks, NOVALUE, NULL, DecInput::partialdec, SCIP_OKAY, SCIPdebugMessage, gcg::PARTIALDECOMP::setNBlocks(), and syntaxError().
Referenced by readDECFile().
◆ readBlockconss()
|
static |
reads the blocks section
- Parameters
-
scip SCIP data structure decinput DEC reading data readerdata reader data
Definition at line 677 of file reader_dec.cpp.
References DecInput::blocknr, FALSE, gcg::PARTIALDECOMP::fixConsToBlockByName(), GCGisVarRelevant(), gcg::PARTIALDECOMP::getDetprobdata(), gcg::DETPROBDATA::getIndexForCons(), getNextToken(), DecInput::haserror, gcg::PARTIALDECOMP::isConsOpencons(), isNewSection(), DecInput::nblocks, NULL, DecInput::partialdec, DecInput::presolved, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, SCIPconsGetName(), SCIPconsIsActive(), SCIPdebugMessage, SCIPfindCons(), SCIPfindOrigCons(), SCIPfreeBufferArrayNull, SCIPgetConsNVars(), SCIPgetConsVars(), SCIPvarGetProbvar(), SCIPwarningMessage(), syntaxError(), DecInput::token, and TRUE.
Referenced by readDECFile().
◆ readBlockvars()
|
static |
reads the block vars section
- Parameters
-
scip SCIP data structure decinput DEC reading data readerdata reader data
Definition at line 779 of file reader_dec.cpp.
References DecInput::blocknr, gcg::PARTIALDECOMP::fixVarToBlockByName(), getNextToken(), isNewSection(), NULL, DecInput::partialdec, SCIP_OKAY, SCIPfindVar(), SCIPvarGetName(), SCIPvarIsActive(), SCIPwarningMessage(), syntaxError(), and DecInput::token.
Referenced by readDECFile().
◆ readMasterconss()
|
static |
reads the masterconss section
- Parameters
-
scip SCIP data structure decinput DEC reading data readerdata reader data
Definition at line 822 of file reader_dec.cpp.
References gcg::PARTIALDECOMP::fixConsToMaster(), gcg::PARTIALDECOMP::getDetprobdata(), gcg::DETPROBDATA::getIndexForCons(), getNextToken(), isNewSection(), NULL, DecInput::partialdec, SCIP_OKAY, SCIPdebugMessage, syntaxError(), and DecInput::token.
Referenced by readDECFile().
◆ readMastervars()
|
static |
reads the mastervars section
- Parameters
-
scip SCIP data structure decinput DEC reading data readerdata reader data
Definition at line 861 of file reader_dec.cpp.
References gcg::PARTIALDECOMP::fixVarToMasterByName(), getNextToken(), isNewSection(), NULL, DecInput::partialdec, SCIP_OKAY, SCIPdebugMessage, SCIPfindVar(), SCIPvarGetName(), SCIPvarIsActive(), syntaxError(), and DecInput::token.
Referenced by readDECFile().
◆ readLinkingvars()
|
static |
reads the linkingvars section
- Parameters
-
scip SCIP data structure decinput DEC reading data readerdata reader data
Definition at line 906 of file reader_dec.cpp.
References gcg::PARTIALDECOMP::fixVarToLinkingByName(), getNextToken(), isNewSection(), NULL, DecInput::partialdec, SCIP_OKAY, SCIPdebugMessage, SCIPfindVar(), SCIPvarGetName(), SCIPvarIsActive(), SCIPwarningMessage(), syntaxError(), and DecInput::token.
Referenced by readDECFile().
◆ setPresolved()
|
static |
Reads the file and sets the decinput->presolved flag. Resets the file stream afterward.
- Parameters
-
scip SCIP data structure decinput DEC reading data
Definition at line 951 of file reader_dec.cpp.
References DEC_PRESOLVED, DEC_START, DecInput::file, getNextToken(), isNewSection(), readPresolved(), SCIP_CALL, SCIP_OKAY, SCIPrewind(), and DecInput::section.
Referenced by readDECFile().
◆ readDECFile()
|
static |
reads a DEC file
- Parameters
-
scip SCIP data structure reader Reader data structure decinput DEC reading data filename name of the input file
Definition at line 971 of file reader_dec.cpp.
References gcg::COMPLETED_CONSTOMASTER, DEC_BLOCKCONSS, DEC_BLOCKVARS, DEC_END, DEC_INCOMPLETE, DEC_LINKINGVARS, DEC_MASTERCONSS, DEC_MASTERVARS, DEC_NBLOCKS, DEC_PRESOLVED, DEC_START, DecInput::file, SCIP_ReaderData::gcg, GCGconshdlrDecompAddPreexisitingPartialDec(), getNextToken(), DecInput::haserror, hasError(), DecInput::haspresolvesection, DecInput::incomplete, isNewSection(), NULL, DecInput::partialdec, DecInput::presolved, readBlockconss(), readBlockvars(), readIncomplete(), readLinkingvars(), readMasterconss(), readMastervars(), readNBlocks(), readStart(), SCIP_CALL, SCIP_INVALIDDATA, SCIP_NOFILE, SCIP_OKAY, SCIP_STAGE_INIT, SCIP_STAGE_PRESOLVED, SCIP_VERBLEVEL_DIALOG, SCIPerrorMessage, SCIPfclose(), SCIPfopen(), SCIPgetNConss(), SCIPgetNVars(), SCIPgetStage(), SCIPinfoMessage(), SCIPpresolve(), SCIPprintSysError(), SCIPreaderGetData(), SCIPverbMessage(), SCIPwarningMessage(), DecInput::section, setPresolved(), gcg::PARTIALDECOMP::setUsergiven(), and TRUE.
Referenced by readDec().
◆ writePartialdec()
|
static |
write partialdec to file in dec format
- Returns
- scip return code
- Parameters
-
scip SCIP data structure file pointer to file to write to partialdec partialdec to write result will be set to SCIP_SUCCESS if writing was successful
Definition at line 1101 of file reader_dec.cpp.
References b, commentchars, GCGdetectorGetName(), gcg::DETPROBDATA::getCons(), gcg::PARTIALDECOMP::getConssForBlock(), gcg::PARTIALDECOMP::getDetectorchain(), gcg::PARTIALDECOMP::getDetectorchainInfo(), gcg::PARTIALDECOMP::getDetectorClockTimes(), gcg::PARTIALDECOMP::getDetprobdata(), gcg::PARTIALDECOMP::getLinkingvars(), gcg::PARTIALDECOMP::getMasterconss(), gcg::PARTIALDECOMP::getMastervars(), gcg::PARTIALDECOMP::getNBlocks(), gcg::DETPROBDATA::getNConss(), gcg::PARTIALDECOMP::getNConssForBlock(), gcg::PARTIALDECOMP::getNLinkingvars(), gcg::PARTIALDECOMP::getNMasterconss(), gcg::PARTIALDECOMP::getNMastervars(), gcg::PARTIALDECOMP::getNNewBlocks(), gcg::DETPROBDATA::getNVars(), gcg::PARTIALDECOMP::getNVarsForBlock(), gcg::PARTIALDECOMP::getPctConssToBlock(), gcg::PARTIALDECOMP::getPctConssToBorder(), gcg::PARTIALDECOMP::getPctVarsToBlock(), gcg::PARTIALDECOMP::getPctVarsToBorder(), gcg::PARTIALDECOMP::getUsergiven(), gcg::DETPROBDATA::getVar(), gcg::PARTIALDECOMP::getVarsForBlock(), gcg::PARTIALDECOMP::isAssignedToOrigProb(), gcg::PARTIALDECOMP::isComplete(), gcg::NOT, NULL, gcg::PARTIAL, SCIP_OKAY, SCIP_SUCCESS, SCIPconsGetName(), SCIPinfoMessage(), and SCIPvarGetName().
Referenced by SCIP_DECL_READERWRITE().
◆ readDec()
| SCIP_RETCODE readDec | ( | SCIP * | scip, |
| const char * | filename, | ||
| SCIP_RESULT * | result | ||
| ) |
- 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 1209 of file reader_dec.cpp.
References DecInput::blocknr, DEC_MAX_LINELEN, DEC_MAX_PUSHEDTOKENS, DEC_START, FALSE, DecInput::file, DecInput::haserror, DecInput::haspresolvesection, DecInput::incomplete, DecInput::linebuf, DecInput::linenumber, DecInput::linepos, DecInput::nblocks, NOVALUE, DecInput::npushedtokens, NULL, DecInput::presolved, DecInput::pushedtokens, readDECFile(), READER_NAME, SCIP_CALL, SCIP_OKAY, SCIP_READERROR, SCIP_SUCCESS, SCIPallocMemoryArray, SCIPfindReader(), SCIPfreeMemoryArray, DecInput::section, DecInput::token, and DecInput::tokenbuf.
Referenced by SCIP_DECL_READERREAD().
◆ SCIP_DECL_READERFREE()
|
static |
destructor of reader to free user data (called when SCIP is exiting)
Definition at line 1275 of file reader_dec.cpp.
References NULL, SCIP_OKAY, SCIPfreeMemory, and SCIPreaderGetData().
◆ SCIP_DECL_READERREAD()
|
static |
problem reading method of reader
Definition at line 1289 of file reader_dec.cpp.
References NULL, readDec(), SCIP_CALL, SCIP_OKAY, SCIP_STAGE_INIT, SCIP_VERBLEVEL_DIALOG, SCIPgetNConss(), SCIPgetNVars(), SCIPgetStage(), and SCIPverbMessage().
◆ SCIP_DECL_READERWRITE()
|
static |
problem writing method of reader
Definition at line 1305 of file reader_dec.cpp.
References SCIP_ReaderData::gcg, GCGgetPartialdecToWrite(), NULL, SCIP_OKAY, SCIPreaderGetData(), SCIPwarningMessage(), and writePartialdec().
◆ GCGincludeReaderDec()
| SCIP_RETCODE GCGincludeReaderDec | ( | GCG * | gcg | ) |
includes the dec file reader in SCIP
- Parameters
-
gcg GCG data structure
Definition at line 1330 of file reader_dec.cpp.
References SCIP_ReaderData::gcg, GCGgetOrigprob(), NULL, READER_DESC, READER_EXTENSION, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPallocMemory, and SCIPincludeReader().
Referenced by GCGincludeGcgPlugins().
Variable Documentation
◆ NOVALUE
|
static |
Definition at line 110 of file reader_dec.cpp.
Referenced by readDec(), and readNBlocks().
◆ LINKINGVALUE
|
static |
Definition at line 111 of file reader_dec.cpp.
◆ delimchars
|
static |
Definition at line 112 of file reader_dec.cpp.
Referenced by isDelimChar().
◆ tokenchars
|
static |
Definition at line 113 of file reader_dec.cpp.
Referenced by isTokenChar().
◆ commentchars
|
static |
Definition at line 114 of file reader_dec.cpp.
Referenced by getNextLine(), and writePartialdec().