Scippy

SCIP

Solving Constraint Integer Programs

reader_bnd.c File Reference

Detailed Description

file reader for variable bounds

Author
Ambros Gleixner
Ingmar Vierhaus
Benjamin Mueller

This reader allows to read a file containing new bounds for variables of the current problem. Each line of the file should have format

<variable name> <lower bound> <upper bound>

where infinite bounds can be written as inf, +inf or -inf. Note that only a subset of the variables may appear in the file. Lines with unknown variable names are ignored. The writing functionality can be used in problem and transformed stages. Note that in transformed stage, the leading "t_" in the name of a transformed variable will not appear in the output. This way, bounds written in transformed stage can be read again in problem stage.

Definition in file reader_bnd.c.

#include <assert.h>
#include <string.h>
#include <strings.h>
#include "scip/reader_bnd.h"
#include "scip/pub_misc.h"

Go to the source code of this file.

Macros

#define READER_NAME   "bndreader"
 
#define READER_DESC   "file reader for variable bounds"
 
#define READER_EXTENSION   "bnd"
 
#define DEFAULT_IMPROVEONLY   FALSE
 

Functions

static SCIP_RETCODE readBounds (SCIP *scip, const char *fname, SCIP_READERDATA *readerdata)
 
static SCIP_DECL_READERCOPY (readerCopyBnd)
 
static SCIP_DECL_READERREAD (readerReadBnd)
 
static void printBounds (SCIP *scip, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, SCIP_Real lb, SCIP_Real ub)
 
static SCIP_RETCODE SCIPwriteBnd (SCIP *scip, FILE *file, SCIP_VAR **vars, int nvars, SCIP_RESULT *result)
 
static SCIP_DECL_READERWRITE (readerWriteBnd)
 
static SCIP_DECL_READERFREE (readerFreeBnd)
 
SCIP_RETCODE SCIPincludeReaderBnd (SCIP *scip)
 

Macro Definition Documentation

◆ READER_NAME

#define READER_NAME   "bndreader"

◆ READER_DESC

#define READER_DESC   "file reader for variable bounds"

Definition at line 47 of file reader_bnd.c.

Referenced by SCIPincludeReaderBnd(), and SCIPincludeReaderZpl().

◆ READER_EXTENSION

#define READER_EXTENSION   "bnd"

Definition at line 48 of file reader_bnd.c.

Referenced by SCIPincludeReaderBnd(), and SCIPincludeReaderZpl().

◆ DEFAULT_IMPROVEONLY

#define DEFAULT_IMPROVEONLY   FALSE

only use improving bounds

Definition at line 50 of file reader_bnd.c.

Referenced by SCIPincludeReaderBnd().

Function Documentation

◆ readBounds()

static SCIP_RETCODE readBounds ( SCIP scip,
const char *  fname,
SCIP_READERDATA readerdata 
)
static

reads a given bound file, problem has to be in problem stage

Parameters
scipSCIP data structure
fnamename of the input file
readerdatapointer to the data of the reader

Definition at line 66 of file reader_bnd.c.

References FALSE, MAX, SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_NOFILE, SCIP_OKAY, SCIP_READERROR, SCIP_Real, SCIPchgVarLb(), SCIPchgVarUb(), SCIPerrorMessage, SCIPfclose(), SCIPfeof(), SCIPfgets(), SCIPfopen(), SCIPgetBoolParam(), SCIPinfinity(), SCIPisGT(), SCIPisLT(), SCIPparseVarName(), SCIPprintSysError(), SCIPsnprintf(), SCIPvarGetLbGlobal(), SCIPvarGetName(), SCIPvarGetUbGlobal(), SCIPwarningMessage(), and TRUE.

Referenced by SCIP_DECL_READERREAD().

◆ SCIP_DECL_READERCOPY()

static SCIP_DECL_READERCOPY ( readerCopyBnd  )
static

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

Definition at line 227 of file reader_bnd.c.

References READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludeReaderBnd(), and SCIPreaderGetName().

◆ SCIP_DECL_READERREAD()

static SCIP_DECL_READERREAD ( readerReadBnd  )
static

problem reading method of reader

In order to determine the type of the file, we have to open it. Thus, it has to be opened twice. This might be removed, but is likely to not hurt the performance too much.

Definition at line 246 of file reader_bnd.c.

References readBounds(), READER_NAME, SCIP_CALL, SCIP_DIDNOTRUN, SCIP_OKAY, SCIP_READERROR, SCIP_STAGE_PROBLEM, SCIP_SUCCESS, SCIPerrorMessage, SCIPgetStage(), SCIPreaderGetData(), and SCIPreaderGetName().

◆ printBounds()

static void printBounds ( SCIP scip,
SCIP_MESSAGEHDLR messagehdlr,
FILE *  file,
SCIP_Real  lb,
SCIP_Real  ub 
)
static

outputs given bounds into a file stream

Parameters
scipSCIP data structure
messagehdlrmessage handler
filefile stream to print into, or NULL for stdout
lblower bound
ubupper bound

Definition at line 276 of file reader_bnd.c.

References SCIP_REAL_FORMAT, SCIPisInfinity(), and SCIPmessageFPrintInfo().

Referenced by SCIPwriteBnd().

◆ SCIPwriteBnd()

static SCIP_RETCODE SCIPwriteBnd ( SCIP scip,
FILE *  file,
SCIP_VAR **  vars,
int  nvars,
SCIP_RESULT result 
)
static

writes problem to file

Parameters
scipSCIP data structure
filefile stream to print into, or NULL for stdout
varsarray with active variables ordered binary, integer, implicit, continuous
nvarsnumber of active variables in the problem
resultpointer to store the result of the file writing call

Definition at line 303 of file reader_bnd.c.

References printBounds(), SCIP_OKAY, SCIP_Real, SCIP_SUCCESS, SCIPgetMessagehdlr(), SCIPinfoMessage(), SCIPmessageFPrintInfo(), SCIPvarGetLbGlobal(), SCIPvarGetLbOriginal(), SCIPvarGetName(), SCIPvarGetUbGlobal(), SCIPvarGetUbOriginal(), SCIPvarIsTransformed(), SCIPvarIsTransformedOrigvar(), and SCIPwarningMessage().

Referenced by SCIP_DECL_READERWRITE().

◆ SCIP_DECL_READERWRITE()

static SCIP_DECL_READERWRITE ( readerWriteBnd  )
static

problem writing method of reader

Definition at line 366 of file reader_bnd.c.

References READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPreaderGetName(), and SCIPwriteBnd().

◆ SCIP_DECL_READERFREE()

static SCIP_DECL_READERFREE ( readerFreeBnd  )
static

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

Definition at line 378 of file reader_bnd.c.

References READER_NAME, SCIP_OKAY, SCIPfreeBlockMemory, SCIPreaderGetData(), and SCIPreaderGetName().