pseudo-Boolean file reader (opb format)
This file reader parses the opb format and is also used by the wbo reader for the wbo format. For a detailed description of this format see
The syntax of the input file format can be described by a simple Backus-Naur form. <formula> is the start symbol of this grammar.
<formula>::= <sequence_of_comments> [<objective>] | [<softheader>] <sequence_of_comments_or_constraints>
<sequence_of_comments>::= <comment> [<sequence_of_comments>] <comment>::= "*" <any_sequence_of_characters_other_than_EOL> <EOL> <sequence_of_comments_or_constraints>::=<comment_or_constraint> [<sequence_of_comments_or_constraints>] <comment_or_constraint>::=<comment>|<constraint>
<objective>::= "min:" <zeroOrMoreSpace> <sum> ";" <constraint>::= <sum> <relational_operator> <zeroOrMoreSpace> <integer> <zeroOrMoreSpace> ";"
<sum>::= <weightedterm> | <weightedterm> <sum> <weightedterm>::= <integer> <oneOrMoreSpace> <term> <oneOrMoreSpace>
<integer>::= <unsigned_integer> | "+" <unsigned_integer> | "-" <unsigned_integer> <unsigned_integer>::= <digit> | <digit><unsigned_integer>
<relational_operator>::= "\>=" | "="
<variablename>::= "x" <unsigned_integer>
<oneOrMoreSpace>::= " " [<oneOrMoreSpace>] <zeroOrMoreSpace>::= [" " <zeroOrMoreSpace>]
For linear pseudo-Boolean instances, <term> is defined as
<term>::=<variablename>
For non-linear instances, <term> is defined as
<term>::= <oneOrMoreLiterals> <oneOrMoreLiterals>::= <literal> | <literal> <oneOrMoreSpace> <oneOrMoreLiterals> <literal>::= <variablename> | "~"<variablename>
For wbo-files are the following additional/changed things possible.
<softheader>::= "soft:" [<unsigned integer>] ";"
<comment_or_constraint>::=<comment>|<constraint>|<softconstraint>
<softconstraint>::= "[" <zeroOrMoreSpace> <unsigned integer> <zeroOrMoreSpace> "]" <constraint>
Definition in file reader_opb.c.
#include "blockmemshell/memory.h"#include <ctype.h>#include "scip/cons_and.h"#include "scip/cons_indicator.h"#include "scip/cons_knapsack.h"#include "scip/cons_linear.h"#include "scip/cons_logicor.h"#include "scip/cons_pseudoboolean.h"#include "scip/cons_setppc.h"#include "scip/cons_varbound.h"#include "scip/debug.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_opb.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_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 "opbreader" |
| #define | READER_DESC "file reader for pseudo-Boolean problem in opb format" |
| #define | READER_EXTENSION "opb" |
| #define | GENCONSNAMES TRUE /* remove if no constraint names should be generated */ |
| #define | LINEAROBJECTIVE |
| #define | INDICATORVARNAME "indicatorvar" /* standard part of name for all indicator variables */ |
| #define | INDICATORSLACKVARNAME "indslack" /* standard part of name for all indicator slack variables; should be the same in cons_indicator */ |
| #define | TOPCOSTCONSNAME "topcostcons" /* standard name for artificial topcost constraint in wbo problems */ |
| #define | OPB_MAX_LINELEN 65536 |
| #define | OPB_MAX_PUSHEDTOKENS 2 |
| #define | OPB_INIT_COEFSSIZE 8192 |
Functions | |
| static void | syntaxError (SCIP *scip, OPBINPUT *opbinput, const char *msg) |
| static SCIP_Bool | hasError (OPBINPUT *opbinput) |
| static SCIP_Bool | isDelimChar (char c) |
| static SCIP_Bool | isTokenChar (char c) |
| static SCIP_Bool | isValueChar (char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, OPBEXPTYPE *exptype) |
| static SCIP_Bool | getNextLine (SCIP *scip, OPBINPUT *opbinput) |
| static void | swapPointers (char **pointer1, char **pointer2) |
| static SCIP_Bool | getNextToken (SCIP *scip, OPBINPUT *opbinput) |
| static void | pushToken (OPBINPUT *opbinput) |
| static void | pushBufferToken (OPBINPUT *opbinput) |
| static void | swapTokenBuffer (OPBINPUT *opbinput) |
| static SCIP_Bool | isEndLine (OPBINPUT *opbinput) |
| static SCIP_Bool | isSign (OPBINPUT *opbinput, int *sign) |
| static SCIP_Bool | isValue (SCIP *scip, OPBINPUT *opbinput, SCIP_Real *value) |
| static SCIP_Bool | isSense (OPBINPUT *opbinput, OPBSENSE *sense) |
| static SCIP_Bool | isStartingSoftConstraintWeight (SCIP *scip, OPBINPUT *opbinput) |
| static SCIP_Bool | isEndingSoftConstraintWeight (SCIP *scip, OPBINPUT *opbinput) |
| static SCIP_RETCODE | createVariable (SCIP *scip, SCIP_VAR **var, char *name) |
| static SCIP_RETCODE | getVariableOrTerm (SCIP *scip, OPBINPUT *opbinput, SCIP_VAR ***vars, int *nvars, int *varssize) |
| static SCIP_RETCODE | readCoefficients (SCIP *const scip, OPBINPUT *const opbinput, char *const name, SCIP_VAR ***linvars, SCIP_Real **lincoefs, int *const nlincoefs, int *lincoefssize, SCIP_VAR ****terms, SCIP_Real **termcoefs, int **ntermvars, int *termcoefssize, int *const ntermcoefs, SCIP_Bool *const newsection, SCIP_Bool *const isNonlinear, SCIP_Bool *const issoftcons, SCIP_Real *const weight) |
| static SCIP_RETCODE | setObjective (SCIP *const scip, OPBINPUT *const opbinput, const char *sense, SCIP_Real const scale, SCIP_VAR **const linvars, SCIP_Real *const coefs, int const ncoefs, SCIP_VAR ***const terms, SCIP_Real *const termcoefs, int *const ntermvars, int const ntermcoefs) |
| static SCIP_RETCODE | readConstraints (SCIP *scip, OPBINPUT *opbinput, SCIP_Real objscale, int *nNonlinearConss) |
| static SCIP_RETCODE | getMaxAndConsDim (SCIP *scip, OPBINPUT *opbinput, SCIP_Real *objscale, SCIP_Real *objoffset) |
| static SCIP_RETCODE | readOPBFile (SCIP *scip, OPBINPUT *opbinput, const char *filename) |
| static SCIP_RETCODE | getBinVarsRepresentatives (SCIP *const scip, SCIP_VAR **const vars, int const nvars, SCIP_Bool const transformed) |
| static SCIP_RETCODE | getActiveVariables (SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed) |
| static SCIP_RETCODE | computeAndConstraintInfos (SCIP *const scip, SCIP_Bool const transformed, SCIP_VAR ***resvars, int *nresvars, SCIP_VAR ****andvars, int **nandvars, SCIP_Bool *const existandconshdlr, SCIP_Bool *const existands) |
| static void | clearBuffer (char *linebuffer, int *linecnt) |
| static void | writeBuffer (SCIP *scip, FILE *file, char *linebuffer, int *linecnt) |
| static void | appendBuffer (SCIP *scip, FILE *file, char *linebuffer, int *linecnt, const char *extension) |
| static SCIP_RETCODE | writeOpbObjective (SCIP *const scip, FILE *const file, SCIP_VAR **const vars, int const nvars, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, SCIP_OBJSENSE const objsense, SCIP_Real const objscale, SCIP_Real const objoffset, char const *const multisymbol, SCIP_Bool const existands, SCIP_Bool const transformed) |
| static SCIP_RETCODE | printNLRow (SCIP *const scip, FILE *const file, char const *const type, SCIP_VAR **const vars, SCIP_Real const *const vals, int const nvars, SCIP_Real lhs, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, SCIP_Longint weight, SCIP_Longint *const mult, char const *const multisymbol) |
| static SCIP_RETCODE | printNonLinearCons (SCIP *const scip, FILE *const file, SCIP_VAR **const vars, SCIP_Real *const vals, int const nvars, SCIP_Real const lhs, SCIP_Real const rhs, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, SCIP_Longint weight, SCIP_Bool const transformed, char const *const multisymbol) |
| static SCIP_RETCODE | printRow (SCIP *scip, FILE *file, const char *type, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhs, SCIP_Longint weight, SCIP_Longint *mult, const char *multisymbol) |
| static SCIP_RETCODE | printLinearCons (SCIP *scip, FILE *file, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhs, SCIP_Real rhs, SCIP_Longint weight, SCIP_Bool transformed, const char *multisymbol) |
| static void | determineTotalNumberLinearConss (SCIP *const scip, SCIP_CONS **const conss, int const nconss, int *nlinearconss, int *nindicatorconss) |
| static SCIP_RETCODE | writeOpbConstraints (SCIP *const scip, FILE *const file, SCIP_CONS **const conss, int const nconss, SCIP_VAR **const vars, int const nvars, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, char const *const multisymbol, SCIP_Bool const existandconshdlr, SCIP_Bool const existands, SCIP_Bool const transformed) |
| static SCIP_RETCODE | writeOpbFixedVars (SCIP *const scip, FILE *const file, SCIP_VAR **vars, int nvars, SCIP_HASHTABLE *const printedfixing, char const *const multisymbol, SCIP_Bool const transformed) |
| static SCIP_RETCODE | writeOpbRelevantAnds (SCIP *const scip, FILE *const file, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, SCIP_HASHTABLE *const printedfixing, char const *const multisymbol, SCIP_Bool const transformed) |
| static SCIP_RETCODE | writeOpb (SCIP *scip, FILE *file, const char *name, SCIP_Bool transformed, SCIP_OBJSENSE objsense, SCIP_Real objscale, SCIP_Real objoffset, SCIP_VAR **vars, int nvars, SCIP_CONS **conss, int nconss, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, SCIP_Bool const existandconshdlr, SCIP_Bool const existands, SCIP_RESULT *result) |
| SCIP_RETCODE | SCIPreadOpb (SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result) |
| SCIP_RETCODE | SCIPwriteOpb (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_VAR **fixedvars, int nfixedvars, SCIP_CONS **conss, int nconss, SCIP_Bool genericnames, SCIP_RESULT *result) |
| static | SCIP_DECL_READERCOPY (readerCopyOpb) |
| static | SCIP_DECL_READERREAD (readerReadOpb) |
| static | SCIP_DECL_READERWRITE (readerWriteOpb) |
| SCIP_RETCODE | SCIPincludeReaderOpb (SCIP *scip) |
Variables | |
| static const char | commentchars [] = "*" |
| #define READER_NAME "opbreader" |
Definition at line 122 of file reader_opb.c.
| #define READER_DESC "file reader for pseudo-Boolean problem in opb format" |
Definition at line 123 of file reader_opb.c.
| #define READER_EXTENSION "opb" |
Definition at line 124 of file reader_opb.c.
Definition at line 126 of file reader_opb.c.
| #define LINEAROBJECTIVE |
Definition at line 127 of file reader_opb.c.
| #define INDICATORVARNAME "indicatorvar" /* standard part of name for all indicator variables */ |
Definition at line 129 of file reader_opb.c.
Referenced by printRow(), readConstraints(), and writeOpbObjective().
| #define INDICATORSLACKVARNAME "indslack" /* standard part of name for all indicator slack variables; should be the same in cons_indicator */ |
Definition at line 130 of file reader_opb.c.
| #define TOPCOSTCONSNAME "topcostcons" /* standard name for artificial topcost constraint in wbo problems */ |
Definition at line 131 of file reader_opb.c.
Referenced by readOPBFile(), writeOpbConstraints(), and writeOpbObjective().
| #define OPB_MAX_LINELEN 65536 |
size of the line buffer for reading or writing
Definition at line 136 of file reader_opb.c.
Referenced by appendBuffer(), getNextToken(), printNLRow(), printRow(), readConstraints(), SCIPreadOpb(), writeBuffer(), writeOpb(), writeOpbFixedVars(), writeOpbObjective(), and writeOpbRelevantAnds().
| #define OPB_MAX_PUSHEDTOKENS 2 |
Definition at line 137 of file reader_opb.c.
Referenced by pushBufferToken(), pushToken(), and SCIPreadOpb().
| #define OPB_INIT_COEFSSIZE 8192 |
Definition at line 138 of file reader_opb.c.
Referenced by readCoefficients().
| typedef enum OpbExpType OPBEXPTYPE |
Definition at line 147 of file reader_opb.c.
Definition at line 156 of file reader_opb.c.
| typedef struct OpbInput OPBINPUT |
Definition at line 182 of file reader_opb.c.
| enum OpbExpType |
Section in OPB File
| Enumerator | |
|---|---|
| OPB_EXP_NONE | |
| OPB_EXP_UNSIGNED | |
| OPB_EXP_SIGNED | |
Definition at line 141 of file reader_opb.c.
| enum OpbSense |
| Enumerator | |
|---|---|
| OPB_SENSE_NOTHING | |
| OPB_SENSE_LE | |
| OPB_SENSE_GE | |
| OPB_SENSE_EQ | |
Definition at line 149 of file reader_opb.c.
issues an error message and marks the OPB data to have errors
| scip | SCIP data structure |
| opbinput | OPB reading data |
| msg | error message |
Definition at line 191 of file reader_opb.c.
References assert(), NULL, SCIPerrorMessage, and TRUE.
Referenced by getVariableOrTerm(), readCoefficients(), and readConstraints().
returns whether a syntax error was detected
| opbinput | OPB reading data |
Definition at line 215 of file reader_opb.c.
References assert(), NULL, and SCIP_Bool.
Referenced by readCoefficients(), readConstraints(), and setObjective().
|
static |
returns whether the given character is a token delimiter
| c | input character |
Definition at line 226 of file reader_opb.c.
References c, FALSE, SCIP_Bool, and TRUE.
Referenced by getNextToken().
|
static |
returns whether the given character is a single token
| c | input character |
Definition at line 247 of file reader_opb.c.
References c, FALSE, SCIP_Bool, and TRUE.
Referenced by getNextToken(), and getVariableOrTerm().
|
static |
returns whether the current character is member of a value string
| c | input character |
| nextc | next input character |
| firstchar | is the given character the first char of the token? |
| hasdot | pointer to update the dot flag |
| exptype | pointer to update the exponent type |
Definition at line 270 of file reader_opb.c.
References assert(), c, FALSE, NULL, OPB_EXP_NONE, OPB_EXP_SIGNED, OPB_EXP_UNSIGNED, SCIP_Bool, and TRUE.
Referenced by getNextToken().
reads the next line from the input file into the line buffer; skips comments; returns whether a line could be read
| scip | SCIP data structure |
| opbinput | OPB reading data |
Definition at line 314 of file reader_opb.c.
References assert(), commentchars, FALSE, i, NULL, SCIP_Bool, SCIP_CALL_ABORT, SCIPcalcMemGrowSize(), SCIPdebugMsg, SCIPfgets(), SCIPreallocBlockMemoryArray, and TRUE.
Referenced by getNextToken().
|
static |
swaps the addresses of two pointers
| pointer1 | first pointer |
| pointer2 | second pointer |
Definition at line 369 of file reader_opb.c.
Referenced by getNextToken(), pushBufferToken(), pushToken(), and swapTokenBuffer().
reads the next token from the input file into the token buffer; returns whether a token was read
| scip | SCIP data structure |
| opbinput | OPB reading data |
Definition at line 383 of file reader_opb.c.
References assert(), FALSE, getNextLine(), isDelimChar(), isTokenChar(), isTokenChar(), isValueChar(), NULL, OPB_EXP_NONE, OPB_MAX_LINELEN, SCIP_Bool, SCIPdebugMsg, swapPointers(), and TRUE.
Referenced by getVariableOrTerm(), readCoefficients(), and readConstraints().
|
static |
puts the current token on the token stack, such that it is read at the next call to getNextToken()
| opbinput | OPB reading data |
Definition at line 484 of file reader_opb.c.
References assert(), NULL, OPB_MAX_PUSHEDTOKENS, and swapPointers().
Referenced by getVariableOrTerm(), and readCoefficients().
|
static |
puts the buffered token on the token stack, such that it is read at the next call to getNextToken()
| opbinput | OPB reading data |
Definition at line 497 of file reader_opb.c.
References assert(), NULL, OPB_MAX_PUSHEDTOKENS, and swapPointers().
Referenced by readCoefficients().
|
static |
swaps the current token with the token buffer
| opbinput | OPB reading data |
Definition at line 510 of file reader_opb.c.
References assert(), NULL, and swapPointers().
Referenced by readCoefficients().
checks whether the current token is a section identifier, and if yes, switches to the corresponding section
| opbinput | OPB reading data |
Definition at line 521 of file reader_opb.c.
References assert(), FALSE, NULL, SCIP_Bool, and TRUE.
Referenced by readCoefficients(), readConstraints(), and setObjective().
returns whether the current token is a sign
| opbinput | OPB reading data |
| sign | pointer to update the sign |
Definition at line 535 of file reader_opb.c.
References assert(), FALSE, NULL, SCIP_Bool, and TRUE.
Referenced by readCoefficients(), and readConstraints().
returns whether the current token is a value
| scip | SCIP data structure |
| opbinput | OPB reading data |
| value | pointer to store the value (unchanged, if token is no value) |
Definition at line 562 of file reader_opb.c.
References assert(), FALSE, NULL, SCIP_Bool, SCIP_Real, SCIPinfinity(), SCIPstrcasecmp(), and TRUE.
Referenced by readCoefficients(), and readConstraints().
returns whether the current token is an equation sense
| opbinput | OPB reading data |
| sense | pointer to store the equation sense, or NULL |
Definition at line 596 of file reader_opb.c.
References assert(), FALSE, NULL, OPB_SENSE_EQ, OPB_SENSE_GE, OPB_SENSE_LE, SCIP_Bool, and TRUE.
Referenced by readCoefficients(), and readConstraints().
returns whether the current token is a value
| scip | SCIP data structure |
| opbinput | OPB reading data |
Definition at line 627 of file reader_opb.c.
References assert(), FALSE, NULL, SCIP_Bool, and TRUE.
Referenced by readCoefficients().
returns whether the current token is a value
| scip | SCIP data structure |
| opbinput | OPB reading data |
Definition at line 643 of file reader_opb.c.
References assert(), FALSE, NULL, SCIP_Bool, and TRUE.
Referenced by readCoefficients().
|
static |
create binary variable with given name
| scip | SCIP data structure |
| var | pointer to store the variable |
| name | name for the variable |
Definition at line 659 of file reader_opb.c.
References NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_VARTYPE_BINARY, SCIPaddVar(), SCIPcreateVar(), SCIPdebugMsg, SCIPgetBoolParam(), SCIPreleaseVar(), and var.
Referenced by getVariableOrTerm(), and readConstraints().
|
static |
returns the variable with the given name, or creates a new variable if it does not exist
| scip | SCIP data structure |
| opbinput | OPB reading data |
| vars | pointer to store the variables |
| nvars | pointer to store the number of variables |
| varssize | pointer to store the varsize, if changed (should already be initialized) |
Definition at line 691 of file reader_opb.c.
References assert(), createVariable(), FALSE, getNextToken(), isTokenChar(), NULL, nvars, pushToken(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPcalcMemGrowSize(), SCIPfindVar(), SCIPgetNegatedVar(), SCIPreallocBufferArray, syntaxError(), TRUE, var, and vars.
Referenced by readCoefficients().
|
static |
reads an objective or constraint with name and coefficients
| scip | SCIP data structure |
| opbinput | OPB reading data |
| name | pointer to store the name of the line; must be at least of size OPB_MAX_LINELEN |
| linvars | pointer to store the array with linear variables (must be freed by caller) |
| lincoefs | pointer to store the array with linear coefficients (must be freed by caller) |
| nlincoefs | pointer to store the number of linear coefficients |
| lincoefssize | pointer to store the size of linvars/lincoefs arrays |
| terms | pointer to store the array with nonlinear variables (must be freed by caller) |
| termcoefs | pointer to store the array with nonlinear coefficients (must be freed by caller) |
| ntermvars | pointer to store the number of nonlinear variables in the terms (must be freed by caller) |
| termcoefssize | pointer to store the size of terms/termcoefs |
| ntermcoefs | pointer to store the number of nonlinear coefficients |
| newsection | pointer to store whether a new section was encountered |
| isNonlinear | pointer to store if we have a nonlinear constraint |
| issoftcons | pointer to store whether it is a soft constraint (for wbo files) |
| weight | pointer to store the weight of the soft constraint |
Definition at line 767 of file reader_opb.c.
References assert(), FALSE, getNextToken(), getVariableOrTerm(), hasError(), isEndingSoftConstraintWeight(), isEndLine(), isSense(), isSign(), isStartingSoftConstraintWeight(), isValue(), NULL, OPB_INIT_COEFSSIZE, pushBufferToken(), pushToken(), SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPallocBlockMemoryArray, SCIPallocBufferArray, SCIPcalcMemGrowSize(), SCIPdebugMsg, SCIPdebugMsgPrint, SCIPfeof(), SCIPfreeBufferArray, SCIPgetNConss(), SCIPgetNVars(), SCIPisIntegral(), SCIPisZero(), SCIPmemccpy(), SCIPreallocBlockMemoryArray, SCIPvarGetName(), SCIPwarningMessage(), swapTokenBuffer(), syntaxError(), and TRUE.
Referenced by readConstraints().
|
static |
set the objective section
| scip | SCIP data structure |
| opbinput | OPB reading data |
| sense | objective sense |
| scale | objective scale |
| linvars | array of linear variables |
| coefs | array of objective values for linear variables |
| ncoefs | number of coefficients for linear part |
| terms | array with nonlinear variables |
| termcoefs | array of objective values for nonlinear variables |
| ntermvars | number of nonlinear variables in the terms |
| ntermcoefs | number of nonlinear coefficients |
Definition at line 1132 of file reader_opb.c.
References ARTIFICIALVARNAMEPREFIX, assert(), FALSE, hasError(), isEndLine(), NULL, nvars, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OBJSENSE_MAXIMIZE, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_BINARY, SCIP_VARTYPE_INTEGER, SCIPaddCons(), SCIPaddOrigObjoffset(), SCIPaddVar(), SCIPaddVarObj(), SCIPchgVarBranchPriority(), SCIPcreateConsAnd(), SCIPcreateConsPseudoboolean(), SCIPcreateVar(), SCIPdebugAddSolVal, SCIPdebugGetSolVal, SCIPdebugPrintCons, SCIPisFeasEQ(), SCIPisFeasGE(), SCIPisFeasLE(), SCIPisFeasZero(), SCIPreleaseCons(), SCIPreleaseVar(), SCIPsnprintf(), SCIPvarGetNegationVar(), SCIPvarIsNegated(), TRUE, var, and vars.
Referenced by readConstraints().
|
static |
reads the constraints section
| scip | SCIP data structure |
| opbinput | OPB reading data |
| objscale | objective scale |
| nNonlinearConss | pointer to store number of nonlinear constraints |
Definition at line 1341 of file reader_opb.c.
References assert(), createVariable(), FALSE, getNextToken(), hasError(), INDICATORVARNAME, isEndLine(), isSense(), isSign(), isValue(), NULL, objscale, OPB_MAX_LINELEN, OPB_SENSE_EQ, OPB_SENSE_GE, OPB_SENSE_LE, OPB_SENSE_NOTHING, propagate, readCoefficients(), READER_NAME, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPaddCons(), SCIPchgVarObj(), SCIPcreateConsLinear(), SCIPcreateConsPseudoboolean(), SCIPdebugMsg, SCIPdebugPrintCons, SCIPerrorMessage, SCIPfreeBlockMemoryArray, SCIPfreeBlockMemoryArrayNull, SCIPgetBoolParam(), SCIPinfinity(), SCIPisInfinity(), SCIPreleaseCons(), SCIPsnprintf(), setObjective(), syntaxError(), and TRUE.
Referenced by readOPBFile().
|
static |
tries to read the first comment line which usually contains information about the max size of "and" products
| scip | SCIP data structure |
| opbinput | OPB reading data |
| objscale | pointer to store objective scale |
| objoffset | pointer to store objective offset |
Definition at line 1578 of file reader_opb.c.
References assert(), commentchars, delimchars, FALSE, i, NULL, objscale, SCIP_Bool, SCIP_CALL_ABORT, SCIP_OKAY, SCIP_READERROR, SCIP_Real, SCIPcalcMemGrowSize(), SCIPdebugMsg, SCIPfeof(), SCIPfgets(), SCIPreallocBlockMemoryArray, and TRUE.
Referenced by readOPBFile().
|
static |
reads an OPB file
| scip | SCIP data structure |
| opbinput | OPB reading data |
| filename | name of the input file |
Definition at line 1695 of file reader_opb.c.
References assert(), FALSE, getMaxAndConsDim(), hasError(), i, NULL, nvars, objscale, readConstraints(), SCIP_CALL, SCIP_NOFILE, SCIP_OKAY, SCIP_Real, SCIPaddCons(), SCIPaddOrigObjoffset(), SCIPallocBufferArray, SCIPceil(), SCIPcreateConsLinear(), SCIPcreateProb(), SCIPdebugPrintCons, SCIPerrorMessage, SCIPfclose(), SCIPfeof(), SCIPfopen(), SCIPfreeBufferArray, SCIPgetNVars(), SCIPgetVars(), SCIPinfinity(), SCIPisZero(), SCIPprintSysError(), SCIPreleaseCons(), SCIPvarGetObj(), TOPCOSTCONSNAME, TRUE, and vars.
Referenced by SCIPreadOpb().
|
static |
transforms given and constraint variables to the corresponding active or negated variables
| scip | SCIP data structure |
| vars | vars array to get active variables for |
| nvars | pointer to number of variables and values in vars and vals array |
| transformed | transformed constraint? |
Definition at line 1797 of file reader_opb.c.
References assert(), NULL, nvars, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_Real, SCIPdebugMsg, SCIPgetBinvarRepresentative(), SCIPgetNegatedVar(), SCIPisEQ(), SCIPisZero(), SCIPvarGetOrigvarSum(), and vars.
Referenced by computeAndConstraintInfos().
|
static |
transforms given variables, scalars, and constant to the corresponding active variables, scalars, and constant
| scip | SCIP data structure |
| vars | vars array to get active variables for |
| scalars | scalars a_1, ..., a_n in linear sum a_1*x_1 + ... + a_n*x_n + c |
| nvars | pointer to number of variables and values in vars and vals array |
| constant | pointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c |
| transformed | transformed constraint? |
Definition at line 1861 of file reader_opb.c.
References assert(), NULL, nvars, scalars, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_Real, SCIPgetProbvarLinearSum(), SCIPreallocBufferArray, SCIPvarGetOrigvarSum(), TRUE, and vars.
Referenced by printLinearCons(), and printNonLinearCons().
|
static |
| scip | SCIP data structure |
| transformed | transformed problem? |
| resvars | pointer to store all resultant variables |
| nresvars | pointer to store the number of all resultant variables |
| andvars | pointer to store to all resultant variables their corresponding active( or negated) and-constraint variables |
| nandvars | pointer to store the number of all corresponding and-variables to their corresponding resultant variable |
| existandconshdlr | pointer to store whether the and-constrainthandler exists |
| existands | pointer to store if their exists some and-constraints |
Definition at line 1906 of file reader_opb.c.
References a, assert(), c, FALSE, getBinVarsRepresentatives(), NULL, r, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIPallocBufferArray, SCIPallocMemoryArray, SCIPconsGetHdlr(), SCIPconshdlrGetConss(), SCIPconshdlrGetName(), SCIPconshdlrGetNConss(), SCIPdebug, SCIPdebugMsg, SCIPduplicateMemoryArray, SCIPfindConshdlr(), SCIPfreeBufferArray, SCIPgetNOrigConss(), SCIPgetNVarsAnd(), SCIPgetOrigConss(), SCIPgetResultantAnd(), SCIPgetVarsAnd(), SCIPprintVar(), SCIPreallocMemoryArray, SCIPsortedvecFindPtr(), SCIPsortPtrPtrInt(), SCIPwarningMessage(), and TRUE.
|
static |
clears the given line buffer
| linebuffer | line |
| linecnt | number of characters in line |
Definition at line 2110 of file reader_opb.c.
References assert(), and NULL.
Referenced by printNLRow(), printRow(), writeBuffer(), writeOpbFixedVars(), writeOpbObjective(), and writeOpbRelevantAnds().
|
static |
ends the given line with '\0' and prints it to the given file stream
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| linebuffer | line |
| linecnt | number of characters in line |
Definition at line 2125 of file reader_opb.c.
References assert(), clearBuffer(), NULL, OPB_MAX_LINELEN, and SCIPinfoMessage().
Referenced by appendBuffer(), printNLRow(), printRow(), writeOpbFixedVars(), writeOpbObjective(), and writeOpbRelevantAnds().
|
static |
appends extension to line and prints it to the give file stream if the line buffer get full
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| linebuffer | line buffer |
| linecnt | number of characters in line |
| extension | string to extent the line |
Definition at line 2148 of file reader_opb.c.
References assert(), NULL, OPB_MAX_LINELEN, and writeBuffer().
Referenced by printNLRow(), printRow(), writeOpbFixedVars(), writeOpbObjective(), and writeOpbRelevantAnds().
|
static |
write objective function
| scip | SCIP data structure |
| file | output file, or NULL if standard output should be used |
| vars | array with active (binary) variables |
| nvars | number of active variables in the problem |
| resvars | array of resultant variables |
| nresvars | number of resultant variables |
| andvars | corresponding array of and-variables |
| nandvars | array of numbers of corresponding and-variables |
| objsense | objective sense |
| objscale | scalar applied to objective function; external objective value is extobj = objsense * objscale * (intobj + objoffset) |
| objoffset | objective offset from bound shifting and fixing |
| multisymbol | the multiplication symbol to use between coefficient and variable |
| existands | does some and-constraints exist? |
| transformed | TRUE iff problem is the transformed problem |
Definition at line 2171 of file reader_opb.c.
References a, appendBuffer(), assert(), c, clearBuffer(), FALSE, INDICATORVARNAME, NULL, nvars, objscale, OPB_MAX_LINELEN, SCIP_Bool, SCIP_INVALIDDATA, SCIP_Longint, SCIP_LONGINT_FORMAT, SCIP_LONGINT_MAX, SCIP_OBJSENSE_MAXIMIZE, SCIP_OKAY, SCIP_Real, SCIP_VARSTATUS_NEGATED, SCIP_VARSTATUS_ORIGINAL, SCIPABORT, SCIPconsGetHdlr(), SCIPconshdlrGetConss(), SCIPconshdlrGetName(), SCIPconshdlrGetNConss(), SCIPdebugMsg, SCIPerrorMessage, SCIPfindCons(), SCIPfindConshdlr(), SCIPgetCapacityKnapsack(), SCIPgetNVarsKnapsack(), SCIPgetNVarsLinear(), SCIPgetNVarsSetppc(), SCIPgetRhsLinear(), SCIPgetVarsKnapsack(), SCIPgetVarsLinear(), SCIPgetVarsSetppc(), SCIPinfoMessage(), SCIPisIntegral(), SCIPisZero(), SCIPround(), SCIPsnprintf(), SCIPsortedvecFindPtr(), SCIPvarGetIndex(), SCIPvarGetName(), SCIPvarGetNegationVar(), SCIPvarGetObj(), SCIPvarGetStatus(), SCIPvarIsNegated(), TOPCOSTCONSNAME, TRUE, var, vars, w, and writeBuffer().
Referenced by writeOpb().
|
static |
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| type | row type ("=" or ">=") |
| vars | array of variables |
| vals | array of values |
| nvars | number of variables |
| lhs | left hand side |
| resvars | array of resultant variables |
| nresvars | number of resultant variables |
| andvars | corresponding array of and-variables |
| nandvars | array of numbers of corresponding and-variables |
| weight | if we found a soft constraint this is the weight, otherwise 0 |
| mult | multiplier for the coefficients |
| multisymbol | the multiplication symbol to use between coefficient and variable |
Definition at line 2543 of file reader_opb.c.
References a, ABS, appendBuffer(), assert(), clearBuffer(), NULL, nvars, OPB_MAX_LINELEN, SCIP_Bool, SCIP_INVALIDDATA, SCIP_Longint, SCIP_LONGINT_FORMAT, SCIP_LONGINT_MAX, SCIP_OKAY, SCIP_Real, SCIPerrorMessage, SCIPinfoMessage(), SCIPisIntegral(), SCIPisZero(), SCIPround(), SCIPsnprintf(), SCIPsortedvecFindPtr(), SCIPvarGetIndex(), SCIPvarGetName(), SCIPvarGetNegationVar(), SCIPvarIsNegated(), var, vars, and writeBuffer().
Referenced by printNonLinearCons().
|
static |
prints given maybe non-linear constraint information in OPB format to file stream
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| vars | array of variables |
| vals | array of coefficients values (or NULL if all coefficient values are 1) |
| nvars | number of variables |
| lhs | left hand side |
| rhs | right hand side |
| resvars | array of resultant variables |
| nresvars | number of resultant variables |
| andvars | corresponding array of and-variables |
| nandvars | array of numbers of corresponding and-variables |
| weight | if we found a soft constraint this is the weight, otherwise 0 |
| transformed | transformed constraint? |
| multisymbol | the multiplication symbol to use between coefficient and variable |
Definition at line 2677 of file reader_opb.c.
References assert(), getActiveVariables(), NULL, nvars, printNLRow(), SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, SCIPfreeBufferArray, SCIPisEQ(), SCIPisInfinity(), and vars.
Referenced by writeOpbConstraints().
|
static |
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| type | row type ("=" or ">=") |
| vars | array of variables |
| vals | array of values |
| nvars | number of variables |
| lhs | left hand side |
| weight | if we found a soft constraint this is the weight, otherwise 0 |
| mult | multiplier for the coefficients |
| multisymbol | the multiplication symbol to use between coefficient and variable |
Definition at line 2780 of file reader_opb.c.
References ABS, appendBuffer(), assert(), clearBuffer(), INDICATORVARNAME, NULL, nvars, OPB_MAX_LINELEN, SCIP_Bool, SCIP_INVALIDDATA, SCIP_Longint, SCIP_LONGINT_FORMAT, SCIP_LONGINT_MAX, SCIP_OKAY, SCIP_Real, SCIPerrorMessage, SCIPinfoMessage(), SCIPisIntegral(), SCIPisZero(), SCIPround(), SCIPsnprintf(), SCIPvarGetName(), SCIPvarGetNegationVar(), SCIPvarIsNegated(), var, vars, and writeBuffer().
Referenced by printLinearCons().
|
static |
prints given linear constraint information in OPB format to file stream
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| vars | array of variables |
| vals | array of coefficients values (or NULL if all coefficient values are 1) |
| nvars | number of variables |
| lhs | left hand side |
| rhs | right hand side |
| weight | if we found a soft constraint this is the weight, otherwise 0 |
| transformed | transformed constraint? |
| multisymbol | the multiplication symbol to use between coefficient and variable |
Definition at line 2875 of file reader_opb.c.
References assert(), getActiveVariables(), NULL, nvars, printRow(), SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, SCIPfreeBufferArray, SCIPisEQ(), SCIPisInfinity(), and vars.
Referenced by writeOpbConstraints().
|
static |
determine total number of split linear and indicator constraints
| scip | SCIP data structure |
| conss | array with constraints of the problem |
| nconss | number of constraints in the problem |
| nlinearconss | pointer to store the total number of split linear constraints |
| nindicatorconss | pointer to store the total number of indicator constraints |
Definition at line 2969 of file reader_opb.c.
References assert(), c, NULL, SCIP_Bool, SCIP_Real, SCIPconsGetHdlr(), SCIPconsGetLhs(), SCIPconsGetRhs(), SCIPconshdlrGetName(), SCIPgetIndVarPseudoboolean(), SCIPisEQ(), and SCIPisInfinity().
Referenced by writeOpb().
|
static |
write constraints
| scip | SCIP data structure |
| file | output file, or NULL if standard output should be used |
| conss | array with constraints of the problem |
| nconss | number of constraints in the problem |
| vars | array with active (binary) variables |
| nvars | number of active variables in the problem |
| resvars | array of resultant variables |
| nresvars | number of resultant variables |
| andvars | corresponding array of and-variables |
| nandvars | array of numbers of corresponding and-variables |
| multisymbol | the multiplication symbol to use between coefficient and variable |
| existandconshdlr | does and-constrainthandler exist? |
| existands | does some and-constraints exist? |
| transformed | TRUE iff problem is the transformed problem |
Definition at line 3047 of file reader_opb.c.
References assert(), c, FALSE, NULL, nvars, printLinearCons(), printNonLinearCons(), SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIP_SETPPCTYPE_COVERING, SCIP_SETPPCTYPE_PACKING, SCIP_SETPPCTYPE_PARTITIONING, SCIP_VARSTATUS_AGGREGATED, SCIP_VARSTATUS_MULTAGGR, SCIP_VARSTATUS_NEGATED, SCIP_VARTYPE_BINARY, SCIPallocBufferArray, SCIPblkmem(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetConss(), SCIPconshdlrGetName(), SCIPconshdlrGetNConss(), SCIPconsIsEnabled(), SCIPconsIsTransformed(), SCIPduplicateBufferArray, SCIPerrorMessage, SCIPfindConshdlr(), SCIPfreeBufferArray, SCIPgetBinaryVarIndicator(), SCIPgetCapacityKnapsack(), SCIPgetIndVarPseudoboolean(), SCIPgetLhsLinear(), SCIPgetLhsVarbound(), SCIPgetLinearConsIndicator(), SCIPgetLinearConsPseudoboolean(), SCIPgetNVarsKnapsack(), SCIPgetNVarsLinear(), SCIPgetNVarsLogicor(), SCIPgetNVarsSetppc(), SCIPgetRhsLinear(), SCIPgetRhsVarbound(), SCIPgetSlackVarIndicator(), SCIPgetTypeSetppc(), SCIPgetValsLinear(), SCIPgetVarsKnapsack(), SCIPgetVarsLinear(), SCIPgetVarsLogicor(), SCIPgetVarsSetppc(), SCIPgetVarVarbound(), SCIPgetVbdcoefVarbound(), SCIPgetVbdvarVarbound(), SCIPgetWeightsKnapsack(), SCIPhashmapCreate(), SCIPhashmapFree(), SCIPhashmapGetImage(), SCIPhashmapInsert(), SCIPinfinity(), SCIPinfoMessage(), SCIPprintCons(), SCIPround(), SCIPvarGetNegationVar(), SCIPvarGetObj(), SCIPvarGetStatus(), SCIPvarGetType(), SCIPwarningMessage(), TOPCOSTCONSNAME, TRUE, and vars.
Referenced by writeOpb().
|
static |
| scip | SCIP data structure |
| file | output file, or NULL if standard output should be used |
| vars | array with active (binary) variables |
| nvars | number of active variables in the problem |
| printedfixing | hashmap to store if a fixed variable was already printed |
| multisymbol | the multiplication symbol to use between coefficient and variable |
| transformed | TRUE iff problem is the transformed problem |
Definition at line 3575 of file reader_opb.c.
References appendBuffer(), assert(), clearBuffer(), FALSE, NULL, nvars, OPB_MAX_LINELEN, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPgetBinvarRepresentative(), SCIPhashtableExists(), SCIPhashtableInsert(), SCIPisFeasIntegral(), SCIPsnprintf(), SCIPvarGetLbLocal(), SCIPvarGetLbOriginal(), SCIPvarGetName(), SCIPvarGetNegationVar(), SCIPvarGetUbLocal(), SCIPvarGetUbOriginal(), var, vars, and writeBuffer().
Referenced by writeOpb().
|
static |
| scip | SCIP data structure |
| file | output file, or NULL if standard output should be used |
| resvars | array of resultant variables |
| nresvars | number of resultant variables |
| andvars | corresponding array of and-variables |
| nandvars | array of numbers of corresponding and-variables |
| printedfixing | hashmap to store if a fixed variable was already printed |
| multisymbol | the multiplication symbol to use between coefficient and variable |
| transformed | TRUE iff problem is the transformed problem |
Definition at line 3649 of file reader_opb.c.
References a, appendBuffer(), assert(), clearBuffer(), FALSE, NULL, OPB_MAX_LINELEN, r, SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_LONGINT_FORMAT, SCIP_OKAY, SCIP_Real, SCIPgetBinvarRepresentative(), SCIPhashtableInsert(), SCIPisFeasIntegral(), SCIPsnprintf(), SCIPsortedvecFindPtr(), SCIPvarGetLbLocal(), SCIPvarGetLbOriginal(), SCIPvarGetName(), SCIPvarGetNegationVar(), SCIPvarGetUbLocal(), SCIPvarGetUbOriginal(), SCIPvarIsActive(), SCIPvarIsNegated(), TRUE, var, and writeBuffer().
Referenced by writeOpb().
|
static |
| scip | SCIP data structure |
| file | output file, or NULL if standard output should be used |
| name | problem name |
| transformed | TRUE iff problem is the transformed problem |
| objsense | objective sense |
| objscale | scalar applied to objective function; external objective value is extobj = objsense * objscale * (intobj + objoffset) |
| objoffset | objective offset from bound shifting and fixing |
| vars | array with active (binary) variables |
| nvars | number of active variables in the problem |
| conss | array with constraints of the problem |
| nconss | number of constraints in the problem |
| resvars | array of resultant variables |
| nresvars | number of resultant variables |
| andvars | corresponding array of and-variables |
| nandvars | array of numbers of corresponding and-variables |
| existandconshdlr | does and-constrainthandler exist? |
| existands | does some and-constraints exist? |
| result | pointer to store the result of the file writing call |
Definition at line 3914 of file reader_opb.c.
References assert(), determineTotalNumberLinearConss(), NULL, nvars, objscale, OPB_MAX_LINELEN, READER_NAME, result, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIP_SUCCESS, SCIPblkmem(), SCIPgetBoolParam(), SCIPhashtableCreate(), SCIPhashtableFree(), SCIPinfoMessage(), SCIPsnprintf(), vars, writeOpbConstraints(), writeOpbFixedVars(), writeOpbObjective(), and writeOpbRelevantAnds().
|
static |
copy method for reader plugins (called when SCIP copies plugins)
Definition at line 4255 of file reader_opb.c.
References assert(), NULL, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludeReaderOpb(), and SCIPreaderGetName().
|
static |
problem reading method of reader
Definition at line 4270 of file reader_opb.c.
References result, SCIP_CALL, SCIP_OKAY, and SCIPreadOpb().
|
static |
|
static |
Definition at line 184 of file reader_opb.c.