Detailed Description
REF file reader for structure information.
Definition in file reader_ref.c.
#include <stdlib.h>#include <assert.h>#include <string.h>#include <ctype.h>#include "gcg/reader_ref.h"#include "gcg/gcg.h"#include "scip/cons_linear.h"#include "gcg/cons_decomp.h"#include "gcg/relax_gcg.h"Go to the source code of this file.
Data Structures | |
| struct | RefInput |
| struct | SCIP_ReaderData |
Macros | |
| #define | READER_NAME "refreader" |
| #define | READER_DESC "file reader for blocks corresponding to a mip in lpb format" |
| #define | READER_EXTENSION "ref" |
| #define | REF_MAX_LINELEN 65536 |
| #define | REF_MAX_PUSHEDTOKENS 2 |
Typedefs | |
| typedef enum RefSection | REFSECTION |
| typedef enum RefExpType | REFEXPTYPE |
| typedef struct RefInput | REFINPUT |
Enumerations | |
| enum | RefSection { REF_START , REF_NBLOCKS , REF_BLOCKSIZES , REF_BLOCKS , REF_END } |
| enum | RefExpType { REF_EXP_NONE , REF_EXP_UNSIGNED , REF_EXP_SIGNED } |
Functions | |
| static void | syntaxError (SCIP *scip, REFINPUT *refinput, const char *msg) |
| static SCIP_Bool | hasError (REFINPUT *refinput) |
| 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, REFEXPTYPE *exptype) |
| static SCIP_Bool | getNextLine (REFINPUT *refinput) |
| static SCIP_Bool | getNextToken (REFINPUT *refinput) |
| static SCIP_Bool | isInt (SCIP *scip, REFINPUT *refinput, int *value) |
| static SCIP_RETCODE | readStart (SCIP *scip, REFINPUT *refinput) |
| static SCIP_RETCODE | readNBlocks (SCIP *scip, REFINPUT *refinput) |
| static SCIP_RETCODE | readBlockSizes (SCIP *scip, REFINPUT *refinput) |
| static SCIP_RETCODE | readBlocks (SCIP *scip, REFINPUT *refinput) |
| static SCIP_RETCODE | readREFFile (SCIP *scip, SCIP_READER *reader, REFINPUT *refinput, GCG_DECOMP *decomp, const char *filename) |
| static SCIP_RETCODE | writeREFFile (SCIP *scip, SCIP_READER *reader, FILE *file) |
| static SCIP_RETCODE | readRef (SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result) |
| static | SCIP_DECL_READERFREE (readerFreeRef) |
| static | SCIP_DECL_READERREAD (readerReadRef) |
| static | SCIP_DECL_READERWRITE (readerWriteRef) |
| SCIP_RETCODE | GCGincludeReaderRef (GCG *gcg) |
Variables | |
| 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 "refreader" |
Definition at line 49 of file reader_ref.c.
◆ READER_DESC
| #define READER_DESC "file reader for blocks corresponding to a mip in lpb format" |
Definition at line 50 of file reader_ref.c.
◆ READER_EXTENSION
| #define READER_EXTENSION "ref" |
Definition at line 51 of file reader_ref.c.
◆ REF_MAX_LINELEN
| #define REF_MAX_LINELEN 65536 |
Definition at line 56 of file reader_ref.c.
◆ REF_MAX_PUSHEDTOKENS
| #define REF_MAX_PUSHEDTOKENS 2 |
Definition at line 57 of file reader_ref.c.
Typedef Documentation
◆ REFSECTION
| typedef enum RefSection REFSECTION |
Definition at line 64 of file reader_ref.c.
◆ REFEXPTYPE
| typedef enum RefExpType REFEXPTYPE |
Definition at line 70 of file reader_ref.c.
◆ REFINPUT
Definition at line 97 of file reader_ref.c.
Enumeration Type Documentation
◆ RefSection
| enum RefSection |
section in REF File
| Enumerator | |
|---|---|
| REF_START | |
| REF_NBLOCKS | |
| REF_BLOCKSIZES | |
| REF_BLOCKS | |
| REF_END | |
Definition at line 60 of file reader_ref.c.
◆ RefExpType
| enum RefExpType |
| Enumerator | |
|---|---|
| REF_EXP_NONE | |
| REF_EXP_UNSIGNED | |
| REF_EXP_SIGNED | |
Definition at line 66 of file reader_ref.c.
Function Documentation
◆ syntaxError()
issues an error message and marks the REF data to have errors
- Parameters
-
scip SCIP data structure refinput REF reading data msg error message
Definition at line 115 of file reader_ref.c.
References RefInput::haserror, RefInput::linebuf, RefInput::linenumber, RefInput::linepos, NULL, REF_END, SCIP_VERBLEVEL_MINIMAL, SCIPsnprintf(), SCIPverbMessage(), RefInput::section, RefInput::token, and TRUE.
Referenced by readBlocks(), readBlockSizes(), and readNBlocks().
◆ hasError()
returns whether a syntax error was detected
- Parameters
-
refinput REF reading data
Definition at line 143 of file reader_ref.c.
References RefInput::haserror, NULL, and SCIP_Bool.
Referenced by readREFFile().
◆ isDelimChar()
|
static |
returns whether the given character is a token delimiter
- Parameters
-
c input character
Definition at line 154 of file reader_ref.c.
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 163 of file reader_ref.c.
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 172 of file reader_ref.c.
References FALSE, NULL, REF_EXP_NONE, REF_EXP_SIGNED, REF_EXP_UNSIGNED, 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
-
refinput REF reading data
Definition at line 216 of file reader_ref.c.
References BMSclearMemoryArray, commentchars, FALSE, RefInput::file, RefInput::haserror, RefInput::linebuf, RefInput::linenumber, RefInput::linepos, NULL, REF_MAX_LINELEN, SCIP_Bool, SCIPerrorMessage, SCIPfgets(), and TRUE.
Referenced by getNextToken().
◆ getNextToken()
reads the next token from the input file into the token buffer; returns whether a token was read
- Parameters
-
refinput REF reading data
Definition at line 260 of file reader_ref.c.
References RefInput::blocknr, FALSE, getNextLine(), isDelimChar(), isTokenChar(), isValueChar(), RefInput::linebuf, RefInput::linenumber, RefInput::linepos, RefInput::npushedtokens, NULL, RefInput::pushedtokens, REF_BLOCKS, REF_BLOCKSIZES, REF_END, REF_EXP_NONE, REF_MAX_LINELEN, REF_NBLOCKS, REF_START, SCIP_Bool, SCIPdebugMessage, SCIPswapPointers(), RefInput::section, RefInput::token, and TRUE.
Referenced by readBlocks(), readBlockSizes(), readNBlocks(), and readStart().
◆ isInt()
returns whether the current token is a value
- Parameters
-
scip SCIP data structure refinput REF reading data value pointer to store the value (unchanged, if token is no value)
Definition at line 368 of file reader_ref.c.
References FALSE, NULL, SCIP_Bool, SCIPstrcasecmp(), RefInput::token, and TRUE.
Referenced by readBlocks(), readBlockSizes(), and readNBlocks().
◆ readStart()
|
static |
reads the header of the file
- Parameters
-
scip SCIP data structure refinput REF reading data
Definition at line 397 of file reader_ref.c.
References getNextToken(), NULL, and SCIP_OKAY.
Referenced by readREFFile().
◆ readNBlocks()
|
static |
reads the nblocks section
- Parameters
-
scip SCIP data structure refinput REF reading data
Definition at line 411 of file reader_ref.c.
References RefInput::blocksizes, getNextToken(), isInt(), RefInput::nblocks, NULL, REF_BLOCKSIZES, SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, SCIPdebugMessage, RefInput::section, and syntaxError().
Referenced by readREFFile().
◆ readBlockSizes()
|
static |
reads the blocksizes section
- Parameters
-
scip SCIP data structure refinput REF reading data
Definition at line 445 of file reader_ref.c.
References RefInput::blocksizes, getNextToken(), isInt(), RefInput::nblocks, NULL, SCIP_OKAY, syntaxError(), and RefInput::totalconss.
Referenced by readREFFile().
◆ readBlocks()
|
static |
reads the blocks section
- Parameters
-
scip SCIP data structure refinput REF reading data
Definition at line 473 of file reader_ref.c.
References RefInput::blocknr, RefInput::blocksizes, RefInput::constoblock, getNextToken(), isInt(), RefInput::nassignedvars, RefInput::nblocks, NULL, SCIP_CALL, SCIP_OKAY, SCIPconsGetHdlr(), SCIPconshdlrGetName(), SCIPdebugMessage, SCIPgetConss(), SCIPgetNVarsLinear(), SCIPgetVarsLinear(), SCIPhashmapExists(), SCIPhashmapGetImage(), SCIPhashmapRemove(), SCIPhashmapSetImage(), SCIPvarGetName(), syntaxError(), RefInput::totalreadconss, and RefInput::vartoblock.
Referenced by readREFFile().
◆ readREFFile()
|
static |
reads an REF file
- Parameters
-
scip SCIP data structure reader reader data structure refinput REF reading data decomp decomposition structure filename name of the input file
Definition at line 561 of file reader_ref.c.
References RefInput::constoblock, FALSE, RefInput::file, SCIP_ReaderData::gcg, GCGdecompSetDetector(), GCGdecompSetNBlocks(), GCGdecompSetPresolved(), GCGfilloutDecompFromHashmaps(), hasError(), RefInput::nblocks, NULL, readBlocks(), readBlockSizes(), readNBlocks(), readStart(), REF_BLOCKS, REF_BLOCKSIZES, REF_END, REF_NBLOCKS, REF_START, SCIP_CALL, SCIP_CALL_QUIET, SCIP_INVALIDDATA, SCIP_NOFILE, SCIP_OKAY, SCIP_STAGE_PRESOLVED, SCIP_STAGE_TRANSFORMED, SCIP_VERBLEVEL_MINIMAL, SCIPerrorMessage, SCIPfclose(), SCIPfopen(), SCIPgetStage(), SCIPprintSysError(), SCIPreaderGetData(), SCIPtransformProb(), SCIPverbMessage(), RefInput::section, and RefInput::vartoblock.
Referenced by readRef().
◆ writeREFFile()
|
static |
writes a Ref file
- Parameters
-
scip SCIP data structure reader ref reader file target file
Definition at line 638 of file reader_ref.c.
References SCIP_ReaderData::gcg, GCGdecompFree(), GCGdecompGetNBlocks(), GCGdecompGetNSubscipconss(), GCGdecompGetSubscipconss(), GCGgetBestDecomp(), GCGgetStructDecomp(), NULL, SCIP_CALL, SCIP_OKAY, SCIPblkmem(), SCIPconsGetName(), SCIPdebugMessage, SCIPfindCons(), SCIPgetNOrigConss(), SCIPgetOrigConss(), SCIPhashmapCreate(), SCIPhashmapFree(), SCIPhashmapGetImage(), SCIPhashmapInsert(), SCIPinfoMessage(), SCIPreaderGetData(), SCIPwarningMessage(), and TRUE.
Referenced by SCIP_DECL_READERWRITE().
◆ readRef()
|
static |
reads problem from file
- Parameters
-
scip SCIP data structure reader the file reader itself 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 732 of file reader_ref.c.
References RefInput::blocknr, RefInput::blocksizes, RefInput::constoblock, FALSE, RefInput::file, SCIP_ReaderData::gcg, GCGconshdlrDecompAddPreexistingDecomp(), GCGdecompCreate(), GCGdecompFree(), GCGvarGetBlock(), RefInput::haserror, RefInput::linebuf, RefInput::linenumber, RefInput::linepos, RefInput::masterconss, RefInput::nassignedvars, RefInput::nblocks, RefInput::nmasterconss, RefInput::npushedtokens, NULL, RefInput::pushedtokens, readREFFile(), REF_MAX_LINELEN, REF_MAX_PUSHEDTOKENS, SCIP_CALL, SCIP_OKAY, SCIP_READERROR, SCIP_SUCCESS, SCIPallocBufferArray, SCIPallocMemoryArray, SCIPblkmem(), SCIPdebugMessage, SCIPfreeBufferArray, SCIPfreeMemoryArray, SCIPgetNConss(), SCIPgetNVars(), SCIPgetVarsData(), SCIPhashmapCreate(), SCIPreaderGetData(), SCIPvarGetName(), RefInput::token, RefInput::tokenbuf, RefInput::totalconss, RefInput::totalreadconss, and RefInput::vartoblock.
Referenced by SCIP_DECL_READERREAD().
◆ SCIP_DECL_READERFREE()
|
static |
destructor of reader to free user data (called when SCIP is exiting)
Definition at line 832 of file reader_ref.c.
References NULL, SCIP_OKAY, SCIPfreeMemory, and SCIPreaderGetData().
◆ SCIP_DECL_READERREAD()
|
static |
problem reading method of reader
Definition at line 845 of file reader_ref.c.
References NULL, readRef(), 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 861 of file reader_ref.c.
References SCIP_CALL, SCIP_OKAY, SCIP_SUCCESS, and writeREFFile().
◆ GCGincludeReaderRef()
| SCIP_RETCODE GCGincludeReaderRef | ( | GCG * | gcg | ) |
includes the ref file reader in SCIP
- Parameters
-
gcg GCG data structure
Definition at line 874 of file reader_ref.c.
References SCIP_ReaderData::gcg, GCGgetOrigprob(), NULL, READER_DESC, READER_EXTENSION, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPallocMemory, and SCIPincludeReader().
Referenced by GCGincludeGcgPlugins().
Variable Documentation
◆ delimchars
|
static |
Definition at line 104 of file reader_ref.c.
Referenced by isDelimChar().
◆ tokenchars
|
static |
Definition at line 105 of file reader_ref.c.
Referenced by isTokenChar().
◆ commentchars
|
static |
Definition at line 106 of file reader_ref.c.
Referenced by getNextLine().