Scippy

SCIP

Solving Constraint Integer Programs

reader_fzn.c File Reference

Detailed Description

FlatZinc file reader.

Author
Timo Berthold
Stefan Heinz

FlatZinc is a low-level solver input language that is the target language for MiniZinc. It is designed to be easy to translate into the form required by a solver. For more details see http://www.g12.cs.mu.oz.au/minizinc/ .

Definition in file reader_fzn.c.

#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include "scip/cons_and.h"
#include "scip/cons_cumulative.h"
#include "scip/cons_knapsack.h"
#include "scip/cons_linear.h"
#include "scip/cons_logicor.h"
#include "scip/cons_or.h"
#include "scip/cons_quadratic.h"
#include "scip/cons_setppc.h"
#include "scip/cons_varbound.h"
#include "scip/cons_xor.h"
#include "scip/pub_misc.h"
#include "scip/reader_fzn.h"

Go to the source code of this file.

Macros

#define READER_NAME   "fznreader"
 
#define READER_DESC   "file reader for FlatZinc format"
 
#define READER_EXTENSION   "fzn"
 
#define FZN_BUFFERLEN   65536
 
#define FZN_MAX_PUSHEDTOKENS   1
 
#define CREATE_CONSTRAINT(x)   SCIP_RETCODE x (SCIP* scip, FZNINPUT* fzninput, const char* fname, char** ftokens, int nftokens, SCIP_Bool* created)
 

Typedefs

typedef enum FznNumberType FZNNUMBERTYPE
 
typedef enum FznExpType FZNEXPTYPE
 
typedef struct Dimensions DIMENSIONS
 
typedef struct FznConstant FZNCONSTANT
 
typedef struct ConstArray CONSTARRAY
 
typedef struct VarArray VARARRAY
 
typedef struct FznInput FZNINPUT
 
typedef struct FznOutput FZNOUTPUT
 

Enumerations

enum  FznNumberType {
  FZN_BOOL,
  FZN_INT,
  FZN_FLOAT
}
 
enum  FznExpType {
  FZN_EXP_NONE,
  FZN_EXP_UNSIGNED,
  FZN_EXP_SIGNED
}
 

Functions

static SCIP_DECL_HASHGETKEY (hashGetKeyVar)
 
static SCIP_DECL_HASHGETKEY (hashGetKeyConstant)
 
static SCIP_DECL_SORTPTRCOMP (vararraysComp)
 
static void freeStringBufferArray (SCIP *scip, char **array, int nelements)
 
static SCIP_Bool isDelimChar (char c)
 
static SCIP_Bool isTokenChar (char c)
 
static SCIP_Bool isChar (const char *token, char c)
 
static SCIP_Bool isBoolExp (const char *name, SCIP_Bool *value)
 
static SCIP_Bool isIdentifier (const char *name)
 
static SCIP_Bool isValueChar (char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, FZNEXPTYPE *exptype)
 
static SCIP_Bool equalTokens (SCIP *scip, const char *token1, const char *token2)
 
static SCIP_Bool getNextLine (SCIP *scip, FZNINPUT *fzninput)
 
static SCIP_Bool getNextToken (SCIP *scip, FZNINPUT *fzninput)
 
static void pushToken (FZNINPUT *fzninput)
 
static SCIP_Bool isEndStatement (FZNINPUT *fzninput)
 
static SCIP_Bool isValue (const char *token, SCIP_Real *value)
 
static void syntaxError (SCIP *scip, FZNINPUT *fzninput, const char *msg)
 
static SCIP_Bool hasError (FZNINPUT *fzninput)
 
static SCIP_RETCODE readerdataCreate (SCIP *scip, SCIP_READERDATA **readerdata)
 
static SCIP_RETCODE ensureVararrySize (SCIP *scip, SCIP_READERDATA *readerdata)
 
static SCIP_RETCODE ensureVararrySizeFznInput (SCIP *scip, FZNINPUT *fzninput)
 
static SCIP_RETCODE ensureConstarrySizeFznInput (SCIP *scip, FZNINPUT *fzninput)
 
static void printValue (SCIP *scip, FILE *file, SCIP_Real value, FZNNUMBERTYPE type)
 
static SCIP_RETCODE copyDimensions (SCIP *scip, DIMENSIONS **target, DIMENSIONS *source)
 
static SCIP_RETCODE createVararray (SCIP *scip, VARARRAY **vararray, const char *name, SCIP_VAR **vars, int nvars, FZNNUMBERTYPE type, DIMENSIONS *info)
 
static void freeDimensions (SCIP *scip, DIMENSIONS **dim)
 
static void freeVararray (SCIP *scip, VARARRAY **vararray)
 
static VARARRAYfindVararray (SCIP *scip, FZNINPUT *fzninput, const char *name)
 
static SCIP_RETCODE createConstarray (SCIP *scip, CONSTARRAY **constarray, const char *name, FZNCONSTANT **constants, int nconstants, FZNNUMBERTYPE type)
 
static void freeConstarray (SCIP *scip, CONSTARRAY **constarray)
 
static CONSTARRAYfindConstarray (SCIP *scip, FZNINPUT *fzninput, const char *name)
 
static SCIP_RETCODE readerdataAddOutputvar (SCIP *scip, SCIP_READERDATA *readerdata, SCIP_VAR *var, FZNNUMBERTYPE type)
 
static SCIP_RETCODE readerdataAddOutputvararray (SCIP *scip, SCIP_READERDATA *readerdata, const char *name, SCIP_VAR **vars, int nvars, FZNNUMBERTYPE type, DIMENSIONS *info)
 
static SCIP_RETCODE fzninputAddVararray (SCIP *scip, FZNINPUT *fzninput, const char *name, SCIP_VAR **vars, int nvars, FZNNUMBERTYPE type, DIMENSIONS *info)
 
static SCIP_RETCODE fzninputAddConstarray (SCIP *scip, FZNINPUT *fzninput, const char *name, FZNCONSTANT **constants, int nconstants, FZNNUMBERTYPE type)
 
static SCIP_RETCODE createQuadraticCons (SCIP *scip, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nquadterms, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoefs, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamicrows)
 
static SCIP_RETCODE createLinearCons (SCIP *scip, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamicrows)
 
static SCIP_RETCODE createLinking (SCIP *scip, FZNINPUT *fzninput, const char *consname, const char *name1, const char *name2, SCIP_Real lhs, SCIP_Real rhs)
 
static void parseArrayIndex (SCIP *scip, FZNINPUT *fzninput, int *idx)
 
static void flattenAssignment (SCIP *scip, FZNINPUT *fzninput, char *assignment)
 
static void computeLinearConsSides (SCIP *scip, FZNINPUT *fzninput, const char *name, SCIP_Real sidevalue, SCIP_Real *lhs, SCIP_Real *rhs)
 
static SCIP_RETCODE parseList (SCIP *scip, FZNINPUT *fzninput, char ***elements, int *nelements, int selements)
 
static void parseRange (SCIP *scip, FZNINPUT *fzninput, FZNNUMBERTYPE *type, SCIP_Real *lb, SCIP_Real *ub)
 
static SCIP_RETCODE parseOutputDimensioninfo (SCIP *scip, FZNINPUT *fzninput, DIMENSIONS **info)
 
static SCIP_RETCODE parseName (SCIP *scip, FZNINPUT *fzninput, char *name, SCIP_Bool *output, DIMENSIONS **info)
 
static void parseType (SCIP *scip, FZNINPUT *fzninput, FZNNUMBERTYPE *type, SCIP_Real *lb, SCIP_Real *ub)
 
