Scippy

SCIP

Solving Constraint Integer Programs

ReaderMOP.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program PolySCIP */
4 /* */
5 /* Copyright (C) 2012-2022 Konrad-Zuse-Zentrum */
6 /* fuer Informationstechnik Berlin */
7 /* */
8 /* PolySCIP is distributed under the terms of the ZIB Academic License. */
9 /* */
10 /* You should have received a copy of the ZIB Academic License */
11 /* along with PolySCIP; see the file LICENCE. */
12 /* */
13 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14 
15 /**
16  * @file ReaderMOP.cpp
17  * @brief Class implementing .mop file reader
18  * @author Sebastian Schenker
19  * @author Timo Strunk
20  *
21  * Adaption of SCIP MPS reader towards MOP format with multiple objectives.
22  * The input file has to follow some simple conventions
23  * - It has to contain a problem in
24  * <a href="http://en.wikipedia.org/wiki/MPS_%28format%29">MPS</a> format
25  * - The file extension must be <code>.mop</code>
26  * - Every row marked <code>N</code> is treated as an objective
27  */
28 
29 #include "ReaderMOP.h"
30 
31 #include <iostream>
32 #include <assert.h>
33 #include <string.h>
34 #include <ctype.h>
35 
36 #include "objscip/objscip.h"
37 #include "prob_data_objectives.h"
38 #include "scip/cons_knapsack.h"
39 #include "scip/cons_indicator.h"
40 #include "scip/cons_linear.h"
41 #include "scip/cons_logicor.h"
42 #include "scip/cons_setppc.h"
43 #include "scip/cons_varbound.h"
44 #include "scip/cons_sos1.h"
45 #include "scip/cons_sos2.h"
46 #include "scip/cons_nonlinear.h"
48 #include "scip/pub_misc.h"
49 
50 #define MPS_MAX_LINELEN 1024 ///< global define
51 #define MPS_MAX_NAMELEN 256 ///< global define
52 #define MPS_MAX_VALUELEN 26 ///< global define
53 #define MPS_MAX_FIELDLEN 20 ///< global define
54 
55 #define PATCH_CHAR '_' ///< global define
56 #define BLANK ' ' ///< global define
57 
58 /** enum containing all mps sections */
60 {
77 };
78 typedef enum MpsSection MPSSECTION; ///< typedef
79 
80 /** mps input structure */
81 struct MpsInput
82 {
83  MPSSECTION section; ///< MpsSection enum
84  SCIP_FILE* fp; ///< SCIP file pointer
85  int lineno; ///< line number
86  SCIP_OBJSENSE objsense; ///< Objective sense
87  SCIP_Bool haserror; ///< Indicates error
88  char buf[MPS_MAX_LINELEN]; ///< character
89  const char* f0; ///< @todo
90  const char* f1; ///< @todo
91  const char* f2; ///< @todo
92  const char* f3; ///< @todo
93  const char* f4; ///< @todo
94  const char* f5; ///< @todo
95  char probname[MPS_MAX_NAMELEN]; ///< problem name
96  char objname [MPS_MAX_NAMELEN]; ///< objective identifier
97  SCIP_Bool isinteger; ///< Indicates integer
98  SCIP_Bool isnewformat; ///< Indicates new MPS format
99 };
100 typedef struct MpsInput MPSINPUT; ///< typedef
101 
102 /** sparse matrix representation */
103 struct SparseMatrix
104 {
105  SCIP_Real* values; /**< matrix element */
106  SCIP_VAR** columns; /**< corresponding variables */
107  const char** rows; /**< corresponding constraint names */
108  int nentries; /**< number of elements in the arrays */
109  int sentries; /**< number of slots in the arrays */
110 };
111 typedef struct SparseMatrix SPARSEMATRIX; ///< typedef
112 
113 /** creates the mps input structure */
114 static
116  SCIP* scip, /**< SCIP data structure */
117  MPSINPUT** mpsi, /**< mps input structure */
118  SCIP_FILE* fp /**< file object for the input file */
119  )
120 {
121  assert(mpsi != NULL);
122  assert(fp != NULL);
123 
124  SCIP_CALL( SCIPallocBlockMemory(scip, mpsi) );
125 
126  (*mpsi)->section = MPS_NAME;
127  (*mpsi)->fp = fp;
128  (*mpsi)->lineno = 0;
129  (*mpsi)->objsense = SCIP_OBJSENSE_MINIMIZE;
130  (*mpsi)->haserror = FALSE;
131  (*mpsi)->isinteger = FALSE;
132  (*mpsi)->isnewformat = FALSE;
133  (*mpsi)->buf [0] = '\0';
134  (*mpsi)->probname[0] = '\0';
135  (*mpsi)->objname [0] = '\0';
136  (*mpsi)->f0 = NULL;
137  (*mpsi)->f1 = NULL;
138  (*mpsi)->f2 = NULL;
139  (*mpsi)->f3 = NULL;
140  (*mpsi)->f4 = NULL;
141  (*mpsi)->f5 = NULL;
142 
143  return SCIP_OKAY;
144 }
145 
146 /** free the mps input structure */
147 static
149  SCIP* scip, /**< SCIP data structure */
150  MPSINPUT** mpsi /**< mps input structure */
151  )
152 {
153  SCIPfreeBlockMemory(scip, mpsi);
154 }
155 
156 /** returns the current section */
157 static
159  const MPSINPUT* mpsi /**< mps input structure */
160  )
161 {
162  assert(mpsi != NULL);
163 
164  return mpsi->section;
165 }
166 
167 /** return the current value of field 0 */
168 static
169 const char* mpsinputField0(
170  const MPSINPUT* mpsi /**< mps input structure */
171  )
172 {
173  assert(mpsi != NULL);
174 
175  return mpsi->f0;
176 }
177 
178 /** return the current value of field 1 */
179 static
180 const char* mpsinputField1(
181  const MPSINPUT* mpsi /**< mps input structure */
182  )
183 {
184  assert(mpsi != NULL);
185 
186  return mpsi->f1;
187 }
188 
189 /** return the current value of field 2 */
190 static
191 const char* mpsinputField2(
192  const MPSINPUT* mpsi /**< mps input structure */
193  )
194 {
195  assert(mpsi != NULL);
196 
197  return mpsi->f2;
198 }
199 
200 /** return the current value of field 3 */
201 static
202 const char* mpsinputField3(
203  const MPSINPUT* mpsi /**< mps input structure */
204  )
205 {
206  assert(mpsi != NULL);
207 
208  return mpsi->f3;
209 }
210 
211 /** return the current value of field 4 */
212 static
213 const char* mpsinputField4(
214  const MPSINPUT* mpsi /**< mps input structure */
215  )
216 {
217  assert(mpsi != NULL);
218 
219  return mpsi->f4;
220 }
221 
222 /** return the current value of field 5 */
223 static
224 const char* mpsinputField5(
225  const MPSINPUT* mpsi /**< mps input structure */
226  )
227 {
228  assert(mpsi != NULL);
229 
230  return mpsi->f5;
231 }
232 
233 /** returns the objective sense */
234 static
236  const MPSINPUT* mpsi /**< mps input structure */
237  )
238 {
239  assert(mpsi != NULL);
240 
241  return mpsi->objsense;
242 }
243 
244 /** returns if an error was detected */
245 static
247  const MPSINPUT* mpsi /**< mps input structure */
248  )
249 {
250  assert(mpsi != NULL);
251 
252  return mpsi->haserror;
253 }
254 
255 /** returns the value of the Bool "is integer" in the mps input */
256 static
258  const MPSINPUT* mpsi /**< mps input structure */
259  )
260 {
261  assert(mpsi != NULL);
262 
263  return mpsi->isinteger;
264 }
265 
266 /** set the section in the mps input structure to given section */
267 static
269  MPSINPUT* mpsi, /**< mps input structure */
270  MPSSECTION section /**< section that is set */
271  )
272 {
273  assert(mpsi != NULL);
274 
275  mpsi->section = section;
276 }
277 
278 /** set the problem name in the mps input structure to given problem name */
279 static
281  MPSINPUT* mpsi, /**< mps input structure */
282  const char* probname /**< name of the problem to set */
283  )
284 {
285  assert(mpsi != NULL);
286  assert(probname != NULL);
287  assert(strlen(probname) < sizeof(mpsi->probname));
288 
289  (void)SCIPmemccpy(mpsi->probname, probname, '\0', MPS_MAX_NAMELEN - 1);
290 }
291 
292 /** set the objective name in the mps input structure to given objective name */
293 static
295  MPSINPUT* mpsi, /**< mps input structure */
296  const char* objname /**< name of the objective function to set */
297  )
298 {
299  assert(mpsi != NULL);
300  assert(objname != NULL);
301  assert(strlen(objname) < sizeof(mpsi->objname));
302 
303  (void)SCIPmemccpy(mpsi->objname, objname, '\0', MPS_MAX_NAMELEN - 1);
304 }
305 
306 /** set the objective sense in the mps input structure to given objective sense */
307 static
309  MPSINPUT* mpsi, /**< mps input structure */
310  SCIP_OBJSENSE sense /**< sense of the objective function */
311  )
312 {
313  assert(mpsi != NULL);
314 
315  mpsi->objsense = sense;
316 }
317 
318 static
320  MPSINPUT* mpsi /**< mps input structure */
321  )
322 {
323  assert(mpsi != NULL);
324 
325  SCIPerrorMessage("Syntax error in line %d\n", mpsi->lineno);
326  mpsi->section = MPS_ENDATA;
327  mpsi->haserror = TRUE;
328 }
329 
330 /** method post a ignore message */
331 static
333  SCIP* scip, /**< SCIP data structure */
334  MPSINPUT* mpsi, /**< mps input structure */
335  const char* what, /**< what get ignored */
336  const char* what_name, /**< name of that object */
337  const char* entity, /**< entity */
338  const char* entity_name, /**< entity name */
339  SCIP_VERBLEVEL verblevel /**< SCIP verblevel for this message */
340  )
341 {
342  assert(mpsi != NULL);
343  assert(what != NULL);
344  assert(what_name != NULL);
345  assert(entity != NULL);
346  assert(entity_name != NULL);
347 
348  SCIPverbMessage(scip, verblevel, NULL,
349  "Warning line %d: %s \"%s\" for %s \"%s\" ignored\n", mpsi->lineno, what, what_name, entity, entity_name);
350 }
351 
352 /** fill the line from \p pos up to column 80 with blanks. */
353 static
355  char* buf, /**< buffer to clear */
356  unsigned int pos /**< position to start the clearing process */
357  )
358 {
359  unsigned int i;
360 
361  for(i = pos; i < 80; i++)
362  buf[i] = BLANK;
363  buf[80] = '\0';
364 }
365 
366 /** change all blanks inside a field to #PATCH_CHAR. */
367 static
369  char* buf, /**< buffer to patch */
370  int beg, /**< position to begin */
371  int end /**< position to end */
372  )
373 {
374  int i;
375 
376  while( (beg <= end) && (buf[end] == BLANK) )
377  end--;
378 
379  while( (beg <= end) && (buf[beg] == BLANK) )
380  beg++;
381 
382  for( i = beg; i <= end; i++ )
383  if( buf[i] == BLANK )
384  buf[i] = PATCH_CHAR;
385 }
386 
387 /** read a mps format data line and parse the fields. */
388 static
390  MPSINPUT* mpsi /**< mps input structure */
391  )
392 {
393  unsigned int len;
394  unsigned int i;
395  int space;
396  char* s;
397  SCIP_Bool is_marker;
398  SCIP_Bool is_empty;
399  char* nexttok;
400 
401  do
402  {
403  mpsi->f0 = mpsi->f1 = mpsi->f2 = mpsi->f3 = mpsi->f4 = mpsi->f5 = 0;
404  is_marker = FALSE;
405 
406  /* Read until we have not a comment line. */
407  do
408  {
409  mpsi->buf[MPS_MAX_LINELEN-1] = '\0';
410  if( NULL == SCIPfgets(mpsi->buf, sizeof(mpsi->buf), mpsi->fp) )
411  return FALSE;
412  mpsi->lineno++;
413  }
414  while( *mpsi->buf == '*' );
415 
416  /* Normalize line */
417  len = strlen(mpsi->buf);
418 
419  for( i = 0; i < len; i++ )
420  if( (mpsi->buf[i] == '\t') || (mpsi->buf[i] == '\n') || (mpsi->buf[i] == '\r') )
421  mpsi->buf[i] = BLANK;
422 
423  if( len < 80 )
424  clearFrom(mpsi->buf, len);
425 
426  SCIPdebugMessage("line %d: <%s>\n", mpsi->lineno, mpsi->buf);
427 
428  assert(strlen(mpsi->buf) >= 80);
429 
430  /* Look for new section */
431  if( *mpsi->buf != BLANK )
432  {
433  mpsi->f0 = SCIPstrtok(&mpsi->buf[0], " ", &nexttok);
434 
435  assert(mpsi->f0 != 0);
436 
437  mpsi->f1 = SCIPstrtok(NULL, " ", &nexttok);
438 
439  return TRUE;
440  }
441 
442  /* If we decide to use the new format we never revert this decision */
443  if( !mpsi->isnewformat )
444  {
445  /* Test for fixed format comments */
446  if( (mpsi->buf[14] == '$') && (mpsi->buf[13] == ' ') )
447  clearFrom(mpsi->buf, 14);
448  else if( (mpsi->buf[39] == '$') && (mpsi->buf[38] == ' ') )
449  clearFrom(mpsi->buf, 39);
450 
451  /* Test for fixed format */
452  space = mpsi->buf[12] | mpsi->buf[13]
453  | mpsi->buf[22] | mpsi->buf[23]
454  | mpsi->buf[36] | mpsi->buf[37] | mpsi->buf[38]
455  | mpsi->buf[47] | mpsi->buf[48]
456  | mpsi->buf[61] | mpsi->buf[62] | mpsi->buf[63];
457 
458  if( space == BLANK )
459  {
460  /* Now we have space at the right positions.
461  * But are there also the non space where they
462  * should be ?
463  */
465 
466  number = isdigit((unsigned char)mpsi->buf[24]) || isdigit((unsigned char)mpsi->buf[25])
467  || isdigit((unsigned char)mpsi->buf[26]) || isdigit((unsigned char)mpsi->buf[27])
468  || isdigit((unsigned char)mpsi->buf[28]) || isdigit((unsigned char)mpsi->buf[29])
469  || isdigit((unsigned char)mpsi->buf[30]) || isdigit((unsigned char)mpsi->buf[31])
470  || isdigit((unsigned char)mpsi->buf[32]) || isdigit((unsigned char)mpsi->buf[33])
471  || isdigit((unsigned char)mpsi->buf[34]) || isdigit((unsigned char)mpsi->buf[35]);
472 
473  /* len < 14 is handle ROW lines with embedded spaces
474  * in the names correctly
475  */
476  if( number || len < 14 )
477  {
478  /* We assume fixed format, so we patch possible embedded spaces. */
479  patchField(mpsi->buf, 4, 12);
480  patchField(mpsi->buf, 14, 22);
481  patchField(mpsi->buf, 39, 47);
482  }
483  else
484  {
485  if( mpsi->section == MPS_COLUMNS || mpsi->section == MPS_RHS
486  || mpsi->section == MPS_RANGES || mpsi->section == MPS_BOUNDS )
487  mpsi->isnewformat = TRUE;
488  }
489  }
490  else
491  {
492  mpsi->isnewformat = TRUE;
493  }
494  }
495  s = &mpsi->buf[1];
496 
497  /* At this point it is not clear if we have a indicator field.
498  * If there is none (e.g. empty) f1 will be the first name field.
499  * If there is one, f2 will be the first name field.
500  *
501  * Initially comment marks '$' are only allowed in the beginning
502  * of the 2nd and 3rd name field. We test all fields but the first.
503  * This makes no difference, since if the $ is at the start of a value
504  * field, the line will be erroneous anyway.
505  */
506  do
507  {
508  if( NULL == (mpsi->f1 = SCIPstrtok(s, " ", &nexttok)) )
509  break;
510 
511  if( (NULL == (mpsi->f2 = SCIPstrtok(NULL, " ", &nexttok))) || (*mpsi->f2 == '$') )
512  {
513  mpsi->f2 = 0;
514  break;
515  }
516  if( !strcmp(mpsi->f2, "'MARKER'") )
517  is_marker = TRUE;
518 
519  if( (NULL == (mpsi->f3 = SCIPstrtok(NULL, " ", &nexttok))) || (*mpsi->f3 == '$') )
520  {
521  mpsi->f3 = 0;
522  break;
523  }
524  if( is_marker )
525  {
526  if( !strcmp(mpsi->f3, "'INTORG'") )
527  mpsi->isinteger = TRUE;
528  else if( !strcmp(mpsi->f3, "'INTEND'") )
529  mpsi->isinteger = FALSE;
530  else
531  break; /* unknown marker */
532  }
533  if( !strcmp(mpsi->f3, "'MARKER'") )
534  is_marker = TRUE;
535 
536  if( (NULL == (mpsi->f4 = SCIPstrtok(NULL, " ", &nexttok))) || (*mpsi->f4 == '$') )
537  {
538  mpsi->f4 = 0;
539  break;
540  }
541  if( is_marker )
542  {
543  if( !strcmp(mpsi->f4, "'INTORG'") )
544  mpsi->isinteger = TRUE;
545  else if( !strcmp(mpsi->f4, "'INTEND'") )
546  mpsi->isinteger = FALSE;
547  else
548  break; /* unknown marker */
549  }
550  if( (NULL == (mpsi->f5 = SCIPstrtok(NULL, " ", &nexttok))) || (*mpsi->f5 == '$') )
551  mpsi->f5 = 0;
552  }
553  while( FALSE );
554 
555  /* check for empty lines */
556  is_empty = (mpsi->f0 == NULL && mpsi->f1 == NULL);
557  }
558  while( is_marker || is_empty );
559 
560  return TRUE;
561 }
562 
563 /** Insert \p name as field 1 or 2 and shift all other fields up. */
564 static
566  MPSINPUT* mpsi, /**< mps input structure */
567  const char* name, /**< name to insert */
568  SCIP_Bool second /**< insert as second field? */
569  )
570 {
571  assert(mpsi != NULL);
572  assert(name != NULL);
573 
574  mpsi->f5 = mpsi->f4;
575  mpsi->f4 = mpsi->f3;
576  mpsi->f3 = mpsi->f2;
577 
578  if( second )
579  mpsi->f2 = name;
580  else
581  {
582  mpsi->f2 = mpsi->f1;
583  mpsi->f1 = name;
584  }
585 }
586 
587 /** Process NAME section. */
588 static
590  SCIP* scip, /**< SCIP data structure */
591  MPSINPUT* mpsi /**< mps input structure */
592  )
593 {
594  assert(mpsi != NULL);
595 
596  SCIPdebugMessage("read problem name\n");
597 
598  /* This has to be the Line with the NAME section. */
599  if( !mpsinputReadLine(mpsi) || mpsinputField0(mpsi) == NULL || strcmp(mpsinputField0(mpsi), "NAME") )
600  {
601  mpsinputSyntaxerror(mpsi);
602  return SCIP_OKAY;
603  }
604 
605  /* Sometimes the name is omitted. */
606  mpsinputSetProbname(mpsi, (mpsinputField1(mpsi) == 0) ? "_MOP_" : mpsinputField1(mpsi));
607 
608  /* This hat to be a new section */
609  if( !mpsinputReadLine(mpsi) || (mpsinputField0(mpsi) == NULL) )
610  {
611  mpsinputSyntaxerror(mpsi);
612  return SCIP_OKAY;
613  }
614 
615  if( !strncmp(mpsinputField0(mpsi), "ROWS", 4) )
617  else if( !strncmp(mpsinputField0(mpsi), "USERCUTS", 8) )
619  else if( !strncmp(mpsinputField0(mpsi), "LAZYCONS", 8) )
621  else if( !strncmp(mpsinputField0(mpsi), "OBJSEN", 6) )
623  else if( !strncmp(mpsinputField0(mpsi), "OBJNAME", 7) )
625  else
626  {
627  mpsinputSyntaxerror(mpsi);
628  return SCIP_OKAY;
629  }
630 
631  return SCIP_OKAY;
632 }
633 
634 /** Process OBJSEN section. This Section is a CPLEX extension. */
635 static
637  SCIP* scip, /**< SCIP data structure */
638  MPSINPUT* mpsi /**< mps input structure */
639  )
640 {
641  assert(mpsi != NULL);
642 
643  SCIPdebugMessage("read objective sense\n");
644 
645  /* This has to be the Line with MIN or MAX. */
646  if( !mpsinputReadLine(mpsi) || (mpsinputField1(mpsi) == NULL) )
647  {
648  mpsinputSyntaxerror(mpsi);
649  return SCIP_OKAY;
650  }
651 
652  if( !strncmp(mpsinputField1(mpsi), "MIN", 3) )
654  else if( !strncmp(mpsinputField1(mpsi), "MAX", 3) )
656  else
657  {
658  mpsinputSyntaxerror(mpsi);
659  return SCIP_OKAY;
660  }
661 
662  /* Look for ROWS, USERCUTS, LAZYCONS, or OBJNAME Section */
663  if( !mpsinputReadLine(mpsi) || mpsinputField0(mpsi) == NULL )
664  {
665  mpsinputSyntaxerror(mpsi);
666  return SCIP_OKAY;
667  }
668 
669  if( !strcmp(mpsinputField0(mpsi), "ROWS") )
671  else if( !strcmp(mpsinputField0(mpsi), "USERCUTS") )
673  else if( !strcmp(mpsinputField0(mpsi), "LAZYCONS") )
675  else if( !strcmp(mpsinputField0(mpsi), "OBJNAME") )
677  else
678  {
679  mpsinputSyntaxerror(mpsi);
680  return SCIP_OKAY;
681  }
682 
683  return SCIP_OKAY;
684 }
685 
686 /** Process OBJNAME section. This Section is a CPLEX extension. */
687 static
689  SCIP* scip, /**< SCIP data structure */
690  MPSINPUT* mpsi /**< mps input structure */
691  )
692 {
693  assert(mpsi != NULL);
694 
695  SCIPdebugMessage("read objective name\n");
696 
697  /* This has to be the Line with the name. */
698  if( !mpsinputReadLine(mpsi) || mpsinputField1(mpsi) == NULL )
699  {
700  mpsinputSyntaxerror(mpsi);
701  return SCIP_OKAY;
702  }
703 
704  mpsinputSetObjname(mpsi, mpsinputField1(mpsi));
705 
706  /* Look for ROWS, USERCUTS, or LAZYCONS Section */
707  if( !mpsinputReadLine(mpsi) || mpsinputField0(mpsi) == NULL )
708  {
709  mpsinputSyntaxerror(mpsi);
710  return SCIP_OKAY;
711  }
712  if( !strcmp(mpsinputField0(mpsi), "ROWS") )
714  else if( !strcmp(mpsinputField0(mpsi), "USERCUTS") )
716  else if( !strcmp(mpsinputField0(mpsi), "LAZYCONS") )
718  else
719  mpsinputSyntaxerror(mpsi);
720 
721  return SCIP_OKAY;
722 }
723 
724 /** Process RHS section. */
725 static
727  MPSINPUT* mpsi, /**< mps input structure */
728  SCIP* scip /**< SCIP data structure */
729  )
730 {
731  char rhsname[MPS_MAX_NAMELEN] = { '\0' };
732  SCIP_CONS* cons;
733  SCIP_Real lhs;
734  SCIP_Real rhs;
735  SCIP_Real val;
736 
737  SCIPdebugMessage("read right hand sides\n");
738 
739  while( mpsinputReadLine(mpsi) )
740  {
741  if( mpsinputField0(mpsi) != NULL )
742  {
743  if( !strcmp(mpsinputField0(mpsi), "RANGES") )
745  else if( !strcmp(mpsinputField0(mpsi), "BOUNDS") )
747  else if( !strcmp(mpsinputField0(mpsi), "SOS") )
749  else if( !strcmp(mpsinputField0(mpsi), "QMATRIX") )
751  else if( !strcmp(mpsinputField0(mpsi), "QUADOBJ") )
753  else if( !strcmp(mpsinputField0(mpsi), "QCMATRIX") )
755  else if( !strcmp(mpsinputField0(mpsi), "INDICATORS") )
757  else if( !strcmp(mpsinputField0(mpsi), "ENDATA") )
759  else
760  break;
761  return SCIP_OKAY;
762  }
763  if( (mpsinputField2(mpsi) != NULL && mpsinputField3(mpsi) == NULL)
764  || (mpsinputField4(mpsi) != NULL && mpsinputField5(mpsi) == NULL) )
765  mpsinputInsertName(mpsi, "_RHS_", FALSE);
766 
767  if( mpsinputField1(mpsi) == NULL || mpsinputField2(mpsi) == NULL || mpsinputField3(mpsi) == NULL )
768  break;
769 
770  if( *rhsname == '\0' )
771  (void)SCIPmemccpy(rhsname, mpsinputField1(mpsi), '\0', MPS_MAX_NAMELEN - 1);
772 
773  if( !strcmp(rhsname, mpsinputField1(mpsi)) )
774  {
775  cons = SCIPfindCons(scip, mpsinputField2(mpsi));
776  if( cons == NULL )
777  mpsinputEntryIgnored(scip, mpsi, "RHS", mpsinputField1(mpsi), "row", mpsinputField2(mpsi), SCIP_VERBLEVEL_NORMAL);
778  else
779  {
780  val = atof(mpsinputField3(mpsi));
781 
782  /* find out the row sense */
783  lhs = SCIPgetLhsLinear(scip, cons);
784  rhs = SCIPgetRhsLinear(scip, cons);
785  if( SCIPisInfinity(scip, -lhs) )
786  {
787  /* lhs = -infinity -> lower or equal */
788  assert(SCIPisZero(scip, rhs));
789  SCIP_CALL( SCIPchgRhsLinear(scip, cons, val) );
790  }
791  else if( SCIPisInfinity(scip, rhs) )
792  {
793  /* rhs = +infinity -> greater or equal */
794  assert(SCIPisZero(scip, lhs));
795  SCIP_CALL( SCIPchgLhsLinear(scip, cons, val) );
796  }
797  else
798  {
799  /* lhs > -infinity, rhs < infinity -> equality */
800  assert(SCIPisZero(scip, lhs));
801  assert(SCIPisZero(scip, rhs));
802  SCIP_CALL( SCIPchgLhsLinear(scip, cons, val) );
803  SCIP_CALL( SCIPchgRhsLinear(scip, cons, val) );
804  }
805  SCIPdebugMessage("RHS <%s> lhs: %g rhs: %g val: <%22.12g>\n", mpsinputField2(mpsi), lhs, rhs, val);
806  }
807  if( mpsinputField5(mpsi) != NULL )
808  {
809  cons = SCIPfindCons(scip, mpsinputField4(mpsi));
810  if( cons == NULL )
811  mpsinputEntryIgnored(scip, mpsi, "RHS", mpsinputField1(mpsi), "row", mpsinputField4(mpsi), SCIP_VERBLEVEL_NORMAL);
812  else
813  {
814  val = atof(mpsinputField5(mpsi));
815 
816  /* find out the row sense */
817  lhs = SCIPgetLhsLinear(scip, cons);
818  rhs = SCIPgetRhsLinear(scip, cons);
819  if( SCIPisInfinity(scip, -lhs) )
820  {
821  /* lhs = -infinity -> lower or equal */
822  assert(SCIPisZero(scip, rhs));
823  SCIP_CALL( SCIPchgRhsLinear(scip, cons, val) );
824  }
825  else if( SCIPisInfinity(scip, rhs) )
826  {
827  /* rhs = +infinity -> greater or equal */
828  assert(SCIPisZero(scip, lhs));
829  SCIP_CALL( SCIPchgLhsLinear(scip, cons, val) );
830  }
831  else
832  {
833  /* lhs > -infinity, rhs < infinity -> equality */
834  assert(SCIPisZero(scip, lhs));
835  assert(SCIPisZero(scip, rhs));
836  SCIP_CALL( SCIPchgLhsLinear(scip, cons, val) );
837  SCIP_CALL( SCIPchgRhsLinear(scip, cons, val) );
838  }
839  SCIPdebugMessage("RHS <%s> lhs: %g rhs: %g val: <%22.12g>\n", mpsinputField4(mpsi), lhs, rhs, val);
840  }
841  }
842  }
843  }
844  mpsinputSyntaxerror(mpsi);
845 
846  return SCIP_OKAY;
847 }
848 
849 /** Process RANGES section */
850 static
852  MPSINPUT* mpsi, /**< mps input structure */
853  SCIP* scip /**< SCIP data structure */
854  )
855 {
856  char rngname[MPS_MAX_NAMELEN] = { '\0' };
857  SCIP_CONS* cons;
858  SCIP_Real lhs;
859  SCIP_Real rhs;
860  SCIP_Real val;
861 
862  SCIPdebugMessage("read ranges\n");
863 
864  while( mpsinputReadLine(mpsi) )
865  {
866  if( mpsinputField0(mpsi) != NULL )
867  {
868  if( !strcmp(mpsinputField0(mpsi), "BOUNDS") )
870  else if( !strcmp(mpsinputField0(mpsi), "SOS") )
872  else if( !strcmp(mpsinputField0(mpsi), "QMATRIX") )
874  else if( !strcmp(mpsinputField0(mpsi), "QUADOBJ") )
876  else if( !strcmp(mpsinputField0(mpsi), "QCMATRIX") )
878  else if( !strcmp(mpsinputField0(mpsi), "INDICATORS") )
880  else if( !strcmp(mpsinputField0(mpsi), "ENDATA") )
882  else
883  break;
884  return SCIP_OKAY;
885  }
886  if( (mpsinputField2(mpsi) != NULL && mpsinputField3(mpsi) == NULL)
887  || (mpsinputField4(mpsi) != NULL && mpsinputField5(mpsi) == NULL) )
888  mpsinputInsertName(mpsi, "_RNG_", FALSE);
889 
890  if( mpsinputField1(mpsi) == NULL || mpsinputField2(mpsi) == NULL || mpsinputField3(mpsi) == NULL )
891  break;
892 
893  if( *rngname == '\0' )
894  (void)SCIPmemccpy(rngname, mpsinputField1(mpsi), '\0', MPS_MAX_NAMELEN - 1);
895 
896  /* The rules are:
897  * Row Sign LHS RHS
898  * ----------------------------------------
899  * G +/- rhs rhs + |range|
900  * L +/- rhs - |range| rhs
901  * E + rhs rhs + range
902  * E - rhs + range rhs
903  * ----------------------------------------
904  */
905  if( !strcmp(rngname, mpsinputField1(mpsi)) )
906  {
907  cons = SCIPfindCons(scip, mpsinputField2(mpsi));
908  if( cons == NULL )
909  mpsinputEntryIgnored(scip, mpsi, "Range", mpsinputField1(mpsi), "row", mpsinputField2(mpsi), SCIP_VERBLEVEL_NORMAL);
910  else
911  {
912  val = atof(mpsinputField3(mpsi));
913 
914  /* find out the row sense */
915  lhs = SCIPgetLhsLinear(scip, cons);
916  rhs = SCIPgetRhsLinear(scip, cons);
917  if( SCIPisInfinity(scip, -lhs) )
918  {
919  /* lhs = -infinity -> lower or equal */
920  SCIP_CALL( SCIPchgLhsLinear(scip, cons, rhs - REALABS(val)) );
921  }
922  else if( SCIPisInfinity(scip, rhs) )
923  {
924  /* rhs = +infinity -> greater or equal */
925  SCIP_CALL( SCIPchgRhsLinear(scip, cons, lhs + REALABS(val)) );
926  }
927  else
928  {
929  /* lhs > -infinity, rhs < infinity -> equality */
930  assert(SCIPisEQ(scip, lhs, rhs));
931  if( val >= 0.0 )
932  {
933  SCIP_CALL( SCIPchgRhsLinear(scip, cons, rhs + val) );
934  }
935  else
936  {
937  SCIP_CALL( SCIPchgLhsLinear(scip, cons, lhs + val) );
938  }
939  }
940  }
941  if( mpsinputField5(mpsi) != NULL )
942  {
943  cons = SCIPfindCons(scip, mpsinputField4(mpsi));
944  if( cons == NULL )
945  mpsinputEntryIgnored(scip, mpsi, "Range", mpsinputField1(mpsi), "row", mpsinputField4(mpsi), SCIP_VERBLEVEL_NORMAL);
946  else
947  {
948  val = atof(mpsinputField5(mpsi));
949 
950  /* find out the row sense */
951  lhs = SCIPgetLhsLinear(scip, cons);
952  rhs = SCIPgetRhsLinear(scip, cons);
953  if( SCIPisInfinity(scip, -lhs) )
954  {
955  /* lhs = -infinity -> lower or equal */
956  SCIP_CALL( SCIPchgLhsLinear(scip, cons, rhs - REALABS(val)) );
957  }
958  else if( SCIPisInfinity(scip, rhs) )
959  {
960  /* rhs = +infinity -> greater or equal */
961  SCIP_CALL( SCIPchgRhsLinear(scip, cons, lhs + REALABS(val)) );
962  }
963  else
964  {
965  /* lhs > -infinity, rhs < infinity -> equality */
966  assert(SCIPisEQ(scip, lhs, rhs));
967  if( val >= 0.0 )
968  {
969  SCIP_CALL( SCIPchgRhsLinear(scip, cons, rhs + val) );
970  }
971  else
972  {
973  SCIP_CALL( SCIPchgLhsLinear(scip, cons, lhs + val) );
974  }
975  }
976  }
977  }
978  }
979  }
980  mpsinputSyntaxerror(mpsi);
981 
982  return SCIP_OKAY;
983 }
984 
985 /** Process BOUNDS section. */
986 static
988  MPSINPUT* mpsi, /**< mps input structure */
989  SCIP* scip /**< SCIP data structure */
990  )
991 {
992  char bndname[MPS_MAX_NAMELEN] = { '\0' };
993  SCIP_VAR* var;
994  SCIP_Real val;
995  SCIP_Bool shifted;
996 
997  SCIP_VAR** semicont;
998  int nsemicont;
999  int semicontsize;
1000  SCIP_Bool dynamiccols;
1001  SCIP_Bool dynamicconss;
1002 
1003  semicont = NULL;
1004  nsemicont = 0;
1005  semicontsize = 0;
1006 
1007  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamiccols", &dynamiccols) );
1008  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicconss", &dynamicconss) );
1009 
1010  SCIPdebugMessage("read bounds\n");
1011 
1012  while( mpsinputReadLine(mpsi) )
1013  {
1014  if( mpsinputField0(mpsi) != 0 )
1015  {
1016  if( !strcmp(mpsinputField0(mpsi), "SOS") )
1017  mpsinputSetSection(mpsi, MPS_SOS);
1018  else if( !strcmp(mpsinputField0(mpsi), "QMATRIX") )
1020  else if( !strcmp(mpsinputField0(mpsi), "QUADOBJ") )
1022  else if( !strcmp(mpsinputField0(mpsi), "QCMATRIX") )
1024  else if( !strcmp(mpsinputField0(mpsi), "INDICATORS") )
1026  else if( !strcmp(mpsinputField0(mpsi), "ENDATA") )
1028  else
1029  break;
1030  goto READBOUNDS_FINISH;
1031  }
1032 
1033  shifted = FALSE;
1034 
1035  /* Is the value field used ? */
1036  if( !strcmp(mpsinputField1(mpsi), "LO") /* lower bound given in field 4 */
1037  || !strcmp(mpsinputField1(mpsi), "UP") /* upper bound given in field 4 */
1038  || !strcmp(mpsinputField1(mpsi), "FX") /* fixed value given in field 4 */
1039  || !strcmp(mpsinputField1(mpsi), "LI") /* CPLEX extension: lower bound of integer variable given in field 4 */
1040  || !strcmp(mpsinputField1(mpsi), "UI") /* CPLEX extension: upper bound of integer variable given in field 4 */
1041  || !strcmp(mpsinputField1(mpsi), "SC") )/* CPLEX extension: semi continuous variable, upper bound given in field 4 */
1042  {
1043  if( mpsinputField3(mpsi) != NULL && mpsinputField4(mpsi) == NULL )
1044  {
1045  mpsinputInsertName(mpsi, "_BND_", TRUE);
1046  shifted = TRUE;
1047  }
1048  }
1049  else if( !strcmp(mpsinputField1(mpsi), "FR") /* free variable */
1050  || !strcmp(mpsinputField1(mpsi), "MI") /* lower bound is minus infinity */
1051  || !strcmp(mpsinputField1(mpsi), "PL") /* upper bound is plus infinity */
1052  || !strcmp(mpsinputField1(mpsi), "BV") ) /* CPLEX extension: binary variable */
1053  {
1054  if( mpsinputField2(mpsi) != NULL && mpsinputField3(mpsi) == NULL )
1055  {
1056  mpsinputInsertName(mpsi, "_BND_", TRUE);
1057  shifted = TRUE;
1058  }
1059  }
1060  else
1061  {
1062  mpsinputSyntaxerror(mpsi);
1063  return SCIP_OKAY;
1064  }
1065 
1066  if( mpsinputField1(mpsi) == NULL || mpsinputField2(mpsi) == NULL || mpsinputField3(mpsi) == NULL )
1067  break;
1068 
1069  if( *bndname == '\0' )
1070  (void)SCIPmemccpy(bndname, mpsinputField2(mpsi), '\0', MPS_MAX_NAMELEN - 1);
1071 
1072  /* Only read the first Bound in section */
1073  if( !strcmp(bndname, mpsinputField2(mpsi)) )
1074  {
1075  SCIP_Bool infeasible;
1076 
1077  var = SCIPfindVar(scip, mpsinputField3(mpsi));
1078  /* if variable did not appear in columns section before, then it may still come in later sections (QCMATRIX, QMATRIX, SOS, ...)
1079  * thus add it as continuous variables, which has default bounds 0.0 <= x, and default cost 0.0 */
1080  if( var == NULL )
1081  {
1082  SCIP_VAR* varcpy;
1083 
1084  SCIP_CALL( SCIPcreateVar(scip, &var, mpsinputField3(mpsi), 0.0, SCIPinfinity(scip), 0.0,
1085  SCIP_VARTYPE_CONTINUOUS, !dynamiccols, dynamiccols, NULL, NULL, NULL, NULL, NULL) );
1086 
1087  SCIP_CALL( SCIPaddVar(scip, var) );
1088  varcpy = var;
1089  SCIP_CALL( SCIPreleaseVar(scip, &varcpy) );
1090  /* mpsinputEntryIgnored(scip, mpsi, "column", mpsinputField3(mpsi), "bound", bndname, SCIP_VERBLEVEL_NORMAL); */
1091  }
1092  assert(var != NULL);
1093 
1094  if( mpsinputField4(mpsi) == NULL )
1095  val = 0.0;
1096  else
1097  val = atof(mpsinputField4(mpsi));
1098 
1099  /* if a bound of a binary variable is given, the variable is converted into an integer variable
1100  * with default bounds 0 <= x <= infinity
1101  */
1102  if( SCIPvarGetType(var) == SCIP_VARTYPE_BINARY )
1103  {
1104  if( (mpsinputField1(mpsi)[1] == 'I') /* CPLEX extension (Integer Bound) */
1105  || (!(mpsinputField1(mpsi)[0] == 'L' && SCIPisFeasEQ(scip, val, 0.0))
1106  && !(mpsinputField1(mpsi)[0] == 'U' && SCIPisFeasEQ(scip, val, 1.0))) )
1107  {
1108  assert(SCIPisFeasEQ(scip, SCIPvarGetLbGlobal(var), 0.0));
1109  assert(SCIPisFeasEQ(scip, SCIPvarGetUbGlobal(var), 1.0));
1110  SCIP_CALL( SCIPchgVarType(scip, var, SCIP_VARTYPE_INTEGER, &infeasible) );
1111  /* don't assert feasibility here because the presolver will and should detect a infeasibility */
1112  SCIP_CALL( SCIPchgVarUb(scip, var, SCIPinfinity(scip)) );
1113  }
1114  }
1115 
1116  switch( mpsinputField1(mpsi)[0] )
1117  {
1118  case 'L':
1119  if( mpsinputField1(mpsi)[1] == 'I' ) /* CPLEX extension (Integer Bound) */
1120  {
1121  SCIP_CALL( SCIPchgVarType(scip, var, SCIP_VARTYPE_INTEGER, &infeasible) );
1122  /* don't assert feasibility here because the presolver will and should detect a infeasibility */
1123  }
1124  SCIP_CALL( SCIPchgVarLb(scip, var, val) );
1125  break;
1126  case 'U':
1127  if( mpsinputField1(mpsi)[1] == 'I' ) /* CPLEX extension (Integer Bound) */
1128  {
1129  SCIP_CALL( SCIPchgVarType(scip, var, SCIP_VARTYPE_INTEGER, &infeasible) );
1130  /* don't assert feasibility here because the presolver will and should detect a infeasibility */
1131  }
1132  SCIP_CALL( SCIPchgVarUb(scip, var, val) );
1133  break;
1134  case 'S':
1135  assert(mpsinputField1(mpsi)[1] == 'C'); /* CPLEX extension (Semi-Continuous) */
1136  /* remember that variable is semi-continuous */
1137  if( semicontsize <= nsemicont )
1138  {
1139  semicontsize = SCIPcalcMemGrowSize(scip, nsemicont+1);
1140  if( semicont == NULL )
1141  {
1142  SCIP_CALL( SCIPallocBufferArray(scip, &semicont, semicontsize) );
1143  }
1144  else
1145  {
1146  SCIP_CALL( SCIPreallocBufferArray(scip, &semicont, semicontsize) );
1147  }
1148  }
1149  assert(semicont != NULL);
1150  semicont[nsemicont] = var;
1151  ++nsemicont;
1152 
1153  SCIP_CALL( SCIPchgVarUb(scip, var, val) );
1154  break;
1155  case 'F':
1156  if( mpsinputField1(mpsi)[1] == 'X' )
1157  {
1158  SCIP_CALL( SCIPchgVarLb(scip, var, val) );
1159  SCIP_CALL( SCIPchgVarUb(scip, var, val) );
1160  }
1161  else
1162  {
1163  SCIP_CALL( SCIPchgVarLb(scip, var, -SCIPinfinity(scip)) );
1164  SCIP_CALL( SCIPchgVarUb(scip, var, +SCIPinfinity(scip)) );
1165  }
1166  break;
1167  case 'M':
1168  SCIP_CALL( SCIPchgVarLb(scip, var, -SCIPinfinity(scip)) );
1169  break;
1170  case 'P':
1171  SCIP_CALL( SCIPchgVarUb(scip, var, +SCIPinfinity(scip)) );
1172  break;
1173  case 'B' : /* CPLEX extension (Binary) */
1174  SCIP_CALL( SCIPchgVarLb(scip, var, 0.0) );
1175  SCIP_CALL( SCIPchgVarUb(scip, var, 1.0) );
1176  SCIP_CALL( SCIPchgVarType(scip, var, SCIP_VARTYPE_BINARY, &infeasible) );
1177  /* don't assert feasibility here because the presolver will and should detect a infeasibility */
1178  break;
1179  default:
1180  mpsinputSyntaxerror(mpsi);
1181  return SCIP_OKAY;
1182  }
1183  }
1184  else
1185  {
1186  /* check for syntax error */
1187  assert(*bndname != '\0');
1188  if( strcmp(bndname, mpsinputField3(mpsi)) == 0 && shifted )
1189  {
1190  mpsinputSyntaxerror(mpsi);
1191  return SCIP_OKAY;
1192  }
1193 
1194  mpsinputEntryIgnored(scip, mpsi, "bound", mpsinputField2(mpsi), "variable", mpsinputField3(mpsi), SCIP_VERBLEVEL_NORMAL);
1195  }
1196  }
1197  mpsinputSyntaxerror(mpsi);
1198 
1199 
1200  READBOUNDS_FINISH:
1201  if( nsemicont > 0 )
1202  {
1203  int i;
1204  SCIP_Real oldlb;
1205  char name[SCIP_MAXSTRLEN];
1206  SCIP_CONS* cons;
1207 
1208  SCIP_VAR* vars[2];
1209  SCIP_BOUNDTYPE boundtypes[2];
1210  SCIP_Real bounds[2];
1211 
1212  assert(semicont != NULL);
1213 
1214  /* add bound disjunction constraints for semi-continuous variables */
1215  for( i = 0; i < nsemicont; ++i )
1216  {
1217  var = semicont[i];
1218 
1219  oldlb = SCIPvarGetLbGlobal(var);
1220  /* if no bound was specified (which we assume if we see lower bound 0.0),
1221  * then the default lower bound for a semi-continuous variable is 1.0 */
1222  if( oldlb == 0.0 )
1223  oldlb = 1.0;
1224 
1225  /* change the lower bound to 0.0 */
1226  SCIP_CALL( SCIPchgVarLb(scip, var, 0.0) );
1227 
1228  /* add a bound disjunction constraint to say var <= 0.0 or var >= oldlb */
1229  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "semicont_%s", SCIPvarGetName(var));
1230 
1231  vars[0] = var;
1232  vars[1] = var;
1233  boundtypes[0] = SCIP_BOUNDTYPE_UPPER;
1234  boundtypes[1] = SCIP_BOUNDTYPE_LOWER;
1235  bounds[0] = 0.0;
1236  bounds[1] = oldlb;
1237 
1238  SCIP_CALL( SCIPcreateConsBounddisjunction(scip, &cons, name, 2, vars, boundtypes, bounds,
1239  !dynamiccols, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, dynamicconss, dynamiccols, FALSE) );
1240  SCIP_CALL( SCIPaddCons(scip, cons) );
1241 
1242  SCIPdebugMessage("add bound disjunction constraint for semi-continuity of <%s>:\n\t", SCIPvarGetName(var));
1243  SCIPdebugPrintCons(scip, cons, NULL);
1244 
1245  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
1246  }
1247  }
1248 
1249  SCIPfreeBufferArrayNull(scip, &semicont);
1250 
1251  return SCIP_OKAY;
1252 }
1253 
1254 
1255 /** Process SOS section.
1256  *
1257  * We read the SOS section, which is a nonstandard section introduced by CPLEX.
1258  *
1259  * @note Currently we do not support the standard way of specifying SOS constraints via markers.
1260  */
1261 static
1263  MPSINPUT* mpsi, /**< mps input structure */
1264  SCIP* scip /**< SCIP data structure */
1265  )
1266 {
1267  SCIP_Bool initial;
1268  SCIP_Bool separate;
1269  SCIP_Bool enforce;
1270  SCIP_Bool check;
1271  SCIP_Bool propagate;
1272  SCIP_Bool local;
1273  SCIP_Bool modifiable;
1274  SCIP_Bool dynamic;
1275  SCIP_Bool removable;
1276  char name[MPS_MAX_NAMELEN] = { '\0' };
1277  SCIP_CONS* cons = NULL;
1278  int consType = -1;
1279  int cnt = 0;
1280 
1281  SCIPdebugMessage("read SOS constraints\n");
1282 
1283  /* standard settings for SOS constraints: */
1284  initial = TRUE;
1285  separate = FALSE;
1286  enforce = TRUE;
1287  check = TRUE;
1288  propagate = TRUE;
1289  local = FALSE;
1290  modifiable = FALSE;
1291  dynamic = FALSE;
1292  removable = FALSE;
1293 
1294  /* loop through section */
1295  while( mpsinputReadLine(mpsi) )
1296  {
1297  int type = -1;
1298 
1299  /* check if next section is found */
1300  if( mpsinputField0(mpsi) != NULL )
1301  {
1302  if( !strcmp(mpsinputField0(mpsi), "ENDATA") )
1304  else if( !strcmp(mpsinputField0(mpsi), "QMATRIX") )
1306  else if( !strcmp(mpsinputField0(mpsi), "QUADOBJ") )
1308  else if( !strcmp(mpsinputField0(mpsi), "QCMATRIX") )
1310  else if( !strcmp(mpsinputField0(mpsi), "INDICATORS") )
1312  break;
1313  }
1314  if( mpsinputField1(mpsi) == NULL )
1315  {
1316  SCIPerrorMessage("empty data in a non-comment line.\n");
1317  mpsinputSyntaxerror(mpsi);
1318  return SCIP_OKAY;
1319  }
1320 
1321  /* check for new SOS set */
1322  if( strcmp(mpsinputField1(mpsi), "S1") == 0 )
1323  type = 1;
1324  if( strcmp(mpsinputField1(mpsi), "S2") == 0 )
1325  type = 2;
1326 
1327  /* add last constraint and create a new one */
1328  if( type > 0 )
1329  {
1330  assert( type == 1 || type == 2 );
1331  if( cons != NULL )
1332  {
1333  /* add last constraint */
1334  SCIP_CALL( SCIPaddCons(scip, cons) );
1335  SCIPdebugMessage("(line %d) added constraint <%s>: ", mpsi->lineno, SCIPconsGetName(cons));
1336  SCIPdebugPrintCons(scip, cons, NULL);
1337  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
1338  }
1339 
1340  /* check name */
1341  if( mpsinputField2(mpsi) != NULL )
1342  (void)SCIPmemccpy(name, mpsinputField2(mpsi), '\0', MPS_MAX_NAMELEN - 1);
1343  else
1344  {
1345  /* create new name */
1346  (void) SCIPsnprintf(name, MPS_MAX_NAMELEN, "SOS%d", ++cnt);
1347  }
1348 
1349  /* create new SOS constraint */
1350  if( type == 1 )
1351  {
1352  /* we do not know the name of the constraint */
1353  SCIP_CALL( SCIPcreateConsSOS1(scip, &cons, name, 0, NULL, NULL, initial, separate, enforce, check, propagate,
1354  local, modifiable, dynamic, removable) );
1355  }
1356  else
1357  {
1358  assert( type == 2 );
1359  SCIP_CALL( SCIPcreateConsSOS2(scip, &cons, name, 0, NULL, NULL, initial, separate, enforce, check, propagate,
1360  local, modifiable, dynamic, removable) );
1361  }
1362  consType = type;
1363  SCIPdebugMessage("created constraint <%s> of type %d.\n", name, type);
1364  /* note: we ignore the priorities! */
1365  }
1366  else
1367  {
1368  /* otherwise we are in the section given variables */
1369  SCIP_VAR* var;
1370  SCIP_Real weight;
1371  char* endptr;
1372 
1373  if( consType != 1 && consType != 2 )
1374  {
1375  SCIPerrorMessage("missing SOS type specification.\n");
1376  mpsinputSyntaxerror(mpsi);
1377  return SCIP_OKAY;
1378  }
1379 
1380  /* get variable */
1381  var = SCIPfindVar(scip, mpsinputField1(mpsi));
1382  if( var == NULL )
1383  {
1384  /* ignore unknown variables - we would not know the type anyway */
1385  mpsinputEntryIgnored(scip, mpsi, "column", mpsinputField1(mpsi), "SOS", name, SCIP_VERBLEVEL_NORMAL);
1386  }
1387  else
1388  {
1389  /* get weight */
1390  weight = strtod(mpsinputField2(mpsi), &endptr);
1391  if( endptr == mpsinputField2(mpsi) || *endptr != '\0' )
1392  {
1393  SCIPerrorMessage("weight for variable <%s> not specified.\n", mpsinputField1(mpsi));
1394  mpsinputSyntaxerror(mpsi);
1395  return SCIP_OKAY;
1396  }
1397 
1398  /* add variable and weight */
1399  assert( consType == 1 || consType == 2 );
1400  switch( consType )
1401  {
1402  case 1:
1403  SCIP_CALL( SCIPaddVarSOS1(scip, cons, var, weight) );
1404  break;
1405  case 2:
1406  SCIP_CALL( SCIPaddVarSOS2(scip, cons, var, weight) );
1407  break;
1408  default:
1409  SCIPerrorMessage("unknown SOS type: <%d>\n", type); /* should not happen */
1410  SCIPABORT();
1411  }
1412  SCIPdebugMessage("added variable <%s> with weight %g.\n", SCIPvarGetName(var), weight);
1413  }
1414  /* check other fields */
1415  if( (mpsinputField3(mpsi) != NULL && *mpsinputField3(mpsi) != '\0' ) ||
1416  (mpsinputField4(mpsi) != NULL && *mpsinputField4(mpsi) != '\0' ) ||
1417  (mpsinputField5(mpsi) != NULL && *mpsinputField5(mpsi) != '\0' ) )
1418  {
1419  SCIPwarningMessage(scip, "ignoring data in fields 3-5 <%s> <%s> <%s>.\n",
1420  mpsinputField3(mpsi), mpsinputField4(mpsi), mpsinputField5(mpsi));
1421  }
1422  }
1423  }
1424 
1425  if( cons != NULL )
1426  {
1427  /* add last constraint */
1428  SCIP_CALL( SCIPaddCons(scip, cons) );
1429  SCIPdebugMessage("(line %d) added constraint <%s>: ", mpsi->lineno, SCIPconsGetName(cons));
1430  SCIPdebugPrintCons(scip, cons, NULL);
1431  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
1432  }
1433 
1434  return SCIP_OKAY;
1435 }
1436 
1437 
1438 /** Process QMATRIX or QUADOBJ section.
1439  *
1440  * - We read the QMATRIX or QUADOBJ section, which is a nonstandard section introduced by CPLEX.
1441  * - We create a quadratic constraint for this matrix and add a variable to the objective to
1442  * represent the value of the QMATRIX.
1443  * - For a QMATRIX, we expect that both lower and upper diagonal elements are given and every
1444  * coefficient has to be divided by 2.0.
1445  * - For a QUADOBJ, we expect that only the upper diagonal elements are given and thus only
1446  * coefficients on the diagonal have to be divided by 2.0.
1447  */
1448 static
1450  MPSINPUT* mpsi, /**< mps input structure */
1451  SCIP_Bool isQuadObj, /**< whether we actually read a QUADOBJ section */
1452  SCIP* scip /**< SCIP data structure */
1453  )
1454 {
1455  SCIP_VAR** quadvars1;
1456  SCIP_VAR** quadvars2;
1457  SCIP_Real* quadcoefs;
1458  int cnt = 0; /* number of qmatrix elements processed so far */
1459  int size; /* size of quad* arrays */
1460 
1461  SCIPdebugMessage("read %s objective\n", isQuadObj ? "QUADOBJ" : "QMATRIX");
1462 
1463  size = 1;
1464  SCIP_CALL( SCIPallocBufferArray(scip, &quadvars1, size) );
1465  SCIP_CALL( SCIPallocBufferArray(scip, &quadvars2, size) );
1466  SCIP_CALL( SCIPallocBufferArray(scip, &quadcoefs, size) );
1467 
1468  /* loop through section */
1469  while( mpsinputReadLine(mpsi) )
1470  {
1471  /* otherwise we are in the section given variables */
1472  SCIP_VAR* var1;
1473  SCIP_VAR* var2;
1474  SCIP_Real coef;
1475 
1476  /* check if next section is found */
1477  if( mpsinputField0(mpsi) != NULL )
1478  {
1479  if( !strcmp(mpsinputField0(mpsi), "QCMATRIX") )
1481  else if( !strcmp(mpsinputField0(mpsi), "INDICATORS") )
1483  else if( !strcmp(mpsinputField0(mpsi), "ENDATA") )
1485  break;
1486  }
1487  if( mpsinputField1(mpsi) == NULL && mpsinputField2(mpsi) == NULL )
1488  {
1489  SCIPerrorMessage("empty data in a non-comment line.\n");
1490  mpsinputSyntaxerror(mpsi);
1491  SCIPfreeBufferArray(scip, &quadvars1);
1492  SCIPfreeBufferArray(scip, &quadvars2);
1493  SCIPfreeBufferArray(scip, &quadcoefs);
1494  return SCIP_OKAY;
1495  }
1496 
1497  /* get first variable */
1498  var1 = SCIPfindVar(scip, mpsinputField1(mpsi));
1499  if( var1 == NULL )
1500  {
1501  /* ignore unknown variables - we would not know the type anyway */
1502  mpsinputEntryIgnored(scip, mpsi, "column", mpsinputField1(mpsi), "QMatrix", "QMATRIX", SCIP_VERBLEVEL_NORMAL);
1503  }
1504  else
1505  {
1506  /* get second variable */
1507  var2 = SCIPfindVar(scip, mpsinputField2(mpsi));
1508  if( var2 == NULL )
1509  {
1510  /* ignore unknown variables - we would not know the type anyway */
1511  mpsinputEntryIgnored(scip, mpsi, "column", mpsinputField2(mpsi), "QMatrix", "QMATRIX", SCIP_VERBLEVEL_NORMAL);
1512  }
1513  else
1514  {
1515  char* endptr;
1516  /* get coefficient */
1517  coef = strtod(mpsinputField3(mpsi), &endptr);
1518  if( endptr == mpsinputField3(mpsi) || *endptr != '\0' )
1519  {
1520  SCIPerrorMessage("coefficient of term <%s>*<%s> not specified.\n", mpsinputField1(mpsi), mpsinputField2(mpsi));
1521  mpsinputSyntaxerror(mpsi);
1522  SCIPfreeBufferArray(scip, &quadvars1);
1523  SCIPfreeBufferArray(scip, &quadvars2);
1524  SCIPfreeBufferArray(scip, &quadcoefs);
1525  return SCIP_OKAY;
1526  }
1527 
1528  /* store variables and coefficient */
1529  if( cnt >= size )
1530  {
1531  int newsize = SCIPcalcMemGrowSize(scip, size+1);
1532  assert(newsize > size);
1533  SCIP_CALL( SCIPreallocBufferArray(scip, &quadvars1, newsize) );
1534  SCIP_CALL( SCIPreallocBufferArray(scip, &quadvars2, newsize) );
1535  SCIP_CALL( SCIPreallocBufferArray(scip, &quadcoefs, newsize) );
1536  size = newsize;
1537  }
1538  assert(cnt < size);
1539  quadvars1[cnt] = var1;
1540  quadvars2[cnt] = var2;
1541  quadcoefs[cnt] = coef;
1542  /* diagonal elements have to be divided by 2.0
1543  * in a QMATRIX section also off-diagonal have to be divided by 2.0, since both lower and upper diagonal elements are given
1544  */
1545  if( var1 == var2 || !isQuadObj )
1546  quadcoefs[cnt] /= 2.0;
1547  ++cnt;
1548 
1549  SCIPdebugMessage("stored term %g*<%s>*<%s>.\n", coef, SCIPvarGetName(var1), SCIPvarGetName(var2));
1550 
1551  /* check other fields */
1552  if( (mpsinputField4(mpsi) != NULL && *mpsinputField4(mpsi) != '\0' ) ||
1553  (mpsinputField5(mpsi) != NULL && *mpsinputField5(mpsi) != '\0' ) )
1554  {
1555  SCIPwarningMessage(scip, "ignoring data in fields 4 and 5 <%s> <%s>.\n", mpsinputField4(mpsi), mpsinputField5(mpsi));
1556  }
1557  }
1558  }
1559  }
1560 
1561  /* add constraint */
1562  if( cnt )
1563  {
1564  SCIP_Bool initial, separate, enforce, check, propagate;
1565  SCIP_Bool local, modifiable, dynamic, removable;
1566  SCIP_CONS* cons = NULL;
1567  SCIP_VAR* qmatrixvar = NULL;
1568  SCIP_Real lhs, rhs;
1569  SCIP_Real minusone = -1.0;
1570 
1571  /* standard settings for quadratic constraints: */
1572  initial = TRUE;
1573  separate = TRUE;
1574  enforce = TRUE;
1575  check = TRUE;
1576  propagate = TRUE;
1577  local = FALSE;
1578  modifiable = FALSE;
1579  dynamic = FALSE;
1580  removable = FALSE;
1581 
1582  SCIP_CALL( SCIPcreateVar(scip, &qmatrixvar, "qmatrixvar", -SCIPinfinity(scip), SCIPinfinity(scip), 1.0,
1583  SCIP_VARTYPE_CONTINUOUS, initial, removable, NULL, NULL, NULL, NULL, NULL) );
1584  SCIP_CALL( SCIPaddVar(scip, qmatrixvar) );
1585 
1587  {
1588  lhs = -SCIPinfinity(scip);
1589  rhs = 0.0;
1590  }
1591  else
1592  {
1593  lhs = 0.0;
1594  rhs = SCIPinfinity(scip);
1595  }
1596 
1597  SCIP_CALL( SCIPcreateConsQuadraticNonlinear(scip, &cons, "qmatrix", 1, &qmatrixvar, &minusone, cnt, quadvars1, quadvars2, quadcoefs, lhs, rhs,
1598  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable) );
1599 
1600  SCIP_CALL( SCIPaddCons(scip, cons) );
1601  SCIPdebugMessage("(line %d) added constraint <%s>: ", mpsi->lineno, SCIPconsGetName(cons));
1602  SCIPdebugPrintCons(scip, cons, NULL);
1603 
1604  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
1605  SCIP_CALL( SCIPreleaseVar(scip, &qmatrixvar) );
1606  }
1607  else
1608  {
1609  SCIPwarningMessage(scip, "%s section has no entries.\n", isQuadObj ? "QUADOBJ" : "QMATRIX");
1610  }
1611 
1612  SCIPfreeBufferArray(scip, &quadvars1);
1613  SCIPfreeBufferArray(scip, &quadvars2);
1614  SCIPfreeBufferArray(scip, &quadcoefs);
1615 
1616  return SCIP_OKAY;
1617 }
1618 
1619 
1620 /** Process QCMATRIX section.
1621  *
1622  * We read the QCMATRIX section, which is a nonstandard section introduced by CPLEX.
1623  *
1624  * We replace the corresponding linear constraint by a quadratic constraint which contains the
1625  * original linear constraint plus the quadratic part specified in the QCMATRIX.
1626  */
1627 static
1629  MPSINPUT* mpsi, /**< mps input structure */
1630  SCIP* scip /**< SCIP data structure */
1631  )
1632 {
1633  SCIP_CONS* lincons; /* the linear constraint that was added for the corresponding row */
1634  SCIP_VAR** quadvars1;
1635  SCIP_VAR** quadvars2;
1636  SCIP_Real* quadcoefs;
1637  int cnt = 0; /* number of qcmatrix elements processed so far */
1638  int size; /* size of quad* arrays */
1639 
1640  if( mpsinputField1(mpsi) == NULL )
1641  {
1642  SCIPerrorMessage("no row name in QCMATRIX line.\n");
1643  mpsinputSyntaxerror(mpsi);
1644  return SCIP_OKAY;
1645  }
1646 
1647  SCIPdebugMessage("read QCMATRIX section for row <%s>\n", mpsinputField1(mpsi));
1648 
1649  lincons = SCIPfindCons(scip, mpsinputField1(mpsi));
1650  if( lincons == NULL )
1651  {
1652  SCIPerrorMessage("no row under name <%s> processed so far.\n", mpsinputField1(mpsi));
1653  mpsinputSyntaxerror(mpsi);
1654  return SCIP_OKAY;
1655  }
1656 
1657  size = 1;
1658  SCIP_CALL( SCIPallocBufferArray(scip, &quadvars1, size) );
1659  SCIP_CALL( SCIPallocBufferArray(scip, &quadvars2, size) );
1660  SCIP_CALL( SCIPallocBufferArray(scip, &quadcoefs, size) );
1661 
1662  /* loop through section */
1663  while( mpsinputReadLine(mpsi) )
1664  {
1665  /* otherwise we are in the section given variables */
1666  SCIP_VAR* var1;
1667  SCIP_VAR* var2;
1668  SCIP_Real coef;
1669 
1670  /* check if next section is found */
1671  if( mpsinputField0(mpsi) != NULL )
1672  {
1673  if( !strcmp(mpsinputField0(mpsi), "QMATRIX") )
1675  else if( !strcmp(mpsinputField0(mpsi), "QUADOBJ") )
1677  else if( !strcmp(mpsinputField0(mpsi), "QCMATRIX") )
1679  else if( !strcmp(mpsinputField0(mpsi), "INDICATORS") )
1681  else if( !strcmp(mpsinputField0(mpsi), "ENDATA") )
1683  break;
1684  }
1685  if( mpsinputField1(mpsi) == NULL && mpsinputField2(mpsi) == NULL )
1686  {
1687  SCIPerrorMessage("empty data in a non-comment line.\n");
1688  mpsinputSyntaxerror(mpsi);
1689  SCIPfreeBufferArray(scip, &quadvars1);
1690  SCIPfreeBufferArray(scip, &quadvars2);
1691  SCIPfreeBufferArray(scip, &quadcoefs);
1692  return SCIP_OKAY;
1693  }
1694 
1695  /* get first variable */
1696  var1 = SCIPfindVar(scip, mpsinputField1(mpsi));
1697  if( var1 == NULL )
1698  {
1699  /* ignore unknown variables - we would not know the type anyway */
1700  mpsinputEntryIgnored(scip, mpsi, "column", mpsinputField1(mpsi), "QCMatrix", SCIPconsGetName(lincons), SCIP_VERBLEVEL_NORMAL);
1701  }
1702  else
1703  {
1704  /* get second variable */
1705  var2 = SCIPfindVar(scip, mpsinputField2(mpsi));
1706  if( var2 == NULL )
1707  {
1708  /* ignore unknown variables - we would not know the type anyway */
1709  mpsinputEntryIgnored(scip, mpsi, "column", mpsinputField2(mpsi), "QCMatrix", SCIPconsGetName(lincons), SCIP_VERBLEVEL_NORMAL);
1710  }
1711  else
1712  {
1713  char* endptr;
1714  /* get coefficient */
1715  coef = strtod(mpsinputField3(mpsi), &endptr);
1716  if( endptr == mpsinputField3(mpsi) || *endptr != '\0' )
1717  {
1718  SCIPerrorMessage("coefficient of term <%s>*<%s> not specified.\n", mpsinputField1(mpsi), mpsinputField2(mpsi));
1719  mpsinputSyntaxerror(mpsi);
1720  SCIPfreeBufferArray(scip, &quadvars1);
1721  SCIPfreeBufferArray(scip, &quadvars2);
1722  SCIPfreeBufferArray(scip, &quadcoefs);
1723  return SCIP_OKAY;
1724  }
1725 
1726  /* store variables and coefficient */
1727  if( cnt >= size )
1728  {
1729  int newsize = SCIPcalcMemGrowSize(scip, size+1);
1730  assert(newsize > size);
1731  SCIP_CALL( SCIPreallocBufferArray(scip, &quadvars1, newsize) );
1732  SCIP_CALL( SCIPreallocBufferArray(scip, &quadvars2, newsize) );
1733  SCIP_CALL( SCIPreallocBufferArray(scip, &quadcoefs, newsize) );
1734  size = newsize;
1735  }
1736  assert(cnt < size);
1737  quadvars1[cnt] = var1;
1738  quadvars2[cnt] = var2;
1739  quadcoefs[cnt] = coef;
1740  ++cnt;
1741 
1742  SCIPdebugMessage("stored term %g*<%s>*<%s>.\n", coef, SCIPvarGetName(var1), SCIPvarGetName(var2));
1743 
1744  /* check other fields */
1745  if( (mpsinputField4(mpsi) != NULL && *mpsinputField4(mpsi) != '\0' ) ||
1746  (mpsinputField5(mpsi) != NULL && *mpsinputField5(mpsi) != '\0' ) )
1747  {
1748  SCIPwarningMessage(scip, "ignoring data in fields 4 and 5 <%s> <%s>.\n", mpsinputField4(mpsi), mpsinputField5(mpsi));
1749  }
1750  }
1751  }
1752  }
1753 
1754  /* replace linear constraint by quadratic constraint */
1755  if( cnt )
1756  {
1757  SCIP_CONS* cons = NULL;
1758 
1760  SCIPgetNVarsLinear(scip, lincons), SCIPgetVarsLinear(scip, lincons), SCIPgetValsLinear(scip, lincons),
1761  cnt, quadvars1, quadvars2, quadcoefs, SCIPgetLhsLinear(scip, lincons), SCIPgetRhsLinear(scip, lincons),
1762  SCIPconsIsInitial(lincons), SCIPconsIsSeparated(lincons), SCIPconsIsEnforced(lincons), SCIPconsIsChecked(lincons),
1763  SCIPconsIsPropagated(lincons), SCIPconsIsLocal(lincons), SCIPconsIsModifiable(lincons), SCIPconsIsDynamic(lincons),
1764  SCIPconsIsRemovable(lincons)) );
1765 
1766  SCIP_CALL( SCIPaddCons(scip, cons) );
1767  SCIPdebugMessage("(line %d) added constraint <%s>: ", mpsi->lineno, SCIPconsGetName(cons));
1768  SCIPdebugPrintCons(scip, cons, NULL);
1769 
1770  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
1771 
1772  SCIP_CALL( SCIPdelCons(scip, lincons) );
1773  }
1774  else
1775  {
1776  SCIPwarningMessage(scip, "QCMATRIX section has no entries.\n");
1777  }
1778 
1779  SCIPfreeBufferArray(scip, &quadvars1);
1780  SCIPfreeBufferArray(scip, &quadvars2);
1781  SCIPfreeBufferArray(scip, &quadcoefs);
1782 
1783  return SCIP_OKAY;
1784 }
1785 
1786 
1787 /** Process INDICATORS section.
1788  *
1789  * We read the INDICATORS section, which is a nonstandard section introduced by CPLEX.
1790  *
1791  * The section has to come after the QMATRIX* sections.
1792  */
1793 static
1795  MPSINPUT* mpsi, /**< mps input structure */
1796  SCIP* scip /**< SCIP data structure */
1797  )
1798 {
1799  SCIP_Bool initial;
1800  SCIP_Bool separate;
1801  SCIP_Bool enforce;
1802  SCIP_Bool check;
1803  SCIP_Bool propagate;
1804  SCIP_Bool local;
1805  SCIP_Bool dynamic;
1806  SCIP_Bool removable;
1807  SCIP_Bool stickingatnode;
1808  char name[MPS_MAX_NAMELEN] = { '\0' };
1809 
1810  SCIPdebugMessage("read INDICATORS constraints\n");
1811 
1812  /* standard settings for indicator constraints: */
1813  initial = TRUE;
1814  separate = TRUE;
1815  enforce = TRUE;
1816  check = TRUE;
1817  propagate = TRUE;
1818  local = FALSE;
1819  dynamic = FALSE;
1820  removable = FALSE;
1821  stickingatnode = FALSE;
1822 
1823  /* loop through section */
1824  while( mpsinputReadLine(mpsi) )
1825  {
1826  SCIP_CONSHDLR* conshdlr;
1827  SCIP_VARTYPE slackvartype;
1828  SCIP_CONS* cons;
1829  SCIP_CONS* lincons;
1830  SCIP_VAR* binvar;
1831  SCIP_VAR* slackvar;
1832  SCIP_Real lhs;
1833  SCIP_Real rhs;
1834  SCIP_Real sign;
1835  SCIP_VAR** linvars;
1836  SCIP_Real* linvals;
1837  int nlinvars;
1838  int i;
1839 
1840  /* check if next section is found */
1841  if( mpsinputField0(mpsi) != NULL )
1842  {
1843  if( !strcmp(mpsinputField0(mpsi), "ENDATA") )
1845  break;
1846  }
1847  if( mpsinputField1(mpsi) == NULL || mpsinputField2(mpsi) == NULL )
1848  {
1849  SCIPerrorMessage("empty data in a non-comment line.\n");
1850  mpsinputSyntaxerror(mpsi);
1851  return SCIP_OKAY;
1852  }
1853 
1854  /* check for new indicator constraint */
1855  if( strcmp(mpsinputField1(mpsi), "IF") != 0 )
1856  {
1857  SCIPerrorMessage("Indicator constraints need to be introduced by 'IF' in column 1.\n");
1858  mpsinputSyntaxerror(mpsi);
1859  return SCIP_OKAY;
1860  }
1861 
1862  /* get linear constraint (row) */
1863  lincons = SCIPfindCons(scip, mpsinputField2(mpsi));
1864  if( lincons == NULL )
1865  {
1866  SCIPerrorMessage("row <%s> does not exist.\n", mpsinputField2(mpsi));
1867  mpsinputSyntaxerror(mpsi);
1868  return SCIP_OKAY;
1869  }
1870 
1871  /* check whether constraint is really linear */
1872  conshdlr = SCIPconsGetHdlr(lincons);
1873  if( strcmp(SCIPconshdlrGetName(conshdlr), "linear") != 0 )
1874  {
1875  SCIPerrorMessage("constraint <%s> is not linear.\n", mpsinputField2(mpsi));
1876  mpsinputSyntaxerror(mpsi);
1877  return SCIP_OKAY;
1878  }
1879 
1880  /* get binary variable */
1881  binvar = SCIPfindVar(scip, mpsinputField3(mpsi));
1882  if( binvar == NULL )
1883  {
1884  SCIPerrorMessage("binary variable <%s> does not exist.\n", mpsinputField3(mpsi));
1885  mpsinputSyntaxerror(mpsi);
1886  return SCIP_OKAY;
1887  }
1888 
1889  /* check type */
1890  if( SCIPvarGetType(binvar) != SCIP_VARTYPE_BINARY )
1891  {
1892  SCIPerrorMessage("variable <%s> is not binary.\n", mpsinputField3(mpsi));
1893  mpsinputSyntaxerror(mpsi);
1894  return SCIP_OKAY;
1895  }
1896 
1897  /* check whether we need the negated variable */
1898  if( mpsinputField4(mpsi) != NULL )
1899  {
1900  if( *mpsinputField4(mpsi) == '0' )
1901  {
1902  SCIP_VAR* var;
1903  SCIP_CALL( SCIPgetNegatedVar(scip, binvar, &var) );
1904  binvar = var;
1905  assert( binvar != NULL );
1906  }
1907  else
1908  {
1909  if( *mpsinputField4(mpsi) != '1' )
1910  {
1911  SCIPerrorMessage("binary variable <%s> can only take values 0/1 (%s).\n", mpsinputField3(mpsi), mpsinputField4(mpsi));
1912  mpsinputSyntaxerror(mpsi);
1913  return SCIP_OKAY;
1914  }
1915  }
1916  }
1917 
1918  /* check lhs/rhs */
1919  lhs = SCIPgetLhsLinear(scip, lincons);
1920  rhs = SCIPgetLhsLinear(scip, lincons);
1921  nlinvars = SCIPgetNVarsLinear(scip, lincons);
1922  linvars = SCIPgetVarsLinear(scip, lincons);
1923  linvals = SCIPgetValsLinear(scip, lincons);
1924 
1925  sign = -1.0;
1926  if( !SCIPisInfinity(scip, -lhs) )
1927  {
1928  if( SCIPisInfinity(scip, rhs) )
1929  sign = 1.0;
1930  else
1931  {
1932  if( !SCIPisEQ(scip, lhs, rhs) )
1933  {
1934  SCIPerrorMessage("ranged row <%s> is not allowed in indicator constraints.\n", mpsinputField2(mpsi));
1935  mpsinputSyntaxerror(mpsi);
1936  return SCIP_OKAY;
1937  }
1938  else
1939  {
1940  /* create second indicator constraint */
1941  SCIP_VAR** vars;
1942  SCIP_Real* vals;
1943 
1944  SCIP_CALL( SCIPallocBufferArray(scip, &vars, nlinvars+1) );
1945  SCIP_CALL( SCIPallocBufferArray(scip, &vals, nlinvars+1) );
1946  for( i = 0; i < nlinvars; ++i )
1947  {
1948  vars[i] = linvars[i];
1949  vals[i] = -linvals[i];
1950  }
1951 
1952  /* create new name */
1953  (void) SCIPsnprintf(name, MPS_MAX_NAMELEN, "indlhs_%s", SCIPconsGetName(lincons));
1954 
1955  /* create indicator constraint */
1956  SCIP_CALL( SCIPcreateConsIndicator(scip, &cons, name, binvar, nlinvars+1, vars, vals, -lhs,
1957  initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode) );
1958  SCIP_CALL( SCIPaddCons(scip, cons) );
1959  SCIPdebugMessage("created indicator constraint <%s>\n", mpsinputField2(mpsi));
1960  SCIPdebugPrintCons(scip, cons, NULL);
1961  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
1962 
1963  SCIPfreeBufferArray(scip, &vals);
1964  SCIPfreeBufferArray(scip, &vars);
1965  }
1966  }
1967  }
1968 
1969  /* check if slack variable can be made implicitly integer */
1970  slackvartype = SCIP_VARTYPE_IMPLINT;
1971  for( i = 0; i < nlinvars; ++i )
1972  {
1973  if( !SCIPvarIsIntegral(linvars[i]) || ! SCIPisIntegral(scip, linvals[i]) )
1974  {
1975  slackvartype = SCIP_VARTYPE_CONTINUOUS;
1976  break;
1977  }
1978  }
1979 
1980  /* create slack variable */
1981  (void) SCIPsnprintf(name, MPS_MAX_NAMELEN, "indslack_%s", SCIPconsGetName(lincons));
1982  SCIP_CALL( SCIPcreateVar(scip, &slackvar, name, 0.0, SCIPinfinity(scip), 0.0, slackvartype, TRUE, FALSE,
1983  NULL, NULL, NULL, NULL, NULL) );
1984 
1985  /* add slack variable */
1986  SCIP_CALL( SCIPaddVar(scip, slackvar) );
1987  SCIP_CALL( SCIPaddCoefLinear(scip, lincons, slackvar, sign) );
1988 
1989  /* create new name */
1990  (void) SCIPsnprintf(name, MPS_MAX_NAMELEN, "indlhs_%s", SCIPconsGetName(lincons));
1991 
1992  /* create indicator constraint */
1993  SCIP_CALL( SCIPcreateConsIndicatorLinCons(scip, &cons, name, binvar, lincons, slackvar,
1994  initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode) );
1995 
1996  SCIP_CALL( SCIPaddCons(scip, cons) );
1997  SCIPdebugMessage("created indicator constraint <%s>", mpsinputField2(mpsi));
1998  SCIPdebugPrintCons(scip, cons, NULL);
1999  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
2000  }
2001 
2002  return SCIP_OKAY;
2003 }
2004 
2005 /*
2006  * Local methods
2007  */
2008 
2009 /** Process ROWS, USERCUTS, or LAZYCONS section. */
2010 static
2012  MPSINPUT* mpsi, /**< mps input structure */
2013  SCIP* scip /**< SCIP data structure */
2014  )
2015 {
2016  ProbDataObjectives* probdata;
2017  SCIP_Bool dynamicrows;
2018  SCIP_Bool dynamicconss;
2019 
2020  SCIPdebugMessage("read rows\n");
2021 
2022  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicconss", &dynamicconss) );
2023  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicrows", &dynamicrows) );
2024 
2025  while( mpsinputReadLine(mpsi) )
2026  {
2027  if( mpsinputField0(mpsi) != NULL )
2028  {
2029  if( !strcmp(mpsinputField0(mpsi), "ROWS") )
2031  else if( !strcmp(mpsinputField0(mpsi), "USERCUTS") )
2033  else if( !strcmp(mpsinputField0(mpsi), "LAZYCONS") )
2035  else if( !strcmp(mpsinputField0(mpsi), "COLUMNS") )
2037  else
2038  mpsinputSyntaxerror(mpsi);
2039 
2040  return SCIP_OKAY;
2041  }
2042 
2043  if( *mpsinputField1(mpsi) == 'N' )
2044  {
2045  probdata = dynamic_cast<ProbDataObjectives *>(SCIPgetObjProbData(scip));
2046  probdata->addObjName(mpsinputField2(mpsi));
2047  }
2048  else
2049  {
2050  SCIP_CONS* cons;
2051  SCIP_Bool initial;
2052  SCIP_Bool separate;
2053  SCIP_Bool enforce;
2054  SCIP_Bool check;
2055  SCIP_Bool propagate;
2056  SCIP_Bool local;
2057  SCIP_Bool modifiable;
2058  SCIP_Bool dynamic;
2059  SCIP_Bool removable;
2060 
2061  cons = SCIPfindCons(scip, mpsinputField2(mpsi));
2062  if( cons != NULL )
2063  break;
2064 
2065  initial = !dynamicrows && (mpsinputSection(mpsi) == MPS_ROWS);
2066  separate = TRUE;
2067  enforce = (mpsinputSection(mpsi) != MPS_USERCUTS);
2068  check = (mpsinputSection(mpsi) != MPS_USERCUTS);
2069  propagate = TRUE;
2070  local = FALSE;
2071  modifiable = FALSE;
2072  dynamic = dynamicconss;
2073  removable = dynamicrows || (mpsinputSection(mpsi) == MPS_USERCUTS);
2074 
2075  switch(*mpsinputField1(mpsi))
2076  {
2077  case 'G' :
2078  SCIP_CALL( SCIPcreateConsLinear(scip, &cons, mpsinputField2(mpsi), 0, NULL, NULL, 0.0, SCIPinfinity(scip),
2079  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, FALSE) );
2080  break;
2081  case 'E' :
2082  SCIP_CALL( SCIPcreateConsLinear(scip, &cons, mpsinputField2(mpsi), 0, NULL, NULL, 0.0, 0.0,
2083  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, FALSE) );
2084  break;
2085  case 'L' :
2086  SCIP_CALL( SCIPcreateConsLinear(scip, &cons, mpsinputField2(mpsi), 0, NULL, NULL, -SCIPinfinity(scip), 0.0,
2087  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, FALSE) );
2088  break;
2089  default :
2090  mpsinputSyntaxerror(mpsi);
2091  return SCIP_OKAY;
2092  }
2093  SCIP_CALL( SCIPaddCons(scip, cons) );
2094  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
2095  }
2096  }
2097  mpsinputSyntaxerror(mpsi);
2098 
2099  return SCIP_OKAY;
2100 }
2101 
2102 /** Process COLUMNS section. */
2103 static SCIP_RETCODE readColsMop(MPSINPUT* mpsi, /**< mps input structure */
2104 SCIP* scip /**< SCIP data structure */
2105 )
2106 {
2107  ProbDataObjectives* probdata;
2108  char colname[MPS_MAX_NAMELEN] = { '\0' };
2109  SCIP_CONS* cons;
2110  SCIP_VAR* var;
2111  SCIP_Real val;
2112  SCIP_Bool dynamiccols;
2113 
2114  probdata = dynamic_cast<ProbDataObjectives *>(SCIPgetObjProbData(scip));
2115 
2116  SCIPdebugMessage("read columns\n");
2117 
2118  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamiccols", &dynamiccols));
2119  var = NULL;
2120  while( mpsinputReadLine(mpsi) )
2121  {
2122  if( mpsinputField0(mpsi) != 0 )
2123  {
2124  if( strcmp(mpsinputField0(mpsi), "RHS") )
2125  break;
2126 
2127  /* add the last variable to the problem */
2128  if( var != NULL )
2129  {
2130  SCIP_CALL( SCIPaddVar(scip, var));
2131  SCIP_CALL( SCIPreleaseVar(scip, &var));
2132  }
2133  assert(var == NULL);
2134 
2135  mpsinputSetSection(mpsi, MPS_RHS);
2136  return SCIP_OKAY;
2137  }
2138  if( mpsinputField1(mpsi) == NULL || mpsinputField2(mpsi) == NULL || mpsinputField3(mpsi) == NULL )
2139  break;
2140 
2141  /* new column? */
2142  if( strcmp(colname, mpsinputField1(mpsi)) )
2143  {
2144  /* add the last variable to the problem */
2145  if( var != NULL )
2146  {
2147  SCIP_CALL( SCIPaddVar(scip, var));
2148  SCIP_CALL( SCIPreleaseVar(scip, &var));
2149  }
2150  assert(var == NULL);
2151 
2152  (void)SCIPmemccpy(colname, mpsinputField1(mpsi), '\0', MPS_MAX_NAMELEN - 1);
2153  if( mpsinputIsInteger(mpsi) )
2154  {
2155  /* for integer variables, default bounds are 0 <= x < 1(not +infinity, like it is for continuous variables), and default cost is 0 */
2156  SCIP_CALL(
2157  SCIPcreateVar(scip, &var, colname, 0.0, 1.0, 0.0, SCIP_VARTYPE_BINARY, !dynamiccols, dynamiccols, NULL, NULL, NULL, NULL, NULL));
2158  }
2159  else
2160  {
2161  /* for continuous variables, default bounds are 0 <= x, and default cost is 0 */
2162  SCIP_CALL(
2163  SCIPcreateVar(scip, &var, colname, 0.0, SCIPinfinity(scip), 0.0, SCIP_VARTYPE_CONTINUOUS, !dynamiccols, dynamiccols, NULL, NULL, NULL, NULL, NULL));
2164  }
2165  }
2166  assert(var != NULL);
2167 
2168  val = atof(mpsinputField3(mpsi));
2169 
2170  cons = SCIPfindCons(scip, mpsinputField2(mpsi));
2171  if( cons == NULL )
2172  {
2173  /* row is objective */
2174  probdata->addObjCoeff(var, mpsinputField2(mpsi), val);
2175  //std::cout << "obj : " << mpsinputField2(mpsi) << " val : " << val << "\n";
2176 
2177  }
2178  else if( !SCIPisZero(scip, val) )
2179  {
2180  SCIP_CALL( SCIPaddCoefLinear(scip, cons, var, val));
2181  }
2182 
2183  if( mpsinputField5(mpsi) != NULL )
2184  {
2185  assert(mpsinputField4(mpsi) != NULL);
2186 
2187  val = atof(mpsinputField5(mpsi));
2188 
2189  cons = SCIPfindCons(scip, mpsinputField4(mpsi));
2190  if( cons == NULL )
2191  {
2192  /* row is objective */
2193  probdata->addObjCoeff(var, mpsinputField4(mpsi), val);
2194  //std::cout << "obj : " << mpsinputField4(mpsi) << " val : " << val << "\n";
2195  }
2196  else if( !SCIPisZero(scip, val) )
2197  {
2198  SCIP_CALL( SCIPaddCoefLinear(scip, cons, var, val));
2199  }
2200 
2201  }
2202  }
2203  mpsinputSyntaxerror(mpsi);
2204 
2205  return SCIP_OKAY;
2206 }
2207 
2208 static
2210  SCIP* scip, /**< SCIP data structure */
2211  const char* filename /**< name of the input file */
2212  )
2213 {
2214  SCIP_FILE *fp;
2215 
2216  MPSINPUT* mpsi;
2217  SCIP_Bool error;
2218 
2219  fp = SCIPfopen(filename, "r");
2220 
2221  if( fp == NULL )
2222  {
2223  SCIPerrorMessage("cannot open file <%s> for reading\n", filename);
2224  SCIPprintSysError(filename);
2225  return SCIP_NOFILE;
2226  }
2227 
2228  SCIP_CALL( mpsinputCreate(scip, &mpsi, fp) );
2229 
2230  SCIP_CALL( readName(scip, mpsi) );
2231 
2232  SCIP_CALL( SCIPcreateObjProb(scip, mpsi->probname, new ProbDataObjectives(), TRUE) );
2233 
2234  if( mpsinputSection(mpsi) == MPS_OBJSEN )
2235  {
2236  SCIP_CALL( readObjsen(scip, mpsi) );
2237  }
2238  if( mpsinputSection(mpsi) == MPS_OBJNAME )
2239  {
2240  SCIP_CALL( readObjname(scip, mpsi) );
2241  }
2242  while( mpsinputSection(mpsi) == MPS_ROWS
2243  || mpsinputSection(mpsi) == MPS_USERCUTS
2244  || mpsinputSection(mpsi) == MPS_LAZYCONS )
2245  {
2246  SCIP_CALL( readRowsMop(mpsi, scip) );
2247  }
2248  if( mpsinputSection(mpsi) == MPS_COLUMNS )
2249  {
2250  SCIP_CALL( readColsMop(mpsi, scip) );
2251  }
2252  if( mpsinputSection(mpsi) == MPS_RHS )
2253  {
2254  SCIP_CALL( readRhs(mpsi, scip) );
2255  }
2256  if( mpsinputSection(mpsi) == MPS_RANGES )
2257  {
2258  SCIP_CALL( readRanges(mpsi, scip) );
2259  }
2260  if( mpsinputSection(mpsi) == MPS_BOUNDS )
2261  {
2262  SCIP_CALL( readBounds(mpsi, scip) );
2263  }
2264  if( mpsinputSection(mpsi) == MPS_SOS )
2265  {
2266  SCIP_CALL( readSOS(mpsi, scip) );
2267  }
2268  while( mpsinputSection(mpsi) == MPS_QCMATRIX )
2269  {
2270  SCIP_CALL( readQCMatrix(mpsi, scip) );
2271  }
2272  if( mpsinputSection(mpsi) == MPS_QMATRIX )
2273  {
2274  SCIP_CALL( readQMatrix(mpsi, FALSE, scip) );
2275  }
2276  if( mpsinputSection(mpsi) == MPS_QUADOBJ )
2277  {
2278  SCIP_CALL( readQMatrix(mpsi, TRUE, scip) );
2279  }
2280  while( mpsinputSection(mpsi) == MPS_QCMATRIX )
2281  {
2282  SCIP_CALL( readQCMatrix(mpsi, scip) );
2283  }
2284  if( mpsinputSection(mpsi) == MPS_INDICATORS )
2285  {
2286  SCIP_CALL( readIndicators(mpsi, scip) );
2287  }
2288  if( mpsinputSection(mpsi) != MPS_ENDATA )
2289  mpsinputSyntaxerror(mpsi);
2290 
2291  SCIPfclose(fp);
2292 
2293  error = mpsinputHasError(mpsi);
2294 
2295  if( !error )
2296  {
2297  SCIP_CALL( SCIPsetObjsense(scip, mpsinputObjsense(mpsi)) );
2298  }
2299  mpsinputFree(scip, &mpsi);
2300 
2301  if( error )
2302  return SCIP_READERROR;
2303  else
2304  return SCIP_OKAY;
2305 }
2306 
2307 
2308 /** destructor of file reader to free user data (called when SCIP is exiting) */
2309 SCIP_DECL_READERFREE(ReaderMOP::scip_free) {
2310  return SCIP_OKAY;
2311 }
2312 
2313 /** problem reading method of reader */
2314 SCIP_DECL_READERREAD(ReaderMOP::scip_read) {
2315  assert(reader != NULL);
2316  assert(scip != NULL);
2317  assert(result != NULL);
2318  assert(filename != NULL);
2319 
2320  SCIP_RETCODE retcode;
2321  retcode = readMOP(scip, filename);
2322 
2323  if( retcode == SCIP_NOFILE || retcode == SCIP_READERROR )
2324  return retcode;
2325 
2326  SCIP_CALL( retcode );
2327 
2328  *result = SCIP_SUCCESS;
2329 
2330  return SCIP_OKAY;
2331 }
2332 
2333 
2334 
static SCIP_RETCODE readRanges(MPSINPUT *mpsi, SCIP *scip)
Definition: ReaderMOP.cpp:851
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
#define MPS_MAX_NAMELEN
global define
Definition: ReaderMOP.cpp:51
int SCIPmemccpy(char *dest, const char *src, char stop, unsigned int cnt)
Definition: misc.c:10639
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
Definition: cons.c:8344
Constraint handler for variable bound constraints .
Class storing multiple objectives of given problem instance.
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17910
#define SCIP_MAXSTRLEN
Definition: def.h:293
static SCIP_RETCODE readRowsMop(MPSINPUT *mpsi, SCIP *scip)
Definition: ReaderMOP.cpp:2011
SCIP_RETCODE SCIPdelCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2842
int SCIPcalcMemGrowSize(SCIP *scip, int num)
Definition: scip_mem.c:130
SCIP_RETCODE SCIPaddVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
Definition: cons_sos2.c:2450
static void mpsinputSetProbname(MPSINPUT *mpsi, const char *probname)
Definition: ReaderMOP.cpp:280
static SCIP_Bool mpsinputReadLine(MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:389
static void mpsinputSetSection(MPSINPUT *mpsi, MPSSECTION section)
Definition: ReaderMOP.cpp:268
void addObjCoeff(SCIP_VAR *var, const char *obj_name, polyscip::ValueType val)
static SCIP_RETCODE readObjname(SCIP *scip, MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:688
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1245
static void patchField(char *buf, int beg, int end)
Definition: ReaderMOP.cpp:368
constraint handler for indicator constraints
#define FALSE
Definition: def.h:87
static SCIP_RETCODE readColsMop(MPSINPUT *mpsi, SCIP *scip)
Definition: ReaderMOP.cpp:2103
SCIP_Real SCIPinfinity(SCIP *scip)
static const char * mpsinputField2(const MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:191
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10755
void addObjName(const char *name)
#define TRUE
Definition: def.h:86
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
static SCIP_OBJSENSE mpsinputObjsense(const MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:235
enum SCIP_VerbLevel SCIP_VERBLEVEL
Definition: type_message.h:48
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:99
#define SCIPdebugMessage
Definition: pub_message.h:87
SCIP_RETCODE SCIPchgVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip_var.c:4673
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:127
Constraint handler for the set partitioning / packing / covering constraints .
#define SCIPdebugPrintCons(x, y, z)
Definition: pub_message.h:93
static const char * mpsinputField4(const MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:213
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
Definition: cons.c:8354
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:111
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
static const char * mpsinputField0(const MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:169
static SCIP_RETCODE readObjsen(SCIP *scip, MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:636
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
Definition: scip_prob.c:2684
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
Definition: scip_var.c:8173
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
Definition: fileio.c:144
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17920
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
Definition: scip_prob.c:1241
Constraint handler for knapsack constraints of the form , x binary and .
#define SCIPerrorMessage
Definition: pub_message.h:55
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4175
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2769
static const char * mpsinputField5(const MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:224
SCIP_RETCODE SCIPaddVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
Definition: cons_sos1.c:10513
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
static SCIP_Bool mpsinputIsInteger(const MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:257
static MPSSECTION mpsinputSection(const MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:158
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip_mem.h:128
struct SCIP_File SCIP_FILE
Definition: pub_fileio.h:34
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
Definition: fileio.c:191
SCIP_RETCODE SCIPcreateConsQuadraticNonlinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nquadterms, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoefs, 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)
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8085
SCIP_RETCODE SCIPchgVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip_var.c:4763
SCIP_RETCODE SCIPcreateConsBounddisjunction(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_BOUNDTYPE *boundtypes, SCIP_Real *bounds, 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 SCIPconsIsPropagated(SCIP_CONS *cons)
Definition: cons.c:8304
struct SparseMatrix SPARSEMATRIX
Definition: reader_mps.c:152
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17251
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip_param.c:241
SCIP_CONS * SCIPfindCons(SCIP *scip, const char *name)
Definition: scip_prob.c:2946
#define NULL
Definition: lpi_spx1.cpp:155
C++ wrapper classes for SCIP.
#define REALABS(x)
Definition: def.h:201
static SCIP_RETCODE readSOS(MPSINPUT *mpsi, SCIP *scip)
Definition: ReaderMOP.cpp:1262
#define SCIP_CALL(x)
Definition: def.h:384
static SCIP_RETCODE readQCMatrix(MPSINPUT *mpsi, SCIP *scip)
Definition: ReaderMOP.cpp:1628
static void mpsinputSetObjname(MPSINPUT *mpsi, const char *objname)
Definition: ReaderMOP.cpp:294
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip_message.c:216
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
Definition: cons.c:8324
SCIP_DECL_READERREAD(ReaderMOP::scip_read)
Definition: ReaderMOP.cpp:2314
static SCIP_RETCODE readBounds(MPSINPUT *mpsi, SCIP *scip)
Definition: ReaderMOP.cpp:987
static SCIP_RETCODE readIndicators(MPSINPUT *mpsi, SCIP *scip)
Definition: ReaderMOP.cpp:1794
static SCIP_RETCODE readQMatrix(MPSINPUT *mpsi, SCIP_Bool isQuadObj, SCIP *scip)
Definition: ReaderMOP.cpp:1449
static const char * mpsinputField1(const MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:180
SCIP_DECL_READERFREE(ReaderMOP::scip_free)
Definition: ReaderMOP.cpp:2309
enum MpsSection MPSSECTION
typedef
Definition: ReaderMOP.cpp:78
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:115
public data structures and miscellaneous methods
#define SCIP_Bool
Definition: def.h:84
SCIP_RETCODE SCIPcreateConsIndicatorLinCons(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *binvar, SCIP_CONS *lincons, SCIP_VAR *slackvar, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
.mop file format reader
void SCIPprintSysError(const char *message)
Definition: misc.c:10664
enum SCIP_Objsense SCIP_OBJSENSE
Definition: type_prob.h:41
static SCIP_RETCODE readMOP(SCIP *scip, const char *filename)
Definition: ReaderMOP.cpp:2209
constraint handler for nonlinear constraints specified by algebraic expressions
static void mpsinputInsertName(MPSINPUT *mpsi, const char *name, SCIP_Bool second)
Definition: ReaderMOP.cpp:565
static SCIP_RETCODE readName(SCIP *scip, MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:589
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8105
#define BLANK
global define
Definition: ReaderMOP.cpp:56
static void mpsinputSetObjsense(MPSINPUT *mpsi, SCIP_OBJSENSE sense)
Definition: ReaderMOP.cpp:308
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8284
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
Definition: cons.c:8254
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:105
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPchgRhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real rhs)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
static long * number
scip::ObjProbData * SCIPgetObjProbData(SCIP *scip)
#define PATCH_CHAR
global define
Definition: ReaderMOP.cpp:55
Stores coefficients and basic methods for objectives of given multi-objective problem.
SCIP_RETCODE SCIPcreateConsIndicator(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *binvar, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
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)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE readRhs(MPSINPUT *mpsi, SCIP *scip)
Definition: ReaderMOP.cpp:726
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_prob.c:1667
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
struct MpsInput MPSINPUT
Definition: reader_mps.c:141
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1110
static void mpsinputFree(SCIP *scip, MPSINPUT **mpsi)
Definition: ReaderMOP.cpp:148
#define SCIP_Real
Definition: def.h:177
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
Definition: cons.c:8334
SCIP_RETCODE SCIPcreateObjProb(SCIP *scip, const char *name, scip::ObjProbData *objprobdata, SCIP_Bool deleteobject)
constraint handler for SOS type 1 constraints
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
Definition: cons.c:8274
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
Definition: cons.c:8264
static SCIP_RETCODE mpsinputCreate(SCIP *scip, MPSINPUT **mpsi, SCIP_FILE *fp)
Definition: ReaderMOP.cpp:115
static void mpsinputEntryIgnored(SCIP *scip, MPSINPUT *mpsi, const char *what, const char *what_name, const char *entity, const char *entity_name, SCIP_VERBLEVEL verblevel)
Definition: ReaderMOP.cpp:332
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17416
enum MpsSection MPSSECTION
Definition: reader_mps.c:115
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPcreateConsSOS1(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
Definition: cons_sos1.c:10376
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:60
constraint handler for SOS type 2 constraints
SCIP_RETCODE SCIPcreateConsSOS2(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
Definition: cons_sos2.c:2351
SCIP_RETCODE SCIPchgLhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real lhs)
MpsSection
Definition: reader_mps.c:96
SCIPallocBlockMemory(scip, subsol))
int SCIPfclose(SCIP_FILE *fp)
Definition: fileio.c:223
static SCIP_Bool mpsinputHasError(const MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:246
static void clearFrom(char *buf, unsigned int pos)
Definition: ReaderMOP.cpp:354
constraint handler for bound disjunction constraints
#define SCIPABORT()
Definition: def.h:356
#define MPS_MAX_LINELEN
global define
Definition: ReaderMOP.cpp:50
static void mpsinputSyntaxerror(MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:319
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:17442
char * SCIPstrtok(char *s, const char *delim, char **ptrptr)
Definition: misc.c:10713
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
static const char * mpsinputField3(const MPSINPUT *mpsi)
Definition: ReaderMOP.cpp:202
SCIP_RETCODE SCIPgetNegatedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **negvar)
Definition: scip_var.c:1524
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:119