Scippy

SCIP

Solving Constraint Integer Programs

reader_osil.c File Reference

Detailed Description

OS instance language (OSiL) format file reader.

Author
Stefan Vigerske
Ingmar Vierhaus

Definition in file reader_osil.c.

#include <assert.h>
#include <string.h>
#include <math.h>
#include "scip/reader_osil.h"
#include "scip/scip.h"
#include "scip/cons_bounddisjunction.h"
#include "scip/cons_linear.h"
#include "scip/cons_quadratic.h"
#include "scip/cons_nonlinear.h"
#include "scip/cons_sos1.h"
#include "scip/cons_sos2.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"
 

Enumerations

enum  CONSTYPE {
  LINEAR,
  QUADRATIC,
  NONLINEAR
}
 

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 readConstraints (SCIP *scip, const XML_NODE *datanode, SCIP_CONS ***conss, CONSTYPE **constypes, int *nconss, 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, SCIP_CONS **conss, CONSTYPE *constypes, int nconss, SCIP_Bool *doingfine)
 
static SCIP_RETCODE readQuadraticCoefs (SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, SCIP_CONS **conss, CONSTYPE *constypes, int nconss, SCIP_CONS **objcons, CONSTYPE *objconstype, SCIP_Bool *doingfine)
 
static SCIP_RETCODE readExpression (SCIP *scip, SCIP_EXPR **expr, const XML_NODE *node, int *exprvaridx, int *nexprvars, int nvars, SCIP_Bool *doingfine)
 
