reader_dec.cpp
Go to the documentation of this file.
37 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
74 DEC_START, DEC_INCOMPLETE, DEC_PRESOLVED, DEC_NBLOCKS, DEC_BLOCKCONSS, DEC_MASTERCONSS, DEC_BLOCKVARS, DEC_MASTERVARS, DEC_LINKINGVARS, DEC_END
98 SCIP_Bool incomplete; /**< if false the unspecified constraints should be forced to the master (for downward compatibility) */
220 SCIPerrorMessage("Error: line %d exceeds %d characters\n", decinput->linenumber, DEC_MAX_LINELEN - 2);
225 decinput->linebuf[DEC_MAX_LINELEN - 2] = '\0'; /* we want to use lookahead of one char -> we need two \0 at the end */
236 *(commentstart + 1) = '\0'; /* we want to use lookahead of one char -> we need two \0 at the end */
257 /** reads the next token from the input file into the token buffer; returns whether a token was read */
303 if( isValueChar(buf[decinput->linepos], buf[decinput->linepos + 1], TRUE, &hasdot, &exptype) ) /*lint !e679*/
316 while( isValueChar(buf[decinput->linepos], buf[decinput->linepos + 1], FALSE, &hasdot, &exptype) ); /*lint !e679*/
334 * if the token is an equality token '=' and the next character is a '<' or '>', replace the token by the inequality sense
337 && (decinput->token[tokenlen - 1] == '<' || decinput->token[tokenlen - 1] == '>' || decinput->token[tokenlen - 1] == '=')
342 else if( decinput->token[tokenlen - 1] == '=' && (buf[decinput->linepos] == '<' || buf[decinput->linepos] == '>') )
356 /** puts the current token on the token stack, such that it is read at the next call to getNextToken() */
393 assert(!(strcasecmp(decinput->token, "INFINITY") == 0) && !(strcasecmp(decinput->token, "INF") == 0));
408 /** checks whether the current token is a section identifier, and if yes, switches to the corresponding section */
451 if( strcasecmp(decinput->token, "BLOCK") == 0 || strcasecmp(decinput->token, "BLOCKCONSS") == 0 || strcasecmp(decinput->token, "BLOCKCONS") == 0)
479 if( strcasecmp(decinput->token, "MASTERCONSS") == 0 || strcasecmp(decinput->token, "MASTERCONS") == 0 )
488 if( strcasecmp(decinput->token, "BLOCKVARS") == 0 || strcasecmp(decinput->token, "BLOCKVAR") == 0 )
516 if( strcasecmp(decinput->token, "MASTERVARS") == 0 || strcasecmp(decinput->token, "MASTERVAR") == 0
517 || strcasecmp(decinput->token, "STATICVAR") == 0 || strcasecmp(decinput->token, "STATICVARS") == 0 )
526 if( strcasecmp(decinput->token, "LINKINGVARS") == 0 || strcasecmp(decinput->token, "LINKINGVAR") == 0 )
587 SCIPdebugMessage("The constraints that are not specified in this decomposition are %s forced to the master\n",
755 SCIPdebugMessage("Cons <%s> has been deleted by presolving or has no variable at all.\n", SCIPconsGetName(cons) );
765 if( !decinput->partialdec->isConsOpencons(decinput->partialdec->getDetprobdata()->getIndexForCons(cons)) )
768 SCIPwarningMessage(scip, "cons %s is already assigned but is supposed to assigned to %d\n", SCIPconsGetName(cons), (blockid+1));
811 SCIPwarningMessage(scip, "Var <%s> has been fixed or aggregated by presolving, skipping.\n", SCIPvarGetName(var));
893 SCIPdebugMessage("Var <%s> has been fixed or aggregated by presolving, skipping.\n", SCIPvarGetName(var));
938 SCIPwarningMessage(scip, "Var <%s> has been fixed or aggregated by presolving, skipping.\n", SCIPvarGetName(var));
986 if( SCIPgetStage(scip) == SCIP_STAGE_INIT || SCIPgetNVars(scip) == 0 || SCIPgetNConss(scip) == 0 )
988 SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "No problem exists, will not read structure!\n");
1010 SCIPinfoMessage(scip, NULL, "read presolved decomposition but problem is not presolved yet -> presolve()\n");
1038 if( decinput->haspresolvesection && !decinput->presolved && SCIPgetStage(scip) >= SCIP_STAGE_PRESOLVED )
1040 SCIPwarningMessage(scip, "decomposition belongs to the unpresolved problem, but the problem is already presolved, please consider to re-read the problem and read the decomposition without presolving when transforming do not succeed.\n");
1046 SCIPwarningMessage(scip, "decomposition has no presolve section at beginning. The behaviour is undefined. Please add a presolve section. File reading is aborted. \n");
1143 SCIPinfoMessage(scip, file, "%s%s stems from a partial decomposition provided by the user\n", commentchars, commentchars);
1152 "%s%s name info time nnewblocks %%ofnewborderconss %%ofnewblockconss %%ofnewlinkingvars %%ofnewblockvars\n",
1158 DECdetectorGetName(detectorchain[i]), detectorchaininfo[i].c_str(), partialdec->getDetectorClockTimes().at(i),
1159 partialdec->getNNewBlocks(i), partialdec->getPctConssToBorder(i), partialdec->getPctConssToBlock(i),
1178 SCIPinfoMessage(scip, file, "%s\n", SCIPconsGetName(detprobdata->getCons(partialdec->getConssForBlock(b)[c])));
1185 SCIPinfoMessage(scip, file, "%s\n", SCIPconsGetName(detprobdata->getCons(partialdec->getMasterconss()[mc])));
1197 SCIPinfoMessage(scip, file, "%s\n", SCIPvarGetName(detprobdata->getVar(partialdec->getLinkingvars()[lv])));
1203 SCIPinfoMessage(scip, file, "%s\n", SCIPvarGetName(detprobdata->getVar(partialdec->getMastervars()[mv])));
1211 SCIPinfoMessage(scip, file, "%s\n", SCIPvarGetName(detprobdata->getVar(partialdec->getVarsForBlock(b)[v])));
1224 const char* filename, /**< full path and name of file to read, or NULL if stdin should be used */
1245 SCIP_CALL( SCIPallocMemoryArray(scip, &decinput.pushedtokens[i], DEC_MAX_LINELEN) ); /*lint !e506 !e866*/
1305 if( SCIPgetStage(scip) == SCIP_STAGE_INIT || SCIPgetNVars(scip) == 0 || SCIPgetNConss(scip) == 0 )
SCIP_RETCODE readDec(SCIP *scip, const char *filename, SCIP_RESULT *result)
Definition: reader_dec.cpp:1222
int getNConss()
returns the number of variables considered in the detprobdata
Definition: class_detprobdata.cpp:796
const char * DECdetectorGetName(DEC_DETECTOR *detector)
returns the name of the provided detector
Definition: cons_decomp.cpp:2618
std::vector< int > & getMastervars()
Gets array containing all master vars indices.
Definition: class_partialdecomp.cpp:3998
static SCIP_RETCODE readBlockconss(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition: reader_dec.cpp:679
std::vector< int > & getVarsForBlock(int block)
Gets array containing vars of a block.
Definition: class_partialdecomp.cpp:4470
std::vector< int >::const_iterator fixConsToMaster(std::vector< int >::const_iterator itr)
fixes a constraint to the master constraints
Definition: class_partialdecomp.cpp:4938
static void syntaxError(SCIP *scip, DECINPUT *decinput, const char *msg)
Definition: reader_dec.cpp:124
void setNBlocks(int nblocks)
sets number of blocks, only increasing number allowed
Definition: class_partialdecomp.cpp:5025
constraint handler for structure detection
std::vector< int > & getMasterconss()
Gets array containing all master conss indices.
Definition: class_partialdecomp.cpp:3992
bool isComplete()
Gets whether this partialdec is complete, i.e. it has no more open constraints and variables.
Definition: class_partialdecomp.cpp:4494
static SCIP_Bool isValueChar(char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, DECEXPTYPE *exptype)
Definition: reader_dec.cpp:180
static SCIP_RETCODE readMastervars(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition: reader_dec.cpp:863
USERGIVEN getUsergiven()
Gets the USERGIVEN status of this partialdecs.
Definition: class_partialdecomp.cpp:4097
int getNVarsForBlock(int block)
Gets size of the vector containing vars assigned to a block.
Definition: class_partialdecomp.cpp:4226
DEC file reader for structure information.
bool fixVarToMasterByName(const char *varname)
assigns a variable with given name as master
Definition: class_partialdecomp.cpp:5331
static SCIP_Bool isNewSection(SCIP *scip, DECINPUT *decinput)
Definition: reader_dec.cpp:410
PARTIALDECOMP * DECgetPartialdecToWrite(SCIP *scip, SCIP_Bool transformed)
Definition: cons_decomp.cpp:2928
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 readBlockvars(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition: reader_dec.cpp:781
void setUsergiven(USERGIVEN usergiven)
sets whether this partialdec is user given
Definition: class_partialdecomp.cpp:5063
static SCIP_RETCODE readStart(SCIP *scip, DECINPUT *decinput)
Definition: reader_dec.cpp:540
static void swapPointers(char **pointer1, char **pointer2)
Definition: reader_dec.cpp:245
int getNConssForBlock(int block)
Gets size of the vector containing conss assigned to a block.
Definition: class_partialdecomp.cpp:4121
SCIP_CONS * getCons(int consIndex)
returns the SCIP constraint related to a constraint index
Definition: class_detprobdata.cpp:698
SCIP_Bool shouldCompletedByConsToMaster()
Checks whether this partialdec is a userpartialdec that should be completed.
Definition: class_partialdecomp.cpp:5439
SCIP_Real getPctConssToBorder(int detectorchainindex)
Gets fraction of constraints assigned to the border for a detector.
Definition: class_partialdecomp.cpp:4344
static SCIP_RETCODE readDECFile(SCIP *scip, SCIP_READER *reader, DECINPUT *decinput, const char *filename)
Definition: reader_dec.cpp:973
SCIP_Real getPctConssToBlock(int detectorchainindex)
Gets fraction of constraints assigned to a block for a detector.
Definition: class_partialdecomp.cpp:4368
int getNVars()
return the number of variables considered in the detprobdata
Definition: class_detprobdata.cpp:848
int getIndexForCons(SCIP_CONS *cons)
returns the constraint index related to a SCIP constraint
Definition: class_detprobdata.cpp:744
int getNLinkingvars()
Gets size of the vector containing linking vars.
Definition: class_partialdecomp.cpp:4148
bool sort()
sorts the vars and conss data structures by their indices
Definition: class_partialdecomp.cpp:5445
static SCIP_Bool isInt(SCIP *scip, DECINPUT *decinput, int *value)
Definition: reader_dec.cpp:382
C++ interface of cons_decomp.
SCIP_Real getPctVarsToBorder(int detectorchainindex)
Gets fraction of variables assigned to the border for a detector.
Definition: class_partialdecomp.cpp:4271
Definition: class_detprobdata.h:106
int getNNewBlocks(int detectorchainindex)
Gets number of blocks a detector added.
Definition: class_partialdecomp.cpp:4154
std::vector< std::string > & getDetectorchainInfo()
Gets the detectorchain info vector.
Definition: class_partialdecomp.cpp:4130
Definition: reader_dec.cpp:86
static SCIP_RETCODE writePartialdec(SCIP *scip, FILE *file, gcg::PARTIALDECOMP *partialdec, SCIP_RESULT *result)
write partialdec to file in dec format
Definition: reader_dec.cpp:1114
static SCIP_RETCODE readIncomplete(SCIP *scip, DECINPUT *decinput)
Definition: reader_dec.cpp:561
static SCIP_RETCODE readNBlocks(SCIP *scip, DECINPUT *decinput)
Definition: reader_dec.cpp:638
static SCIP_RETCODE readMasterconss(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition: reader_dec.cpp:824
std::vector< SCIP_Real > & getDetectorClockTimes()
returns a vector of the clock times that each detector needed that was involved in this partialdec
Definition: class_partialdecomp.cpp:3656
std::vector< int > & getConssForBlock(int block)
returns array containing constraints assigned to a block
Definition: class_partialdecomp.cpp:3693
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
DETPROBDATA * getDetprobdata()
Gets the corresponding detprobdata.
Definition: class_partialdecomp.cpp:4424
std::vector< int > & getLinkingvars()
returns array containing all linking vars indices
Definition: class_partialdecomp.cpp:3986
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, DECINPUT *decinput)
Definition: reader_dec.cpp:598
bool isConsOpencons(int cons)
Gets whether the cons is an open cons.
Definition: class_partialdecomp.cpp:4524
bool fixConsToBlockByName(const char *consname, int blockid)
assigns a constraint by name to a block
Definition: class_partialdecomp.cpp:5283
SCIP_Real getPctVarsToBlock(int detectorchainindex)
Gets fraction of variables assigned to a block for a detector.
Definition: class_partialdecomp.cpp:4295
class storing (potentially incomplete) decompositions
public methods for GCG variables
static SCIP_RETCODE readLinkingvars(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition: reader_dec.cpp:908
std::vector< DEC_DETECTOR * > & getDetectorchain()
returns detector chain as vector of detector pointers
Definition: class_partialdecomp.cpp:3702
int getNMasterconss()
Gets size of the vector containing master conss.
Definition: class_partialdecomp.cpp:4170
bool isAssignedToOrigProb()
Gets whether the partialdec is from the presolved problem.
Definition: class_partialdecomp.cpp:4533
SCIP_VAR * getVar(int varIndex)
returns SCIP variable related to a variable index
Definition: class_detprobdata.cpp:955
int getNMastervars()
Gets size of the vector containing master vars.
Definition: class_partialdecomp.cpp:4176
class storing partialdecs and the problem matrix
static SCIP_RETCODE setPresolved(SCIP *scip, DECINPUT *decinput)
Definition: reader_dec.cpp:953
public methods for working with decomposition structures