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