36 #define READER_NAME "pbmreader" 37 #define READER_DESC "file writer for portable bitmap file format (PBM), open with common graphic viewer programs (e.g. xview)" 38 #define READER_EXTENSION "pbm" 43 #define PBM_MAX_LINELEN 71 44 #define DEFAULT_PBM_BINARY TRUE 45 #define DEFAULT_PBM_MAXROWS 1000 46 #define DEFAULT_PBM_MAXCOLS 1000 49 struct SCIP_ReaderData
76 assert(scalars != NULL);
77 assert(nvars != NULL);
78 assert(constant != NULL);
84 if( requiredsize > *nvars )
90 assert(requiredsize <= *nvars);
95 for( v = 0; v < *nvars; ++v )
116 assert(scip != NULL);
117 assert(vars != NULL);
118 assert(nvars != NULL);
124 if( requiredsize > *nvars )
129 assert(requiredsize <= *nvars);
136 for( v = 0; v < *nvars; ++v )
154 assert(linebuffer != NULL);
155 assert(linecnt != NULL);
158 linebuffer[0] =
'\0';
167 unsigned char* bitcnt,
168 unsigned char* bitbuffer
171 assert(scip != NULL);
176 assert(bitbuffer != NULL);
177 assert(*bitcnt > 0 && *bitcnt <= 8);
179 (*bitbuffer) <<= (8 - *bitcnt);
181 fputc(*bitbuffer, file);
194 unsigned char* bitcnt,
195 unsigned char* bitbuffer
198 assert(scip != NULL);
200 assert(bitbuffer != NULL);
202 (*bitbuffer) = ((*bitbuffer)<<1)|(bit&1);
206 flushBits(scip, file, bitcnt, bitbuffer);
221 assert(readerdata->maxrows != 0 && readerdata->maxcols != 0);
223 if( readerdata->maxrows > nconss )
224 readerdata->maxrows = nconss;
226 if( readerdata->maxcols > nvars )
227 readerdata->maxcols = nvars;
229 sizev = (nconss + readerdata->maxrows - 1) / readerdata->maxrows;
230 sizeh = (nvars + readerdata->maxcols - 1) / readerdata->maxcols;
233 if( readerdata->maxrows == -1 && readerdata->maxcols == -1 )
237 else if( readerdata->maxrows == -1 && readerdata->maxcols > 0 )
241 else if( readerdata->maxrows > 0 && readerdata->maxcols == -1 )
245 else if( sizev > sizeh )
250 readerdata->maxrows = (nconss + res - 1) / res;
251 readerdata->maxcols = (nvars + res - 1) / res;
271 const int y = conscnt / submatrixsize;
274 assert(scip != NULL);
276 assert(readerdata != NULL);
278 for( i = 0; i < nvars; ++i )
283 x = v / submatrixsize;
284 ++(scaledimage[y * readerdata->maxcols + x]);
311 assert(scip != NULL);
312 assert(vars != NULL);
314 assert(conscnt >= 0);
315 assert(readerdata != NULL);
328 for( v = 0; v < nactivevars; ++v )
336 printRow(scip, readerdata, activevars, conscnt, nactivevars, submatrixsize, scaledimage);
356 unsigned char bitcnt = 0;
357 unsigned char bitbuffer =
'\0';
359 assert(scip != NULL);
360 assert(readerdata != NULL);
363 for( y = 0; y < readerdata->maxrows; y++ )
365 for( x = 0; x < readerdata->maxcols; x++ )
368 if( scaledimage[y*readerdata->maxcols+x] >= 1 )
372 appendBit(scip, file, v, &bitcnt, &bitbuffer);
374 flushBits(scip, file, &bitcnt, &bitbuffer);
387 assert(
scip != NULL);
388 assert(reader != NULL);
406 assert(readerdata != NULL);
414 #define readerReadPbm NULL 426 assert(readerdata != NULL);
449 readerCopyPbm, readerFreePbm,
readerReadPbm, readerWritePbm, readerdata) );
453 "reading/pbmreader/binary",
"should the output format be binary(P4) (otherwise plain(P1) format)",
456 "reading/pbmreader/maxrows",
"maximum number of rows in the scaled picture (-1 for no limit)",
459 "reading/pbmreader/maxcols",
"maximum number of columns in the scaled picture (-1 for no limit)",
484 const char* conshdlrname;
492 assert(scip != NULL);
493 assert(readerdata != NULL);
494 assert(conss != NULL);
496 readerdata_copy = *readerdata;
498 readerdata = &readerdata_copy;
501 assert(scaledimage != NULL);
505 if( readerdata->binary )
511 SCIPinfoMessage(scip, file,
"%d %d\n", readerdata->maxcols, readerdata->maxrows);
515 for( c = 0; c < nconss; ++c )
518 assert(cons != NULL);
524 assert(conshdlr != NULL);
529 if( strcmp(conshdlrname,
"linear") == 0 )
533 assert(consvars != NULL || nconsvars == 0);
538 nconsvars, c, transformed, submatrixsize, scaledimage) );
541 else if( strcmp(conshdlrname,
"setppc") == 0 )
545 assert(consvars != NULL || nconsvars == 0);
550 nconsvars, c, transformed, submatrixsize, scaledimage) );
553 else if( strcmp(conshdlrname,
"logicor") == 0 )
557 assert(consvars != NULL || nconsvars == 0);
562 nconsvars, c, transformed, submatrixsize, scaledimage) );
565 else if( strcmp(conshdlrname,
"knapsack") == 0 )
571 assert(consvars != NULL || nconsvars == 0);
576 for( v = 0; v < nconsvars; ++v )
577 consvals[v] = weights[v];
582 submatrixsize, scaledimage) );
587 else if( strcmp(conshdlrname,
"varbound") == 0 )
599 submatrixsize, scaledimage) );
623 printRow(scip, readerdata, consvars, c, nconsvars, submatrixsize, scaledimage);
627 SCIPwarningMessage(scip,
"constraint handler <%s> cannot print requested format\n", conshdlrname );
static SCIP_RETCODE getActiveVariables2(SCIP *scip, SCIP_VAR **vars, int *nvars, SCIP_Bool transformed)
enum SCIP_Result SCIP_RESULT
SCIP_Bool SCIPconsIsEnabled(SCIP_CONS *cons)
static SCIP_DECL_READERFREE(readerFreePbm)
Constraint handler for variable bound constraints .
static void clearLine(char *linebuffer, int *linecnt)
int SCIPgetNVarsSetppc(SCIP *scip, SCIP_CONS *cons)
#define DEFAULT_PBM_BINARY
int SCIPgetNVarsLogicor(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_READERWRITE(readerWritePbm)
const char * SCIPreaderGetName(SCIP_READER *reader)
static SCIP_RETCODE getActiveVariables(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
enum SCIP_Retcode SCIP_RETCODE
static int getSubmatrixSize(SCIP_READERDATA *readerdata, int nvars, int nconss)
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)
#define SCIPfreeBufferArray(scip, ptr)
Constraint handler for the set partitioning / packing / covering constraints .
#define SCIPallocBlockMemory(scip, ptr)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
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,...)
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)
SCIP_RETCODE SCIPincludeReaderPbm(SCIP *scip)
static void appendBit(SCIP *scip, FILE *file, unsigned char bit, unsigned char *bitcnt, unsigned char *bitbuffer)
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)
#define DEFAULT_PBM_MAXCOLS
static void flushBits(SCIP *scip, FILE *file, unsigned char *bitcnt, unsigned char *bitbuffer)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPgetConsNVars(SCIP *scip, SCIP_CONS *cons, int *nvars, SCIP_Bool *success)
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
SCIP_Real SCIPgetVbdcoefVarbound(SCIP *scip, SCIP_CONS *cons)
#define SCIPfreeBufferArrayNull(scip, ptr)
SCIP_VAR ** SCIPgetVarsLogicor(SCIP *scip, SCIP_CONS *cons)
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)
file writer for portable bitmap file format (PBM), open with common graphic viewer programs (e...
SCIP_RETCODE SCIPgetConsVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int varssize, SCIP_Bool *success)
#define SCIPallocBufferArray(scip, ptr, num)
struct SCIP_ReaderData SCIP_READERDATA
public data structures and miscellaneous methods
static void printRow(SCIP *scip, SCIP_READERDATA *readerdata, SCIP_VAR **vars, int conscnt, int nvars, int submatrixsize, int *scaledimage)
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
static SCIP_DECL_READERCOPY(readerCopyPbm)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_RETCODE SCIPincludeReader(SCIP *scip, const char *name, const char *desc, const char *extension, SCIP_DECL_READERCOPY((*readercopy)), SCIP_DECL_READERFREE((*readerfree)), SCIP_DECL_READERREAD((*readerread)), SCIP_DECL_READERWRITE((*readerwrite)), SCIP_READERDATA *readerdata)
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)
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
SCIP_VAR ** SCIPgetVarsSetppc(SCIP *scip, SCIP_CONS *cons)
static const SCIP_Real scalars[]
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
#define DEFAULT_PBM_MAXROWS
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
#define BMSclearMemoryArray(ptr, num)
SCIP_Longint * SCIPgetWeightsKnapsack(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPgetActiveVars(SCIP *scip, SCIP_VAR **vars, int *nvars, int varssize, int *requiredsize)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
static void drawScaledImage(SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, int *scaledimage)
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)