Scippy

SCIP

Solving Constraint Integer Programs

Detailed Description

file reader for polynomial mixed-integer programs in PIP format

Author
Stefan Vigerske
Marc Pfetsch

Definition in file reader_pip.c.

#include "blockmemshell/memory.h"
#include <ctype.h>
#include "nlpi/pub_expr.h"
#include "scip/cons_abspower.h"
#include "scip/cons_and.h"
#include "scip/cons_bivariate.h"
#include "scip/cons_knapsack.h"
#include "scip/cons_linear.h"
#include "scip/cons_logicor.h"
#include "scip/cons_nonlinear.h"
#include "scip/cons_quadratic.h"
#include "scip/cons_setppc.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_nlp.h"
#include "scip/pub_reader.h"
#include "scip/pub_var.h"
#include "scip/reader_pip.h"
#include "scip/scip_cons.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>
#include <strings.h>

Go to the source code of this file.

Macros

#define READER_NAME   "pipreader"
 
#define READER_DESC   "file reader for polynomial mixed-integer programs in PIP format"
 
#define READER_EXTENSION   "pip"
 
#define PIP_MAX_LINELEN   65536
 
#define PIP_MAX_PUSHEDTOKENS   2
 
#define PIP_INIT_VARSSIZE   256
 
#define PIP_INIT_MONOMIALSSIZE   128
 
#define PIP_INIT_FACTORSSIZE   16
 
#define PIP_MAX_PRINTLEN   561
 
#define PIP_MAX_NAMELEN   256
 
#define PIP_PRINTLEN   100
 

Typedefs

typedef enum PipSection PIPSECTION
 
typedef enum PipExpType PIPEXPTYPE
 
typedef enum PipSense PIPSENSE
 
typedef struct PipInput PIPINPUT
 

Enumerations

enum  PipSection {
  PIP_START,
  PIP_OBJECTIVE,
  PIP_CONSTRAINTS,
  PIP_BOUNDS,
  PIP_GENERALS,
  PIP_BINARIES,
  PIP_END
}
 
enum  PipExpType {
  PIP_EXP_NONE,
  PIP_EXP_UNSIGNED,
  PIP_EXP_SIGNED
}
 
enum  PipSense {
  PIP_SENSE_NOTHING,
  PIP_SENSE_LE,
  PIP_SENSE_GE,
  PIP_SENSE_EQ
}
 

Functions

static void syntaxError (SCIP *scip, PIPINPUT *pipinput, const char *msg)
 
static SCIP_Bool hasError (PIPINPUT *pipinput)
 
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, PIPEXPTYPE *exptype)
 
static SCIP_Bool getNextLine (SCIP *scip, PIPINPUT *pipinput)
 
static void swapPointers (char **pointer1, char **pointer2)
 
static SCIP_Bool getNextToken (SCIP *scip, PIPINPUT *pipinput)
 
static void pushToken (PIPINPUT *pipinput)
 
static void pushBufferToken (PIPINPUT *pipinput)
 
static void swapTokenBuffer (PIPINPUT *pipinput)
 
static SCIP_Bool isNewSection (SCIP *scip, PIPINPUT *pipinput)
 
static SCIP_Bool isSign (PIPINPUT *pipinput, int *sign)
 
static SCIP_Bool isValue (SCIP *scip, PIPINPUT *pipinput, SCIP_Real *value)
 
static SCIP_Bool isSense (PIPINPUT *pipinput, PIPSENSE *sense)
 
static SCIP_RETCODE getVariable (SCIP *scip, char *name, SCIP_Bool dynamiccols, SCIP_VAR **var, SCIP_Bool *created)
 
static SCIP_RETCODE readStart (SCIP *scip, PIPINPUT *pipinput)
 
static SCIP_RETCODE ensureMonomialsSize (SCIP *scip, SCIP_EXPRDATA_MONOMIAL ***monomials, int *monomialssize, int minnmonomials)
 
static SCIP_RETCODE ensureFactorsSize (SCIP *scip, SCIP_Real **exponents, int **varidxs, int *factorssize, int minnfactors)
 
static SCIP_RETCODE getVariableIndex (SCIP *scip, SCIP_VAR ***vars, int *varssize, int *nvars, SCIP_HASHMAP *varhash, SCIP_VAR *var, int *varidx)
 
static SCIP_RETCODE readPolynomial (SCIP *scip, PIPINPUT *pipinput, char *name, SCIP_EXPRTREE **exprtree, int *degree, SCIP_Bool *newsection)
 
static void getLinearAndQuadraticCoefs (SCIP_EXPRTREE *exprtree, SCIP_Real *constant, int *nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int *nquadterms, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoefs)
 
