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