DIFF file reader.
This reader allows to parse a new objective function in the style of CPLEX .lp files.
The lp format is defined within the CPLEX documentation.
An example of a *.diff file looks like this:
Minimize obj: - STM6 + STM7
Here is the objective sense set to minimize the function -STM6 + STM7.
Definition in file reader_diff.c.
#include <ctype.h>#include "scip/pub_fileio.h"#include "scip/pub_message.h"#include "scip/pub_misc.h"#include "scip/pub_reader.h"#include "scip/pub_var.h"#include "scip/reader_diff.h"#include "scip/scip_general.h"#include "scip/scip_mem.h"#include "scip/scip_message.h"#include "scip/scip_numerics.h"#include "scip/scip_prob.h"#include "scip/scip_reader.h"#include "scip/scip_solve.h"#include <stdlib.h>Go to the source code of this file.
Macros | |
| #define | READER_NAME "diffreader" |
| #define | READER_DESC "file reader for changes in the LP file" |
| #define | READER_EXTENSION "diff" |
| #define | LP_MAX_LINELEN 65536 |
| #define | LP_MAX_PUSHEDTOKENS 2 |
| #define | LP_INIT_COEFSSIZE 8192 |
Functions | |
| static void | syntaxError (SCIP *scip, LPINPUT *lpinput, const char *msg) |
| static SCIP_Bool | hasError (LPINPUT *lpinput) |
| static SCIP_Bool | isDelimChar (char c) |
| static SCIP_Bool | isTokenChar (char c) |
| static SCIP_Bool | isValueChar (char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, LPEXPTYPE *exptype) |
| static SCIP_Bool | getNextLine (SCIP *scip, LPINPUT *lpinput) |
| static void | swapPointers (char **pointer1, char **pointer2) |
| static SCIP_Bool | getNextToken (SCIP *scip, LPINPUT *lpinput) |
| static void | pushToken (LPINPUT *lpinput) |
| static void | pushBufferToken (LPINPUT *lpinput) |
| static void | swapTokenBuffer (LPINPUT *lpinput) |
| static SCIP_Bool | isNewSection (SCIP *scip, LPINPUT *lpinput) |
| static SCIP_Bool | isSign (LPINPUT *lpinput, int *sign) |
| static SCIP_Bool | isValue (SCIP *scip, LPINPUT *lpinput, SCIP_Real *value) |
| static SCIP_Bool | isSense (LPINPUT *lpinput, LPSENSE *sense) |
| static SCIP_RETCODE | getVariable (SCIP *scip, char *name, SCIP_VAR **var) |
| static SCIP_RETCODE | readStart (SCIP *scip, 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_RETCODE | readObjective (SCIP *scip, LPINPUT *lpinput) |
| static SCIP_RETCODE | readDiffFile (SCIP *scip, LPINPUT *lpinput, const char *filename) |
| static | SCIP_DECL_READERCOPY (readerCopyDiff) |
| static | SCIP_DECL_READERFREE (readerFreeDiff) |
| static | SCIP_DECL_READERREAD (readerReadDiff) |
| SCIP_RETCODE | SCIPincludeReaderDiff (SCIP *scip) |
| SCIP_RETCODE | SCIPreadDiff (SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result) |
Variables | |
| static const char | commentchars [] = "\\" |
| #define READER_NAME "diffreader" |
Definition at line 61 of file reader_diff.c.
| #define READER_DESC "file reader for changes in the LP file" |
Definition at line 62 of file reader_diff.c.
| #define READER_EXTENSION "diff" |
Definition at line 63 of file reader_diff.c.
| #define LP_MAX_LINELEN 65536 |
Definition at line 68 of file reader_diff.c.
Referenced by createIndicatorConstraint(), getNextToken(), getNextToken(), isNewSection(), isNewSection(), readCoefficients(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), readObjective(), readObjective(), readObjectiveRational(), SCIPreadDiff(), and SCIPreadLp().
| #define LP_MAX_PUSHEDTOKENS 2 |
Definition at line 69 of file reader_diff.c.
Referenced by pushBufferToken(), pushBufferToken(), pushToken(), pushToken(), SCIPreadDiff(), and SCIPreadLp().
| #define LP_INIT_COEFSSIZE 8192 |
Definition at line 70 of file reader_diff.c.
Referenced by readCoefficients(), readCoefficients(), and readCoefficientsRational().
Definition at line 77 of file reader_diff.c.
Definition at line 83 of file reader_diff.c.
Definition at line 89 of file reader_diff.c.
| typedef struct LpInput LPINPUT |
Definition at line 109 of file reader_diff.c.
| enum LpSection |
Section in LP File
| Enumerator | |
|---|---|
| LP_START | |
| LP_OBJECTIVE | |
| LP_END | |
Definition at line 73 of file reader_diff.c.
| enum LpExpType |
| Enumerator | |
|---|---|
| LP_EXP_NONE | |
| LP_EXP_UNSIGNED | |
| LP_EXP_SIGNED | |
Definition at line 79 of file reader_diff.c.
| enum LpSense |
| Enumerator | |
|---|---|
| LP_SENSE_LE | |
| LP_SENSE_GE | |
| LP_SENSE_EQ | |
Definition at line 85 of file reader_diff.c.
issues an error message and marks the LP data to have errors
| scip | SCIP data structure |
| lpinput | LP reading data |
| msg | error message |
Definition at line 120 of file reader_diff.c.
References assert(), LP_END, NULL, SCIP_VERBLEVEL_MINIMAL, SCIPerrorMessage, SCIPsnprintf(), SCIPverbMessage(), syntaxError(), and TRUE.
Referenced by applyVariableAssignment(), computeLinearConsSides(), CREATE_CONSTRAINT(), CREATE_CONSTRAINT(), CREATE_CONSTRAINT(), createConstantAssignment(), createIndicatorConstraint(), createVariable(), flattenAssignment(), getVariableOrTerm(), parseArrayAssignment(), parseArrayDimension(), parseArrayIndex(), parseArrayType(), parseConstant(), parseConstantArray(), parseConstantArrayAssignment(), parseConstraint(), parseName(), parseOutputDimensioninfo(), parseRange(), parseSolveItem(), parseType(), parseValue(), parseVariable(), parseVariableArray(), parseVariableArrayAssignment(), readBinaries(), readBinaries(), readBounds(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficients(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraints(), readConstraints(), readConstraintsRational(), readFZNFile(), readGenerals(), readGenerals(), readPolynomial(), readSemicontinuous(), readSos(), syntaxError(), syntaxError(), syntaxError(), syntaxError(), and syntaxError().
returns whether a syntax error was detected
| lpinput | LP reading data |
Definition at line 147 of file reader_diff.c.
References assert(), hasError(), NULL, and SCIP_Bool.
Referenced by CREATE_CONSTRAINT(), CREATE_CONSTRAINT(), CREATE_CONSTRAINT(), createIndicatorConstraint(), hasError(), hasError(), hasError(), hasError(), hasError(), parseAggregation(), parseArray(), parseArrayAssignment(), parseConstant(), parseConstantArray(), parseConstantArrayAssignment(), parseConstraint(), parseLinking(), parseList(), parseQuadratic(), parseSolveItem(), parseVariable(), parseVariableArray(), readCoefficients(), readConstraints(), readConstraints(), readConstraints(), readConstraintsRational(), readDiffFile(), readFZNFile(), readLPFile(), readObjective(), readObjective(), readObjectiveRational(), readOPBFile(), readPIPFile(), and setObjective().
|
static |
returns whether the given character is a token delimiter
| c | input character |
Definition at line 158 of file reader_diff.c.
References c, FALSE, isDelimChar(), SCIP_Bool, and TRUE.
Referenced by getNextToken(), getNextToken(), getNextToken(), getNextToken(), getNextToken(), isDelimChar(), isDelimChar(), isDelimChar(), isDelimChar(), and isDelimChar().
|
static |
returns whether the given character is a single token
| c | input character |
Definition at line 179 of file reader_diff.c.
References c, FALSE, isTokenChar(), SCIP_Bool, and TRUE.
Referenced by getNextToken(), getNextToken(), getNextToken(), getNextToken(), getNextToken(), getVariableOrTerm(), isTokenChar(), isTokenChar(), isTokenChar(), isTokenChar(), and isTokenChar().
|
static |
returns whether the current character is member of a value string
| c | input character |
| nextc | next input character |
| firstchar | is the given character the first char of the token? |
| hasdot | pointer to update the dot flag |
| exptype | pointer to update the exponent type |
Definition at line 203 of file reader_diff.c.
References assert(), c, FALSE, isValueChar(), LP_EXP_NONE, LP_EXP_SIGNED, LP_EXP_UNSIGNED, NULL, SCIP_Bool, and TRUE.
Referenced by getNextToken(), getNextToken(), getNextToken(), getNextToken(), getNextToken(), isValueChar(), isValueChar(), isValueChar(), isValueChar(), and isValueChar().
reads the next line from the input file into the line buffer; skips comments; returns whether a line could be read
| scip | SCIP data structure |
| lpinput | LP reading data |
Definition at line 247 of file reader_diff.c.
References assert(), BMSclearMemoryArray, commentchars, FALSE, getNextLine(), i, NULL, SCIP_Bool, SCIP_CALL_ABORT, SCIPcalcMemGrowSize(), SCIPfgets(), SCIPreallocBlockMemoryArray, and TRUE.
Referenced by getNextLine(), getNextLine(), getNextLine(), getNextLine(), getNextLine(), getNextToken(), getNextToken(), getNextToken(), getNextToken(), and getNextToken().
|
static |
swaps the addresses of two pointers
| pointer1 | first pointer |
| pointer2 | second pointer |
Definition at line 305 of file reader_diff.c.
References swapPointers().
Referenced by getNextToken(), getNextToken(), getNextToken(), getNextToken(), pushBufferToken(), pushBufferToken(), pushBufferToken(), pushBufferToken(), pushToken(), pushToken(), pushToken(), pushToken(), swapPointers(), swapPointers(), swapPointers(), swapPointers(), swapTokenBuffer(), swapTokenBuffer(), swapTokenBuffer(), and swapTokenBuffer().
reads the next token from the input file into the token buffer; returns whether a token was read
| scip | SCIP data structure |
| lpinput | LP reading data |
Definition at line 319 of file reader_diff.c.
References assert(), FALSE, getNextLine(), getNextToken(), isDelimChar(), isTokenChar(), isValueChar(), LP_END, LP_EXP_NONE, LP_MAX_LINELEN, NULL, SCIP_Bool, SCIPdebugMsg, swapPointers(), and TRUE.
Referenced by CREATE_CONSTRAINT(), CREATE_CONSTRAINT(), CREATE_CONSTRAINT(), createIndicatorConstraint(), flattenAssignment(), getNextToken(), getNextToken(), getNextToken(), getNextToken(), getNextToken(), getVariableOrTerm(), isNewSection(), isNewSection(), isNewSection(), parseArrayAssignment(), parseArrayDimension(), parseArrayIndex(), parseArrayType(), parseConstant(), parseConstantArray(), parseConstantArrayAssignment(), parseConstraint(), parseList(), parseName(), parseOutputDimensioninfo(), parseRange(), parseSolveItem(), parseType(), parseVariable(), parseVariableArray(), parseVariableArrayAssignment(), readBinaries(), readBinaries(), readBounds(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficients(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraints(), readConstraints(), readConstraintsRational(), readFZNFile(), readGenerals(), readGenerals(), readPolynomial(), readSemicontinuous(), readSos(), readStart(), readStart(), and readStart().
|
static |
puts the current token on the token stack, such that it is read at the next call to getNextToken()
| lpinput | LP reading data |
Definition at line 427 of file reader_diff.c.
References assert(), LP_MAX_PUSHEDTOKENS, NULL, pushToken(), and swapPointers().
Referenced by flattenAssignment(), getVariableOrTerm(), isNewSection(), isNewSection(), isNewSection(), parseArrayType(), parseConstantArrayAssignment(), parseList(), parseName(), parseType(), parseVariable(), parseVariableArray(), parseVariableArrayAssignment(), pushToken(), pushToken(), pushToken(), pushToken(), pushToken(), readBounds(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficients(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), readFZNFile(), readPolynomial(), readSemicontinuous(), and readSos().
|
static |
puts the buffered token on the token stack, such that it is read at the next call to getNextToken()
| lpinput | LP reading data |
Definition at line 440 of file reader_diff.c.
References assert(), LP_MAX_PUSHEDTOKENS, NULL, pushBufferToken(), and swapPointers().
Referenced by pushBufferToken(), pushBufferToken(), pushBufferToken(), pushBufferToken(), readCoefficients(), readCoefficients(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), readPolynomial(), and readSos().
|
static |
swaps the current token with the token buffer
| lpinput | LP reading data |
Definition at line 453 of file reader_diff.c.
References assert(), NULL, swapPointers(), and swapTokenBuffer().
Referenced by isNewSection(), isNewSection(), isNewSection(), readCoefficients(), readCoefficients(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), readPolynomial(), readSos(), swapTokenBuffer(), swapTokenBuffer(), swapTokenBuffer(), and swapTokenBuffer().
checks whether the current token is a section identifier, and if yes, switches to the corresponding section
| scip | SCIP data structure |
| lpinput | LP reading data |
Definition at line 464 of file reader_diff.c.
References assert(), c, FALSE, getNextToken(), isNewSection(), LP_END, LP_MAX_LINELEN, LP_OBJECTIVE, NULL, pushToken(), SCIP_Bool, SCIP_OBJSENSE_MAXIMIZE, SCIP_OBJSENSE_MINIMIZE, SCIPdebugMsg, swapTokenBuffer(), and TRUE.
Referenced by isNewSection(), isNewSection(), isNewSection(), readBinaries(), readBinaries(), readBounds(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), readGenerals(), readGenerals(), readPolynomial(), readSemicontinuous(), readSos(), readStart(), readStart(), and readStart().
returns whether the current token is a sign
| lpinput | LP reading data |
| sign | pointer to update the sign |
Definition at line 542 of file reader_diff.c.
References assert(), FALSE, isSign(), NULL, SCIP_Bool, and TRUE.
Referenced by createIndicatorConstraint(), isSign(), isSign(), isSign(), isSign(), readBounds(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficients(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraints(), readConstraints(), readConstraintsRational(), readPolynomial(), and readSos().
returns whether the current token is a value
| scip | SCIP data structure |
| lpinput | LP reading data |
| value | pointer to store the value (unchanged, if token is no value) |
Definition at line 567 of file reader_diff.c.
References assert(), FALSE, isValue(), NULL, SCIP_Bool, SCIP_Real, SCIPinfinity(), SCIPstrcasecmp(), and TRUE.
Referenced by applyVariableAssignment(), createConstantAssignment(), createIndicatorConstraint(), createLinking(), isValue(), isValue(), isValue(), isValue(), isValue(), isValueRational(), parseArrayIndex(), parseRange(), parseValue(), parseVariableArrayAssignment(), readBounds(), readBounds(), readCoefficients(), readCoefficients(), readCoefficients(), readConstraints(), readConstraints(), readConstraints(), readPolynomial(), and readSos().
returns whether the current token is an equation sense
| lpinput | LP reading data |
| sense | pointer to store the equation sense, or NULL |
Definition at line 599 of file reader_diff.c.
References assert(), FALSE, isSense(), LP_SENSE_EQ, LP_SENSE_GE, LP_SENSE_LE, NULL, SCIP_Bool, and TRUE.
Referenced by createIndicatorConstraint(), isSense(), isSense(), isSense(), isSense(), readBounds(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficients(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraints(), readConstraints(), readConstraintsRational(), and readPolynomial().
|
static |
returns the variable with the given name, or creates a new variable if it does not exist
| scip | SCIP data structure |
| name | name of the variable |
| var | pointer to store the variable |
Definition at line 630 of file reader_diff.c.
References assert(), getVariable(), NULL, SCIP_OKAY, SCIP_READERROR, SCIPfindVar(), and var.
|
static |
reads the header of the file
| scip | SCIP data structure |
| lpinput | LP reading data |
Definition at line 649 of file reader_diff.c.
References assert(), getNextToken(), isNewSection(), NULL, readStart(), and SCIP_OKAY.
Referenced by readDiffFile(), readLPFile(), readPIPFile(), readStart(), readStart(), and readStart().
|
static |
reads an objective or constraint with name and coefficients
| scip | SCIP data structure |
| lpinput | LP reading data |
| isobjective | indicates whether we are currently reading the coefficients of the objective |
| name | pointer to store the name of the line; must be at least of size LP_MAX_LINELEN |
| coefssize | size of vars and coefs arrays |
| vars | pointer to store the array with variables (must be freed by caller) |
| coefs | pointer to store the array with coefficients (must be freed by caller) |
| ncoefs | pointer to store the number of coefficients |
| newsection | pointer to store whether a new section was encountered |
Definition at line 670 of file reader_diff.c.
References assert(), FALSE, getNextToken(), getVariable(), isNewSection(), isSense(), isSign(), isValue(), LP_INIT_COEFSSIZE, LP_MAX_LINELEN, MAX, NULL, pushBufferToken(), pushToken(), readCoefficients(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_READERROR, SCIP_Real, SCIPallocBlockMemoryArray, SCIPdebugMsg, SCIPisZero(), SCIPmemccpy(), SCIPreallocBlockMemoryArray, SCIPvarGetName(), SCIPwarningMessage(), swapTokenBuffer(), syntaxError(), TRUE, var, and vars.
Referenced by createIndicatorConstraint(), readCoefficients(), readCoefficients(), readCoefficients(), readConstraints(), readConstraints(), readObjective(), and readObjective().
|
static |
reads the objective section
| scip | SCIP data structure |
| lpinput | LP reading data |
Definition at line 870 of file reader_diff.c.
References assert(), LP_MAX_LINELEN, NULL, readCoefficients(), readObjective(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPchgReoptObjective(), SCIPfreeBlockMemoryArrayNull, TRUE, and vars.
Referenced by readDiffFile(), readLPFile(), readObjective(), readObjective(), readObjective(), readObjective(), readPIPFile(), and SCIP_DECL_READERREAD().
|
static |
reads a diff file
| scip | SCIP data structure |
| lpinput | LP reading data |
| filename | name of the input file |
Definition at line 899 of file reader_diff.c.
References assert(), hasError(), LP_END, LP_OBJECTIVE, LP_START, NULL, readDiffFile(), readObjective(), readStart(), SCIP_CALL, SCIP_INVALIDDATA, SCIP_NOFILE, SCIP_OKAY, SCIP_STAGE_PROBLEM, SCIPerrorMessage, SCIPfclose(), SCIPfopen(), SCIPfreeReoptSolve(), SCIPfreeTransform(), SCIPgetStage(), SCIPisReoptEnabled(), and SCIPprintSysError().
Referenced by readDiffFile(), and SCIPreadDiff().
|
static |
copy method for reader plugins (called when SCIP copies plugins)
Definition at line 959 of file reader_diff.c.
References assert(), NULL, READER_NAME, SCIP_CALL, SCIP_DECL_READERCOPY, SCIP_INVALIDCALL, SCIP_OKAY, SCIP_STRINGEQ, SCIPincludeReaderDiff(), and SCIPreaderGetName().
|
static |
destructor of reader to free user data (called when SCIP is exiting)
Definition at line 974 of file reader_diff.c.
References SCIP_DECL_READERFREE, and SCIP_OKAY.
|
static |
problem reading method of reader
Definition at line 981 of file reader_diff.c.
References result, SCIP_CALL, SCIP_DECL_READERREAD, SCIP_OKAY, and SCIPreadDiff().
|
static |
Definition at line 111 of file reader_diff.c.
Referenced by getCommentLineData(), getNextLine(), getNextLine(), getNextLine(), getNextLine(), and getNextLine().