static SCIP_RETCODE readNonlinearExprs (SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, SCIP_CONS **conss, CONSTYPE *constypes, int nconss, SCIP_CONS **objcons, CONSTYPE *objconstype, 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 41 of file reader_osil.c.

Referenced by SCIPincludeReaderOsil().

◆ READER_DESC

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

Definition at line 42 of file reader_osil.c.

Referenced by SCIPincludeReaderOsil().

◆ READER_EXTENSION

#define READER_EXTENSION   "osil"

Definition at line 43 of file reader_osil.c.

Referenced by SCIPincludeReaderOsil().

Enumeration Type Documentation

◆ CONSTYPE

enum CONSTYPE

type of constraint

Enumerator
LINEAR 

linear constraint

QUADRATIC 

quadratic constraint

NONLINEAR 

general nonlinear constraint

Definition at line 50 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 occured

Definition at line 64 of file reader_osil.c.

References FALSE, 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 occured

Definition at line 278 of file reader_osil.c.

References FALSE, 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().

◆ readConstraints()

static SCIP_RETCODE readConstraints ( SCIP scip,
const XML_NODE datanode,
SCIP_CONS ***  conss,
CONSTYPE **  constypes,
int *  nconss,
SCIP_Bool  initialconss,
SCIP_Bool  dynamicconss,
SCIP_Bool  dynamicrows,
SCIP_Bool doingfine 
)
static

setup constraint sides as linear constraints

constraints are not added to the problem yet

Parameters
scipSCIP data structure
datanodeXML root node for instance data
conssbuffer to store array of (linear) constraints
constypesbuffer to store type of constraints (will be all LINEAR)
nconssbuffer to store number of 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?
doingfinebuffer to indicate whether no errors occured

Definition at line 424 of file reader_osil.c.

References FALSE, LINEAR, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPcreateConsLinear(), SCIPerrorMessage, SCIPinfinity(), SCIPsnprintf(), TRUE, 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 occured

Definition at line 594 of file reader_osil.c.

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

Referenced by readLinearCoefs().

◆ readLinearCoefs()

static SCIP_RETCODE readLinearCoefs ( SCIP scip,
const XML_NODE datanode,
SCIP_VAR **  vars,
int  nvars,
SCIP_CONS **  conss,
CONSTYPE constypes,
int  nconss,
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
conssconstraints in order of OSiL indices
constypestype of constraints (assumed to be LINEAR)
nconssnumber of constraints
doingfinebuffer to indicate whether no errors occured

Definition at line 660 of file reader_osil.c.

References FALSE, LINEAR, readMultIncr(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPaddCoefLinear(), 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,
SCIP_CONS **  conss,
CONSTYPE constypes,
int  nconss,
SCIP_CONS **  objcons,
CONSTYPE objconstype,
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
conssconstraints in order of OSiL indices
constypestype of constraints (assumed to be LINEAR)
nconssnumber of constraints
objconsbuffer to store constraint for nonlinear part of objective function, or to add to if already existing
objconstypebuffer to store type of objective constraint, if created (should be QUADRATIC)
doingfinebuffer to indicate whether no errors occured

Definition at line 1000 of file reader_osil.c.

References FALSE, LINEAR, QUADRATIC, SCIP_CALL, SCIP_OBJSENSE_MAXIMIZE, SCIP_OBJSENSE_MINIMIZE, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPaddBilinTermQuadratic(), SCIPaddVar(), SCIPconsGetName(), SCIPconsIsChecked(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPcreateConsQuadratic(), SCIPcreateVar(), SCIPerrorMessage, SCIPgetLhsLinear(), SCIPgetNVarsLinear(), SCIPgetObjsense(), SCIPgetRhsLinear(), SCIPgetValsLinear(), SCIPgetVarsLinear(), SCIPinfinity(), SCIPreleaseCons(), SCIPreleaseVar(), TRUE, 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,
int *  exprvaridx,
int *  nexprvars,
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
exprvaridxarray with index of problem variables in expression graph
nexprvarsnumber of variables in currently processed expression so far
nvarstotal number of variables in problem (and length of exprvaridx array)
doingfinebuffer to indicate whether no errors occurred

Definition at line 1214 of file reader_osil.c.

References SCIP_QuadElement::coef, FALSE, SCIP_QuadElement::idx1, SCIP_QuadElement::idx2, log(), M_PI, SCIP_CALL, SCIP_EXPR_ABS, SCIP_EXPR_CONST, SCIP_EXPR_DIV, SCIP_EXPR_EXP, SCIP_EXPR_INTPOWER, SCIP_EXPR_LOG, SCIP_EXPR_MAX, SCIP_EXPR_MIN, SCIP_EXPR_MUL, SCIP_EXPR_PRODUCT, SCIP_EXPR_REALPOWER, SCIP_EXPR_SQRT, SCIP_EXPR_SQUARE, SCIP_EXPR_SUM, SCIP_EXPR_VARIDX, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPblkmem(), SCIPcalcMemGrowSize(), SCIPerrorMessage, SCIPexprAdd(), SCIPexprCreate(), SCIPexprCreateLinear(), SCIPexprCreateQuadratic(), SCIPexprFreeDeep(), SCIPexprGetOperator(), SCIPexprGetOpReal(), SCIPexprMulConstant(), SCIPfreeBufferArray, SCIPisFinite, SCIPisIntegral(), SCIPreallocBufferArray, SCIPround(), xmlFirstChild(), xmlGetAttrval(), xmlGetName(), and xmlNextSibl().

Referenced by readNonlinearExprs().

◆ readNonlinearExprs()

static SCIP_RETCODE readNonlinearExprs ( SCIP scip,
const XML_NODE datanode,
SCIP_VAR **  vars,
int  nvars,
SCIP_CONS **  conss,
CONSTYPE constypes,
int  nconss,
SCIP_CONS **  objcons,
CONSTYPE objconstype,
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
conssconstraints in order of OSiL indices
constypestype of constraints (assumed to be LINEAR)
nconssnumber of constraints
objconsbuffer to store constraint for nonlinear part of objective function, or to add to if already existing
objconstypebuffer to store type of objective constraint, if created (should be QUADRATIC)
doingfinebuffer to indicate whether no errors occurred

Definition at line 1863 of file reader_osil.c.

References SCIP_QuadVarTerm::adjbilin, SCIP_QuadElement::coef, SCIP_BilinTerm::coef, FALSE, SCIP_QuadElement::idx1, SCIP_QuadElement::idx2, SCIP_QuadVarTerm::lincoef, LINEAR, MAX, SCIP_QuadVarTerm::nadjbilin, NONLINEAR, QUADRATIC, readExpression(), SCIP_CALL, SCIP_CALL_TERMINATE, SCIP_EXPR_VARIDX, SCIP_OBJSENSE_MAXIMIZE, SCIP_OBJSENSE_MINIMIZE, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPaddExprtreesNonlinear(), SCIPaddVar(), SCIPallocBufferArray, SCIPblkmem(), SCIPconsGetName(), SCIPconsIsChecked(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPconsIsStickingAtNode(), SCIPcreateConsNonlinear(), SCIPcreateVar(), SCIPerrorMessage, SCIPexprCreate(), SCIPexprCreateQuadratic(), SCIPexprtreeCreate(), SCIPexprtreeFree(), SCIPexprtreeSetVars(), SCIPfindQuadVarTermQuadratic(), SCIPfreeBufferArray, SCIPgetBilinTermsQuadratic(), SCIPgetLhsLinear(), SCIPgetLhsNonlinear(), SCIPgetLinearCoefsNonlinear(), SCIPgetLinearVarsNonlinear(), SCIPgetNBilinTermsQuadratic(), SCIPgetNLinearVarsNonlinear(), SCIPgetNQuadVarTermsQuadratic(), SCIPgetNVarsLinear(), SCIPgetObjsense(), SCIPgetQuadVarTermsQuadratic(), SCIPgetRhsLinear(), SCIPgetRhsNonlinear(), SCIPgetValsLinear(), SCIPgetVarsLinear(), SCIPinfinity(), SCIPreleaseCons(), SCIPreleaseVar(), SCIPsortQuadVarTermsQuadratic(), SCIP_QuadVarTerm::sqrcoef, TRUE, SCIP_QuadVarTerm::var, 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 2193 of file reader_osil.c.

References FALSE, 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 2387 of file reader_osil.c.

References SCIP_CALL, SCIP_OKAY, and SCIPincludeReaderOsil().

◆ SCIP_DECL_READERREAD()