static SCIP_RETCODE readObjective (SCIP *scip, PIPINPUT *pipinput)
 
static SCIP_RETCODE readConstraints (SCIP *scip, PIPINPUT *pipinput)
 
static SCIP_RETCODE readBounds (SCIP *scip, PIPINPUT *pipinput)
 
static SCIP_RETCODE readGenerals (SCIP *scip, PIPINPUT *pipinput)
 
static SCIP_RETCODE readBinaries (SCIP *scip, PIPINPUT *pipinput)
 
static SCIP_RETCODE readPIPFile (SCIP *scip, PIPINPUT *pipinput, 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 void printRow (SCIP *scip, FILE *file, const char *rowname, const char *rownameextension, const char *type, SCIP_VAR **linvars, SCIP_Real *linvals, int nlinvars, SCIP_QUADVARTERM *quadvarterms, int nquadvarterms, SCIP_BILINTERM *bilinterms, int nbilinterms, SCIP_Real rhs)
 
static void printRowNl (SCIP *scip, FILE *file, const char *rowname, const char *rownameextension, const char *type, SCIP_VAR **linvars, SCIP_Real *linvals, int nlinvars, SCIP_EXPRTREE **exprtrees, SCIP_Real *exprtreecoefs, int nexprtrees, SCIP_Real rhs)
 
static SCIP_RETCODE printQuadraticCons (SCIP *scip, FILE *file, const char *rowname, SCIP_VAR **linvars, SCIP_Real *linvals, int nlinvars, SCIP_QUADVARTERM *quadvarterms, int nquadvarterms, SCIP_BILINTERM *bilinterms, int nbilinterms, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool transformed)
 
static SCIP_RETCODE printNonlinearCons (SCIP *scip, FILE *file, const char *rowname, SCIP_VAR **linvars, SCIP_Real *linvals, int nlinvars, SCIP_EXPRTREE **exprtrees, SCIP_Real *exprtreecoefs, int nexprtrees, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool transformed)
 
static SCIP_RETCODE collectAggregatedVars (int nvars, SCIP_VAR **vars, int *nAggregatedVars, SCIP_VAR ***aggregatedVars, SCIP_HASHTABLE **varAggregated)
 
static SCIP_RETCODE printAggregatedCons (SCIP *scip, FILE *file, SCIP_Bool transformed, int nvars, int nAggregatedVars, SCIP_VAR **aggregatedVars)
 
static SCIP_Bool isNameValid (const char *name)
 
static void checkVarnames (SCIP *scip, SCIP_VAR **vars, int nvars)
 
static void checkConsnames (SCIP *scip, SCIP_CONS **conss, int nconss, SCIP_Bool transformed)
 
SCIP_RETCODE SCIPwritePip (SCIP *scip, FILE *file, const char *name, SCIP_Bool transformed, SCIP_OBJSENSE objsense, SCIP_Real objscale, SCIP_Real objoffset, SCIP_VAR **vars, int nvars, int nbinvars, int nintvars, int nimplvars, int ncontvars, SCIP_CONS **conss, int nconss, SCIP_RESULT *result)
 
static SCIP_DECL_READERCOPY (readerCopyPip)
 
static SCIP_DECL_READERREAD (readerReadPip)
 
static SCIP_DECL_READERWRITE (readerWritePip)
 
SCIP_RETCODE SCIPincludeReaderPip (SCIP *scip)
 
SCIP_RETCODE SCIPreadPip (SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result)
 

Variables

static const char delimchars [] = " \f\n\r\t\v"
 
static const char tokenchars [] = "-+:<>=*^"
 
static const char commentchars [] = "\\"
 
static const char namechars [] = "!#$%&;?@_"
 

Macro Definition Documentation

◆ READER_NAME

#define READER_NAME   "pipreader"

Definition at line 62 of file reader_pip.c.

Referenced by SCIP_DECL_READERCOPY(), and SCIPincludeReaderPip().

◆ READER_DESC

#define READER_DESC   "file reader for polynomial mixed-integer programs in PIP format"

Definition at line 63 of file reader_pip.c.

Referenced by SCIPincludeReaderPip().

◆ READER_EXTENSION

#define READER_EXTENSION   "pip"

Definition at line 64 of file reader_pip.c.

Referenced by SCIPincludeReaderPip().

◆ PIP_MAX_LINELEN

#define PIP_MAX_LINELEN   65536

◆ PIP_MAX_PUSHEDTOKENS

#define PIP_MAX_PUSHEDTOKENS   2

Definition at line 71 of file reader_pip.c.

Referenced by pushBufferToken(), pushToken(), and SCIPreadPip().

◆ PIP_INIT_VARSSIZE

#define PIP_INIT_VARSSIZE   256

Definition at line 72 of file reader_pip.c.

Referenced by readPolynomial().

◆ PIP_INIT_MONOMIALSSIZE

#define PIP_INIT_MONOMIALSSIZE   128

Definition at line 73 of file reader_pip.c.

Referenced by readPolynomial().

◆ PIP_INIT_FACTORSSIZE

#define PIP_INIT_FACTORSSIZE   16

Definition at line 74 of file reader_pip.c.

Referenced by readPolynomial().

◆ PIP_MAX_PRINTLEN

#define PIP_MAX_PRINTLEN   561

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

Definition at line 75 of file reader_pip.c.

Referenced by appendLine(), endLine(), printRow(), printRowNl(), and SCIPwritePip().

◆ PIP_MAX_NAMELEN

#define PIP_MAX_NAMELEN   256

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

Definition at line 76 of file reader_pip.c.

Referenced by checkConsnames(), isNameValid(), printAggregatedCons(), printRow(), printRowNl(), and SCIPwritePip().

◆ PIP_PRINTLEN

#define PIP_PRINTLEN   100

Definition at line 77 of file reader_pip.c.

Referenced by appendLine().

Typedef Documentation

◆ PIPSECTION

typedef enum PipSection PIPSECTION

Definition at line 90 of file reader_pip.c.

◆ PIPEXPTYPE

typedef enum PipExpType PIPEXPTYPE

Definition at line 98 of file reader_pip.c.

◆ PIPSENSE

typedef enum PipSense PIPSENSE

Definition at line 107 of file reader_pip.c.

◆ PIPINPUT

typedef struct PipInput PIPINPUT

Definition at line 130 of file reader_pip.c.

Enumeration Type Documentation

◆ PipSection

enum PipSection

Section in PIP File

Enumerator
PIP_START 
PIP_OBJECTIVE 
PIP_CONSTRAINTS 
PIP_BOUNDS 
PIP_GENERALS 
PIP_BINARIES 
PIP_END 

Definition at line 80 of file reader_pip.c.

◆ PipExpType

enum PipExpType
Enumerator
PIP_EXP_NONE 
PIP_EXP_UNSIGNED 
PIP_EXP_SIGNED 

Definition at line 92 of file reader_pip.c.

◆ PipSense

enum PipSense
Enumerator
PIP_SENSE_NOTHING 
PIP_SENSE_LE 
PIP_SENSE_GE 
PIP_SENSE_EQ 

Definition at line 100 of file reader_pip.c.

Function Documentation

◆ syntaxError()

static void syntaxError ( SCIP scip,
PIPINPUT pipinput,
const char *  msg 
)
static

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

Parameters
scipSCIP data structure
pipinputPIP reading data
msgerror message

Definition at line 144 of file reader_pip.c.

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

Referenced by readBinaries(), readBounds(), readConstraints(), readGenerals(), and readPolynomial().

◆ hasError()

static SCIP_Bool hasError ( PIPINPUT pipinput)
static

returns whether a syntax error was detected

Parameters
pipinputPIP reading data

Definition at line 171 of file reader_pip.c.

References NULL.

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

◆ isDelimChar()

static SCIP_Bool isDelimChar ( char  c)
static

returns whether the given character is a token delimiter

Parameters
cinput character

Definition at line 182 of file reader_pip.c.

References delimchars, and NULL.

Referenced by getNextToken().

◆ isTokenChar()

static SCIP_Bool isTokenChar ( char  c)
static

returns whether the given character is a single token

Parameters
cinput character

Definition at line 191 of file reader_pip.c.

References NULL, and tokenchars.

Referenced by getNextToken().

◆ isValueChar()

static SCIP_Bool isValueChar ( char  c,
char  nextc,
SCIP_Bool  firstchar,
SCIP_Bool hasdot,
PIPEXPTYPE 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 200 of file reader_pip.c.

References FALSE, NULL, PIP_EXP_NONE, PIP_EXP_SIGNED, PIP_EXP_UNSIGNED, and TRUE.

Referenced by getNextToken().

◆ getNextLine()

static SCIP_Bool getNextLine ( SCIP scip,
PIPINPUT pipinput 
)
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
pipinputPIP reading data

Definition at line 244 of file reader_pip.c.

References BMSclearMemoryArray, commentchars, FALSE, NULL, PIP_MAX_LINELEN, SCIPerrorMessage, SCIPfgets(), and TRUE.

Referenced by getNextToken().

◆ swapPointers()

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

swaps the addresses of two pointers

Parameters
pointer1first pointer
pointer2second pointer

Definition at line 289 of file reader_pip.c.

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

◆ getNextToken()

static SCIP_Bool getNextToken ( SCIP scip,
PIPINPUT pipinput 
)
static

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

Parameters
scipSCIP data structure
pipinputPIP reading data

Definition at line 303 of file reader_pip.c.

References FALSE, getNextLine(), isDelimChar(), isTokenChar(), isValueChar(), NULL, PIP_END, PIP_EXP_NONE, PIP_MAX_LINELEN, SCIP_Bool, SCIPdebugMsg, swapPointers(), and TRUE.

Referenced by isNewSection(), readBinaries(), readBounds(), readConstraints(), readGenerals(), readPolynomial(), and readStart().

◆ pushToken()

static void pushToken ( PIPINPUT pipinput)
static

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

Parameters
pipinputPIP reading data

Definition at line 402 of file reader_pip.c.

References NULL, PIP_MAX_PUSHEDTOKENS, and swapPointers().

Referenced by isNewSection(), readBounds(), and readPolynomial().

◆ pushBufferToken()

static void pushBufferToken ( PIPINPUT pipinput)
static

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

Parameters
pipinputPIP reading data

Definition at line 415 of file reader_pip.c.

References NULL, PIP_MAX_PUSHEDTOKENS, and swapPointers().

Referenced by readPolynomial().

◆ swapTokenBuffer()

static void swapTokenBuffer ( PIPINPUT pipinput)
static

swaps the current token with the token buffer

Parameters
pipinputPIP reading data

Definition at line 428 of file reader_pip.c.

References NULL, and swapPointers().

Referenced by isNewSection(), and readPolynomial().

◆ isNewSection()

static SCIP_Bool isNewSection ( SCIP scip,
PIPINPUT pipinput 
)
static

checks whether the current token is a section identifier, and if yes, switches to the corresponding section

Parameters
scipSCIP data structure
pipinputPIP reading data

Definition at line 439 of file reader_pip.c.

References FALSE, getNextToken(), NULL, PIP_BINARIES, PIP_BOUNDS, PIP_CONSTRAINTS, PIP_END, PIP_GENERALS, PIP_OBJECTIVE, pushToken(), SCIP_Bool, SCIP_OBJSENSE_MAXIMIZE, SCIP_OBJSENSE_MINIMIZE, SCIPdebugMsg, swapTokenBuffer(), and TRUE.

Referenced by readBinaries(), readBounds(), readGenerals(), readPolynomial(), and readStart().

◆ isSign()

static SCIP_Bool isSign ( PIPINPUT pipinput,
int *  sign 
)
static

returns whether the current token is a sign

Parameters
pipinputPIP reading data
signpointer to update the sign

Definition at line 572 of file reader_pip.c.

References FALSE, NULL, and TRUE.

Referenced by readBounds(), readConstraints(), and readPolynomial().

◆ isValue()

static SCIP_Bool isValue ( SCIP scip,
PIPINPUT pipinput,
SCIP_Real value 
)
static

returns whether the current token is a value

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

Definition at line 597 of file reader_pip.c.

References FALSE, NULL, SCIPinfinity(), and TRUE.

Referenced by readBounds(), readConstraints(), and readPolynomial().

◆ isSense()

static SCIP_Bool isSense ( PIPINPUT pipinput,
PIPSENSE sense 
)
static

returns whether the current token is an equation sense

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

Definition at line 629 of file reader_pip.c.

References FALSE, NULL, PIP_SENSE_EQ, PIP_SENSE_GE, PIP_SENSE_LE, and TRUE.

Referenced by readBounds(), readConstraints(), and readPolynomial().

◆ getVariable()

static SCIP_RETCODE getVariable ( SCIP scip,
char *  name,
SCIP_Bool  dynamiccols,
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
dynamiccolsshould columns be added and removed dynamically to the LP?
varpointer to store the variable
createdpointer to store whether a new variable was created, or NULL

Definition at line 660 of file reader_pip.c.

References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIP_VARTYPE_CONTINUOUS, SCIPaddVar(), SCIPcreateVar(), SCIPdebugMsg, SCIPfindVar(), SCIPinfinity(), SCIPreleaseVar(), and TRUE.

Referenced by readBinaries(), readBounds(), readGenerals(), and readPolynomial().

◆ readStart()

static SCIP_RETCODE readStart ( SCIP scip,
PIPINPUT pipinput 
)
static

reads the header of the file

Parameters
scipSCIP data structure
pipinputPIP reading data

Definition at line 699 of file reader_pip.c.

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

Referenced by readPIPFile().

◆ ensureMonomialsSize()

static SCIP_RETCODE ensureMonomialsSize ( SCIP scip,
SCIP_EXPRDATA_MONOMIAL ***  monomials,
int *  monomialssize,
int  minnmonomials 
)
static

ensure that an array of monomials can hold a minimum number of entries

Parameters
scipSCIP data structure
monomialspointer to current array of monomials
monomialssizecurrent size of monomials array at input; new size at exit
minnmonomialsrequired minimal size of monomials array

Definition at line 720 of file reader_pip.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, SCIPcalcMemGrowSize(), and SCIPreallocBufferArray.

Referenced by readPolynomial().

◆ ensureFactorsSize()

static SCIP_RETCODE ensureFactorsSize ( SCIP scip,
SCIP_Real **  exponents,
int **  varidxs,
int *  factorssize,
int  minnfactors 
)
static

ensure that arrays of exponents and variable indices can hold a minimum number of entries

Parameters
scipSCIP data structure
exponentspointer to current array of exponents
varidxspointer to current array of variable indices
factorssizecurrent size of arrays at input; new size at exit
minnfactorsrequired minimal size of arrays

Definition at line 754 of file reader_pip.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, SCIPcalcMemGrowSize(), and SCIPreallocBufferArray.

Referenced by readPolynomial().

◆ getVariableIndex()

static SCIP_RETCODE getVariableIndex ( SCIP scip,
SCIP_VAR ***  vars,
int *  varssize,
int *  nvars,
SCIP_HASHMAP varhash,
SCIP_VAR var,
int *  varidx 
)
static

gives index of variable in vars array, inserts it at the end if not existing yet

Parameters
scipSCIP data structure
varspointer to current array of variables
varssizecurrent size of variables array at input; new size at exit
nvarsnumber of variables stored in array
varhashhashmap variables -> indices
varthe variable which index we need
varidxpointer to store index of variable in *vars

Definition at line 794 of file reader_pip.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, SCIPcalcMemGrowSize(), SCIPhashmapExists(), SCIPhashmapGetImageInt(), SCIPhashmapInsertInt(), and SCIPreallocBufferArray.

Referenced by readPolynomial().

◆ readPolynomial()

static SCIP_RETCODE readPolynomial ( SCIP scip,
PIPINPUT pipinput,
char *  name,
SCIP_EXPRTREE **  exprtree,
int *  degree,
SCIP_Bool newsection 
)
static

reads an objective or constraint with name and coefficients

Parameters
scipSCIP data structure
pipinputPIP reading data
namepointer to store the name of the line; must be at least of size PIP_MAX_LINELEN
exprtreepointer to store constraint function as polynomial expression
degreepointer to store degree of polynomial
newsectionpointer to store whether a new section was encountered

Definition at line 852 of file reader_pip.c.

References ensureFactorsSize(), ensureMonomialsSize(), FALSE, getNextToken(), getVariable(), getVariableIndex(), isNewSection(), isSense(), isSign(), isValue(), NULL, PIP_INIT_FACTORSSIZE, PIP_INIT_MONOMIALSSIZE, PIP_INIT_VARSSIZE, PIP_MAX_LINELEN, pushBufferToken(), pushToken(), SCIP_Bool, SCIP_CALL, SCIP_EXPR_DEGREEINFINITY, SCIP_EXPR_VARIDX, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPblkmem(), SCIPdebug, SCIPdebugMsg, SCIPdebugMsgPrint, SCIPexprCreate(), SCIPexprCreateMonomial(), SCIPexprCreatePolynomial(), SCIPexprtreeCreate(), SCIPexprtreePrintWithNames(), SCIPexprtreeSetVars(), SCIPfreeBufferArray, SCIPgetMessagehdlr(), SCIPhashmapCreate(), SCIPhashmapFree(), SCIPisIntegral(), SCIPstrncpy(), SCIPvarGetName(), swapTokenBuffer(), syntaxError(), and TRUE.

Referenced by readConstraints(), and readObjective().

◆ getLinearAndQuadraticCoefs()

static void getLinearAndQuadraticCoefs ( SCIP_EXPRTREE exprtree,
SCIP_Real constant,
int *  nlinvars,
SCIP_VAR **  linvars,
SCIP_Real lincoefs,
int *  nquadterms,
SCIP_VAR **  quadvars1,
SCIP_VAR **  quadvars2,
SCIP_Real quadcoefs 
)
static

given an expression tree that holds a polynomial expression of degree at most two, gives the coefficients of the constant, linear, and quadratic part of this expression

Parameters
exprtreeexpression tree holding polynomial expression
constantbuffer to store constant monomials
nlinvarsbuffer to store number of linear coefficients
linvarsarray to fill with linear variables
lincoefsarray to fill with coefficients of linear variables
nquadtermsbuffer to store number of quadratic terms
quadvars1array to fill with quadratic variables
quadvars2array to fill with quadratic variables
quadcoefsarray to fill with coefficients of quadratic terms

Definition at line 1157 of file reader_pip.c.

References NULL, SCIP_EXPR_POLYNOMIAL, SCIP_EXPR_VARIDX, SCIPexprGetChildren(), SCIPexprGetMonomialChildIndices(), SCIPexprGetMonomialCoef(), SCIPexprGetMonomialExponents(), SCIPexprGetMonomialNFactors(), SCIPexprGetMonomials(), SCIPexprGetNChildren(), SCIPexprGetNMonomials(), SCIPexprGetOperator(), SCIPexprGetOpIndex(), SCIPexprGetPolynomialConstant(), SCIPexprtreeGetNVars(), SCIPexprtreeGetRoot(), and SCIPexprtreeGetVars().

Referenced by readConstraints(), and readObjective().

◆ readObjective()

◆ readConstraints()

◆ readBounds()

static SCIP_RETCODE readBounds ( SCIP scip,
PIPINPUT pipinput 
)
static

◆ readGenerals()

static SCIP_RETCODE readGenerals ( SCIP scip,
PIPINPUT pipinput 
)
static

reads the generals section

Parameters
scipSCIP data structure
pipinputPIP reading data

Definition at line 1832 of file reader_pip.c.

References getNextToken(), getVariable(), isNewSection(), NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_VARTYPE_INTEGER, SCIPchgVarType(), and syntaxError().

Referenced by readPIPFile().

◆ readBinaries()

static SCIP_RETCODE readBinaries ( SCIP scip,
PIPINPUT pipinput 
)
static

reads the binaries section

Parameters
scipSCIP data structure
pipinputPIP reading data

Definition at line 1867 of file reader_pip.c.

References getNextToken(), getVariable(), isNewSection(), NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_VARTYPE_BINARY, SCIPchgVarLb(), SCIPchgVarType(), SCIPchgVarUb(), SCIPvarGetLbGlobal(), SCIPvarGetUbGlobal(), and syntaxError().

Referenced by readPIPFile().

◆ readPIPFile()

static SCIP_RETCODE readPIPFile ( SCIP scip,
PIPINPUT pipinput,
const char *  filename 
)
static

reads a PIP file

Parameters
scipSCIP data structure
pipinputPIP reading data
filenamename of the input file

Definition at line 1911 of file reader_pip.c.

References hasError(), NULL, PIP_BINARIES, PIP_BOUNDS, PIP_CONSTRAINTS, PIP_END, PIP_GENERALS, PIP_OBJECTIVE, PIP_START, readBinaries(), readBounds(), readConstraints(), readGenerals(), readObjective(), readStart(), SCIP_CALL, SCIP_INVALIDDATA, SCIP_NOFILE, SCIP_OKAY, SCIPcreateProb(), SCIPerrorMessage, SCIPfclose(), SCIPfopen(), and SCIPprintSysError().

Referenced by SCIPreadPip().

◆ SCIP_DECL_HASHGETKEY()

static SCIP_DECL_HASHGETKEY ( hashGetKeyVar  )
static

hash key retrieval function for variables

Definition at line 1981 of file reader_pip.c.

◆ SCIP_DECL_HASHKEYEQ()

static SCIP_DECL_HASHKEYEQ ( hashKeyEqVar  )
static

returns TRUE iff the indices of both variables are equal

Definition at line 1988 of file reader_pip.c.

References FALSE, and TRUE.

◆ SCIP_DECL_HASHKEYVAL()

static SCIP_DECL_HASHKEYVAL ( hashKeyValVar  )
static

returns the hash value of the key

Definition at line 1997 of file reader_pip.c.

References SCIPvarGetIndex().

◆ getActiveVariables()

static 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
varsvars array to get active variables for
scalarsscalars 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 2005 of file reader_pip.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPgetProbvarLinearSum(), SCIPreallocBufferArray, SCIPvarGetOrigvarSum(), and TRUE.

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

◆ clearLine()

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

clears the given line buffer

Parameters
linebufferline
linecntnumber of characters in line

Definition at line 2046 of file reader_pip.c.

References NULL.

Referenced by endLine(), printRow(), printRowNl(), and SCIPwritePip().

◆ endLine()

static 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 2060 of file reader_pip.c.

References clearLine(), NULL, PIP_MAX_PRINTLEN, and SCIPinfoMessage().

Referenced by appendLine(), printRow(), printRowNl(), and SCIPwritePip().

◆ appendLine()

static 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 PIP_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 2083 of file reader_pip.c.

References endLine(), NULL, PIP_MAX_PRINTLEN, PIP_PRINTLEN, and SCIPdebugMsg.

Referenced by printRow(), printRowNl(), and SCIPwritePip().

◆ printRow()

static void printRow ( SCIP scip,
FILE *  file,
const char *  rowname,
const char *  rownameextension,
const char *  type,
SCIP_VAR **  linvars,
SCIP_Real linvals,
int  nlinvars,
SCIP_QUADVARTERM quadvarterms,
int  nquadvarterms,
SCIP_BILINTERM bilinterms,
int  nbilinterms,
SCIP_Real  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
quadvartermsquadratic variable terms
nquadvartermsnumber of quadratic variable terms
bilintermsbilinear terms
nbilintermsnumber of bilinear terms
rhsright hand side

Definition at line 2114 of file reader_pip.c.

References appendLine(), clearLine(), endLine(), NULL, PIP_MAX_NAMELEN, PIP_MAX_PRINTLEN, SCIPisZero(), SCIPsnprintf(), and SCIPvarGetName().

Referenced by printAggregatedCons(), and printQuadraticCons().

◆ printRowNl()

static void printRowNl ( SCIP scip,
FILE *  file,
const char *  rowname,
const char *  rownameextension,
const char *  type,
SCIP_VAR **  linvars,
SCIP_Real linvals,
int  nlinvars,
SCIP_EXPRTREE **  exprtrees,
SCIP_Real exprtreecoefs,
int  nexprtrees,
SCIP_Real  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
exprtreesexpression trees
exprtreecoefscoefficients of expression trees
nexprtreesnumber of expression trees
rhsright hand side

Definition at line 2251 of file reader_pip.c.

References appendLine(), clearLine(), SCIP_QuadElement::coef, endLine(), SCIP_QuadElement::idx1, SCIP_QuadElement::idx2, NULL, PIP_MAX_NAMELEN, PIP_MAX_PRINTLEN, SCIP_EXPR_CONST, SCIP_EXPR_INTPOWER, SCIP_EXPR_LINEAR, SCIP_EXPR_MINUS, SCIP_EXPR_MUL, SCIP_EXPR_PLUS, SCIP_EXPR_POLYNOMIAL, SCIP_EXPR_PRODUCT, SCIP_EXPR_QUADRATIC, SCIP_EXPR_REALPOWER, SCIP_EXPR_SQRT, SCIP_EXPR_SQUARE, SCIP_EXPR_SUM, SCIP_EXPR_VARIDX, SCIPerrorMessage, SCIPexprGetChildren(), SCIPexprGetIntPowerExponent(), SCIPexprGetLinearCoefs(), SCIPexprGetLinearConstant(), SCIPexprGetMonomialChildIndices(), SCIPexprGetMonomialCoef(), SCIPexprGetMonomialExponents(), SCIPexprGetMonomialNFactors(), SCIPexprGetMonomials(), SCIPexprGetNChildren(), SCIPexprGetNMonomials(), SCIPexprGetNQuadElements(), SCIPexprGetOperator(), SCIPexprGetOpIndex(), SCIPexprGetOpReal(), SCIPexprGetPolynomialConstant(), SCIPexprGetQuadConstant(), SCIPexprGetQuadElements(), SCIPexprGetQuadLinearCoefs(), SCIPexprGetRealPowerExponent(), SCIPexpropGetName(), SCIPexprtreeGetNVars(), SCIPexprtreeGetRoot(), SCIPexprtreeGetVars(), SCIPisZero(), SCIPsnprintf(), and SCIPvarGetName().

Referenced by printNonlinearCons().

◆ printQuadraticCons()

static SCIP_RETCODE printQuadraticCons ( SCIP scip,
FILE *  file,
const char *  rowname,
SCIP_VAR **  linvars,
SCIP_Real linvals,
int  nlinvars,
SCIP_QUADVARTERM quadvarterms,
int  nquadvarterms,
SCIP_BILINTERM bilinterms,
int  nbilinterms,
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
quadvartermsquadratic variable terms
nquadvartermsnumber of quadratic variable terms
bilintermsbilinear terms
nbilintermsnumber of bilinear terms
lhsleft hand side
rhsright hand side
transformedtransformed constraint?

Definition at line 2608 of file reader_pip.c.

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

Referenced by SCIPwritePip().

◆ printNonlinearCons()

static SCIP_RETCODE printNonlinearCons ( SCIP scip,
FILE *  file,
const char *  rowname,
SCIP_VAR **  linvars,
SCIP_Real linvals,
int  nlinvars,
SCIP_EXPRTREE **  exprtrees,
SCIP_Real exprtreecoefs,
int  nexprtrees,
SCIP_Real  lhs,
SCIP_Real  rhs,
SCIP_Bool  transformed 
)
static

prints given nonlinear 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
exprtreesexpression trees
exprtreecoefscoefficients of expression trees
nexprtreesnumber of expression trees
lhsleft hand side
rhsright hand side
transformedtransformed constraint?

Definition at line 2705 of file reader_pip.c.

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

Referenced by SCIPwritePip().

◆ collectAggregatedVars()

static SCIP_RETCODE collectAggregatedVars ( int  nvars,
SCIP_VAR **  vars,
int *  nAggregatedVars,
SCIP_VAR ***  aggregatedVars,
SCIP_HASHTABLE **  varAggregated 
)
static

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

Parameters
nvarsnumber of active variables in the problem
varsvariable array
nAggregatedVarsnumber of aggregated variables on output
aggregatedVarsarray storing the aggregated variables on output
varAggregatedhashtable for checking duplicates

Definition at line 2804 of file reader_pip.c.

References SCIP_CALL, SCIP_OKAY, SCIP_VARSTATUS_AGGREGATED, SCIP_VARSTATUS_MULTAGGR, SCIP_VARSTATUS_NEGATED, SCIPhashtableExists(), SCIPhashtableInsert(), and SCIPvarGetStatus().

Referenced by SCIPwritePip().

◆ printAggregatedCons()

static 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 2844 of file reader_pip.c.

References getActiveVariables(), NULL, PIP_MAX_NAMELEN, printRow(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPsnprintf(), and SCIPvarGetName().

Referenced by SCIPwritePip().

◆ isNameValid()

static SCIP_Bool isNameValid ( const char *  name)
static

returns whether name is valid according to PIP specification

Checks these two conditions from http://polip.zib.de/pipformat.php:

  • Names/labels can contain at most 255 characters.
  • Name/labels have to consist of the following characters: a-z, A-Z, 0-9, "!", "#", "$", "%", "&", ";", "?", "@", "_". They cannot start with a number.

In addition checks that the length is not zero.

Parameters
namename to check

Definition at line 2904 of file reader_pip.c.

References FALSE, namechars, NULL, PIP_MAX_NAMELEN, and TRUE.

Referenced by checkConsnames(), and checkVarnames().

◆ checkVarnames()

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

method check if the variable names are valid according to PIP specification

Parameters
scipSCIP data structure
varsarray of variables
nvarsnumber of variables

Definition at line 2940 of file reader_pip.c.

References isNameValid(), NULL, SCIPvarGetName(), and SCIPwarningMessage().

Referenced by SCIPwritePip().

◆ checkConsnames()

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

method check if the constraint names are valid according to PIP specification

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

Definition at line 2964 of file reader_pip.c.

References isNameValid(), NULL, PIP_MAX_NAMELEN, SCIP_Real, SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetName(), SCIPconsIsEnabled(), SCIPconsIsTransformed(), SCIPgetLhsLinear(), SCIPisEQ(), and SCIPwarningMessage().

Referenced by SCIPwritePip().

◆ SCIP_DECL_READERCOPY()

static SCIP_DECL_READERCOPY ( readerCopyPip  )
static

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

Definition at line 3776 of file reader_pip.c.

References NULL, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludeReaderPip(), and SCIPreaderGetName().

◆ SCIP_DECL_READERREAD()

static SCIP_DECL_READERREAD ( readerReadPip  )
static

problem reading method of reader

Definition at line 3791 of file reader_pip.c.

References SCIP_CALL, SCIP_OKAY, and SCIPreadPip().

◆ SCIP_DECL_READERWRITE()

static SCIP_DECL_READERWRITE ( readerWritePip  )
static

problem writing method of reader

Definition at line 3802 of file reader_pip.c.

References SCIP_CALL, SCIP_OKAY, and SCIPwritePip().

Variable Documentation

◆ delimchars

const char delimchars[] = " \f\n\r\t\v"
static

Definition at line 132 of file reader_pip.c.

Referenced by isDelimChar().

◆ tokenchars

const char tokenchars[] = "-+:<>=*^"
static

Definition at line 133 of file reader_pip.c.

Referenced by isTokenChar().

◆ commentchars

const char commentchars[] = "\\"
static

Definition at line 134 of file reader_pip.c.

Referenced by getNextLine().

◆ namechars

const char namechars[] = "!#$%&;?@_"
static

Definition at line 135 of file reader_pip.c.

Referenced by isNameValid().