SCIP Doxygen Documentation
Loading...
Searching...
No Matches

Detailed Description

LP file reader.

Author
Tobias Achterberg
Marc Pfetsch
Stefan Heinz
Stefan Vigerske
Michael Winkler
Lars Schewe

Definition in file reader_lp.c.

#include "blockmemshell/memory.h"
#include <ctype.h>
#include "scip/cons_and.h"
#include "scip/cons_bounddisjunction.h"
#include "scip/cons_nonlinear.h"
#include "scip/cons_indicator.h"
#include "scip/cons_knapsack.h"
#include "scip/cons_linear.h"
#include "scip/cons_exactlinear.h"
#include "scip/cons_logicor.h"
#include "scip/cons_setppc.h"
#include "scip/cons_sos1.h"
#include "scip/cons_sos2.h"
#include "scip/cons_varbound.h"
#include "scip/pub_cons.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/rational.h"
#include "scip/reader_lp.h"
#include "scip/scip_cons.h"
#include "scip/scip_exact.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_numerics.h"
#include "scip/scip_param.h"
#include "scip/scip_prob.h"
#include "scip/scip_reader.h"
#include "scip/scip_var.h"
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Macros

#define READER_NAME   "lpreader"
#define READER_DESC   "file reader for MIPs in IBM CPLEX's LP file format"
#define READER_EXTENSION   "lp"
#define DEFAULT_LINEARIZE_ANDS   TRUE
#define DEFAULT_AGGRLINEARIZATION_ANDS   TRUE
#define LP_MAX_LINELEN   65536
#define LP_MAX_PUSHEDTOKENS   2
#define LP_INIT_COEFSSIZE   8192
#define LP_INIT_QUADCOEFSSIZE   16
#define LP_MAX_PRINTLEN   561
#define LP_MAX_NAMELEN   256
#define LP_PRINTLEN   100

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 isValueRational (SCIP *scip, LPINPUT *lpinput, SCIP_RATIONAL *value)
static SCIP_Bool isSense (LPINPUT *lpinput, LPSENSE *sense)
static SCIP_RETCODE getVariable (SCIP *scip, char *name, SCIP_VAR **var, SCIP_Bool *created)
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, int *quadcoefssize, SCIP_VAR ***quadvars1, SCIP_VAR ***quadvars2, SCIP_Real **quadcoefs, int *nquadcoefs, SCIP_Real *objoffset, SCIP_Bool *newsection)
static SCIP_RETCODE readCoefficientsRational (SCIP *scip, LPINPUT *lpinput, SCIP_Bool isobjective, char *name, int *coefssize, SCIP_VAR ***vars, SCIP_RATIONAL ***coefs, int *ncoefs, SCIP_RATIONAL *objoffset, SCIP_Bool *newsection)
static SCIP_RETCODE readObjectiveRational (SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readObjective (SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE createIndicatorConstraint (SCIP *scip, LPINPUT *lpinput, const char *name, SCIP_VAR *binvar, SCIP_Real binvalue)
static SCIP_RETCODE readConstraintsRational (SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readConstraints (SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readBoundsRational (SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readBounds (SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readGenerals (SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readBinaries (SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readSemicontinuous (SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readSos (SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readLPFile (SCIP *scip, LPINPUT *lpinput, const char *filename)
static SCIP_DECL_HASHGETKEY (hashGetKeyVar)
static SCIP_DECL_HASHKEYEQ (hashKeyEqVar)
static SCIP_DECL_HASHKEYVAL (hashKeyValVar)
static SCIP_RETCODE getActiveVariables (SCIP *scip, SCIP_VAR ***vars, SCIP_Real **scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
static void clearLine (char *linebuffer, int *linecnt)
static void endLine (SCIP *scip, FILE *file, char *linebuffer, int *linecnt)
static void appendLine (SCIP *scip, FILE *file, char *linebuffer, int *linecnt, const char *extension)
static SCIP_RETCODE printRow (SCIP *scip, FILE *file, const char *rowname, const char *rownameextension, const char *type, SCIP_VAR **linvars, SCIP_Real *linvals, int nlinvars, SCIP_EXPR *quadexpr, SCIP_Real rhs, SCIP_Bool transformed)
static SCIP_RETCODE printRowExact (SCIP *scip, FILE *file, const char *rowname, const char *rownameextension, const char *type, SCIP_VAR **linvars, SCIP_RATIONAL **linvals, int nlinvars, SCIP_RATIONAL *rhs)
static SCIP_RETCODE printQuadraticCons (SCIP *scip, FILE *file, const char *rowname, SCIP_VAR **linvars, SCIP_Real *linvals, int nlinvars, SCIP_EXPR *quadexpr, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool transformed)
static void printSosCons (SCIP *scip, FILE *file, const char *rowname, SCIP_VAR **vars, SCIP_Real *weights, int nvars, int type)
static SCIP_RETCODE printAndCons (SCIP *scip, FILE *file, const char *consname, SCIP_CONS *cons, SCIP_Bool aggrlinearizationands, SCIP_Bool transformed)
static SCIP_RETCODE collectAggregatedVars (SCIP *scip, SCIP_VAR **vars, int nvars, SCIP_VAR ***aggvars, int *naggvars, int *saggvars, SCIP_HASHTABLE *varAggregated)
static SCIP_RETCODE printAggregatedCons (SCIP *scip, FILE *file, SCIP_Bool transformed, int nvars, int nAggregatedVars, SCIP_VAR **aggregatedVars)
static void checkVarnames (SCIP *scip, SCIP_VAR **vars, int nvars)
static void checkConsnames (SCIP *scip, SCIP_CONS **conss, int nconss, SCIP_Bool transformed)
static SCIP_DECL_READERCOPY (readerCopyLp)
static SCIP_DECL_READERFREE (readerFreeLp)
static SCIP_DECL_READERREAD (readerReadLp)
static SCIP_DECL_READERWRITE (readerWriteLp)
SCIP_RETCODE SCIPincludeReaderLp (SCIP *scip)
SCIP_RETCODE SCIPreadLp (SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result)
SCIP_RETCODE SCIPwriteLp (SCIP *scip, FILE *file, const char *name, SCIP_Bool transformed, SCIP_OBJSENSE objsense, SCIP_Real objoffset, SCIP_Real objscale, SCIP_RATIONAL *objoffsetexact, SCIP_RATIONAL *objscaleexact, SCIP_VAR **vars, int nvars, int nbinvars, int nintvars, int nimplvars, int ncontvars, SCIP_CONS **conss, int nconss, SCIP_RESULT *result)

Variables

static const char commentchars [] = "\\"

Macro Definition Documentation

◆ READER_NAME

#define READER_NAME   "lpreader"

Definition at line 74 of file reader_lp.c.

◆ READER_DESC

#define READER_DESC   "file reader for MIPs in IBM CPLEX's LP file format"

Definition at line 75 of file reader_lp.c.

◆ READER_EXTENSION

#define READER_EXTENSION   "lp"

Definition at line 76 of file reader_lp.c.

◆ DEFAULT_LINEARIZE_ANDS

#define DEFAULT_LINEARIZE_ANDS   TRUE

Should possible "and"-constraints be linearized when writing the lp file?

Definition at line 78 of file reader_lp.c.

Referenced by SCIPincludeReaderLp(), SCIPincludeReaderMps(), and SCIPwriteLp().

◆ DEFAULT_AGGRLINEARIZATION_ANDS

#define DEFAULT_AGGRLINEARIZATION_ANDS   TRUE

Should an aggregated linearization for and constraints be used?

Definition at line 79 of file reader_lp.c.

Referenced by SCIPincludeReaderLp(), SCIPincludeReaderMps(), and SCIPwriteLp().

◆ LP_MAX_LINELEN

#define LP_MAX_LINELEN   65536

Definition at line 85 of file reader_lp.c.

◆ LP_MAX_PUSHEDTOKENS

#define LP_MAX_PUSHEDTOKENS   2

Definition at line 86 of file reader_lp.c.

◆ LP_INIT_COEFSSIZE

#define LP_INIT_COEFSSIZE   8192

Definition at line 87 of file reader_lp.c.

◆ LP_INIT_QUADCOEFSSIZE

#define LP_INIT_QUADCOEFSSIZE   16

Definition at line 88 of file reader_lp.c.

Referenced by readCoefficients().

◆ LP_MAX_PRINTLEN

#define LP_MAX_PRINTLEN   561

the maximum length of any line is 560 + '\0' = 561

Definition at line 89 of file reader_lp.c.

Referenced by appendLine(), endLine(), printRow(), printRowExact(), printSosCons(), and SCIPwriteLp().

◆ LP_MAX_NAMELEN

#define LP_MAX_NAMELEN   256

the maximum length for any name is 255 + '\0' = 256

Definition at line 90 of file reader_lp.c.

Referenced by checkConsnames(), checkVarnames(), printAggregatedCons(), printAndCons(), printRow(), printRowExact(), printSosCons(), and SCIPwriteLp().

◆ LP_PRINTLEN

#define LP_PRINTLEN   100

Definition at line 91 of file reader_lp.c.

Referenced by appendLine().

Enumeration Type Documentation

◆ LpSection

enum LpSection

Section in LP File

Enumerator
LP_START 
LP_OBJECTIVE 
LP_CONSTRAINTS 
LP_BOUNDS 
LP_GENERALS 
LP_BINARIES 
LP_SEMICONTINUOUS 
LP_SOS 
LP_END 

Definition at line 103 of file reader_lp.c.

◆ LpExpType

enum LpExpType
Enumerator
LP_EXP_NONE 
LP_EXP_UNSIGNED 
LP_EXP_SIGNED 

Definition at line 109 of file reader_lp.c.

◆ LpSense

enum LpSense
Enumerator
LP_SENSE_NOTHING 
LP_SENSE_LE 
LP_SENSE_GE 
LP_SENSE_EQ 

Definition at line 115 of file reader_lp.c.

Function Documentation

◆ syntaxError()

void syntaxError ( SCIP * scip,
LPINPUT * lpinput,
const char * msg )
static

issues an error message and marks the LP data to have errors

Parameters
scipSCIP data structure
lpinputLP reading data
msgerror message

Definition at line 156 of file reader_lp.c.

References assert(), LP_END, NULL, SCIP_VERBLEVEL_MINIMAL, SCIPerrorMessage, SCIPsnprintf(), SCIPverbMessage(), and TRUE.

Referenced by createIndicatorConstraint(), readBinaries(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), readGenerals(), readSemicontinuous(), and readSos().

◆ hasError()

SCIP_Bool hasError ( LPINPUT * lpinput)
static

returns whether a syntax error was detected

Parameters
lpinputLP reading data

Definition at line 183 of file reader_lp.c.

References assert(), NULL, and SCIP_Bool.

Referenced by createIndicatorConstraint(), readConstraints(), readConstraintsRational(), readObjective(), and readObjectiveRational().

◆ isDelimChar()

SCIP_Bool isDelimChar ( char c)
static

returns whether the given character is a token delimiter

Parameters
cinput character

Definition at line 194 of file reader_lp.c.

References c, FALSE, SCIP_Bool, and TRUE.

Referenced by getNextToken().

◆ isTokenChar()

SCIP_Bool isTokenChar ( char c)
static

returns whether the given character is a single token

Parameters
cinput character

Definition at line 215 of file reader_lp.c.

References c, FALSE, SCIP_Bool, and TRUE.

Referenced by getNextToken().

◆ isValueChar()

SCIP_Bool isValueChar ( char c,
char nextc,
SCIP_Bool firstchar,
SCIP_Bool * hasdot,
LPEXPTYPE * exptype )
static

returns whether the current character is member of a value string

Parameters
cinput character
nextcnext input character
firstcharis the given character the first char of the token?
hasdotpointer to update the dot flag
exptypepointer to update the exponent type

Definition at line 239 of file reader_lp.c.

References assert(), c, FALSE, LP_EXP_NONE, LP_EXP_SIGNED, LP_EXP_UNSIGNED, NULL, SCIP_Bool, and TRUE.

Referenced by getNextToken().

◆ getNextLine()

SCIP_Bool getNextLine ( SCIP * scip,
LPINPUT * lpinput )
static

reads the next line from the input file into the line buffer; skips comments; returns whether a line could be read

Parameters
scipSCIP data structure
lpinputLP reading data

Definition at line 293 of file reader_lp.c.

References assert(), BMSclearMemoryArray, commentchars, FALSE, i, NULL, SCIP_Bool, SCIP_CALL_ABORT, SCIPcalcMemGrowSize(), SCIPfgets(), SCIPreallocBlockMemoryArray, and TRUE.

Referenced by getNextToken().

◆ swapPointers()

void swapPointers ( char ** pointer1,
char ** pointer2 )
static

swaps the addresses of two pointers

Parameters
pointer1first pointer
pointer2second pointer

Definition at line 351 of file reader_lp.c.

Referenced by getNextToken(), pushBufferToken(), pushToken(), and swapTokenBuffer().

◆ getNextToken()

SCIP_Bool getNextToken ( SCIP * scip,
LPINPUT * lpinput )
static

reads the next token from the input file into the token buffer; returns whether a token was read

Parameters
scipSCIP data structure
lpinputLP reading data

Definition at line 365 of file reader_lp.c.

References assert(), FALSE, getNextLine(), isDelimChar(), isTokenChar(), isTokenChar(), isValueChar(), LP_END, LP_EXP_NONE, LP_MAX_LINELEN, NULL, SCIP_Bool, SCIPdebugMsg, swapPointers(), and TRUE.

Referenced by createIndicatorConstraint(), isNewSection(), readBinaries(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), readGenerals(), readSemicontinuous(), readSos(), and readStart().

◆ pushToken()

void pushToken ( LPINPUT * lpinput)
static

puts the current token on the token stack, such that it is read at the next call to getNextToken()

Parameters
lpinputLP reading data

Definition at line 472 of file reader_lp.c.

References assert(), LP_MAX_PUSHEDTOKENS, NULL, and swapPointers().

Referenced by isNewSection(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), readSemicontinuous(), and readSos().

◆ pushBufferToken()

void pushBufferToken ( LPINPUT * lpinput)
static

puts the buffered token on the token stack, such that it is read at the next call to getNextToken()

Parameters
lpinputLP reading data

Definition at line 485 of file reader_lp.c.

References assert(), LP_MAX_PUSHEDTOKENS, NULL, and swapPointers().

Referenced by readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), and readSos().

◆ swapTokenBuffer()

void swapTokenBuffer ( LPINPUT * lpinput)
static

swaps the current token with the token buffer

Parameters
lpinputLP reading data

Definition at line 498 of file reader_lp.c.

References assert(), NULL, and swapPointers().

Referenced by isNewSection(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), and readSos().

◆ isNewSection()

SCIP_Bool isNewSection ( SCIP * scip,
LPINPUT * lpinput )
static

◆ isSign()

SCIP_Bool isSign ( LPINPUT * lpinput,
int * sign )
static

returns whether the current token is a sign

Parameters
lpinputLP reading data
signpointer to update the sign

Definition at line 720 of file reader_lp.c.

References assert(), FALSE, NULL, SCIP_Bool, and TRUE.

Referenced by createIndicatorConstraint(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficientsRational(), readConstraints(), readConstraintsRational(), and readSos().

◆ isValue()

SCIP_Bool isValue ( SCIP * scip,
LPINPUT * lpinput,
SCIP_Real * value )
static

returns whether the current token is a value

Parameters
scipSCIP data structure
lpinputLP reading data
valuepointer to store the value (unchanged, if token is no value)

Definition at line 745 of file reader_lp.c.

References assert(), FALSE, NULL, SCIP_Bool, SCIP_Real, SCIPinfinity(), SCIPstrcasecmp(), and TRUE.

Referenced by createIndicatorConstraint(), isValueRational(), readBounds(), readCoefficients(), readConstraints(), and readSos().

◆ isValueRational()

SCIP_Bool isValueRational ( SCIP * scip,
LPINPUT * lpinput,
SCIP_RATIONAL * value )
static

returns whether the current token is a value

Parameters
scipSCIP data structure
lpinputLP reading data
valuepointer to store the value (unchanged, if token is no value)

Definition at line 777 of file reader_lp.c.

References assert(), FALSE, isValue(), NULL, SCIP_Bool, SCIPrationalIsString(), SCIPrationalSetInfinity(), SCIPrationalSetString(), SCIPstrcasecmp(), and TRUE.

Referenced by readBoundsRational(), readCoefficientsRational(), and readConstraintsRational().

◆ isSense()

SCIP_Bool isSense ( LPINPUT * lpinput,
LPSENSE * sense )
static

returns whether the current token is an equation sense

Parameters
lpinputLP reading data
sensepointer to store the equation sense, or NULL

Definition at line 807 of file reader_lp.c.

References assert(), FALSE, LP_SENSE_EQ, LP_SENSE_GE, LP_SENSE_LE, NULL, SCIP_Bool, and TRUE.

Referenced by createIndicatorConstraint(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficientsRational(), readConstraints(), and readConstraintsRational().

◆ getVariable()

SCIP_RETCODE getVariable ( SCIP * scip,
char * name,
SCIP_VAR ** var,
SCIP_Bool * created )
static

returns the variable with the given name, or creates a new variable if it does not exist

Parameters
scipSCIP data structure
namename of the variable
varpointer to store the variable
createdpointer to store whether a new variable was created, or NULL

Definition at line 838 of file reader_lp.c.

References assert(), FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_VARTYPE_CONTINUOUS, SCIPaddVar(), SCIPaddVarExactData(), SCIPcreateVar(), SCIPdebugMsg, SCIPfindVar(), SCIPgetBoolParam(), SCIPinfinity(), SCIPisExact(), SCIPreleaseVar(), TRUE, and var.

Referenced by readBinaries(), readBounds(), readBoundsRational(), readCoefficients(), readCoefficientsRational(), readGenerals(), and readSemicontinuous().

◆ readStart()

SCIP_RETCODE readStart ( SCIP * scip,
LPINPUT * lpinput )
static

reads the header of the file

Parameters
scipSCIP data structure
lpinputLP reading data

Definition at line 887 of file reader_lp.c.

References assert(), getNextToken(), isNewSection(), NULL, and SCIP_OKAY.

Referenced by readLPFile().

◆ readCoefficients()

SCIP_RETCODE readCoefficients ( SCIP * scip,
LPINPUT * lpinput,
SCIP_Bool isobjective,
char * name,
int * coefssize,
SCIP_VAR *** vars,
SCIP_Real ** coefs,
int * ncoefs,
int * quadcoefssize,
SCIP_VAR *** quadvars1,
SCIP_VAR *** quadvars2,
SCIP_Real ** quadcoefs,
int * nquadcoefs,
SCIP_Real * objoffset,
SCIP_Bool * newsection )
static

reads an objective or constraint with name and coefficients

Parameters
scipSCIP data structure
lpinputLP reading data
isobjectiveindicates whether we are currently reading the coefficients of the objective
namepointer to store the name of the line; must be at least of size LP_MAX_LINELEN
coefssizesize of vars and coefs arrays
varspointer to store the array with variables (must be freed by caller)
coefspointer to store the array with coefficients (must be freed by caller)
ncoefspointer to store the number of coefficients
quadcoefssizesize of quadvars1, quadvars2, quadcoefs arrays
quadvars1pointer to store the array with first variables in quadratic terms (must be freed by caller)
quadvars2pointer to store the array with second variables in quadratic terms (must be freed by caller)
quadcoefspointer to store the array with coefficients in quadratic terms (must be freed by caller)
nquadcoefspointer to store the number of quadratic coefficients
objoffsetpointer to store an objective offset (or NULL if ! isobjective)
newsectionpointer to store whether a new section was encountered

Definition at line 908 of file reader_lp.c.

References assert(), FALSE, getNextToken(), getVariable(), isNewSection(), isSense(), isSign(), isValue(), LP_INIT_COEFSSIZE, LP_INIT_QUADCOEFSSIZE, LP_MAX_LINELEN, MAX, NULL, pushBufferToken(), pushToken(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBlockMemoryArray, SCIPdebugMsg, SCIPisZero(), SCIPmemccpy(), SCIPreallocBlockMemoryArray, SCIPvarGetName(), SCIPwarningMessage(), swapTokenBuffer(), syntaxError(), TRUE, var, and vars.

Referenced by createIndicatorConstraint(), readConstraints(), and readObjective().

◆ readCoefficientsRational()

SCIP_RETCODE readCoefficientsRational ( SCIP * scip,
LPINPUT * lpinput,
SCIP_Bool isobjective,
char * name,
int * coefssize,
SCIP_VAR *** vars,
SCIP_RATIONAL *** coefs,
int * ncoefs,
SCIP_RATIONAL * objoffset,
SCIP_Bool * newsection )
static

reads an objective or constraint with name and coefficients

Parameters
scipSCIP data structure
lpinputLP reading data
isobjectiveindicates whether we are currently reading the coefficients of the objective
namepointer to store the name of the line; must be at least of size LP_MAX_LINELEN
coefssizesize of vars and coefs arrays
varspointer to store the array with variables (must be freed by caller)
coefspointer to store the array with coefficients (must be freed by caller)
ncoefspointer to store the number of coefficients
objoffsetpointer to store an objective offset (or NULL if ! isobjective)
newsectionpointer to store whether a new section was encountered

Definition at line 1329 of file reader_lp.c.

References assert(), FALSE, getNextToken(), getVariable(), isNewSection(), isSense(), isSign(), isValueRational(), LP_INIT_COEFSSIZE, LP_MAX_LINELEN, MAX, NULL, pushBufferToken(), pushToken(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemoryArray, SCIPblkmem(), SCIPbuffer(), SCIPdebugMsg, SCIPmemccpy(), SCIPrationalCreateBlockArray(), SCIPrationalCreateBuffer(), SCIPrationalFreeBuffer(), SCIPrationalGetReal(), SCIPrationalIsZero(), SCIPrationalMultReal(), SCIPrationalReallocBlockArray(), SCIPrationalSetReal(), SCIPreallocBlockMemoryArray, SCIPvarGetName(), SCIPwarningMessage(), swapTokenBuffer(), syntaxError(), TRUE, var, and vars.

Referenced by readConstraintsRational(), and readObjectiveRational().

◆ readObjectiveRational()

◆ readObjective()

◆ createIndicatorConstraint()

SCIP_RETCODE createIndicatorConstraint ( SCIP * scip,
LPINPUT * lpinput,
const char * name,
SCIP_VAR * binvar,
SCIP_Real binvalue )
static

◆ readConstraintsRational()

◆ readConstraints()

SCIP_RETCODE readConstraints ( SCIP * scip,
LPINPUT * lpinput )
static

reads the constraints section

Read linear and indicator constraints.

The CPLEX manual says that indicator constraints are of the following form:

[constraintname:] binaryvariable = value -> linear constraint

We also accept "<->".

Parameters
scipSCIP data structure
lpinputLP reading data

Definition at line 2215 of file reader_lp.c.

References assert(), createIndicatorConstraint(), FALSE, getNextToken(), hasError(), isNewSection(), isSense(), isSign(), isValue(), LP_MAX_LINELEN, LP_SENSE_EQ, LP_SENSE_GE, LP_SENSE_LE, LP_SENSE_NOTHING, NULL, propagate, pushBufferToken(), pushToken(), readCoefficients(), readConstraintsRational(), SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_Real, SCIPaddCons(), SCIPcreateConsLinear(), SCIPcreateConsQuadraticNonlinear(), SCIPdebugMsg, SCIPdebugPrintCons, SCIPerrorMessage, SCIPfreeBlockMemoryArrayNull, SCIPinfinity(), SCIPisEQ(), SCIPisExact(), SCIPreleaseCons(), SCIPsnprintf(), separate(), swapTokenBuffer(), syntaxError(), TRUE, and vars.

Referenced by readLPFile().

◆ readBoundsRational()

◆ readBounds()

◆ readGenerals()

SCIP_RETCODE readGenerals ( SCIP * scip,
LPINPUT * lpinput )
static

reads the generals section

Parameters
scipSCIP data structure
lpinputLP reading data

Definition at line 2821 of file reader_lp.c.

References assert(), getNextToken(), getVariable(), isNewSection(), NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_INTEGER, SCIPchgVarType(), SCIPisFeasIntegral(), SCIPvarGetLbGlobal(), SCIPvarGetName(), SCIPvarGetUbGlobal(), SCIPwarningMessage(), syntaxError(), and var.

Referenced by readLPFile().

◆ readBinaries()

◆ readSemicontinuous()

◆ readSos()

SCIP_RETCODE readSos ( SCIP * scip,
LPINPUT * lpinput )
static

reads the sos section

The format is as follows:

SOS <constraint name>: [S1|S2]:: {<variable name>:<weight>} ... <constraint name>: [S1|S2]:: {<variable name>:<weight>}

Parameters
scipSCIP data structure
lpinputLP reading data

Definition at line 3034 of file reader_lp.c.

References assert(), FALSE, getNextToken(), isNewSection(), isSign(), isValue(), NULL, propagate, pushBufferToken(), pushToken(), SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPABORT, SCIPaddCons(), SCIPaddVarSOS1(), SCIPaddVarSOS2(), SCIPconsGetName(), SCIPcreateConsSOS1(), SCIPcreateConsSOS2(), SCIPdebugMsg, SCIPdebugPrintCons, SCIPerrorMessage, SCIPfindVar(), SCIPmemccpy(), SCIPreleaseCons(), SCIPsnprintf(), SCIPvarGetName(), separate(), swapTokenBuffer(), syntaxError(), TRUE, and var.

Referenced by readLPFile().

◆ readLPFile()

SCIP_RETCODE readLPFile ( SCIP * scip,
LPINPUT * lpinput,
const char * filename )
static

◆ SCIP_DECL_HASHGETKEY()

SCIP_DECL_HASHGETKEY ( hashGetKeyVar )
static

hash key retrieval function for variables

Definition at line 3326 of file reader_lp.c.

◆ SCIP_DECL_HASHKEYEQ()

SCIP_DECL_HASHKEYEQ ( hashKeyEqVar )
static

returns TRUE iff the indices of both variables are equal

Definition at line 3333 of file reader_lp.c.

References FALSE, and TRUE.

◆ SCIP_DECL_HASHKEYVAL()

SCIP_DECL_HASHKEYVAL ( hashKeyValVar )
static

returns the hash value of the key

Definition at line 3342 of file reader_lp.c.

References assert(), and SCIPvarGetIndex().

◆ getActiveVariables()

SCIP_RETCODE getActiveVariables ( SCIP * scip,
SCIP_VAR *** vars,
SCIP_Real ** scalars,
int * nvars,
SCIP_Real * constant,
SCIP_Bool transformed )
static

transforms given variables, scalars, and constant to the corresponding active variables, scalars, and constant

Parameters
scipSCIP data structure
varspointer to vars array to get active variables for
scalarspointer to scalars a_1, ..., a_n in linear sum a_1*x_1 + ... + a_n*x_n + c
nvarspointer to number of variables and values in vars and vals array
constantpointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c
transformedtransformed constraint?

Definition at line 3350 of file reader_lp.c.

References assert(), NULL, nvars, scalars, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_Real, SCIP_VARSTATUS_NEGATED, SCIPABORT, SCIPerrorMessage, SCIPgetProbvarLinearSum(), SCIPreallocBufferArray, SCIPvarGetNegatedVar(), SCIPvarGetOrigvarSum(), SCIPvarGetStatus(), and vars.

Referenced by printAggregatedCons(), printQuadraticCons(), and printRow().

◆ clearLine()

void clearLine ( char * linebuffer,
int * linecnt )
static

clears the given line buffer

Parameters
linebufferline
linecntnumber of characters in line

Definition at line 3412 of file reader_lp.c.

References assert(), and NULL.

Referenced by endLine(), printRow(), printRowExact(), printSosCons(), and SCIPwriteLp().

◆ endLine()

void endLine ( SCIP * scip,
FILE * file,
char * linebuffer,
int * linecnt )
static

ends the given line with '\0' and prints it to the given file stream

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
linebufferline
linecntnumber of characters in line

Definition at line 3426 of file reader_lp.c.

References assert(), clearLine(), LP_MAX_PRINTLEN, NULL, and SCIPinfoMessage().

Referenced by appendLine(), printRow(), printRowExact(), printSosCons(), and SCIPwriteLp().

◆ appendLine()

void appendLine ( SCIP * scip,
FILE * file,
char * linebuffer,
int * linecnt,
const char * extension )
static

appends extension to line and prints it to the give file stream if the line exceeded the length given in the define LP_PRINTLEN

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
linebufferline
linecntnumber of characters in line
extensionstring to extent the line

Definition at line 3449 of file reader_lp.c.

References assert(), endLine(), LP_MAX_PRINTLEN, LP_PRINTLEN, NULL, and SCIPdebugMsg.

Referenced by printRow(), printRowExact(), printSosCons(), and SCIPwriteLp().

◆ printRow()

SCIP_RETCODE printRow ( SCIP * scip,
FILE * file,
const char * rowname,
const char * rownameextension,
const char * type,
SCIP_VAR ** linvars,
SCIP_Real * linvals,
int nlinvars,
SCIP_EXPR * quadexpr,
SCIP_Real rhs,
SCIP_Bool transformed )
static
Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
rownamerow name
rownameextensionrow name extension
typerow type ("=", "<=", or ">=")
linvarsarray of linear variables
linvalsarray of linear coefficient values
nlinvarsnumber of linear variables
quadexprquadratic expression
rhsright hand side
transformedtransformed constraint?

Definition at line 3479 of file reader_lp.c.

References appendLine(), assert(), clearLine(), endLine(), getActiveVariables(), LP_MAX_NAMELEN, LP_MAX_PRINTLEN, NULL, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, SCIPerrorMessage, SCIPexprGetQuadraticBilinTerm(), SCIPexprGetQuadraticData(), SCIPexprGetQuadraticQuadTerm(), SCIPfreeBufferArray, SCIPgetVarExprVar(), SCIPisExprVar(), SCIPisInfinity(), SCIPsnprintf(), SCIPvarGetName(), and var.

Referenced by printAggregatedCons(), and printQuadraticCons().

◆ printRowExact()

SCIP_RETCODE printRowExact ( SCIP * scip,
FILE * file,
const char * rowname,
const char * rownameextension,
const char * type,
SCIP_VAR ** linvars,
SCIP_RATIONAL ** linvals,
int nlinvars,
SCIP_RATIONAL * rhs )
static
Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
rownamerow name
rownameextensionrow name extension
typerow type ("=", "<=", or ">=")
linvarsarray of linear variables
linvalsarray of linear coefficient values
nlinvarsnumber of linear variables
rhsright hand side

Definition at line 3774 of file reader_lp.c.

References appendLine(), assert(), clearLine(), endLine(), LP_MAX_NAMELEN, LP_MAX_PRINTLEN, NULL, SCIP_INVALIDDATA, SCIP_OKAY, SCIPerrorMessage, SCIPrationalIsNegative(), SCIPrationalToString(), SCIPsnprintf(), SCIPvarGetName(), and var.

Referenced by SCIPwriteLp().

◆ printQuadraticCons()

SCIP_RETCODE printQuadraticCons ( SCIP * scip,
FILE * file,
const char * rowname,
SCIP_VAR ** linvars,
SCIP_Real * linvals,
int nlinvars,
SCIP_EXPR * quadexpr,
SCIP_Real lhs,
SCIP_Real rhs,
SCIP_Bool transformed )
static

prints given (linear or) quadratic constraint information in LP format to file stream

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
rownamename of the row
linvarsarray of linear variables
linvalsarray of linear coefficients values (or NULL if all linear coefficient values are 1)
nlinvarsnumber of linear variables
quadexprquadratic expression (or NULL if nlinvars > 0)
lhsleft hand side
rhsright hand side
transformedtransformed constraint?

Definition at line 3884 of file reader_lp.c.

References assert(), getActiveVariables(), NULL, printRow(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, SCIPfreeBufferArray, SCIPisEQ(), and SCIPisInfinity().

Referenced by printAndCons(), and SCIPwriteLp().

◆ printSosCons()

void printSosCons ( SCIP * scip,
FILE * file,
const char * rowname,
SCIP_VAR ** vars,
SCIP_Real * weights,
int nvars,
int type )
static

prints given SOS constraint information in LP format to file stream

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
rownamename of the row
varsarray of variables
weightsarray of weight values (or NULL)
nvarsnumber of variables
typeSOS type (SOS1 or SOS2)

Definition at line 3972 of file reader_lp.c.

References appendLine(), assert(), clearLine(), endLine(), LP_MAX_NAMELEN, LP_MAX_PRINTLEN, NULL, nvars, SCIP_Real, SCIPsnprintf(), SCIPvarGetName(), and vars.

Referenced by SCIPwriteLp().

◆ printAndCons()

SCIP_RETCODE printAndCons ( SCIP * scip,
FILE * file,
const char * consname,
SCIP_CONS * cons,
SCIP_Bool aggrlinearizationands,
SCIP_Bool transformed )
static

prints a linearization of an and-constraint into the given file

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
consnamename of the constraint
consand constraint
aggrlinearizationandsprint weak or strong realaxation
transformedtransformed constraint?

Definition at line 4031 of file reader_lp.c.

References assert(), LP_MAX_NAMELEN, NULL, nvars, printQuadraticCons(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPgetNVarsAnd(), SCIPgetResultantAnd(), SCIPgetVarsAnd(), SCIPinfinity(), SCIPsnprintf(), and vars.

Referenced by SCIPwriteLp().

◆ collectAggregatedVars()

SCIP_RETCODE collectAggregatedVars ( SCIP * scip,
SCIP_VAR ** vars,
int nvars,
SCIP_VAR *** aggvars,
int * naggvars,
int * saggvars,
SCIP_HASHTABLE * varAggregated )
static

check whether given variables are aggregated and put them into an array without duplication

Parameters
scipSCIP data structure
varsvariable array
nvarsnumber of active variables in the problem
aggvarspointer to array storing the aggregated variables on output
naggvarspointer to number of aggregated variables on output
saggvarspointer to number of slots in aggvars array
varAggregatedhashtable for checking duplicates

Definition at line 4118 of file reader_lp.c.

References assert(), NULL, nvars, SCIP_CALL, SCIP_OKAY, SCIP_VARSTATUS_AGGREGATED, SCIP_VARSTATUS_MULTAGGR, SCIP_VARSTATUS_NEGATED, SCIPcalcMemGrowSize(), SCIPhashtableExists(), SCIPhashtableInsert(), SCIPreallocBlockMemoryArray, SCIPvarGetStatus(), var, and vars.

Referenced by SCIPwriteLp().

◆ printAggregatedCons()

SCIP_RETCODE printAggregatedCons ( SCIP * scip,
FILE * file,
SCIP_Bool transformed,
int nvars,
int nAggregatedVars,
SCIP_VAR ** aggregatedVars )
static

print aggregated variable-constraints

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
transformedTRUE iff problem is the transformed problem
nvarsnumber of active variables in the problem
nAggregatedVarsnumber of aggregated variables
aggregatedVarsarray storing the aggregated variables

Definition at line 4174 of file reader_lp.c.

References assert(), getActiveVariables(), LP_MAX_NAMELEN, NULL, nvars, printRow(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPsnprintf(), and SCIPvarGetName().

Referenced by SCIPwriteLp().

◆ checkVarnames()

void checkVarnames ( SCIP * scip,
SCIP_VAR ** vars,
int nvars )
static

method check if the variable names are not longer than LP_MAX_NAMELEN

Parameters
scipSCIP data structure
varsarray of variables
nvarsnumber of variables

Definition at line 4228 of file reader_lp.c.

References assert(), FALSE, LP_MAX_NAMELEN, NULL, nvars, SCIP_Bool, SCIPvarGetName(), SCIPwarningMessage(), TRUE, and vars.

Referenced by SCIPwriteLp().

◆ checkConsnames()

void checkConsnames ( SCIP * scip,
SCIP_CONS ** conss,
int nconss,
SCIP_Bool transformed )
static

method check if the constraint names are not longer than LP_MAX_NAMELEN

Parameters
scipSCIP data structure
conssarray of constraints
nconssnumber of constraints
transformedTRUE iff problem is the transformed problem

Definition at line 4265 of file reader_lp.c.

References assert(), c, FALSE, LP_MAX_NAMELEN, NULL, SCIP_Bool, SCIP_Real, SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetName(), SCIPconsIsEnabled(), SCIPconsIsTransformed(), SCIPgetLhsLinear(), SCIPgetRhsLinear(), SCIPisEQ(), SCIPwarningMessage(), and TRUE.

Referenced by SCIPwriteLp().

◆ SCIP_DECL_READERCOPY()

SCIP_DECL_READERCOPY ( readerCopyLp )
static

copy method for reader plugins (called when SCIP copies plugins)

Definition at line 4334 of file reader_lp.c.

References assert(), NULL, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludeReaderLp(), and SCIPreaderGetName().

◆ SCIP_DECL_READERFREE()

SCIP_DECL_READERFREE ( readerFreeLp )
static

destructor of reader to free user data (called when SCIP is exiting)

Definition at line 4348 of file reader_lp.c.

References assert(), NULL, READER_NAME, SCIP_OKAY, SCIPfreeBlockMemory, SCIPreaderGetData(), and SCIPreaderGetName().

◆ SCIP_DECL_READERREAD()

SCIP_DECL_READERREAD ( readerReadLp )
static

problem reading method of reader

Definition at line 4362 of file reader_lp.c.

References result, SCIP_CALL, SCIP_OKAY, and SCIPreadLp().

◆ SCIP_DECL_READERWRITE()

SCIP_DECL_READERWRITE ( readerWriteLp )
static

problem writing method of reader

Definition at line 4373 of file reader_lp.c.

References assert(), NULL, nvars, objscale, READER_NAME, result, SCIP_CALL, SCIP_OKAY, SCIPreaderGetName(), SCIPwriteLp(), and vars.

Variable Documentation

◆ commentchars

const char commentchars[] = "\\"
static

Definition at line 147 of file reader_lp.c.