Scippy

SCIP

Solving Constraint Integer Programs

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 https://www.minizinc.org. The format is described at https://github.com/MiniZinc/minizinc-doc/blob/develop/en/fzn-spec.rst.

Definition in file reader_fzn.c.

#include "blockmemshell/memory.h"
#include <ctype.h>
#include "scip/cons_nonlinear.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_setppc.h"
#include "scip/cons_varbound.h"
#include "scip/cons_xor.h"
#include "scip/pub_cons.h"
#include "scip/pub_fileio.h"
#include "scip/pub_message.h"
#include "scip/pub_misc.h"
#include "scip/pub_misc_sort.h"
#include "scip/pub_reader.h"
#include "scip/pub_var.h"
#include "scip/reader_fzn.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_sol.h"
#include "scip/scip_solvingstats.h"
#include "scip/scip_var.h"
#include <stdlib.h>
#include <string.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_INIT_LINELEN   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 (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 (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 (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 const int nconstypes = 7
 

Macro Definition Documentation

◆ READER_NAME

#define READER_NAME   "fznreader"

Definition at line 77 of file reader_fzn.c.

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

◆ READER_DESC

#define READER_DESC   "file reader for FlatZinc format"

Definition at line 78 of file reader_fzn.c.

Referenced by SCIPincludeReaderFzn().

◆ READER_EXTENSION

#define READER_EXTENSION   "fzn"

Definition at line 79 of file reader_fzn.c.

Referenced by SCIPincludeReaderFzn().

◆ FZN_BUFFERLEN

◆ FZN_INIT_LINELEN

#define FZN_INIT_LINELEN   65536

initial size of the line buffer for reading

Definition at line 83 of file reader_fzn.c.

Referenced by SCIP_DECL_READERREAD().

◆ FZN_MAX_PUSHEDTOKENS

#define FZN_MAX_PUSHEDTOKENS   1

Definition at line 84 of file reader_fzn.c.

Referenced by pushToken(), and SCIP_DECL_READERREAD().

◆ CREATE_CONSTRAINT

#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 168 of file reader_fzn.c.

Referenced by CREATE_CONSTRAINT().

Typedef Documentation

◆ FZNNUMBERTYPE

Definition at line 97 of file reader_fzn.c.

◆ FZNEXPTYPE

typedef enum FznExpType FZNEXPTYPE

Definition at line 106 of file reader_fzn.c.

◆ DIMENSIONS

typedef struct Dimensions DIMENSIONS

Definition at line 116 of file reader_fzn.c.

◆ FZNCONSTANT

typedef struct FznConstant FZNCONSTANT

Definition at line 125 of file reader_fzn.c.

◆ CONSTARRAY

typedef struct ConstArray CONSTARRAY

Definition at line 135 of file reader_fzn.c.

◆ VARARRAY

typedef struct VarArray VARARRAY

Definition at line 146 of file reader_fzn.c.

◆ FZNINPUT

typedef struct FznInput FZNINPUT

Definition at line 206 of file reader_fzn.c.

◆ FZNOUTPUT

typedef struct FznOutput FZNOUTPUT

Definition at line 223 of file reader_fzn.c.

Enumeration Type Documentation

◆ FznNumberType

number types

Enumerator
FZN_BOOL 
FZN_INT 
FZN_FLOAT 

Definition at line 91 of file reader_fzn.c.

◆ FznExpType

enum FznExpType

Expression type in FlatZinc File

Enumerator
FZN_EXP_NONE 
FZN_EXP_UNSIGNED 
FZN_EXP_SIGNED 

Definition at line 100 of file reader_fzn.c.

Function Documentation

◆ SCIP_DECL_HASHGETKEY() [1/2]

static SCIP_DECL_HASHGETKEY ( hashGetKeyVar  )
static

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

Definition at line 235 of file reader_fzn.c.

References NULL, and SCIPvarGetName().

◆ SCIP_DECL_HASHGETKEY() [2/2]

static SCIP_DECL_HASHGETKEY ( hashGetKeyConstant  )
static

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

Definition at line 245 of file reader_fzn.c.

References NULL.

◆ SCIP_DECL_SORTPTRCOMP()

static SCIP_DECL_SORTPTRCOMP ( vararraysComp  )
static

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

