Scippy

GCG

Branch-and-Price & Column Generation for Everyone

reader_ref.c File Reference

Detailed Description

REF file reader for structure information.

Author
Gerald Gamrath
Christian Puchert
Martin Bergner

Definition in file reader_ref.c.

#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include "reader_ref.h"
#include "gcg.h"
#include "scip/cons_linear.h"
#include "cons_decomp.h"
#include "relax_gcg.h"

Go to the source code of this file.

Data Structures

struct  RefInput
 

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
 
#define readerFreeRef   NULL
 

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, DEC_DECOMP *decomp, const char *filename)
 
static SCIP_RETCODE writeREFFile (SCIP *scip, SCIP_READER *reader, FILE *file)
 
static SCIP_DECL_READERREAD (readerReadRef)
 
static SCIP_DECL_READERWRITE (readerWriteRef)
 
SCIP_RETCODE SCIPincludeReaderRef (SCIP *scip)
 
SCIP_RETCODE SCIPreadRef (SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result)
 

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 52 of file reader_ref.c.

◆ READER_DESC

#define READER_DESC   "file reader for blocks corresponding to a mip in lpb format"

Definition at line 53 of file reader_ref.c.

◆ READER_EXTENSION

#define READER_EXTENSION   "ref"

Definition at line 54 of file reader_ref.c.

◆ REF_MAX_LINELEN

#define REF_MAX_LINELEN   65536

Definition at line 59 of file reader_ref.c.

◆ REF_MAX_PUSHEDTOKENS

#define REF_MAX_PUSHEDTOKENS   2

Definition at line 60 of file reader_ref.c.

◆ readerFreeRef

#define readerFreeRef   NULL

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

Definition at line 731 of file reader_ref.c.

Typedef Documentation

◆ REFSECTION

typedef enum RefSection REFSECTION

Definition at line 67 of file reader_ref.c.

◆ REFEXPTYPE

typedef enum RefExpType REFEXPTYPE

Definition at line 73 of file reader_ref.c.

◆ REFINPUT

typedef struct RefInput REFINPUT

Definition at line 100 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 63 of file reader_ref.c.

◆ RefExpType

enum RefExpType
Enumerator
REF_EXP_NONE 
REF_EXP_UNSIGNED 
REF_EXP_SIGNED 

Definition at line 69 of file reader_ref.c.

Function Documentation

◆ syntaxError()

static void syntaxError ( SCIP *  scip,
REFINPUT refinput,
const char *  msg 
)
static

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

Parameters
scipSCIP data structure
refinputREF reading data
msgerror message

Definition at line 113 of file reader_ref.c.

References RefInput::haserror, RefInput::linebuf, RefInput::linenumber, RefInput::linepos, REF_END, RefInput::section, and RefInput::token.

Referenced by readBlocks(), readBlockSizes(), and readNBlocks().

◆ hasError()

static SCIP_Bool hasError ( REFINPUT refinput)
static

returns whether a syntax error was detected

Parameters
refinputREF reading data

Definition at line 141 of file reader_ref.c.

References RefInput::haserror.

Referenced by readREFFile().

◆ isDelimChar()

static SCIP_Bool isDelimChar ( char  c)
static

returns whether the given character is a token delimiter

Parameters
cinput character

Definition at line 152 of file reader_ref.c.

References delimchars.

Referenced by getNextToken().

◆ isTokenChar()

static SCIP_Bool isTokenChar ( char  c)
static

returns whether the given character is a single token

Parameters
cinput character

Definition at line 161 of file reader_ref.c.

References tokenchars.

Referenced by getNextToken().

◆ isValueChar()

