Scippy

SCIP

Solving Constraint Integer Programs

Detailed Description

OS instance language (OSiL) format file reader.

Author
Stefan Vigerske
Ingmar Vierhaus
Benjamin Mueller

Definition in file reader_osil.c.

#include "blockmemshell/memory.h"
#include "scip/cons_bounddisjunction.h"
#include "scip/cons_nonlinear.h"
#include "scip/cons_linear.h"
#include "scip/cons_sos1.h"
#include "scip/cons_sos2.h"
#include "scip/expr_abs.h"
#include "scip/expr_erf.h"
#include "scip/expr_exp.h"
#include "scip/expr_log.h"
#include "scip/expr_pow.h"
#include "scip/expr_product.h"
#include "scip/expr_sum.h"
#include "scip/expr_trig.h"
#include "scip/expr_value.h"
#include "scip/expr_var.h"
#include "scip/pub_cons.h"
#include "scip/pub_message.h"
#include "scip/pub_misc.h"
#include "scip/pub_nlp.h"
#include "scip/pub_var.h"
#include "scip/reader_osil.h"
#include "scip/scip_cons.h"
#include "scip/scip_mem.h"
#include "scip/scip_numerics.h"
#include "scip/scip_param.h"
#include "scip/scip_prob.h"
#include "scip/scip_reader.h"
#include "scip/scip_var.h"
#include <stdlib.h>
#include <string.h>
#include "xml/xml.h"

Go to the source code of this file.

Macros

#define READER_NAME   "osilreader"
 
#define READER_DESC   "file reader for OS instance language (OSiL) format"
 
#define READER_EXTENSION   "osil"
 

Functions

static SCIP_RETCODE readVariables (SCIP *scip, const XML_NODE *datanode, SCIP_VAR ***vars, int *nvars, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamiccols, SCIP_Bool dynamicrows, SCIP_Bool *doingfine)
 
static SCIP_RETCODE readObjective (SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, SCIP_Bool dynamiccols, SCIP_Bool *doingfine)
 
static SCIP_RETCODE readNConstraints (SCIP *scip, const XML_NODE *datanode, int *nconss, SCIP_Bool *doingfine)
 
static SCIP_RETCODE createConstraint (SCIP *scip, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nlinvars, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoefs, int nquadterms, SCIP_EXPR *nlexpr, SCIP_Real lhs, SCIP_Real rhs, const char *name, SCIP_Bool objcons, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamicrows)
 
static SCIP_RETCODE readConstraints (SCIP *scip, const XML_NODE *datanode, int nconss, SCIP_VAR ***linvars, SCIP_Real **lincoefs, int *nlinvars, SCIP_VAR ***quadvars1, SCIP_VAR ***quadvars2, SCIP_Real **quadcoefs, int *nquadterms, SCIP_EXPR **nlexprs, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamicrows, SCIP_Bool *doingfine)
 
static void readMultIncr (const XML_NODE *node, int *mult, int *incrint, SCIP_Real *incrreal, SCIP_Bool *doingfine)
 
static SCIP_RETCODE readLinearCoefs (SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, int nconss, SCIP_VAR ***linvars, SCIP_Real **lincoefs, int *nlinvars, SCIP_Bool *doingfine)
 
static SCIP_RETCODE readQuadraticCoefs (SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, int nconss, SCIP_VAR ***quadvars1, SCIP_VAR ***quadvars2, SCIP_Real **quadcoefs, int *nquadterms, int *termssize, SCIP_Bool *doingfine)
 
static SCIP_RETCODE readExpression (SCIP *scip, SCIP_EXPR **expr, const XML_NODE *node, SCIP_VAR **vars, int nvars, SCIP_Bool *doingfine)
 
static SCIP_RETCODE readNonlinearExprs (SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, int nconss, SCIP_EXPR **exprs, SCIP_Bool *doingfine)
 
static SCIP_RETCODE readSOScons (SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamicrows, SCIP_Bool *doingfine)
 
static SCIP_DECL_READERCOPY (readerCopyOsil)
 
static SCIP_DECL_READERREAD (readerReadOsil)
 
SCIP_RETCODE SCIPincludeReaderOsil (SCIP *scip)
 

Macro Definition Documentation

◆ READER_NAME

#define READER_NAME   "osilreader"

Definition at line 69 of file reader_osil.c.

◆ READER_DESC

#define READER_DESC   "file reader for OS instance language (OSiL) format"

Definition at line 70 of file reader_osil.c.

◆ READER_EXTENSION

#define READER_EXTENSION   "osil"

Definition at line 71 of file reader_osil.c.

Function Documentation

◆ readVariables()

