Scippy

SCIP

Solving Constraint Integer Programs

reader_pbm.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file reader_pbm.c
17  * @ingroup DEFPLUGINS_READER
18  * @brief file writer for portable bitmap file format (PBM), open with common graphic viewer programs (e.g. xview)
19  * @author Alexandra Kraft
20  *
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #include "blockmemshell/memory.h"
26 #include "scip/cons_knapsack.h"
27 #include "scip/cons_linear.h"
28 #include "scip/cons_logicor.h"
29 #include "scip/cons_setppc.h"
30 #include "scip/cons_varbound.h"
31 #include "scip/pub_cons.h"
32 #include "scip/pub_message.h"
33 #include "scip/pub_reader.h"
34 #include "scip/pub_var.h"
35 #include "scip/reader_pbm.h"
36 #include "scip/scip_cons.h"
37 #include "scip/scip_mem.h"
38 #include "scip/scip_message.h"
39 #include "scip/scip_param.h"
40 #include "scip/scip_reader.h"
41 #include "scip/scip_var.h"
42 #include <string.h>
43 
44 #define READER_NAME "pbmreader"
45 #define READER_DESC "file writer for portable bitmap file format (PBM), open with common graphic viewer programs (e.g. xview)"
46 #define READER_EXTENSION "pbm"
47 
48 /*
49  * Data structures
50  */
51 #define PBM_MAX_LINELEN 71 /**< the maximum length of any line is 70 + '\\0' = 71*/
52 #define DEFAULT_PBM_BINARY TRUE /**< binary is the default format for PBM */
53 #define DEFAULT_PBM_MAXROWS 1000 /**< allowed maximum of pixel-rows int the picture */
54 #define DEFAULT_PBM_MAXCOLS 1000 /**< allowed maximum of pixel-columns in the picture */
55 
56 /** LP reading data */
57 struct SCIP_ReaderData
58 {
59  SCIP_Bool binary; /**< binary is the default format for PBM */
60  int maxrows; /**< allowed maximum of pixel-rows int the picture */
61  int maxcols; /**< allowed maximum of pixel-columns in the picture */
62 };
63 
64 /*
65  * Local methods (for writing)
66  */
67 
68 /** transforms given variables, scalars, and constant to the corresponding active variables, scalars, and constant */
69 static
71  SCIP* scip, /**< SCIP data structure */
72  SCIP_VAR** vars, /**< vars array to get active variables for */
73  SCIP_Real* scalars, /**< scalars a_1, ..., a_n in sum a_1*x_1 + ... + a_n*x_n + c */
74  int* nvars, /**< pointer to number of variables and values in vars and vals array */
75  SCIP_Real* constant, /**< pointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c */
76  SCIP_Bool transformed /**< transformed constraint? */
77  )
78 {
79  int requiredsize;
80  int v;
81 
82  assert(scip != NULL);
83  assert(vars != NULL);
84  assert(scalars != NULL);
85  assert(nvars != NULL);
86  assert(constant != NULL);
87 
88  if( transformed )
89  {
90  SCIP_CALL( SCIPgetProbvarLinearSum(scip, vars, scalars, nvars, *nvars, constant, &requiredsize, TRUE) );
91 
92  if( requiredsize > *nvars )
93  {
94  SCIP_CALL( SCIPreallocBufferArray(scip, &vars, requiredsize) );
95  SCIP_CALL( SCIPreallocBufferArray(scip, &scalars, requiredsize) );
96 
97  SCIP_CALL( SCIPgetProbvarLinearSum(scip, vars, scalars, nvars, requiredsize, constant, &requiredsize, TRUE) );
98  assert(requiredsize <= *nvars);
99  }
100  }
101  else
102  {
103  for( v = 0; v < *nvars; ++v )
104  {
105  SCIP_CALL( SCIPvarGetOrigvarSum(&vars[v], &scalars[v], constant) );
106  }
107  }
108 
109  return SCIP_OKAY;
110 }
111 
112 /** transforms given variables to the corresponding active variables */
113 static
115  SCIP* scip, /**< SCIP data structure */
116  SCIP_VAR** vars, /**< vars array to get active variables for */
117  int* nvars, /**< pointer to number of variables and values in vars and vals array */
118  SCIP_Bool transformed /**< transformed constraint? */
119  )
120 {
121  int requiredsize;
122  int v;
123 
124  assert(scip != NULL);
125  assert(vars != NULL);
126  assert(nvars != NULL);
127 
128  if( transformed )
129  {
130  SCIP_CALL( SCIPgetActiveVars(scip, vars, nvars, *nvars, &requiredsize) );
131 
132  if( requiredsize > *nvars )
133  {
134  SCIP_CALL( SCIPreallocBufferArray(scip, &vars, requiredsize) );
135 
136  SCIP_CALL( SCIPgetActiveVars(scip, vars, nvars, requiredsize, &requiredsize) );
137  assert(requiredsize <= *nvars);
138  }
139  }
140  else
141  {
142  SCIP_Real scalar;
143  SCIP_Real constant;
144  for( v = 0; v < *nvars; ++v )
145  {
146  scalar = 1.0;
147  constant = 0.0;
148  SCIP_CALL( SCIPvarGetOrigvarSum(&vars[v], &scalar, &constant) );
149  }
150  }
151 
152  return SCIP_OKAY;
153 }
154 
155 /** clears the given line buffer */
156 static
158  char* linebuffer, /**< line */
159  int* linecnt /**< number of characters in line */
160  )
161 {
162  assert(linebuffer != NULL);
163  assert(linecnt != NULL);
164 
165  (*linecnt) = 0;
166  linebuffer[0] = '\0';
167 }
168 
169 
170 /** appends a bit to buffer and prints it to the give file stream if we've gather a whole byte */
171 static
173  SCIP* scip, /**< SCIP data structure */
174  FILE* file, /**< output file (or NULL for standard output) */
175  unsigned char* bitcnt, /**< counts bits until whole byte is gathered */
176  unsigned char* bitbuffer /**< bit buffer */
177  )
178 {
179  assert(scip != NULL);
180 
181  if( *bitcnt == 0 )
182  return;
183 
184  assert(bitbuffer != NULL);
185  assert(*bitcnt > 0 && *bitcnt <= 8);
186 
187  (*bitbuffer) <<= (8 - *bitcnt); /*lint !e701 !e734*/
188 
189  fputc(*bitbuffer, file);
190 
191  *bitcnt = 0;
192  *bitbuffer = 0;
193 }
194 
195 
196 /** appends a bit to buffer and prints it to the given file stream if we've gathered a whole byte */
197 static
199  SCIP* scip, /**< SCIP data structure */
200  FILE* file, /**< output file (or NULL for standard output) */
201  unsigned char bit, /**< bit to append */
202  unsigned char* bitcnt, /**< counts bits until whole byte is gathered */
203  unsigned char* bitbuffer /**< bit buffer */
204  )
205 {
206  assert(scip != NULL);
207  assert(*bitcnt < 8);
208  assert(bitbuffer != NULL);
209 
210  (*bitbuffer) = ((*bitbuffer)<<1)|(bit&1); /*lint !e734*/
211  *bitcnt += 1;
212 
213  if( *bitcnt == 8 )
214  flushBits(scip, file, bitcnt, bitbuffer);
215 }
216 
217 /** calculates the size of the quadratic matrix, which will correspond to one pixel in the picture */
218 static
220  SCIP_READERDATA* readerdata, /**< information for reader */
221  int nvars, /**< number of variables */
222  int nconss /**< number of constraints */
223  )
224 {
225  int sizev;
226  int sizeh;
227  int res;
228 
229  assert(readerdata->maxrows != 0 && readerdata->maxcols != 0);
230 
231  if( readerdata->maxrows > nconss )
232  readerdata->maxrows = nconss;
233 
234  if( readerdata->maxcols > nvars )
235  readerdata->maxcols = nvars;
236 
237  sizev = (nconss + readerdata->maxrows - 1) / readerdata->maxrows;
238  sizeh = (nvars + readerdata->maxcols - 1) / readerdata->maxcols;
239 
240  /* both defined with -1 */
241  if( readerdata->maxrows == -1 && readerdata->maxcols == -1 )
242  res = 1;
243 
244  /* only width is defined */
245  else if( readerdata->maxrows == -1 && readerdata->maxcols > 0 )
246  res = sizeh;
247 
248  /* only height is defined */
249  else if( readerdata->maxrows > 0 && readerdata->maxcols == -1 )
250  res = sizev;
251 
252  /* both are defined, use smaller scaling factor */
253  else if( sizev > sizeh )
254  res = sizev;
255  else
256  res = sizeh;
257 
258  readerdata->maxrows = (nconss + res - 1) / res;
259  readerdata->maxcols = (nvars + res - 1) / res;
260 
261  return res;
262 }
263 
264 
265 /** print row in PBM format to file stream */
266 static
267 void printRow(
268  SCIP* scip, /**< SCIP data structure */
269  SCIP_READERDATA* readerdata, /**< information for reader */
270  SCIP_VAR** vars, /**< array of constraint variables */
271  int conscnt, /**< current constraint */
272  int nvars, /**< number of constraint variables */
273  int submatrixsize, /**< size of the submatrices */
274  int* scaledimage /**< array of ints that count variables in every submatrix */
275  )
276 {
277  int v;
278  int i;
279  const int y = conscnt / submatrixsize;
280  int x;
281 
282  assert(scip != NULL);
283  assert(nvars > 0);
284  assert(readerdata != NULL);
285 
286  for( i = 0; i < nvars; ++i )
287  {
288  assert(vars != NULL); /* for lint */
289 
290  v = SCIPvarGetProbindex(vars[i]);
291  if( v != -1 )
292  {
293  x = v / submatrixsize;
294  ++(scaledimage[y * readerdata->maxcols + x]);
295  }
296  }
297 
298  return;
299 }
300 
301 /** prints given linear constraint information in PBM format to file stream */
302 static
304  SCIP* scip, /**< SCIP data structure */
305  SCIP_READERDATA* readerdata, /**< information for reader */
306  SCIP_VAR** vars, /**< array of variables */
307  SCIP_Real* vals, /**< array of coefficients values (or NULL if all coefficient values are 1) */
308  int nvars, /**< current constraint */
309  int conscnt, /**< counts variables in the constraint */
310  SCIP_Bool transformed, /**< transformed constraint? */
311  int submatrixsize, /**< size of the submatrices */
312  int* scaledimage /**< array of ints that count variables in every submatrix */
313  )
314 {
315  SCIP_VAR** activevars;
316  SCIP_Real* activevals;
317  SCIP_Real activeconstant = 0.0;
318  int nactivevars;
319  int v;
320 
321  assert(scip != NULL);
322  assert(vars != NULL);
323  assert(nvars > 0);
324  assert(conscnt >= 0);
325  assert(readerdata != NULL);
326 
327  /* duplicate variable and value array */
328  nactivevars = nvars;
329  SCIP_CALL( SCIPduplicateBufferArray(scip, &activevars, vars, nactivevars ) );
330  if( vals != NULL )
331  {
332  SCIP_CALL( SCIPduplicateBufferArray(scip, &activevals, vals, nactivevars ) );
333  }
334  else
335  {
336  SCIP_CALL( SCIPallocBufferArray(scip, &activevals, nactivevars) );
337 
338  for( v = 0; v < nactivevars; ++v )
339  activevals[v] = 1.0;
340  }
341 
342  /* retransform given variables to active variables */
343  SCIP_CALL( getActiveVariables(scip, activevars, activevals, &nactivevars, &activeconstant, transformed) );
344 
345  /* print constraint */
346  printRow(scip, readerdata, activevars, conscnt, nactivevars, submatrixsize, scaledimage);
347 
348  /* free buffer arrays */
349  SCIPfreeBufferArray(scip, &activevars);
350  SCIPfreeBufferArray(scip, &activevals);
351 
352  return SCIP_OKAY;
353 }
354 
355 /* draws the scaled image */
356 static
358  SCIP* scip, /**< SCIP data structure */
359  FILE* file, /**< output file, or NULL if standard output should be used */
360  SCIP_READERDATA* readerdata, /**< information for reader */
361  int* scaledimage /**< array of ints that count variables in every submatrix */
362  )
363 {
364  int y;
365  int x;
366  unsigned char bitcnt = 0;
367  unsigned char bitbuffer = '\0';
368 
369  assert(scip != NULL);
370  assert(readerdata != NULL);
371 
372  for( y = 0; y < readerdata->maxrows; y++ )
373  {
374  for( x = 0; x < readerdata->maxcols; x++ )
375  {
376  unsigned char v = 0;
377  if( scaledimage[y*readerdata->maxcols+x] >= 1 )
378  {
379  v = 1;
380  }
381  appendBit(scip, file, v, &bitcnt, &bitbuffer);
382  }
383  flushBits(scip, file, &bitcnt, &bitbuffer);
384  }
385 }
386 
387 
388 /*
389  * Callback methods of reader
390  */
391 
392 /** copy method for reader plugins (called when SCIP copies plugins) */
393 static
394 SCIP_DECL_READERCOPY(readerCopyPbm)
395 { /*lint --e{715}*/
396  assert(scip != NULL);
397  assert(reader != NULL);
398  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
399 
400  /* call inclusion method of reader */
402 
403  return SCIP_OKAY;
404 }
405 
406 /** destructor of reader to free user data (called when SCIP is exiting) */
407 static
408 SCIP_DECL_READERFREE(readerFreePbm)
409 {
410  SCIP_READERDATA* readerdata;
411 
412  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
413 
414  readerdata = SCIPreaderGetData(reader);
415  assert(readerdata != NULL);
416 
417  SCIPfreeBlockMemory(scip, &readerdata);
418 
419  return SCIP_OKAY;
420 }
421 
422 /** problem reading method of reader */
423 #define readerReadPbm NULL
424 
425 /** problem writing method of reader */
426 static
427 SCIP_DECL_READERWRITE(readerWritePbm)
428 { /*lint --e{715}*/
429  SCIP_READERDATA* readerdata;
430 
431  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
432 
433  readerdata = SCIPreaderGetData(reader);
434  assert(readerdata != NULL);
435 
436  SCIP_CALL( SCIPwritePbm(scip, file, name, readerdata, transformed, nvars, conss, nconss, result) );
437 
438  return SCIP_OKAY;
439 }
440 
441 /*
442  * reader specific interface methods
443  */
444 
445 /** includes the pbm file reader in SCIP */
447  SCIP* scip /**< SCIP data structure */
448  )
449 {
450  SCIP_READERDATA* readerdata;
451 
452  /* create pbm reader data */
453  SCIP_CALL( SCIPallocBlockMemory(scip, &readerdata) );
454 
455  /* include pbm reader */
457  readerCopyPbm, readerFreePbm, readerReadPbm, readerWritePbm, readerdata) );
458 
459  /* add pbm reader parameters */
461  "reading/pbmreader/binary", "should the output format be binary(P4) (otherwise plain(P1) format)",
462  &readerdata->binary, FALSE, DEFAULT_PBM_BINARY, NULL, NULL) );
464  "reading/pbmreader/maxrows", "maximum number of rows in the scaled picture (-1 for no limit)",
465  &readerdata->maxrows, FALSE, DEFAULT_PBM_MAXROWS, -1, INT_MAX, NULL, NULL) );
467  "reading/pbmreader/maxcols", "maximum number of columns in the scaled picture (-1 for no limit)",
468  &readerdata->maxcols, FALSE, DEFAULT_PBM_MAXCOLS, -1, INT_MAX, NULL, NULL) );
469 
470  return SCIP_OKAY;
471 }
472 
473 /* writes picture of matrix structure to file */
475  SCIP* scip, /**< SCIP data structure */
476  FILE* file, /**< output file, or NULL if standard output should be used */
477  const char* name, /**< problem name */
478  SCIP_READERDATA* readerdata, /**< information for reader */
479  SCIP_Bool transformed, /**< TRUE iff problem is the transformed problem */
480  int nvars, /**< number of active variables in the problem */
481  SCIP_CONS** conss, /**< array with constraints of the problem */
482  int nconss, /**< number of constraints in the problem */
483  SCIP_RESULT* result /**< pointer to store the result of the file writing call */
484  )
485 {
486  SCIP_CONSHDLR* conshdlr;
487  SCIP_CONS* cons;
488  SCIP_VAR** consvars;
489  SCIP_Real* consvals;
490  SCIP_READERDATA readerdata_copy;
491  char linebuffer[PBM_MAX_LINELEN];
492  const char* conshdlrname;
493  int* scaledimage;
494  int submatrixsize;
495  int nconsvars;
496  int linecnt;
497  int c;
498  int v;
499 
500  assert(scip != NULL);
501  assert(readerdata != NULL);
502  assert(conss != NULL);
503 
504  readerdata_copy = *readerdata;
505  submatrixsize = getSubmatrixSize(&readerdata_copy, nvars, nconss);
506  readerdata = &readerdata_copy;
507 
508  SCIP_CALL( SCIPallocBufferArray(scip, &scaledimage, readerdata_copy.maxrows * readerdata_copy.maxcols) );
509  assert(scaledimage != NULL);
510  BMSclearMemoryArray(scaledimage, readerdata->maxrows * readerdata->maxcols);
511 
512  /* print statistics as comment to file */
513  if( readerdata->binary )
514  SCIPinfoMessage(scip, file, "P4\n");
515  else
516  SCIPinfoMessage(scip, file, "P1\n");
517 
518  SCIPinfoMessage(scip, file, "# %s\n", name);
519  SCIPinfoMessage(scip, file, "%d %d\n", readerdata->maxcols, readerdata->maxrows);
520 
521  clearLine(linebuffer, &linecnt);
522 
523  for( c = 0; c < nconss; ++c )
524  {
525  cons = conss[c];
526  assert(cons != NULL);
527 
528  /* in case the transformed is written only constraint are posted which are enabled in the current node */
529  assert(!transformed || SCIPconsIsEnabled(cons));
530 
531  conshdlr = SCIPconsGetHdlr(cons);
532  assert(conshdlr != NULL);
533 
534  conshdlrname = SCIPconshdlrGetName(conshdlr);
535  assert(transformed == SCIPconsIsTransformed(cons));
536 
537  if( strcmp(conshdlrname, "linear") == 0 )
538  {
539  consvars = SCIPgetVarsLinear(scip, cons);
540  nconsvars = SCIPgetNVarsLinear(scip, cons);
541  assert(consvars != NULL || nconsvars == 0);
542 
543  if( nconsvars > 0 )
544  {
545  SCIP_CALL( printLinearCons(scip, readerdata, consvars, SCIPgetValsLinear(scip, cons),
546  nconsvars, c, transformed, submatrixsize, scaledimage) );
547  }
548  }
549  else if( strcmp(conshdlrname, "setppc") == 0 )
550  {
551  consvars = SCIPgetVarsSetppc(scip, cons);
552  nconsvars = SCIPgetNVarsSetppc(scip, cons);
553  assert(consvars != NULL || nconsvars == 0);
554 
555  if( nconsvars > 0 )
556  {
557  SCIP_CALL( printLinearCons(scip, readerdata, consvars, NULL,
558  nconsvars, c, transformed, submatrixsize, scaledimage) );
559  }
560  }
561  else if( strcmp(conshdlrname, "logicor") == 0 )
562  {
563  consvars = SCIPgetVarsLogicor(scip, cons);
564  nconsvars = SCIPgetNVarsLogicor(scip, cons);
565  assert(consvars != NULL || nconsvars == 0);
566 
567  if( nconsvars > 0 )
568  {
569  SCIP_CALL( printLinearCons(scip, readerdata, consvars, NULL,
570  nconsvars, c, transformed, submatrixsize, scaledimage) );
571  }
572  }
573  else if( strcmp(conshdlrname, "knapsack") == 0 )
574  {
575  SCIP_Longint* weights;
576 
577  consvars = SCIPgetVarsKnapsack(scip, cons);
578  nconsvars = SCIPgetNVarsKnapsack(scip, cons);
579  assert(consvars != NULL || nconsvars == 0);
580 
581  /* copy Longint array to SCIP_Real array */
582  weights = SCIPgetWeightsKnapsack(scip, cons);
583  SCIP_CALL( SCIPallocBufferArray(scip, &consvals, nconsvars) );
584  for( v = 0; v < nconsvars; ++v )
585  consvals[v] = weights[v];
586 
587  if( nconsvars > 0 )
588  {
589  SCIP_CALL( printLinearCons(scip, readerdata, consvars, consvals, nconsvars, c, transformed,
590  submatrixsize, scaledimage) );
591  }
592 
593  SCIPfreeBufferArray(scip, &consvals);
594  }
595  else if( strcmp(conshdlrname, "varbound") == 0 )
596  {
597  SCIP_CALL( SCIPallocBufferArray(scip, &consvars, 2) );
598  SCIP_CALL( SCIPallocBufferArray(scip, &consvals, 2) );
599 
600  consvars[0] = SCIPgetVarVarbound(scip, cons);
601  consvars[1] = SCIPgetVbdvarVarbound(scip, cons);
602 
603  consvals[0] = 1.0;
604  consvals[1] = SCIPgetVbdcoefVarbound(scip, cons);
605 
606  SCIP_CALL( printLinearCons(scip, readerdata, consvars, consvals, 2, c, transformed,
607  submatrixsize, scaledimage) );
608 
609  SCIPfreeBufferArray(scip, &consvars);
610  SCIPfreeBufferArray(scip, &consvals);
611  }
612  else
613  {
614  SCIP_Bool success;
615 
616  consvars = NULL;
617  SCIP_CALL( SCIPgetConsNVars(scip, cons, &nconsvars, &success) );
618 
619  if( success )
620  {
621  SCIP_CALL( SCIPallocBufferArray(scip, &consvars, nconsvars) );
622 
623  SCIP_CALL( SCIPgetConsVars(scip, cons, consvars, nconsvars, &success) );
624  }
625 
626  if( success )
627  {
628  /* retransform given variables to active variables */
629  SCIP_CALL( getActiveVariables2(scip, consvars, &nconsvars, transformed) );
630 
631  printRow(scip, readerdata, consvars, c, nconsvars, submatrixsize, scaledimage);
632  }
633  else
634  {
635  SCIPwarningMessage(scip, "constraint handler <%s> cannot print requested format\n", conshdlrname );
636  SCIPinfoMessage(scip, file, "\\ ");
637  SCIP_CALL( SCIPprintCons(scip, cons, file) );
638  }
639 
640  SCIPfreeBufferArrayNull(scip, &consvars);
641  }
642  }
643 
644  drawScaledImage(scip, file, readerdata, scaledimage);
645 
646  SCIPfreeBufferArray(scip, &scaledimage);
647 
648  *result = SCIP_SUCCESS;
649 
650  return SCIP_OKAY; /*lint !e438*/
651 }
static SCIP_RETCODE getActiveVariables2(SCIP *scip, SCIP_VAR **vars, int *nvars, SCIP_Bool transformed)
Definition: reader_pbm.c:114
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_EXPORT const char * SCIPreaderGetName(SCIP_READER *reader)
Definition: reader.c:548
SCIP_Bool SCIPconsIsEnabled(SCIP_CONS *cons)
Definition: cons.c:8174
static SCIP_DECL_READERFREE(readerFreePbm)
Definition: reader_pbm.c:408
public methods for SCIP parameter handling
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)
Definition: reader_pbm.c:474
Constraint handler for variable bound constraints .
public methods for memory management
static void clearLine(char *linebuffer, int *linecnt)
Definition: reader_pbm.c:157
SCIP_EXPORT SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
Definition: reader.c:483
#define DEFAULT_PBM_BINARY
Definition: reader_pbm.c:52
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:123
static SCIP_DECL_READERWRITE(readerWritePbm)
Definition: reader_pbm.c:427
int SCIPgetNVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
#define FALSE
Definition: def.h:73
static SCIP_RETCODE getActiveVariables(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
Definition: reader_pbm.c:70
#define TRUE
Definition: def.h:72
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
static int getSubmatrixSize(SCIP_READERDATA *readerdata, int nvars, int nconss)
Definition: reader_pbm.c:219
#define READER_NAME
Definition: reader_pbm.c:44
SCIP_VAR ** SCIPgetVarsSetppc(SCIP *scip, SCIP_CONS *cons)
Definition: cons_setppc.c:9273
public methods for problem variables
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)
Definition: scip_param.c:48
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:95
#define SCIPduplicateBufferArray(scip, ptr, source, num)
Definition: scip_mem.h:119
SCIP_Longint * SCIPgetWeightsKnapsack(SCIP *scip, SCIP_CONS *cons)
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:123
Constraint handler for the set partitioning / packing / covering constraints .
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip_mem.h:78
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
public methods for SCIP variables
#define readerReadPbm
Definition: reader_pbm.c:423
SCIP_RETCODE SCIPgetConsNVars(SCIP *scip, SCIP_CONS *cons, int *nvars, SCIP_Bool *success)
Definition: scip_cons.c:2558
SCIP_VAR ** x
Definition: circlepacking.c:54
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)
Definition: reader_pbm.c:303
static void appendBit(SCIP *scip, FILE *file, unsigned char bit, unsigned char *bitcnt, unsigned char *bitbuffer)
Definition: reader_pbm.c:198
public methods for managing constraints
Constraint handler for knapsack constraints of the form , x binary and .
SCIP_RETCODE SCIPgetProbvarLinearSum(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, int varssize, SCIP_Real *constant, int *requiredsize, SCIP_Bool mergemultiples)
Definition: scip_var.c:1742
SCIP_VAR * SCIPgetVarVarbound(SCIP *scip, SCIP_CONS *cons)
#define DEFAULT_PBM_MAXCOLS
Definition: reader_pbm.c:54
static void flushBits(SCIP *scip, FILE *file, unsigned char *bitcnt, unsigned char *bitbuffer)
Definition: reader_pbm.c:172
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)
Definition: scip_mem.h:124
#define READER_EXTENSION
Definition: reader_pbm.c:46
#define NULL
Definition: lpi_spx1.cpp:155
SCIP_VAR * SCIPgetVbdvarVarbound(SCIP *scip, SCIP_CONS *cons)
#define SCIP_CALL(x)
Definition: def.h:364
file writer for portable bitmap file format (PBM), open with common graphic viewer programs (e...
public methods for constraint handler plugins and constraints
SCIP_VAR ** SCIPgetVarsLogicor(SCIP *scip, SCIP_CONS *cons)
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:111
struct SCIP_ReaderData SCIP_READERDATA
Definition: type_reader.h:44
#define SCIP_Bool
Definition: def.h:70
static void printRow(SCIP *scip, SCIP_READERDATA *readerdata, SCIP_VAR **vars, int conscnt, int nvars, int submatrixsize, int *scaledimage)
Definition: reader_pbm.c:267
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
Definition: scip_cons.c:2473
static SCIP_DECL_READERCOPY(readerCopyPbm)
Definition: reader_pbm.c:394
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPgetActiveVars(SCIP *scip, SCIP_VAR **vars, int *nvars, int varssize, int *requiredsize)
Definition: scip_var.c:1834
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
Definition: cons.c:8386
SCIP_VAR ** SCIPgetVarsKnapsack(SCIP *scip, 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)
Definition: scip_reader.c:57
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPincludeReaderPbm(SCIP *scip)
Definition: reader_pbm.c:446
static const SCIP_Real scalars[]
Definition: lp.c:5731
int SCIPgetNVarsLogicor(SCIP *scip, SCIP_CONS *cons)
public methods for message output
int SCIPgetNVarsSetppc(SCIP *scip, SCIP_CONS *cons)
Definition: cons_setppc.c:9250
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)
Definition: scip_param.c:74
#define SCIP_Real
Definition: def.h:163
public methods for input file readers
SCIP_VAR ** y
Definition: circlepacking.c:55
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8097
public methods for message handling
SCIP_EXPORT SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12545
#define SCIP_Longint
Definition: def.h:148
#define DEFAULT_PBM_MAXROWS
Definition: reader_pbm.c:53
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4167
SCIP_EXPORT int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:17360
#define PBM_MAX_LINELEN
Definition: reader_pbm.c:51
#define BMSclearMemoryArray(ptr, num)
Definition: memory.h:122
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:199
public methods for reader plugins
SCIP_RETCODE SCIPgetConsVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int varssize, SCIP_Bool *success)
Definition: scip_cons.c:2514
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
static void drawScaledImage(SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, int *scaledimage)
Definition: reader_pbm.c:357
#define READER_DESC
Definition: reader_pbm.c:45
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:115
memory allocation routines