static SCIP_RETCODE applyVariableAssignment (SCIP *scip, FZNINPUT *fzninput, SCIP_VAR *var, FZNNUMBERTYPE type, const char *assignment)
 
static SCIP_RETCODE createConstantAssignment (SCIP *scip, FZNCONSTANT **constant, FZNINPUT *fzninput, const char *name, FZNNUMBERTYPE type, const char *assignment)
 
static void parseArrayType (SCIP *scip, FZNINPUT *fzninput, SCIP_Bool *isvararray, FZNNUMBERTYPE *type, SCIP_Real *lb, SCIP_Real *ub)
 
static SCIP_RETCODE parseArrayAssignment (SCIP *scip, FZNINPUT *fzninput, char ***elements, int *nelements, int selements)
 
static void parseArrayDimension (SCIP *scip, FZNINPUT *fzninput, int *nelements)
 
static SCIP_RETCODE createVariable (SCIP *scip, FZNINPUT *fzninput, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, FZNNUMBERTYPE type)
 
static SCIP_RETCODE parseVariableArray (SCIP *scip, SCIP_READERDATA *readerdata, FZNINPUT *fzninput, const char *name, int nvars, FZNNUMBERTYPE type, SCIP_Real lb, SCIP_Real ub, DIMENSIONS *info)
 
static SCIP_RETCODE parseConstantArray (SCIP *scip, FZNINPUT *fzninput, const char *name, int nconstants, FZNNUMBERTYPE type)
 
static SCIP_RETCODE parsePredicate (SCIP *scip, FZNINPUT *fzninput)
 
static SCIP_RETCODE parseArray (SCIP *scip, SCIP_READERDATA *readerdata, FZNINPUT *fzninput)
 
static SCIP_RETCODE parseVariable (SCIP *scip, SCIP_READERDATA *readerdata, FZNINPUT *fzninput)
 
static SCIP_RETCODE parseConstant (SCIP *scip, FZNINPUT *fzninput, FZNNUMBERTYPE type)
 
static void parseValue (SCIP *scip, FZNINPUT *fzninput, SCIP_Real *value, const char *assignment)
 
static SCIP_RETCODE parseConstantArrayAssignment (SCIP *scip, FZNINPUT *fzninput, SCIP_Real **vals, int *nvals, int sizevals)
 
static SCIP_RETCODE parseVariableArrayAssignment (SCIP *scip, FZNINPUT *fzninput, SCIP_VAR ***vars, int *nvars, int sizevars)
 
static SCIP_RETCODE parseQuadratic (SCIP *scip, FZNINPUT *fzninput, const char *name)
 
static SCIP_RETCODE parseAggregation (SCIP *scip, FZNINPUT *fzninput, const char *name, const char *type)
 
static SCIP_RETCODE parseLinking (SCIP *scip, FZNINPUT *fzninput, const char *name, const char *type, SCIP_Real sidevalue)
 
static CREATE_CONSTRAINT (createCoercionOpCons)
 
static CREATE_CONSTRAINT (createSetOpCons)
 
static CREATE_CONSTRAINT (createArrayOpCons)
 
static CREATE_CONSTRAINT (createLogicalOpCons)
 
static CREATE_CONSTRAINT (createComparisonOpCons)
 
static CREATE_CONSTRAINT (createAlldifferentOpCons)
 
static CREATE_CONSTRAINT (createCumulativeOpCons)
 
static CREATE_CONSTRAINT ((*constypes[]))
 
static SCIP_RETCODE parseConstraint (SCIP *scip, FZNINPUT *fzninput)
 
static SCIP_RETCODE parseSolveItem (SCIP *scip, FZNINPUT *fzninput)
 
static SCIP_RETCODE readFZNFile (SCIP *scip, SCIP_READERDATA *readerdata, FZNINPUT *fzninput, const char *filename)
 