static SCIP_RETCODE readVariables ( SCIP scip,
const XML_NODE datanode,
SCIP_VAR ***  vars,
int *  nvars,
SCIP_Bool  initialconss,
SCIP_Bool  dynamicconss,
SCIP_Bool  dynamiccols,
SCIP_Bool  dynamicrows,
SCIP_Bool doingfine 
)
static

create variables with bounds and type according to xml data

Parameters
scipSCIP data structure
datanodeXML root node for instance data
varsbuffer to store pointer to variable array
nvarsbuffer to store number of variables
initialconssshould model constraints be marked as initial?
dynamicconssshould model constraints be subject to aging?
dynamiccolsshould columns be added and removed dynamically to the LP?
dynamicrowsshould rows be added and removed dynamically to the LP?
doingfinebuffer to indicate whether no errors occurred

Definition at line 79 of file reader_osil.c.

References FALSE, NULL, SCIP_BOUNDTYPE_LOWER, SCIP_BOUNDTYPE_UPPER, SCIP_CALL, SCIP_INVALID, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_BINARY, SCIP_VARTYPE_CONTINUOUS, SCIP_VARTYPE_INTEGER, SCIPaddCons(), SCIPaddVar(), SCIPallocBufferArray, SCIPceil(), SCIPcreateConsBounddisjunction(), SCIPcreateVar(), SCIPerrorMessage, SCIPfloor(), SCIPinfinity(), SCIPreleaseCons(), SCIPsnprintf(), SCIPvarGetName(), TRUE, xmlFindNodeMaxdepth(), xmlFirstChild(), xmlGetAttrval(), and xmlNextSibl().

Referenced by SCIP_DECL_READERREAD().

◆ readObjective()

static SCIP_RETCODE readObjective ( SCIP scip,
const XML_NODE datanode,
SCIP_VAR **  vars,
int  nvars,
SCIP_Bool  dynamiccols,
SCIP_Bool doingfine 
)
static

setup linear coefficients and constant of objective and objective sense

Parameters
scipSCIP data structure
datanodeXML root node for instance data
varsvariables in order of OSiL indices
nvarsnumber of variables
dynamiccolsshould columns be added and removed dynamically to the LP?
doingfinebuffer to indicate whether no errors occurred

Definition at line 293 of file reader_osil.c.

References FALSE, NULL, SCIP_CALL, SCIP_OBJSENSE_MAXIMIZE, SCIP_OBJSENSE_MINIMIZE, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPaddVar(), SCIPchgVarObj(), SCIPcreateVar(), SCIPerrorMessage, SCIPreleaseVar(), SCIPsetObjsense(), SCIPvarGetName(), xmlFindNodeMaxdepth(), xmlFirstChild(), xmlGetAttrval(), xmlGetData(), and xmlNextSibl().

Referenced by SCIP_DECL_READERREAD().

◆ readNConstraints()

static SCIP_RETCODE readNConstraints ( SCIP scip,
const XML_NODE datanode,
int *  nconss,
SCIP_Bool doingfine 
)
static

helper method to get the total number of constraints

Parameters
scipSCIP data structure
datanodeXML root node for instance data
nconsspointer to store the total number of constraints
doingfinebuffer to indicate whether no errors occurred

Definition at line 436 of file reader_osil.c.

References FALSE, NULL, SCIP_OKAY, SCIPerrorMessage, xmlFindNodeMaxdepth(), and xmlGetAttrval().

Referenced by SCIP_DECL_READERREAD().

◆ createConstraint()

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

helper method to create and add a constraint (or a nonlinear objective constraint)

Parameters
scipSCIP data structure
linvarsarray containing the linear variables (might be NULL)
lincoefsarray containing the coefficients of the linear variables (might be NULL)
nlinvarsthe total number of linear variables
quadvars1array containing the first variables of the quadratic terms (might be NULL)
quadvars2array containing the second variables of the quadratic terms (might be NULL)
quadcoefsarray containing the coefficients of the quadratic terms (might be NULL)
nquadtermsthe total number of quadratic terms
nlexprthe nonlinear part (might be NULL)
lhsleft-hand side
rhsright-hand side
namename of the constraint
objconswhether to add an objective constraints
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 482 of file reader_osil.c.

References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPaddCoefLinear(), SCIPaddCons(), SCIPaddVar(), SCIPappendExprSumExpr(), SCIPcreateConsLinear(), SCIPcreateConsNonlinear(), SCIPcreateExprQuadratic(), SCIPcreateExprSum(), SCIPcreateExprVar(), SCIPcreateVar(), SCIPinfinity(), SCIPisExprSum(), SCIPreleaseCons(), SCIPreleaseExpr(), SCIPreleaseVar(), and TRUE.

Referenced by readConstraints(), and SCIP_DECL_READERREAD().

◆ readConstraints()

