GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
reader_dec.cpp File Reference

Detailed Description

DEC file reader for structure information.

Author
Lukas Kirchhart
Martin Bergner
Gerald Gamrath
Christian Puchert
Michael Bastubbe

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

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
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.

Referenced by getNextLine(), getNextToken(), and readDec().

◆ DEC_MAX_PUSHEDTOKENS

#define DEC_MAX_PUSHEDTOKENS   2

Definition at line 66 of file reader_dec.cpp.

Referenced by pushToken(), and readDec().

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

typedef struct DecInput 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()

void syntaxError ( SCIP * scip,
DECINPUT * decinput,
const char * msg )
static

issues an error message and marks the DEC data to have errors

Parameters
scipSCIP data structure
decinputDEC reading data
msgerror message

Definition at line 122 of file reader_dec.cpp.

References assert(), DEC_END, DecInput::haserror, DecInput::linebuf, DecInput::linenumber, DecInput::linepos, DecInput::section, syntaxError(), and DecInput::token.

◆ hasError()

SCIP_Bool hasError ( DECINPUT * decinput)
static

returns whether a syntax error was detected

Parameters
decinputDEC reading data

Definition at line 150 of file reader_dec.cpp.

References assert(), hasError(), and DecInput::haserror.

◆ isDelimChar()

SCIP_Bool isDelimChar ( char c)
static

returns whether the given character is a token delimiter

Parameters
cinput character

Definition at line 160 of file reader_dec.cpp.

References c, delimchars, and isDelimChar().

◆ isTokenChar()

SCIP_Bool isTokenChar ( char c)
static

returns whether the given character is a single token

Parameters
cinput character

Definition at line 169 of file reader_dec.cpp.

References c, isTokenChar(), and tokenchars.

◆ isValueChar()

SCIP_Bool isValueChar ( char c,
char nextc,
SCIP_Bool firstchar,
SCIP_Bool * hasdot,
DECEXPTYPE * exptype )
static

returns whether the current character is member of a value string

Parameters
cinput character
nextcnext input character
firstcharis the given character the first char of the token?
hasdotpointer to update the dot flag
exptypepointer to update the exponent type

Definition at line 178 of file reader_dec.cpp.

References assert(), c, and isValueChar().

◆ getNextLine()

SCIP_Bool getNextLine ( DECINPUT * decinput)
static

reads the next line from the input file into the line buffer; skips comments; returns whether a line could be read

Parameters
decinputDEC reading data

Definition at line 199 of file reader_dec.cpp.

References assert(), commentchars, DEC_MAX_LINELEN, DecInput::file, getNextLine(), DecInput::haserror, i, DecInput::linebuf, DecInput::linenumber, and DecInput::linepos.

◆ swapPointers()

void swapPointers ( char ** pointer1,
char ** pointer2 )
static

swaps the addresses of two pointers

Parameters
pointer1first pointer
pointer2second pointer

Definition at line 243 of file reader_dec.cpp.

References swapPointers().

◆ getNextToken()

SCIP_Bool getNextToken ( DECINPUT * decinput)
static

reads the next token from the input file into the token buffer; returns whether a token was read

Parameters
decinputDEC reading data

Definition at line 257 of file reader_dec.cpp.

References assert(), DEC_END, DEC_EXP_NONE, DEC_MAX_LINELEN, getNextLine(), getNextToken(), isDelimChar(), isTokenChar(), isValueChar(), DecInput::linebuf, DecInput::linenumber, DecInput::linepos, DecInput::npushedtokens, DecInput::pushedtokens, SCIPdebugMessage(), DecInput::section, swapPointers(), and DecInput::token.

◆ pushToken()

void pushToken ( DECINPUT * decinput)
static

puts the current token on the token stack, such that it is read at the next call to getNextToken()

Parameters
decinputDEC reading data

Definition at line 356 of file reader_dec.cpp.

References assert(), DEC_MAX_PUSHEDTOKENS, DecInput::npushedtokens, DecInput::pushedtokens, pushToken(), swapPointers(), and DecInput::token.

◆ swapTokenBuffer()

void swapTokenBuffer ( DECINPUT * decinput)
static

swaps the current token with the token buffer

Parameters
decinputDEC reading data

Definition at line 369 of file reader_dec.cpp.

