reader_dec.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program */
4 /* GCG --- Generic Column Generation */
5 /* a Dantzig-Wolfe decomposition based extension */
6 /* of the branch-cut-and-price framework */
7 /* SCIP --- Solving Constraint Integer Programs */
8 /* */
9 /* Copyright (C) 2010-2018 Operations Research, RWTH Aachen University */
10 /* Zuse Institute Berlin (ZIB) */
11 /* */
12 /* This program is free software; you can redistribute it and/or */
13 /* modify it under the terms of the GNU Lesser General Public License */
14 /* as published by the Free Software Foundation; either version 3 */
15 /* of the License, or (at your option) any later version. */
16 /* */
17 /* This program is distributed in the hope that it will be useful, */
18 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
19 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
20 /* GNU Lesser General Public License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with this program; if not, write to the Free Software */
24 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/
25 /* */
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
37 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
38 
39 #include <assert.h>
40 #include <string.h>
41 #if defined(_WIN32) || defined(_WIN64)
42 #else
43 #include <strings.h> /*lint --e{766}*/ /* needed for strcasecmp() */
44 #endif
45 #include <ctype.h>
46 
47 #include "reader_dec.h"
48 #include "scip_misc.h"
49 #include "pub_gcgvar.h"
50 
51 #include "cons_decomp.h"
52 #include "pub_decomp.h"
53 
54 #include "class_seeed.h"
55 
57 
58 #define READER_NAME "decreader"
59 #define READER_DESC "file reader for blocks in dec format"
60 #define READER_EXTENSION "dec"
61 
62 
63 /*
64  * Data structures
65  */
66 #define DEC_MAX_LINELEN 65536
67 #define DEC_MAX_PUSHEDTOKENS 2
68 
71 {
73 };
74 typedef enum DecSection DECSECTION;
75 
78 {
80 };
81 typedef enum DecExpType DECEXPTYPE;
82 
84 struct DecInput
85 {
86  SCIP_FILE* file;
88  char* token;
89  char* tokenbuf;
92  int linenumber;
93  int linepos;
94  SCIP_Bool presolved;
95  SCIP_Bool haspresolvesection;
96  SCIP_Bool incomplete;
97  int nblocks;
98  int blocknr;
100  SCIP_Bool haserror;
102 };
103 typedef struct DecInput DECINPUT;
104 
106 struct SCIP_ReaderData
107 {
108  SCIP_HASHMAP* constoblock;
109 };
110 static const int NOVALUE = -1;
111 static const int LINKINGVALUE = -2;
112 static const char delimchars[] = " \f\n\r\t\v";
113 static const char tokenchars[] = "-+:<>=";
114 static const char commentchars[] = "\\";
115 
116 
117 
118 
119 /*
120  * Local methods (for reading)
121  */
122 
124 static
126  SCIP* scip,
127  DECINPUT* decinput,
128  const char* msg
129  )
130 {
131  char formatstr[256];
132 
133  assert(decinput != NULL);
134 
135  SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, "Syntax error in line %d: %s ('%s')\n",
136  decinput->linenumber, msg, decinput->token);
137  if( decinput->linebuf[strlen(decinput->linebuf) - 1] == '\n' )
138  {
139  SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, " input: %s", decinput->linebuf);
140  }
141  else
142  {
143  SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, " input: %s\n", decinput->linebuf);
144  }
145  (void) SCIPsnprintf(formatstr, 256, " %%%ds\n", decinput->linepos);
146  SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, formatstr, "^");
147  decinput->section = DEC_END;
148  decinput->haserror = TRUE;
149 }
150 
152 static
153 SCIP_Bool hasError(
154  DECINPUT* decinput
155  )
156 {
157  assert(decinput != NULL);
158 
159  return decinput->haserror;
160 }
161 
163 static
164 SCIP_Bool isDelimChar(
165  char c
166  )
167 {
168  return (c == '\0') || (strchr(delimchars, c) != NULL);
169 }
170 
172 static
173 SCIP_Bool isTokenChar(
174  char c
175  )
176 {
177  return (strchr(tokenchars, c) != NULL);
178 }
179 
181 static
182 SCIP_Bool isValueChar(
183  char c,
184  char nextc,
185  SCIP_Bool firstchar,
186  SCIP_Bool* hasdot,
187  DECEXPTYPE* exptype
188  )
189 { /*lint --e{715}*/
190  assert(hasdot != NULL);
191  assert(exptype != NULL);
192 
193  if( isdigit(c) )
194  return TRUE;
195 
196  return FALSE;
197 }
198 
202 static
203 SCIP_Bool getNextLine(
204  DECINPUT* decinput
205  )
206 {
207  int i;
208 
209  assert(decinput != NULL);
210 
211  /* clear the line */
212  BMSclearMemoryArray(decinput->linebuf, DEC_MAX_LINELEN);
213 
214  /* read next line */
215  decinput->linepos = 0;
216  decinput->linebuf[DEC_MAX_LINELEN - 2] = '\0';
217  if( SCIPfgets(decinput->linebuf, DEC_MAX_LINELEN, decinput->file) == NULL )
218  return FALSE;
219  decinput->linenumber ++;
220  if( decinput->linebuf[DEC_MAX_LINELEN - 2] != '\0' )
221  {
222  SCIPerrorMessage("Error: line %d exceeds %d characters\n", decinput->linenumber, DEC_MAX_LINELEN - 2);
223  decinput->haserror = TRUE;
224  return FALSE;
225  }
226  decinput->linebuf[DEC_MAX_LINELEN - 1] = '\0';
227  decinput->linebuf[DEC_MAX_LINELEN - 2] = '\0'; /* we want to use lookahead of one char -> we need two \0 at the end */
228 
229  /* skip characters after comment symbol */
230  for( i = 0; commentchars[i] != '\0'; ++ i )
231  {
232  char* commentstart;
233 
234  commentstart = strchr(decinput->linebuf, commentchars[i]);
235  if( commentstart != NULL )
236  {
237  *commentstart = '\0';
238  *(commentstart + 1) = '\0'; /* we want to use lookahead of one char -> we need two \0 at the end */
239  }
240  }
241 
242  return TRUE;
243 }
244 
246 static
248  char** pointer1,
249  char** pointer2
250  )
251 {
252  char* tmp;
253 
254  tmp = * pointer1;
255  *pointer1 = * pointer2;
256  *pointer2 = tmp;
257 }
258 
260 static
261 SCIP_Bool getNextToken(
262  DECINPUT* decinput
263  )
264 {
265  SCIP_Bool hasdot;
266  DECEXPTYPE exptype;
267  char* buf;
268  int tokenlen;
269 
270  assert(decinput != NULL);
271  assert(decinput->linepos < DEC_MAX_LINELEN);
272 
273  /* check the token stack */
274  if( decinput->npushedtokens > 0 )
275  {
276  swapPointers(&decinput->token, &decinput->pushedtokens[decinput->npushedtokens - 1]);
277  decinput->npushedtokens --;
278  SCIPdebugMessage("(line %d) read token again: '%s'\n", decinput->linenumber, decinput->token);
279  return TRUE;
280  }
281 
282  /* skip delimiters */
283  buf = decinput->linebuf;
284  while( isDelimChar(buf[decinput->linepos]) )
285  {
286  if( buf[decinput->linepos] == '\0' )
287  {
288  if( ! getNextLine(decinput) )
289  {
290  decinput->section = DEC_END;
291  SCIPdebugMessage("(line %d) end of file\n", decinput->linenumber);
292  return FALSE;
293  }
294  assert(decinput->linepos == 0);
295  }
296  else
297  decinput->linepos ++;
298  }
299  assert(decinput->linepos < DEC_MAX_LINELEN);
300  assert(! isDelimChar(buf[decinput->linepos]));
301 
302  /* check if the token is a value */
303  hasdot = FALSE;
304  exptype = DEC_EXP_NONE;
305  if( isValueChar(buf[decinput->linepos], buf[decinput->linepos + 1], TRUE, &hasdot, &exptype) ) /*lint !e679*/
306  {
307  /* read value token */
308  tokenlen = 0;
309  do
310  {
311  assert(tokenlen < DEC_MAX_LINELEN);
312  assert(! isDelimChar(buf[decinput->linepos]));
313  decinput->token[tokenlen] = buf[decinput->linepos];
314  ++tokenlen;
315  ++(decinput->linepos);
316  assert(decinput->linepos < DEC_MAX_LINELEN-1);
317  }
318  while( isValueChar(buf[decinput->linepos], buf[decinput->linepos + 1], FALSE, &hasdot, &exptype) ); /*lint !e679*/
319  }
320  else
321  {
322  /* read non-value token */
323  tokenlen = 0;
324  do
325  {
326  assert(tokenlen < DEC_MAX_LINELEN);
327  decinput->token[tokenlen] = buf[decinput->linepos];
328  tokenlen ++;
329  decinput->linepos ++;
330  if( tokenlen == 1 && isTokenChar(decinput->token[0]) )
331  break;
332  }
333  while( ! isDelimChar(buf[decinput->linepos]) && ! isTokenChar(buf[decinput->linepos]) );
334 
335  /* if the token is an equation sense '<', '>', or '=', skip a following '='
336  * if the token is an equality token '=' and the next character is a '<' or '>', replace the token by the inequality sense
337  */
338  if( tokenlen >= 1
339  && (decinput->token[tokenlen - 1] == '<' || decinput->token[tokenlen - 1] == '>' || decinput->token[tokenlen - 1] == '=')
340  && buf[decinput->linepos] == '=' )
341  {
342  decinput->linepos ++;
343  }
344  else if( decinput->token[tokenlen - 1] == '=' && (buf[decinput->linepos] == '<' || buf[decinput->linepos] == '>') )
345  {
346  decinput->token[tokenlen - 1] = buf[decinput->linepos];
347  decinput->linepos ++;
348  }
349  }
350  assert(tokenlen < DEC_MAX_LINELEN);
351  decinput->token[tokenlen] = '\0';
352 
353  SCIPdebugMessage("(line %d) read token: '%s'\n", decinput->linenumber, decinput->token);
354 
355  return TRUE;
356 }
357 
359 static
361  DECINPUT* decinput
362  )
363 {
364  assert(decinput != NULL);
365  assert(decinput->npushedtokens < DEC_MAX_PUSHEDTOKENS);
366 
367  swapPointers(&decinput->pushedtokens[decinput->npushedtokens], &decinput->token);
368  decinput->npushedtokens ++;
369 }
370 
372 static
374  DECINPUT* decinput
375  )
376 {
377  assert(decinput != NULL);
378 
379  swapPointers(&decinput->token, &decinput->tokenbuf);
380 }
381 
383 static
384 SCIP_Bool isInt(
385  SCIP* scip,
386  DECINPUT* decinput,
387  int* value
388  )
389 {
390  long val;
391  char* endptr;
392 
393  assert(decinput != NULL);
394  assert(value != NULL);
395  assert(!(strcasecmp(decinput->token, "INFINITY") == 0) && !(strcasecmp(decinput->token, "INF") == 0));
396 
397  val = strtol(decinput->token, &endptr, 0);
398  if( endptr != decinput->token && * endptr == '\0' )
399  {
400  if( val < INT_MIN || val > INT_MAX ) /*lint !e685*/
401  return FALSE;
402 
403  *value = (int) val;
404  return TRUE;
405  }
406 
407  return FALSE;
408 }
409 
411 static
412 SCIP_Bool isNewSection(
413  SCIP* scip,
414  DECINPUT* decinput
415  )
416 {
417 
418  assert(decinput != NULL);
419 
420  /* remember first token by swapping the token buffer */
421  swapTokenBuffer(decinput);
422 
423  /* look at next token: if this is a ':', the first token is a name and no section keyword */
424  if( getNextToken(decinput) )
425  {
426  pushToken(decinput);
427  }
428 
429  /* reinstall the previous token by swapping back the token buffer */
430  swapTokenBuffer(decinput);
431 
432  if( strcasecmp(decinput->token, "INCOMPLETE") == 0 )
433  {
434  SCIPdebugMessage("(line %d) new section: INCOMPLETE\n", decinput->linenumber);
435  decinput->section = DEC_INCOMPLETE;
436  return TRUE;
437  }
438 
439  if( strcasecmp(decinput->token, "PRESOLVED") == 0 )
440  {
441  SCIPdebugMessage("(line %d) new section: PRESOLVED\n", decinput->linenumber);
442  decinput->section = DEC_PRESOLVED;
443  return TRUE;
444  }
445 
446  if( strcasecmp(decinput->token, "NBLOCKS") == 0 )
447  {
448  SCIPdebugMessage("(line %d) new section: NBLOCKS\n", decinput->linenumber);
449  decinput->section = DEC_NBLOCKS;
450  return TRUE;
451  }
452 
453  if( strcasecmp(decinput->token, "BLOCK") == 0 || strcasecmp(decinput->token, "BLOCKCONSS") == 0 || strcasecmp(decinput->token, "BLOCKCONS") == 0)
454  {
455  int blocknr;
456 
457  decinput->section = DEC_BLOCKCONSS;
458 
459  if( getNextToken(decinput) )
460  {
461  /* read block number */
462  if( isInt(scip, decinput, &blocknr) )
463  {
464  assert(blocknr >= 0);
465  assert(blocknr <= decinput->nblocks);
466 
467  decinput->blocknr = blocknr - 1;
468  }
469  else
470  syntaxError(scip, decinput, "no block number after block keyword!\n");
471  }
472  else
473  syntaxError(scip, decinput, "no block number after block keyword!\n");
474 
475  SCIPdebugMessage("new section: BLOCKCONSS %d\n", decinput->blocknr);
476 
477  return TRUE;
478 
479  }
480 
481  if( strcasecmp(decinput->token, "MASTERCONSS") == 0 || strcasecmp(decinput->token, "MASTERCONS") == 0 )
482  {
483  decinput->section = DEC_MASTERCONSS;
484 
485  SCIPdebugMessage("new section: MASTERCONSS\n");
486 
487  return TRUE;
488  }
489 
490  if( strcasecmp(decinput->token, "BLOCKVARS") == 0 || strcasecmp(decinput->token, "BLOCKVAR") == 0 )
491  {
492  int blocknr;
493 
494  decinput->section = DEC_BLOCKVARS;
495 
496  if( getNextToken(decinput) )
497  {
498  /* read block number */
499  if( isInt(scip, decinput, &blocknr) )
500  {
501  assert(blocknr >= 0);
502  assert(blocknr <= decinput->nblocks);
503 
504  decinput->blocknr = blocknr - 1;
505  }
506  else
507  syntaxError(scip, decinput, "no block number after block keyword!\n");
508  }
509  else
510  syntaxError(scip, decinput, "no block number after block keyword!\n");
511 
512  SCIPdebugMessage("new section: BLOCKVARS %d\n", decinput->blocknr);
513 
514  return TRUE;
515 
516  }
517 
518  if( strcasecmp(decinput->token, "MASTERVARS") == 0 || strcasecmp(decinput->token, "MASTERVAR") == 0 )
519  {
520  decinput->section = DEC_MASTERVARS;
521 
522  SCIPdebugMessage("new section: MASTERVARS\n");
523 
524  return TRUE;
525  }
526 
527  if( strcasecmp(decinput->token, "LINKINGVARS") == 0 || strcasecmp(decinput->token, "LINKINGVAR") == 0 )
528  {
529  decinput->section = DEC_LINKINGVARS;
530 
531  SCIPdebugMessage("new section: LINKINGVARS\n");
532 
533  return TRUE;
534  }
535 
536 
537 
538  return FALSE;
539 }
540 
542 static
543 SCIP_RETCODE readStart(
544  SCIP* scip,
545  DECINPUT* decinput
546  )
547 {
548  assert(decinput != NULL);
549 
550  /* everything before first section is treated as comment */
551  do
552  {
553  /* get token */
554  if( ! getNextToken(decinput) )
555  return SCIP_OKAY;
556  }
557  while( ! isNewSection(scip, decinput) );
558 
559  return SCIP_OKAY;
560 }
561 
563 static
564 SCIP_RETCODE readIncomplete(
565  SCIP* scip,
566  DECINPUT* decinput
567  )
568 {
569  int incomplete;
570 
571  assert(scip != NULL);
572  assert(decinput != NULL);
573 
574  while( getNextToken(decinput) )
575  {
576  /* check if we reached a new section */
577  if( isNewSection(scip, decinput) )
578  return SCIP_OKAY;
579 
580  /* read if the consdefaultmaster */
581  if( isInt(scip, decinput, &incomplete) )
582  {
583  if( incomplete == 1 )
584  decinput->incomplete = TRUE;
585  else if ( incomplete == 0 )
586  decinput->incomplete = FALSE;
587  else
588  syntaxError(scip, decinput, "incomplete parameter must be 0 or 1");
589  SCIPdebugMessage("The constraints that are not specified in this decomposition are %s forced to the master\n",
590  decinput->incomplete ? "" : " not");
591  }
592  }
593 
594  return SCIP_OKAY;
595 }
596 
597 
598 
600 static
601 SCIP_RETCODE readPresolved(
602  SCIP* scip,
603  DECINPUT* decinput
604  )
605 {
606  int presolved;
607 
608  assert(scip != NULL);
609  assert(decinput != NULL);
610 
611  while( getNextToken(decinput) )
612  {
613  /* check if we reached a new section */
614  if( isNewSection(scip, decinput) )
615  return SCIP_OKAY;
616 
617  /* read number of blocks */
618  if( isInt(scip, decinput, &presolved) )
619  {
620  decinput->haspresolvesection = TRUE;
621  if( presolved == 1 )
622  {
623  decinput->presolved = TRUE;
624  }
625  else if ( presolved == 0 )
626  {
627  decinput->presolved = FALSE;
628 
629  }
630  else
631  syntaxError(scip, decinput, "presolved parameter must be 0 or 1");
632  SCIPdebugMessage("Decomposition is%s from presolved problem\n",
633  decinput->presolved ? "" : " not");
634  }
635  }
636 
637  return SCIP_OKAY;
638 }
639 
641 static
642 SCIP_RETCODE readNBlocks(
643  SCIP* scip,
644  DECINPUT* decinput
645  )
646 {
647  int nblocks;
648 
649  assert(scip != NULL);
650  assert(decinput != NULL);
651 
652  while( getNextToken(decinput) )
653  {
654  /* check if we reached a new section */
655  if( isNewSection(scip, decinput) )
656  {
657  if( decinput->nblocks == NOVALUE )
658  syntaxError(scip, decinput, "no integer value in nblocks section");
659  else
660  return SCIP_OKAY;
661  }
662 
663  /* read number of blocks */
664  if( isInt(scip, decinput, &nblocks) )
665  {
666  if( decinput->nblocks == NOVALUE )
667  {
668  decinput->nblocks = nblocks;
670  }
671  else
672  syntaxError(scip, decinput, "2 integer values in nblocks section");
673  SCIPdebugMessage("Number of blocks = %d\n", decinput->nblocks);
674  }
675  }
676 
677  return SCIP_OKAY;
678 }
679 
681 static
682 SCIP_RETCODE readBlockconss(
683  SCIP* scip,
684  DECINPUT* decinput,
685  SCIP_READERDATA* readerdata
686  )
687 {
688  int blockid;
689 
690  SCIP_Bool success;
691  assert(decinput != NULL);
692  assert(readerdata != NULL);
693 
694  while( getNextToken(decinput) )
695  {
696  int i;
697  SCIP_CONS* cons;
698  SCIP_VAR** curvars = NULL;
699  int ncurvars;
700 
701  SCIP_Bool conshasvar = FALSE;
702  /* check if we reached a new section */
703  if( isNewSection(scip, decinput) )
704  break;
705 
706  /* the token must be the name of an existing cons */
707  cons = SCIPfindCons(scip, decinput->token);
708  if( cons == NULL )
709  {
710  syntaxError(scip, decinput, "unknown constraint in block section");
711  decinput->haserror = TRUE;
712  break;
713  }
714 
715  if( !SCIPconsIsActive(cons) )
716  {
717  assert( !SCIPhashmapExists(readerdata->constoblock, cons));
718  continue;
719  }
720 
721  /* get all curvars for the specific constraint */
722  SCIP_CALL( SCIPgetConsNVars(scip, cons, &ncurvars, &success) );
723  assert(success);
724  if( ncurvars > 0 )
725  {
726  SCIP_CALL( SCIPallocBufferArray(scip, &curvars, ncurvars) );
727  SCIP_CALL( SCIPgetConsVars(scip, cons, curvars, ncurvars, &success) );
728  assert(success);
729  }
730 
731  blockid = decinput->blocknr;
732 
733  for( i = 0; i < ncurvars; i ++ )
734  {
735  assert(curvars != NULL); /* for flexelint */
736  if( decinput->presolved )
737  {
738  SCIP_VAR* var = SCIPvarGetProbvar(curvars[i]);
739  if( !GCGisVarRelevant(var) )
740  continue;
741  }
742 
743  conshasvar = TRUE;
744  }
745 
746  SCIPfreeBufferArrayNull(scip, &curvars);
747 
748  if( !conshasvar )
749  {
750 // SCIP_CALL( SCIPhashmapSetImage(readerdata->constoblock, cons, (void*) (size_t) (blockid+1)) );
751 // SCIP_CALL(SCIPconshdlrDecompUserSeeedSetConsToBlock(scip, decinput->token, blockid) );
752  SCIPwarningMessage(scip, "Cons <%s> has been deleted by presolving or has no variable at all, skipped.\n", SCIPconsGetName(cons) );
753  continue;
754  }
755  /*
756  * saving block <-> constraint
757  */
758 
759  if( SCIPhashmapGetImage(readerdata->constoblock, cons) != (void*)(size_t) LINKINGVALUE )
760  {
761  decinput->haserror = TRUE;
762  SCIPinfoMessage(scip, NULL,"cons %s is already assigned\n", SCIPconsGetName(cons) );
763  return SCIP_OKAY;
764  }
765 
766  SCIPdebugMessage("cons %s is in block %d\n", SCIPconsGetName(cons), blockid);
767  SCIP_CALL( SCIPhashmapSetImage(readerdata->constoblock, cons, (void*) (size_t) (blockid+1)) );
768  SCIP_CALL(SCIPconshdlrDecompUserSeeedSetConsToBlock(scip, decinput->token, blockid) );
769  }
770 
771  return SCIP_OKAY;
772 }
773 
775 static
776 SCIP_RETCODE readBlockvars(
777  SCIP* scip,
778  DECINPUT* decinput,
779  SCIP_READERDATA* readerdata
780  )
781 {
782  int blockid;
783 
784  assert(decinput != NULL);
785  assert(readerdata != NULL);
786 
787  while( getNextToken(decinput) )
788  {
789  SCIP_Var* var;
790 // SCIP_VAR** curvars = NULL;
791 // int ncurvars;
792 
793 // SCIP_Bool conshasvar = FALSE;
794  /* check if we reached a new section */
795  if( isNewSection(scip, decinput) )
796  break;
797 
798  /* the token must be the name of an existing cons */
799  var = SCIPfindVar(scip, decinput->token);
800  if( var == NULL )
801  {
802  syntaxError(scip, decinput, "unknown variable in block section");
803  break;
804  }
805 
806  if( !SCIPvarIsActive(var) )
807  {
808  SCIPwarningMessage(scip, "Var <%s> has been fixed or aggregated by presolving, skipping.\n", SCIPvarGetName(var));
809  continue;
810  }
811 
812 
813  blockid = decinput->blocknr;
814 
815 
816  SCIPconshdlrDecompUserSeeedSetVarToBlock(scip, decinput->token, blockid);
817 
818  }
819 
820  return SCIP_OKAY;
821 }
822 
823 
824 
826 static
827 SCIP_RETCODE readMasterconss(
828  SCIP* scip,
829  DECINPUT* decinput,
830  SCIP_READERDATA* readerdata
831  )
832 {
833  assert(scip != NULL);
834  assert(decinput != NULL);
835  assert(readerdata != NULL);
836 
837  while( getNextToken(decinput) )
838  {
839  SCIP_CONS* cons;
840 
841  /* check if we reached a new section */
842  if( isNewSection(scip, decinput) )
843  break;
844 
845  /* the token must be the name of an existing constraint */
846  cons = SCIPfindCons(scip, decinput->token);
847  if( cons == NULL )
848  {
849  syntaxError(scip, decinput, "unknown constraint in masterconss section");
850  break;
851  }
852  else
853  {
854  if( !SCIPhashmapExists( readerdata->constoblock, cons) )
855  {
856  SCIPwarningMessage(scip, "Cons <%s> has been deleted by presolving, skipping.\n", SCIPconsGetName(cons));
857  continue;
858  }
859 
860  assert(SCIPhashmapGetImage(readerdata->constoblock, cons) == (void*) (size_t) LINKINGVALUE);
861 
863  SCIPdebugMessage("cons %s is linking constraint\n", decinput->token);
864  }
865  }
866 
867  return SCIP_OKAY;
868 }
869 
871 static
872 SCIP_RETCODE readMastervars(
873  SCIP* scip,
874  DECINPUT* decinput,
875  SCIP_READERDATA* readerdata
876  )
877 {
878  assert(scip != NULL);
879  assert(decinput != NULL);
880  assert(readerdata != NULL);
881 
882  while( getNextToken(decinput) )
883  {
884  SCIP_VAR* var;
885 
886  /* check if we reached a new section */
887  if( isNewSection(scip, decinput) )
888  break;
889 
890  /* the token must be the name of an existing constraint */
891  var = SCIPfindVar(scip, decinput->token);
892  if( var == NULL )
893  {
894  syntaxError(scip, decinput, "unknown constraint in mastervars section");
895  break;
896  }
897  else
898  {
899  if( !SCIPvarIsActive(var) )
900  {
901  SCIPwarningMessage(scip, "Var <%s> has been fixed or aggregated by presolving, skipping.\n", SCIPvarGetName(var));
902  continue;
903  }
904 
906 
907  SCIPdebugMessage("var %s is master constraint\n", decinput->token);
908  }
909  }
910 
911  return SCIP_OKAY;
912 }
913 
915 static
916 SCIP_RETCODE readLinkingvars(
917  SCIP* scip,
918  DECINPUT* decinput,
919  SCIP_READERDATA* readerdata
920  )
921 {
922  assert(scip != NULL);
923  assert(decinput != NULL);
924  assert(readerdata != NULL);
925 
926  while( getNextToken(decinput) )
927  {
928  SCIP_Var* var;
929 
930  /* check if we reached a new section */
931  if( isNewSection(scip, decinput) )
932  break;
933 
934  /* the token must be the name of an existing constraint */
935  var = SCIPfindVar(scip, decinput->token);
936  if( var == NULL )
937  {
938  syntaxError(scip, decinput, "unknown constraint in masterconss section");
939  break;
940  }
941  else
942  {
943  if( !SCIPvarIsActive(var) )
944  {
945  SCIPwarningMessage(scip, "Var <%s> has been fixed or aggregated by presolving, skipping.\n", SCIPvarGetName(var));
946  continue;
947  }
948 
950 
951  SCIPdebugMessage("cons %s is linking constraint\n", decinput->token);
952  }
953  }
954 
955  return SCIP_OKAY;
956 }
957 
958 
962 //static
963 //SCIP_RETCODE fillDecompStruct(
964 // SCIP* scip, /**< SCIP data structure */
965 // DECINPUT* decinput, /**< DEC reading data */
966 // DEC_DECOMP* decomp, /**< DEC_DECOMP structure to fill */
967 // SCIP_READERDATA* readerdata /**< reader data*/
968 // )
969 //{
970 // int nblocks;
971 //
972 // SCIP_CONS** conss;
973 // int nconss;
974 // int i;
975 // SCIP_HASHMAP* constoblock;
976 // assert(scip != NULL);
977 // assert(decinput != NULL);
978 // assert(decomp != NULL);
979 // assert(readerdata != NULL);
980 //
981 // nblocks = decinput->nblocks;
982 //
983 // DECdecompSetPresolved(decomp, decinput->presolved);
984 // DECdecompSetNBlocks(decomp, nblocks);
985 // DECdecompSetDetector(decomp, NULL);
986 //
987 // nconss = SCIPgetNConss(scip);
988 // conss = SCIPgetConss(scip);
989 //
990 // SCIP_CALL( SCIPhashmapCreate(&constoblock, SCIPblkmem(scip), nconss) );
991 //
992 // for( i = 0; i < nconss; ++i )
993 // {
994 //
995 // int blockid;
996 // assert(SCIPhashmapExists(readerdata->constoblock, conss[i]));
997 // blockid = (int) (size_t) SCIPhashmapGetImage(readerdata->constoblock, conss[i]); /*lint !e507*/
998 // if( blockid == LINKINGVALUE )
999 // {
1000 // blockid = decinput->nblocks+1;
1001 // SCIP_CALL( SCIPhashmapSetImage(constoblock, conss[i], (void*) (size_t) (nblocks+1)) );
1002 // }
1003 //
1004 // SCIP_CALL( SCIPhashmapSetImage(constoblock, conss[i], (void*) (size_t) blockid) );
1005 // }
1006 //
1007 //
1008 // SCIP_CALL_QUIET( DECfilloutDecompFromConstoblock(scip, decomp, constoblock, nblocks, FALSE) );
1009 // return SCIP_OKAY;
1010 //}
1011 
1012 
1014 static
1015 SCIP_RETCODE readDECFile(
1016  SCIP* scip,
1017  SCIP_READER* reader,
1018  DECINPUT* decinput,
1019  const char* filename
1020  )
1021 {
1022  SCIP_RETCODE retcode;
1023  SCIP_READERDATA* readerdata;
1024  SCIP_CONS** conss;
1025  int nconss;
1026  int i;
1027 
1028  assert(decinput != NULL);
1029  assert(scip != NULL);
1030  assert(reader != NULL);
1031 
1032 
1033  if( SCIPgetStage(scip) == SCIP_STAGE_INIT || SCIPgetNVars(scip) == 0 || SCIPgetNConss(scip) == 0 )
1034  {
1035  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "No problem exists, will not read structure!\n");
1036 
1037  return SCIP_OKAY;
1038  }
1039 
1040  /* open file */
1041  decinput->file = SCIPfopen(filename, "r");
1042  if( decinput->file == NULL )
1043  {
1044  SCIPerrorMessage("cannot open file <%s> for reading\n", filename);
1045  SCIPprintSysError(filename);
1046  return SCIP_NOFILE;
1047  }
1048 
1049  readerdata = SCIPreaderGetData(reader);
1050  assert(readerdata != NULL);
1051 
1052 
1053 
1054 
1055  /* parse the file */
1056  decinput->section = DEC_START;
1057  retcode = SCIP_OKAY;
1058 
1059  while( decinput->section != DEC_END && ! hasError(decinput) && retcode == SCIP_OKAY )
1060  {
1061  switch( decinput->section )
1062  {
1063  case DEC_START:
1064  SCIP_CALL( readStart(scip, decinput) );
1065  break;
1066  case DEC_INCOMPLETE:
1067  SCIP_CALL( readIncomplete(scip, decinput) );
1068  break;
1069 
1070 
1071  case DEC_PRESOLVED:
1072  SCIP_CALL( readPresolved(scip, decinput) );
1073  if( decinput->presolved && SCIPgetStage(scip) < SCIP_STAGE_PRESOLVED )
1074  {
1075 
1076  SCIPinfoMessage(scip, NULL, "read presolved decomposition but problem is not presolved yet -> presolve()\n");
1077  SCIPpresolve(scip);
1078 
1079 
1080 
1081  assert(decinput->haspresolvesection);
1082  }
1084  if ( decinput->presolved )
1085  {
1087  }
1088  else
1089  {
1091  }
1092  /* cons -> block mapping */
1093  conss = SCIPgetConss(scip);
1094  nconss = SCIPgetNConss(scip);
1095  SCIP_CALL( SCIPhashmapCreate(&readerdata->constoblock, SCIPblkmem(scip), nconss) );
1096  for( i = 0; i < nconss; i ++ )
1097  {
1098  assert( !SCIPhashmapExists(readerdata->constoblock, conss[i] ) );
1099  SCIP_CALL( SCIPhashmapInsert(readerdata->constoblock, conss[i], (void*) (size_t) LINKINGVALUE) );
1100  }
1101 
1102  SCIPconshdlrDecompCreateUserSeeed(scip, decinput->presolved, decinput->incomplete);
1103  break;
1104 
1105  case DEC_NBLOCKS:
1106  SCIP_CALL( readNBlocks(scip, decinput) );
1107  if( decinput->haspresolvesection && !decinput->presolved && SCIPgetStage(scip) >= SCIP_STAGE_PRESOLVED )
1108  {
1109  SCIPwarningMessage(scip, "decomposition belongs to the unpresolved problem, but the problem is already presolved, please consider to re-read the problem and read the decomposition without presolving when transforming do not succeed.\n");
1110  break;
1111 
1112  }
1113  if( !decinput->haspresolvesection )
1114  {
1115  SCIPwarningMessage(scip, "decomposition has no presolve section at beginning. The behaviour is undefined. Please add a presolve section. File reading is aborted. \n");
1116  }
1117  break;
1118 
1119  case DEC_BLOCKCONSS:
1120  SCIP_CALL( readBlockconss(scip, decinput, readerdata) );
1121  break;
1122 
1123  case DEC_MASTERCONSS:
1124  SCIP_CALL( readMasterconss(scip, decinput, readerdata) );
1125  break;
1126 
1127  case DEC_BLOCKVARS:
1128  SCIP_CALL( readBlockvars(scip, decinput, readerdata) );
1129  break;
1130 
1131 
1132  case DEC_MASTERVARS:
1133  SCIP_CALL( readMastervars(scip, decinput, readerdata) );
1134  break;
1135 
1136  case DEC_LINKINGVARS:
1137  SCIP_CALL( readLinkingvars(scip, decinput, readerdata) );
1138  break;
1139 
1140 
1141 
1142  case DEC_END: /* this is already handled in the while() loop */
1143  default:
1144  SCIPerrorMessage("invalid DEC file section <%d>\n", decinput->section);
1145  return SCIP_INVALIDDATA;
1146  }
1147  }
1148 
1149  if( decinput->haserror)
1150  {
1151  SCIPinfoMessage(scip, NULL, "error occured while reading dec file");
1153  }
1154  else
1155  {
1156  SCIPinfoMessage(scip, NULL, "just read dec file:");
1158  }
1159 // SCIP_CALL( DECdecompCreate(scip, &decdecomp) );
1160 //
1161 // if( retcode == SCIP_OKAY )
1162 // {
1163 // /* fill decomp */
1164 // retcode = fillDecompStruct(scip, decinput, decdecomp, readerdata);
1165 // }
1166 //
1167 // if( retcode == SCIP_OKAY )
1168 // {
1169 // /* add decomp to cons_decomp */
1170 // SCIP_CALL( SCIPconshdlrDecompAddDecdecomp(scip, decdecomp) );
1171 // }
1172 // else
1173 // {
1174 // SCIP_CALL( DECdecompFree(scip, &decdecomp) );
1175 // }
1176  SCIPhashmapFree(&readerdata->constoblock);
1177 
1178  /* close file */
1179  SCIPfclose(decinput->file);
1180 
1181  return retcode;
1182 }
1183 
1184 
1185 /*
1186  * Callback methods of reader
1187  */
1188 
1190 static
1191 SCIP_DECL_READERFREE(readerFreeDec)
1192 {
1193  SCIP_READERDATA* readerdata;
1194 
1195  readerdata = SCIPreaderGetData(reader);
1196  assert(readerdata != NULL);
1197 
1198  SCIPfreeMemory(scip, &readerdata);
1199 
1200  return SCIP_OKAY;
1201 }
1202 
1204 static
1205 SCIP_DECL_READERREAD(readerReadDec)
1206 { /*lint --e{715}*/
1207 
1208  if( SCIPgetStage(scip) == SCIP_STAGE_INIT || SCIPgetNVars(scip) == 0 || SCIPgetNConss(scip) == 0 )
1209  {
1210  SCIPverbMessage(scip, SCIP_VERBLEVEL_DIALOG, NULL, "Please read in a problem before reading in the corresponding structure file!\n");
1211  return SCIP_OKAY;
1212  }
1213 
1214  SCIP_CALL( SCIPreadDec(scip, filename, result) );
1215 
1216  return SCIP_OKAY;
1217 }
1218 
1220 static
1221 SCIP_DECL_READERWRITE(readerWriteDec)
1222 { /*lint --e{715}*/
1223  assert(scip != NULL);
1224  assert(reader != NULL);
1225 
1227 
1228  return SCIP_OKAY;
1229 }
1230 
1231 /*
1232  * reader specific interface methods
1233  */
1234 
1236 SCIP_RETCODE
1238  SCIP* scip
1239  )
1240 {
1241  SCIP_READERDATA* readerdata;
1242 
1243  /* create dec reader data */
1244  SCIP_CALL( SCIPallocMemory(scip, &readerdata) );
1245 
1246  /* include dec reader */
1247  SCIP_CALL(SCIPincludeReader(scip, READER_NAME, READER_DESC, READER_EXTENSION, NULL,
1248  readerFreeDec, readerReadDec, readerWriteDec, readerdata));
1249 
1250  return SCIP_OKAY;
1251 }
1252 
1253 /* reads problem from file */
1254 SCIP_RETCODE SCIPreadDec(
1255  SCIP* scip,
1256  const char* filename,
1257  SCIP_RESULT* result
1258  )
1259 {
1260  SCIP_RETCODE retcode;
1261  SCIP_READER* reader;
1262  DECINPUT decinput;
1263  int i;
1264 
1265 
1266  if( SCIPgetStage(scip) < SCIP_STAGE_TRANSFORMED )
1267  SCIP_CALL( SCIPtransformProb(scip) );
1268 
1269 
1270  reader = SCIPfindReader(scip, READER_NAME);
1271  assert(reader != NULL);
1272 
1273  /* initialize DEC input data */
1274  decinput.file = NULL;
1275  decinput.linebuf[0] = '\0';
1276  SCIP_CALL( SCIPallocMemoryArray(scip, &decinput.token, DEC_MAX_LINELEN) ); /*lint !e506*/
1277  decinput.token[0] = '\0';
1278  SCIP_CALL( SCIPallocMemoryArray(scip, &decinput.tokenbuf, DEC_MAX_LINELEN) ); /*lint !e506*/
1279  decinput.tokenbuf[0] = '\0';
1280  for( i = 0; i < DEC_MAX_PUSHEDTOKENS; ++ i )
1281  {
1282  SCIP_CALL( SCIPallocMemoryArray(scip, &decinput.pushedtokens[i], DEC_MAX_LINELEN) ); /*lint !e506 !e866*/
1283  }
1284 
1285  decinput.npushedtokens = 0;
1286  decinput.linenumber = 0;
1287  decinput.linepos = 0;
1288  decinput.section = DEC_START;
1289  decinput.presolved = FALSE;
1290  decinput.haspresolvesection = FALSE;
1291  decinput.nblocks = NOVALUE;
1292  decinput.blocknr = - 2;
1293  decinput.haserror = FALSE;
1294  decinput.incomplete = FALSE;
1295 
1296  /* read the file */
1297  retcode = readDECFile(scip, reader, &decinput, filename);
1298 
1299  /* free dynamically allocated memory */
1300  SCIPfreeMemoryArray(scip, &decinput.token);
1301  SCIPfreeMemoryArray(scip, &decinput.tokenbuf);
1302  for( i = 0; i < DEC_MAX_PUSHEDTOKENS; ++ i )
1303  {
1304  SCIPfreeMemoryArray(scip, &decinput.pushedtokens[i]);
1305  }
1306 
1307  /* evaluate the result */
1308  if( decinput.haserror )
1309  return SCIP_READERROR;
1310  else if( retcode == SCIP_OKAY )
1311  {
1312  *result = SCIP_SUCCESS;
1313  }
1314 
1315  return retcode;
1316 }
1317 
1319 static
1320 SCIP_RETCODE writeData(
1321  SCIP* scip,
1322  FILE* file,
1323  DEC_DECOMP* decdecomp
1324  )
1325 {
1326  SCIP_CONS*** subscipconss;
1327  SCIP_CONS** linkingconss;
1328  int* nsubscipconss;
1329  int nlinkingconss;
1330  int nblocks;
1331  SCIP_Bool presolved;
1332  int i;
1333  int j;
1334 
1335  assert(scip != NULL);
1336  assert(decdecomp != NULL);
1337 
1338  assert(DECdecompGetType(decdecomp) == DEC_DECTYPE_ARROWHEAD
1339  || DECdecompGetType(decdecomp) == DEC_DECTYPE_BORDERED
1340  || DECdecompGetType(decdecomp) == DEC_DECTYPE_DIAGONAL
1341  || DECdecompGetType(decdecomp) == DEC_DECTYPE_UNKNOWN
1342  || DECdecompGetType(decdecomp) == DEC_DECTYPE_STAIRCASE);
1343  SCIPdebugMessage("DEC_DECOMP Type: %s\n", DECgetStrType(DECdecompGetType(decdecomp)));
1344 
1345  /* at first: write meta data of decompsition as comment */
1346  SCIPinfoMessage(scip, file, "%s%s ndetectors \n", commentchars, commentchars );
1347  SCIPinfoMessage(scip, file, "%s%s %d \n", commentchars, commentchars, DECdecompGetDetectorChainSize(decdecomp) );
1348 
1349  SCIPinfoMessage(scip, file, "%s%s name time nnewblocks %%ofnewborderconss %%ofnewblockconss %%ofnewlinkingvars %%ofnewblockvars \n", commentchars, commentchars );
1350 
1351  for ( i = 0; i < DECdecompGetDetectorChainSize(decdecomp) ; ++i)
1352  {
1353  SCIPinfoMessage(scip, file, "%s%s %s %f %d %f %f %f %f \n", commentchars, commentchars, DECdetectorGetName(DECdecompGetDetectorChain(decdecomp)[i] ), DECdecompGetDetectorClockTimes(decdecomp)[i],
1355  DECdecompGetDetectorPctVarsToBlock(decdecomp)[i]) ;
1356  }
1357 
1358 
1359  /* if we don't have staicase, but something else, go through the blocks and create the indices */
1360  /* subscip conss */
1361  subscipconss = DECdecompGetSubscipconss(decdecomp);
1362  nsubscipconss = DECdecompGetNSubscipconss(decdecomp);
1363  assert(subscipconss != NULL);
1364  assert(nsubscipconss != NULL);
1365 
1366  /* linking cons */
1367  linkingconss = DECdecompGetLinkingconss(decdecomp);
1368  nlinkingconss = DECdecompGetNLinkingconss(decdecomp);
1369  assert(nlinkingconss >= 0 && nlinkingconss < SCIPgetNConss(scip));
1370  assert(linkingconss != NULL || nlinkingconss == 0 );
1371 
1372  presolved = DECdecompGetPresolved(decdecomp);
1373 
1374  SCIPinfoMessage(scip, file, "PRESOLVED\n");
1375  SCIPinfoMessage(scip, file, "%d\n", presolved ? 1 : 0);
1376 
1377  nblocks = DECdecompGetNBlocks(decdecomp);
1378 
1379  SCIPinfoMessage(scip, file, "NBLOCKS\n");
1380  SCIPinfoMessage(scip, file, "%d\n", nblocks);
1381 
1382  for( i = 0; i < nblocks; i ++ )
1383  {
1384  SCIPinfoMessage(scip, file, "BLOCK %d\n", i + 1);
1385  for( j = 0; j < nsubscipconss[i]; j ++ )
1386  {
1387  SCIPinfoMessage(scip, file, "%s\n", SCIPconsGetName(subscipconss[i][j]));
1388  }
1389  }
1390 
1391  if( nlinkingconss > 0 )
1392  {
1393  assert(linkingconss != NULL); /* for flexelint */
1394  SCIPinfoMessage(scip, file, "MASTERCONSS\n");
1395  for( i = 0; i < nlinkingconss; i ++ )
1396  {
1397  SCIPinfoMessage(scip, file, "%s\n", SCIPconsGetName(linkingconss[i]));
1398  }
1399  }
1400 
1401  return SCIP_OKAY;
1402 }
1403 
1405 SCIP_RETCODE GCGwriteDecomp(
1406  SCIP* scip,
1407  FILE* file,
1408  DEC_DECOMP* decdecomp
1409  )
1410 {
1411  char outname[SCIP_MAXSTRLEN];
1412  assert(scip != NULL);
1413 
1414  if( decdecomp == NULL )
1415  {
1416  SCIPwarningMessage(scip, "Cannot write decomposed problem if decomposition structure is empty!\n");
1417 
1418  (void) SCIPsnprintf(outname, SCIP_MAXSTRLEN, "%s", SCIPgetProbName(scip));
1419  }
1420  else
1421  {
1422  (void) SCIPsnprintf(outname, SCIP_MAXSTRLEN, "%s_%d", SCIPgetProbName(scip), DECdecompGetNBlocks(decdecomp));
1423 
1424  SCIP_CALL( writeData(scip, file, decdecomp) );
1425  }
1426 
1427  return SCIP_OKAY;
1428 }
SCIP_CONS *** DECdecompGetSubscipconss(DEC_DECOMP *decomp)
Definition: decomp.c:903
static SCIP_RETCODE writeData(SCIP *scip, FILE *file, DEC_DECOMP *decdecomp)
static SCIP_RETCODE readBlockconss(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition: reader_dec.cpp:682
enum DecSection DECSECTION
Definition: reader_dec.cpp:74
static void swapTokenBuffer(DECINPUT *decinput)
Definition: reader_dec.cpp:373
static SCIP_DECL_READERREAD(readerReadDec)
#define DEC_MAX_PUSHEDTOKENS
Definition: reader_dec.cpp:67
const char * DECgetStrType(DEC_DECTYPE type)
Definition: decomp.c:458
static void pushToken(DECINPUT *decinput)
Definition: reader_dec.cpp:360
static SCIP_Bool isTokenChar(char c)
Definition: reader_dec.cpp:173
static void syntaxError(SCIP *scip, DECINPUT *decinput, const char *msg)
Definition: reader_dec.cpp:125
static const char tokenchars[]
Definition: reader_dec.cpp:113
DecSection
Definition: reader_dec.cpp:70
SCIP_Real * DECdecompGetDetectorPctVarsToBorder(DEC_DECOMP *decomp)
Definition: decomp.c:1731
SCIP_RETCODE SCIPreadDec(SCIP *scip, const char *filename, SCIP_RESULT *result)
int DECdecompGetDetectorChainSize(DEC_DECOMP *decomp)
Definition: decomp.c:1609
SCIP_Real * DECdecompGetDetectorClockTimes(DEC_DECOMP *decomp)
Definition: decomp.c:1670
static SCIP_RETCODE readMastervars(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition: reader_dec.cpp:872
static const int LINKINGVALUE
Definition: reader_dec.cpp:111
SCIP_Real * DECdecompGetDetectorPctConssToBlock(DEC_DECOMP *decomp)
Definition: decomp.c:1837
SCIP_RETCODE SCIPconshdlrDecompUserSeeedSetVarToLinking(SCIP *scip, const char *varname)
sets a variable by name to the linking variables in the current user seeed
SCIP_RETCODE SCIPconshdlrDecompUserSeeedSetConsToMaster(SCIP *scip, const char *consname)
sets a constraint by name to master in the current user seeed
static SCIP_Bool isValueChar(char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, DECEXPTYPE *exptype)
Definition: reader_dec.cpp:182
SCIP_Real * DECdecompGetDetectorPctVarsToBlock(DEC_DECOMP *decomp)
Definition: decomp.c:1801
char * tokenbuf
Definition: reader_dec.cpp:89
int blocknr
Definition: reader_dec.cpp:98
int linenumber
Definition: reader_dec.cpp:92
char linebuf[DEC_MAX_LINELEN]
Definition: reader_dec.cpp:87
SCIP_RETCODE SCIPconshdlrDecompUserSeeedFlush(SCIP *scip)
finalizes and flushes the current user seeed, i.e. consider implicits, calc hashvalue, construct decdecomp if complete etc
static const char commentchars[]
Definition: reader_dec.cpp:114
static SCIP_Bool isNewSection(SCIP *scip, DECINPUT *decinput)
Definition: reader_dec.cpp:412
DEC file reader for structure information.
SCIP_RETCODE SCIPconshdlrDecompCreateUserSeeed(SCIP *scip, SCIP_Bool presolved, SCIP_Bool markedincomplete)
creates a user seeed for the problem
SCIP_Bool presolved
Definition: reader_dec.cpp:94
static SCIP_RETCODE readBlockvars(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition: reader_dec.cpp:776
#define READER_EXTENSION
Definition: reader_dec.cpp:60
SCIP_Bool haspresolvesection
Definition: reader_dec.cpp:95
SCIP_Bool incomplete
Definition: reader_dec.cpp:96
SCIP_Bool haserror
Definition: reader_dec.cpp:100
SCIP_RETCODE GCGwriteDecomp(SCIP *scip, FILE *file, DEC_DECOMP *decdecomp)
static SCIP_RETCODE readStart(SCIP *scip, DECINPUT *decinput)
Definition: reader_dec.cpp:543
int DECdecompGetNLinkingconss(DEC_DECOMP *decomp)
Definition: decomp.c:972
SCIP_FILE * file
Definition: reader_dec.cpp:86
DEC_DECTYPE DECdecompGetType(DEC_DECOMP *decomp)
Definition: decomp.c:686
static void swapPointers(char **pointer1, char **pointer2)
Definition: reader_dec.cpp:247
int DECdecompGetNBlocks(DEC_DECOMP *decomp)
Definition: decomp.c:740
static const int NOVALUE
Definition: reader_dec.cpp:110
static SCIP_Bool getNextToken(DECINPUT *decinput)
Definition: reader_dec.cpp:261
DecExpType
Definition: reader_dec.cpp:77
various SCIP helper methods
class to manage partial decompositions (aka seeed), each seeed corresponds to one seeedpool which con...
Definition: class_seeed.h:71
DEC_DETECTOR ** DECdecompGetDetectorChain(DEC_DECOMP *decomp)
Definition: decomp.c:1599
static SCIP_RETCODE readDECFile(SCIP *scip, SCIP_READER *reader, DECINPUT *decinput, const char *filename)
SeeedPtr seeed
Definition: reader_dec.cpp:101
static SCIP_Bool isInt(SCIP *scip, DECINPUT *decinput, int *value)
Definition: reader_dec.cpp:384
#define READER_DESC
Definition: reader_dec.cpp:59
gcg::Seeed * SeeedPtr
Definition: reader_dec.cpp:56
SCIP_CONS ** DECdecompGetLinkingconss(DEC_DECOMP *decomp)
Definition: decomp.c:962
int * DECdecompGetNSubscipconss(DEC_DECOMP *decomp)
Definition: decomp.c:912
SCIP_RETCODE SCIPconshdlrDecompUserSeeedSetConsToBlock(SCIP *scip, const char *consname, int blockid)
sets a constraint by name to a block in the current user seeed
SCIP_RETCODE SCIPconshdlrDecompCreateSeeedpool(SCIP *scip)
creates the seeedpool for the presolved problem
int * DECdecompGetNNewBlocks(DEC_DECOMP *decomp)
Definition: decomp.c:1945
static const char delimchars[]
Definition: reader_dec.cpp:112
SCIP_RETCODE SCIPincludeReaderDec(SCIP *scip)
static SCIP_DECL_READERWRITE(readerWriteDec)
int linepos
Definition: reader_dec.cpp:93
SCIP_Bool GCGisVarRelevant(SCIP_VAR *var)
Definition: scip_misc.c:41
static SCIP_RETCODE readMasterconss(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition: reader_dec.cpp:827
SCIP_RETCODE SCIPconshdlrDecompWriteDec(SCIP *scip, FILE *file, SCIP_Bool transformed, SCIP_RESULT *result)
static SCIP_DECL_READERFREE(readerFreeDec)
char * token
Definition: reader_dec.cpp:88
static SCIP_RETCODE readIncomplete(SCIP *scip, DECINPUT *decinput)
Definition: reader_dec.cpp:564
static SCIP_RETCODE readNBlocks(SCIP *scip, DECINPUT *decinput)
Definition: reader_dec.cpp:642
public methods for GCG variables
int nblocks
Definition: reader_dec.cpp:97
#define READER_NAME
Definition: reader_dec.cpp:58
static SCIP_Bool hasError(DECINPUT *decinput)
Definition: reader_dec.cpp:153
SCIP_RETCODE SCIPconshdlrDecompCreateSeeedpoolUnpresolved(SCIP *scip)
creates the seeedpool for the unpresolved problem
enum DecExpType DECEXPTYPE
Definition: reader_dec.cpp:81
int npushedtokens
Definition: reader_dec.cpp:91
static SCIP_RETCODE readPresolved(SCIP *scip, DECINPUT *decinput)
Definition: reader_dec.cpp:601
SCIP_RETCODE SCIPconshdlrDecompUserSeeedReject(SCIP *scip)
rejects and deletes the current user seeed
static SCIP_RETCODE readLinkingvars(SCIP *scip, DECINPUT *decinput, SCIP_READERDATA *readerdata)
Definition: reader_dec.cpp:916
static SCIP_Bool isDelimChar(char c)
Definition: reader_dec.cpp:164
const char * DECdetectorGetName(DEC_DETECTOR *detector)
returns the name of the provided detector
constraint handler for structure detection
SCIP_Real * DECdecompGetDetectorPctConssToBorder(DEC_DECOMP *decomp)
Definition: decomp.c:1766
SCIP_RETCODE SCIPconshdlrDecompUserSeeedSetnumberOfBlocks(SCIP *scip, int nblocks)
set the number of blocks in the current user seeed (which is used for user input (read or modify) ) ...
struct DecDecomp DEC_DECOMP
Definition: type_decomp.h:43
DECSECTION section
Definition: reader_dec.cpp:99
char * pushedtokens[DEC_MAX_PUSHEDTOKENS]
Definition: reader_dec.cpp:90
public methods for working with decomposition structures
SCIP_RETCODE SCIPconshdlrDecompUserSeeedSetVarToMaster(SCIP *scip, const char *varname)
sets a variable by name to the master in the current user seeed
static SCIP_Bool getNextLine(DECINPUT *decinput)
Definition: reader_dec.cpp:203
#define DEC_MAX_LINELEN
Definition: reader_dec.cpp:66
SCIP_Bool DECdecompGetPresolved(DEC_DECOMP *decomp)
Definition: decomp.c:718
SCIP_RETCODE SCIPconshdlrDecompUserSeeedSetVarToBlock(SCIP *scip, const char *varname, int blockid)
sets a variable by name to a block in the current user seeed