reader_dec.cpp File Reference
#include <assert.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include "reader_dec.h"
#include "scip_misc.h"
#include "pub_gcgvar.h"
#include "cons_decomp.h"
#include "pub_decomp.h"
#include "class_seeed.h"

Go to the source code of this file.

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 gcg::SeeedSeeedPtr
 
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 readDECFile (SCIP *scip, SCIP_READER *reader, DECINPUT *decinput, const char *filename)
 
static SCIP_DECL_READERFREE (readerFreeDec)
 
static SCIP_DECL_READERREAD (readerReadDec)
 
static SCIP_DECL_READERWRITE (readerWriteDec)
 
SCIP_RETCODE SCIPincludeReaderDec (SCIP *scip)
 
SCIP_RETCODE SCIPreadDec (SCIP *scip, const char *filename, SCIP_RESULT *result)
 
static SCIP_RETCODE writeData (SCIP *scip, FILE *file, DEC_DECOMP *decdecomp)
 
SCIP_RETCODE GCGwriteDecomp (SCIP *scip, FILE *file, DEC_DECOMP *decdecomp)
 

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

#define DEC_MAX_LINELEN   65536

Definition at line 66 of file reader_dec.cpp.

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

#define DEC_MAX_PUSHEDTOKENS   2

Definition at line 67 of file reader_dec.cpp.

Referenced by pushToken(), and SCIPreadDec().

#define READER_DESC   "file reader for blocks in dec format"

Definition at line 59 of file reader_dec.cpp.

Referenced by SCIPincludeReaderDec().

#define READER_EXTENSION   "dec"

Definition at line 60 of file reader_dec.cpp.

Referenced by SCIPincludeReaderDec().

#define READER_NAME   "decreader"

Definition at line 58 of file reader_dec.cpp.

Referenced by SCIPincludeReaderDec(), and SCIPreadDec().

Typedef Documentation

typedef enum DecExpType DECEXPTYPE

Definition at line 81 of file reader_dec.cpp.

typedef struct DecInput DECINPUT

Definition at line 103 of file reader_dec.cpp.

typedef enum DecSection DECSECTION

Definition at line 74 of file reader_dec.cpp.

typedef gcg::Seeed* SeeedPtr

Definition at line 56 of file reader_dec.cpp.

Enumeration Type Documentation

enum DecExpType

exponent indicator of the a value

Enumerator
DEC_EXP_NONE 

Definition at line 77 of file reader_dec.cpp.

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 70 of file reader_dec.cpp.

Function Documentation

SCIP_RETCODE GCGwriteDecomp ( SCIP *  scip,
FILE *  file,
DEC_DECOMP decdecomp 
)

write a DEC file for a given decomposition

Parameters
scipSCIP data structure
fileFile pointer to write to
decdecompDecomposition pointer

Definition at line 1405 of file reader_dec.cpp.

References DECdecompGetNBlocks(), and writeData().

Referenced by SCIP_DECL_DIALOGEXEC().

static 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 203 of file reader_dec.cpp.

References commentchars, DEC_MAX_LINELEN, DecInput::file, DecInput::haserror, DecInput::linebuf, DecInput::linenumber, and DecInput::linepos.

Referenced by getNextToken().

static SCIP_Bool getNextToken ( DECINPUT decinput)
static
static SCIP_Bool hasError ( DECINPUT decinput)
static

returns whether a syntax error was detected

Parameters
decinputDEC reading data

Definition at line 153 of file reader_dec.cpp.

References DecInput::haserror.

Referenced by readDECFile().

static SCIP_Bool isDelimChar ( char  c)
static

returns whether the given character is a token delimiter

Parameters
cinput character

Definition at line 164 of file reader_dec.cpp.

References delimchars.

Referenced by getNextToken().

static 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 384 of file reader_dec.cpp.

References DecInput::token.

Referenced by isNewSection(), readIncomplete(), readNBlocks(), and readPresolved().

