Scippy

SCIP

Solving Constraint Integer Programs

reader_cip.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-2019 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_cip.c
17  * @brief CIP file reader
18  * @author Stefan Heinz
19  * @author Marc Pfetsch
20  * @author Michael Winkler
21  *
22  */
23 
24 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
25 
26 #include "blockmemshell/memory.h"
27 #include <ctype.h>
28 #include "scip/cons_linear.h"
29 #include "scip/pub_fileio.h"
30 #include "scip/pub_message.h"
31 #include "scip/pub_misc.h"
32 #include "scip/pub_reader.h"
33 #include "scip/pub_var.h"
34 #include "scip/reader_cip.h"
35 #include "scip/scip_cons.h"
36 #include "scip/scip_mem.h"
37 #include "scip/scip_message.h"
38 #include "scip/scip_numerics.h"
39 #include "scip/scip_param.h"
40 #include "scip/scip_prob.h"
41 #include "scip/scip_reader.h"
42 #include "scip/scip_var.h"
43 #include <string.h>
44 
45 #if !defined(_WIN32) && !defined(_WIN64)
46 #include <strings.h> /*lint --e{766}*/ /* needed for strncasecmp() */
47 #endif
48 
49 #define READER_NAME "cipreader"
50 #define READER_DESC "file reader for CIP (Constraint Integer Program) format"
51 #define READER_EXTENSION "cip"
52 
53 #define DEFAULT_CIP_WRITEFIXEDVARS TRUE /**< Should fixed and aggregated variables be written when writing? */
54 
55 
56 /** CIP reading data */
57 struct SCIP_ReaderData
58 {
59  SCIP_Bool writefixedvars; /**< Should fixed and aggregated variables be written when writing? */
60 };
61 
62 
63 /** Section of the in CIP files */
65 {
66  CIP_START, /**< start tag */
67  CIP_STATISTIC, /**< statistics section */
68  CIP_OBJECTIVE, /**< objective */
69  CIP_VARS, /**< list of (free) variables */
70  CIP_FIXEDVARS, /**< list of fixed variables */
71  CIP_CONSTRAINTS, /**< constraints */
72  CIP_END /**< end of file tag */
73 };
74 typedef enum CipSection CIPSECTION; /**< Section of the in CIP files */
75 
76 
77 /*
78  * Data structures
79  */
80 
81 /** CIP reading data */
82 struct CipInput
83 {
84  SCIP_FILE* file; /**< input file */
85  char* strbuf; /**< string buffer for input lines */
86  int len; /**< length of strbuf */
87  int readingsize; /**< size of block in which len is increased if necessary */
88  int linenumber; /**< number of line in input file */
89  CIPSECTION section; /**< current section */
90  SCIP_Bool haserror; /**< some error occurred */
91  SCIP_Bool endfile; /**< we have reached the end of the file */
92 };
93 typedef struct CipInput CIPINPUT; /**< CIP reading data */
94 
95 
96 /*
97  * Local methods for reading/parsing
98  */
99 
100 /** get next input line; this are all characters until the next semicolon */
101 static
103  SCIP* scip, /**< SCIP data structure */
104  CIPINPUT* cipinput /**< CIP parsing data */
105  )
106 {
107  char* endline;
108  char* endcharacter;
109  char* windowsendlinechar;
110 
111  assert(cipinput != NULL);
112 
113  /* read next line */
114  cipinput->endfile = (SCIPfgets(cipinput->strbuf, cipinput->len, cipinput->file) == NULL);
115 
116  if( cipinput->endfile )
117  {
118  /* clear the line for safety reason */
119  BMSclearMemoryArray(cipinput->strbuf, cipinput->len);
120  return SCIP_OKAY;
121  }
122 
123  cipinput->linenumber++;
124  endline = strchr(cipinput->strbuf, '\n');
125 
126  endcharacter = strchr(cipinput->strbuf, ';');
127  while( endline == NULL || (endcharacter == NULL && cipinput->section == CIP_CONSTRAINTS && strncmp(cipinput->strbuf, "END", 3) != 0 ) )
128  {
129  int pos;
130 
131  /* we refill the buffer from the '\n' character */
132  if( endline == NULL )
133  pos = cipinput->len - 1;
134  else
135  pos = (int) (endline - cipinput->strbuf);
136 
137  /* don't erase the '\n' from all buffers for constraints */
138  if( endline != NULL && cipinput->section == CIP_CONSTRAINTS )
139  pos++;
140 
141  /* if necessary reallocate memory */
142  if( pos + cipinput->readingsize >= cipinput->len )
143  {
144  cipinput->len = SCIPcalcMemGrowSize(scip, pos + cipinput->readingsize);
145  SCIP_CALL( SCIPreallocBufferArray(scip, &(cipinput->strbuf), cipinput->len) );
146  }
147 
148  /* read next line */
149  cipinput->endfile = (SCIPfgets(&(cipinput->strbuf[pos]), cipinput->len - pos, cipinput->file) == NULL);
150 
151  if( cipinput->endfile )
152  {
153  /* clear the line for safety reason */
154  BMSclearMemoryArray(cipinput->strbuf, cipinput->len);
155  return SCIP_OKAY;
156  }
157 
158  cipinput->linenumber++;
159  endline = strrchr(cipinput->strbuf, '\n');
160  endcharacter = strchr(cipinput->strbuf, ';');
161  }
162  assert(endline != NULL);
163 
164  /*SCIPdebugMsg(scip, "read line: %s\n", cipinput->strbuf);*/
165 
166  /* check for windows "carriage return" endline character */
167  windowsendlinechar = strrchr(cipinput->strbuf, '\r');
168  if( windowsendlinechar != NULL && windowsendlinechar + 1 == endline )
169  --endline;
170  else
171  /* if the assert should not hold we found a windows "carriage return" which was not at the end of the line */
172  assert(windowsendlinechar == NULL);
173 
174  if( cipinput->section == CIP_CONSTRAINTS && endcharacter != NULL && endline - endcharacter != 1 )
175  {
176  SCIPerrorMessage("Constraint line has to end with ';\\n' (line: %d).\n", cipinput->linenumber);
177  cipinput->haserror = TRUE;
178  return SCIP_OKAY; /* return error at hightest level */
179  }
180 
181  *endline = '\0';
182 
183  return SCIP_OKAY;
184 }
185 
186 /** read the problem name out of the statistics */
187 static
188 void getStart(
189  SCIP* scip, /**< SCIP data structure */
190  CIPINPUT* cipinput /**< CIP parsing data */
191  )
192 {
193  char* buf;
194 
195  buf = cipinput->strbuf;
196 
197  if( strncmp(buf, "STATISTICS", 9) == 0 )
198  {
199  cipinput->section = CIP_STATISTIC;
200  return;
201  }
202 
203  if( strncmp(buf, "VARIABLES", 8) == 0 || strncmp(buf, "FIXED", 5) == 0 || strncmp(buf, "CONSTRAINTS", 11) == 0 || strncmp(buf, "OBJECTIVE", 9) == 0 )
204  {
205  SCIPerrorMessage("Syntax Error: File has to start with 'STATISTICS' section.\n");
206  cipinput->haserror = TRUE;
207  }
208 }
209 
210 
211 /** read the problem name out of the statistics */
212 static
214  SCIP* scip, /**< SCIP data structure */
215  CIPINPUT* cipinput /**< CIP parsing data */
216  )
217 {
218  char* buf;
219 
220  buf = cipinput->strbuf;
221 
222  if( strncmp(buf, "OBJECTIVE", 9) == 0 )
223  {
224  cipinput->section = CIP_OBJECTIVE;
225  return SCIP_OKAY;
226  }
227 
228  SCIPdebugMsg(scip, "parse statistics\n");
229 
230  if( strncmp(buf, " Problem name", 14) == 0 )
231  {
232  char* name;
233  char* s;
234 
235  name = strchr(buf, ':');
236 
237  if( name == NULL )
238  {
239  SCIPwarningMessage(scip, "did not find problem name (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
240  return SCIP_OKAY; /* no error, might work with empty problem name */
241  }
242 
243  /* skip ':' */
244  ++name;
245 
246  /* make sure that we terminate the string at comments ('#') or newline ('\r', '\n')*/
247  if( NULL != (s = strpbrk(name, "#\r\n")) )
248  *s = '\0';
249 
250  /* remove white space (tabs, ' ') in front of the name */
251  while( isspace((unsigned char)* name) )
252  ++name;
253 
254  /* set problem name */
255  SCIP_CALL( SCIPsetProbName(scip, name) );
256 
257  SCIPdebugMsg(scip, "problem name <%s>\n", name);
258  }
259 
260  return SCIP_OKAY;
261 }
262 
263 /** read objective sense, offset, and scale */
264 static
266  SCIP* scip, /**< SCIP data structure */
267  CIPINPUT* cipinput, /**< CIP parsing data */
268  SCIP_Real* objscale, /**< buffer where to multiply with objective scale */
269  SCIP_Real* objoffset /**< buffer where to add with objective offset */
270  )
271 {
272  char* buf;
273  char* name;
274 
275  assert(objscale != NULL);
276  assert(objoffset != NULL);
277 
278  buf = cipinput->strbuf;
279 
280  if( strncmp(buf, "VARIABLES", 8) == 0 )
281  cipinput->section = CIP_VARS;
282  else if( strncmp(buf, "FIXED", 5) == 0 )
283  cipinput->section = CIP_FIXEDVARS;
284  else if( strncmp(buf, "CONSTRAINTS", 11) == 0 )
285  cipinput->section = CIP_CONSTRAINTS;
286  else if( strncmp(buf, "END", 3) == 0 )
287  cipinput->section = CIP_END;
288 
289  if( cipinput->section != CIP_OBJECTIVE )
290  return SCIP_OKAY;
291 
292  SCIPdebugMsg(scip, "parse objective information\n");
293 
294  /* remove white space */
295  while ( isspace((unsigned char)* buf) )
296  ++buf;
297 
298  if( strncasecmp(buf, "Sense", 5) == 0 )
299  {
300  SCIP_OBJSENSE objsense;
301 
302  name = strchr(buf, ':');
303 
304  if( name == NULL )
305  {
306  SCIPwarningMessage(scip, "did not find objective sense (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
307  return SCIP_OKAY; /* no error - might work with default */
308  }
309 
310  /* skip ':' */
311  ++name;
312 
313  /* remove white space in front of the name */
314  while( isspace((unsigned char)* name) )
315  ++name;
316 
317  if( strncasecmp(name, "minimize", 3) == 0 )
318  objsense = SCIP_OBJSENSE_MINIMIZE;
319  else if( strncasecmp(name, "maximize", 3) == 0 )
320  objsense = SCIP_OBJSENSE_MAXIMIZE;
321  else
322  {
323  SCIPwarningMessage(scip, "unknown objective sense '%s' (line: %d):\n%s\n", name, cipinput->linenumber, cipinput->strbuf);
324  return SCIP_OKAY; /* no error - might work with default */
325  }
326 
327  /* set problem name */
328  SCIP_CALL( SCIPsetObjsense(scip, objsense) );
329  SCIPdebugMsg(scip, "objective sense <%s>\n", objsense == SCIP_OBJSENSE_MINIMIZE ? "minimize" : "maximize");
330  }
331  else if( strncasecmp(buf, "Offset", 6) == 0 )
332  {
333  SCIP_Real off = 0;
334  char* endptr;
335 
336  name = strchr(buf, ':');
337 
338  if( name == NULL )
339  {
340  SCIPwarningMessage(scip, "did not find offset (line: %d)\n", cipinput->linenumber);
341  return SCIP_OKAY;
342  }
343 
344  /* skip ':' */
345  ++name;
346 
347  /* remove white space in front of the name */
348  while(isspace((unsigned char)*name))
349  ++name;
350 
351  if ( SCIPstrToRealValue(name, &off, &endptr) )
352  {
353  *objoffset += off;
354  SCIPdebugMsg(scip, "offset <%g> (total: %g)\n", off, *objoffset);
355  }
356  else
357  {
358  SCIPwarningMessage(scip, "could not parse offset (line: %d)\n%s\n", cipinput->linenumber, cipinput->strbuf);
359  return SCIP_OKAY;
360  }
361  }
362  else if( strncasecmp(buf, "Scale", 5) == 0 )
363  {
364  SCIP_Real scale = 1.0;
365  char* endptr;
366 
367  name = strchr(buf, ':');
368 
369  if( name == NULL )
370  {
371  SCIPwarningMessage(scip, "did not find scale (line: %d)\n", cipinput->linenumber);
372  return SCIP_OKAY;
373  }
374 
375  /* skip ':' */
376  ++name;
377 
378  /* remove white space in front of the name */
379  while(isspace((unsigned char)*name))
380  ++name;
381 
382  if ( SCIPstrToRealValue(name, &scale, &endptr) )
383  {
384  *objscale *= scale;
385  SCIPdebugMsg(scip, "objscale <%g> (total: %g)\n", scale, *objscale);
386  }
387  else
388  {
389  SCIPwarningMessage(scip, "could not parse objective scale (line: %d)\n%s\n", cipinput->linenumber, cipinput->strbuf);
390  return SCIP_OKAY;
391  }
392  }
393 
394  return SCIP_OKAY;
395 }
396 
397 /** read variable */
398 static
400  SCIP* scip, /**< SCIP data structure */
401  CIPINPUT* cipinput, /**< CIP parsing data */
402  SCIP_Bool initial, /**< should var's column be present in the initial root LP? */
403  SCIP_Bool removable, /**< is var's column removable from the LP (due to aging or cleanup)? */
404  SCIP_Real objscale /**< objective scale */
405  )
406 {
407  SCIP_Bool success;
408  SCIP_VAR* var;
409  char* buf;
410  char* endptr;
411 
412  buf = cipinput->strbuf;
413 
414  if( strncmp(buf, "FIXED", 5) == 0 )
415  cipinput->section = CIP_FIXEDVARS;
416  else if( strncmp(buf, "CONSTRAINTS", 4) == 0 )
417  cipinput->section = CIP_CONSTRAINTS;
418  else if( strncmp(buf, "END", 3) == 0 )
419  cipinput->section = CIP_END;
420 
421  if( cipinput->section != CIP_VARS )
422  return SCIP_OKAY;
423 
424  SCIPdebugMsg(scip, "parse variable\n");
425 
426  /* parse the variable */
427  SCIP_CALL( SCIPparseVar(scip, &var, buf, initial, removable, NULL, NULL, NULL, NULL, NULL, &endptr, &success) );
428 
429  if( !success )
430  {
431  SCIPerrorMessage("syntax error in variable information (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
432  cipinput->haserror = TRUE;
433  return SCIP_OKAY;
434  }
435 
436  if( objscale != 1.0 )
437  {
438  SCIP_CALL( SCIPchgVarObj(scip, var, SCIPvarGetObj(var) * objscale) );
439  }
440 
441  SCIP_CALL( SCIPaddVar(scip, var) );
442 
443  SCIPdebug( SCIP_CALL( SCIPprintVar(scip, var, NULL) ) );
444 
445  SCIP_CALL( SCIPreleaseVar(scip, &var) );
446 
447  return SCIP_OKAY;
448 }
449 
450 /** read fixed variable */
451 static
453  SCIP* scip, /**< SCIP data structure */
454  CIPINPUT* cipinput /**< CIP parsing data */
455  )
456 {
457  SCIP_Bool success;
458  SCIP_VAR* var;
459  char* buf;
460  char* endptr;
461  char name[SCIP_MAXSTRLEN];
462 
463  buf = cipinput->strbuf;
464 
465  if( strncmp(buf, "CONSTRAINTS", 11) == 0 )
466  cipinput->section = CIP_CONSTRAINTS;
467  else if( strncmp(buf, "END", 3) == 0 )
468  cipinput->section = CIP_END;
469 
470  if( cipinput->section != CIP_FIXEDVARS )
471  return SCIP_OKAY;
472 
473  SCIPdebugMsg(scip, "parse fixed variable\n");
474 
475  /* parse the variable */
476  SCIP_CALL( SCIPparseVar(scip, &var, buf, TRUE, FALSE, NULL, NULL, NULL, NULL, NULL, &endptr, &success) );
477 
478  if( !success )
479  {
480  SCIPerrorMessage("syntax error in variable information (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
481  cipinput->haserror = TRUE;
482  return SCIP_OKAY;
483  }
484 
485  /* skip intermediate stuff */
486  buf = endptr;
487 
488  while ( *buf != '\0' && (*buf == ' ' || *buf == ',') )
489  ++buf;
490 
491  /* check whether variable is fixed */
492  if ( strncmp(buf, "fixed:", 6) == 0 )
493  {
494  SCIP_CALL( SCIPaddVar(scip, var) );
495  SCIPdebug( SCIP_CALL( SCIPprintVar(scip, var, NULL) ) );
496  }
497  else if ( strncmp(buf, "negated:", 8) == 0 )
498  {
499  SCIP_CONS* lincons;
500  SCIP_VAR* negvar;
501  SCIP_Real vals[2];
502  SCIP_VAR* vars[2];
503 
504  buf += 8;
505 
506  /* we can just parse the next variable (ignoring all other information in between) */
507  SCIP_CALL( SCIPparseVarName(scip, buf, &negvar, &endptr) );
508 
509  if ( negvar == NULL )
510  {
511  SCIPerrorMessage("could not parse negated variable (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
512  cipinput->haserror = TRUE;
513  return SCIP_OKAY;
514  }
515  assert(SCIPvarIsBinary(var));
516  assert(SCIPvarIsBinary(negvar));
517 
518  SCIP_CALL( SCIPaddVar(scip, var) );
519 
520  SCIPdebugMsg(scip, "creating negated variable <%s> (of <%s>) ...\n", SCIPvarGetName(var), SCIPvarGetName(negvar) );
521  SCIPdebug( SCIP_CALL( SCIPprintVar(scip, var, NULL) ) );
522 
523  /* add linear constraint for negation */
524  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "neg_%s", SCIPvarGetName(var) );
525  vars[0] = var;
526  vars[1] = negvar;
527  vals[0] = 1.0;
528  vals[1] = 1.0;
529  SCIPdebugMsg(scip, "coupling constraint:\n");
530  SCIP_CALL( SCIPcreateConsLinear(scip, &lincons, name, 2, vars, vals, 1.0, 1.0, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) );
531  SCIPdebugPrintCons(scip, lincons, NULL);
532  SCIP_CALL( SCIPaddCons(scip, lincons) );
533  SCIP_CALL( SCIPreleaseCons(scip, &lincons) );
534  }
535  else if ( strncmp(buf, "aggregated:", 11) == 0 )
536  {
537  /* handle (multi-)aggregated variables */
538  SCIP_CONS* lincons;
539  SCIP_Real* vals;
540  SCIP_VAR** vars;
541  SCIP_Real rhs = 0.0;
542  const char* str;
543  int nvarssize = 20;
544  int requsize;
545  int nvars;
546 
547  buf += 11;
548 
549  SCIPdebugMsg(scip, "parsing aggregated variable <%s> ...\n", SCIPvarGetName(var));
550 
551  /* first parse constant */
552  if ( ! SCIPstrToRealValue(buf, &rhs, &endptr) )
553  {
554  SCIPerrorMessage("expected constant when aggregated variable information (line: %d):\n%s\n", cipinput->linenumber, buf);
555  cipinput->haserror = TRUE;
556  return SCIP_OKAY;
557  }
558 
559  /* check whether constant is 0.0 */
560  str = endptr;
561  while ( *str != '\0' && isspace(*str) )
562  ++str;
563  /* if next char is '<' we found a variable -> constant is 0 */
564  if ( *str != '<' )
565  {
566  SCIPdebugMsg(scip, "constant: %f\n", rhs);
567  buf = endptr;
568  }
569  else
570  {
571  /* otherwise keep buf */
572  rhs = 0.0;
573  }
574 
575  /* initialize buffers for storing the variables and values */
576  SCIP_CALL( SCIPallocBufferArray(scip, &vars, nvarssize) );
577  SCIP_CALL( SCIPallocBufferArray(scip, &vals, nvarssize) );
578 
579  vars[0] = var;
580  vals[0] = -1.0;
581  --nvarssize;
582 
583  /* parse linear sum to get variables and coefficients */
584  SCIP_CALL( SCIPparseVarsLinearsum(scip, buf, &(vars[1]), &(vals[1]), &nvars, nvarssize, &requsize, &endptr, &success) );
585  if ( success && requsize > nvarssize )
586  {
587  /* realloc buffers and try again */
588  nvarssize = requsize;
589  SCIP_CALL( SCIPreallocBufferArray(scip, &vars, nvarssize + 1) );
590  SCIP_CALL( SCIPreallocBufferArray(scip, &vals, nvarssize + 1) );
591 
592  SCIP_CALL( SCIPparseVarsLinearsum(scip, buf, &(vars[1]), &(vals[1]), &nvars, nvarssize, &requsize, &endptr, &success) );
593  assert( ! success || requsize <= nvarssize); /* if successful, then should have had enough space now */
594  }
595 
596  if( success )
597  {
598  /* add aggregated variable */
599  SCIP_CALL( SCIPaddVar(scip, var) );
600 
601  /* special handling of variables that seem to be slack variables of indicator constraints */
602  str = SCIPvarGetName(var);
603  if ( strncmp(str, "indslack", 8) == 0 )
604  {
605  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "indlin");
606  (void) strncat(name, str+8, SCIP_MAXSTRLEN-7);
607  }
608  else if ( strncmp(str, "t_indslack", 10) == 0 )
609  {
610  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "indlin");
611  (void) strncat(name, str+10, SCIP_MAXSTRLEN-7);
612  }
613  else
614  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s", SCIPvarGetName(var) );
615 
616  /* add linear constraint for (multi-)aggregation */
617  SCIPdebugMsg(scip, "coupling constraint:\n");
618  SCIP_CALL( SCIPcreateConsLinear(scip, &lincons, name, nvars + 1, vars, vals, -rhs, -rhs, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) );
619  SCIPdebugPrintCons(scip, lincons, NULL);
620  SCIP_CALL( SCIPaddCons(scip, lincons) );
621  SCIP_CALL( SCIPreleaseCons(scip, &lincons) );
622  }
623  else
624  {
625  SCIPwarningMessage(scip, "Could not read (multi-)aggregated variable <%s>: dependent variables unkown - consider changing the order (line: %d):\n%s\n",
626  SCIPvarGetName(var), cipinput->linenumber, buf);
627  }
628 
629  SCIPfreeBufferArray(scip, &vals);
630  SCIPfreeBufferArray(scip, &vars);
631  }
632  else
633  {
634  SCIPerrorMessage("unknown section when parsing variables (line: %d):\n%s\n", cipinput->linenumber, buf);
635  cipinput->haserror = TRUE;
636  return SCIP_OKAY;
637  }
638  SCIP_CALL( SCIPreleaseVar(scip, &var) );
639 
640  return SCIP_OKAY;
641 }
642 
643 /** read constraint */
644 static
646  SCIP* scip, /**< SCIP data structure */
647  CIPINPUT* cipinput, /**< CIP parsing data */
648  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
649  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
650  SCIP_Bool dynamic, /**< Is constraint subject to aging?
651  * Usually set to FALSE. Set to TRUE for own cuts which
652  * are separated as constraints. */
653  SCIP_Bool removable /**< should the relaxation be removed from the LP due to aging or cleanup?
654  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
655  )
656 {
657  SCIP_CONS* cons;
658  char* buf;
659  char* copybuf;
660  SCIP_RETCODE retcode;
661  SCIP_Bool separate;
662  SCIP_Bool enforce;
663  SCIP_Bool check;
664  SCIP_Bool propagate;
665  SCIP_Bool local;
666  SCIP_Bool modifiable;
667  SCIP_Bool success;
668  int len;
669 
670  buf = cipinput->strbuf;
671 
672  if( strncmp(buf, "END", 3) == 0 )
673  {
674  cipinput->section = CIP_END;
675  return SCIP_OKAY;
676  }
677 
678  SCIPdebugMsg(scip, "parse constraints in line %d\n", cipinput->linenumber);
679 
680  separate = TRUE;
681  enforce = TRUE;
682  check = TRUE;
683  propagate = TRUE;
684  local = FALSE;
685  modifiable = FALSE;
686 
687  /* get length of line and check for correct ending of constraint line */
688  len = (int)strlen(buf);
689  if( len < 1 )
690  {
691  SCIPerrorMessage("syntax error: expected constraint in line %d.\n", cipinput->linenumber);
692  cipinput->haserror = TRUE;
693  return SCIP_OKAY;
694  }
695  if ( buf[len - 1] != ';' )
696  {
697  SCIPerrorMessage("syntax error: line has to end with ';' (line: %d)\n", cipinput->linenumber);
698  cipinput->haserror = TRUE;
699  return SCIP_OKAY;
700  }
701 
702  /* copy buffer for working purpose */
703  SCIP_CALL( SCIPduplicateBufferArray(scip, &copybuf, buf, len) );
704  copybuf[len - 1] = '\0';
705 
706  /* parse the constraint */
707  retcode = SCIPparseCons(scip, &cons, copybuf,
708  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, FALSE, &success);
709 
710  /* free temporary buffer */
711  SCIPfreeBufferArray(scip, &copybuf);
712 
713  SCIP_CALL( retcode );
714 
715  if( !success )
716  {
717  SCIPerrorMessage("syntax error when reading constraint (line: %d):\n%s\n", cipinput->linenumber, cipinput->strbuf);
718  cipinput->haserror = TRUE;
719  return SCIP_OKAY;
720  }
721 
722  SCIP_CALL( SCIPaddCons(scip, cons) );
723  SCIPdebugPrintCons(scip, cons, NULL);
724  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
725 
726  return SCIP_OKAY;
727 }
728 
729 /*
730  * Callback methods of reader
731  */
732 
733 /** copy method for reader plugins (called when SCIP copies plugins) */
734 static
735 SCIP_DECL_READERCOPY(readerCopyCip)
736 { /*lint --e{715}*/
737  assert(scip != NULL);
738  assert(reader != NULL);
739  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
740 
741  /* call inclusion method of reader */
743 
744  return SCIP_OKAY;
745 }
746 
747 /** destructor of reader to free user data (called when SCIP is exiting) */
748 static
749 SCIP_DECL_READERFREE(readerFreeCip)
750 {
751  SCIP_READERDATA* readerdata;
752 
753  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
754  readerdata = SCIPreaderGetData(reader);
755  assert(readerdata != NULL);
756  SCIPfreeBlockMemory(scip, &readerdata);
757 
758  return SCIP_OKAY;
759 }
760 
761 
762 /** problem reading method of reader */
763 static
764 SCIP_DECL_READERREAD(readerReadCip)
765 { /*lint --e{715}*/
766  CIPINPUT cipinput;
767  SCIP_Real objscale;
768  SCIP_Real objoffset;
769  SCIP_Bool initialconss;
770  SCIP_Bool dynamicconss;
771  SCIP_Bool dynamiccols;
772  SCIP_Bool dynamicrows;
773  SCIP_Bool initialvar;
774  SCIP_Bool removablevar;
775  SCIP_RETCODE retcode;
776 
777  if( NULL == (cipinput.file = SCIPfopen(filename, "r")) )
778  {
779  SCIPerrorMessage("cannot open file <%s> for reading\n", filename);
780  SCIPprintSysError(filename);
781  return SCIP_NOFILE;
782  }
783 
784  cipinput.len = 131071;
785  SCIP_CALL( SCIPallocBufferArray(scip, &(cipinput.strbuf), cipinput.len) );
786 
787  cipinput.linenumber = 0;
788  cipinput.section = CIP_START;
789  cipinput.haserror = FALSE;
790  cipinput.endfile = FALSE;
791  cipinput.readingsize = 65535;
792 
793  SCIP_CALL( SCIPcreateProb(scip, filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
794 
795  SCIP_CALL( SCIPgetBoolParam(scip, "reading/initialconss", &initialconss) );
796  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamiccols", &dynamiccols) );
797  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicconss", &dynamicconss) );
798  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicrows", &dynamicrows) );
799 
800  initialvar = !dynamiccols;
801  removablevar = dynamiccols;
802 
803  objscale = 1.0;
804  objoffset = 0.0;
805 
806  while( cipinput.section != CIP_END && !cipinput.haserror )
807  {
808  /* get next input string */
809  SCIP_CALL( getInputString(scip, &cipinput) );
810 
811  if( cipinput.endfile )
812  break;
813 
814  switch( cipinput.section )
815  {
816  case CIP_START:
817  getStart(scip, &cipinput);
818  break;
819  case CIP_STATISTIC:
820  SCIP_CALL( getStatistics(scip, &cipinput) );
821  break;
822  case CIP_OBJECTIVE:
823  SCIP_CALL( getObjective(scip, &cipinput, &objscale, &objoffset) );
824  break;
825  case CIP_VARS:
826  retcode = getVariable(scip, &cipinput, initialvar, removablevar, objscale);
827 
828  if( retcode == SCIP_READERROR )
829  {
830  cipinput.haserror = TRUE;
831  goto TERMINATE;
832  }
833  SCIP_CALL(retcode);
834 
835  break;
836  case CIP_FIXEDVARS:
837  retcode = getFixedVariable(scip, &cipinput);
838 
839  if( retcode == SCIP_READERROR )
840  {
841  cipinput.haserror = TRUE;
842  goto TERMINATE;
843  }
844  SCIP_CALL(retcode);
845 
846  break;
847  case CIP_CONSTRAINTS:
848  retcode = getConstraint(scip, &cipinput, initialconss, dynamicconss, dynamicrows);
849 
850  if( retcode == SCIP_READERROR )
851  {
852  cipinput.haserror = TRUE;
853  goto TERMINATE;
854  }
855  SCIP_CALL(retcode);
856 
857  break;
858  default:
859  SCIPerrorMessage("invalid CIP state\n");
860  SCIPABORT();
861  return SCIP_INVALIDDATA; /*lint !e527*/
862  } /*lint !e788*/
863  }
864 
865  if( !SCIPisZero(scip, objoffset) && !cipinput.haserror )
866  {
867  SCIP_VAR* objoffsetvar;
868 
869  objoffset *= objscale;
870  SCIP_CALL( SCIPcreateVar(scip, &objoffsetvar, "objoffset", objoffset, objoffset, 1.0, SCIP_VARTYPE_CONTINUOUS,
871  TRUE, TRUE, NULL, NULL, NULL, NULL, NULL) );
872  SCIP_CALL( SCIPaddVar(scip, objoffsetvar) );
873  SCIP_CALL( SCIPreleaseVar(scip, &objoffsetvar) );
874  SCIPdebugMsg(scip, "added variables <objoffset> for objective offset of <%g>\n", objoffset);
875  }
876 
877  if( cipinput.section != CIP_END && !cipinput.haserror )
878  {
879  SCIPerrorMessage("unexpected EOF\n");
880  }
881 
882  TERMINATE:
883  /* close file stream */
884  SCIPfclose(cipinput.file);
885 
886  SCIPfreeBufferArray(scip, &cipinput.strbuf);
887 
888  if( cipinput.haserror )
889  return SCIP_READERROR;
890 
891  /* successfully parsed cip format */
892  *result = SCIP_SUCCESS;
893  return SCIP_OKAY;
894 }
895 
896 /** hash key retrieval function for variables */
897 static
898 SCIP_DECL_HASHGETKEY(hashGetKeyVar)
899 { /*lint --e{715}*/
900  return elem;
901 }
902 
903 /** returns TRUE iff the indices of both variables are equal */
904 static
905 SCIP_DECL_HASHKEYEQ(hashKeyEqVar)
906 { /*lint --e{715}*/
907  if( key1 == key2 )
908  return TRUE;
909  return FALSE;
910 }
911 
912 /** returns the hash value of the key */
913 static
914 SCIP_DECL_HASHKEYVAL(hashKeyValVar)
915 { /*lint --e{715}*/
916  assert( SCIPvarGetIndex((SCIP_VAR*) key) >= 0 );
917  return (unsigned int) SCIPvarGetIndex((SCIP_VAR*) key);
918 }
919 
920 /** problem writing method of reader */
921 static
922 SCIP_DECL_READERWRITE(readerWriteCip)
923 { /*lint --e{715}*/
924  SCIP_HASHTABLE* varhash = NULL;
925  SCIP_READERDATA* readerdata;
926  int i;
927 
928  assert(reader != NULL);
929  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
930 
931  SCIPinfoMessage(scip, file, "STATISTICS\n");
932  SCIPinfoMessage(scip, file, " Problem name : %s\n", name);
933  SCIPinfoMessage(scip, file, " Variables : %d (%d binary, %d integer, %d implicit integer, %d continuous)\n",
934  nvars, nbinvars, nintvars, nimplvars, ncontvars);
935  SCIPinfoMessage(scip, file, " Constraints : %d initial, %d maximal\n", startnconss, maxnconss);
936 
937  SCIPinfoMessage(scip, file, "OBJECTIVE\n");
938  SCIPinfoMessage(scip, file, " Sense : %s\n", objsense == SCIP_OBJSENSE_MINIMIZE ? "minimize" : "maximize");
939  if( !SCIPisZero(scip, objoffset) )
940  SCIPinfoMessage(scip, file, " Offset : %+.15g\n", objoffset);
941  if( !SCIPisEQ(scip, objscale, 1.0) )
942  SCIPinfoMessage(scip, file, " Scale : %.15g\n", objscale);
943 
944  if ( nfixedvars > 0 )
945  {
946  /* set up hash table for variables that have been written property (used for writing out fixed vars in the right order) */
947  SCIP_CALL( SCIPhashtableCreate(&varhash, SCIPblkmem(scip), nvars + nfixedvars, hashGetKeyVar, hashKeyEqVar, hashKeyValVar, NULL) );
948  }
949 
950  if ( nvars + nfixedvars > 0 )
951  {
952  SCIPinfoMessage(scip, file, "VARIABLES\n");
953  }
954 
955  if( nvars > 0 )
956  {
957  for( i = 0; i < nvars; ++i )
958  {
959  SCIP_VAR* var;
960 
961  var = vars[i];
962  assert( var != NULL );
963  SCIP_CALL( SCIPprintVar(scip, var, file) );
964  if ( varhash != NULL )
965  {
966  /* add free variable to hashtable */
967  if ( ! SCIPhashtableExists(varhash, (void*) var) )
968  {
969  SCIP_CALL( SCIPhashtableInsert(varhash, (void*) var) );
970  }
971  }
972  }
973  }
974 
975  readerdata = SCIPreaderGetData(reader);
976  assert(readerdata != NULL);
977 
978  if( readerdata->writefixedvars && nfixedvars > 0 )
979  {
980  int nwritten = 0;
981 
982  SCIPinfoMessage(scip, file, "FIXED\n");
983 
984  /* loop through variables until each has been written after the variables that it depends on have been written; this
985  * requires several runs over the variables, but the depth (= number of loops) is usually small. */
986  while ( nwritten < nfixedvars )
987  {
988  SCIPdebugMsg(scip, "written %d of %d fixed variables.\n", nwritten, nfixedvars);
989  for (i = 0; i < nfixedvars; ++i)
990  {
991  SCIP_VAR* var;
992  SCIP_VAR* tmpvar;
993 
994  var = fixedvars[i];
995  assert( var != NULL );
996 
997  /* skip variables already written */
998  if ( SCIPhashtableExists(varhash, (void*) var) )
999  continue;
1000 
1001  switch ( SCIPvarGetStatus(var) )
1002  {
1003  case SCIP_VARSTATUS_FIXED:
1004 
1005  /* fixed variables can simply be output and added to the hashtable */
1006  SCIP_CALL( SCIPprintVar(scip, var, file) );
1007  assert( ! SCIPhashtableExists(varhash, (void*) var) );
1008  SCIP_CALL( SCIPhashtableInsert(varhash, (void*) var) );
1009  ++nwritten;
1010 
1011  break;
1012 
1014 
1015  tmpvar = SCIPvarGetNegationVar(var);
1016  assert( tmpvar != NULL );
1017  assert( var == SCIPvarGetNegatedVar(tmpvar) );
1018 
1019  /* if the negated variable has been written, we can write the current variable */
1020  if ( SCIPhashtableExists(varhash, (void*) tmpvar) )
1021  {
1022  SCIP_CALL( SCIPprintVar(scip, var, file) );
1023  assert( ! SCIPhashtableExists(varhash, (void*) var) );
1024  SCIP_CALL( SCIPhashtableInsert(varhash, (void*) var) );
1025  ++nwritten;
1026  }
1027  break;
1028 
1030 
1031  tmpvar = SCIPvarGetAggrVar(var);
1032  assert( tmpvar != NULL );
1033 
1034  /* if the aggregating variable has been written, we can write the current variable */
1035  if ( SCIPhashtableExists(varhash, (void*) tmpvar) )
1036  {
1037  SCIP_CALL( SCIPprintVar(scip, var, file) );
1038  assert( ! SCIPhashtableExists(varhash, (void*) var) );
1039  SCIP_CALL( SCIPhashtableInsert(varhash, (void*) var) );
1040  ++nwritten;
1041  }
1042  break;
1043 
1045  {
1046  SCIP_VAR** aggrvars;
1047  int naggrvars;
1048  int j;
1049 
1050  /* get the active representation */
1052 
1053  naggrvars = SCIPvarGetMultaggrNVars(var);
1054  aggrvars = SCIPvarGetMultaggrVars(var);
1055  assert(aggrvars != NULL || naggrvars == 0);
1056 
1057  for (j = 0; j < naggrvars; ++j)
1058  {
1059  if( !SCIPhashtableExists(varhash, (void*) aggrvars[j]) ) /*lint !e613*/
1060  break;
1061  }
1062 
1063  /* if all multi-aggregating variables have been written, we can write the current variable */
1064  if ( j >= naggrvars )
1065  {
1066  SCIP_CALL( SCIPprintVar(scip, var, file) );
1067  assert( ! SCIPhashtableExists(varhash, (void*) var) );
1068  SCIP_CALL( SCIPhashtableInsert(varhash, (void*) var) );
1069  ++nwritten;
1070  }
1071  break;
1072  }
1073 
1075  case SCIP_VARSTATUS_LOOSE:
1076  case SCIP_VARSTATUS_COLUMN:
1077  SCIPerrorMessage("Only fixed variables are allowed to be present in fixedvars list.\n");
1078  SCIPABORT();
1079  return SCIP_ERROR; /*lint !e527*/
1080  }
1081  }
1082  }
1083  }
1084 
1085  if( nconss > 0 )
1086  {
1087  SCIPinfoMessage(scip, file, "CONSTRAINTS\n");
1088 
1089  for( i = 0; i < nconss; ++i )
1090  {
1091  SCIP_CALL( SCIPprintCons(scip, conss[i], file) );
1092  SCIPinfoMessage(scip, file, ";\n");
1093  }
1094  }
1095  SCIPinfoMessage(scip, file, "END\n");
1096 
1097  *result = SCIP_SUCCESS;
1098 
1099  if( nfixedvars > 0 )
1100  SCIPhashtableFree(&varhash);
1101  else
1102  assert(varhash == NULL);
1103 
1104  return SCIP_OKAY;
1105 }
1106 
1107 
1108 /*
1109  * reader specific interface methods
1110  */
1111 
1112 /** includes the cip file reader in SCIP */
1114  SCIP* scip /**< SCIP data structure */
1115  )
1116 {
1117  SCIP_READERDATA* readerdata;
1118  SCIP_READER* reader;
1119 
1120  /* create cip reader data */
1121  SCIP_CALL( SCIPallocBlockMemory(scip, &readerdata) );
1122 
1123  /* include reader */
1124  SCIP_CALL( SCIPincludeReaderBasic(scip, &reader, READER_NAME, READER_DESC, READER_EXTENSION, readerdata) );
1125 
1126  /* set non fundamental callbacks via setter functions */
1127  SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyCip) );
1128  SCIP_CALL( SCIPsetReaderFree(scip, reader, readerFreeCip) );
1129  SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadCip) );
1130  SCIP_CALL( SCIPsetReaderWrite(scip, reader, readerWriteCip) );
1131 
1132  /* add cip reader parameters */
1134  "reading/cipreader/writefixedvars", "should fixed and aggregated variables be printed (if not, re-parsing might fail)",
1135  &readerdata->writefixedvars, FALSE, DEFAULT_CIP_WRITEFIXEDVARS, NULL, NULL) );
1136 
1137  return SCIP_OKAY;
1138 }
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
CipSection
Definition: reader_cip.c:64
SCIP_EXPORT const char * SCIPreaderGetName(SCIP_READER *reader)
Definition: reader.c:547
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
#define NULL
Definition: def.h:253
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
Definition: misc.c:2364
SCIP_RETCODE SCIPparseCons(SCIP *scip, SCIP_CONS **cons, const char *str, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, SCIP_Bool *success)
Definition: scip_cons.c:1017
public methods for SCIP parameter handling
static SCIP_DECL_HASHGETKEY(hashGetKeyVar)
Definition: reader_cip.c:898
public methods for memory management
SCIP_EXPORT SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
Definition: reader.c:482
SCIP_RETCODE SCIPprintVar(SCIP *scip, SCIP_VAR *var, FILE *file)
Definition: scip_var.c:9712
SCIP_Bool SCIPhashtableExists(SCIP_HASHTABLE *hashtable, void *element)
Definition: misc.c:2476
#define SCIP_MAXSTRLEN
Definition: def.h:274
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
Definition: scip_prob.c:1241
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:122
struct CipInput CIPINPUT
Definition: reader_cip.c:93
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip_param.c:240
SCIP_EXPORT SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:16918
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: scip_reader.c:185
#define FALSE
Definition: def.h:73
CIP file reader.
SCIP_EXPORT SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17200
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: scip_reader.c:137
#define READER_NAME
Definition: reader_cip.c:49
static SCIP_RETCODE getInputString(SCIP *scip, CIPINPUT *cipinput)
Definition: reader_cip.c:102
#define TRUE
Definition: def.h:72
#define SCIPdebug(x)
Definition: pub_message.h:74
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPparseVarName(SCIP *scip, const char *str, SCIP_VAR **var, char **endptr)
Definition: scip_var.c:523
#define READER_DESC
Definition: reader_cip.c:50
public methods for problem variables
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:47
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:95
static SCIP_RETCODE getObjective(SCIP *scip, CIPINPUT *cipinput, SCIP_Real *objscale, SCIP_Real *objoffset)
Definition: reader_cip.c:265
SCIP_EXPORT SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16857
#define SCIPduplicateBufferArray(scip, ptr, source, num)
Definition: scip_mem.h:119
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:123
#define READER_EXTENSION
Definition: reader_cip.c:51
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip_mem.h:78
#define SCIPdebugPrintCons(x, y, z)
Definition: pub_message.h:83
public methods for SCIP variables
static SCIP_DECL_READERCOPY(readerCopyCip)
Definition: reader_cip.c:735
#define SCIPdebugMsg
Definition: scip_message.h:69
public methods for numerical tolerances
SCIP_RETCODE SCIPhashtableCreate(SCIP_HASHTABLE **hashtable, BMS_BLKMEM *blkmem, int tablesize, SCIP_DECL_HASHGETKEY((*hashgetkey)), SCIP_DECL_HASHKEYEQ((*hashkeyeq)), SCIP_DECL_HASHKEYVAL((*hashkeyval)), void *userptr)
Definition: misc.c:2113
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
Definition: scip_reader.c:209
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
Definition: fileio.c:140
static SCIP_DECL_READERREAD(readerReadCip)
Definition: reader_cip.c:764
static SCIP_RETCODE getFixedVariable(SCIP *scip, CIPINPUT *cipinput)
Definition: reader_cip.c:452
SCIP_EXPORT const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16738
static SCIP_RETCODE getVariable(SCIP *scip, CIPINPUT *cipinput, SCIP_Bool initial, SCIP_Bool removable, SCIP_Real objscale)
Definition: reader_cip.c:399
static SCIP_DECL_READERWRITE(readerWriteCip)
Definition: reader_cip.c:922
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_Bool SCIPstrToRealValue(const char *str, SCIP_Real *value, char **endptr)
Definition: misc.c:10364
SCIP_EXPORT SCIP_VAR * SCIPvarGetNegatedVar(SCIP_VAR *var)
Definition: var.c:17168
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:47
struct SCIP_File SCIP_FILE
Definition: pub_fileio.h:34
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
Definition: fileio.c:187
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
static SCIP_DECL_READERFREE(readerFreeCip)
Definition: reader_cip.c:749
static SCIP_RETCODE getStatistics(SCIP *scip, CIPINPUT *cipinput)
Definition: reader_cip.c:213
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
Definition: scip_reader.c:161
#define SCIP_CALL(x)
Definition: def.h:365
Definition: grphload.c:88
static void getStart(SCIP *scip, CIPINPUT *cipinput)
Definition: reader_cip.c:188
public methods for constraint handler plugins and constraints
wrapper functions to map file i/o to standard or zlib file i/o
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:111
struct SCIP_ReaderData SCIP_READERDATA
Definition: type_reader.h:39
int SCIPcalcMemGrowSize(SCIP *scip, int num)
Definition: scip_mem.c:129
public data structures and miscellaneous methods
SCIP_EXPORT SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
Definition: var.c:17178
static SCIP_DECL_HASHKEYVAL(hashKeyValVar)
Definition: reader_cip.c:914
void SCIPhashtableFree(SCIP_HASHTABLE **hashtable)
Definition: misc.c:2163
#define SCIP_Bool
Definition: def.h:70
enum SCIP_Objsense SCIP_OBJSENSE
Definition: type_prob.h:41
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
Definition: scip_cons.c:2472
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
Definition: scip_var.c:104
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip_reader.c:99
SCIP_RETCODE SCIPparseVarsLinearsum(SCIP *scip, const char *str, SCIP_VAR **vars, SCIP_Real *vals, int *nvars, int varssize, int *requiredsize, char **endptr, SCIP_Bool *success)
Definition: scip_var.c:699
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
Definition: scip_prob.c:105
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_prob.c:1667
SCIP_RETCODE SCIPsetProbName(SCIP *scip, const char *name)
Definition: scip_prob.c:1094
#define DEFAULT_CIP_WRITEFIXEDVARS
Definition: reader_cip.c:53
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
Definition: scip_var.c:4451
SCIP_EXPORT int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
Definition: var.c:17120
public methods for message output
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10263
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1251
enum CipSection CIPSECTION
Definition: reader_cip.c:74
static SCIP_DECL_HASHKEYEQ(hashKeyEqVar)
Definition: reader_cip.c:905
#define SCIP_Real
Definition: def.h:164
public methods for input file readers
public methods for message handling
void SCIPprintSysError(const char *message)
Definition: misc.c:10172
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2765
SCIP_RETCODE SCIPincludeReaderCip(SCIP *scip)
Definition: reader_cip.c:1113
#define BMSclearMemoryArray(ptr, num)
Definition: memory.h:120
SCIP_EXPORT SCIP_VAR * SCIPvarGetAggrVar(SCIP_VAR *var)
Definition: var.c:17087
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:198
int SCIPfclose(SCIP_FILE *fp)
Definition: fileio.c:219
SCIP_RETCODE SCIPflattenVarAggregationGraph(SCIP *scip, SCIP_VAR *var)
Definition: scip_var.c:1696
static SCIP_RETCODE getConstraint(SCIP *scip, CIPINPUT *cipinput, SCIP_Bool initial, SCIP_Bool dynamic, SCIP_Bool removable)
Definition: reader_cip.c:645
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1109
public methods for reader plugins
#define SCIPABORT()
Definition: def.h:337
public methods for global and local (sub)problems
SCIP_RETCODE SCIPparseVar(SCIP *scip, SCIP_VAR **var, const char *str, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARCOPY((*varcopy)), SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_VARDATA *vardata, char **endptr, SCIP_Bool *success)
Definition: scip_var.c:464
SCIP_EXPORT SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
Definition: var.c:17132
SCIP_EXPORT int SCIPvarGetIndex(SCIP_VAR *var)
Definition: var.c:17035
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:115
memory allocation routines