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