static 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 412 of file reader_dec.cpp.

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

Referenced by readBlockconss(), readBlockvars(), readIncomplete(), readLinkingvars(), readMasterconss(), readMastervars(), readNBlocks(), readPresolved(), and readStart().

static SCIP_Bool isTokenChar ( char  c)
static

returns whether the given character is a single token

Parameters
cinput character

Definition at line 173 of file reader_dec.cpp.

References tokenchars.

Referenced by getNextToken().

static 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 182 of file reader_dec.cpp.

Referenced by getNextToken().

static 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 360 of file reader_dec.cpp.

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

Referenced by isNewSection().

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

reads the blocks section

Parameters
scipSCIP data structure
decinputDEC reading data
readerdatareader data

Definition at line 682 of file reader_dec.cpp.

References DecInput::blocknr, GCGisVarRelevant(), getNextToken(), DecInput::haserror, isNewSection(), LINKINGVALUE, DecInput::presolved, SCIPconshdlrDecompUserSeeedSetConsToBlock(), syntaxError(), and DecInput::token.

Referenced by readDECFile().

static 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 776 of file reader_dec.cpp.

References DecInput::blocknr, getNextToken(), isNewSection(), SCIPconshdlrDecompUserSeeedSetVarToBlock(), syntaxError(), and DecInput::token.

Referenced by readDECFile().

static SCIP_RETCODE readDECFile ( SCIP *  scip,
SCIP_READER *  reader,
DECINPUT decinput,
const char *  filename 
)
static

DEPRECATED : delete fills the whole Decomp struct after the dec file has been read reads a DEC file

call cons_decomp to create seeed (and correct seeedpool if necessary) seeed from the right seeedpool

Parameters
scipSCIP data structure
readerReader data structure
decinputDEC reading data
filenamename of the input file

Definition at line 1015 of file reader_dec.cpp.

References DEC_BLOCKCONSS, DEC_BLOCKVARS, DEC_END, DEC_INCOMPLETE, DEC_LINKINGVARS, DEC_MASTERCONSS, DEC_MASTERVARS, DEC_NBLOCKS, DEC_PRESOLVED, DEC_START, DecInput::file, DecInput::haserror, hasError(), DecInput::haspresolvesection, DecInput::incomplete, LINKINGVALUE, DecInput::presolved, readBlockconss(), readBlockvars(), readIncomplete(), readLinkingvars(), readMasterconss(), readMastervars(), readNBlocks(), readPresolved(), readStart(), SCIPconshdlrDecompCreateSeeedpool(), SCIPconshdlrDecompCreateSeeedpoolUnpresolved(), SCIPconshdlrDecompCreateUserSeeed(), SCIPconshdlrDecompUserSeeedFlush(), SCIPconshdlrDecompUserSeeedReject(), and DecInput::section.

Referenced by SCIPreadDec().

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

reads the incomplete section

Parameters
scipSCIP data structure
decinputDEC reading data

Definition at line 564 of file reader_dec.cpp.

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

Referenced by readDECFile().

static 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 916 of file reader_dec.cpp.

References getNextToken(), isNewSection(), SCIPconshdlrDecompUserSeeedSetVarToLinking(), syntaxError(), and DecInput::token.

Referenced by readDECFile().

static 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 827 of file reader_dec.cpp.

References getNextToken(), isNewSection(), LINKINGVALUE, SCIPconshdlrDecompUserSeeedSetConsToMaster(), syntaxError(), and DecInput::token.

Referenced by readDECFile().

static 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 872 of file reader_dec.cpp.

References getNextToken(), isNewSection(), SCIPconshdlrDecompUserSeeedSetVarToMaster(), syntaxError(), and DecInput::token.

Referenced by readDECFile().

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

reads the nblocks section

Parameters
scipSCIP data structure
decinputDEC reading data

Definition at line 642 of file reader_dec.cpp.

