54#define READER_NAME "cipreader"
55#define READER_DESC "file reader for CIP (Constraint Integer Program) format"
56#define READER_EXTENSION "cip"
58#define DEFAULT_CIP_WRITEFIXEDVARS TRUE
64 SCIP_Bool writefixedvars;
114 char* windowsendlinechar;
119 cipinput->endfile = (
SCIPfgets(cipinput->strbuf, cipinput->len, cipinput->file) ==
NULL);
121 if( cipinput->endfile )
128 cipinput->linenumber++;
129 endline = strchr(cipinput->strbuf,
'\n');
130 endcharacter = strchr(cipinput->strbuf,
';');
132 while( endline ==
NULL || (endcharacter ==
NULL && cipinput->section ==
CIP_CONSTRAINTS && strncmp(cipinput->strbuf,
"END", 3) != 0 ) )
137 if( endline ==
NULL )
138 pos = cipinput->len - 1;
140 pos = (int) (endline - cipinput->strbuf);
147 if( pos + cipinput->readingsize >= cipinput->len )
154 cipinput->endfile = (
SCIPfgets(&(cipinput->strbuf[pos]), cipinput->len - pos, cipinput->file) ==
NULL);
156 if( cipinput->endfile )
163 cipinput->linenumber++;
164 endline = strrchr(&cipinput->strbuf[pos],
'\n');
165 endcharacter = strchr(&cipinput->strbuf[pos],
';');
172 windowsendlinechar = strrchr(cipinput->strbuf,
'\r');
173 if( windowsendlinechar !=
NULL && windowsendlinechar + 1 == endline )
179 if( cipinput->section ==
CIP_CONSTRAINTS && endcharacter !=
NULL && endline - endcharacter != 1 )
181 SCIPerrorMessage(
"Constraint line has to end with ';\\n' (line: %d).\n", cipinput->linenumber);
182 cipinput->haserror =
TRUE;
202 buf = cipinput->strbuf;
204 if( strncmp(buf,
"STATISTICS", 9) == 0 )
210 if( strncmp(buf,
"VARIABLES", 8) == 0 || strncmp(buf,
"FIXED", 5) == 0 || strncmp(buf,
"CONSTRAINTS", 11) == 0 || strncmp(buf,
"OBJECTIVE", 9) == 0 )
212 SCIPerrorMessage(
"Syntax Error: File has to start with 'STATISTICS' section.\n");
213 cipinput->haserror =
TRUE;
227 buf = cipinput->strbuf;
229 if( strncmp(buf,
"OBJECTIVE", 9) == 0 )
237 if( strncmp(buf,
" Problem name", 14) == 0 )
242 name = strchr(buf,
':');
246 SCIPwarningMessage(
scip,
"did not find problem name (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
254 if(
NULL != (s = strpbrk(name,
"#\r\n")) )
284 buf = cipinput->strbuf;
286 if( strncmp(buf,
"VARIABLES", 8) == 0 )
288 else if( strncmp(buf,
"FIXED", 5) == 0 )
290 else if( strncmp(buf,
"CONSTRAINTS", 11) == 0 )
292 else if( strncmp(buf,
"END", 3) == 0 )
307 name = strchr(buf,
':');
311 SCIPwarningMessage(
scip,
"did not find objective sense (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
327 SCIPwarningMessage(
scip,
"unknown objective sense '%s' (line: %d):\n%s\n", name, cipinput->linenumber, cipinput->strbuf);
340 name = strchr(buf,
':');
361 SCIPwarningMessage(
scip,
"could not parse offset (line: %d)\n%s\n", cipinput->linenumber, cipinput->strbuf);
367 SCIP_Real scale = 1.0;
370 name = strchr(buf,
':');
391 SCIPwarningMessage(
scip,
"could not parse objective scale (line: %d)\n%s\n", cipinput->linenumber, cipinput->strbuf);
414 buf = cipinput->strbuf;
416 if( strncmp(buf,
"FIXED", 5) == 0 )
418 else if( strncmp(buf,
"CONSTRAINTS", 4) == 0 )
420 else if( strncmp(buf,
"END", 3) == 0 )
429 SCIP_CALL(
SCIPparseVar(
scip, &
var, buf, initial, removable,
NULL,
NULL,
NULL,
NULL,
NULL, &endptr, &success) );
433 SCIPerrorMessage(
"syntax error in variable information (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
434 cipinput->haserror =
TRUE;
465 buf = cipinput->strbuf;
467 if( strncmp(buf,
"CONSTRAINTS", 11) == 0 )
469 else if( strncmp(buf,
"END", 3) == 0 )
478 SCIP_CALL(
SCIPparseVar(
scip, &
var, buf,
TRUE,
FALSE,
NULL,
NULL,
NULL,
NULL,
NULL, &endptr, &success) );
482 SCIPerrorMessage(
"syntax error in variable information (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
483 cipinput->haserror =
TRUE;
490 while ( *buf !=
'\0' && (*buf ==
' ' || *buf ==
',') )
494 if ( strncmp(buf,
"fixed:", 6) == 0 )
499 else if ( strncmp(buf,
"negated:", 8) == 0 )
511 if ( negvar ==
NULL )
513 SCIPerrorMessage(
"could not parse negated variable (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
514 cipinput->haserror =
TRUE;
533 SCIP_CALL(
SCIPcreateConsLinear(
scip, &lincons, name, 2,
vars, vals, 1.0, 1.0,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
FALSE,
TRUE,
FALSE) );
538 else if ( strncmp(buf,
"aggregated:", 11) == 0 )
557 SCIPerrorMessage(
"expected constant when aggregated variable information (line: %d):\n%s\n", cipinput->linenumber, buf);
558 cipinput->haserror =
TRUE;
587 if ( success && requsize > nvarssize )
590 nvarssize = requsize;
595 assert( ! success || requsize <= nvarssize);
605 if ( strncmp(str,
"indslack", 8) == 0 )
610 else if ( strncmp(str,
"t_indslack", 10) == 0 )
620 SCIP_CALL(
SCIPcreateConsLinear(
scip, &lincons, name,
nvars + 1,
vars, vals, -rhs, -rhs,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
FALSE,
TRUE,
FALSE) );
627 SCIPwarningMessage(
scip,
"Could not read (multi-)aggregated variable <%s>: dependent variables unkown - consider changing the order (line: %d):\n%s\n",
636 SCIPerrorMessage(
"unknown section when parsing variables (line: %d):\n%s\n", cipinput->linenumber, buf);
637 cipinput->haserror =
TRUE;
668 SCIP_Bool modifiable;
672 buf = cipinput->strbuf;
674 if( strncmp(buf,
"END", 3) == 0 )
690 len = (int)strlen(buf);
693 SCIPerrorMessage(
"syntax error: expected constraint in line %d.\n", cipinput->linenumber);
694 cipinput->haserror =
TRUE;
697 if ( buf[len - 1] !=
';' )
699 SCIPerrorMessage(
"syntax error: line has to end with ';' (line: %d)\n", cipinput->linenumber);
700 cipinput->haserror =
TRUE;
706 copybuf[len - 1] =
'\0';
710 initial, separate, enforce, check,
propagate, local, modifiable, dynamic, removable,
FALSE, &success);
719 SCIPerrorMessage(
"syntax error when reading constraint (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
720 cipinput->haserror =
TRUE;
771 SCIP_Bool initialconss;
772 SCIP_Bool dynamicconss;
773 SCIP_Bool dynamiccols;
774 SCIP_Bool dynamicrows;
775 SCIP_Bool initialvar;
776 SCIP_Bool removablevar;
786 cipinput.len = 131071;
789 cipinput.linenumber = 0;
791 cipinput.haserror =
FALSE;
792 cipinput.endfile =
FALSE;
793 cipinput.readingsize = 65535;
802 initialvar = !dynamiccols;
803 removablevar = dynamiccols;
808 while( cipinput.section !=
CIP_END && !cipinput.haserror )
813 if( cipinput.endfile )
816 switch( cipinput.section )
832 cipinput.haserror =
TRUE;
843 cipinput.haserror =
TRUE;
850 retcode =
getConstraint(
scip, &cipinput, initialconss, dynamicconss, dynamicrows);
854 cipinput.haserror =
TRUE;
876 SCIPdebugMsg(
scip,
"added variables <objoffset> for objective offset of <%g>\n", objoffset);
879 if( cipinput.section !=
CIP_END && !cipinput.haserror )
890 if( cipinput.haserror )
935 SCIPinfoMessage(
scip, file,
" Variables : %d (%d binary, %d integer, %d implicit integer, %d continuous)\n",
937 SCIPinfoMessage(
scip, file,
" Constraints : %d initial, %d maximal\n", startnconss, maxnconss);
946 if ( nfixedvars > 0 )
952 if (
nvars + nfixedvars > 0 )
966 if ( varhash !=
NULL )
980 if( readerdata->writefixedvars && nfixedvars > 0 )
988 while ( nwritten < nfixedvars )
990 SCIPdebugMsg(
scip,
"written %d of %d fixed variables.\n", nwritten, nfixedvars);
991 for (
i = 0;
i < nfixedvars; ++
i)
1059 for (j = 0; j < naggrvars; ++j)
1066 if ( j >= naggrvars )
1079 SCIPerrorMessage(
"Only fixed variables are allowed to be present in fixedvars list.\n");
1091 for(
i = 0;
i < nconss; ++
i )
1101 if( nfixedvars > 0 )
1136 "reading/cipreader/writefixedvars",
"should fixed and aggregated variables be printed (if not, re-parsing might fail)",
Constraint handler for linear constraints in their most general form, .
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
int SCIPfclose(SCIP_FILE *fp)
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPincludeReaderCip(SCIP *scip)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPsetProbName(SCIP *scip, const char *name)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
void SCIPhashtableFree(SCIP_HASHTABLE **hashtable)
SCIP_Bool SCIPhashtableExists(SCIP_HASHTABLE *hashtable, void *element)
SCIP_RETCODE SCIPhashtableCreate(SCIP_HASHTABLE **hashtable, BMS_BLKMEM *blkmem, int tablesize, SCIP_DECL_HASHGETKEY((*hashgetkey)), SCIP_DECL_HASHKEYEQ((*hashkeyeq)), SCIP_DECL_HASHKEYVAL((*hashkeyval)), void *userptr)
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
SCIP_RETCODE SCIPparseCons(SCIP *scip, SCIP_CONS **cons, const char *str, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, SCIP_Bool *success)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPreallocBufferArray(scip, ptr, num)
#define SCIPfreeBufferArray(scip, ptr)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader,)
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader,)
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader,)
const char * SCIPreaderGetName(SCIP_READER *reader)
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader,)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_VAR * SCIPvarGetNegatedVar(SCIP_VAR *var)
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_RETCODE SCIPparseVarName(SCIP *scip, const char *str, SCIP_VAR **var, char **endptr)
SCIP_RETCODE SCIPparseVar(SCIP *scip, SCIP_VAR **var, const char *str, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARCOPY((*varcopy)), SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_VARDATA *vardata, char **endptr, SCIP_Bool *success)
int SCIPvarGetIndex(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_RETCODE SCIPparseVarsLinearsum(SCIP *scip, const char *str, SCIP_VAR **vars, SCIP_Real *vals, int *nvars, int varssize, int *requiredsize, char **endptr, SCIP_Bool *success)
SCIP_RETCODE SCIPflattenVarAggregationGraph(SCIP *scip, SCIP_VAR *var)
SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
SCIP_RETCODE SCIPprintVar(SCIP *scip, SCIP_VAR *var, FILE *file)
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
SCIP_VAR * SCIPvarGetAggrVar(SCIP_VAR *var)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIP_Bool SCIPstrToRealValue(const char *str, SCIP_Real *value, char **endptr)
void SCIPprintSysError(const char *message)
SCIP_RETCODE SCIPskipSpace(char **s)
int SCIPstrncasecmp(const char *s1, const char *s2, int length)
assert(minobj< SCIPgetCutoffbound(scip))
static SCIP_Bool propagate
memory allocation routines
#define BMSclearMemoryArray(ptr, num)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
wrapper functions to map file i/o to standard or zlib file i/o
struct SCIP_File SCIP_FILE
public methods for message output
#define SCIPdebugPrintCons(x, y, z)
public data structures and miscellaneous methods
public methods for input file readers
public methods for problem variables
static SCIP_RETCODE getConstraint(SCIP *scip, CIPINPUT *cipinput, SCIP_Bool initial, SCIP_Bool dynamic, SCIP_Bool removable)
enum CipSection CIPSECTION
static SCIP_RETCODE getInputString(SCIP *scip, CIPINPUT *cipinput)
static SCIP_RETCODE getObjective(SCIP *scip, CIPINPUT *cipinput, SCIP_Real *objscale, SCIP_Real *objoffset)
static void getStart(SCIP *scip, CIPINPUT *cipinput)
static SCIP_RETCODE getStatistics(SCIP *scip, CIPINPUT *cipinput)
#define DEFAULT_CIP_WRITEFIXEDVARS
static SCIP_RETCODE getFixedVariable(SCIP *scip, CIPINPUT *cipinput)
static SCIP_RETCODE getVariable(SCIP *scip, CIPINPUT *cipinput, SCIP_Bool initial, SCIP_Bool removable, SCIP_Real objscale)
public methods for constraint handler plugins and constraints
public methods for memory management
public methods for message handling
public methods for numerical tolerances
public methods for SCIP parameter handling
public methods for global and local (sub)problems
public methods for reader plugins
public methods for SCIP variables
#define SCIP_DECL_HASHKEYEQ(x)
#define SCIP_DECL_HASHGETKEY(x)
#define SCIP_DECL_HASHKEYVAL(x)
enum SCIP_Objsense SCIP_OBJSENSE
#define SCIP_DECL_READERWRITE(x)
struct SCIP_ReaderData SCIP_READERDATA
#define SCIP_DECL_READERREAD(x)
#define SCIP_DECL_READERCOPY(x)
#define SCIP_DECL_READERFREE(x)
enum SCIP_Retcode SCIP_RETCODE
@ SCIP_VARTYPE_CONTINUOUS
@ SCIP_VARSTATUS_ORIGINAL
@ SCIP_VARSTATUS_MULTAGGR
@ SCIP_VARSTATUS_AGGREGATED