61#define READER_NAME "diffreader"
62#define READER_DESC "file reader for changes in the LP file"
63#define READER_EXTENSION "diff"
68#define LP_MAX_LINELEN 65536
69#define LP_MAX_PUSHEDTOKENS 2
70#define LP_INIT_COEFSSIZE 8192
130 SCIPerrorMessage(
"Syntax error in line %d ('%s'): %s \n", lpinput->linenumber, lpinput->token, msg);
131 if( lpinput->linebuf[lpinput->linebufsize - 1] ==
'\n' )
139 (void)
SCIPsnprintf(formatstr, 256,
" %%%ds\n", lpinput->linepos);
141 lpinput->section =
LP_END;
142 lpinput->haserror =
TRUE;
153 return lpinput->haserror;
214 if( isdigit((
unsigned char)
c) )
216 else if( (*exptype ==
LP_EXP_NONE) && !(*hasdot) && (
c ==
'.') && isdigit((
unsigned char)nextc) )
221 else if( !firstchar && (*exptype ==
LP_EXP_NONE) && (
c ==
'e' ||
c ==
'E') )
223 if( nextc ==
'+' || nextc ==
'-' )
228 else if( isdigit((
unsigned char)nextc) )
257 lpinput->linepos = 0;
258 lpinput->linebuf[lpinput->linebufsize - 2] =
'\0';
260 if(
SCIPfgets(lpinput->linebuf, lpinput->linebufsize, lpinput->file) ==
NULL )
268 lpinput->linenumber++;
271 while( lpinput->linebuf[lpinput->linebufsize - 2] !=
'\0' )
278 lpinput->linebuf[newsize-2] =
'\0';
279 if (
SCIPfgets(lpinput->linebuf + lpinput->linebufsize - 1, newsize - lpinput->linebufsize + 1, lpinput->file) ==
NULL )
281 lpinput->linebufsize = newsize;
283 lpinput->linebuf[lpinput->linebufsize - 1] =
'\0';
291 if( commentstart !=
NULL )
293 *commentstart =
'\0';
294 *(commentstart+1) =
'\0';
313 *pointer1 = *pointer2;
330 assert(lpinput->linepos < lpinput->linebufsize);
333 if( lpinput->npushedtokens > 0 )
335 swapPointers(&lpinput->token, &lpinput->pushedtokens[lpinput->npushedtokens-1]);
336 lpinput->npushedtokens--;
338 SCIPdebugMsg(
scip,
"(line %d) read token again: '%s'\n", lpinput->linenumber, lpinput->token);
343 buf = lpinput->linebuf;
346 if( buf[lpinput->linepos] ==
'\0' )
350 lpinput->section =
LP_END;
354 assert(lpinput->linepos == 0);
356 buf = lpinput->linebuf;
361 assert(lpinput->linepos < lpinput->linebufsize);
363 assert(buf[lpinput->linepos] !=
'\0');
368 if(
isValueChar(buf[lpinput->linepos], buf[lpinput->linepos+1],
TRUE, &hasdot, &exptype) )
376 lpinput->token[tokenlen] = buf[lpinput->linepos];
380 while(
isValueChar(buf[lpinput->linepos], buf[lpinput->linepos+1],
FALSE, &hasdot, &exptype) );
389 lpinput->token[tokenlen] = buf[lpinput->linepos];
392 if( tokenlen == 1 &&
isTokenChar(lpinput->token[0]) )
401 if( tokenlen >= 1 && lpinput->token[tokenlen-1] ==
'^' && buf[lpinput->linepos] ==
'2' )
406 && (lpinput->token[tokenlen-1] ==
'<' || lpinput->token[tokenlen-1] ==
'>' || lpinput->token[tokenlen-1] ==
'=')
407 && buf[lpinput->linepos] ==
'=' )
411 else if( lpinput->token[tokenlen-1] ==
'=' && (buf[lpinput->linepos] ==
'<' || buf[lpinput->linepos] ==
'>') )
413 lpinput->token[tokenlen-1] = buf[lpinput->linepos];
418 lpinput->token[tokenlen] =
'\0';
420 SCIPdebugMsg(
scip,
"(line %d) read token: '%s'\n", lpinput->linenumber, lpinput->token);
434 swapPointers(&lpinput->pushedtokens[lpinput->npushedtokens], &lpinput->token);
435 lpinput->npushedtokens++;
447 swapPointers(&lpinput->pushedtokens[lpinput->npushedtokens], &lpinput->tokenbuf);
448 lpinput->npushedtokens++;
481 iscolon = (*lpinput->token ==
':');
492 len = strlen(lpinput->token);
496 if( len > 1 && (len < 9 || len == 15) )
501 while( lpinput->token[
c] !=
'\0' )
503 token[
c] = toupper(lpinput->token[
c]);
509 if( (len == 3 && strcmp(token,
"MIN") == 0)
510 || (len == 7 && strcmp(token,
"MINIMUM") == 0)
511 || (len == 8 && strcmp(token,
"MINIMIZE") == 0) )
513 SCIPdebugMsg(
scip,
"(line %d) new section: OBJECTIVE\n", lpinput->linenumber);
519 if( (len == 3 && strcmp(token,
"MAX") == 0)
520 || (len == 7 && strcmp(token,
"MAXIMUM") == 0)
521 || (len == 8 && strcmp(token,
"MAXIMIZE") == 0) )
523 SCIPdebugMsg(
scip,
"(line %d) new section: OBJECTIVE\n", lpinput->linenumber);
529 if( len == 3 && strcmp(token,
"END") == 0 )
532 lpinput->section =
LP_END;
549 assert(*sign == +1 || *sign == -1);
551 if( lpinput->token[1] ==
'\0' )
553 if( *lpinput->token ==
'+' )
555 else if( *lpinput->token ==
'-' )
586 val = strtod(lpinput->token, &endptr);
587 if( endptr != lpinput->token && *endptr ==
'\0' )
606 if( strcmp(lpinput->token,
"<") == 0 )
612 else if( strcmp(lpinput->token,
">") == 0 )
618 else if( strcmp(lpinput->token,
"=") == 0 )
719 if( strcmp(lpinput->token,
":") == 0 )
725 SCIPdebugMsg(
scip,
"(line %d) read constraint name: '%s'\n", lpinput->linenumber, name);
757 if(
isSign(lpinput, &coefsign) )
759 SCIPdebugMsg(
scip,
"(line %d) read coefficient sign: %+d\n", lpinput->linenumber, coefsign);
767 SCIPdebugMsg(
scip,
"(line %d) read coefficient value: %g with sign %+d\n", lpinput->linenumber, coef, coefsign);
794 if( (isobjective || (!havevalue && !havesign)) &&
isNewSection(
scip, lpinput) )
796 if( havesign && !havevalue )
798 SCIPwarningMessage(
scip,
"skipped single sign %c without value or variable in objective\n", coefsign == 1 ?
'+' :
'-');
810 if( *lpinput->token ==
'[' )
812 syntaxError(
scip, lpinput,
"diff reader does not support quadratic objective function.");
817 if( *ncoefs > 0 && !havesign )
819 syntaxError(
scip, lpinput,
"expected sign ('+' or '-') or sense ('<' or '>').");
824 if( *lpinput->token ==
'^' )
826 syntaxError(
scip, lpinput,
"diff reader does not support quadratic objective function.");
840 if( *ncoefs >= *coefssize )
844 oldcoefssize = *coefssize;
846 *coefssize =
MAX(*coefssize, (*ncoefs)+1);
850 assert(*ncoefs < *coefssize);
853 (*vars)[*ncoefs] =
var;
854 (*coefs)[*ncoefs] = coefsign * coef;
908 lpinput->file =
SCIPfopen(filename,
"r");
909 if( lpinput->file ==
NULL )
930 switch( lpinput->section )
1015 const char* filename,
1026 lpinput.file =
NULL;
1028 lpinput.linebuf[0] =
'\0';
1030 lpinput.probname[0] =
'\0';
1031 lpinput.objname[0] =
'\0';
1033 lpinput.token[0] =
'\0';
1035 lpinput.tokenbuf[0] =
'\0';
1041 lpinput.npushedtokens = 0;
1042 lpinput.linenumber = 0;
1043 lpinput.linepos = 0;
1046 lpinput.haserror =
FALSE;
1061 if( lpinput.haserror )
#define SCIP_CALL_ABORT(x)
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 SCIPreadDiff(SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result)
SCIP_RETCODE SCIPincludeReaderDiff(SCIP *scip)
SCIP_STAGE SCIPgetStage(SCIP *scip)
SCIP_RETCODE SCIPchgReoptObjective(SCIP *scip, SCIP_OBJSENSE objsense, SCIP_VAR **vars, SCIP_Real *coefs, int nvars)
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
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_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader,)
const char * SCIPreaderGetName(SCIP_READER *reader)
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader,)
SCIP_Bool SCIPisReoptEnabled(SCIP *scip)
SCIP_RETCODE SCIPfreeReoptSolve(SCIP *scip)
SCIP_RETCODE SCIPfreeTransform(SCIP *scip)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
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)
int SCIPmemccpy(char *dest, const char *src, char stop, unsigned int cnt)
assert(minobj< SCIPgetCutoffbound(scip))
#define BMSclearMemoryArray(ptr, num)
wrapper functions to map file i/o to standard or zlib file i/o
struct SCIP_File SCIP_FILE
public methods for message output
public data structures and miscellaneous methods
public methods for input file readers
public methods for problem variables
#define LP_INIT_COEFSSIZE
static SCIP_Bool isSign(LPINPUT *lpinput, int *sign)
static SCIP_Bool isNewSection(SCIP *scip, LPINPUT *lpinput)
static SCIP_Bool hasError(LPINPUT *lpinput)
static void pushToken(LPINPUT *lpinput)
static SCIP_Bool getNextLine(SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE getVariable(SCIP *scip, char *name, SCIP_VAR **var)
static void swapTokenBuffer(LPINPUT *lpinput)
static SCIP_Bool getNextToken(SCIP *scip, LPINPUT *lpinput)
static const char commentchars[]
static SCIP_Bool isValueChar(char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, LPEXPTYPE *exptype)
#define LP_MAX_PUSHEDTOKENS
static SCIP_RETCODE readObjective(SCIP *scip, LPINPUT *lpinput)
static SCIP_Bool isValue(SCIP *scip, LPINPUT *lpinput, SCIP_Real *value)
static void syntaxError(SCIP *scip, LPINPUT *lpinput, const char *msg)
static void pushBufferToken(LPINPUT *lpinput)
static SCIP_RETCODE readCoefficients(SCIP *scip, LPINPUT *lpinput, SCIP_Bool isobjective, char *name, int *coefssize, SCIP_VAR ***vars, SCIP_Real **coefs, int *ncoefs, SCIP_Bool *newsection)
static SCIP_Bool isSense(LPINPUT *lpinput, LPSENSE *sense)
static SCIP_Bool isDelimChar(char c)
static void swapPointers(char **pointer1, char **pointer2)
static SCIP_RETCODE readStart(SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readDiffFile(SCIP *scip, LPINPUT *lpinput, const char *filename)
static SCIP_Bool isTokenChar(char c)
public methods for memory management
public methods for message handling
public methods for numerical tolerances
public methods for global and local (sub)problems
public methods for reader plugins
enum SCIP_Objsense SCIP_OBJSENSE
struct SCIP_Reader SCIP_READER
#define SCIP_DECL_READERREAD(x)
#define SCIP_DECL_READERCOPY(x)
#define SCIP_DECL_READERFREE(x)
enum SCIP_Result SCIP_RESULT
enum SCIP_Retcode SCIP_RETCODE