References assert(), swapPointers(), swapTokenBuffer(), DecInput::token, and DecInput::tokenbuf.

◆ isInt()

SCIP_Bool isInt ( SCIP * scip,
DECINPUT * decinput,
int * value )
static

returns whether the current token is a value

Parameters
scipSCIP data structure
decinputDEC reading data
valuepointer to store the value (unchanged, if token is no value)

Definition at line 380 of file reader_dec.cpp.

References assert(), isInt(), and DecInput::token.

◆ isNewSection()

SCIP_Bool isNewSection ( SCIP * scip,
DECINPUT * decinput )
static

checks whether the current token is a section identifier, and if yes, switches to the corresponding section

Parameters
scipSCIP data structure
decinputDEC reading data

Definition at line 408 of file reader_dec.cpp.

References assert(), DecInput::blocknr, DEC_BLOCKCONSS, DEC_BLOCKVARS, DEC_INCOMPLETE, DEC_LINKINGVARS, DEC_MASTERCONSS, DEC_MASTERVARS, DEC_NBLOCKS, DEC_PRESOLVED, getNextToken(), isInt(), isNewSection(), DecInput::linenumber, pushToken(), SCIPdebugMessage(), DecInput::section, swapTokenBuffer(), syntaxError(), and DecInput::token.

◆ readStart()

SCIP_RETCODE readStart ( SCIP * scip,
DECINPUT * decinput )
static

reads the header of the file

Parameters
scipSCIP data structure
decinputDEC reading data

Definition at line 538 of file reader_dec.cpp.

References assert(), getNextToken(), isNewSection(), and readStart().

◆ readIncomplete()

SCIP_RETCODE readIncomplete ( SCIP * scip,
DECINPUT * decinput )
static

reads the incomplete section

Parameters
scipSCIP data structure
decinputDEC reading data

Definition at line 559 of file reader_dec.cpp.

References assert(), getNextToken(), DecInput::incomplete, isInt(), isNewSection(), readIncomplete(), SCIPdebugMessage(), and syntaxError().

Referenced by readDECFile(), and readIncomplete().

◆ readPresolved()

SCIP_RETCODE readPresolved ( SCIP * scip,
DECINPUT * decinput )
static

reads the presolved section

Parameters
scipSCIP data structure
decinputDEC reading data

Definition at line 596 of file reader_dec.cpp.

References assert(), getNextToken(), DecInput::haspresolvesection, isInt(), isNewSection(), DecInput::presolved, readPresolved(), SCIPdebugMessage(), and syntaxError().

◆ readNBlocks()

SCIP_RETCODE readNBlocks ( SCIP * scip,
DECINPUT * decinput )
static

reads the nblocks section

Parameters
scipSCIP data structure
decinputDEC reading data

Definition at line 636 of file reader_dec.cpp.

References assert(), getNextToken(), isInt(), isNewSection(), DecInput::nblocks, NOVALUE, DecInput::partialdec, readNBlocks(), SCIPdebugMessage(), gcg::PARTIALDECOMP::setNBlocks(), and syntaxError().

◆ readBlockconss()

◆ readBlockvars()

SCIP_RETCODE readBlockvars ( SCIP * scip,
DECINPUT * decinput,
SCIP_READERDATA * readerdata )
static

reads the block vars section

Parameters
scipSCIP data structure
decinputDEC reading data
readerdatareader data

Definition at line 779 of file reader_dec.cpp.

References assert(), DecInput::blocknr, gcg::PARTIALDECOMP::fixVarToBlockByName(), getNextToken(), isNewSection(), DecInput::partialdec, readBlockvars(), syntaxError(), DecInput::token, and var.

Referenced by readBlockvars(), and readDECFile().

◆ readMasterconss()

SCIP_RETCODE readMasterconss ( SCIP * scip,
DECINPUT * decinput,
SCIP_READERDATA * readerdata )
static

reads the masterconss section

Parameters
scipSCIP data structure
decinputDEC reading data
readerdatareader data

Definition at line 822 of file reader_dec.cpp.

References assert(), gcg::PARTIALDECOMP::fixConsToMaster(), gcg::PARTIALDECOMP::getDetprobdata(), gcg::DETPROBDATA::getIndexForCons(), getNextToken(), isNewSection(), DecInput::partialdec, readMasterconss(), SCIPdebugMessage(), syntaxError(), and DecInput::token.

