Scippy

SCIP

Solving Constraint Integer Programs

reader_ppm.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-2018 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 email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file reader_ppm.c
17  * @brief file writer for portable pixmap file format (PPM), open with common graphic viewer programs (e.g. xview)
18  * @author Michael Winkler
19  *
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include <stdlib.h>
25 #include <assert.h>
26 #include <string.h>
27 
28 #include "scip/reader_ppm.h"
29 #include "scip/cons_knapsack.h"
30 #include "scip/cons_linear.h"
31 #include "scip/cons_logicor.h"
32 #include "scip/cons_setppc.h"
33 #include "scip/cons_varbound.h"
34 #include "scip/pub_misc.h"
35 
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"
39 
40 /*
41  * Data structures
42  */
43 #define PPM_MAX_LINELEN 71 /**< the maximum length of any line is 70 + '\\0' = 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
48 
49 /** PPM reading data */
50 struct SCIP_ReaderData
51 {
52  SCIP_Bool rgb_relative;
53  SCIP_Bool rgb_ascii;
54  int rgb_limit;
55  int coef_limit;
56 };
57 
58 /*
59  * Local methods (for writing)
60  */
61 
62 /** initializes the reader data */
63 static
65  SCIP_READERDATA* readerdata /**< reader data */
66  )
67 {
68  assert(readerdata != NULL);
69 
70  readerdata->rgb_relative = DEFAULT_PPM_RGB_RELATIVE;
71  readerdata->rgb_ascii = DEFAULT_PPM_RGB_ASCII;
72  readerdata->rgb_limit = DEFAULT_PPM_RGB_LIMIT;
73  readerdata->coef_limit = DEFAULT_PPM_COEF_LIMIT;
74 }
75 
76 
77 /** transforms given variables, scalars, and constant to the corresponding active variables, scalars, and constant */
78 static
80  SCIP* scip, /**< SCIP data structure */
81  SCIP_VAR** vars, /**< vars array to get active variables for */
82  SCIP_Real* scalars, /**< scalars a_1, ..., a_n inrc/scip/reader_ppm.c linear sum a_1*x_1 + ... + a_n*x_n + c */
83  int* nvars, /**< pointer to number of variables and values in vars and vals array */
84  SCIP_Real* constant, /**< pointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c */
85  SCIP_Bool transformed /**< transformed constraint? */
86  )
87 {
88  int requiredsize;
89  int v;
90 
91  assert( scip != NULL );
92  assert( vars != NULL );
93  assert( scalars != NULL );
94  assert( nvars != NULL );
95  assert( constant != NULL );
96 
97  if( transformed )
98  {
99  SCIP_CALL( SCIPgetProbvarLinearSum(scip, vars, scalars, nvars, *nvars, constant, &requiredsize, TRUE) );
100 
101  if( requiredsize > *nvars )
102  {
103  SCIP_CALL( SCIPreallocBufferArray(scip, &vars, requiredsize) );
104  SCIP_CALL( SCIPreallocBufferArray(scip, &scalars, requiredsize) );
105 
106  SCIP_CALL( SCIPgetProbvarLinearSum(scip, vars, scalars, nvars, requiredsize, constant, &requiredsize, TRUE) );
107  assert( requiredsize <= *nvars );
108  }
109  }
110  else
111  {
112  for( v = 0; v < *nvars; ++v )
113  {
114  SCIP_CALL( SCIPvarGetOrigvarSum(&vars[v], &scalars[v], constant) );
115  }
116  }
117  return SCIP_OKAY;
118 }
119 
120 /** clears the given line buffer */
121 static
123  char* linebuffer, /**< line */
124  int* linecnt /**< number of characters in line */
125  )
126 {
127  assert( linebuffer != NULL );
128  assert( linecnt != NULL );
129 
130  (*linecnt) = 0;
131  linebuffer[0] = '\0';
132 }
133 
134 /** ends the given line with '\\0' and prints it to the given file stream */
135 static
136 void endLine(
137  SCIP* scip, /**< SCIP data structure */
138  FILE* file, /**< output file (or NULL for standard output) */
139  SCIP_READERDATA* readerdata, /**< information for reader */
140  char* linebuffer, /**< line */
141  int* linecnt /**< number of characters in line */
142  )
143 {
144  assert( scip != NULL );
145  assert( linebuffer != NULL );
146  assert( linecnt != NULL );
147 
148  if( (*linecnt) > 0 )
149  {
150  linebuffer[(*linecnt)] = '\0';
151 
152  if(readerdata->rgb_ascii)
153  SCIPinfoMessage(scip, file, "%s", linebuffer);
154  else
155  SCIPinfoMessage(scip, file, "%s\n", linebuffer);
156  clearLine(linebuffer, linecnt);
157  }
158 }
159 
160 /** appends extension to line and prints it to the give file stream if the line exceeded PPM_PRINTLEN */
161 static
163  SCIP* scip, /**< SCIP data structure */
164  FILE* file, /**< output file (or NULL for standard output) */
165  SCIP_READERDATA* readerdata, /**< information for reader */
166  char* linebuffer, /**< line */
167  int* linecnt, /**< number of characters in line */
168  const char* extension /**< string to extent the line */
169  )
170 {
171  assert( scip != NULL );
172  assert( linebuffer != NULL );
173  assert( linecnt != NULL );
174  assert( extension != NULL );
175 
176  if( *linecnt + strlen(extension) > PPM_MAX_LINELEN - 1 )
177  endLine(scip, file, readerdata, linebuffer, linecnt);
178 
179  /* append extension to linebuffer */
180  strncat(linebuffer, extension, PPM_MAX_LINELEN - (unsigned int)(*linecnt) - 1);
181  (*linecnt) += (int) strlen(extension);
182 }
183 
184 
185 /** calculates the color value for a given coefficient */
186 static
188  SCIP* scip, /**< SCIP data structure */
189  SCIP_READERDATA* readerdata, /**< information for reader */
190  SCIP_Real coef, /**< coefficient to scale */
191  int* red, /**< red part */
192  int* green, /**< green part */
193  int* blue, /**< blue part */
194  SCIP_Real scale /**< maximal coefficient */
195  )
196 {
197  SCIP_Real coeflog;
198 
199  assert(scip != NULL);
200  assert(readerdata != NULL);
201  assert(readerdata->rgb_limit >= 0);
202  assert(coef > 0);
203 
204  coeflog = SCIPfloor(scip, log10(coef));
205 
206  if( !(readerdata->rgb_relative) )
207  {
208  (*red) = 255;
209  (*blue) = readerdata->rgb_limit - (int) (unsigned short) (coef/scale * readerdata->rgb_limit);
210  (*green) = *blue;
211  }
212  else
213  {
214  if( coeflog >= 0 )
215  {
216  (*red) = 255;
217  if( coeflog >= readerdata->coef_limit )
218  {
219  (*blue) = 0;
220  (*green) = 0;
221  }
222  else
223  {
224  (*blue) = readerdata->rgb_limit - (int) (unsigned short) (readerdata->rgb_limit * coeflog/readerdata->coef_limit);
225  (*green) = *blue;
226  }
227  }
228  else
229  {
230  (*blue) = 255;
231  coeflog = -1.0*coeflog;
232  if( coeflog >= readerdata->coef_limit )
233  {
234  (*red) = 0;
235  (*green) = 0;
236  }
237  else
238  {
239  (*red) = (readerdata->rgb_limit) - (int) (unsigned short) ((readerdata->rgb_limit)*coeflog/(readerdata->coef_limit));
240  (*green) = *red;
241  }
242  }
243  }
244 }
245 
246 
247 /** print row in PPM format to file stream */
248 static
249 void printRow(
250  SCIP* scip, /**< SCIP data structure */
251  FILE* file, /**< output file (or NULL for standard output) */
252  SCIP_READERDATA* readerdata, /**< information for reader */
253  SCIP_VAR** vars, /**< array of constraint variables */
254  SCIP_Real* vals, /**< array of constraint values */
255  int nvars, /**< number of constraint variables */
256  int ntotalvars, /**< number of variables */
257  SCIP_Real maxcoef /**< maximal coefficient */
258  )
259 {
260  int v;
261  int i;
262  int j;
263 
264  int red;
265  int green;
266  int blue;
267 
268  char linebuffer[PPM_MAX_LINELEN];
269  int linecnt;
270  int varindex;
271  int actvarindex;
272  int maxvarindex;
273  int indexvar = 0;
274 
275  char buffer[PPM_MAX_LINELEN];
276  const unsigned char max = (unsigned char)255;
277  char white[4];
278 
279  assert( scip != NULL );
280  assert (nvars > 0);
281  assert (readerdata != NULL);
282 
283  i = 0;
284  varindex = -1;
285  maxvarindex = 0;
286 
287  (void) SCIPsnprintf(white, 4, "%c%c%c", max, max, max);
288  clearLine(linebuffer, &linecnt);
289 
290  /* calculate maximum index of the variables in this constraint */
291  for( v = 0; v < nvars; ++v )
292  {
293  if( maxvarindex < SCIPvarGetProbindex(vars[v]) )
294  maxvarindex = SCIPvarGetProbindex(vars[v]);
295  }
296  assert(maxvarindex < ntotalvars);
297 
298  /* print coefficients */
299  for(v = 0; v < nvars; ++v)
300  {
301  actvarindex = maxvarindex;
302  for(j = 0; j < nvars; ++j)
303  {
304  if( varindex < SCIPvarGetProbindex(vars[j]) && SCIPvarGetProbindex(vars[j]) <= actvarindex )
305  {
306  actvarindex = SCIPvarGetProbindex(vars[j]);
307  indexvar = j;
308  }
309  }
310  varindex = actvarindex;
311 
312  /* fill in white points since these variables indices do not exits in this constraint */
313  for( ; i < varindex; ++i )
314  {
315  if(readerdata->rgb_ascii)
316  appendLine(scip, file, readerdata, linebuffer, &linecnt, white);
317  else
318  appendLine(scip, file, readerdata, linebuffer, &linecnt, " 255 255 255 ");
319  }
320 
321  calcColorValue(scip, readerdata, REALABS(vals[indexvar]), &red, &green, &blue, maxcoef);
322  if( readerdata->rgb_ascii )
323  {
324  if( red == 35 || red == 0 )
325  red++;
326  if( green==35 || green == 0 )
327  green++;
328  if( blue==35 || blue == 0 )
329  blue++;
330  (void) SCIPsnprintf(buffer, PPM_MAX_LINELEN, "%c%c%c", (unsigned char)red, (unsigned char)green, (unsigned char)blue);
331  }
332  else
333  (void) SCIPsnprintf(buffer, PPM_MAX_LINELEN, " %d %d %d ", red, green, blue);
334 
335  appendLine(scip, file, readerdata, linebuffer, &linecnt, buffer);
336  i++;
337  }
338 
339  /* fill in white points since these variables indices do not exits in this constraint */
340  for( ; i < ntotalvars; ++i )
341  {
342  if(readerdata->rgb_ascii)
343  appendLine(scip, file, readerdata, linebuffer, &linecnt, white);
344  else
345  appendLine(scip, file, readerdata, linebuffer, &linecnt, " 255 255 255 ");
346  }
347 
348  endLine(scip, file, readerdata, linebuffer, &linecnt);
349 }
350 
351 
352 /** prints given linear constraint information in PPM format to file stream */
353 static
355  SCIP* scip, /**< SCIP data structure */
356  FILE* file, /**< output file (or NULL for standard output) */
357  SCIP_READERDATA* readerdata, /**< information for reader */
358  SCIP_VAR** vars, /**< array of variables */
359  SCIP_Real* vals, /**< array of coefficients values (or NULL if all coefficient values are 1) */
360  int nvars, /**< number of variables */
361  int ncompletevars, /**< number of variables in whole problem */
362  SCIP_Bool transformed, /**< transformed constraint? */
363  SCIP_Real* maxcoef, /**< maximal coefficient */
364  SCIP_Bool printbool /**< print row or calculate maximum coefficient */
365  )
366 {
367  int v;
368  SCIP_VAR** activevars;
369  SCIP_Real* activevals;
370  int nactivevars;
371  SCIP_Real activeconstant = 0.0;
372 
373  assert( scip != NULL );
374  assert( vars != NULL );
375  assert( nvars > 0 );
376  assert( readerdata != NULL );
377 
378  /* duplicate variable and value array */
379  nactivevars = nvars;
380  SCIP_CALL( SCIPduplicateBufferArray(scip, &activevars, vars, nactivevars ) );
381  if( vals != NULL )
382  {
383  SCIP_CALL( SCIPduplicateBufferArray(scip, &activevals, vals, nactivevars ) );
384  }
385  else
386  {
387  SCIP_CALL( SCIPallocBufferArray(scip, &activevals, nactivevars) );
388 
389  for( v = 0; v < nactivevars; ++v )
390  activevals[v] = 1.0;
391  }
392 
393  /* retransform given variables to active variables */
394  SCIP_CALL( getActiveVariables(scip, activevars, activevals, &nactivevars, &activeconstant, transformed) );
395 
396  if( ! readerdata->rgb_relative )
397  {
398  if( ! printbool )
399  {
400  for(v = 0; v < nactivevars; ++v)
401  {
402  if( REALABS(activevals[v]) > *maxcoef)
403  *maxcoef = REALABS(activevals[v]);
404  }
405  }
406  else
407  {
408  assert (*maxcoef > 0);
409  /* print constraint */
410  printRow(scip, file, readerdata, activevars, activevals, nactivevars, ncompletevars, *maxcoef);
411  }
412  }
413  else
414  {
415  /* print constraint */
416  printRow(scip, file, readerdata, activevars, activevals, nactivevars, ncompletevars, *maxcoef);
417  }
418 
419  /* free buffer arrays */
420  SCIPfreeBufferArray(scip, &activevars);
421  SCIPfreeBufferArray(scip, &activevals);
422 
423  return SCIP_OKAY;
424 }
425 
426 
427 /*
428  * Callback methods of reader
429  */
430 
431 /** copy method for reader plugins (called when SCIP copies plugins) */
432 static
433 SCIP_DECL_READERCOPY(readerCopyPpm)
434 { /*lint --e{715}*/
435  assert(scip != NULL);
436  assert(reader != NULL);
437  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
438 
439  /* call inclusion method of reader */
441 
442  return SCIP_OKAY;
443 }
444 
445 /** destructor of reader to free user data (called when SCIP is exiting) */
446 static
447 SCIP_DECL_READERFREE(readerFreePpm)
448 {
449  SCIP_READERDATA* readerdata;
450 
451  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
452  readerdata = SCIPreaderGetData(reader);
453  assert(readerdata != NULL);
454  SCIPfreeBlockMemory(scip, &readerdata);
455 
456  return SCIP_OKAY;
457 }
458 
459 
460 /** problem writing method of reader */
461 static
462 SCIP_DECL_READERWRITE(readerWritePpm)
463 { /*lint --e{715}*/
464 
465  SCIP_READERDATA* readerdata;
466 
467  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
468  readerdata = SCIPreaderGetData(reader);
469  assert(readerdata != NULL);
470 
471  SCIP_CALL( SCIPwritePpm(scip, file, name, readerdata, transformed, vars, nvars, conss, nconss, result) );
472 
473  return SCIP_OKAY;
474 }
475 
476 /*
477  * reader specific interface methods
478  */
479 
480 /** includes the ppm file reader in SCIP */
482  SCIP* scip /**< SCIP data structure */
483  )
484 {
485  SCIP_READERDATA* readerdata;
486  SCIP_READER* reader;
487 
488  /* create ppm reader data */
489  SCIP_CALL( SCIPallocBlockMemory(scip, &readerdata) );
490  initReaderdata(readerdata);
491 
492  /* include reader */
494 
495  assert(reader != NULL);
496 
497  /* set non fundamental callbacks via setter functions */
498  SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyPpm) );
499  SCIP_CALL( SCIPsetReaderFree(scip, reader, readerFreePpm) );
500  SCIP_CALL( SCIPsetReaderWrite(scip, reader, readerWritePpm) );
501 
502  /* add ppm reader parameters */
504  "reading/ppmreader/rgbrelativ", "should the coloring values be relativ or absolute",
505  &readerdata->rgb_relative, FALSE, DEFAULT_PPM_RGB_RELATIVE, NULL, NULL) );
507  "reading/ppmreader/rgbascii", "should the output format be binary(P6) (otherwise plain(P3) format)",
508  &readerdata->rgb_ascii, FALSE, DEFAULT_PPM_RGB_ASCII, NULL, NULL) );
510  "reading/ppmreader/coefficientlimit",
511  "splitting coefficients in this number of intervals",
512  &readerdata->coef_limit, FALSE, DEFAULT_PPM_COEF_LIMIT, 3, 16, NULL, NULL) );
514  "reading/ppmreader/rgblimit",
515  "maximal color value",
516  &readerdata->rgb_limit, FALSE, DEFAULT_PPM_RGB_LIMIT, 0, 255, NULL, NULL) );
517 
518  return SCIP_OKAY;
519 }
520 
521 
522 /** writes problem to file */
524  SCIP* scip, /**< SCIP data structure */
525  FILE* file, /**< output file, or NULL if standard output should be used */
526  const char* name, /**< problem name */
527  SCIP_READERDATA* readerdata, /**< information for reader */
528  SCIP_Bool transformed, /**< TRUE iff problem is the transformed problem */
529  SCIP_VAR** vars, /**< array with active variables ordered binary, integer, implicit, continuous */
530  int nvars, /**< number of active variables in the problem */
531  SCIP_CONS** conss, /**< array with constraints of the problem */
532  int nconss, /**< number of constraints in the problem */
533  SCIP_RESULT* result /**< pointer to store the result of the file writing call */
534  )
535 { /*lint --e{715}*/
536  int c;
537  int v;
538  int i;
539 
540  int linecnt;
541  char linebuffer[PPM_MAX_LINELEN];
542 
543  SCIP_CONSHDLR* conshdlr;
544  const char* conshdlrname;
545  SCIP_CONS* cons;
546 
547  SCIP_VAR** consvars;
548  SCIP_Real* consvals;
549  int nconsvars;
550  int i_max = 1;
551  SCIP_Real maxcoef = 0;
552  SCIP_Bool printbool = FALSE;
553 
554  assert( scip != NULL );
555  assert(readerdata != NULL);
556 
557  /* print statistics as comment to file */
558  if(readerdata->rgb_ascii)
559  SCIPinfoMessage(scip, file, "P6\n");
560  else
561  SCIPinfoMessage(scip, file, "P3\n");
562  SCIPinfoMessage(scip, file, "# %s\n", name);
563  SCIPinfoMessage(scip, file, "%d %d\n", nvars, nconss);
564  SCIPinfoMessage(scip, file, "255\n");
565 
566  clearLine(linebuffer, &linecnt);
567 
568  if( ! readerdata->rgb_relative )
569  i_max = 2;
570 
571  for(i = 0; i < i_max; ++i)
572  {
573  if( i )
574  {
575  printbool = TRUE;
576  SCIPdebugMsgPrint(scip, "Maximal coefficient = %g\n", maxcoef);
577  }
578 
579  for(c = 0; c < nconss; ++c)
580  {
581  cons = conss[c];
582  assert( cons != NULL);
583 
584  /* in case the transformed is written only constraint are posted which are enabled in the current node */
585  assert(!transformed || SCIPconsIsEnabled(cons));
586 
587  conshdlr = SCIPconsGetHdlr(cons);
588  assert( conshdlr != NULL );
589 
590  conshdlrname = SCIPconshdlrGetName(conshdlr);
591  assert( transformed == SCIPconsIsTransformed(cons) );
592 
593  if( strcmp(conshdlrname, "linear") == 0 )
594  {
595  consvars = SCIPgetVarsLinear(scip, cons);
596  nconsvars = SCIPgetNVarsLinear(scip, cons);
597  assert( consvars != NULL || nconsvars == 0 );
598 
599  if( nconsvars > 0 )
600  {
601  SCIP_CALL( printLinearCons(scip, file, readerdata, consvars, SCIPgetValsLinear(scip, cons),
602  nconsvars, nvars, transformed, &maxcoef, printbool) );
603  }
604  }
605  else if( strcmp(conshdlrname, "setppc") == 0 )
606  {
607  consvars = SCIPgetVarsSetppc(scip, cons);
608  nconsvars = SCIPgetNVarsSetppc(scip, cons);
609  assert( consvars != NULL || nconsvars == 0 );
610 
611  if( nconsvars > 0 )
612  {
613  SCIP_CALL( printLinearCons(scip, file, readerdata, consvars, NULL,
614  nconsvars, nvars, transformed, &maxcoef, printbool) );
615  }
616  }
617  else if( strcmp(conshdlrname, "logicor") == 0 )
618  {
619  consvars = SCIPgetVarsLogicor(scip, cons);
620  nconsvars = SCIPgetNVarsLogicor(scip, cons);
621  assert( consvars != NULL || nconsvars == 0 );
622 
623  if( nconsvars > 0 )
624  {
625  SCIP_CALL( printLinearCons(scip, file, readerdata, consvars, NULL,
626  nconsvars, nvars, transformed, &maxcoef, printbool) );
627  }
628  }
629  else if( strcmp(conshdlrname, "knapsack") == 0 )
630  {
631  SCIP_Longint* weights;
632 
633  consvars = SCIPgetVarsKnapsack(scip, cons);
634  nconsvars = SCIPgetNVarsKnapsack(scip, cons);
635  assert( consvars != NULL || nconsvars == 0 );
636 
637  /* copy Longint array to SCIP_Real array */
638  weights = SCIPgetWeightsKnapsack(scip, cons);
639  SCIP_CALL( SCIPallocBufferArray(scip, &consvals, nconsvars) );
640  for( v = 0; v < nconsvars; ++v )
641  consvals[v] = (SCIP_Real)weights[v];
642 
643  if( nconsvars > 0 )
644  {
645  SCIP_CALL( printLinearCons(scip, file, readerdata, consvars, consvals, nconsvars, nvars, transformed, &maxcoef, printbool) );
646  }
647 
648  SCIPfreeBufferArray(scip, &consvals);
649  }
650  else if( strcmp(conshdlrname, "varbound") == 0 )
651  {
652  SCIP_CALL( SCIPallocBufferArray(scip, &consvars, 2) );
653  SCIP_CALL( SCIPallocBufferArray(scip, &consvals, 2) );
654 
655  consvars[0] = SCIPgetVarVarbound(scip, cons);
656  consvars[1] = SCIPgetVbdvarVarbound(scip, cons);
657 
658  consvals[0] = 1.0;
659  consvals[1] = SCIPgetVbdcoefVarbound(scip, cons);
660 
661  SCIP_CALL( printLinearCons(scip, file, readerdata, consvars, consvals, 2, nvars, transformed, &maxcoef, printbool) );
662 
663  SCIPfreeBufferArray(scip, &consvars);
664  SCIPfreeBufferArray(scip, &consvals);
665  }
666  else
667  {
668  SCIPwarningMessage(scip, "constraint handler <%s> cannot print requested format\n", conshdlrname );
669  SCIPinfoMessage(scip, file, "\\ ");
670  SCIP_CALL( SCIPprintCons(scip, cons, file) );
671  SCIPinfoMessage(scip, file, ";\n");
672  }
673  }
674  }
675 
676  *result = SCIP_SUCCESS;
677 
678  return SCIP_OKAY;
679 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_Bool SCIPconsIsEnabled(SCIP_CONS *cons)
Definition: cons.c:8083
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)
Definition: reader_ppm.c:354
static void calcColorValue(SCIP *scip, SCIP_READERDATA *readerdata, SCIP_Real coef, int *red, int *green, int *blue, SCIP_Real scale)
Definition: reader_ppm.c:187
Constraint handler for variable bound constraints .
int SCIPgetNVarsSetppc(SCIP *scip, SCIP_CONS *cons)
Definition: cons_setppc.c:9230
int SCIPgetNVarsLogicor(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_READERCOPY(readerCopyPpm)
Definition: reader_ppm.c:433
const char * SCIPreaderGetName(SCIP_READER *reader)
Definition: reader.c:515
SCIP_RETCODE SCIPincludeReaderPpm(SCIP *scip)
Definition: reader_ppm.c:481
#define DEFAULT_PPM_COEF_LIMIT
Definition: reader_ppm.c:45
#define FALSE
Definition: def.h:64
static void endLine(SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, char *linebuffer, int *linecnt)
Definition: reader_ppm.c:136
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10011
#define TRUE
Definition: def.h:63
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:16969
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
Definition: cons.c:8295
SCIP_VAR ** SCIPgetVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip.h:22602
#define SCIPduplicateBufferArray(scip, ptr, source, num)
Definition: scip.h:22628
file writer for portable pixmap file format (PPM), open with common graphic viewer programs (e...
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:22632
Constraint handler for the set partitioning / packing / covering constraints .
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip.h:22585
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1267
#define SCIPdebugMsgPrint
Definition: scip.h:456
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.c:4265
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip.c:1343
#define DEFAULT_PPM_RGB_RELATIVE
Definition: reader_ppm.c:46
#define DEFAULT_PPM_RGB_ASCII
Definition: reader_ppm.c:47
SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
Definition: reader.c:450
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)
Definition: cons.c:4113
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
SCIP_Real SCIPgetVbdcoefVarbound(SCIP *scip, SCIP_CONS *cons)
#define PPM_MAX_LINELEN
Definition: reader_ppm.c:43
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)
Definition: reader_ppm.c:79
#define DEFAULT_PPM_RGB_LIMIT
Definition: reader_ppm.c:44
#define REALABS(x)
Definition: def.h:173
#define READER_DESC
Definition: reader_ppm.c:37
SCIP_VAR * SCIPgetVbdvarVarbound(SCIP *scip, SCIP_CONS *cons)
#define SCIP_CALL(x)
Definition: def.h:350
#define READER_NAME
Definition: reader_ppm.c:36
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.c:19255
static SCIP_DECL_READERWRITE(readerWritePpm)
Definition: reader_ppm.c:462
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:22620
struct SCIP_ReaderData SCIP_READERDATA
Definition: type_reader.h:37
public data structures and miscellaneous methods
#define SCIP_Bool
Definition: def.h:61
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip.c:5264
static void clearLine(char *linebuffer, int *linecnt)
Definition: reader_ppm.c:122
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
Definition: scip.c:29091
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8006
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
Definition: scip.c:5374
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12184
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: scip.c:5302
SCIP_VAR ** SCIPgetVarsSetppc(SCIP *scip, SCIP_CONS *cons)
Definition: cons_setppc.c:9251
static void initReaderdata(SCIP_READERDATA *readerdata)
Definition: reader_ppm.c:64
static const SCIP_Real scalars[]
Definition: lp.c:5618
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)
Definition: reader_ppm.c:162
#define READER_EXTENSION
Definition: reader_ppm.c:38
#define SCIP_Real
Definition: def.h:149
int SCIPgetNVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_READERFREE(readerFreePpm)
Definition: reader_ppm.c:447
#define SCIP_Longint
Definition: def.h:134
static void printRow(SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, SCIP_VAR **vars, SCIP_Real *vals, int nvars, int ntotalvars, SCIP_Real maxcoef)
Definition: reader_ppm.c:249
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)
Definition: reader_ppm.c:523
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
Definition: scip.c:47149
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
Definition: scip.c:5326
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.c:4239
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip.h:22624