Loading...
Searching...
No Matches
reader_dec.cpp
Go to the documentation of this file.
38/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
95 SCIP_Bool incomplete; /**< if false the unspecified constraints should be forced to the master (for downward compatibility) */
218 SCIPerrorMessage("Error: line %d exceeds %d characters\n", decinput->linenumber, DEC_MAX_LINELEN - 2);
223 decinput->linebuf[DEC_MAX_LINELEN - 2] = '\0'; /* we want to use lookahead of one char -> we need two \0 at the end */
255/** reads the next token from the input file into the token buffer; returns whether a token was read */
301 if( isValueChar(buf[decinput->linepos], buf[decinput->linepos + 1], TRUE, &hasdot, &exptype) ) /*lint !e679*/
314 while( isValueChar(buf[decinput->linepos], buf[decinput->linepos + 1], FALSE, &hasdot, &exptype) ); /*lint !e679*/
332 * if the token is an equality token '=' and the next character is a '<' or '>', replace the token by the inequality sense
335 && (decinput->token[tokenlen - 1] == '<' || decinput->token[tokenlen - 1] == '>' || decinput->token[tokenlen - 1] == '=')
354/** puts the current token on the token stack, such that it is read at the next call to getNextToken() */
391 assert(!(SCIPstrcasecmp(decinput->token, "INFINITY") == 0) && !(SCIPstrcasecmp(decinput->token, "INF") == 0));
406/** checks whether the current token is a section identifier, and if yes, switches to the corresponding section */
449 if( SCIPstrcasecmp(decinput->token, "BLOCK") == 0 || SCIPstrcasecmp(decinput->token, "BLOCKCONSS") == 0 || SCIPstrcasecmp(decinput->token, "BLOCKCONS") == 0)
477 if( SCIPstrcasecmp(decinput->token, "MASTERCONSS") == 0 || SCIPstrcasecmp(decinput->token, "MASTERCONS") == 0 )
486 if( SCIPstrcasecmp(decinput->token, "BLOCKVARS") == 0 || SCIPstrcasecmp(decinput->token, "BLOCKVAR") == 0 )
514 if( SCIPstrcasecmp(decinput->token, "MASTERVARS") == 0 || SCIPstrcasecmp(decinput->token, "MASTERVAR") == 0
515 || SCIPstrcasecmp(decinput->token, "STATICVAR") == 0 || SCIPstrcasecmp(decinput->token, "STATICVARS") == 0 )
524 if( SCIPstrcasecmp(decinput->token, "LINKINGVARS") == 0 || SCIPstrcasecmp(decinput->token, "LINKINGVAR") == 0 )
585 SCIPdebugMessage("The constraints that are not specified in this decomposition are %s forced to the master\n",
753 SCIPdebugMessage("Cons <%s> has been deleted by presolving or has no variable at all.\n", SCIPconsGetName(cons) );
763 if( !decinput->partialdec->isConsOpencons(decinput->partialdec->getDetprobdata()->getIndexForCons(cons)) )
766 SCIPwarningMessage(scip, "cons %s is already assigned but is supposed to assigned to %d\n", SCIPconsGetName(cons), (blockid+1));
809 SCIPwarningMessage(scip, "Var <%s> has been fixed or aggregated by presolving, skipping.\n", SCIPvarGetName(var));
891 SCIPdebugMessage("Var <%s> has been fixed or aggregated by presolving, skipping.\n", SCIPvarGetName(var));
936 SCIPwarningMessage(scip, "Var <%s> has been fixed or aggregated by presolving, skipping.\n", SCIPvarGetName(var));
984 if( SCIPgetStage(scip) == SCIP_STAGE_INIT || SCIPgetNVars(scip) == 0 || SCIPgetNConss(scip) == 0 )
986 SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "No problem exists, will not read structure!\n");
1008 SCIPinfoMessage(scip, NULL, "read presolved decomposition but problem is not presolved yet -> presolve()\n");
1036 if( decinput->haspresolvesection && !decinput->presolved && SCIPgetStage(scip) >= SCIP_STAGE_PRESOLVED )
1038 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");
1044 SCIPwarningMessage(scip, "decomposition has no presolve section at beginning. The behaviour is undefined. Please add a presolve section. File reading is aborted. \n");
1130 SCIPinfoMessage(scip, file, "%s%s stems from a partial decomposition provided by the user\n", commentchars, commentchars);
1139 "%s%s name info time nnewblocks %%ofnewborderconss %%ofnewblockconss %%ofnewlinkingvars %%ofnewblockvars\n",
1145 GCGdetectorGetName(detectorchain[i]), detectorchaininfo[i].c_str(), partialdec->getDetectorClockTimes().at(i),
1146 partialdec->getNNewBlocks(i), partialdec->getPctConssToBorder(i), partialdec->getPctConssToBlock(i),
1165 SCIPinfoMessage(scip, file, "%s\n", SCIPconsGetName(detprobdata->getCons(partialdec->getConssForBlock(b)[c])));
1172 SCIPinfoMessage(scip, file, "%s\n", SCIPconsGetName(detprobdata->getCons(partialdec->getMasterconss()[mc])));
1184 SCIPinfoMessage(scip, file, "%s\n", SCIPvarGetName(detprobdata->getVar(partialdec->getLinkingvars()[lv])));
1190 SCIPinfoMessage(scip, file, "%s\n", SCIPvarGetName(detprobdata->getVar(partialdec->getMastervars()[mv])));
1198 SCIPinfoMessage(scip, file, "%s\n", SCIPvarGetName(detprobdata->getVar(partialdec->getVarsForBlock(b)[v])));
1211 const char* filename, /**< full path and name of file to read, or NULL if stdin should be used */
1232 SCIP_CALL( SCIPallocMemoryArray(scip, &decinput.pushedtokens[i], DEC_MAX_LINELEN) ); /*lint !e506 !e866*/
1292 if( SCIPgetStage(scip) == SCIP_STAGE_INIT || SCIPgetNVars(scip) == 0 || SCIPgetNConss(scip) == 0 )
1294 SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "Please read in a problem before reading in the corresponding structure file!\n");
SCIP_DECL_READERREAD(ReaderTSP::scip_read)
SCIP_DECL_READERWRITE(ReaderTSP::scip_write)
SCIP_DECL_READERFREE(ReaderTSP::scip_free)
SCIP_VAR ** b
class storing partialdecs and the problem matrix
class storing (potentially incomplete) decompositions
Definition class_detprobdata.h:110
GCG_EXPORT int getIndexForCons(SCIP_CONS *cons)
returns the constraint index related to a SCIP constraint
Definition class_detprobdata.cpp:792
GCG_EXPORT int getNConss()
returns the number of variables considered in the detprobdata
Definition class_detprobdata.cpp:850
GCG_EXPORT int getNVars()
return the number of variables considered in the detprobdata
Definition class_detprobdata.cpp:902
GCG_EXPORT SCIP_VAR * getVar(int varIndex)
returns SCIP variable related to a variable index
Definition class_detprobdata.cpp:1015
GCG_EXPORT SCIP_CONS * getCons(int consIndex)
returns the SCIP constraint related to a constraint index
Definition class_detprobdata.cpp:746
GCG_EXPORT int getNMasterconss()
Gets size of the vector containing master conss.
Definition class_partialdecomp.cpp:4481
GCG_EXPORT bool fixVarToMasterByName(const char *varname)
assigns a variable with given name as master
Definition class_partialdecomp.cpp:5687
GCG_EXPORT std::vector< GCG_DETECTOR * > & getDetectorchain()
returns detector chain as vector of detector pointers
Definition class_partialdecomp.cpp:3977
GCG_EXPORT SCIP_Real getPctConssToBorder(int detectorchainindex)
Gets fraction of constraints assigned to the border for a detector.
Definition class_partialdecomp.cpp:4643
GCG_EXPORT SCIP_Real getPctVarsToBorder(int detectorchainindex)
Gets fraction of variables assigned to the border for a detector.
Definition class_partialdecomp.cpp:4570
GCG_EXPORT bool fixConsToBlockByName(const char *consname, int blockid)
assigns a constraint by name to a block
Definition class_partialdecomp.cpp:5639
GCG_EXPORT USERGIVEN getUsergiven()
Gets the USERGIVEN status of this partialdecs.
Definition class_partialdecomp.cpp:4408
GCG_EXPORT void setNBlocks(int nblocks)
sets number of blocks, only increasing number allowed
Definition class_partialdecomp.cpp:5350
GCG_EXPORT 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:3931
GCG_EXPORT bool fixVarToLinkingByName(const char *varname)
assigns a variable by name to the linking variables
Definition class_partialdecomp.cpp:5701
GCG_EXPORT bool fixVarToBlockByName(const char *varname, int blockid)
assigns a variable by name to a block
Definition class_partialdecomp.cpp:5655
GCG_EXPORT std::vector< int > & getMasterconss()
Gets array containing all master conss indices.
Definition class_partialdecomp.cpp:4286
GCG_EXPORT std::vector< int > & getConssForBlock(int block)
returns array containing constraints assigned to a block
Definition class_partialdecomp.cpp:3968
GCG_EXPORT DETPROBDATA * getDetprobdata()
Gets the corresponding detprobdata.
Definition class_partialdecomp.cpp:4725
GCG_EXPORT bool isComplete()
Gets whether this partialdec is complete, i.e. it has no more open constraints and variables.
Definition class_partialdecomp.cpp:4796
GCG_EXPORT SCIP_Real getPctVarsToBlock(int detectorchainindex)
Gets fraction of variables assigned to a block for a detector.
Definition class_partialdecomp.cpp:4594
GCG_EXPORT int getNVarsForBlock(int block)
Gets size of the vector containing vars assigned to a block.
Definition class_partialdecomp.cpp:4537
GCG_EXPORT std::vector< int > & getLinkingvars()
returns array containing all linking vars indices
Definition class_partialdecomp.cpp:4261
GCG_EXPORT bool isAssignedToOrigProb()
Gets whether the partialdec is from the original problem.
Definition class_partialdecomp.cpp:4835
GCG_EXPORT std::vector< int > & getMastervars()
Gets array containing all master vars indices.
Definition class_partialdecomp.cpp:4292
GCG_EXPORT void setUsergiven(USERGIVEN usergiven)
sets whether this partialdec is user given
Definition class_partialdecomp.cpp:5411
GCG_EXPORT SCIP_Real getPctConssToBlock(int detectorchainindex)
Gets fraction of constraints assigned to a block for a detector.
Definition class_partialdecomp.cpp:4667
GCG_EXPORT int getNLinkingvars()
Gets size of the vector containing linking vars.
Definition class_partialdecomp.cpp:4459
GCG_EXPORT int getNNewBlocks(int detectorchainindex)
Gets number of blocks a detector added.
Definition class_partialdecomp.cpp:4465
GCG_EXPORT int getNMastervars()
Gets size of the vector containing master vars.
Definition class_partialdecomp.cpp:4487
GCG_EXPORT int getNConssForBlock(int block)
Gets size of the vector containing conss assigned to a block.
Definition class_partialdecomp.cpp:4432
GCG_EXPORT std::vector< std::string > & getDetectorchainInfo()
Gets the detectorchain info vector.
Definition class_partialdecomp.cpp:4441
GCG_EXPORT bool isConsOpencons(int cons)
Gets whether the cons is an open cons.
Definition class_partialdecomp.cpp:4826
GCG_EXPORT std::vector< int >::const_iterator fixConsToMaster(std::vector< int >::const_iterator itr)
fixes a constraint to the master constraints
Definition class_partialdecomp.cpp:5264
GCG_EXPORT std::vector< int > & getVarsForBlock(int block)
Gets array containing vars of a block.
Definition class_partialdecomp.cpp:4771
const char * GCGdetectorGetName(GCG_DETECTOR *detector)
returns the name of the provided detector
Definition cons_decomp.cpp:2084
PARTIALDECOMP * GCGgetPartialdecToWrite(GCG *gcg, SCIP_Bool transformed)
Definition cons_decomp.cpp:2441
SCIP_RETCODE GCGconshdlrDecompAddPreexisitingPartialDec(GCG *gcg, PARTIALDECOMP *partialdec)
adds a preexisting partial dec to be considered at the beginning of the detection
Definition cons_decomp.cpp:3133
constraint handler for structure detection
C++ interface of cons_decomp.
#define SCIP_Bool
#define TRUE
#define FALSE
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
void SCIPrewind(SCIP_FILE *stream)
int SCIPfclose(SCIP_FILE *fp)
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
SCIP_STAGE SCIPgetStage(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
SCIP_CONS * SCIPfindOrigCons(SCIP *scip, const char *name)
int SCIPgetNConss(SCIP *scip)
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
SCIP_CONS * SCIPfindCons(SCIP *scip, const char *name)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPgetConsNVars(SCIP *scip, SCIP_CONS *cons, int *nvars, SCIP_Bool *success)
SCIP_RETCODE SCIPgetConsVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int varssize, SCIP_Bool *success)
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
const char * SCIPconsGetName(SCIP_CONS *cons)
#define SCIPallocMemoryArray(scip, ptr, num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
#define SCIPfreeMemoryArray(scip, ptr)
#define SCIPfreeBufferArrayNull(scip, ptr)
SCIP_RETCODE SCIPincludeReader(SCIP *scip, const char *name, const char *desc, const char *extension, SCIP_DECL_READERCOPY((*readercopy)), SCIP_DECL_READERFREE((*readerfree)), SCIP_DECL_READERREAD((*readerread)), SCIP_DECL_READERWRITE((*readerwrite)), SCIP_READERDATA *readerdata)
SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
SCIP_READER * SCIPfindReader(SCIP *scip, const char *name)
SCIP_RETCODE SCIPpresolve(SCIP *scip)
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
int SCIPstrcasecmp(const char *s1, const char *s2)
int SCIPsnprintf(char *t, int len, const char *s,...)
void SCIPprintSysError(const char *message)
SCIPfreeMemory(GCGgetOrigprob(gcg), &divingdata)
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
#define NULL
#define BMSclearMemoryArray(ptr, num)
Definition class_conspartition.cpp:44
public methods for working with decomposition structures
struct SCIP_File SCIP_FILE
public methods for GCG variables
#define SCIPerrorMessage
static void syntaxError(SCIP *scip, BLKINPUT *blkinput, const char *msg)
Definition reader_blk.cpp:140
static SCIP_RETCODE readPresolved(SCIP *scip, BLKINPUT *blkinput)
Definition reader_blk.cpp:561
static SCIP_RETCODE readMasterconss(SCIP *scip, BLKINPUT *blkinput, gcg::PARTIALDECOMP *partialdec, SCIP_READERDATA *readerdata)
Definition reader_blk.cpp:720
static SCIP_Bool isInt(SCIP *scip, BLKINPUT *blkinput, int *value)
Definition reader_blk.cpp:422
static SCIP_Bool isValueChar(char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, BLKEXPTYPE *exptype)
Definition reader_blk.cpp:197
static SCIP_RETCODE readNBlocks(SCIP *scip, gcg::PARTIALDECOMP *partialdec, BLKINPUT *blkinput)
Definition reader_blk.cpp:597
static SCIP_Bool isNewSection(SCIP *scip, BLKINPUT *blkinput)
Definition reader_blk.cpp:450
static SCIP_RETCODE readBlockvars(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition reader_dec.cpp:779
static SCIP_RETCODE readLinkingvars(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition reader_dec.cpp:906
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:1101
static SCIP_RETCODE readBlockconss(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition reader_dec.cpp:677
static SCIP_RETCODE readIncomplete(SCIP *scip, DECINPUT *decinput)
Definition reader_dec.cpp:559
static SCIP_RETCODE setPresolved(SCIP *scip, DECINPUT *decinput)
Definition reader_dec.cpp:951
static SCIP_RETCODE readDECFile(SCIP *scip, SCIP_READER *reader, DECINPUT *decinput, const char *filename)
Definition reader_dec.cpp:971
static SCIP_RETCODE readMastervars(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition reader_dec.cpp:861
SCIP_RETCODE readDec(SCIP *scip, const char *filename, SCIP_RESULT *result)
Definition reader_dec.cpp:1209
DEC file reader for structure information.
various SCIP helper methods
Definition reader_dec.cpp:84
Definition reader_blk.cpp:112
struct SCIP_Cons SCIP_CONS
SCIP_VERBLEVEL_DIALOG
SCIP_VERBLEVEL_MINIMAL
struct SCIP_ReaderData SCIP_READERDATA
struct SCIP_Reader SCIP_READER
SCIP_SUCCESS
enum SCIP_Result SCIP_RESULT
SCIP_NOFILE
SCIP_READERROR
SCIP_INVALIDDATA
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
SCIP_STAGE_INIT
SCIP_STAGE_PRESOLVED
struct SCIP_Var SCIP_VAR