file writer for portable pixmap file format (PPM), open with common graphic viewer programs (e.g. xview)
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) |
#define READER_NAME "ppmreader" |
Definition at line 36 of file reader_ppm.c.
Referenced by SCIP_DECL_READERCOPY(), SCIP_DECL_READERFREE(), SCIP_DECL_READERWRITE(), and SCIPincludeReaderPpm().
#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().
|
static |
initializes the reader data
readerdata | reader data |
Definition at line 64 of file reader_ppm.c.
References DEFAULT_PPM_COEF_LIMIT, DEFAULT_PPM_RGB_ASCII, DEFAULT_PPM_RGB_LIMIT, and DEFAULT_PPM_RGB_RELATIVE.
Referenced by SCIPincludeReaderPpm().
|
static |
transforms given variables, scalars, and constant to the corresponding active variables, scalars, and constant
scip | SCIP data structure |
vars | vars array to get active variables for |
scalars | scalars a_1, ..., a_n inrc/scip/reader_ppm.c linear sum a_1*x_1 + ... + a_n*x_n + c |
nvars | pointer to number of variables and values in vars and vals array |
constant | pointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c |
transformed | transformed constraint? |
Definition at line 79 of file reader_ppm.c.
References SCIP_CALL, SCIP_OKAY, SCIPgetProbvarLinearSum(), SCIPreallocBufferArray, SCIPvarGetOrigvarSum(), and TRUE.
Referenced by printLinearCons().
|
static |
clears the given line buffer
linebuffer | line |
linecnt | number of characters in line |
Definition at line 122 of file reader_ppm.c.
Referenced by endLine(), printRow(), and SCIPwritePpm().
|
static |
ends the given line with '\0' and prints it to the given file stream
scip | SCIP data structure |
file | output file (or NULL for standard output) |
readerdata | information for reader |
linebuffer | line |
linecnt | number of characters in line |
Definition at line 136 of file reader_ppm.c.
References clearLine(), and SCIPinfoMessage().
Referenced by appendLine(), and printRow().
|
static |
appends extension to line and prints it to the give file stream if the line exceeded PPM_PRINTLEN
scip | SCIP data structure |
file | output file (or NULL for standard output) |
readerdata | information for reader |
linebuffer | line |
linecnt | number of characters in line |
extension | string to extent the line |
Definition at line 162 of file reader_ppm.c.
References endLine(), and PPM_MAX_LINELEN.
Referenced by printRow().
|
static |
calculates the color value for a given coefficient
scip | SCIP data structure |
readerdata | information for reader |
coef | coefficient to scale |
red | red part |
green | green part |
blue | blue part |
scale | maximal coefficient |
Definition at line 187 of file reader_ppm.c.
References SCIP_Real, and SCIPfloor().
Referenced by printRow().
|
static |
print row in PPM format to file stream
scip | SCIP data structure |
file | output file (or NULL for standard output) |
readerdata | information for reader |
vars | array of constraint variables |
vals | array of constraint values |
nvars | number of constraint variables |
ntotalvars | number of variables |
maxcoef | maximal coefficient |
Definition at line 249 of file reader_ppm.c.
References appendLine(), calcColorValue(), clearLine(), endLine(), PPM_MAX_LINELEN, REALABS, SCIPsnprintf(), and SCIPvarGetProbindex().
Referenced by printLinearCons().
|
static |
prints given linear constraint information in PPM format to file stream
scip | SCIP data structure |
file | output file (or NULL for standard output) |
readerdata | information for reader |
vars | array of variables |
vals | array of coefficients values (or NULL if all coefficient values are 1) |
nvars | number of variables |
ncompletevars | number of variables in whole problem |
transformed | transformed constraint? |
maxcoef | maximal coefficient |
printbool | print row or calculate maximum coefficient |
Definition at line 354 of file reader_ppm.c.
References getActiveVariables(), printRow(), REALABS, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, and SCIPfreeBufferArray.
Referenced by SCIPwritePpm().
|
static |
copy method for reader plugins (called when SCIP copies plugins)
Definition at line 433 of file reader_ppm.c.
References READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludeReaderPpm(), and SCIPreaderGetName().
|
static |
destructor of reader to free user data (called when SCIP is exiting)
Definition at line 447 of file reader_ppm.c.
References READER_NAME, SCIP_OKAY, SCIPfreeBlockMemory, SCIPreaderGetData(), and SCIPreaderGetName().
|
static |
problem writing method of reader
Definition at line 462 of file reader_ppm.c.
References READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPreaderGetData(), SCIPreaderGetName(), and SCIPwritePpm().