static SCIP_RETCODE readConstraints ( SCIP scip,
const XML_NODE datanode,
int  nconss,
SCIP_VAR ***  linvars,
SCIP_Real **  lincoefs,
int *  nlinvars,
SCIP_VAR ***  quadvars1,
SCIP_VAR ***  quadvars2,
SCIP_Real **  quadcoefs,
int *  nquadterms,
SCIP_EXPR **  nlexprs,
SCIP_Bool  initialconss,
SCIP_Bool  dynamicconss,
SCIP_Bool  dynamicrows,
SCIP_Bool doingfine 
)
static

reads constraint-specific information; creates and adds linear and nonlinear constraints based on the information that have been collected by readLinearCoefs, readQuadraticCoefs, and readNonlinearExprs

Parameters
scipSCIP data structure
datanodeXML root node for instance data
nconsstotal number of constraints
linvarsarray containing for each constraint the linear variables
lincoefsarray containing for each constraint the coefficients of the linear variables
nlinvarsarray containing for each constraint the total number of linear variables
quadvars1array containing for each constraint the first variables of the quadratic terms
quadvars2array containing for each constraint the second variables of the quadratic terms
quadcoefsarray containing for each constraint the coefficients of the quadratic terms
nquadtermsarray containing for each constraint the total number of quadratic terms
nlexprsarray containing for each constraint the nonlinear part
initialconssshould model constraints be marked as initial?
dynamicconssshould model constraints be subject to aging?
dynamicrowsshould rows be added and removed dynamically to the LP?
doingfinebuffer to indicate whether no errors occurred

Definition at line 627 of file reader_osil.c.

References createConstraint(), FALSE, NULL, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPerrorMessage, SCIPinfinity(), SCIPsnprintf(), xmlFindNodeMaxdepth(), xmlFirstChild(), xmlGetAttrval(), and xmlNextSibl().

Referenced by SCIP_DECL_READERREAD().

◆ readMultIncr()

static void readMultIncr ( const XML_NODE node,
int *  mult,
int *  incrint,
SCIP_Real incrreal,
SCIP_Bool doingfine 
)
static

reads mult and incr attributes of an OSiL node

if mult attribute is not present, then returns mult=1 if incr attribute is not present, then returns incrint=0 and incrreal=0

Parameters
nodeXML node to read attributes from
multbuffer to store mult
incrintbuffer to store incr as int, or NULL if no int expected
incrrealbuffer to store incr as real, or NULL if no real expected
doingfinebuffer to indicate whether no errors occurred

Definition at line 781 of file reader_osil.c.

References FALSE, NULL, SCIPerrorMessage, SCIPisFinite, and xmlGetAttrval().

Referenced by readLinearCoefs().

◆ readLinearCoefs()

static SCIP_RETCODE readLinearCoefs ( SCIP scip,
const XML_NODE datanode,
SCIP_VAR **  vars,
int  nvars,
int  nconss,
SCIP_VAR ***  linvars,
SCIP_Real **  lincoefs,
int *  nlinvars,
SCIP_Bool doingfine 
)
static

parse linear coefficients of constraints

Parameters
scipSCIP data structure
datanodeXML root node for instance data
varsvariables in order of OSiL indices
nvarsnumber of variables
nconssnumber of constraints
linvarsarray to store for each constraint the linear variables
lincoefsarray to store for each constraint the coefficients of the linear variables
nlinvarsarray to store for each constraint the total number of linear variables
doingfinebuffer to indicate whether no errors occurred

Definition at line 847 of file reader_osil.c.

