reader_tex.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 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include <assert.h>
36 #include <string.h>
37 
38 #if defined(_WIN32) || defined(_WIN64)
39 #else
40 #include <strings.h> /*lint --e{766}*/ /* needed for strcasecmp() */
41 #endif
42 #include <ctype.h>
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <fstream>
46 #include <vector>
47 #include <sstream>
48 
49 #include "reader_tex.h"
50 #include "scip_misc.h"
51 #include "pub_gcgvar.h"
52 #include "reader_gp.h"
53 #include "cons_decomp.h"
54 #include "pub_decomp.h"
55 #include "struct_decomp.h"
56 #include "params_visu.h"
57 
59 #include "class_seeed.h"
60 #include "class_seeedpool.h"
61 #include "wrapper_seeed.h"
62 
63 #define READER_NAME "texreader"
64 #define READER_DESC "LaTeX file writer for seeed visualization"
65 #define READER_EXTENSION "tex"
66 
67 #define DEFAULT_USEGP FALSE
68 #define DEFAULT_PICTURESONLY FALSE
69 
70 using namespace gcg;
71 
74 SCIP_DECL_READERFREE(readerFreeTex)
75 {
76  /*@todo this is a workaround */
78  return SCIP_OKAY;
79 }
80 
84 SCIP_DECL_READERREAD(readerReadTex)
85 { /*lint --e{715}*/
86  return SCIP_READERROR;
87 }
88 
91 SCIP_DECL_READERWRITE(readerWriteTex)
92 {
93  SEEED_WRAPPER swr;
94  assert(scip != NULL);
95  assert(reader != NULL);
96 
97 
98  /* get seeed to write */
100 
101  if( swr.seeed == NULL )
102  {
103  SCIPerrorMessage("Could not find best Seeed!\n");
104  *result = SCIP_DIDNOTRUN;
105  }
106  else
107  {
108  GCGwriteTexVisualization(scip, file, swr.seeed->getID(), TRUE, FALSE);
109  *result = SCIP_SUCCESS;
110  }
111 
112  return SCIP_OKAY;
113 }
114 
115 
116 /* outputs the r, g, b decimal values for the rgb hex input */
117 static
118 SCIP_RETCODE getRgbFromHex(
119  char* hex,
120  int* red,
121  int* green,
122  int* blue
123  )
124 {
125  char temp[SCIP_MAXSTRLEN];
126  unsigned int r = 0;
127  unsigned int g = 0;
128  unsigned int b = 0;
129 
130  assert( hex[0] == '#' );
131 
132  /* remove the '#' at the beginning */
133  strcpy( temp, hex );
134  memmove( temp, temp+1, strlen( temp ) );
135 
136  /* extract int values from the rest */
137  sscanf( temp, "%02x%02x%02x", &r, &g, &b );
138 
139  *red = (int) r;
140  *green = (int) g;
141  *blue = (int) b;
142 
143  return SCIP_OKAY;
144 }
145 
146 
148 static
149 SCIP_RETCODE getTexColorFromHex(
150  char* hex,
151  const char* colorname,
152  char* code
153  )
154 {
155  char texcode[SCIP_MAXSTRLEN];
156  char colorcode[SCIP_MAXSTRLEN];
157  int r;
158  int g;
159  int b;
160 
161  /* convert hex color code to rgb color */
162  getRgbFromHex( hex, &r, &g, &b );
163 
164  /* make tex code line that defines a rgb color with the computed values */
165  strcpy( texcode, "\\definecolor{" );
166  strcat( texcode, colorname );
167  strcat( texcode, "}{RGB}{" );
168  snprintf(colorcode, SCIP_MAXSTRLEN, "%d", r);
169  strcat( texcode, colorcode );
170  strcat( texcode, "," );
171  snprintf(colorcode, SCIP_MAXSTRLEN, "%d", g);
172  strcat( texcode, colorcode );
173  strcat( texcode, "," );
174  snprintf(colorcode, SCIP_MAXSTRLEN, "%d", b);
175  strcat( texcode, colorcode );
176  strcat( texcode, "}" );
177 
178  /* copy the code line into the output variable */
179  strcpy( code, texcode );
180 
181  return SCIP_OKAY;
182 }
183 
184 
186 static
187 SCIP_RETCODE writeTexHeader(
188  SCIP* scip,
189  FILE* file,
190  SCIP_Bool externalizepics
191  )
192 {
193  char temp[SCIP_MAXSTRLEN];
194 
195  /* write header */
196  SCIPinfoMessage(scip, file, "%% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n");
197  SCIPinfoMessage(scip, file, "%% * * \n");
198  SCIPinfoMessage(scip, file, "%% * This file is part of the program * \n");
199  SCIPinfoMessage(scip, file, "%% * GCG --- Generic Column Generation * \n");
200  SCIPinfoMessage(scip, file, "%% * a Dantzig-Wolfe decomposition based extension * \n");
201  SCIPinfoMessage(scip, file, "%% * of the branch-cut-and-price framework * \n");
202  SCIPinfoMessage(scip, file, "%% * SCIP --- Solving Constraint Integer Programs * \n");
203  SCIPinfoMessage(scip, file, "%% * * \n");
204  SCIPinfoMessage(scip, file, "%% * Copyright (C) 2010-2018 Operations Research, RWTH Aachen University * \n");
205  SCIPinfoMessage(scip, file, "%% * Zuse Institute Berlin (ZIB) * \n");
206  SCIPinfoMessage(scip, file, "%% * * \n");
207  SCIPinfoMessage(scip, file, "%% * This program is free software; you can redistribute it and/or * \n");
208  SCIPinfoMessage(scip, file, "%% * modify it under the terms of the GNU Lesser General Public License * \n");
209  SCIPinfoMessage(scip, file, "%% * as published by the Free Software Foundation; either version 3 * \n");
210  SCIPinfoMessage(scip, file, "%% * of the License, or (at your option) any later version. * \n");
211  SCIPinfoMessage(scip, file, "%% * * \n");
212  SCIPinfoMessage(scip, file, "%% * This program is distributed in the hope that it will be useful, * \n");
213  SCIPinfoMessage(scip, file, "%% * but WITHOUT ANY WARRANTY; without even the implied warranty of * \n");
214  SCIPinfoMessage(scip, file, "%% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * \n");
215  SCIPinfoMessage(scip, file, "%% * GNU Lesser General Public License for more details. * \n");
216  SCIPinfoMessage(scip, file, "%% * * \n");
217  SCIPinfoMessage(scip, file, "%% * You should have received a copy of the GNU Lesser General Public License * \n");
218  SCIPinfoMessage(scip, file, "%% * along with this program; if not, write to the Free Software * \n");
219  SCIPinfoMessage(scip, file, "%% * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.* \n");
220  SCIPinfoMessage(scip, file, "%% * * \n");
221  SCIPinfoMessage(scip, file, "%% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n");
222  SCIPinfoMessage(scip, file, "%% \n");
223  SCIPinfoMessage(scip, file, "%% @author Hanna Franzen \n");
224  SCIPinfoMessage(scip, file, " \n");
225  SCIPinfoMessage(scip, file, " \n");
226  SCIPinfoMessage(scip, file, "\\documentclass[a4paper,10pt]{article} \n");
227  SCIPinfoMessage(scip, file, " \n");
228  SCIPinfoMessage(scip, file, "%% packages \n");
229  SCIPinfoMessage(scip, file, "\\usepackage[utf8]{inputenc} \n");
230  SCIPinfoMessage(scip, file, "\\usepackage[hidelinks]{hyperref} \n");
231  SCIPinfoMessage(scip, file, "\\usepackage{pdfpages} \n");
232  SCIPinfoMessage(scip, file, "\\usepackage{fancybox} \n");
233  if(!GCGgetUseGp())
234  {
235  SCIPinfoMessage(scip, file, "\\usepackage{pgfplots} \n");
236  SCIPinfoMessage(scip, file, "\\pgfplotsset{compat=1.12} \n");
237 // SCIPinfoMessage(scip, file, "\\pgfplotsset{compat=newest} \n");
238 // SCIPinfoMessage(scip, file, "\\pgfplotsset{legend image with text/.style={\nlegend image code/.code={% \n");
239 // SCIPinfoMessage(scip, file, "\\node[anchor=center] at (0.3cm,0cm) {#1};\n}},}\n" );
240 // SCIPinfoMessage(scip, file, "\\usepackage{tikz} \n");
241  SCIPinfoMessage(scip, file, "\\usetikzlibrary{positioning} \n");
242  if(externalizepics)
243  {
244  SCIPinfoMessage(scip, file, " \\usetikzlibrary{external} \n");
245  SCIPinfoMessage(scip, file, " \\tikzexternalize \n");
246  }
247  }
248  SCIPinfoMessage(scip, file, " \n");
249 
250  /* introduce colors of current color scheme */
251  getTexColorFromHex(SCIPvisuGetColorMasterconss(), "colormasterconss", temp);
252  SCIPinfoMessage(scip, file, "%s \n", temp);
253 
254  getTexColorFromHex(SCIPvisuGetColorMastervars(), "colormastervars", temp);
255  SCIPinfoMessage(scip, file, "%s \n", temp);
256 
257  getTexColorFromHex(SCIPvisuGetColorLinking(), "colorlinking", temp);
258  SCIPinfoMessage(scip, file, "%s \n", temp);
259 
260  getTexColorFromHex(SCIPvisuGetColorStairlinking(), "colorstairlinking", temp);
261  SCIPinfoMessage(scip, file, "%s \n", temp);
262 
263  getTexColorFromHex(SCIPvisuGetColorBlock(), "colorblock", temp);
264  SCIPinfoMessage(scip, file, "%s \n", temp);
265 
266  getTexColorFromHex(SCIPvisuGetColorOpen(), "coloropen", temp);
267  SCIPinfoMessage(scip, file, "%s \n", temp);
268 
269  getTexColorFromHex(SCIPvisuGetColorNonzero(), "colornonzero", temp);
270  SCIPinfoMessage(scip, file, "%s \n", temp);
271 
272  getTexColorFromHex(SCIPvisuGetColorLine(), "colorline", temp);
273  SCIPinfoMessage(scip, file, "%s \n", temp);
274 
275  /* start writing the document */
276  SCIPinfoMessage(scip, file, " \n");
277  SCIPinfoMessage(scip, file, "\\begin{document} \n");
278  SCIPinfoMessage(scip, file, " \n");
279 
280  return SCIP_OKAY;
281 }
282 
283 
285 static
286 SCIP_RETCODE writeTexTitlepage(
287  SCIP* scip,
288  FILE* file,
289  int* npresentedseeeds
290  )
291 {
292  char* pname;
293  char ppath[SCIP_MAXSTRLEN];
294  int ndecomps;
295 
296  ndecomps = SCIPconshdlrDecompGetNFinishedDecomps(scip);
297  strcpy(ppath, SCIPgetProbName(scip));
298  SCIPsplitFilename(ppath, NULL, &pname, NULL, NULL);
299 
300  SCIPinfoMessage(scip, file, "\\begin{titlepage} \n");
301  SCIPinfoMessage(scip, file, " \\centering \n");
302  SCIPinfoMessage(scip, file, " \\thispagestyle{empty} \n");
303  SCIPinfoMessage(scip, file, " {\\Huge Report: %s} \\\\ \\today \n",
304  pname);
305  SCIPinfoMessage(scip, file, " \n");
306  SCIPinfoMessage(scip, file, "\\vspace{2cm} \n");
307  SCIPinfoMessage(scip, file, "\\begin{tabular}{{lp{10cm}}} \n");
308  SCIPinfoMessage(scip, file, " \\textbf{Problem}: & \\begin{minipage}{10cm} \n");
309  SCIPinfoMessage(scip, file, " \\begin{verbatim}%s\\end{verbatim} \n",
310  pname);
311  SCIPinfoMessage(scip, file, " \\end{minipage} \\\\ \n");
312  SCIPinfoMessage(scip, file, " Number of variables in original problem: & %i \\\\ \n",
313  SCIPgetNOrigVars(scip));
314  SCIPinfoMessage(scip, file, " \\vspace{0.5cm} \n");
315  SCIPinfoMessage(scip, file, " Number of constraints in original problem: & %i \\\\ \n",
316  SCIPgetNOrigConss(scip));
317  SCIPinfoMessage(scip, file, " Number of found finished decompositions: & %i \\\\ \n",
319  SCIPinfoMessage(scip, file, " Number of found incomplete decompositions: & %i \\\\ \n",
321  if(npresentedseeeds != NULL){
322  if( ndecomps > *npresentedseeeds )
323  {
324  SCIPinfoMessage(scip, file, " Number of decompositions presented in this document: & %i \\\\ \n",
325  *npresentedseeeds);
326  }
327  else
328  {
329  SCIPinfoMessage(scip, file, " Number of decompositions presented in this document: & %i \\\\ \n", ndecomps);
330  }
331  }
332  SCIPinfoMessage(scip, file, "\\end{tabular} \n");
333  SCIPinfoMessage(scip, file, " \n");
334  SCIPinfoMessage(scip, file, "\\end{titlepage} \n");
335  SCIPinfoMessage(scip, file, "\\newpage \n");
336 
337  return SCIP_OKAY;
338 }
339 
340 
342 static
344  SCIP* scip,
345  FILE* file
346  )
347 {
348  SCIPinfoMessage(scip, file, "\\thispagestyle{empty} \n");
349  SCIPinfoMessage(scip, file, "\\tableofcontents \n");
350  SCIPinfoMessage(scip, file, "\\newpage \n");
351  SCIPinfoMessage(scip, file, " \n");
352 
353  return SCIP_OKAY;
354 }
355 
356 
359 static
360 SCIP_RETCODE writeTikzBox(
361  SCIP* scip,
362  FILE* file,
363  int xmax,
364  int ymax,
365  int x1,
366  int y1,
367  int x2,
368  int y2,
369  const char* color
370  )
371 {
372  SCIPinfoMessage(scip, file,
373  " \\filldraw [fill=%s, draw=colorline] (%f*\\textwidth*0.75,%f*\\textwidth*0.75) rectangle (%f*\\textwidth*0.75,%f*\\textwidth*0.75);\n",
374  color, ( (float) x1 / (float) xmax ), ( (float) y1 / (float) ymax ), ( (float) x2 / (float) xmax ),
375  ( (float) y2 / (float) ymax ));
376  return SCIP_OKAY;
377 }
378 
379 
382 static
383 SCIP_RETCODE writeTikzNonzeros(
384  SCIP* scip,
385  FILE* file,
386  Seeed* seeed,
387  Seeedpool* seeedpool,
388  float radius,
389  int xmax,
390  int ymax
391  )
392 {
393  std::vector<int> orderToRows(seeed->getNConss(), -1);
394  std::vector<int> rowToOrder(seeed->getNConss(), -1);
395  std::vector<int> orderToCols(seeed->getNVars(), -1);
396  std::vector<int> colsToOrder(seeed->getNVars(), -1);
397  int counterrows = 0;
398  int countercols = 0;
399 
401  /* master constraints */
402  for( int i = 0; i < seeed->getNMasterconss() ; ++i )
403  {
404  int rowidx = seeed->getMasterconss()[i];
405  orderToRows[counterrows] = rowidx;
406  rowToOrder[rowidx] = counterrows;
407  ++counterrows;
408  }
409 
410  /* block constraints */
411  for( int b = 0; b < seeed->getNBlocks(); ++b )
412  {
413  for(int i = 0; i < seeed->getNConssForBlock(b); ++i )
414  {
415  int rowidx = seeed->getConssForBlock(b)[i];
416  orderToRows[counterrows] = rowidx;
417  rowToOrder[rowidx] = counterrows;
418  ++counterrows;
419  }
420  }
421 
423  for( int i = 0; i < seeed->getNOpenconss(); ++i )
424  {
425  int rowidx = seeed->getOpenconss()[i];
426  orderToRows[counterrows] = rowidx;
427  rowToOrder[rowidx] = counterrows;
428  ++counterrows;
429  }
430 
433  /* linking variables */
434  for( int i = 0; i < seeed->getNLinkingvars() ; ++i )
435  {
436  int colidx = seeed->getLinkingvars()[i];
437  orderToCols[countercols] = colidx;
438  colsToOrder[colidx] = countercols;
439  ++countercols;
440  }
441 
442  /* master variables */
443  for( int i = 0; i < seeed->getNMastervars() ; ++i )
444  {
445  int colidx = seeed->getMastervars()[i];
446  orderToCols[countercols] = colidx;
447  colsToOrder[colidx] = countercols;
448  ++countercols;
449  }
450 
451  /* block variables */
452  for( int b = 0; b < seeed->getNBlocks(); ++b )
453  {
454  for(int i = 0; i < seeed->getNVarsForBlock(b); ++i )
455  {
456  int colidx = seeed->getVarsForBlock(b)[i];
457  orderToCols[countercols] = colidx;
458  colsToOrder[colidx] = countercols;
459  ++countercols;
460  }
461  for(int i = 0; i < seeed->getNStairlinkingvars(b); ++i )
462  {
463  int colidx = seeed->getStairlinkingvars(b)[i];
464  orderToCols[countercols] = colidx;
465  colsToOrder[colidx] = countercols;
466  ++countercols;
467  }
468  }
469 
470  /* open vars */
471  for( int i = 0; i < seeed->getNOpenvars() ; ++i )
472  {
473  int colidx = seeed->getOpenvars()[i];
474  orderToCols[countercols] = colidx;
475  colsToOrder[colidx] = countercols;
476  ++countercols;
477  }
478 
479  /* write scatter plot */
480  for( int row = 0; row < seeed->getNConss(); ++row )
481  {
482  for ( int col = 0; col < seeed->getNVars(); ++col )
483  {
484  assert( orderToRows[row] != -1 );
485  assert( orderToCols[col] != -1 );
486  if( seeedpool->getVal( orderToRows[row], orderToCols[col] ) != 0 )
487  {
488  SCIPinfoMessage(scip, file,
489  " \\draw [fill] (%f*\\textwidth*0.75,%f*\\textwidth*0.75) circle [radius=%f*0.75];\n",
490  ( (float) col + 0.5 ) / (float) xmax, ( (float) row + 0.5 ) / (float) ymax, radius);
491  }
492  }
493  }
494 
495  return SCIP_OKAY;
496 }
497 
498 
499 static
500 SCIP_RETCODE writeTexSeeed(
501  SCIP* scip,
502  FILE* file,
503  Seeed* seeed,
504  Seeedpool* seeedpool,
505  SCIP_Bool nofigure
506  )
507 {
508  int rowboxcounter = 0;
509  int colboxcounter = 0;
510  int nvars;
511  int nconss;
512 
513  nvars = seeed->getNVars();
514  nconss = seeed->getNConss();
515 
516  if(!nofigure)
517  {
518  SCIPinfoMessage(scip, file, "\\begin{figure}[!htb] \n");
519  SCIPinfoMessage(scip, file, " \\begin{center} \n");
520  }
521  SCIPinfoMessage(scip, file, " \\begin{tikzpicture}[yscale=-1] \n");
522  /* --- draw boxes ---*/
523 
524  /* linking vars */
525  if(seeed->getNLinkingvars() != 0)
526  {
527  writeTikzBox(scip, file, nvars, nconss, 0, 0, seeed->getNLinkingvars(), seeed->getNConss(),
528  (const char*) "colorlinking");
529  colboxcounter += seeed->getNLinkingvars();
530  }
531 
532  /* masterconss */
533  if(seeed->getNMasterconss() != 0)
534  {
535  writeTikzBox(scip, file, nvars, nconss, 0, 0, seeed->getNVars(), seeed->getNMasterconss(),
536  (const char*) "colormasterconss");
537  rowboxcounter += seeed->getNMasterconss();
538  }
539 
540  /* mastervars */
541  if(seeed->getNMastervars() != 0)
542  {
543  writeTikzBox(scip, file, nvars, nconss, colboxcounter, 0, seeed->getNMastervars()+colboxcounter,
544  seeed->getNMasterconss(), (const char*) "colormastervars");
545  colboxcounter += seeed->getNMastervars();
546  }
547 
548  /* blocks (blocks are not empty) */
549  for( int b = 0; b < seeed->getNBlocks() ; ++b )
550  {
551  writeTikzBox(scip, file, nvars, nconss, colboxcounter, rowboxcounter,
552  colboxcounter + seeed->getNVarsForBlock(b), rowboxcounter + seeed->getNConssForBlock(b),
553  (const char*) "colorblock");
554  colboxcounter += seeed->getNVarsForBlock(b);
555 
556  if( seeed->getNStairlinkingvars(b) != 0 )
557  {
558  writeTikzBox(scip, file, nvars, nconss, colboxcounter, rowboxcounter,
559  colboxcounter + seeed->getNStairlinkingvars(b),
560  rowboxcounter + seeed->getNConssForBlock(b) + seeed->getNConssForBlock(b+1),
561  (const char*) "colorstairlinking");
562  }
563  colboxcounter += seeed->getNStairlinkingvars(b);
564  rowboxcounter += seeed->getNConssForBlock(b);
565  }
566 
567  /* open */
568  if(seeed->getNOpenvars() != 0)
569  {
570  writeTikzBox(scip, file, nvars, nconss, colboxcounter, rowboxcounter, colboxcounter + seeed->getNOpenvars(),
571  rowboxcounter+seeed->getNOpenconss(), (const char*) "coloropen" );
572  colboxcounter += seeed->getNOpenvars();
573  rowboxcounter += seeed->getNOpenconss();
574  }
575 
576  /* --- draw nonzeros --- */
577  if(SCIPvisuGetDraftmode() == FALSE)
578  {
579  writeTikzNonzeros(scip, file, seeed, seeedpool, SCIPvisuGetNonzeroRadius(seeed->getNVars(), seeed->getNConss(), 1),
580  nvars, nconss);
581  }
582 
583  SCIPinfoMessage(scip, file, " \\end{tikzpicture} \n");
584  if(!nofigure)
585  {
586  SCIPinfoMessage(scip, file, " \\end{center} \n");
587  SCIPinfoMessage(scip, file, "\\end {figure} \n");
588  }
589 
590  return SCIP_OKAY;
591 }
592 
593 static
595  SCIP* scip,
596  FILE* file,
597  Seeed* seeed
598  )
599 {
600  DEC_DETECTOR** detectorchain;
601  char fulldetectorstring[SCIP_MAXSTRLEN];
602  int sizedetectorchain;
603  int i;
604 
605  /* get detector chain full-text string*/
606  detectorchain = seeed->getDetectorchain();
607  sizedetectorchain = seeed->getNDetectors();
608  if( detectorchain[0] != NULL)
609  sprintf(fulldetectorstring, "%s", DECdetectorGetName(detectorchain[0]));
610  else
611  sprintf(fulldetectorstring, "%s", "user");
612  for( i=1; i < sizedetectorchain; ++i )
613  {
614  sprintf(fulldetectorstring, "%s, %s",fulldetectorstring, DECdetectorGetName(detectorchain[i]) );
615  }
616 
617  SCIPinfoMessage(scip, file, " \n");
618  SCIPinfoMessage(scip, file, "\\vspace{0.3cm} \n");
619  SCIPinfoMessage(scip, file, "\\begin{tabular}{lp{10cm}} \n");
620  SCIPinfoMessage(scip, file,
621  " Found by detector(s): & \\begin{minipage}{10cm}\\begin{verbatim}%s\\end{verbatim}\\end{minipage} \\\\ \n",
622  fulldetectorstring);
623  SCIPinfoMessage(scip, file, " Number of blocks: & %i \\\\ \n",
624  seeed->getNBlocks());
625  SCIPinfoMessage(scip, file, " Number of master variables: & %i \\\\ \n",
626  seeed->getNMastervars());
627  SCIPinfoMessage(scip, file, " Number of master constraints: & %i \\\\ \n",
628  seeed->getNMasterconss());
629  SCIPinfoMessage(scip, file, " Number of linking variables: & %i \\\\ \n",
630  seeed->getNLinkingvars());
631  SCIPinfoMessage(scip, file, " Number of stairlinking variables: & %i \\\\ \n",
632  seeed->getNTotalStairlinkingvars());
633  SCIPinfoMessage(scip, file, " Max white score: & %f \\\\ \n",
634  seeed->getMaxWhiteScore());
635  SCIPinfoMessage(scip, file, "\\end{tabular} \n");
636 
637  SCIPinfoMessage(scip, file, "\\clearpage \n");
638  SCIPinfoMessage(scip, file, " \n");
639 
640  return SCIP_OKAY;
641 }
642 
643 
645 static
646 SCIP_RETCODE writeTexEnding(
647  SCIP* scip,
648  FILE* file
649  )
650 {
651 
652  SCIPinfoMessage(scip, file, "\\end{document} \n");
653 
654  return SCIP_OKAY;
655 }
656 
660  SCIP* scip,
661  FILE* file,
662  SeeedPtr seeed,
663  int currheight,
664  int visucounter
665  )
666 {
667  char relposition[SCIP_MAXSTRLEN];
668  int position = visucounter % 3;
669  if( position == 0 )
670  strcpy(relposition, "above");
671  else if ( position == 1)
672  strcpy(relposition, " ");
673  else if ( position == 2)
674  strcpy(relposition, "below");
675  else
676  strcpy(relposition, "below left");
677 
678  if( currheight != 1)
679  strcpy(relposition, " ");
680 
681  if( currheight > seeed->getNDetectorchainInfo() )
682  {
683  SCIPinfoMessage(scip, file, "edge from parent node [%s] {no info%d-%d } ", relposition, seeed->getID(),
684  currheight - 1);
685  }
686  else
687  {
688  std::string oldinfo = seeed->getDetectorchainInfo( currheight - 1 );
690  size_t index = 0;
691  while(true)
692  {
693  /* Locate the substring to replace. */
694  index = oldinfo.find("_", index);
695  if(index == std::string::npos)
696  break;
697  if( index > 0 && oldinfo.at(index-1) == '\\' )
698  {
699  ++index;
700  continue;
701  }
702 
703  /* Make the replacement. */
704  oldinfo.replace(index, 1, "\\_");
705 
706  /* Advance index forward so the next iteration doesn't pick it up as well. */
707  index += 2;
708  }
709 
710  SCIPinfoMessage(scip, file, "edge from parent node [%s] {%s} ", relposition, oldinfo.c_str());
711  }
712 
713  return SCIP_OKAY;
714 }
715 
716 
720 SCIP_Bool finishNextChild( std::vector<int>& childs, std::vector<SCIP_Bool>& childsfinished, int child )
721 {
722  for( size_t s = 0; s < childsfinished.size(); ++s )
723  {
724  if( !childsfinished[s] )
725  {
726  assert(childs[s] == child);
727  childsfinished[s] = TRUE;
728  return s == childsfinished.size() - 1;
729  }
730  }
731  return FALSE;
732 }
733 
734 
735 SCIP_Bool unfinishedChildExists(std::vector<SCIP_Bool> const& childsfinished)
736 {
737  for( size_t s = 0; s < childsfinished.size(); ++s )
738  {
739  if( !childsfinished[s] )
740  return true;
741  }
742  return false;
743 }
744 
745 
746 int getFirstUnfinishedChild(std::vector<SCIP_Bool> const& childsfinished, std::vector<int> const& childs)
747 {
748  for( size_t s = 0; s < childsfinished.size(); ++s )
749  {
750  if( !childsfinished[s] )
751  return childs[s];
752  }
753  return -1;
754 }
755 
756 
758 SCIP_RETCODE GCGwriteTexReport(
759  SCIP* scip,
760  FILE* file,
761  int* seeedids,
762  int* nseeeds,
763  SCIP_Bool titlepage,
764  SCIP_Bool toc,
765  SCIP_Bool statistics,
766  SCIP_Bool usegp
767  )
768 {
769  MiscVisualization* misc = new MiscVisualization();
770  SEEED_WRAPPER seeedwr;
771  Seeed* seeed;
772  Seeedpool* seeedpool = NULL;
773  char* gppath;
774  char* filepath;
775  char* path;
776  char gpname[SCIP_MAXSTRLEN];
777  char pdfname[SCIP_MAXSTRLEN];
778 
779  if(*nseeeds > GCGreportGetMaxNDecomps())
780  *nseeeds = GCGreportGetMaxNDecomps();
781 
782  /* write tex code into file */
783  writeTexHeader(scip, file, TRUE);
784  if(titlepage)
785  writeTexTitlepage(scip, file, nseeeds);
786  if(toc)
787  writeTexTableOfContents(scip, file);
788  for(int i = 0; i < *nseeeds; i++)
789  {
790  /* get and write each seeed */
791  int tempindex = seeedids[i];
792  GCGgetSeeedFromID(scip, &tempindex, &seeedwr);
793  seeed = seeedwr.seeed;
794 
795  if(toc)
796  {
797  char decompname[SCIP_MAXSTRLEN];
798  SCIPsnprintf( decompname, SCIP_MAXSTRLEN, "%s-%d", seeed->getDetectorChainString(), seeed->getID() );
799 
800  SCIPinfoMessage(scip, file, "\\section*{Decomposition: %s} \n", decompname);
801  if(toc)
802  SCIPinfoMessage(scip, file, "\\addcontentsline{toc}{section}{Decomposition: %s} \n", decompname);
803  SCIPinfoMessage(scip, file, " \n");
804  }
805 
806  seeedpool = misc->GCGgetSeeedpoolForSeeed(scip, tempindex);
807  if(!usegp)
808  {
809  writeTexSeeed(scip, file, seeed, seeedpool, FALSE);
810  }
811  else
812  {
813  /* in case a gp file should be generated include it in the tex code */
814  misc->GCGgetVisualizationFilename(scip, seeed, "gp", gpname);
815  misc->GCGgetVisualizationFilename(scip, seeed, "pdf", pdfname);
816  strcat(pdfname, ".pdf");
817 
818  filepath = misc->GCGgetFilePath(scip, file);
819  SCIPsplitFilename(filepath, &path, NULL, NULL, NULL);
820 
821  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &gppath, SCIP_MAXSTRLEN) );
822 
823  strcpy(gppath, path);
824  strcat(gppath, "/");
825  strcat(gppath, gpname);
826  strcat(gppath, ".gp");
827 
828  GCGwriteGpVisualization( scip, gppath, pdfname, seeedids[i] );
829 
830  SCIPfreeBlockMemoryArray(scip, &gppath, SCIP_MAXSTRLEN);
831 
832  SCIPinfoMessage(scip, file, "\\begin{figure}[!htb] \n");
833  SCIPinfoMessage(scip, file, " \\begin{center} \n");
834  SCIPinfoMessage(scip, file, " \\includegraphics{%s} \n", pdfname);
835  SCIPinfoMessage(scip, file, " \\end{center} \n");
836  SCIPinfoMessage(scip, file, "\\end {figure} \n");
837  }
838  if(statistics)
839  writeTexSeeedStatistics(scip, file, seeed);
840  }
841  writeTexEnding(scip, file);
842 
843  GCGtexWriteMakefileAndReadme(scip, file, usegp, FALSE);
844 
845  return SCIP_OKAY;
846 }
847 
848 
851  SCIP* scip,
852  FILE* file,
853  const char* workfolder,
854  SEEED_WRAPPER** seeedswr,
855  int* nseeeds
856  )
857 {
858  MiscVisualization* miscvisu = new MiscVisualization();
859  SCIP_Real firstsibldist = -1.;
860  int curr = -1;
861  int currheight = 0;
862  int helpvisucounter; /* help counter for family tree visualization to iterate the heights */
863 
864  /* collection of treeseeds */
865  std::vector<SeeedPtr> treeseeeds(0);
866  std::vector<int> treeseeedids(0);
867  SEEED_WRAPPER** allrelevantseeedswr;
868  int nallrelevantseeeds = 0;
869  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &allrelevantseeedswr, SCIPconshdlrDecompGetNSeeeds(scip)) );
870  SCIPconshdlrDecompGetAllRelevantSeeeds(scip, allrelevantseeedswr, &nallrelevantseeeds);
871 
872  std::vector<SCIP_Bool> isseeedintree(nallrelevantseeeds, FALSE);
873 
874  int root = -1;
875  int root2 = -1;
876  std::vector<int> parents(nallrelevantseeeds, -1);
877  std::vector< std::vector<int> > childs (nallrelevantseeeds, std::vector<int>(0));
878  std::vector< std::vector<SCIP_Bool> > childsfinished(nallrelevantseeeds, std::vector<SCIP_Bool>(0));
879  std::vector<SCIP_Bool> visited(nallrelevantseeeds, FALSE);
880 
881  helpvisucounter = 0;
882 
884  for( int s = 0; s < nallrelevantseeeds; ++s )
885  {
886  assert(allrelevantseeedswr[s]->seeed == NULL || (int) s == allrelevantseeedswr[s]->seeed->getID() );
887  }
888 
890  for( int s = 0; s < *nseeeds; ++s )
891  {
892  int currid;
893  if ( seeedswr[s]->seeed == NULL )
894  continue;
895  currid = seeedswr[s]->seeed->getID();
896  if( !isseeedintree[seeedswr[s]->seeed->getID()] )
897  {
898  isseeedintree[seeedswr[s]->seeed->getID()] = TRUE;
899  treeseeeds.push_back(seeedswr[s]->seeed);
900  treeseeedids.push_back(seeedswr[s]->seeed->getID());
901  }
902  else
903  break;
904 
905  for( int i = 0; i < seeedswr[s]->seeed->getNAncestors(); ++i )
906  {
907  int ancestorid;
908  ancestorid = seeedswr[s]->seeed->getAncestorID( seeedswr[s]->seeed->getNAncestors() - i - 1 );
909  parents[currid] = ancestorid;
910  childs[ancestorid].push_back(currid);
911  childsfinished[ancestorid].push_back(FALSE);
912 
913  if( !isseeedintree[ancestorid] )
914  {
915  isseeedintree[ancestorid] = TRUE;
916  assert(allrelevantseeedswr[ancestorid]->seeed != NULL);
917  treeseeeds.push_back( allrelevantseeedswr[ancestorid]->seeed );
918  treeseeedids.push_back(ancestorid);
919  if( i == seeedswr[s]->seeed->getNAncestors() -1 )
920  {
921  if( root == -1 )
922  root = ancestorid;
923  else if( ancestorid != root )
924  root2 = ancestorid;
925  }
926  currid = ancestorid;
927  }
928  else
929  break;
930  }
931  }
932 
933  for( size_t i = 0; i < treeseeeds.size(); ++i )
934  {
935  SeeedPtr seeed;
936  char imagefilename[SCIP_MAXSTRLEN];
937  char decompfilename[SCIP_MAXSTRLEN];
938  char temp[SCIP_MAXSTRLEN];
939 
940  seeed = treeseeeds[i];
941  strcpy( imagefilename, workfolder );
942  strcat( imagefilename, "/" );
943 
944  /* gp files have to be generated and included later in the figure */
945  miscvisu->GCGgetVisualizationFilename(scip, seeed, "gp", temp);
946  strcat( imagefilename, temp );
947  strcat( imagefilename, ".gp" );
948  miscvisu->GCGgetVisualizationFilename(scip, seeed, "pdf", temp);
949  strcpy( decompfilename, temp );
950  strcat( decompfilename, ".pdf" );
951 
952  GCGwriteGpVisualization(scip, imagefilename, decompfilename, seeed->getID());
953  }
954 
955  /* merge both roots in the first one*/
956  for( size_t s = 0; root2 != -1 && s < treeseeeds.size(); ++s )
957  {
958  int seeedid = treeseeeds[s]->getID();
959  if ( parents[seeedid] == root2 )
960  {
961  parents[seeedid] = root;
962  }
963  }
964 
965  for( size_t s = 0; root2 != -1 && s < childs[root2].size(); ++s )
966  {
967  childs[root].push_back(childs[root2][s] );
968  childsfinished[root].push_back(FALSE );
969  }
970 
971  firstsibldist = 1. / (childs[root].size() - 1 );
972  if( childs[root].size() == 1 ){
973  firstsibldist = 1;
974  }
975 
976  /* start document with header */
977  writeTexHeader(scip, file, FALSE);
978 // SCIPinfoMessage(scip, file, "\\begin{center}\n");
979 
980  /* beginning of tree */
981  SCIPinfoMessage(scip, file,
982  "\\begin{tikzpicture}[level/.style={sibling distance=%f\\textwidth/#1}, level distance=12em, ->, dashed]\n",
983  firstsibldist);
984 
986  curr = root;
987 
988  if(curr != -1)
989  SCIPinfoMessage(scip, file, "\\node ");
990 
991  while ( curr != -1 )
992  {
993  if( !visited[curr] )
994  {
996  SCIPinfoMessage(scip, file, "(s%d) ", allrelevantseeedswr[curr]->seeed->getID());
997 
998  char temp[SCIP_MAXSTRLEN];
999  miscvisu->GCGgetVisualizationFilename(scip, allrelevantseeedswr[curr]->seeed, "pdf", temp);
1000  SCIPinfoMessage(scip, file, "{ \\includegraphics[width=0.15\\textwidth]{%s.pdf} }", temp);
1001 
1002  /* set node visited */
1003  visited[curr] = TRUE;
1004  if( parents[curr] != -1 )
1005  finishNextChild(childs[parents[curr]], childsfinished[parents[curr]], curr);
1006 
1007  }
1008  if ( unfinishedChildExists(childsfinished[curr] ) )
1009  {
1010  int unfinishedchild = getFirstUnfinishedChild(childsfinished[curr], childs[curr] );
1011  /* is first child unfinihsed? */
1012  // if( unfinishedchild == childs[curr][0] )
1013  SCIPinfoMessage(scip, file, "\n child { node ");
1014  curr = unfinishedchild;
1015  ++currheight;
1016  }
1017  else
1018  {
1019  if ( parents[curr] != -1 ){
1020  writeSeeedDetectorChainInfoLatex(scip, file, allrelevantseeedswr[curr]->seeed, currheight, helpvisucounter);
1021  ++helpvisucounter;
1022  }
1023  --currheight;
1024  curr = parents[curr];
1025  if( curr != -1)
1026  SCIPinfoMessage(scip, file, " } ");
1027  }
1028  }
1029 
1030  if(root != -1)
1031  {
1032  SCIPinfoMessage(scip, file, ";\n");
1033  for( size_t i = 0; i < treeseeeds.size(); ++i)
1034  {
1035  if ( treeseeeds[i]->getID() == root2 )
1036  continue;
1037  SCIPinfoMessage(scip, file, "\\node[below = \\belowcaptionskip of s%d] (caps%d) {\\scriptsize %s}; \n",
1038  treeseeeds[i]->getID(), treeseeeds[i]->getID(), treeseeeds[i]->getShortCaption());
1039  }
1040  }
1041  else
1042  {
1043  /* this case should only appear for decompositions that were read instead of detected, therefore no root */
1044  SCIP_Bool isnodefirst = true;
1045  for( size_t i = 0; i < treeseeeds.size(); ++i)
1046  {
1047  if ( treeseeeds[i]->getID() == root2 )
1048  {
1049  isnodefirst = false;
1050  continue;
1051  }
1052  if(isnodefirst)
1053  {
1054  /* in this case the picture is not included as a loop yet and has to be added */
1055  char temp[SCIP_MAXSTRLEN];
1056  miscvisu->GCGgetVisualizationFilename(scip, treeseeeds[i], "pdf", temp);
1057  SCIPinfoMessage(scip, file, "\\node[] (s%d) { \\includegraphics[width=0.15\\textwidth]{%s.pdf} };",
1058  treeseeeds[i]->getID(), temp);
1059  SCIPinfoMessage(scip, file, "\\node[below = \\belowcaptionskip of s%d] (caps%d) {\\scriptsize %s}; \n",
1060  treeseeeds[i]->getID(), treeseeeds[i]->getID(), treeseeeds[i]->getShortCaption());
1061  }
1062  else
1063  SCIPinfoMessage(scip, file, "\\node[below = \\belowcaptionskip of s%d] (caps%d) {\\scriptsize %s}; \n",
1064  treeseeeds[i]->getID(), treeseeeds[i]->getID(), treeseeeds[i]->getShortCaption());
1065  isnodefirst = false;
1066  }
1067  }
1068 
1069  SCIPinfoMessage(scip, file, "\\end{tikzpicture}\n");
1070 // SCIPinfoMessage(scip, file, "\\end{center}\n");
1071  writeTexEnding(scip, file);
1072 
1073  for( int i = 0; i < nallrelevantseeeds; ++i )
1074  {
1075  SCIPfreeBlockMemory( scip, &(allrelevantseeedswr[i]) );
1076  }
1077  SCIPfreeBlockMemoryArray(scip, &allrelevantseeedswr, SCIPconshdlrDecompGetNSeeeds(scip));
1078 
1079  GCGtexWriteMakefileAndReadme(scip, file, TRUE, FALSE);
1080 
1081  return SCIP_OKAY;
1082 }
1083 
1084 
1087  SCIP* scip,
1088  FILE* file,
1089  int seeedid,
1090  SCIP_Bool statistics,
1091  SCIP_Bool usegp
1092  )
1093 {
1094  MiscVisualization* misc = new MiscVisualization();
1095  SEEED_WRAPPER seeedwr;
1096  Seeed* seeed;
1097  Seeedpool* seeedpool = NULL;
1098  char gpname[SCIP_MAXSTRLEN];
1099  char pdfname[SCIP_MAXSTRLEN];
1100 
1101  /* get seeed */
1102  GCGgetSeeedFromID(scip, &seeedid, &seeedwr);
1103  seeed = seeedwr.seeed;
1104  seeedpool = misc->GCGgetSeeedpoolForSeeed(scip, seeedid);
1105 
1106  /* write tex code into file */
1107  writeTexHeader(scip, file, FALSE);
1108 
1109  if(!usegp)
1110  {
1111  writeTexSeeed(scip, file, seeed, seeedpool, FALSE);
1112  }
1113  else
1114  {
1115  /* in case a gp file should be generated include it */
1116  misc->GCGgetVisualizationFilename(scip, seeed, "gp", gpname);
1117  misc->GCGgetVisualizationFilename(scip, seeed, "pdf", pdfname);
1118 
1119  GCGwriteGpVisualization(scip, gpname, pdfname, seeedid);
1120 
1121  SCIPinfoMessage(scip, file, "\\begin{figure}[!htb] \n");
1122  SCIPinfoMessage(scip, file, " \\begin{center} \n");
1123  SCIPinfoMessage(scip, file, " \\input{%s} \n", pdfname);
1124  SCIPinfoMessage(scip, file, " \\end{center} \n");
1125  SCIPinfoMessage(scip, file, "\\end {figure} \n");
1126  }
1127  if(statistics)
1128  writeTexSeeedStatistics(scip, file, seeed);
1129 
1130  writeTexEnding(scip, file);
1131 
1132  return SCIP_OKAY;
1133 }
1134 
1135 
1138  SCIP* scip,
1139  FILE* file,
1140  SCIP_Bool usegp,
1141  SCIP_Bool compiletex
1143  )
1144 {
1145  FILE* makefile;
1146  FILE* readme;
1147  char* filepath;
1148  char* filename;
1149  char* pfile;
1150  char pfilecpy[SCIP_MAXSTRLEN];
1151  char makefilename[SCIP_MAXSTRLEN];
1152  char readmename[SCIP_MAXSTRLEN];
1153  char name[SCIP_MAXSTRLEN];
1154  const char makename[SCIP_MAXSTRLEN] = "makepdf";
1155 
1156  /* --- create a Makefile --- */
1157 
1158  /* get path to write to and put it into makefilename */
1159  MiscVisualization* miscvisu = new MiscVisualization();
1160  pfile = miscvisu->GCGgetFilePath(scip, file);
1161  strcpy(pfilecpy, pfile);
1162  SCIPsplitFilename(pfilecpy, &filepath, &filename, NULL, NULL);
1163  strcpy(makefilename, filepath);
1164  strcat(makefilename, "/");
1165  strcpy(name, makename);
1166  strcat(name, "_");
1167  strcat(name, filename);
1168  strcat(name, ".make");
1169  strcat(makefilename, name);
1170 
1171  /* open and write makefile */
1172  makefile = fopen(makefilename, "w");
1173  if( makefile == NULL )
1174  {
1175  return SCIP_FILECREATEERROR;
1176  }
1177 
1178  if( usegp )
1179  {
1180  SCIPinfoMessage(scip, makefile, "GPFILES := $(wildcard *.gp)\n");
1181  }
1182  if( compiletex )
1183  {
1184  /* will only be applied if the filename ends with "-tex.tex" due to the standard naming scheme */
1185  SCIPinfoMessage(scip, makefile, "TEXFILES := $(wildcard *-pdf.tex)\n");
1186  }
1187  SCIPinfoMessage(scip, makefile, " \n");
1188  SCIPinfoMessage(scip, makefile, "# latexmk automatically manages the .tex files \n");
1189  SCIPinfoMessage(scip, makefile, "%s.pdf: %s.tex\n",
1190  filename, filename);
1191  if( usegp )
1192  {
1193  SCIPinfoMessage(scip, makefile, "\t@echo ------------ \n");
1194  SCIPinfoMessage(scip, makefile, "\t@echo \n");
1195  SCIPinfoMessage(scip, makefile, "\t@echo Compiling gp files to tex \n");
1196  SCIPinfoMessage(scip, makefile, "\t@echo \n");
1197  SCIPinfoMessage(scip, makefile, "\t@echo ------------ \n");
1198  SCIPinfoMessage(scip, makefile, "\t$(SHELL) -ec 'for i in $(GPFILES); \\\n");
1199  SCIPinfoMessage(scip, makefile, "\t\tdo \\\n");
1200  SCIPinfoMessage(scip, makefile, "\t\tgnuplot $$i; \\\n");
1201  SCIPinfoMessage(scip, makefile, "\t\tdone'\n");
1202  }
1203  SCIPinfoMessage(scip, makefile, "\t@echo ------------ \n");
1204  SCIPinfoMessage(scip, makefile, "\t@echo \n");
1205  SCIPinfoMessage(scip, makefile, "\t@echo Compiling tex code. This may take a while. \n");
1206  SCIPinfoMessage(scip, makefile, "\t@echo \n");
1207  SCIPinfoMessage(scip, makefile, "\t@echo ------------ \n");
1208  if( compiletex )
1209  {
1210  SCIPinfoMessage(scip, makefile, "\t$(SHELL) -ec 'for j in $(TEXFILES); \\\n");
1211  SCIPinfoMessage(scip, makefile, "\t\tdo \\\n");
1212  SCIPinfoMessage(scip, makefile, "\t\tpdflatex $$j; \\\n");
1213  SCIPinfoMessage(scip, makefile, "\t\tdone'\n");
1214  }
1215  SCIPinfoMessage(scip, makefile,
1216  "\t@latexmk -pdf -pdflatex=\"pdflatex -interaction=batchmode -shell-escape\" -use-make %s.tex \n", filename);
1217  SCIPinfoMessage(scip, makefile, "\t@make -f %s clean \n", name);
1218  SCIPinfoMessage(scip, makefile, " \n");
1219  SCIPinfoMessage(scip, makefile, "clean: \n");
1220  SCIPinfoMessage(scip, makefile, "\t@latexmk -c \n");
1221  SCIPinfoMessage(scip, makefile, "\t@rm -f report_*figure*.* \n");
1222  SCIPinfoMessage(scip, makefile, "\t@rm -f *.auxlock \n");
1223  SCIPinfoMessage(scip, makefile, "\t@rm -f *figure*.md5 \n");
1224  SCIPinfoMessage(scip, makefile, "\t@rm -f *figure*.log \n");
1225  SCIPinfoMessage(scip, makefile, "\t@rm -f *figure*.dpth \n");
1226  if( usegp )
1227  {
1228  SCIPinfoMessage(scip, makefile, "\t@rm -f *.gp \n");
1229  }
1230  SCIPinfoMessage(scip, makefile, " \n");
1231  SCIPinfoMessage(scip, makefile, "cleanall: \n");
1232  SCIPinfoMessage(scip, makefile, "\t@latexmk -C \n");
1233  SCIPinfoMessage(scip, makefile, "\t@make -f %s clean \n", name);
1234 
1235  /* close makefile */
1236  fclose(makefile);
1237 
1238  /* --- create a readme file --- */
1239 
1240  /* use same file path as the makefile */
1241  strcpy(readmename, filepath);
1242  strcat(readmename, "/");
1243  strcat(readmename, "README_");
1244  strcat(readmename, makename);
1245 
1246  /* open and write readme */
1247  readme = fopen(readmename, "w");
1248  if( readme == NULL )
1249  {
1250  return SCIP_FILECREATEERROR;
1251  }
1252 
1253  SCIPinfoMessage(scip, readme, "README: How to create a PDF file from the .tex file(s) using the %s file. \n", name);
1254  SCIPinfoMessage(scip, readme, "Note: The package pdflatex is required. \n", name);
1255  SCIPinfoMessage(scip, readme, " \n");
1256  SCIPinfoMessage(scip, readme, "Use the command\n\t'make -f %s'\nto compile. \n", name);
1257  SCIPinfoMessage(scip, readme, "Depending on the size of your problem that may take some time. \n");
1258  SCIPinfoMessage(scip, readme,
1259  "Please do not delete any new files that might be generated during the compile process. \n");
1260  SCIPinfoMessage(scip, readme, "All access files will be deleted automatically once the compilation is complete.\n");
1261  SCIPinfoMessage(scip, readme, " \n");
1262  SCIPinfoMessage(scip, readme, "Clean options: \n");
1263  SCIPinfoMessage(scip, readme, "\t'make -f %s clean' clears all present intermediate files (if any exist) \n", name);
1264  SCIPinfoMessage(scip, readme, "\t'make -f %s cleanall' clears all generated files INCLUDING .pdf \n", name);
1265 
1266  /* close readme file */
1267  fclose(readme);
1268  return SCIP_OKAY;
1269 }
1270 
1271 
1274  SCIP* scip
1275  )
1276 {
1277  /* include tex reader */
1278  SCIP_CALL(SCIPincludeReader(scip, READER_NAME, READER_DESC, READER_EXTENSION, NULL,
1279  readerFreeTex, readerReadTex, readerWriteTex, NULL));
1280 
1281  return SCIP_OKAY;
1282 }
1283 
gcg::Seeed * seeed
Definition: wrapper_seeed.h:45
SCIP_FILE * file
Definition: reader_ref.c:78
#define READER_NAME
Definition: reader_tex.cpp:63
static SCIP_RETCODE getRgbFromHex(char *hex, int *red, int *green, int *blue)
Definition: reader_tex.cpp:118
static SCIP_RETCODE getTexColorFromHex(char *hex, const char *colorname, char *code)
Definition: reader_tex.cpp:149
int getAncestorID(int ancestorindex)
gets seeed id of given ancestor id
struct DEC_Detector DEC_DETECTOR
Definition: type_detector.h:46
SCIP_RETCODE GCGwriteTexVisualization(SCIP *scip, FILE *file, int seeedid, SCIP_Bool statistics, SCIP_Bool usegp)
const int * getOpenconss()
returns array containing constraints not assigned yet
char * SCIPvisuGetColorNonzero()
Definition: params_visu.c:401
static SCIP_RETCODE writeTikzBox(SCIP *scip, FILE *file, int xmax, int ymax, int x1, int y1, int x2, int y2, const char *color)
Definition: reader_tex.cpp:360
char * SCIPvisuGetColorLinking()
Definition: params_visu.c:337
int getNConssForBlock(int block)
returns size of the vector containing conss assigned to a block
miscellaneous methods for visualizations
int getNLinkingvars()
returns size of the vector containing linking vars
const int * getMasterconss()
static SCIP_RETCODE writeTexSeeedStatistics(SCIP *scip, FILE *file, Seeed *seeed)
Definition: reader_tex.cpp:594
char * SCIPvisuGetColorLine()
Definition: params_visu.c:417
int getNVars()
returns number of vars
int getNConss()
returns the number of constraints
int getNAncestors()
returns number of ancestor seeeds
SCIP_Bool finishNextChild(std::vector< int > &childs, std::vector< SCIP_Bool > &childsfinished, int child)
Seeedpool * GCGgetSeeedpoolForSeeed(SCIP *scip, int seeedid)
SCIP_Bool unfinishedChildExists(std::vector< SCIP_Bool > const &childsfinished)
void GCGVisuFreeParams(SCIP *scip)
Definition: params_visu.c:589
static SCIP_RETCODE writeTexTitlepage(SCIP *scip, FILE *file, int *npresentedseeeds)
Definition: reader_tex.cpp:286
int getNOpenvars()
returns size of vector containing variables not assigned yet
SCIP_Bool GCGgetUseGp()
Definition: params_visu.c:533
SCIP_RETCODE SCIPincludeReaderTex(SCIP *scip)
static SCIP_RETCODE writeTexTableOfContents(SCIP *scip, FILE *file)
Definition: reader_tex.cpp:343
SCIP_RETCODE GCGgetVisualizationFilename(SCIP *scip, SeeedPtr seeed, const char *extension, char *filename)
#define READER_DESC
Definition: reader_tex.cpp:64
int getNTotalStairlinkingvars()
returns total number of stairlinking vars
int getFirstUnfinishedChild(std::vector< SCIP_Bool > const &childsfinished, std::vector< int > const &childs)
const int * getLinkingvars()
returns array containing all linking vars indices
const int * getVarsForBlock(int block)
returns array containing vars of a block
DEC_DETECTOR ** getDetectorchain()
returns detector chain as array of detector pointers
SCIP_RETCODE GCGwriteTexReport(SCIP *scip, FILE *file, int *seeedids, int *nseeeds, SCIP_Bool titlepage, SCIP_Bool toc, SCIP_Bool statistics, SCIP_Bool usegp)
Definition: reader_tex.cpp:758
GP file reader writing gnuplot files.
SCIP_DECL_READERWRITE(readerWriteTex)
Definition: reader_tex.cpp:91
SCIP_DECL_READERREAD(readerReadTex)
Definition: reader_tex.cpp:84
various SCIP helper methods
class to manage partial decompositions (aka seeed), each seeed corresponds to one seeedpool which con...
Definition: class_seeed.h:71
char * GCGgetFilePath(SCIP *scip, FILE *file)
int getID()
returns the unique id of the seeed
char * SCIPvisuGetColorOpen()
Definition: params_visu.c:385
static SCIP_RETCODE writeTexHeader(SCIP *scip, FILE *file, SCIP_Bool externalizepics)
Definition: reader_tex.cpp:187
char * SCIPvisuGetColorStairlinking()
Definition: params_visu.c:353
int SCIPconshdlrDecompGetNFinishedDecomps(SCIP *scip)
SCIP_Bool SCIPvisuGetDraftmode()
Definition: params_visu.c:272
float SCIPvisuGetNonzeroRadius(int maxindx, int maxindy, float scalingfactor)
Definition: params_visu.c:506
int getNDetectorchainInfo()
returns size of the detectorchain info vector
SCIP_RETCODE SCIPconshdlrDecompGetAllRelevantSeeeds(SCIP *scip, SEEED_WRAPPER **seeedswr, int *nseeeds)
int getNBlocks()
returns the number of blocks
char * SCIPvisuGetColorBlock()
Definition: params_visu.c:369
SCIP_RETCODE writeSeeedDetectorChainInfoLatex(SCIP *scip, FILE *file, SeeedPtr seeed, int currheight, int visucounter)
Definition: reader_tex.cpp:659
const int * getConssForBlock(int block)
returns array containing constraints assigned to a block
static SCIP_RETCODE writeTexEnding(SCIP *scip, FILE *file)
Definition: reader_tex.cpp:646
Provides wrapping to have Seeeds and Seeedpools as parameters in C-conform function headers with C++ ...
public methods for GCG variables
SCIP_DECL_READERFREE(readerFreeTex)
Definition: reader_tex.cpp:74
#define READER_EXTENSION
Definition: reader_tex.cpp:65
tex file reader for writing decomposition details to LaTeX files
const int * getOpenvars()
returns array containing variables not assigned yet
SCIP_RETCODE DECgetSeeedToWrite(SCIP *scip, SCIP_Bool transformed, SEEED_WRAPPER *seeedwrapper)
static SCIP_RETCODE writeTexSeeed(SCIP *scip, FILE *file, Seeed *seeed, Seeedpool *seeedpool, SCIP_Bool nofigure)
Definition: reader_tex.cpp:500
SCIP_Real getMaxWhiteScore()
returns the "maximum white score"
int getNDetectors()
returns the number of detectors the seeed is propagated by
char * getDetectorChainString()
the detectorchainstring contains the chars of all detectors that worked on this seeed in this order ...
int getNStairlinkingvars(int block)
returns size of the vector containing stairlinking vars
int getNMasterconss()
returns size of the vector containing master conss
int getNVarsForBlock(int block)
returns size of the vector containing vars assigned to a block
SCIP_Real getVal(int row, int col)
returns a coefficient from the coefficient matrix
int getNOpenconss()
returns size of vector containing constraints not assigned yet
SCIP_RETCODE GCGwriteGpVisualization(SCIP *scip, char *filename, char *outputname, int seeedid)
Definition: reader_gp.cpp:457
static SCIP_RETCODE writeTikzNonzeros(SCIP *scip, FILE *file, Seeed *seeed, Seeedpool *seeedpool, float radius, int xmax, int ymax)
Definition: reader_tex.cpp:383
char * SCIPvisuGetColorMastervars()
Definition: params_visu.c:321
class with functions for seeed pool where a seeed is a (potentially incomplete) description of a deco...
const int * getMastervars()
const char * DECdetectorGetName(DEC_DETECTOR *detector)
returns the name of the provided detector
const int * getStairlinkingvars(int block)
returns array containing stairlinking vars,
int GCGreportGetMaxNDecomps()
Definition: params_visu.c:547
SCIP_RETCODE GCGgetSeeedFromID(SCIP *scip, int *seeedid, SEEED_WRAPPER *seeedwr)
constraint handler for structure detection
int getNMastervars()
returns size of the vector containing master vars (hitting only constraints in the master) ...
SCIP_RETCODE GCGtexWriteMakefileAndReadme(SCIP *scip, FILE *file, SCIP_Bool usegp, SCIP_Bool compiletex)
std::string getDetectorchainInfo(int detectorchainindex)
returns detectorchain info of detector related to given detectorchain index
public methods for working with decomposition structures
SCIP_RETCODE GCGwriteTexFamilyTree(SCIP *scip, FILE *file, const char *workfolder, SEEED_WRAPPER **seeedswr, int *nseeeds)
Definition: reader_tex.cpp:850
char * SCIPvisuGetColorMasterconss()
Definition: params_visu.c:305
int SCIPconshdlrDecompGetNSeeeds(SCIP *scip)