36 #define READER_NAME "ppmreader" 37 #define READER_DESC "file writer for portable pixmap file format (PPM), open with common graphic viewer programs (e.g. xview)" 38 #define READER_EXTENSION "ppm" 43 #define PPM_MAX_LINELEN 71 44 #define DEFAULT_PPM_RGB_LIMIT 160 45 #define DEFAULT_PPM_COEF_LIMIT 3 46 #define DEFAULT_PPM_RGB_RELATIVE TRUE 47 #define DEFAULT_PPM_RGB_ASCII TRUE 50 struct SCIP_ReaderData
68 assert(readerdata !=
NULL);
91 assert( scip !=
NULL );
92 assert( vars !=
NULL );
93 assert( scalars !=
NULL );
94 assert( nvars !=
NULL );
95 assert( constant !=
NULL );
101 if( requiredsize > *nvars )
107 assert( requiredsize <= *nvars );
112 for( v = 0; v < *nvars; ++v )
127 assert( linebuffer !=
NULL );
128 assert( linecnt !=
NULL );
131 linebuffer[0] =
'\0';
144 assert( scip !=
NULL );
145 assert( linebuffer !=
NULL );
146 assert( linecnt !=
NULL );
150 linebuffer[(*linecnt)] =
'\0';
152 if(readerdata->rgb_ascii)
168 const char* extension
171 assert( scip !=
NULL );
172 assert( linebuffer !=
NULL );
173 assert( linecnt !=
NULL );
174 assert( extension !=
NULL );
177 endLine(scip, file, readerdata, linebuffer, linecnt);
180 strncat(linebuffer, extension,
PPM_MAX_LINELEN - (
unsigned int)(*linecnt) - 1);
181 (*linecnt) += (int) strlen(extension);
199 assert(scip !=
NULL);
200 assert(readerdata !=
NULL);
201 assert(readerdata->rgb_limit >= 0);
206 if( !(readerdata->rgb_relative) )
209 (*blue) = readerdata->rgb_limit - (int) (
unsigned short) (coef/scale * readerdata->rgb_limit);
217 if( coeflog >= readerdata->coef_limit )
224 (*blue) = readerdata->rgb_limit - (int) (
unsigned short) (readerdata->rgb_limit * coeflog/readerdata->coef_limit);
231 coeflog = -1.0*coeflog;
232 if( coeflog >= readerdata->coef_limit )
239 (*red) = (readerdata->rgb_limit) - (
int) (
unsigned short) ((readerdata->rgb_limit)*coeflog/(readerdata->coef_limit));
276 const unsigned char max = (
unsigned char)255;
279 assert( scip !=
NULL );
281 assert (readerdata !=
NULL);
291 for( v = 0; v < nvars; ++v )
296 assert(maxvarindex < ntotalvars);
299 for(v = 0; v < nvars; ++v)
301 actvarindex = maxvarindex;
302 for(j = 0; j < nvars; ++j)
310 varindex = actvarindex;
313 for( ; i < varindex; ++i )
315 if(readerdata->rgb_ascii)
316 appendLine(scip, file, readerdata, linebuffer, &linecnt, white);
318 appendLine(scip, file, readerdata, linebuffer, &linecnt,
" 255 255 255 ");
322 if( readerdata->rgb_ascii )
324 if( red == 35 || red == 0 )
326 if( green==35 || green == 0 )
328 if( blue==35 || blue == 0 )
335 appendLine(scip, file, readerdata, linebuffer, &linecnt, buffer);
340 for( ; i < ntotalvars; ++i )
342 if(readerdata->rgb_ascii)
343 appendLine(scip, file, readerdata, linebuffer, &linecnt, white);
345 appendLine(scip, file, readerdata, linebuffer, &linecnt,
" 255 255 255 ");
348 endLine(scip, file, readerdata, linebuffer, &linecnt);
373 assert( scip !=
NULL );
374 assert( vars !=
NULL );
376 assert( readerdata !=
NULL );
389 for( v = 0; v < nactivevars; ++v )
396 if( ! readerdata->rgb_relative )
400 for(v = 0; v < nactivevars; ++v)
402 if(
REALABS(activevals[v]) > *maxcoef)
403 *maxcoef =
REALABS(activevals[v]);
408 assert (*maxcoef > 0);
410 printRow(scip, file, readerdata, activevars, activevals, nactivevars, ncompletevars, *maxcoef);
416 printRow(scip, file, readerdata, activevars, activevals, nactivevars, ncompletevars, *maxcoef);
436 assert(reader !=
NULL);
453 assert(readerdata !=
NULL);
469 assert(readerdata !=
NULL);
495 assert(reader !=
NULL);
504 "reading/ppmreader/rgbrelativ",
"should the coloring values be relativ or absolute",
507 "reading/ppmreader/rgbascii",
"should the output format be binary(P6) (otherwise plain(P3) format)",
510 "reading/ppmreader/coefficientlimit",
511 "splitting coefficients in this number of intervals",
514 "reading/ppmreader/rgblimit",
515 "maximal color value",
544 const char* conshdlrname;
554 assert( scip !=
NULL );
555 assert(readerdata !=
NULL);
558 if(readerdata->rgb_ascii)
568 if( ! readerdata->rgb_relative )
571 for(i = 0; i < i_max; ++i)
579 for(c = 0; c < nconss; ++c)
582 assert( cons !=
NULL);
588 assert( conshdlr !=
NULL );
593 if( strcmp(conshdlrname,
"linear") == 0 )
597 assert( consvars !=
NULL || nconsvars == 0 );
602 nconsvars, nvars, transformed, &maxcoef, printbool) );
605 else if( strcmp(conshdlrname,
"setppc") == 0 )
609 assert( consvars !=
NULL || nconsvars == 0 );
614 nconsvars, nvars, transformed, &maxcoef, printbool) );
617 else if( strcmp(conshdlrname,
"logicor") == 0 )
621 assert( consvars !=
NULL || nconsvars == 0 );
626 nconsvars, nvars, transformed, &maxcoef, printbool) );
629 else if( strcmp(conshdlrname,
"knapsack") == 0 )
635 assert( consvars !=
NULL || nconsvars == 0 );
640 for( v = 0; v < nconsvars; ++v )
645 SCIP_CALL(
printLinearCons(scip, file, readerdata, consvars, consvals, nconsvars, nvars, transformed, &maxcoef, printbool) );
650 else if( strcmp(conshdlrname,
"varbound") == 0 )
661 SCIP_CALL(
printLinearCons(scip, file, readerdata, consvars, consvals, 2, nvars, transformed, &maxcoef, printbool) );
668 SCIPwarningMessage(scip,
"constraint handler <%s> cannot print requested format\n", conshdlrname );
enum SCIP_Result SCIP_RESULT
SCIP_Bool SCIPconsIsEnabled(SCIP_CONS *cons)
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 void calcColorValue(SCIP *scip, SCIP_READERDATA *readerdata, SCIP_Real coef, int *red, int *green, int *blue, SCIP_Real scale)
Constraint handler for variable bound constraints .
int SCIPgetNVarsSetppc(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsLogicor(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_READERCOPY(readerCopyPpm)
const char * SCIPreaderGetName(SCIP_READER *reader)
SCIP_RETCODE SCIPincludeReaderPpm(SCIP *scip)
#define DEFAULT_PPM_COEF_LIMIT
static void endLine(SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, char *linebuffer, int *linecnt)
int SCIPsnprintf(char *t, int len, const char *s,...)
enum SCIP_Retcode SCIP_RETCODE
int SCIPvarGetProbindex(SCIP_VAR *var)
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
file writer for portable pixmap file format (PPM), open with common graphic viewer programs (e...
#define SCIPfreeBufferArray(scip, ptr)
Constraint handler for the set partitioning / packing / covering constraints .
#define SCIPallocBlockMemory(scip, ptr)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
#define SCIPdebugMsgPrint
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
#define DEFAULT_PPM_RGB_RELATIVE
#define DEFAULT_PPM_RGB_ASCII
SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
Constraint handler for knapsack constraints of the form , x binary and .
SCIP_VAR * SCIPgetVarVarbound(SCIP *scip, SCIP_CONS *cons)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
SCIP_Real SCIPgetVbdcoefVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsLogicor(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE getActiveVariables(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
#define DEFAULT_PPM_RGB_LIMIT
SCIP_VAR * SCIPgetVbdvarVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPgetProbvarLinearSum(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, int varssize, SCIP_Real *constant, int *requiredsize, SCIP_Bool mergemultiples)
static SCIP_DECL_READERWRITE(readerWritePpm)
#define SCIPallocBufferArray(scip, ptr, num)
struct SCIP_ReaderData SCIP_READERDATA
public data structures and miscellaneous methods
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
static void clearLine(char *linebuffer, int *linecnt)
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
SCIP_VAR ** SCIPgetVarsSetppc(SCIP *scip, SCIP_CONS *cons)
static void initReaderdata(SCIP_READERDATA *readerdata)
static const SCIP_Real scalars[]
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
static void appendLine(SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, char *linebuffer, int *linecnt, const char *extension)
int SCIPgetNVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_READERFREE(readerFreePpm)
static void printRow(SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, SCIP_VAR **vars, SCIP_Real *vals, int nvars, int ntotalvars, SCIP_Real maxcoef)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Longint * SCIPgetWeightsKnapsack(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
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)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
#define SCIPreallocBufferArray(scip, ptr, num)