reader_blk.cpp
Go to the documentation of this file.
35 * The structure is defined variable-wise, i.e., the number of blocks and the variables belonging to each block are
36 * defined. Afterwards, each constraint that has only variables of one block is added to that block,
37 * constraints having variables of more than one block go into the master. If needed, constraints can also be
41 * - Presolved: to be followed by either 0 or 1 indicating that the decomposition is for the presolved or unpresolved problem
43 * - Block i with 1 <= i <= nblocks: to be followed by the names of the variables belonging to block i, one per line.
44 * - Masterconss: to be followed by names of constraints, one per line, that should go into the master,
48 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
121 SCIP_CONS*** blockcons; /**< array of assignments from constraints to their blocks [blocknr][consid] */
262 SCIPerrorMessage("Error: line %d exceeds %d characters\n", blkinput->linenumber, BLK_MAX_LINELEN-2);
267 blkinput->linebuf[BLK_MAX_LINELEN-2] = '\0'; /* we want to use lookahead of one char -> we need two \0 at the end */
278 *(commentstart+1) = '\0'; /* we want to use lookahead of one char -> we need two \0 at the end */
299 /** reads the next token from the input file into the token buffer; returns whether a token was read */
345 if( isValueChar(buf[blkinput->linepos], buf[blkinput->linepos+1], TRUE, &hasdot, &exptype) ) /*lint !e679*/
358 while( isValueChar(buf[blkinput->linepos], buf[blkinput->linepos+1], FALSE, &hasdot, &exptype) ); /*lint !e679*/
376 * if the token is an equality token '=' and the next character is a '<' or '>', replace the token by the inequality sense
379 && (blkinput->token[tokenlen-1] == '<' || blkinput->token[tokenlen-1] == '>' || blkinput->token[tokenlen-1] == '=')
384 else if( blkinput->token[tokenlen-1] == '=' && (buf[blkinput->linepos] == '<' || buf[blkinput->linepos] == '>') )
398 /** puts the current token on the token stack, such that it is read at the next call to getNextToken() */
435 assert(!(strcasecmp(blkinput->token, "INFINITY") == 0) && !(strcasecmp(blkinput->token, "INF") == 0));
450 /** checks whether the current token is a section identifier, and if yes, switches to the corresponding section */
684 /* variable was assigned to another (non-linking) block before, so it becomes a linking variable, now */
688 SCIPdebugMessage("\tVar %s is linking (old %d != %d new).\n", SCIPvarGetName(var), oldblock, blockid);
692 /* decrease the number of variables in the old block and increase the number of linking variables */
698 SCIP_CALL( SCIPallocMemoryArray(scip, &readerdata->linkingvarsblocks[varidx], 2) ); /*lint !e506 !e866*/
711 SCIP_CALL( SCIPreallocMemoryArray(scip, &readerdata->linkingvarsblocks[varidx], (size_t) readerdata->nlinkingvarsblocks[varidx] + 1) ); /*lint !e866*/
750 SCIP_CALL( SCIPhashmapSetImage(readerdata->constoblock, cons, (void*) (size_t) (blkinput->nblocks +1)) );
841 /* if a contained variable is directly transferred to the master, the constraint is a linking constraint */
848 if( blocknr == -1 && readerdata->varstoblock[SCIPvarGetProbindex(consvars[j])] != LINKINGVALUE )
997 // SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, "decomposition belongs to the presolved problem, please presolve the problem first.\n");
1008 if( blkinput->haspresolvesection && !blkinput->presolved && SCIPgetStage(scip) >= SCIP_STAGE_PRESOLVED )
1010 SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, "decomposition belongs to the original problem, please re-read the problem and read the decomposition without presolving.\n");
1015 SCIPwarningMessage(scip, "decomposition has no presolve section at beginning. It is assumed to belong to the unpresolved problem but the behaviour is undefined. See the FAQ for further information.\n");
1119 if( SCIPgetStage(scip) == SCIP_STAGE_INIT || SCIPgetNVars(scip) == 0 || SCIPgetNConss(scip) == 0 )
1121 SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "Please read in a problem before reading in the corresponding structure file!\n");
1162 const char* filename, /**< full path and name of file to read, or NULL if stdin should be used */
1193 SCIP_CALL( SCIPallocMemoryArray(scip, &blkinput.pushedtokens[i], BLK_MAX_LINELEN) ); /*lint !e506 !e866*/
void DECdecompSetNBlocks(DEC_DECOMP *decomp, int nblocks)
Definition: decomp.c:733
static SCIP_RETCODE readMasterconss(SCIP *scip, BLKINPUT *blkinput, gcg::PARTIALDECOMP *partialdec, SCIP_READERDATA *readerdata)
Definition: reader_blk.cpp:722
static SCIP_Bool isInt(SCIP *scip, BLKINPUT *blkinput, int *value)
Definition: reader_blk.cpp:424
Definition: struct_decomp.h:51
void setNBlocks(int nblocks)
sets number of blocks, only increasing number allowed
Definition: class_partialdecomp.cpp:5025
constraint handler for structure detection
static SCIP_Bool isNewSection(SCIP *scip, BLKINPUT *blkinput)
Definition: reader_blk.cpp:452
SCIP_RETCODE GCGconsGetVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int nvars)
Definition: scip_misc.c:490
static SCIP_RETCODE readStart(SCIP *scip, BLKINPUT *blkinput)
Definition: reader_blk.cpp:542
bool fixVarToMasterByName(const char *varname)
assigns a variable with given name as master
Definition: class_partialdecomp.cpp:5331
various SCIP helper methods
bool fixVarToLinkingByName(const char *varname)
assigns a variable by name to the linking variables
Definition: class_partialdecomp.cpp:5345
static SCIP_RETCODE readNBlocks(SCIP *scip, gcg::PARTIALDECOMP *partialdec, BLKINPUT *blkinput)
Definition: reader_blk.cpp:599
void setUsergiven(USERGIVEN usergiven)
sets whether this partialdec is user given
Definition: class_partialdecomp.cpp:5063
BLK file reader for structure information.
static void syntaxError(SCIP *scip, BLKINPUT *blkinput, const char *msg)
Definition: reader_blk.cpp:142
static SCIP_RETCODE fillDecompStruct(SCIP *scip, BLKINPUT *blkinput, DEC_DECOMP *decomp, gcg::PARTIALDECOMP *partialdec, SCIP_READERDATA *readerdata)
Definition: reader_blk.cpp:760
SCIP_RETCODE DECfilloutDecompFromConstoblock(SCIP *scip, DEC_DECOMP *decomp, SCIP_HASHMAP *constoblock, int nblocks, SCIP_Bool staircase)
Definition: decomp.c:1455
void DECdecompSetPresolved(DEC_DECOMP *decomp, SCIP_Bool presolved)
Definition: decomp.c:712
C++ interface of cons_decomp.
SCIP_RETCODE SCIPreadBlk(SCIP *scip, const char *filename, SCIP_RESULT *result)
Definition: reader_blk.cpp:1160
static SCIP_Bool isValueChar(char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, BLKEXPTYPE *exptype)
Definition: reader_blk.cpp:199
GCG relaxator.
bool fixConsToMasterByName(const char *consname)
assgins a constraint by name as master
Definition: class_partialdecomp.cpp:5317
Definition: reader_blk.cpp:114
SCIP_RETCODE GCGconshdlrDecompAddPreexisitingPartialDec(SCIP *scip, PARTIALDECOMP *partialdec)
adds a preexisting partial dec to be considered at the beginning of the detection
Definition: cons_decomp.cpp:3554
static SCIP_RETCODE readBlock(SCIP *scip, BLKINPUT *blkinput, gcg::PARTIALDECOMP *partialdec, SCIP_READERDATA *readerdata)
Definition: reader_blk.cpp:641
static void swapPointers(char **pointer1, char **pointer2)
Definition: reader_blk.cpp:287
void DECdecompSetDetector(DEC_DECOMP *decomp, DEC_DETECTOR *detector)
Definition: decomp.c:1579
bool fixVarToBlockByName(const char *varname, int blockid)
assigns a variable by name to a block
Definition: class_partialdecomp.cpp:5299
static SCIP_RETCODE readPresolved(SCIP *scip, BLKINPUT *blkinput)
Definition: reader_blk.cpp:563
SCIP_RETCODE DECdecompCreate(SCIP *scip, DEC_DECOMP **decdecomp)
Definition: decomp.c:471
bool fixConsToBlockByName(const char *consname, int blockid)
assigns a constraint by name to a block
Definition: class_partialdecomp.cpp:5283
class storing (potentially incomplete) decompositions
public methods for GCG variables
static SCIP_RETCODE readBLKFile(SCIP *scip, SCIP_READER *reader, BLKINPUT *blkinput, const char *filename)
Definition: reader_blk.cpp:915
Definition: reader_blk.cpp:94
SCIP_RETCODE DECdecompSetType(DEC_DECOMP *decomp, DEC_DECTYPE type)
Definition: decomp.c:647
public methods for working with decomposition structures