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 "scip/pub_fileio.h"
#include "scip/pub_message.h"
#include "scip/pub_misc.h"
#include "scip/pub_reader.h"
#include "scip/pub_var.h"
#include "scip/reader_bnd.h"
#include "scip/scip_general.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_numerics.h"
#include "scip/scip_param.h"
#include "scip/scip_reader.h"
#include "scip/scip_var.h"
#include <string.h>
#include <strings.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 57 of file reader_bnd.c.

Referenced by SCIPincludeReaderBnd(), and SCIPincludeReaderZpl().

◆ READER_EXTENSION

#define READER_EXTENSION   "bnd"

Definition at line 58 of file reader_bnd.c.

Referenced by SCIPincludeReaderBnd(), and SCIPincludeReaderZpl().

◆ DEFAULT_IMPROVEONLY

#define DEFAULT_IMPROVEONLY   FALSE

only use improving bounds

Definition at line 60 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 76 of file reader_bnd.c.

References FALSE, MAX, MIN, NULL, 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 238 of file reader_bnd.c.

References NULL, 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 257 of file reader_bnd.c.

References NULL, 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 287 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 314 of file reader_bnd.c.

References NULL, 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 377 of file reader_bnd.c.

References NULL, 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 389 of file reader_bnd.c.

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