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-2016 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_relativ;
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_relativ = 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
161  PPM_PRINTLEN */
162 static
164  SCIP* scip, /**< SCIP data structure */
165  FILE* file, /**< output file (or NULL for standard output) */
166  SCIP_READERDATA* readerdata, /**< information for reader */
167  char* linebuffer, /**< line */
168  int* linecnt, /**< number of characters in line */
169  const char* extension /**< string to extent the line */
170  )
171 {
172  assert( scip != NULL );
173  assert( linebuffer != NULL );
174  assert( linecnt != NULL );
175  assert( extension != NULL );
176 
177  if( *linecnt + strlen(extension) > PPM_MAX_LINELEN - 1 )
178  endLine(scip, file, readerdata, linebuffer, linecnt);
179 
180  /* append extension to linebuffer */
181  strncat(linebuffer, extension, PPM_MAX_LINELEN - (unsigned int)(*linecnt) - 1);
182  (*linecnt) += (int) strlen(extension);
183 }
184 
185 
186 /** calculates the color value for a given coefficient */
187 static
189  SCIP* scip, /**< SCIP data structure */
190  SCIP_READERDATA* readerdata, /**< information for reader */
191  SCIP_Real coef, /**< Coefficient to scale */
192  int* red, /**< red part */
193  int* green, /**< green part */
194  int* blue, /**< blue part */
195  SCIP_Real scale /**< maximal coefficient */
196  )
197 {
198  SCIP_Real coeflog;
199 
200  assert(scip != NULL);
201  assert(readerdata != NULL);
202  assert(readerdata->rgb_limit >= 0);
203  assert(coef > 0);
204 
205  coeflog = SCIPfloor(scip, log10(coef));
206 
207  if(!(readerdata->rgb_relativ))
208  {
209  (*red) = 255;
210  (*blue) = ((readerdata->rgb_limit) - (unsigned short) (coef/scale*(readerdata->rgb_limit)));
211  (*green) = *blue;
212  }
213  else
214  {
215  if( coeflog >= 0 )
216  {
217  (*red) = 255;
218  if( coeflog >= (readerdata->coef_limit) )
219  {
220  (*blue) = 0;
221  (*green) = 0;
222  }
223  else
224  {
225  (*blue) = (readerdata->rgb_limit) - (unsigned short) ((readerdata->rgb_limit)*coeflog/(readerdata->coef_limit));
226  (*green) = *blue;
227  }
228  }
229  else
230  {
231  (*blue) = 255;
232  coeflog = -1.0*coeflog;
233  if( coeflog >= (readerdata->coef_limit) )
234  {
235  (*red) = 0;
236  (*green) = 0;
237  }
238  else
239  {
240  (*red) = (readerdata->rgb_limit) - (unsigned short) ((readerdata->rgb_limit)*coeflog/(readerdata->coef_limit));
241  (*green) = *red;
242  }
243  }
244  }
245 }
246 
247 
248 /** print row in PPM format to file stream */
249 static
250 void printRow(
251  SCIP* scip, /**< SCIP data structure */
252  FILE* file, /**< output file (or NULL for standard output) */
253  SCIP_READERDATA* readerdata, /**< information for reader */
254  SCIP_VAR** vars, /**< array of constraint variables */
255  SCIP_Real* vals, /**< array of constraint values */
256  int nvars, /**< number of constraint variables */
257  int ntotalvars, /**< number of variables */
258  SCIP_Real maxcoef /**< maximal coefficient */
259  )
260 {
261  int v;
262  int i;
263  int j;
264 
265  int red;
266  int green;
267  int blue;
268 
269  char linebuffer[PPM_MAX_LINELEN];
270  int linecnt;
271  int varindex;
272  int actvarindex;
273  int maxvarindex;
274  int indexvar = 0;
275 
276  char buffer[PPM_MAX_LINELEN];
277  const unsigned char max = (unsigned char)255;
278  char white[4];
279 
280  assert( scip != NULL );
281  assert (nvars > 0);
282  assert (readerdata != NULL);
283 
284  i = 0;
285  varindex = -1;
286  maxvarindex = 0;
287 
288  (void) SCIPsnprintf(white, 4, "%c%c%c", max, max, max);
289  clearLine(linebuffer, &linecnt);
290 
291  /* calculate maximum index of the variables in this constraint */
292  for( v = 0; v < nvars; ++v )
293  {
294  if(maxvarindex < SCIPvarGetProbindex(vars[v]))
295  maxvarindex = SCIPvarGetProbindex(vars[v]);
296  }
297 
298  assert(maxvarindex < ntotalvars);
299 
300  /* print coefficients */
301  for(v = 0; v < nvars; ++v)
302  {
303  actvarindex = maxvarindex;
304  for(j = 0; j < nvars; ++j)
305  {
306  if( varindex < SCIPvarGetProbindex(vars[j]) && SCIPvarGetProbindex(vars[j]) <= actvarindex )
307  {
308  actvarindex = SCIPvarGetProbindex(vars[j]);
309  indexvar = j;
310  }
311  }
312  varindex = actvarindex;
313 
314  /* fill in white points since these variables indices do not exits in this constraint */
315  for( ; i < varindex; ++i )
316  {
317  if(readerdata->rgb_ascii)
318  appendLine(scip, file, readerdata, linebuffer, &linecnt, white);
319  else
320  appendLine(scip, file, readerdata, linebuffer, &linecnt, " 255 255 255 ");
321  }
322 
323 
324  calcColorValue(scip, readerdata, REALABS(vals[indexvar]), &red, &green, &blue, maxcoef);
325  if(readerdata->rgb_ascii)
326  {
327  if(red == 35 || red == 0) red++;
328  if(green==35 || green == 0) green++;
329  if(blue==35 || blue == 0) 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_relativ)
397  {
398  if(!printbool)
399  for(v = 0; v < nactivevars; ++v)
400  {
401  if( REALABS(activevals[v]) > *maxcoef)
402  *maxcoef = REALABS(activevals[v]);
403  }
404  else
405  {
406  assert (*maxcoef > 0);
407  /* print constraint */
408  printRow(scip, file, readerdata, activevars, activevals, nactivevars, ncompletevars, *maxcoef);
409  }
410  }
411  else
412  {
413  /* print constraint */
414  printRow(scip, file, readerdata, activevars, activevals, nactivevars, ncompletevars, *maxcoef);
415  }
416 
417  /* free buffer arrays */
418  SCIPfreeBufferArray(scip, &activevars);
419  SCIPfreeBufferArray(scip, &activevals);
420 
421  return SCIP_OKAY;
422 }
423 
424 
425 /*
426  * Callback methods of reader
427  */
428 
429 /** copy method for reader plugins (called when SCIP copies plugins) */
430 static
431 SCIP_DECL_READERCOPY(readerCopyPpm)
432 { /*lint --e{715}*/
433  assert(scip != NULL);
434  assert(reader != NULL);
435  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
436 
437  /* call inclusion method of reader */
439 
440  return SCIP_OKAY;
441 }
442 
443 /** destructor of reader to free user data (called when SCIP is exiting) */
444 static
445 SCIP_DECL_READERFREE(readerFreePpm)
446 {
447  SCIP_READERDATA* readerdata;
448 
449  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
450  readerdata = SCIPreaderGetData(reader);
451  assert(readerdata != NULL);
452  SCIPfreeMemory(scip, &readerdata);
453 
454  return SCIP_OKAY;
455 }
456 
457 
458 /** problem writing method of reader */
459 static
460 SCIP_DECL_READERWRITE(readerWritePpm)
461 { /*lint --e{715}*/
462 
463  SCIP_READERDATA* readerdata;
464 
465  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
466  readerdata = SCIPreaderGetData(reader);
467  assert(readerdata != NULL);
468 
469  SCIP_CALL( SCIPwritePpm(scip, file, name, readerdata, transformed, vars, nvars, conss, nconss, result) );
470 
471  return SCIP_OKAY;
472 }
473 
474 /*
475  * reader specific interface methods
476  */
477 
478 /** includes the ppm file reader in SCIP */
480  SCIP* scip /**< SCIP data structure */
481  )
482 {
483  SCIP_READERDATA* readerdata;
484  SCIP_READER* reader;
485 
486  /* create ppm reader data */
487  SCIP_CALL( SCIPallocMemory(scip, &readerdata) );
488  initReaderdata(readerdata);
489 
490  /* include reader */
492 
493  assert(reader != NULL);
494 
495  /* set non fundamental callbacks via setter functions */
496  SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyPpm) );
497  SCIP_CALL( SCIPsetReaderFree(scip, reader, readerFreePpm) );
498  SCIP_CALL( SCIPsetReaderWrite(scip, reader, readerWritePpm) );
499 
500  /* add ppm reader parameters */
502  "reading/ppmreader/rgbrelativ", "should the coloring values be relativ or absolute",
503  &readerdata->rgb_relativ, FALSE, DEFAULT_PPM_RGB_RELATIVE, NULL, NULL) );
505  "reading/ppmreader/rgbascii", "should the output format be binary(P6) (otherwise plain(P3) format)",
506  &readerdata->rgb_ascii, FALSE, DEFAULT_PPM_RGB_ASCII, NULL, NULL) );
508  "reading/ppmreader/coefficientlimit",
509  "splitting coefficients in this number of intervals",
510  &readerdata->coef_limit, FALSE, DEFAULT_PPM_COEF_LIMIT, 3, 16, NULL, NULL) );
512  "reading/ppmreader/rgblimit",
513  "maximal color value",
514  &readerdata->rgb_limit, FALSE, DEFAULT_PPM_RGB_LIMIT, 0, 255, NULL, NULL) );
515 
516  return SCIP_OKAY;
517 }
518 
519 
520 /** writes problem to file */
522  SCIP* scip, /**< SCIP data structure */
523  FILE* file, /**< output file, or NULL if standard output should be used */
524  const char* name, /**< problem name */
525  SCIP_READERDATA* readerdata, /**< information for reader */
526  SCIP_Bool transformed, /**< TRUE iff problem is the transformed problem */
527  SCIP_VAR** vars, /**< array with active variables ordered binary, integer, implicit, continuous */
528  int nvars, /**< number of active variables in the problem */
529  SCIP_CONS** conss, /**< array with constraints of the problem */
530  int nconss, /**< number of constraints in the problem */
531  SCIP_RESULT* result /**< pointer to store the result of the file writing call */
532  )
533 { /*lint --e{715}*/
534  int c;
535  int v;
536  int i;
537 
538  int linecnt;
539  char linebuffer[PPM_MAX_LINELEN];
540 
541  SCIP_CONSHDLR* conshdlr;
542  const char* conshdlrname;
543  SCIP_CONS* cons;
544 
545  SCIP_VAR** consvars;
546  SCIP_Real* consvals;
547  int nconsvars;
548  int i_max = 1;
549  SCIP_Real maxcoef = 0;
550  SCIP_Bool printbool = FALSE;
551 
552  assert( scip != NULL );
553  assert(readerdata != NULL);
554 
555  /* print statistics as comment to file */
556  if(readerdata->rgb_ascii)
557  SCIPinfoMessage(scip, file, "P6\n");
558  else
559  SCIPinfoMessage(scip, file, "P3\n");
560  SCIPinfoMessage(scip, file, "# %s\n", name);
561  SCIPinfoMessage(scip, file, "%d %d\n", nvars, nconss);
562  SCIPinfoMessage(scip, file, "255\n");
563 
564  clearLine(linebuffer, &linecnt);
565 
566  if(!(readerdata->rgb_relativ))
567  {
568  i_max = 2;
569  }
570 
571  for(i = 0; i < i_max; ++i)
572  {
573  if(i)
574  {
575  printbool = TRUE;
576  SCIPdebugPrintf("Maximal coefficient = %g\n", maxcoef);
577  }
578 
579 
580  for(c = 0; c < nconss; ++c)
581  {
582  cons = conss[c];
583  assert( cons != NULL);
584 
585  /* in case the transformed is written only constraint are posted which are enabled in the current node */
586  assert(!transformed || SCIPconsIsEnabled(cons));
587 
588  conshdlr = SCIPconsGetHdlr(cons);
589  assert( conshdlr != NULL );
590 
591  conshdlrname = SCIPconshdlrGetName(conshdlr);
592  assert( transformed == SCIPconsIsTransformed(cons) );
593 
594  if( strcmp(conshdlrname, "linear") == 0 )
595  {
596  consvars = SCIPgetVarsLinear(scip, cons);
597  nconsvars = SCIPgetNVarsLinear(scip, cons);
598  assert( consvars != NULL || nconsvars == 0 );
599 
600  if( nconsvars > 0 )
601  {
602  SCIP_CALL( printLinearCons(scip, file, readerdata, consvars, SCIPgetValsLinear(scip, cons),
603  nconsvars, nvars, transformed, &maxcoef, printbool) );
604  }
605  }
606  else if( strcmp(conshdlrname, "setppc") == 0 )
607  {
608  consvars = SCIPgetVarsSetppc(scip, cons);
609  nconsvars = SCIPgetNVarsSetppc(scip, cons);
610  assert( consvars != NULL || nconsvars == 0 );
611 
612  if( nconsvars > 0 )
613  {
614  SCIP_CALL( printLinearCons(scip, file, readerdata, consvars, NULL,
615  nconsvars, nvars, transformed, &maxcoef, printbool) );
616  }
617  }
618  else if( strcmp(conshdlrname, "logicor") == 0 )
619  {
620  consvars = SCIPgetVarsLogicor(scip, cons);
621  nconsvars = SCIPgetNVarsLogicor(scip, cons);
622  assert( consvars != NULL || nconsvars == 0 );
623 
624  if( nconsvars > 0 )
625  {
626  SCIP_CALL( printLinearCons(scip, file, readerdata, consvars, NULL,
627  nconsvars, nvars, transformed, &maxcoef, printbool) );
628  }
629  }
630  else if( strcmp(conshdlrname, "knapsack") == 0 )
631  {
632  SCIP_Longint* weights;
633 
634  consvars = SCIPgetVarsKnapsack(scip, cons);
635  nconsvars = SCIPgetNVarsKnapsack(scip, cons);
636  assert( consvars != NULL || nconsvars == 0 );
637 
638  /* copy Longint array to SCIP_Real array */
639  weights = SCIPgetWeightsKnapsack(scip, cons);
640  SCIP_CALL( SCIPallocBufferArray(scip, &consvals, nconsvars) );
641  for( v = 0; v < nconsvars; ++v )
642  consvals[v] = (SCIP_Real)weights[v];
643 
644  if( nconsvars > 0 )
645  {
646  SCIP_CALL( printLinearCons(scip, file, readerdata, consvars, consvals, nconsvars, nvars, transformed, &maxcoef, printbool) );
647  }
648 
649  SCIPfreeBufferArray(scip, &consvals);
650  }
651  else if( strcmp(conshdlrname, "varbound") == 0 )
652  {
653  SCIP_CALL( SCIPallocBufferArray(scip, &consvars, 2) );
654  SCIP_CALL( SCIPallocBufferArray(scip, &consvals, 2) );
655 
656  consvars[0] = SCIPgetVarVarbound(scip, cons);
657  consvars[1] = SCIPgetVbdvarVarbound(scip, cons);
658 
659  consvals[0] = 1.0;
660  consvals[1] = SCIPgetVbdcoefVarbound(scip, cons);
661 
662  SCIP_CALL( printLinearCons(scip, file, readerdata, consvars, consvals, 2, nvars, transformed, &maxcoef, printbool) );
663 
664  SCIPfreeBufferArray(scip, &consvars);
665  SCIPfreeBufferArray(scip, &consvals);
666  }
667  else
668  {
669  SCIPwarningMessage(scip, "constraint handler <%s> cannot print requested format\n", conshdlrname );
670  SCIPinfoMessage(scip, file, "\\ ");
671  SCIP_CALL( SCIPprintCons(scip, cons, file) );
672  SCIPinfoMessage(scip, file, ";\n");
673  }
674  }
675  }
676 
677  *result = SCIP_SUCCESS;
678 
679  return SCIP_OKAY;
680 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:51
#define SCIPallocMemory(scip, ptr)
Definition: scip.h:20526
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
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:17373
static void calcColorValue(SCIP *scip, SCIP_READERDATA *readerdata, SCIP_Real coef, int *red, int *green, int *blue, SCIP_Real scale)
Definition: reader_ppm.c:188
Constraint handler for variable bound constraints .
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip.h:20589
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12033
const char * SCIPreaderGetName(SCIP_READER *reader)
Definition: reader.c:510
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1248
static SCIP_DECL_READERCOPY(readerCopyPpm)
Definition: reader_ppm.c:431
#define NULL
Definition: lpi_spx.cpp:130
int SCIPgetNVarsSetppc(SCIP *scip, SCIP_CONS *cons)
Definition: cons_setppc.c:9086
#define DEFAULT_PPM_COEF_LIMIT
Definition: reader_ppm.c:45
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
Definition: cons.c:7909
#define FALSE
Definition: def.h:56
static void endLine(SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, char *linebuffer, int *linecnt)
Definition: reader_ppm.c:136
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:8174
#define TRUE
Definition: def.h:55
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:7640
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define SCIP_CALL(x)
Definition: def.h:266
SCIP_Longint * SCIPgetWeightsKnapsack(SCIP *scip, SCIP_CONS *cons)
file writer for portable pixmap file format (PPM), open with common graphic viewer programs (e...
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
Definition: scip.c:26237
Constraint handler for the set partitioning / packing / covering constraints .
SCIP_VAR ** SCIPgetVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
Definition: scip.c:4625
#define DEFAULT_PPM_RGB_RELATIVE
Definition: reader_ppm.c:46
#define DEFAULT_PPM_RGB_ASCII
Definition: reader_ppm.c:47
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:3547
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:3573
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: scip.c:4601
Constraint handler for knapsack constraints of the form , x binary and .
#define SCIPfreeMemory(scip, ptr)
Definition: scip.h:20542
#define SCIPdebugPrintf
Definition: pub_message.h:80
int SCIPgetNVarsLogicor(SCIP *scip, SCIP_CONS *cons)
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:3897
SCIP_VAR ** SCIPgetVarsSetppc(SCIP *scip, SCIP_CONS *cons)
Definition: cons_setppc.c:9107
SCIP_RETCODE SCIPincludeReaderPpm(SCIP *scip)
Definition: reader_ppm.c:479
#define PPM_MAX_LINELEN
Definition: reader_ppm.c:43
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
Definition: scip.c:41758
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 READER_DESC
Definition: reader_ppm.c:37
#define READER_NAME
Definition: reader_ppm.c:36
SCIP_Real SCIPgetVbdcoefVarbound(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_READERWRITE(readerWritePpm)
Definition: reader_ppm.c:460
struct SCIP_ReaderData SCIP_READERDATA
Definition: type_reader.h:37
public data structures and miscellaneous methods
#define SCIP_Bool
Definition: def.h:53
static void clearLine(char *linebuffer, int *linecnt)
Definition: reader_ppm.c:122
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip.c:4563
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:521
SCIP_VAR * SCIPgetVbdvarVarbound(SCIP *scip, SCIP_CONS *cons)
Constraint handler for linear constraints in their most general form, .
SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
Definition: reader.c:445
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:20585
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
Definition: scip.c:4673
static void initReaderdata(SCIP_READERDATA *readerdata)
Definition: reader_ppm.c:64
static const SCIP_Real scalars[]
Definition: lp.c:5506
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip.c:1281
#define REALABS(x)
Definition: def.h:151
SCIP_VAR ** SCIPgetVarsLogicor(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
Definition: scip.h:20593
static void appendLine(SCIP *scip, FILE *file, SCIP_READERDATA *readerdata, char *linebuffer, int *linecnt, const char *extension)
Definition: reader_ppm.c:163
#define READER_EXTENSION
Definition: reader_ppm.c:38
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:16750
#define SCIP_Real
Definition: def.h:127
static SCIP_DECL_READERFREE(readerFreePpm)
Definition: reader_ppm.c:445
#define SCIP_Longint
Definition: def.h:112
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:250
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:20597
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR * SCIPgetVarVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPconsIsEnabled(SCIP_CONS *cons)
Definition: cons.c:7707
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)