References FALSE, nterms, NULL, readMultIncr(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBlockMemoryArray, SCIPallocBufferArray, SCIPerrorMessage, SCIPfreeBufferArrayNull, SCIPisFinite, TRUE, xmlFindNodeMaxdepth(), xmlFirstChild(), xmlGetAttrval(), xmlGetData(), xmlGetName(), and xmlNextSibl().

Referenced by SCIP_DECL_READERREAD().

◆ readQuadraticCoefs()

static SCIP_RETCODE readQuadraticCoefs ( SCIP scip,
const XML_NODE datanode,
SCIP_VAR **  vars,
int  nvars,
int  nconss,
SCIP_VAR ***  quadvars1,
SCIP_VAR ***  quadvars2,
SCIP_Real **  quadcoefs,
int *  nquadterms,
int *  termssize,
SCIP_Bool doingfine 
)
static

read quadratic coefficients of constraints and objective

Parameters
scipSCIP data structure
datanodeXML root node for instance data
varsvariables in order of OSiL indices
nvarsnumber of variables
nconssnumber of constraints
quadvars1array to store for each constraint the first variables of the quadratic terms
quadvars2array to store for each constraint the second variables of the quadratic terms
quadcoefsarray to store for each constraint the coefficients of the quadratic terms
nquadtermsarray to store for each constraint the total number of quadratic terms
termssizepointer to store the size of quadvars1, quadvars2, and quadcoefs
doingfinebuffer to indicate whether no errors occurred

Definition at line 1228 of file reader_osil.c.

References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPcalcMemGrowSize(), SCIPerrorMessage, SCIPreallocBlockMemoryArray, xmlFindNodeMaxdepth(), xmlFirstChild(), xmlGetAttrval(), xmlGetName(), and xmlNextSibl().

Referenced by SCIP_DECL_READERREAD().

◆ readExpression()

static SCIP_RETCODE readExpression ( SCIP scip,
SCIP_EXPR **  expr,
const XML_NODE node,
SCIP_VAR **  vars,
int  nvars,
SCIP_Bool doingfine 
)
static

transforms OSnL expression tree into SCIP expression

Parameters
scipSCIP data structure
exprbuffer to store pointer to created expression
noderoot node of expression to be read
varsvariables in order of OSiL indices
nvarstotal number of variables in problem
doingfinebuffer to indicate whether no errors occurred

Definition at line 1410 of file reader_osil.c.

References FALSE, M_PI, NULL, readExpression(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPcalcMemGrowSize(), SCIPcaptureExpr(), SCIPcreateExprAbs(), SCIPcreateExprCos(), SCIPcreateExprErf(), SCIPcreateExprExp(), SCIPcreateExprLog(), SCIPcreateExprPow(), SCIPcreateExprProduct(), SCIPcreateExprQuadratic(), SCIPcreateExprSignpower(), SCIPcreateExprSin(), SCIPcreateExprSum(), SCIPcreateExprValue(), SCIPcreateExprVar(), SCIPerrorMessage, SCIPfreeBufferArray, SCIPgetValueExprValue(), SCIPisExprValue(), SCIPisFinite, SCIPreallocBufferArray, SCIPreleaseExpr(), SCIPwarningMessage(), xmlFirstChild(), xmlGetAttrval(), xmlGetName(), and xmlNextSibl().

Referenced by readExpression(), and readNonlinearExprs().

◆ readNonlinearExprs()

static SCIP_RETCODE readNonlinearExprs ( SCIP scip,
const XML_NODE datanode,
SCIP_VAR **  vars,
int  nvars,
int  nconss,
SCIP_EXPR **  exprs,
SCIP_Bool doingfine 
)
static

read nonlinear expressions of constraints and objective

Parameters
scipSCIP data structure
datanodeXML root node for instance data
varsvariables in order of OSiL indices
nvarsnumber of variables
nconssnumber of constraints
exprsarray to store for each constraint a nonlinear expression
doingfinebuffer to indicate whether no errors occurred

Definition at line 2001 of file reader_osil.c.

References FALSE, NULL, readExpression(), SCIP_CALL, SCIP_OKAY, SCIPerrorMessage, xmlFindNodeMaxdepth(), xmlFirstChild(), xmlGetAttrval(), xmlGetName(), and xmlNextSibl().

Referenced by SCIP_DECL_READERREAD().

◆ readSOScons()

static SCIP_RETCODE readSOScons ( SCIP scip,
const XML_NODE datanode,
SCIP_VAR **  vars,
int  nvars,
SCIP_Bool  initialconss,
SCIP_Bool  dynamicconss,
SCIP_Bool  dynamicrows,
SCIP_Bool doingfine 
)
static

read sos1 and sos2 constraints

sos constraints are expected to be given as a node of <instanceData> in the following way:

<specialOrderedSets numberOfSpecialOrderedSets="1">
<sos numberOfVar="2" order="2">
<var idx="1"></var>
<var idx="2"></var>
</sos>
</specialOrderedSets>

Weights are determined by the order in which the variables are given

Parameters
scipSCIP data structure
datanodeXML root node for instance data
varsvariables in order of OSiL indices
nvarsnumber of variables
initialconssshould model constraints be marked as initial?
dynamicconssshould model constraints be subject to aging?
dynamicrowsshould rows be added and removed dynamically to the LP?
doingfinebuffer to indicate whether no errors occurred

Definition at line 2111 of file reader_osil.c.

References FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPABORT, SCIPaddCons(), SCIPaddVarSOS1(), SCIPaddVarSOS2(), SCIPcreateConsSOS1(), SCIPcreateConsSOS2(), SCIPerrorMessage, SCIPreleaseCons(), SCIPsnprintf(), TRUE, xmlFindNodeMaxdepth(), xmlFirstChild(), xmlGetAttrval(), xmlGetName(), and xmlNextSibl().

Referenced by SCIP_DECL_READERREAD().

◆ SCIP_DECL_READERCOPY()

static SCIP_DECL_READERCOPY ( readerCopyOsil  )
static

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

Definition at line 2306 of file reader_osil.c.

References NULL, SCIP_CALL, SCIP_OKAY, and SCIPincludeReaderOsil().

◆ SCIP_DECL_READERREAD()