Definition at line 255 of file reader_fzn.c.

◆ freeStringBufferArray()

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 263 of file reader_fzn.c.

References SCIPfreeBufferArray.

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

◆ isDelimChar()

static SCIP_Bool isDelimChar ( char  c)
static

returns whether the given character is a token delimiter

Parameters
cinput character

Definition at line 279 of file reader_fzn.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 288 of file reader_fzn.c.

References NULL, and tokenchars.

Referenced by getNextToken().

◆ isChar()

static SCIP_Bool isChar ( const char *  token,
char  c 
)
static

◆ isBoolExp()

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 310 of file reader_fzn.c.

References FALSE, and TRUE.

Referenced by applyVariableAssignment(), and createConstantAssignment().

◆ isIdentifier()

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 345 of file reader_fzn.c.

References FALSE, and TRUE.

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

◆ isValueChar()

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 368 of file reader_fzn.c.

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

Referenced by getNextToken().

◆ equalTokens()

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

compares two token if they are equal

Parameters
token1first token
token2second token

Definition at line 412 of file reader_fzn.c.

References FALSE, and NULL.

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

◆ getNextLine()

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 430 of file reader_fzn.c.

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

Referenced by getNextToken().

◆ getNextToken()

static SCIP_Bool getNextToken ( SCIP scip,
FZNINPUT fzninput 
)
static

◆ pushToken()

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 609 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().

◆ isEndStatement()

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 622 of file reader_fzn.c.

References isChar(), and NULL.

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

◆ isValue()

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 633 of file reader_fzn.c.

References FALSE, NULL, and TRUE.

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

◆ syntaxError()

static void syntaxError ( SCIP scip,
FZNINPUT fzninput,
const char *  msg 
)
static

◆ hasError()

static SCIP_Bool hasError ( FZNINPUT fzninput)
static

◆ readerdataCreate()

static SCIP_RETCODE readerdataCreate ( SCIP scip,
SCIP_READERDATA **  readerdata 
)
static

create reader data

Parameters
scipSCIP data structure
readerdatapointer to reader data

Definition at line 687 of file reader_fzn.c.

References NULL, SCIP_CALL, SCIP_OKAY, and SCIPallocBlockMemory.

Referenced by SCIPincludeReaderFzn().

◆ ensureVararrySize()

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 703 of file reader_fzn.c.

References SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemoryArray, and SCIPreallocBlockMemoryArray.

Referenced by readerdataAddOutputvar(), and readerdataAddOutputvararray().

◆ ensureVararrySizeFznInput()

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 735 of file reader_fzn.c.

References SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemoryArray, and SCIPreallocBlockMemoryArray.

Referenced by fzninputAddVararray().

◆ ensureConstarrySizeFznInput()

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 767 of file reader_fzn.c.

References SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemoryArray, and SCIPreallocBlockMemoryArray.

Referenced by fzninputAddConstarray().

◆ printValue()

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 799 of file reader_fzn.c.

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

Referenced by SCIPincludeExprhdlrValue(), and SCIPprintSolReaderFzn().

◆ copyDimensions()

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 843 of file reader_fzn.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory, and SCIPduplicateBlockMemoryArray.

Referenced by createVararray().

◆ 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 866 of file reader_fzn.c.

References copyDimensions(), SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory, and SCIPduplicateBlockMemoryArray.

Referenced by fzninputAddVararray(), and readerdataAddOutputvararray().

◆ freeDimensions()

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

free dimension structure

Parameters
scipSCIP data structure
dimpointer to dimension structure

Definition at line 895 of file reader_fzn.c.

References NULL, SCIPfreeBlockMemory, and SCIPfreeBlockMemoryArrayNull.

Referenced by freeVararray(), and parseArray().

◆ freeVararray()

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

free variable array data structure

Parameters
scipSCIP data structure
vararraypointer to variable array

Definition at line 910 of file reader_fzn.c.

References freeDimensions(), SCIPfreeBlockMemory, and SCIPfreeBlockMemoryArray.

Referenced by SCIP_DECL_READERFREE(), and SCIP_DECL_READERREAD().

◆ findVararray()