References getNextToken(), isInt(), isNewSection(), DecInput::nblocks, NOVALUE, SCIPconshdlrDecompUserSeeedSetnumberOfBlocks(), and syntaxError().

Referenced by readDECFile().

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

reads the presolved section

Parameters
scipSCIP data structure
decinputDEC reading data

Definition at line 601 of file reader_dec.cpp.

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

Referenced by readDECFile().

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

reads the header of the file

Parameters
scipSCIP data structure
decinputDEC reading data

Definition at line 543 of file reader_dec.cpp.

References getNextToken(), and isNewSection().

Referenced by readDECFile().

static SCIP_DECL_READERFREE ( readerFreeDec  )
static

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

Definition at line 1191 of file reader_dec.cpp.

static SCIP_DECL_READERREAD ( readerReadDec  )
static

problem reading method of reader

Definition at line 1205 of file reader_dec.cpp.

References SCIPreadDec().

static SCIP_DECL_READERWRITE ( readerWriteDec  )
static

problem writing method of reader

Definition at line 1221 of file reader_dec.cpp.

References DecInput::file, SCIPconshdlrDecompWriteDec(), and gcg::transformed.

SCIP_RETCODE SCIPincludeReaderDec ( SCIP *  scip)

includes the dec file reader in SCIP

Parameters
scipSCIP data structure

Definition at line 1237 of file reader_dec.cpp.

References READER_DESC, READER_EXTENSION, and READER_NAME.

Referenced by SCIPincludeGcgPlugins().

SCIP_RETCODE SCIPreadDec ( SCIP *  scip,
const char *  filename,
SCIP_RESULT *  result 
)
Parameters
scipSCIP data structure
filenamefull path and name of file to read, or NULL if stdin should be used
resultpointer to store the result of the file reading call

Definition at line 1254 of file reader_dec.cpp.

References DecInput::blocknr, DEC_MAX_LINELEN, DEC_MAX_PUSHEDTOKENS, DEC_START, DecInput::file, DecInput::haserror, DecInput::haspresolvesection, DecInput::incomplete, DecInput::linebuf, DecInput::linenumber, DecInput::linepos, DecInput::nblocks, NOVALUE, DecInput::npushedtokens, DecInput::presolved, DecInput::pushedtokens, readDECFile(), READER_NAME, DecInput::section, DecInput::token, and DecInput::tokenbuf.

Referenced by SCIP_DECL_READERREAD().

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

swaps the addresses of two pointers

Parameters
pointer1first pointer
pointer2second pointer

Definition at line 247 of file reader_dec.cpp.

Referenced by getNextToken(), pushToken(), and swapTokenBuffer().

static void swapTokenBuffer ( DECINPUT decinput)
static

swaps the current token with the token buffer

Parameters
decinputDEC reading data

Definition at line 373 of file reader_dec.cpp.

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

Referenced by isNewSection().

static 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 125 of file reader_dec.cpp.

References DEC_END, DecInput::haserror, DecInput::linebuf, DecInput::linenumber, DecInput::linepos, DecInput::section, and DecInput::token.

Referenced by isNewSection(), readBlockconss(), readBlockvars(), readIncomplete(), readLinkingvars(), readMasterconss(), readMastervars(), readNBlocks(), and readPresolved().

Variable Documentation

const char commentchars[] = "\\"
static

Definition at line 114 of file reader_dec.cpp.

Referenced by getNextLine(), and writeData().

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

Definition at line 112 of file reader_dec.cpp.

Referenced by isDelimChar().

const int LINKINGVALUE = -2
static

Definition at line 111 of file reader_dec.cpp.

Referenced by readBlockconss(), readDECFile(), and readMasterconss().

const int NOVALUE = -1
static

Definition at line 110 of file reader_dec.cpp.

Referenced by readNBlocks(), and SCIPreadDec().

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

Definition at line 113 of file reader_dec.cpp.

Referenced by isTokenChar().