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 "blockmemshell/memory.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_cons.h"
#include "scip/pub_message.h"
#include "scip/pub_reader.h"
#include "scip/pub_var.h"
#include "scip/reader_pbm.h"
#include "scip/scip_cons.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_param.h"
#include "scip/scip_reader.h"
#include "scip/scip_var.h"
#include <string.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

◆ READER_NAME

#define READER_NAME   "pbmreader"

◆ READER_DESC

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

Definition at line 44 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

◆ READER_EXTENSION

#define READER_EXTENSION   "pbm"

Definition at line 45 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

◆ PBM_MAX_LINELEN

#define PBM_MAX_LINELEN   71

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

Definition at line 50 of file reader_pbm.c.

Referenced by SCIPwritePbm().

◆ DEFAULT_PBM_BINARY

#define DEFAULT_PBM_BINARY   TRUE

binary is the default format for PBM

Definition at line 51 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

◆ DEFAULT_PBM_MAXROWS

#define DEFAULT_PBM_MAXROWS   1000

allowed maximum of pixel-rows int the picture

Definition at line 52 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

◆ DEFAULT_PBM_MAXCOLS

#define DEFAULT_PBM_MAXCOLS   1000

allowed maximum of pixel-columns in the picture

Definition at line 53 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

◆ readerReadPbm

#define readerReadPbm   NULL

problem reading method of reader

Definition at line 420 of file reader_pbm.c.

Referenced by SCIPincludeReaderPbm().

Function Documentation

◆ getActiveVariables()

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 69 of file reader_pbm.c.

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

Referenced by printLinearCons().

◆ getActiveVariables2()

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 113 of file reader_pbm.c.

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

Referenced by SCIPwritePbm().

◆ clearLine()

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

clears the given line buffer

Parameters
linebufferline
linecntnumber of characters in line

Definition at line 156 of file reader_pbm.c.

References NULL.

Referenced by SCIPwritePbm().

◆ flushBits()

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 171 of file reader_pbm.c.

References NULL.

Referenced by appendBit(), and drawScaledImage().

◆ appendBit()

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 197 of file reader_pbm.c.

References flushBits(), and NULL.

Referenced by drawScaledImage().

◆ getSubmatrixSize()

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 218 of file reader_pbm.c.

Referenced by SCIPwritePbm().

◆ printRow()

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 266 of file reader_pbm.c.

References NULL, SCIPvarGetProbindex(), x, and y.

Referenced by printLinearCons(), and SCIPwritePbm().

◆ printLinearCons()

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 300 of file reader_pbm.c.

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

Referenced by SCIPwritePbm().

◆ drawScaledImage()

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 354 of file reader_pbm.c.

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

Referenced by SCIPwritePbm().

◆ SCIP_DECL_READERCOPY()

static SCIP_DECL_READERCOPY ( readerCopyPbm  )
static

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

Definition at line 391 of file reader_pbm.c.

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

◆ SCIP_DECL_READERFREE()

static SCIP_DECL_READERFREE ( readerFreePbm  )
static

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

Definition at line 405 of file reader_pbm.c.

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

◆ SCIP_DECL_READERWRITE()

static SCIP_DECL_READERWRITE ( readerWritePbm  )
static

problem writing method of reader

Definition at line 424 of file reader_pbm.c.

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