static SCIP_Bool isValueChar ( char  c,
char  nextc,
SCIP_Bool  firstchar,
SCIP_Bool *  hasdot,
REFEXPTYPE 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 170 of file reader_ref.c.

References REF_EXP_NONE, REF_EXP_SIGNED, and REF_EXP_UNSIGNED.

Referenced by getNextToken().

◆ getNextLine()

static SCIP_Bool getNextLine ( REFINPUT refinput)
static

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

Parameters
refinputREF reading data

Definition at line 214 of file reader_ref.c.

References commentchars, RefInput::file, RefInput::haserror, RefInput::linebuf, RefInput::linenumber, RefInput::linepos, and REF_MAX_LINELEN.

Referenced by getNextToken().

◆ getNextToken()

static SCIP_Bool getNextToken ( REFINPUT refinput)
static

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

Parameters
refinputREF reading data

Definition at line 258 of file reader_ref.c.

References RefInput::blocknr, getNextLine(), isDelimChar(), isTokenChar(), isValueChar(), RefInput::linebuf, RefInput::linenumber, RefInput::linepos, RefInput::npushedtokens, RefInput::pushedtokens, REF_BLOCKS, REF_BLOCKSIZES, REF_END, REF_EXP_NONE, REF_MAX_LINELEN, REF_NBLOCKS, REF_START, RefInput::section, and RefInput::token.

Referenced by readBlocks(), readBlockSizes(), readNBlocks(), and readStart().

◆ isInt()

static SCIP_Bool isInt ( SCIP *  scip,
REFINPUT refinput,
int *  value 
)
static

returns whether the current token is a value

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

Definition at line 366 of file reader_ref.c.

References RefInput::token.

Referenced by readBlocks(), readBlockSizes(), and readNBlocks().

◆ readStart()

static SCIP_RETCODE readStart ( SCIP *  scip,
REFINPUT refinput 
)
static

reads the header of the file

Parameters
scipSCIP data structure
refinputREF reading data

Definition at line 395 of file reader_ref.c.

References getNextToken().

Referenced by readREFFile().

◆ readNBlocks()

static SCIP_RETCODE readNBlocks ( SCIP *  scip,
REFINPUT refinput 
)
static

reads the nblocks section

Parameters
scipSCIP data structure
refinputREF reading data

Definition at line 409 of file reader_ref.c.

References RefInput::blocksizes, getNextToken(), isInt(), RefInput::nblocks, REF_BLOCKSIZES, RefInput::section, and syntaxError().

Referenced by readREFFile().

◆ readBlockSizes()

static SCIP_RETCODE readBlockSizes ( SCIP *  scip,
REFINPUT refinput 
)
static

reads the blocksizes section

Parameters
scipSCIP data structure
refinputREF reading data

Definition at line 443 of file reader_ref.c.

References RefInput::blocknr, RefInput::blocksizes, getNextToken(), isInt(), RefInput::nblocks, syntaxError(), and RefInput::totalconss.

Referenced by readREFFile().

◆ readBlocks()

static SCIP_RETCODE readBlocks ( SCIP *  scip,
REFINPUT refinput 
)
static

reads the blocks section

Parameters
scipSCIP data structure
refinputREF reading data

Definition at line 471 of file reader_ref.c.

References RefInput::blocknr, RefInput::blocksizes, RefInput::constoblock, getNextToken(), isInt(), RefInput::nassignedvars, RefInput::nblocks, syntaxError(), RefInput::totalreadconss, and RefInput::vartoblock.

Referenced by readREFFile().

◆ readREFFile()

static SCIP_RETCODE readREFFile ( SCIP *  scip,
SCIP_READER *  reader,
REFINPUT refinput,
DEC_DECOMP decomp,
const char *  filename 
)
static

reads an REF file

Parameters
scipSCIP data structure
readerreader data structure
refinputREF reading data
decompdecomposition structure
filenamename of the input file

Definition at line 559 of file reader_ref.c.

References RefInput::constoblock, DECdecompSetDetector(), DECdecompSetNBlocks(), DECdecompSetPresolved(), DECfilloutDecompFromHashmaps(), RefInput::file, hasError(), RefInput::nblocks, readBlocks(), readBlockSizes(), readNBlocks(), readStart(), REF_BLOCKS, REF_BLOCKSIZES, REF_END, REF_NBLOCKS, REF_START, RefInput::section, and RefInput::vartoblock.

Referenced by SCIPreadRef().

◆ writeREFFile()

static SCIP_RETCODE writeREFFile ( SCIP *  scip,
SCIP_READER *  reader,
FILE *  file 
)
static

writes a Ref file

Parameters
scipSCIP data structure
readerref reader
filetarget file

Definition at line 635 of file reader_ref.c.

References DECdecompFree(), DECdecompGetNBlocks(), DECdecompGetNSubscipconss(), DECdecompGetSubscipconss(), DECgetBestDecomp(), RefInput::file, GCGgetStructDecomp(), and RefInput::nblocks.

Referenced by SCIP_DECL_READERWRITE().

◆ SCIP_DECL_READERREAD()

static SCIP_DECL_READERREAD ( readerReadRef  )
static

problem reading method of reader

Definition at line 735 of file reader_ref.c.

References SCIPreadRef().

◆ SCIP_DECL_READERWRITE()

static SCIP_DECL_READERWRITE ( readerWriteRef  )
static

problem writing method of reader

Definition at line 751 of file reader_ref.c.

References RefInput::file, and writeREFFile().

◆ SCIPincludeReaderRef()

SCIP_RETCODE SCIPincludeReaderRef ( SCIP *  scip)

includes the ref file reader in SCIP

Parameters
scipSCIP data structure

Definition at line 764 of file reader_ref.c.

References READER_DESC, READER_EXTENSION, READER_NAME, and readerFreeRef.

Referenced by SCIPincludeGcgPlugins().

◆ SCIPreadRef()

SCIP_RETCODE SCIPreadRef ( SCIP *  scip,
SCIP_READER *  reader,
const char *  filename,
SCIP_RESULT *  result 
)

Variable Documentation

◆ delimchars

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

Definition at line 102 of file reader_ref.c.

Referenced by isDelimChar().

◆ tokenchars

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

Definition at line 103 of file reader_ref.c.

Referenced by isTokenChar().

◆ commentchars

const char commentchars[] = "\\"
static

Definition at line 104 of file reader_ref.c.

Referenced by getNextLine().