static VARARRAY* findVararray ( 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
fzninputFZN reading data
namevariable array name

Definition at line 925 of file reader_fzn.c.

References equalTokens(), and NULL.

Referenced by parseConstantArrayAssignment(), and parseVariableArrayAssignment().

◆ createConstarray()

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 951 of file reader_fzn.c.

References SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory, SCIPdebugMsg, and SCIPduplicateBlockMemoryArray.

Referenced by fzninputAddConstarray().

◆ freeConstarray()

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

free constant array data structure

Parameters
scipSCIP data structure
constarraypointer to constant array

Definition at line 979 of file reader_fzn.c.

References SCIPdebugMsg, SCIPfreeBlockMemory, and SCIPfreeBlockMemoryArray.

Referenced by SCIP_DECL_READERREAD().

◆ findConstarray()

static CONSTARRAY* findConstarray ( 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
fzninputFZN reading data
nameconstant array name

Definition at line 998 of file reader_fzn.c.

References equalTokens(), and NULL.

Referenced by parseConstantArrayAssignment().

◆ readerdataAddOutputvar()

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 1020 of file reader_fzn.c.

References ensureVararrySize(), NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory, SCIPduplicateBlockMemoryArray, and SCIPvarGetName().

Referenced by parseVariable().

◆ readerdataAddOutputvararray()

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 1067 of file reader_fzn.c.

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

Referenced by parseVariableArray().

◆ fzninputAddVararray()

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 1096 of file reader_fzn.c.

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

Referenced by parseVariableArray().

◆ fzninputAddConstarray()

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 1125 of file reader_fzn.c.

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

Referenced by parseConstantArray().

◆ createQuadraticCons()

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 quadratic 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 1153 of file reader_fzn.c.

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

Referenced by parseQuadratic().

◆ createLinearCons()

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 1186 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().

◆ createLinking()

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 1214 of file reader_fzn.c.

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

Referenced by parseLinking().

◆ parseArrayIndex()

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 1283 of file reader_fzn.c.

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

Referenced by flattenAssignment().

◆ 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 1326 of file reader_fzn.c.

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

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

◆ computeLinearConsSides()

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 1387 of file reader_fzn.c.

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

Referenced by CREATE_CONSTRAINT(), and parseLinking().

◆ parseList()

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 1430 of file reader_fzn.c.

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

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

◆ parseRange()

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 1482 of file reader_fzn.c.

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

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

◆ parseOutputDimensioninfo()

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 1533 of file reader_fzn.c.

References FZN_INT, getNextToken(), isChar(), parseRange(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBlockMemory, SCIPallocBlockMemoryArray, SCIPreallocBlockMemoryArray, and syntaxError().

Referenced by parseName().

◆ 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 1594 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().

◆ parseType()

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(), SCIPdebugMsg, SCIPinfinity(), SCIPwarningMessage(), and syntaxError().

Referenced by parseArrayType(), and parseVariable().

◆ applyVariableAssignment()

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 1707 of file reader_fzn.c.

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

Referenced by parseVariable(), and parseVariableArray().

◆ createConstantAssignment()

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 1763 of file reader_fzn.c.

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

Referenced by parseConstant(), and parseConstantArray().

◆ parseArrayType()

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 1831 of file reader_fzn.c.

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

Referenced by parseArray().

◆ parseArrayAssignment()

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 1868 of file reader_fzn.c.

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

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

◆ parseArrayDimension()

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 1902 of file reader_fzn.c.

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

Referenced by parseArray().

◆ createVariable()

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 1941 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, SCIPdebugMsg, SCIPhashtableInsert(), SCIPhashtableRetrieve(), SCIPprintVar(), SCIPreleaseVar(), and syntaxError().

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

◆ parseVariableArray()

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 2000 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().

◆ parseConstantArray()

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 2077 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().

◆ parsePredicate()

static SCIP_RETCODE parsePredicate ( SCIP scip,
FZNINPUT fzninput 
)
static

parse predicate expression

Parameters
scipSCIP data structure
fzninputFZN reading data

Definition at line 2123 of file reader_fzn.c.

References NULL, SCIP_OKAY, and TRUE.

Referenced by readFZNFile().

◆ parseArray()

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 2138 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 SCIPdebugMsg.

Referenced by readFZNFile().

◆ parseVariable()

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 2198 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, SCIPdebugMsg, and syntaxError().

Referenced by readFZNFile().

◆ parseConstant()

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 2262 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, SCIPdebugMsg, and syntaxError().

Referenced by readFZNFile().

◆ parseValue()

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 2301 of file reader_fzn.c.

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

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

◆ parseConstantArrayAssignment()

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 2344 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().

◆ parseVariableArrayAssignment()

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 2470 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().

◆ parseQuadratic()

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 2580 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().

◆ parseAggregation()

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 2709 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().

◆ parseLinking()

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 2818 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().

◆ CREATE_CONSTRAINT() [1/8]

static CREATE_CONSTRAINT ( createCoercionOpCons  )
static

creates a linear constraint for an array operation

Definition at line 2856 of file reader_fzn.c.

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

◆ CREATE_CONSTRAINT() [2/8]

static CREATE_CONSTRAINT ( createSetOpCons  )
static

creates a linear constraint for an array operation

Definition at line 2874 of file reader_fzn.c.

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

◆ CREATE_CONSTRAINT() [3/8]

static CREATE_CONSTRAINT ( createArrayOpCons  )
static

creates linear constraint for an array operation

Definition at line 2891 of file reader_fzn.c.

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

◆ CREATE_CONSTRAINT() [4/8]

◆ CREATE_CONSTRAINT() [5/8]

◆ CREATE_CONSTRAINT() [6/8]

static CREATE_CONSTRAINT ( createAlldifferentOpCons  )
static

◆ CREATE_CONSTRAINT() [7/8]

◆ CREATE_CONSTRAINT() [8/8]

static CREATE_CONSTRAINT ( *[]  constypes)
static

◆ parseConstraint()

static SCIP_RETCODE parseConstraint ( SCIP scip,
FZNINPUT fzninput 
)
static

◆ parseSolveItem()

static SCIP_RETCODE parseSolveItem ( SCIP scip,
FZNINPUT fzninput 
)
static

◆ readFZNFile()

static SCIP_RETCODE readFZNFile ( SCIP scip,
SCIP_READERDATA readerdata,
FZNINPUT fzninput,
const char *  filename 
)
static

◆ 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 3865 of file reader_fzn.c.

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

Referenced by printLinearCons().

◆ writeBuffer()

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 3918 of file reader_fzn.c.

References NULL, and SCIPinfoMessage().

Referenced by writeFzn().

◆ appendBuffer()

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 3938 of file reader_fzn.c.

References MAX, NULL, SCIP_CALL, SCIP_OKAY, SCIPreallocBufferArray, and SCIPstrncpy().

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

◆ flattenFloat()

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 3974 of file reader_fzn.c.

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

Referenced by printRow(), and writeFzn().

◆ printRow()

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 3988 of file reader_fzn.c.

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

Referenced by printLinearCons().

◆ 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 4091 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().

◆ 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 4233 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(), SCIPdebugMsg, 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().

◆ SCIP_DECL_READERCOPY()

static SCIP_DECL_READERCOPY ( readerCopyFzn  )
static

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

Definition at line 4729 of file reader_fzn.c.

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

◆ SCIP_DECL_READERFREE()

static SCIP_DECL_READERFREE ( readerFreeFzn  )
static

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

Definition at line 4744 of file reader_fzn.c.

References freeVararray(), NULL, SCIP_OKAY, SCIPfreeBlockMemory, SCIPfreeBlockMemoryArrayNull, and SCIPreaderGetData().

◆ SCIP_DECL_READERREAD()

◆ SCIP_DECL_READERWRITE()

static SCIP_DECL_READERWRITE ( readerWriteFzn  )
static

Variable Documentation

◆ delimchars

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

Definition at line 225 of file reader_fzn.c.

Referenced by getMaxAndConsDim(), and isDelimChar().

◆ tokenchars

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

Definition at line 226 of file reader_fzn.c.

Referenced by isTokenChar().

◆ commentchars

const char commentchars[] = "%"
static

Definition at line 227 of file reader_fzn.c.

Referenced by getNextLine().

◆ nconstypes

const int nconstypes = 7
static

size of the function pointer array

Definition at line 3424 of file reader_fzn.c.

Referenced by parseConstraint().