Scippy

SCIP

Solving Constraint Integer Programs

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 "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_misc.h"
#include "scip/pub_reader.h"
#include "scip/pub_var.h"
#include "scip/reader_ppm.h"
#include "scip/scip_cons.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>

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

◆ READER_NAME

#define READER_NAME   "ppmreader"

◆ READER_DESC

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

Definition at line 47 of file reader_ppm.c.

Referenced by SCIPincludeReaderPpm().

◆ READER_EXTENSION

#define READER_EXTENSION   "ppm"

Definition at line 48 of file reader_ppm.c.

Referenced by SCIPincludeReaderPpm().

◆ PPM_MAX_LINELEN

#define PPM_MAX_LINELEN   71

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

Definition at line 53 of file reader_ppm.c.

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

◆ DEFAULT_PPM_RGB_LIMIT

#define DEFAULT_PPM_RGB_LIMIT   160

Definition at line 54 of file reader_ppm.c.

Referenced by initReaderdata(), and SCIPincludeReaderPpm().

◆ DEFAULT_PPM_COEF_LIMIT

#define DEFAULT_PPM_COEF_LIMIT   3

Definition at line 55 of file reader_ppm.c.

Referenced by initReaderdata(), and SCIPincludeReaderPpm().

◆ DEFAULT_PPM_RGB_RELATIVE

#define DEFAULT_PPM_RGB_RELATIVE   TRUE

Definition at line 56 of file reader_ppm.c.

Referenced by initReaderdata(), and SCIPincludeReaderPpm().

◆ DEFAULT_PPM_RGB_ASCII

#define DEFAULT_PPM_RGB_ASCII   TRUE

Definition at line 57 of file reader_ppm.c.

Referenced by initReaderdata(), and SCIPincludeReaderPpm().

Function Documentation

◆ initReaderdata()

static void initReaderdata ( SCIP_READERDATA readerdata)
static

initializes the reader data

Parameters
readerdatareader data

Definition at line 74 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().

◆ 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 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 89 of file reader_ppm.c.

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

Referenced by printLinearCons().

◆ clearLine()

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

clears the given line buffer

Parameters
linebufferline
linecntnumber of characters in line

Definition at line 132 of file reader_ppm.c.

References NULL.

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

◆ endLine()

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 146 of file reader_ppm.c.

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

Referenced by appendLine(), and printRow().

◆ appendLine()

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 172 of file reader_ppm.c.

References endLine(), NULL, and PPM_MAX_LINELEN.

Referenced by printRow().

◆ calcColorValue()

static void calcColorValue ( SCIP scip,
SCIP_READERDATA readerdata,
SCIP_Real  coef,
int *  red,
int *  green,
int *  blue,
SCIP_Real  scale 
)
static

calculates the color value for a given coefficient

Parameters
scipSCIP data structure
readerdatainformation for reader
coefcoefficient to scale
redred part
greengreen part
blueblue part
scalemaximal coefficient

Definition at line 197 of file reader_ppm.c.

References NULL, SCIP_Real, and SCIPfloor().

Referenced by printRow().

◆ 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

print row in PPM format to file stream

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 259 of file reader_ppm.c.

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

Referenced by printLinearCons().

◆ 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 364 of file reader_ppm.c.

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

Referenced by SCIPwritePpm().

◆ SCIP_DECL_READERCOPY()

static SCIP_DECL_READERCOPY ( readerCopyPpm  )
static

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

Definition at line 443 of file reader_ppm.c.

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

◆ SCIP_DECL_READERFREE()

static SCIP_DECL_READERFREE ( readerFreePpm  )
static

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

Definition at line 457 of file reader_ppm.c.

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

◆ SCIP_DECL_READERWRITE()

static SCIP_DECL_READERWRITE ( readerWritePpm  )
static

problem writing method of reader

Definition at line 472 of file reader_ppm.c.

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