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