◆ readMastervars()

SCIP_RETCODE readMastervars ( SCIP * scip,
DECINPUT * decinput,
SCIP_READERDATA * readerdata )
static

reads the mastervars section

Parameters
scipSCIP data structure
decinputDEC reading data
readerdatareader data

Definition at line 861 of file reader_dec.cpp.

References assert(), gcg::PARTIALDECOMP::fixVarToMasterByName(), getNextToken(), isNewSection(), DecInput::partialdec, readMastervars(), SCIPdebugMessage(), syntaxError(), DecInput::token, and var.

Referenced by readDECFile(), and readMastervars().

◆ readLinkingvars()

SCIP_RETCODE readLinkingvars ( SCIP * scip,
DECINPUT * decinput,
SCIP_READERDATA * readerdata )
static

reads the linkingvars section

Parameters
scipSCIP data structure
decinputDEC reading data
readerdatareader data

Definition at line 906 of file reader_dec.cpp.

References assert(), gcg::PARTIALDECOMP::fixVarToLinkingByName(), getNextToken(), isNewSection(), DecInput::partialdec, readLinkingvars(), SCIPdebugMessage(), syntaxError(), DecInput::token, and var.

Referenced by readDECFile(), and readLinkingvars().

◆ setPresolved()

SCIP_RETCODE setPresolved ( SCIP * scip,
DECINPUT * decinput )
static

Reads the file and sets the decinput->presolved flag. Resets the file stream afterward.

Parameters
scipSCIP data structure
decinputDEC reading data

Definition at line 951 of file reader_dec.cpp.

References DEC_PRESOLVED, DEC_START, DecInput::file, getNextToken(), isNewSection(), readPresolved(), SCIP_CALL(), DecInput::section, and setPresolved().

Referenced by readDECFile(), and setPresolved().

◆ readDECFile()

◆ writePartialdec()

SCIP_RETCODE writePartialdec ( SCIP * scip,
FILE * file,
gcg::PARTIALDECOMP * partialdec,
SCIP_RESULT * result )
static

◆ readDec()

SCIP_RETCODE readDec ( SCIP * scip,
const char * filename,
SCIP_RESULT * result )

◆ SCIP_DECL_READERFREE()

SCIP_DECL_READERFREE ( readerFreeDec )
static

destructor of reader to free user data (called when SCIP is exiting)

Definition at line 1275 of file reader_dec.cpp.

References assert(), and SCIPfreeMemory().

◆ SCIP_DECL_READERREAD()

SCIP_DECL_READERREAD ( readerReadDec )
static

problem reading method of reader

Definition at line 1289 of file reader_dec.cpp.

References readDec(), result, and SCIP_CALL().

◆ SCIP_DECL_READERWRITE()

SCIP_DECL_READERWRITE ( readerWriteDec )
static

problem writing method of reader

Definition at line 1305 of file reader_dec.cpp.

References assert(), SCIP_ReaderData::gcg, GCGgetPartialdecToWrite(), result, and writePartialdec().

◆ GCGincludeReaderDec()

SCIP_RETCODE GCGincludeReaderDec ( GCG * gcg)

includes the dec file reader in SCIP

includes the dec file reader into SCIP

Parameters
gcgGCG data structure

Definition at line 1330 of file reader_dec.cpp.

References assert(), SCIP_ReaderData::gcg, GCGgetOrigprob(), GCGincludeReaderDec(), origprob, READER_DESC, READER_EXTENSION, READER_NAME, and SCIP_CALL().

Referenced by GCGincludeGcgPlugins(), and GCGincludeReaderDec().

Variable Documentation

◆ NOVALUE

const int NOVALUE = -1
static

Definition at line 110 of file reader_dec.cpp.

◆ LINKINGVALUE

const int LINKINGVALUE = -2
static

Definition at line 111 of file reader_dec.cpp.

◆ delimchars

const char delimchars[] = " \f\n\r\t\v"
static

Definition at line 112 of file reader_dec.cpp.

◆ tokenchars

const char tokenchars[] = "-+:<>="
static

Definition at line 113 of file reader_dec.cpp.

◆ commentchars

const char commentchars[] = "\\"
static

Definition at line 114 of file reader_dec.cpp.