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