Scippy

SCIP

Solving Constraint Integer Programs

reader_pbm.c File Reference

Detailed Description

file writer for portable bitmap file format (PBM), open with common graphic viewer programs (e.g. xview)

Author
Alexandra Kraft

Definition in file reader_pbm.c.

#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "scip/reader_pbm.h"
#include "scip/cons_knapsack.h"
#include "scip/cons_linear.h"
#include "scip/cons_logicor.h"
#include "scip/cons_setppc.h"
#include "scip/cons_varbound.h"
#include "scip/pub_misc.h"

Go to the source code of this file.

Macros

#define READER_NAME   "pbmreader"
 
#define READER_DESC   "file writer for portable bitmap file format (PBM), open with common graphic viewer programs (e.g. xview)"
 
#define READER_EXTENSION   "pbm"
 
#define PBM_MAX_LINELEN   71
 
#define DEFAULT_PBM_BINARY   TRUE
 
#define DEFAULT_PBM_MAXROWS   1000
 
#define DEFAULT_PBM_MAXCOLS   1000
 
#define readerReadPbm   NULL
 

Functions

static SCIP_RETCODE getActiveVariables (SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
 
static SCIP_RETCODE getActiveVariables2 (SCIP *scip, SCIP_VAR **vars, int *nvars, SCIP_Bool transformed)
 
static void clearLine (char *linebuffer, int *linecnt)
 
static void flushBits (SCIP *scip, FILE *file, unsigned char *bitcnt, unsigned char *bitbuffer)
 
static void appendBit (SCIP *scip, FILE *file, unsigned char bit, unsigned char *bitcnt, unsigned char *bitbuffer)
 
static int getSubmatrixSize (SCIP_READERDATA *readerdata, int nvars, int nconss)
 
static void printRow (SCIP *scip, SCIP_READERDATA *readerdata, SCIP_VAR **vars, int conscnt, int nvars, int submatrixsize, int *scaledimage)
 
static SCIP_RETCODE printLinearCons (SCIP *scip, SCIP_READERDATA *readerdata, SCIP_VAR **vars, SCIP_Real *vals, int nvars, int conscnt, SCIP_Bool transformed, int submatrixsize, int *scaledimage)
 
static void drawScaledImage (SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, int *scaledimage)
 
static SCIP_DECL_READERCOPY (readerCopyPbm)
 
static SCIP_DECL_READERFREE (readerFreePbm)
 
static SCIP_DECL_READERWRITE (readerWritePbm)
 
SCIP_RETCODE SCIPincludeReaderPbm (SCIP *scip)
 
SCIP_RETCODE SCIPwritePbm (SCIP *scip, FILE *file, const char *name, SCIP_READERDATA *readerdata, SCIP_Bool transformed, int nvars, SCIP_CONS **conss, int nconss, SCIP_RESULT *result)
 

Macro Definition Documentation

#define READER_NAME   "pbmreader"
#define READER_DESC   "file writer for portable bitmap file format (PBM), open with common graphic viewer programs (e.g. xview)"

Definition at line 37 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

#define READER_EXTENSION   "pbm"

Definition at line 38 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

#define PBM_MAX_LINELEN   71

the maximum length of any line is 70 + '\0' = 71

Definition at line 43 of file reader_pbm.c.

Referenced by SCIPwritePbm().

#define DEFAULT_PBM_BINARY   TRUE

binary is the default format for PBM

Definition at line 44 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

#define DEFAULT_PBM_MAXROWS   1000

allowed maximum of pixel-rows int the picture

Definition at line 45 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

#define DEFAULT_PBM_MAXCOLS   1000

allowed maximum of pixel-columns in the picture

Definition at line 46 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

#define readerReadPbm   NULL

problem reading method of reader

Definition at line 414 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

Function Documentation

static SCIP_RETCODE getActiveVariables ( SCIP scip,
SCIP_VAR **  vars,
SCIP_Real scalars,
int *  nvars,
SCIP_Real constant,
SCIP_Bool  transformed 
)
static

transforms given variables, scalars, and constant to the corresponding active variables, scalars, and constant

Parameters
scipSCIP data structure
varsvars array to get active variables for
scalarsscalars a_1, ..., a_n in sum a_1*x_1 + ... + a_n*x_n + c
nvarspointer to number of variables and values in vars and vals array
constantpointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c
transformedtransformed constraint?

Definition at line 62 of file reader_pbm.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPgetProbvarLinearSum(), SCIPreallocBufferArray, SCIPvarGetOrigvarSum(), and TRUE.

Referenced by printLinearCons().

static SCIP_RETCODE getActiveVariables2 ( SCIP scip,
SCIP_VAR **  vars,
int *  nvars,
SCIP_Bool  transformed 
)
static

transforms given variables to the corresponding active variables

Parameters
scipSCIP data structure
varsvars array to get active variables for
nvarspointer to number of variables and values in vars and vals array
transformedtransformed constraint?

Definition at line 106 of file reader_pbm.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPgetActiveVars(), SCIPreallocBufferArray, and SCIPvarGetOrigvarSum().

Referenced by SCIPwritePbm().

static void clearLine ( char *  linebuffer,
int *  linecnt 
)
static

clears the given line buffer

Parameters
linebufferline
linecntnumber of characters in line

Definition at line 149 of file reader_pbm.c.

References NULL.

Referenced by SCIPwritePbm().

static void flushBits ( SCIP scip,
FILE *  file,
unsigned char *  bitcnt,
unsigned char *  bitbuffer 
)
static

appends a bit to buffer and prints it to the give file stream if we've gather a whole byte

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
bitcntcounts bits until whole byte is gathered
bitbufferbit buffer

Definition at line 164 of file reader_pbm.c.

References NULL.

Referenced by appendBit(), and drawScaledImage().

static void appendBit ( SCIP scip,
FILE *  file,
unsigned char  bit,
unsigned char *  bitcnt,
unsigned char *  bitbuffer 
)
static

appends a bit to buffer and prints it to the given file stream if we've gathered a whole byte

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
bitbit to append
bitcntcounts bits until whole byte is gathered
bitbufferbit buffer

Definition at line 190 of file reader_pbm.c.

References flushBits(), and NULL.

Referenced by drawScaledImage().

static int getSubmatrixSize ( SCIP_READERDATA readerdata,
int  nvars,
int  nconss 
)
static

calculates the size of the quadratic matrix, which will correspond to one pixel in the picture

Parameters
readerdatainformation for reader
nvarsnumber of variables
nconssnumber of constraints

Definition at line 211 of file reader_pbm.c.

Referenced by SCIPwritePbm().

static void printRow ( SCIP scip,
SCIP_READERDATA readerdata,
SCIP_VAR **  vars,
int  conscnt,
int  nvars,
int  submatrixsize,
int *  scaledimage 
)
static

print row in PBM format to file stream

Parameters
scipSCIP data structure
readerdatainformation for reader
varsarray of constraint variables
conscntcurrent constraint
nvarsnumber of constraint variables
submatrixsizesize of the submatrices
scaledimagearray of ints that count variables in every submatrix

Definition at line 259 of file reader_pbm.c.

References NULL, and SCIPvarGetProbindex().

Referenced by printLinearCons(), and SCIPwritePbm().

static SCIP_RETCODE printLinearCons ( SCIP scip,
SCIP_READERDATA readerdata,
SCIP_VAR **  vars,
SCIP_Real vals,
int  nvars,
int  conscnt,
SCIP_Bool  transformed,
int  submatrixsize,
int *  scaledimage 
)
static

prints given linear constraint information in PBM format to file stream

Parameters
scipSCIP data structure
readerdatainformation for reader
varsarray of variables
valsarray of coefficients values (or NULL if all coefficient values are 1)
nvarscurrent constraint
conscntcounts variables in the constraint
transformedtransformed constraint?
submatrixsizesize of the submatrices
scaledimagearray of ints that count variables in every submatrix

Definition at line 293 of file reader_pbm.c.

References getActiveVariables(), NULL, printRow(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, and SCIPfreeBufferArray.

Referenced by SCIPwritePbm().

static void drawScaledImage ( SCIP scip,
FILE *  file,
SCIP_READERDATA readerdata,
int *  scaledimage 
)
static
Parameters
scipSCIP data structure
fileoutput file, or NULL if standard output should be used
readerdatainformation for reader
scaledimagearray of ints that count variables in every submatrix

Definition at line 347 of file reader_pbm.c.

References appendBit(), flushBits(), and NULL.

Referenced by SCIPwritePbm().

static SCIP_DECL_READERCOPY ( readerCopyPbm  )
static

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

Definition at line 385 of file reader_pbm.c.

References NULL, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludeReaderPbm(), and SCIPreaderGetName().

static SCIP_DECL_READERFREE ( readerFreePbm  )
static

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

Definition at line 399 of file reader_pbm.c.

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

static SCIP_DECL_READERWRITE ( readerWritePbm  )
static

problem writing method of reader

Definition at line 418 of file reader_pbm.c.

References NULL, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPreaderGetData(), SCIPreaderGetName(), and SCIPwritePbm().

SCIP_RETCODE SCIPincludeReaderPbm ( SCIP scip)
SCIP_RETCODE SCIPwritePbm ( SCIP scip,
FILE *  file,
const char *  name,
SCIP_READERDATA readerdata,
SCIP_Bool  transformed,
int  nvars,
SCIP_CONS **  conss,
int  nconss,
SCIP_RESULT result 
)
Parameters
scipSCIP data structure
fileoutput file, or NULL if standard output should be used
nameproblem name
readerdatainformation for reader
transformedTRUE iff problem is the transformed problem
nvarsnumber of active variables in the problem
conssarray with constraints of the problem
nconssnumber of constraints in the problem
resultpointer to store the result of the file writing call

Definition at line 466 of file reader_pbm.c.

References BMSclearMemoryArray, clearLine(), drawScaledImage(), getActiveVariables2(), getSubmatrixSize(), NULL, PBM_MAX_LINELEN, printLinearCons(), printRow(), SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIP_SUCCESS, SCIPallocBufferArray, SCIPconsGetHdlr(), SCIPconshdlrGetName(), SCIPconsIsEnabled(), SCIPconsIsTransformed(), SCIPfreeBufferArray, SCIPfreeBufferArrayNull, SCIPgetConsNVars(), SCIPgetConsVars(), SCIPgetNVarsKnapsack(), SCIPgetNVarsLinear(), SCIPgetNVarsLogicor(), SCIPgetNVarsSetppc(), SCIPgetValsLinear(), SCIPgetVarsKnapsack(), SCIPgetVarsLinear(), SCIPgetVarsLogicor(), SCIPgetVarsSetppc(), SCIPgetVarVarbound(), SCIPgetVbdcoefVarbound(), SCIPgetVbdvarVarbound(), SCIPgetWeightsKnapsack(), SCIPinfoMessage(), SCIPprintCons(), and SCIPwarningMessage().

Referenced by SCIP_DECL_READERWRITE().