Scippy

SCIP

Solving Constraint Integer Programs

reader_ppm.c File Reference

Detailed Description

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

Author
Michael Winkler

Definition in file reader_ppm.c.

#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "scip/reader_ppm.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   "ppmreader"
 
#define READER_DESC   "file writer for portable pixmap file format (PPM), open with common graphic viewer programs (e.g. xview)"
 
#define READER_EXTENSION   "ppm"
 
#define PPM_MAX_LINELEN   71
 
#define DEFAULT_PPM_RGB_LIMIT   160
 
#define DEFAULT_PPM_COEF_LIMIT   3
 
#define DEFAULT_PPM_RGB_RELATIVE   TRUE
 
#define DEFAULT_PPM_RGB_ASCII   TRUE
 

Functions

static void initReaderdata (SCIP_READERDATA *readerdata)
 
static SCIP_RETCODE getActiveVariables (SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
 
static void clearLine (char *linebuffer, int *linecnt)
 
static void endLine (SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, char *linebuffer, int *linecnt)
 
static void appendLine (SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, char *linebuffer, int *linecnt, const char *extension)
 
static void calcColorValue (SCIP *scip, SCIP_READERDATA *readerdata, SCIP_Real coef, int *red, int *green, int *blue, SCIP_Real scale)
 
static void printRow (SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, SCIP_VAR **vars, SCIP_Real *vals, int nvars, int ntotalvars, SCIP_Real maxcoef)
 
static SCIP_RETCODE printLinearCons (SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, SCIP_VAR **vars, SCIP_Real *vals, int nvars, int ncompletevars, SCIP_Bool transformed, SCIP_Real *maxcoef, SCIP_Bool printbool)
 
static SCIP_DECL_READERCOPY (readerCopyPpm)
 
static SCIP_DECL_READERFREE (readerFreePpm)
 
static SCIP_DECL_READERWRITE (readerWritePpm)
 
SCIP_RETCODE SCIPincludeReaderPpm (SCIP *scip)
 
SCIP_RETCODE SCIPwritePpm (SCIP *scip, FILE *file, const char *name, SCIP_READERDATA *readerdata, SCIP_Bool transformed, SCIP_VAR **vars, int nvars, SCIP_CONS **conss, int nconss, SCIP_RESULT *result)
 

Macro Definition Documentation

#define READER_NAME   "ppmreader"
#define READER_DESC   "file writer for portable pixmap file format (PPM), open with common graphic viewer programs (e.g. xview)"

Definition at line 37 of file reader_ppm.c.

Referenced by SCIPincludeReaderPpm().

#define READER_EXTENSION   "ppm"

Definition at line 38 of file reader_ppm.c.

Referenced by SCIPincludeReaderPpm().

#define PPM_MAX_LINELEN   71

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

Definition at line 43 of file reader_ppm.c.

Referenced by appendLine(), printRow(), and SCIPwritePpm().

#define DEFAULT_PPM_RGB_LIMIT   160

Definition at line 44 of file reader_ppm.c.

Referenced by initReaderdata(), and SCIPincludeReaderPpm().

#define DEFAULT_PPM_COEF_LIMIT   3

Definition at line 45 of file reader_ppm.c.

Referenced by initReaderdata(), and SCIPincludeReaderPpm().

#define DEFAULT_PPM_RGB_RELATIVE   TRUE

Definition at line 46 of file reader_ppm.c.

Referenced by initReaderdata(), and SCIPincludeReaderPpm().

#define DEFAULT_PPM_RGB_ASCII   TRUE

Definition at line 47 of file reader_ppm.c.

Referenced by initReaderdata(), and SCIPincludeReaderPpm().

Function Documentation

static void initReaderdata ( SCIP_READERDATA readerdata)
static

initializes the reader data

Parameters
readerdatareader data

Definition at line 64 of file reader_ppm.c.

References DEFAULT_PPM_COEF_LIMIT, DEFAULT_PPM_RGB_ASCII, DEFAULT_PPM_RGB_LIMIT, DEFAULT_PPM_RGB_RELATIVE, and NULL.

Referenced by SCIPincludeReaderPpm().

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 inrc/scip/reader_ppm.c linear 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 79 of file reader_ppm.c.

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

Referenced by printLinearCons().

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

clears the given line buffer

Parameters
linebufferline
linecntnumber of characters in line

Definition at line 120 of file reader_ppm.c.

References NULL.

Referenced by endLine(), printRow(), and SCIPwritePpm().

static void endLine ( SCIP scip,
FILE *  file,
SCIP_READERDATA readerdata,
char *  linebuffer,
int *  linecnt 
)
static

ends the given line with '\0' and prints it to the given file stream

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
readerdatainformation for reader
linebufferline
linecntnumber of characters in line

Definition at line 134 of file reader_ppm.c.

References clearLine(), NULL, and SCIPinfoMessage().

Referenced by appendLine(), and printRow().

static void appendLine ( SCIP scip,
FILE *  file,
SCIP_READERDATA readerdata,
char *  linebuffer,
int *  linecnt,
const char *  extension 
)
static

appends extension to line and prints it to the give file stream if the line exceeded PPM_PRINTLEN

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
readerdatainformation for reader
linebufferline
linecntnumber of characters in line
extensionstring to extent the line

Definition at line 161 of file reader_ppm.c.

References endLine(), NULL, and PPM_MAX_LINELEN.

Referenced by printRow().

static void calcColorValue ( SCIP scip,
SCIP_READERDATA readerdata,
SCIP_Real  coef,
int *  red,
int *  green,
int *  blue,
SCIP_Real  scale 
)
static
Parameters
scipSCIP data structure
readerdatainformation for reader
coefCoefficient to scale
redred part
greengreen part
blueblue part
scalemaximal coefficient

Definition at line 186 of file reader_ppm.c.

References NULL, SCIP_Real, and SCIPfloor().

Referenced by printRow().

static void printRow ( SCIP scip,
FILE *  file,
SCIP_READERDATA readerdata,
SCIP_VAR **  vars,
SCIP_Real vals,
int  nvars,
int  ntotalvars,
SCIP_Real  maxcoef 
)
static
Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
readerdatainformation for reader
varsarray of constraint variables
valsarray of constraint values
nvarsnumber of constraint variables
ntotalvarsnumber of variables
maxcoefmaximal coefficient

Definition at line 246 of file reader_ppm.c.

References appendLine(), calcColorValue(), clearLine(), endLine(), NULL, PPM_MAX_LINELEN, SCIPsnprintf(), and SCIPvarGetProbindex().

Referenced by printLinearCons().

static SCIP_RETCODE printLinearCons ( SCIP scip,
FILE *  file,
SCIP_READERDATA readerdata,
SCIP_VAR **  vars,
SCIP_Real vals,
int  nvars,
int  ncompletevars,
SCIP_Bool  transformed,
SCIP_Real maxcoef,
SCIP_Bool  printbool 
)
static

prints given linear constraint information in PPM format to file stream

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
readerdatainformation for reader
varsarray of variables
valsarray of coefficients values (or NULL if all coefficient values are 1)
nvarsnumber of variables
ncompletevarsnumber of variables in whole problem
transformedtransformed constraint?
maxcoefmaximal coefficient
printboolprint row or calculate maximum coefficient

Definition at line 350 of file reader_ppm.c.

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

Referenced by SCIPwritePpm().

static SCIP_DECL_READERCOPY ( readerCopyPpm  )
static

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

Definition at line 425 of file reader_ppm.c.

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

static SCIP_DECL_READERFREE ( readerFreePpm  )
static

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

Definition at line 439 of file reader_ppm.c.

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

static SCIP_DECL_READERWRITE ( readerWritePpm  )
static

problem writing method of reader

Definition at line 454 of file reader_ppm.c.

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

SCIP_RETCODE SCIPwritePpm ( SCIP scip,
FILE *  file,
const char *  name,
SCIP_READERDATA readerdata,
SCIP_Bool  transformed,
SCIP_VAR **  vars,
int  nvars,
SCIP_CONS **  conss,
int  nconss,
SCIP_RESULT result 
)

writes problem to file

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
varsarray with active variables ordered binary, integer, implicit, continuous
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 515 of file reader_ppm.c.

References clearLine(), FALSE, NULL, PPM_MAX_LINELEN, printLinearCons(), SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIP_SUCCESS, SCIPallocBufferArray, SCIPconsGetHdlr(), SCIPconshdlrGetName(), SCIPconsIsEnabled(), SCIPconsIsTransformed(), SCIPdebugPrintf, SCIPfreeBufferArray, SCIPgetNVarsKnapsack(), SCIPgetNVarsLinear(), SCIPgetNVarsLogicor(), SCIPgetNVarsSetppc(), SCIPgetValsLinear(), SCIPgetVarsKnapsack(), SCIPgetVarsLinear(), SCIPgetVarsLogicor(), SCIPgetVarsSetppc(), SCIPgetVarVarbound(), SCIPgetVbdcoefVarbound(), SCIPgetVbdvarVarbound(), SCIPgetWeightsKnapsack(), SCIPinfoMessage(), SCIPprintCons(), SCIPwarningMessage(), and TRUE.

Referenced by SCIP_DECL_READERWRITE().