61#if !defined(_WIN32) && !defined(_WIN64)
65#define READER_NAME "diffreader"
66#define READER_DESC "file reader for changes in the LP file"
67#define READER_EXTENSION "diff"
72#define LP_MAX_LINELEN 65536
73#define LP_MAX_PUSHEDTOKENS 2
74#define LP_INIT_COEFSSIZE 8192
134 SCIPerrorMessage(
"Syntax error in line %d ('%s'): %s \n", lpinput->linenumber, lpinput->token, msg);
135 if( lpinput->linebuf[lpinput->linebufsize - 1] ==
'\n' )
143 (void)
SCIPsnprintf(formatstr, 256,
" %%%ds\n", lpinput->linepos);
145 lpinput->section =
LP_END;
146 lpinput->haserror =
TRUE;
157 return lpinput->haserror;
218 if( isdigit((
unsigned char)
c) )
220 else if( (*exptype ==
LP_EXP_NONE) && !(*hasdot) && (
c ==
'.') && isdigit((
unsigned char)nextc) )
225 else if( !firstchar && (*exptype ==
LP_EXP_NONE) && (
c ==
'e' ||
c ==
'E') )
227 if( nextc ==
'+' || nextc ==
'-' )
232 else if( isdigit((
unsigned char)nextc) )
261 lpinput->linepos = 0;
262 lpinput->linebuf[lpinput->linebufsize - 2] =
'\0';
264 if(
SCIPfgets(lpinput->linebuf, lpinput->linebufsize, lpinput->file) ==
NULL )
272 lpinput->linenumber++;
275 while( lpinput->linebuf[lpinput->linebufsize - 2] !=
'\0' )
282 lpinput->linebuf[newsize-2] =
'\0';
283 if (
SCIPfgets(lpinput->linebuf + lpinput->linebufsize - 1, newsize - lpinput->linebufsize + 1, lpinput->file) ==
NULL )
285 lpinput->linebufsize = newsize;
287 lpinput->linebuf[lpinput->linebufsize - 1] =
'\0';
295 if( commentstart !=
NULL )
297 *commentstart =
'\0';
298 *(commentstart+1) =
'\0';
317 *pointer1 = *pointer2;
334 assert(lpinput->linepos < lpinput->linebufsize);
337 if( lpinput->npushedtokens > 0 )
339 swapPointers(&lpinput->token, &lpinput->pushedtokens[lpinput->npushedtokens-1]);
340 lpinput->npushedtokens--;
342 SCIPdebugMsg(
scip,
"(line %d) read token again: '%s'\n", lpinput->linenumber, lpinput->token);
347 buf = lpinput->linebuf;
350 if( buf[lpinput->linepos] ==
'\0' )
354 lpinput->section =
LP_END;
358 assert(lpinput->linepos == 0);
360 buf = lpinput->linebuf;
365 assert(lpinput->linepos < lpinput->linebufsize);
367 assert(buf[lpinput->linepos] !=
'\0');
372 if(
isValueChar(buf[lpinput->linepos], buf[lpinput->linepos+1],
TRUE, &hasdot, &exptype) )
380 lpinput->token[tokenlen] = buf[lpinput->linepos];
384 while(
isValueChar(buf[lpinput->linepos], buf[lpinput->linepos+1],
FALSE, &hasdot, &exptype) );
393 lpinput->token[tokenlen] = buf[lpinput->linepos];
396 if( tokenlen == 1 &&
isTokenChar(lpinput->token[0]) )
405 if( tokenlen >= 1 && lpinput->token[tokenlen-1] ==
'^' && buf[lpinput->linepos] ==
'2' )
410 && (lpinput->token[tokenlen-1] ==
'<' || lpinput->token[tokenlen-1] ==
'>' || lpinput->token[tokenlen-1] ==
'=')
411 && buf[lpinput->linepos] ==
'=' )
415 else if( lpinput->token[tokenlen-1] ==
'=' && (buf[lpinput->linepos] ==
'<' || buf[lpinput->linepos] ==
'>') )
417 lpinput->token[tokenlen-1] = buf[lpinput->linepos];
422 lpinput->token[tokenlen] =
'\0';
424 SCIPdebugMsg(
scip,
"(line %d) read token: '%s'\n", lpinput->linenumber, lpinput->token);
438 swapPointers(&lpinput->pushedtokens[lpinput->npushedtokens], &lpinput->token);
439 lpinput->npushedtokens++;
451 swapPointers(&lpinput->pushedtokens[lpinput->npushedtokens], &lpinput->tokenbuf);
452 lpinput->npushedtokens++;
485 iscolon = (*lpinput->token ==
':');
496 len = strlen(lpinput->token);
500 if( len > 1 && (len < 9 || len == 15) )
505 while( lpinput->token[
c] !=
'\0' )
507 token[
c] = toupper(lpinput->token[
c]);
513 if( (len == 3 && strcmp(token,
"MIN") == 0)
514 || (len == 7 && strcmp(token,
"MINIMUM") == 0)
515 || (len == 8 && strcmp(token,
"MINIMIZE") == 0) )
517 SCIPdebugMsg(
scip,
"(line %d) new section: OBJECTIVE\n", lpinput->linenumber);
523 if( (len == 3 && strcmp(token,
"MAX") == 0)
524 || (len == 7 && strcmp(token,
"MAXIMUM") == 0)
525 || (len == 8 && strcmp(token,
"MAXIMIZE") == 0) )
527 SCIPdebugMsg(
scip,
"(line %d) new section: OBJECTIVE\n", lpinput->linenumber);
533 if( len == 3 && strcmp(token,
"END") == 0 )
536 lpinput->section =
LP_END;
553 assert(*sign == +1 || *sign == -1);
555 if( lpinput->token[1] ==
'\0' )
557 if( *lpinput->token ==
'+' )
559 else if( *lpinput->token ==
'-' )
580 if( strcasecmp(lpinput->token,
"INFINITY") == 0 || strcasecmp(lpinput->token,
"INF") == 0 )
590 val = strtod(lpinput->token, &endptr);
591 if( endptr != lpinput->token && *endptr ==
'\0' )
610 if( strcmp(lpinput->token,
"<") == 0 )
616 else if( strcmp(lpinput->token,
">") == 0 )
622 else if( strcmp(lpinput->token,
"=") == 0 )
677 SCIP_Bool isobjective,
684 SCIP_Bool* newsection
723 if( strcmp(lpinput->token,
":") == 0 )
729 SCIPdebugMsg(
scip,
"(line %d) read constraint name: '%s'\n", lpinput->linenumber, name);
761 if(
isSign(lpinput, &coefsign) )
763 SCIPdebugMsg(
scip,
"(line %d) read coefficient sign: %+d\n", lpinput->linenumber, coefsign);
771 SCIPdebugMsg(
scip,
"(line %d) read coefficient value: %g with sign %+d\n", lpinput->linenumber, coef, coefsign);
798 if( (isobjective || (!havevalue && !havesign)) &&
isNewSection(
scip, lpinput) )
800 if( havesign && !havevalue )
802 SCIPwarningMessage(
scip,
"skipped single sign %c without value or variable in objective\n", coefsign == 1 ?
'+' :
'-');
814 if( *lpinput->token ==
'[' )
816 syntaxError(
scip, lpinput,
"diff reader does not support quadratic objective function.");
821 if( *ncoefs > 0 && !havesign )
823 syntaxError(
scip, lpinput,
"expected sign ('+' or '-') or sense ('<' or '>').");
828 if( *lpinput->token ==
'^' )
830 syntaxError(
scip, lpinput,
"diff reader does not support quadratic objective function.");
844 if( *ncoefs >= *coefssize )
848 oldcoefssize = *coefssize;
850 *coefssize =
MAX(*coefssize, (*ncoefs)+1);
854 assert(*ncoefs < *coefssize);
857 (*vars)[*ncoefs] =
var;
858 (*coefs)[*ncoefs] = coefsign * coef;
882 SCIP_Bool newsection;
912 lpinput->file =
SCIPfopen(filename,
"r");
913 if( lpinput->file ==
NULL )
934 switch( lpinput->section )
1019 const char* filename,
1030 lpinput.file =
NULL;
1032 lpinput.linebuf[0] =
'\0';
1034 lpinput.probname[0] =
'\0';
1035 lpinput.objname[0] =
'\0';
1037 lpinput.token[0] =
'\0';
1039 lpinput.tokenbuf[0] =
'\0';
1045 lpinput.npushedtokens = 0;
1046 lpinput.linenumber = 0;
1047 lpinput.linepos = 0;
1050 lpinput.haserror =
FALSE;
1065 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 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)
#define LP_MAX_PUSHEDTOKENS
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
#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