static SCIP_RETCODE getActiveVariables (SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
 
static void writeBuffer (SCIP *scip, FILE *file, char *buffer, int bufferpos)
 
static SCIP_RETCODE appendBuffer (SCIP *scip, char **buffer, int *bufferlen, int *bufferpos, const char *extension)
 
static void flattenFloat (SCIP *scip, SCIP_Real val, char *buffer)
 
static SCIP_RETCODE printRow (SCIP *scip, FZNOUTPUT *fznoutput, const char *type, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real rhs, SCIP_Bool hasfloats)
 
static SCIP_RETCODE printLinearCons (SCIP *scip, FZNOUTPUT *fznoutput, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool transformed, SCIP_Bool mayhavefloats)
 
static SCIP_RETCODE writeFzn (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 (readerCopyFzn)
 
static SCIP_DECL_READERFREE (readerFreeFzn)
 
static SCIP_DECL_READERREAD (readerReadFzn)
 
static SCIP_DECL_READERWRITE (readerWriteFzn)
 
SCIP_RETCODE SCIPincludeReaderFzn (SCIP *scip)
 
SCIP_RETCODE SCIPprintSolReaderFzn (SCIP *scip, SCIP_SOL *sol, FILE *file)
 

Variables

static const char delimchars [] = " \f\n\r\t\v"
 
static const char tokenchars [] = ":<>=;{}[],()"
 
static const char commentchars [] = "%"
 
static int nconstypes = 7
 

Macro Definition Documentation

#define READER_NAME   "fznreader"

Definition at line 50 of file reader_fzn.c.

Referenced by SCIP_DECL_READERCOPY(), SCIPincludeReaderFzn(), and SCIPprintSolReaderFzn().

#define READER_DESC   "file reader for FlatZinc format"

Definition at line 51 of file reader_fzn.c.

Referenced by SCIPincludeReaderFzn().

#define READER_EXTENSION   "fzn"

Definition at line 52 of file reader_fzn.c.

Referenced by SCIPincludeReaderFzn().

#define FZN_MAX_PUSHEDTOKENS   1

Definition at line 56 of file reader_fzn.c.

Referenced by pushToken(), and SCIP_DECL_READERREAD().

#define CREATE_CONSTRAINT (   x)    SCIP_RETCODE x (SCIP* scip, FZNINPUT* fzninput, const char* fname, char** ftokens, int nftokens, SCIP_Bool* created)

tries to creates and adds a constraint; sets parameter created to TRUE if method was successful

input:

  • scip : SCIP main data structure
  • fzninput, : FZN reading data
  • fname, : functions identifier name
  • ftokens, : function identifier tokens
  • nftokens, : number of function identifier tokes

output

  • created : pointer to store whether a constraint was created or not

Definition at line 139 of file reader_fzn.c.

Referenced by CREATE_CONSTRAINT().

Typedef Documentation

Definition at line 69 of file reader_fzn.c.

typedef enum FznExpType FZNEXPTYPE

Definition at line 78 of file reader_fzn.c.

typedef struct Dimensions DIMENSIONS

Definition at line 87 of file reader_fzn.c.

typedef struct FznConstant FZNCONSTANT

Definition at line 96 of file reader_fzn.c.

typedef struct ConstArray CONSTARRAY

Definition at line 106 of file reader_fzn.c.

typedef struct VarArray VARARRAY

Definition at line 117 of file reader_fzn.c.

typedef struct FznInput FZNINPUT

Definition at line 177 of file reader_fzn.c.

typedef struct FznOutput FZNOUTPUT

Definition at line 194 of file reader_fzn.c.

Enumeration Type Documentation

number types

Enumerator
FZN_BOOL 
FZN_INT 
FZN_FLOAT 

Definition at line 63 of file reader_fzn.c.

enum FznExpType

Expression type in FlatZinc File

Enumerator
FZN_EXP_NONE 
FZN_EXP_UNSIGNED 
FZN_EXP_SIGNED 

Definition at line 72 of file reader_fzn.c.

Function Documentation

static SCIP_DECL_HASHGETKEY ( hashGetKeyVar  )
static

gets the key (i.e. the name) of the given variable

Definition at line 206 of file reader_fzn.c.

References NULL, and SCIPvarGetName().

static SCIP_DECL_HASHGETKEY ( hashGetKeyConstant  )
static

gets the key (i.e. the name) of the flatzinc constant

Definition at line 216 of file reader_fzn.c.

References NULL.

static SCIP_DECL_SORTPTRCOMP ( vararraysComp  )
static

comparison method for sorting variable arrays w.r.t. to their name

Definition at line 226 of file reader_fzn.c.

static void freeStringBufferArray ( SCIP scip,
char **  array,
int  nelements 
)
static

frees a given buffer char* array

Parameters
scipSCIP data structure
arraybuffer array to free
nelementsnumber of elements

Definition at line 234 of file reader_fzn.c.

References SCIPfreeBufferArray.

Referenced by CREATE_CONSTRAINT(), parseAggregation(), parseConstantArray(), parseConstantArrayAssignment(), parseLinking(), parseQuadratic(), parseVariableArray(), and parseVariableArrayAssignment().

static SCIP_Bool isDelimChar ( char  c)
static

returns whether the given character is a token delimiter

Parameters
cinput character

Definition at line 252 of file reader_fzn.c.

References delimchars, and NULL.

Referenced by getNextToken().

static SCIP_Bool isTokenChar ( char  c)
static

returns whether the given character is a single token

Parameters
cinput character

Definition at line 261 of file reader_fzn.c.

References NULL, and tokenchars.

Referenced by getNextToken().

static SCIP_Bool isChar ( const char *  token,
char  c 
)
static
static SCIP_Bool isBoolExp ( const char *  name,
SCIP_Bool value 
)
static

check if the current token is Bool expression, this means false or true

Parameters
namename to check
valuepointer to store the Bool value

Definition at line 283 of file reader_fzn.c.

References FALSE, and TRUE.

Referenced by applyVariableAssignment(), and createConstantAssignment().

static SCIP_Bool isIdentifier ( const char *  name)
static

check if the current token is an identifier, this means [A-Za-z][A-Za-z0-9_]*

Parameters
namename to check

Definition at line 318 of file reader_fzn.c.

References FALSE, and TRUE.

Referenced by flattenAssignment(), parseArrayIndex(), parseConstraint(), parseName(), parseValue(), and SCIP_DECL_READERWRITE().

static SCIP_Bool isValueChar ( char  c,
char  nextc,
SCIP_Bool  firstchar,
SCIP_Bool hasdot,
FZNEXPTYPE 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 341 of file reader_fzn.c.

References FALSE, FZN_EXP_NONE, FZN_EXP_SIGNED, FZN_EXP_UNSIGNED, NULL, and TRUE.

Referenced by getNextToken().

static SCIP_Bool equalTokens ( SCIP scip,
const char *  token1,
const char *  token2 
)
static

compares two token if they are equal

Parameters
scipSCIP data structure
token1first token
token2second token

Definition at line 385 of file reader_fzn.c.

References FALSE, and NULL.

Referenced by computeLinearConsSides(), CREATE_CONSTRAINT(), findConstarray(), findVararray(), parseAggregation(), parseArrayType(), parseName(), parseRange(), parseSolveItem(), parseType(), and readFZNFile().

static SCIP_Bool getNextLine ( SCIP scip,
FZNINPUT fzninput 
)
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
fzninputFZN reading data

Definition at line 404 of file reader_fzn.c.

References BMSclearMemoryArray, commentchars, FALSE, FZN_BUFFERLEN, NULL, SCIPdebugMessage, SCIPfgets(), SCIPfseek(), SCIPwarningMessage(), and TRUE.

Referenced by getNextToken().

static void pushToken ( FZNINPUT fzninput)
static

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

Parameters
fzninputFZN reading data

Definition at line 618 of file reader_fzn.c.

References FZN_MAX_PUSHEDTOKENS, NULL, and SCIPswapPointers().

Referenced by flattenAssignment(), parseArrayType(), parseConstantArrayAssignment(), parseList(), parseName(), parseType(), parseVariable(), parseVariableArray(), parseVariableArrayAssignment(), and readFZNFile().

static SCIP_Bool isEndStatement ( FZNINPUT fzninput)
static

checks whether the current token is a semicolon which closes a statement

Parameters
fzninputFZN reading data

Definition at line 631 of file reader_fzn.c.

References isChar(), and NULL.

Referenced by flattenAssignment(), parseArrayIndex(), parseName(), parseType(), parseVariableArray(), and readFZNFile().

static SCIP_Bool isValue ( const char *  token,
SCIP_Real value 
)
static

returns whether the current token is a value

Parameters
tokentoken to check
valuepointer to store the value (unchanged, if token is no value)

Definition at line 642 of file reader_fzn.c.

References FALSE, NULL, and TRUE.

Referenced by applyVariableAssignment(), createConstantAssignment(), createLinking(), parseArrayIndex(), parseRange(), parseValue(), and parseVariableArrayAssignment().

static void syntaxError ( SCIP scip,
FZNINPUT fzninput,
const char *  msg 
)
static
static SCIP_Bool hasError ( FZNINPUT fzninput)
static
static SCIP_RETCODE readerdataCreate ( SCIP scip,
SCIP_READERDATA **  readerdata 
)
static

create reader data

Parameters
scipSCIP data structure
readerdatapointer to reader data

Definition at line 695 of file reader_fzn.c.

References NULL, SCIP_CALL, SCIP_OKAY, and SCIPallocMemory.

Referenced by SCIPincludeReaderFzn().

static SCIP_RETCODE ensureVararrySize ( SCIP scip,
SCIP_READERDATA readerdata 
)
static

ensure the size if the variable array

Parameters
scipSCIP data structure
readerdatareader data

Definition at line 711 of file reader_fzn.c.

References SCIP_CALL, SCIP_OKAY, SCIPallocMemoryArray, and SCIPreallocMemoryArray.

Referenced by readerdataAddOutputvar(), and readerdataAddOutputvararray().

static SCIP_RETCODE ensureVararrySizeFznInput ( SCIP scip,
FZNINPUT fzninput 
)
static

ensure the size if the variable array

Parameters
scipSCIP data structure
fzninputFZN reading data

Definition at line 743 of file reader_fzn.c.

References SCIP_CALL, SCIP_OKAY, SCIPallocMemoryArray, and SCIPreallocMemoryArray.

Referenced by fzninputAddVararray().

static SCIP_RETCODE ensureConstarrySizeFznInput ( SCIP scip,
FZNINPUT fzninput 
)
static

ensure the size if the variable array

Parameters
scipSCIP data structure
fzninputFZN reading data

Definition at line 775 of file reader_fzn.c.

References SCIP_CALL, SCIP_OKAY, SCIPallocMemoryArray, and SCIPreallocMemoryArray.

Referenced by fzninputAddConstarray().

static void printValue ( SCIP scip,
FILE *  file,
SCIP_Real  value,
FZNNUMBERTYPE  type 
)
static

print given value in FlatZinc format to given stream

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
valuevalue to print
typeFlatZinc number type

Definition at line 807 of file reader_fzn.c.

References FZN_BOOL, FZN_FLOAT, FZN_INT, SCIP_Longint, SCIPconvertRealToLongint(), SCIPinfoMessage(), and SCIPisIntegral().

Referenced by SCIPprintSolReaderFzn().

static SCIP_RETCODE copyDimensions ( SCIP scip,
DIMENSIONS **  target,
DIMENSIONS source 
)
static

free dimension structure

Parameters
scipSCIP data structure
targetpointer to dimension target structure
sourcedimension source

Definition at line 851 of file reader_fzn.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPallocMemory, and SCIPduplicateMemoryArray.

Referenced by createVararray().

static SCIP_RETCODE createVararray ( SCIP scip,
VARARRAY **  vararray,
const char *  name,
SCIP_VAR **  vars,
int  nvars,
FZNNUMBERTYPE  type,
DIMENSIONS info 
)
static

create variable array data structure

Parameters
scipSCIP data structure
vararraypointer to variable array
namename of the variable array
varsarray of variables
nvarsnumber of variables
typevariable type
infodimension information for output

Definition at line 873 of file reader_fzn.c.

References copyDimensions(), SCIP_CALL, SCIP_OKAY, SCIPallocMemory, and SCIPduplicateMemoryArray.

Referenced by fzninputAddVararray(), and readerdataAddOutputvararray().

static void freeDimensions ( SCIP scip,
DIMENSIONS **  dim 
)
static

free dimension structure

Parameters
scipSCIP data structure
dimpointer to dimension structure

Definition at line 902 of file reader_fzn.c.

References NULL, SCIPfreeMemory, and SCIPfreeMemoryArrayNull.

Referenced by freeVararray(), and parseArray().

static void freeVararray ( SCIP scip,
VARARRAY **  vararray 
)
static

free variable array data structure

Parameters
scipSCIP data structure
vararraypointer to variable array

Definition at line 917 of file reader_fzn.c.

References freeDimensions(), SCIPfreeMemory, and SCIPfreeMemoryArray.

Referenced by SCIP_DECL_READERFREE(), and SCIP_DECL_READERREAD().

static VARARRAY* findVararray ( SCIP scip,
FZNINPUT fzninput,
const char *  name 
)
static

searches the variable array data base if a constant array exists with the given name; if it exists it is returned

Parameters
scipSCIP data structure
fzninputFZN reading data
namevariable array name

Definition at line 932 of file reader_fzn.c.

References equalTokens(), and NULL.

Referenced by parseConstantArrayAssignment(), and parseVariableArrayAssignment().

static SCIP_RETCODE createConstarray ( SCIP scip,
CONSTARRAY **  constarray,
const char *  name,
FZNCONSTANT **  constants,
int  nconstants,
FZNNUMBERTYPE  type 
)
static

create constant array data structure

Parameters
scipSCIP data structure
constarraypointer to constant array
namename of the variable array
constantsarray of constants
nconstantsnumber of constants
typeconstant type

Definition at line 959 of file reader_fzn.c.

References SCIP_CALL, SCIP_OKAY, SCIPallocMemory, SCIPdebugMessage, and SCIPduplicateMemoryArray.

Referenced by fzninputAddConstarray().

static void freeConstarray ( SCIP scip,
CONSTARRAY **  constarray 
)
static

free constant array data structure

Parameters
scipSCIP data structure
constarraypointer to constant array

Definition at line 987 of file reader_fzn.c.

References SCIPdebugMessage, SCIPfreeMemory, and SCIPfreeMemoryArray.

Referenced by SCIP_DECL_READERREAD().

static CONSTARRAY* findConstarray ( SCIP scip,
FZNINPUT fzninput,
const char *  name 
)
static

searches the constant array data base if a constant array exists with the given name; if it exists it is returned

Parameters
scipSCIP data structure
fzninputFZN reading data
nameconstant array name

Definition at line 1006 of file reader_fzn.c.

References equalTokens(), and NULL.

Referenced by parseConstantArrayAssignment().

static SCIP_RETCODE readerdataAddOutputvar ( SCIP scip,
SCIP_READERDATA readerdata,
SCIP_VAR var,
FZNNUMBERTYPE  type 
)
static

add variable to the reader data

Parameters
scipSCIP data structure
readerdatareader data
varvariable to add to the reader data
typevariable type

Definition at line 1029 of file reader_fzn.c.

References ensureVararrySize(), NULL, SCIP_CALL, SCIP_OKAY, SCIPallocMemory, SCIPduplicateMemoryArray, and SCIPvarGetName().

Referenced by parseVariable().

static SCIP_RETCODE readerdataAddOutputvararray ( SCIP scip,
SCIP_READERDATA readerdata,
const char *  name,
SCIP_VAR **  vars,
int  nvars,
FZNNUMBERTYPE  type,
DIMENSIONS info 
)
static

add variable to the reader data

Parameters
scipSCIP data structure
readerdatareader data
namename of the variable array
varsarray of variable to add to the reader data
nvarsnumber of variables
typevariable type
infodimension information for output

Definition at line 1075 of file reader_fzn.c.

References createVararray(), ensureVararrySize(), SCIP_CALL, and SCIP_OKAY.

Referenced by parseVariableArray().

static SCIP_RETCODE fzninputAddVararray ( SCIP scip,
FZNINPUT fzninput,
const char *  name,
SCIP_VAR **  vars,
int  nvars,
FZNNUMBERTYPE  type,
DIMENSIONS info 
)
static

add variable to the input data

Parameters
scipSCIP data structure
fzninputFZN reading data
namename of the variable array
varsarray of variables
nvarsnumber of variables
typevariable type
infodimension information for output

Definition at line 1104 of file reader_fzn.c.

References createVararray(), ensureVararrySizeFznInput(), SCIP_CALL, and SCIP_OKAY.

Referenced by parseVariableArray().

static SCIP_RETCODE fzninputAddConstarray ( SCIP scip,
FZNINPUT fzninput,
const char *  name,
FZNCONSTANT **  constants,
int  nconstants,
FZNNUMBERTYPE  type 
)
static

add variable to the reader data

Parameters
scipSCIP data structure
fzninputFZN reading data
namename of the variable array
constantsarray of constants
nconstantsnumber of constants
typevariable type

Definition at line 1133 of file reader_fzn.c.

References createConstarray(), ensureConstarrySizeFznInput(), SCIP_CALL, and SCIP_OKAY.

Referenced by parseConstantArray().

static SCIP_RETCODE createQuadraticCons ( SCIP scip,
const char *  name,
int  nlinvars,
SCIP_VAR **  linvars,
SCIP_Real lincoefs,
int  nquadterms,
SCIP_VAR **  quadvars1,
SCIP_VAR **  quadvars2,
SCIP_Real quadcoefs,
SCIP_Real  lhs,
SCIP_Real  rhs,
SCIP_Bool  initialconss,
SCIP_Bool  dynamicconss,
SCIP_Bool  dynamicrows 
)
static

creates, adds, and releases a linear constraint

Parameters
scipSCIP data structure
namename of constraint
nlinvarsnumber of linear terms (n)
linvarsarray with variables in linear part (x_i)
lincoefsarray with coefficients of variables in linear part (b_i)
nquadtermsnumber of quadratic terms (m)
quadvars1array with first variables in quadratic terms (y_j)
quadvars2array with second variables in quadratic terms (z_j)
quadcoefsarray with coefficients of quadratic terms (a_j)
lhsleft hand side of quadratic equation (ell)
rhsright hand side of quadratic equation (u)
initialconssshould model constraints be marked as initial?
dynamicconssshould model constraints be subject to aging?
dynamicrowsshould rows be added and removed dynamically to the LP?

Definition at line 1161 of file reader_fzn.c.

References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPaddCons(), SCIPcreateConsQuadratic(), SCIPdebugPrintCons, SCIPreleaseCons(), and TRUE.

Referenced by parseQuadratic().

static SCIP_RETCODE createLinearCons ( SCIP scip,
const char *  name,
int  nvars,
SCIP_VAR **  vars,
SCIP_Real vals,
SCIP_Real  lhs,
SCIP_Real  rhs,
SCIP_Bool  initialconss,
SCIP_Bool  dynamicconss,
SCIP_Bool  dynamicrows 
)
static

creates, adds, and releases a linear constraint

Parameters
scipSCIP data structure
namename of constraint
nvarsnumber of nonzeros in the constraint
varsarray with variables of constraint entries
valsarray with coefficients of constraint entries
lhsleft hand side of constraint
rhsright hand side of constraint
initialconssshould model constraints be marked as initial?
dynamicconssshould model constraints be subject to aging?
dynamicrowsshould rows be added and removed dynamically to the LP?

Definition at line 1193 of file reader_fzn.c.

References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPaddCons(), SCIPcreateConsLinear(), SCIPdebugPrintCons, SCIPreleaseCons(), and TRUE.

Referenced by applyVariableAssignment(), CREATE_CONSTRAINT(), createLinking(), parseAggregation(), parseConstraint(), and parseQuadratic().

static SCIP_RETCODE createLinking ( SCIP scip,
FZNINPUT fzninput,
const char *  consname,
const char *  name1,
const char *  name2,
SCIP_Real  lhs,
SCIP_Real  rhs 
)
static

create a linking between the two given identifiers

Parameters
scipSCIP data structure
fzninputFZN reading data
consnamename of constraint
name1name of first identifier
name2name of second identifier
lhsleft hand side of the linking
rhsright hand side of the linking

Definition at line 1221 of file reader_fzn.c.

References createLinearCons(), isValue(), NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPhashtableRetrieve(), and SCIPisInfinity().

Referenced by parseLinking().

static void parseArrayIndex ( SCIP scip,
FZNINPUT fzninput,
int *  idx 
)
static

parse array index expression

Parameters
scipSCIP data structure
fzninputFZN reading data
idxpointer to store the array index

Definition at line 1290 of file reader_fzn.c.

References FALSE, FZN_INT, getNextToken(), isChar(), isEndStatement(), isIdentifier(), isValue(), NULL, SCIP_Real, SCIPhashtableRetrieve(), and syntaxError().

Referenced by flattenAssignment().

static void flattenAssignment ( SCIP scip,
FZNINPUT fzninput,
char *  assignment 
)
static

unroll assignment if it is an array access one

Parameters
scipSCIP data structure
fzninputFZN reading data
assignmentassignment to unroll

Definition at line 1333 of file reader_fzn.c.

References FZN_BUFFERLEN, getNextToken(), isChar(), isEndStatement(), isIdentifier(), NULL, parseArrayIndex(), pushToken(), SCIPdebugMessage, SCIPsnprintf(), and syntaxError().

Referenced by CREATE_CONSTRAINT(), parseConstant(), parseConstraint(), parseList(), parseSolveItem(), and parseVariable().

static void computeLinearConsSides ( SCIP scip,
FZNINPUT fzninput,
const char *  name,
SCIP_Real  sidevalue,
SCIP_Real lhs,
SCIP_Real rhs 
)
static

computes w.r.t. to the given side value and relation the left and right side for a SCIP linear constraint

Parameters
scipSCIP data structure
fzninputFZN reading data
namename of the relation
sidevalueparsed side value
lhspointer to left hand side
rhspointer to right hand side

Definition at line 1394 of file reader_fzn.c.

References equalTokens(), SCIPdebugMessage, and syntaxError().

Referenced by CREATE_CONSTRAINT(), and parseLinking().

static SCIP_RETCODE parseList ( SCIP scip,
FZNINPUT fzninput,
char ***  elements,
int *  nelements,
int  selements 
)
static

parse a list of elements which is separates by a comma

Parameters
scipSCIP data structure
fzninputFZN reading data
elementspointer to char* array for storing the elements of the list
nelementspointer to store the number of elements
selementssize of the elements char* array

Definition at line 1437 of file reader_fzn.c.

References flattenAssignment(), FZN_BUFFERLEN, getNextToken(), hasError(), isChar(), pushToken(), SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, SCIPduplicateBufferArray, and SCIPreallocBufferArray.

Referenced by CREATE_CONSTRAINT(), parseAggregation(), parseArrayAssignment(), parseLinking(), and parseQuadratic().

static void parseRange ( SCIP scip,
FZNINPUT fzninput,
FZNNUMBERTYPE type,
SCIP_Real lb,
SCIP_Real ub 
)
static

parse range expression

Parameters
scipSCIP data structure
fzninputFZN reading data
typepointer to store the number type
lbpointer to store the lower bound
ubpointer to store the upper bound

Definition at line 1490 of file reader_fzn.c.

References equalTokens(), FZN_FLOAT, FZN_INT, getNextToken(), isValue(), SCIPisIntegral(), SCIPwarningMessage(), and syntaxError().

Referenced by parseArrayDimension(), parseOutputDimensioninfo(), parseType(), and readFZNFile().

static SCIP_RETCODE parseOutputDimensioninfo ( SCIP scip,
FZNINPUT fzninput,
DIMENSIONS **  info 
)
static

parse dimension information

Parameters
scipSCIP data structure
fzninputFZN reading data
infopointer to store the output dimension information if one

Definition at line 1538 of file reader_fzn.c.

References FZN_INT, getNextToken(), isChar(), parseRange(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocMemory, SCIPallocMemoryArray, SCIPreallocMemoryArray, and syntaxError().

Referenced by parseName().

static SCIP_RETCODE parseName ( SCIP scip,
FZNINPUT fzninput,
char *  name,
SCIP_Bool output,
DIMENSIONS **  info 
)
static

parse identifier name without annotations

Parameters
scipSCIP data structure
fzninputFZN reading data
namepointer to store the name
outputpointer to store if the name has the annotations to output
infopointer to store the output dimension information if one

Definition at line 1593 of file reader_fzn.c.

References equalTokens(), FALSE, FZN_BUFFERLEN, getNextToken(), isChar(), isEndStatement(), isIdentifier(), NULL, parseOutputDimensioninfo(), pushToken(), SCIP_CALL, SCIP_OKAY, SCIPsnprintf(), syntaxError(), and TRUE.

Referenced by parseArray(), parseConstant(), and parseVariable().

static void parseType ( SCIP scip,
FZNINPUT fzninput,
FZNNUMBERTYPE type,
SCIP_Real lb,
SCIP_Real ub 
)
static

parse variable/constant (array) type (integer, float, bool, or set)

Parameters
scipSCIP data structure
fzninputFZN reading data
typepointer to store the number type
lbpointer to store the lower bound
ubpointer to store the lower bound

Definition at line 1654 of file reader_fzn.c.

References equalTokens(), FALSE, FZN_BOOL, FZN_FLOAT, FZN_INT, getNextToken(), isChar(), isEndStatement(), parseRange(), pushToken(), SCIPdebugMessage, SCIPinfinity(), SCIPwarningMessage(), and syntaxError().

Referenced by parseArrayType(), and parseVariable().

static SCIP_RETCODE applyVariableAssignment ( SCIP scip,
FZNINPUT fzninput,
SCIP_VAR var,
FZNNUMBERTYPE  type,
const char *  assignment 
)
static

applies assignment

Parameters
scipSCIP data structure
fzninputFZN reading data
varvariable to assign something
typenumber type
assignmentassignment

Definition at line 1704 of file reader_fzn.c.

References createLinearCons(), FZN_BOOL, isBoolExp(), isValue(), NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPhashtableRetrieve(), and syntaxError().

Referenced by parseVariable(), and parseVariableArray().

static SCIP_RETCODE createConstantAssignment ( SCIP scip,
FZNCONSTANT **  constant,
FZNINPUT fzninput,
const char *  name,
FZNNUMBERTYPE  type,
const char *  assignment 
)
static

applies constant assignment expression

Parameters
scipSCIP data structure
constantpointer to constant
fzninputFZN reading data
nameconstant name
typenumber type
assignmentassignment to apply

Definition at line 1759 of file reader_fzn.c.

References FZN_BOOL, isBoolExp(), isValue(), NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBuffer, SCIPduplicateBufferArray, SCIPhashtableInsert(), SCIPhashtableRetrieve(), SCIPreallocBufferArray, and syntaxError().

Referenced by parseConstant(), and parseConstantArray().

static void parseArrayType ( SCIP scip,
FZNINPUT fzninput,
SCIP_Bool isvararray,
FZNNUMBERTYPE type,
SCIP_Real lb,
SCIP_Real ub 
)
static

parse array type ( (i) variable or constant; (ii) integer, float, bool, or set)

Parameters
scipSCIP data structure
fzninputFZN reading data
isvararraypointer to store if it is a variable or constant array
typepointer to store number type
lbpointer to store the lower bound
ubpointer to store the lower bound

Definition at line 1825 of file reader_fzn.c.

References equalTokens(), FALSE, getNextToken(), parseType(), pushToken(), syntaxError(), and TRUE.

Referenced by parseArray().

static SCIP_RETCODE parseArrayAssignment ( SCIP scip,
FZNINPUT fzninput,
char ***  elements,
int *  nelements,
int  selements 
)
static

parse an array assignment

Parameters
scipSCIP data structure
fzninputFZN reading data
elementspointer to string array to store the parsed elements
nelementspointer to store the number of parsed elements
selementssize of the string array elements

Definition at line 1862 of file reader_fzn.c.

References getNextToken(), hasError(), isChar(), NULL, parseList(), SCIP_CALL, SCIP_OKAY, and syntaxError().

Referenced by parseConstantArray(), parseConstantArrayAssignment(), parseVariableArray(), and parseVariableArrayAssignment().

static void parseArrayDimension ( SCIP scip,
FZNINPUT fzninput,
int *  nelements 
)
static

parse array dimension

Parameters
scipSCIP data structure
fzninputFZN reading data
nelementspointer to store the size of the array

Definition at line 1896 of file reader_fzn.c.

References FZN_INT, getNextToken(), isChar(), parseRange(), SCIP_Real, and syntaxError().

Referenced by parseArray().

static SCIP_RETCODE createVariable ( SCIP scip,
FZNINPUT fzninput,
SCIP_VAR **  var,
const char *  name,
SCIP_Real  lb,
SCIP_Real  ub,
FZNNUMBERTYPE  type 
)
static

creates and adds a variable to SCIP and stores it for latter use in fzninput structure

Parameters
scipSCIP data structure
fzninputFZN reading data
varpointer to hold the created variable, or NULL
namename of the variable
lblower bound of the variable
ubupper bound of the variable
typenumber type

Definition at line 1935 of file reader_fzn.c.

References FZN_BOOL, FZN_FLOAT, FZN_INT, NULL, SCIP_CALL, SCIP_OKAY, SCIP_VARTYPE_BINARY, SCIP_VARTYPE_CONTINUOUS, SCIP_VARTYPE_INTEGER, SCIPaddVar(), SCIPcreateVar(), SCIPdebug, SCIPdebugMessage, SCIPhashtableInsert(), SCIPhashtableRetrieve(), SCIPprintVar(), SCIPreleaseVar(), and syntaxError().

Referenced by parseVariable(), parseVariableArray(), parseVariableArrayAssignment(), and readFZNFile().

static SCIP_RETCODE parseVariableArray ( SCIP scip,
SCIP_READERDATA readerdata,
FZNINPUT fzninput,
const char *  name,
int  nvars,
FZNNUMBERTYPE  type,
SCIP_Real  lb,
SCIP_Real  ub,
DIMENSIONS info 
)
static

parse variable array assignment and create the variables

Parameters
scipSCIP data structure
readerdatareader data
fzninputFZN reading data
namearray name
nvarsnumber of variables
typenumber type
lblower bound of the variables
ublower bound of the variables
infodimension information

Definition at line 1994 of file reader_fzn.c.

References applyVariableAssignment(), createVariable(), freeStringBufferArray(), FZN_BUFFERLEN, fzninputAddVararray(), getNextToken(), hasError(), isChar(), isEndStatement(), NULL, parseArrayAssignment(), pushToken(), readerdataAddOutputvararray(), SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPsnprintf(), and syntaxError().

Referenced by parseArray().

static SCIP_RETCODE parseConstantArray ( SCIP scip,
FZNINPUT fzninput,
const char *  name,
int  nconstants,
FZNNUMBERTYPE  type 
)
static

parse constant array assignment and create the constants

Parameters
scipSCIP data structure
fzninputFZN reading data
namearray name
nconstantsnumber of constants
typenumber type

Definition at line 2071 of file reader_fzn.c.

References createConstantAssignment(), freeStringBufferArray(), FZN_BUFFERLEN, fzninputAddConstarray(), getNextToken(), hasError(), isChar(), parseArrayAssignment(), SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPsnprintf(), and syntaxError().

Referenced by parseArray().

static SCIP_RETCODE parsePredicate ( SCIP scip,
FZNINPUT fzninput 
)
static

parse predicate expression

Parameters
scipSCIP data structure
fzninputFZN reading data

Definition at line 2117 of file reader_fzn.c.

References SCIP_OKAY, and TRUE.

Referenced by readFZNFile().

static SCIP_RETCODE parseArray ( SCIP scip,
SCIP_READERDATA readerdata,
FZNINPUT fzninput 
)
static

parse array expression

Parameters
scipSCIP data structure
readerdatareader data
fzninputFZN reading data

Definition at line 2130 of file reader_fzn.c.

References FALSE, freeDimensions(), FZN_BOOL, FZN_BUFFERLEN, FZN_INT, hasError(), NULL, parseArrayDimension(), parseArrayType(), parseConstantArray(), parseName(), parseVariableArray(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, and SCIPdebugMessage.

Referenced by readFZNFile().

static SCIP_RETCODE parseVariable ( SCIP scip,
SCIP_READERDATA readerdata,
FZNINPUT fzninput 
)
static

parse variable expression

Parameters
scipSCIP data structure
readerdatareader data
fzninputFZN reading data

Definition at line 2190 of file reader_fzn.c.

References applyVariableAssignment(), createVariable(), flattenAssignment(), FZN_BOOL, FZN_BUFFERLEN, FZN_FLOAT, FZN_INT, getNextToken(), hasError(), isChar(), NULL, parseName(), parseType(), pushToken(), readerdataAddOutputvar(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPdebugMessage, and syntaxError().

Referenced by readFZNFile().

static SCIP_RETCODE parseConstant ( SCIP scip,
FZNINPUT fzninput,
FZNNUMBERTYPE  type 
)
static

parse constant expression

Parameters
scipSCIP data structure
fzninputFZN reading data
typeconstant type

Definition at line 2254 of file reader_fzn.c.

References createConstantAssignment(), flattenAssignment(), FZN_BOOL, FZN_BUFFERLEN, FZN_FLOAT, FZN_INT, getNextToken(), hasError(), isChar(), NULL, parseName(), SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, and syntaxError().

Referenced by readFZNFile().

static void parseValue ( SCIP scip,
FZNINPUT fzninput,
SCIP_Real value,
const char *  assignment 
)
static

evaluates current token as constant

Parameters
scipSCIP data structure
fzninputFZN reading data
valuepointer to store value
assignmentassignment to parse a value

Definition at line 2293 of file reader_fzn.c.

References isIdentifier(), isValue(), NULL, SCIPhashtableRetrieve(), SCIPisEQ(), SCIPvarGetLbOriginal(), SCIPvarGetUbOriginal(), and syntaxError().

Referenced by CREATE_CONSTRAINT(), parseAggregation(), parseConstantArrayAssignment(), and parseQuadratic().

static SCIP_RETCODE parseConstantArrayAssignment ( SCIP scip,
FZNINPUT fzninput,
SCIP_Real **  vals,
int *  nvals,
int  sizevals 
)
static

parse array expression containing constants

Parameters
scipSCIP data structure
fzninputFZN reading data
valspointer to value array
nvalspointer to store the number if values
sizevalssize of the vals array

Definition at line 2336 of file reader_fzn.c.

References findConstarray(), findVararray(), freeStringBufferArray(), getNextToken(), hasError(), isChar(), NULL, parseArrayAssignment(), parseValue(), pushToken(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPisEQ(), SCIPreallocBufferArray, SCIPvarGetLbOriginal(), SCIPvarGetUbOriginal(), and syntaxError().

Referenced by CREATE_CONSTRAINT(), and parseSolveItem().

static SCIP_RETCODE parseVariableArrayAssignment ( SCIP scip,
FZNINPUT fzninput,
SCIP_VAR ***  vars,
int *  nvars,
int  sizevars 
)
static

parse array expression containing variables

Parameters
scipSCIP data structure
fzninputFZN reading data
varspointer to variable array
nvarspointer to store the number if variable
sizevarssize of the variable array

Definition at line 2462 of file reader_fzn.c.

References createVariable(), findVararray(), freeStringBufferArray(), FZN_FLOAT, getNextToken(), isChar(), isValue(), NULL, parseArrayAssignment(), pushToken(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPhashtableRetrieve(), SCIPreallocBufferArray, and syntaxError().

Referenced by CREATE_CONSTRAINT(), and parseSolveItem().

static SCIP_RETCODE parseQuadratic ( SCIP scip,
FZNINPUT fzninput,
const char *  name 
)
static

parse linking statement

Parameters
scipSCIP data structure
fzninputFZN reading data
namename of constraint

Definition at line 2572 of file reader_fzn.c.

References createLinearCons(), createQuadraticCons(), freeStringBufferArray(), hasError(), NULL, parseList(), parseValue(), SCIP_CALL, SCIP_INVALID, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPhashtableRetrieve(), and SCIPswapPointers().

Referenced by CREATE_CONSTRAINT().

static SCIP_RETCODE parseAggregation ( SCIP scip,
FZNINPUT fzninput,
const char *  name,
const char *  type 
)
static

parse aggregation statement (plus, minus, negate)

Parameters
scipSCIP data structure
fzninputFZN reading data
namename of constraint
typelinear constraint type

Definition at line 2701 of file reader_fzn.c.

References createLinearCons(), equalTokens(), freeStringBufferArray(), hasError(), NULL, parseList(), parseValue(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, and SCIPhashtableRetrieve().

Referenced by CREATE_CONSTRAINT().

static SCIP_RETCODE parseLinking ( SCIP scip,
FZNINPUT fzninput,
const char *  name,
const char *  type,
SCIP_Real  sidevalue 
)
static

parse linking statement

Parameters
scipSCIP data structure
fzninputFZN reading data
namename of constraint
typelinear constraint type
sidevalueside value of constraint

Definition at line 2810 of file reader_fzn.c.

References computeLinearConsSides(), createLinking(), freeStringBufferArray(), hasError(), parseList(), SCIP_CALL, SCIP_INVALID, SCIP_OKAY, SCIP_Real, and SCIPallocBufferArray.

Referenced by CREATE_CONSTRAINT().

static CREATE_CONSTRAINT ( createCoercionOpCons  )
static

creates a linear constraint for an array operation

Definition at line 2848 of file reader_fzn.c.

References equalTokens(), NULL, parseLinking(), SCIP_CALL, SCIP_OKAY, and TRUE.

static CREATE_CONSTRAINT ( createSetOpCons  )
static

creates a linear constraint for an array operation

Definition at line 2866 of file reader_fzn.c.

References equalTokens(), FALSE, NULL, SCIP_OKAY, and SCIPwarningMessage().

static CREATE_CONSTRAINT ( createArrayOpCons  )
static

creates linear constraint for an array operation

Definition at line 2883 of file reader_fzn.c.

References equalTokens(), FALSE, NULL, SCIP_OKAY, and SCIPwarningMessage().

static CREATE_CONSTRAINT ( createAlldifferentOpCons  )
static
static CREATE_CONSTRAINT ( *[]  constypes)
static
static SCIP_RETCODE parseConstraint ( SCIP scip,
FZNINPUT fzninput 
)
static
static SCIP_RETCODE parseSolveItem ( SCIP scip,
FZNINPUT fzninput 
)
static
static SCIP_RETCODE readFZNFile ( SCIP scip,
SCIP_READERDATA readerdata,
FZNINPUT fzninput,
const char *  filename 
)
static
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 3856 of file reader_fzn.c.

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

Referenced by printLinearCons().

static void writeBuffer ( SCIP scip,
FILE *  file,
char *  buffer,
int  bufferpos 
)
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)
bufferline
bufferposnumber of characters in buffer

Definition at line 3900 of file reader_fzn.c.

References NULL, and SCIPinfoMessage().

Referenced by writeFzn().

static SCIP_RETCODE appendBuffer ( SCIP scip,
char **  buffer,
int *  bufferlen,
int *  bufferpos,
const char *  extension 
)
static

appends extension to line and prints it to the give file stream if the line buffer get full

Parameters
scipSCIP data structure
bufferbuffer which should be extended
bufferlenlength of the buffer
bufferposcurrent position in the buffer
extensionstring to extend the line

Definition at line 3920 of file reader_fzn.c.

References MAX, NULL, SCIP_CALL, SCIP_OKAY, and SCIPreallocBufferArray.

Referenced by printLinearCons(), printRow(), and writeFzn().

static void flattenFloat ( SCIP scip,
SCIP_Real  val,
char *  buffer 
)
static
Parameters
scipSCIP data structure
valvalue to flatten
bufferstring buffer to print in

Definition at line 3954 of file reader_fzn.c.

References FZN_BUFFERLEN, SCIPisIntegral(), SCIPround(), and SCIPsnprintf().

Referenced by printRow(), and writeFzn().

static SCIP_RETCODE printRow ( SCIP scip,
FZNOUTPUT fznoutput,
const char *  type,
SCIP_VAR **  vars,
SCIP_Real vals,
int  nvars,
SCIP_Real  rhs,
SCIP_Bool  hasfloats 
)
static
Parameters
scipSCIP data structure
fznoutputoutput data structure containing the buffers to write to
typerow type ("eq", "le" or "ge")
varsarray of variables
valsarray of values
nvarsnumber of variables
rhsright hand side
hasfloatsare there continuous variables or coefficients in the constraint?

Definition at line 3969 of file reader_fzn.c.

References appendBuffer(), flattenFloat(), FZN_BUFFERLEN, NULL, SCIP_CALL, SCIP_OKAY, SCIPisZero(), SCIPsnprintf(), SCIPvarGetName(), and SCIPvarGetProbindex().

Referenced by printLinearCons().

static SCIP_RETCODE printLinearCons ( SCIP scip,
FZNOUTPUT fznoutput,
SCIP_VAR **  vars,
SCIP_Real vals,
int  nvars,
SCIP_Real  lhs,
SCIP_Real  rhs,
SCIP_Bool  transformed,
SCIP_Bool  mayhavefloats 
)
static

prints given linear constraint information in FZN format to file stream

Parameters
scipSCIP data structure
fznoutputoutput data structure containing the buffers to write to
varsarray of variables
valsarray of coefficients values (or NULL if all coefficient values are 1)
nvarsnumber of variables
lhsleft hand side
rhsright hand side
transformedtransformed constraint?
mayhavefloatsmay there be continuous variables in the constraint?

Definition at line 4070 of file reader_fzn.c.

References appendBuffer(), FALSE, FZN_BUFFERLEN, getActiveVariables(), NULL, printRow(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_BINARY, SCIP_VARTYPE_INTEGER, SCIPallocBufferArray, SCIPduplicateBufferArray, SCIPfreeBufferArray, SCIPisEQ(), SCIPisInfinity(), SCIPisIntegral(), SCIPsnprintf(), SCIPvarGetName(), SCIPvarGetProbindex(), SCIPvarGetType(), and TRUE.

Referenced by writeFzn().

static SCIP_RETCODE writeFzn ( 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
Parameters
scipSCIP data structure
fileoutput file, or NULL if standard output should be used
nameproblem name
transformedTRUE iff problem is the transformed problem
objsenseobjective sense
objscalescalar applied to objective function; external objective value is extobj = objsense * objscale * (intobj + objoffset)
objoffsetobjective offset from bound shifting and fixing
varsarray with active variables ordered binary, integer, implicit, continuous
nvarsnumber of active variables in the problem
nbinvarsnumber of binary variables
nintvarsnumber of general integer variables
nimplvarsnumber of implicit integer variables
ncontvarsnumber of continuous variables
conssarray with constraints of the problem
nconssnumber of constraints in the problem
resultpointer to store the result of the file writing call

Definition at line 4208 of file reader_fzn.c.

References appendBuffer(), FALSE, flattenFloat(), FZN_BUFFERLEN, NULL, printLinearCons(), SCIP_Bool, SCIP_BOUNDTYPE_LOWER, SCIP_BOUNDTYPE_UPPER, SCIP_CALL, SCIP_Longint, SCIP_MAXSTRLEN, SCIP_OBJSENSE_MINIMIZE, SCIP_OKAY, SCIP_Real, SCIP_SETPPCTYPE_COVERING, SCIP_SETPPCTYPE_PACKING, SCIP_SETPPCTYPE_PARTITIONING, SCIP_SUCCESS, SCIP_VARTYPE_BINARY, SCIP_VARTYPE_CONTINUOUS, SCIP_VARTYPE_IMPLINT, SCIP_VARTYPE_INTEGER, SCIPallocBufferArray, SCIPconsGetHdlr(), SCIPconshdlrGetName(), SCIPconsIsEnabled(), SCIPconsIsTransformed(), SCIPdebugMessage, SCIPfreeBufferArray, SCIPgetCapacityCumulative(), SCIPgetCapacityKnapsack(), SCIPgetDemandsCumulative(), SCIPgetDurationsCumulative(), SCIPgetLhsLinear(), SCIPgetLhsVarbound(), SCIPgetNVarsCumulative(), SCIPgetNVarsKnapsack(), SCIPgetNVarsLinear(), SCIPgetNVarsLogicor(), SCIPgetNVarsSetppc(), SCIPgetRhsLinear(), SCIPgetRhsVarbound(), SCIPgetTypeSetppc(), SCIPgetValsLinear(), SCIPgetVarsCumulative(), SCIPgetVarsKnapsack(), SCIPgetVarsLinear(), SCIPgetVarsLogicor(), SCIPgetVarsSetppc(), SCIPgetVarVarbound(), SCIPgetVbdcoefVarbound(), SCIPgetVbdvarVarbound(), SCIPgetWeightsKnapsack(), SCIPinfinity(), SCIPinfoMessage(), SCIPisEQ(), SCIPisFeasIntegral(), SCIPisInfinity(), SCIPisIntegral(), SCIPisZero(), SCIPsnprintf(), SCIPvarGetLbLocal(), SCIPvarGetLbOriginal(), SCIPvarGetName(), SCIPvarGetObj(), SCIPvarGetType(), SCIPvarGetUbLocal(), SCIPvarGetUbOriginal(), SCIPwarningMessage(), TRUE, and writeBuffer().

Referenced by SCIP_DECL_READERWRITE().

static SCIP_DECL_READERCOPY ( readerCopyFzn  )
static

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

Definition at line 4704 of file reader_fzn.c.

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

static SCIP_DECL_READERFREE ( readerFreeFzn  )
static

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

Definition at line 4719 of file reader_fzn.c.

References freeVararray(), NULL, SCIP_OKAY, SCIPfreeMemory, SCIPfreeMemoryArrayNull, and SCIPreaderGetData().

static SCIP_DECL_READERWRITE ( readerWriteFzn  )
static
SCIP_RETCODE SCIPincludeReaderFzn ( SCIP scip)

includes the fzn file reader in SCIP

Parameters
scipSCIP data structure

Definition at line 4903 of file reader_fzn.c.

References READER_DESC, READER_EXTENSION, READER_NAME, readerdataCreate(), SCIP_CALL, SCIP_OKAY, SCIPincludeReaderBasic(), SCIPsetReaderCopy(), SCIPsetReaderFree(), SCIPsetReaderRead(), and SCIPsetReaderWrite().

Referenced by SCIP_DECL_READERCOPY(), and SCIPincludeDefaultPlugins().

SCIP_RETCODE SCIPprintSolReaderFzn ( SCIP scip,
SCIP_SOL sol,
FILE *  file 
)

print given solution in Flatzinc format w.r.t. the output annotation

Parameters
scipSCIP data structure
solprimal solution, or NULL for current LP/pseudo solution
fileoutput file (or NULL for standard output)

Definition at line 4926 of file reader_fzn.c.

References NULL, printValue(), READER_NAME, SCIP_OKAY, SCIP_Real, SCIPfindReader(), SCIPgetSolVal(), SCIPinfoMessage(), SCIPreaderGetData(), and SCIPsortPtr().

Variable Documentation

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

Definition at line 196 of file reader_fzn.c.

Referenced by getMaxAndConsDim(), and isDelimChar().

const char tokenchars[] = ":<>=;{}[],()"
static

Definition at line 197 of file reader_fzn.c.

Referenced by isTokenChar().

const char commentchars[] = "%"
static

Definition at line 198 of file reader_fzn.c.

Referenced by getNextLine().

int nconstypes = 7
static

size of the function pointer array

Definition at line 3418 of file reader_fzn.c.

Referenced by parseConstraint().