Scippy

GCG

Branch-and-Price & Column Generation for Everyone

reader_tex.cpp File Reference

Detailed Description

tex file reader for writing partialdecs to LaTeX files

Author
Hanna Franzen

Definition in file reader_tex.cpp.

#include <cassert>
#include <cstring>
#include <cstdio>
#include <vector>
#include <sstream>
#include <algorithm>
#include "gcg/reader_tex.h"
#include "gcg/scip_misc.h"
#include "gcg/reader_gp.h"
#include "gcg/cons_decomp.h"
#include "gcg/cons_decomp.hpp"
#include "gcg/pub_decomp.h"
#include "gcg/miscvisualization.h"
#include "gcg/class_partialdecomp.h"
#include "gcg/class_detprobdata.h"
#include "gcg/params_visu.h"

Go to the source code of this file.

Data Structures

struct  SCIP_ReaderData
 

Macros

#define READER_NAME   "texreader"
 
#define READER_DESC   "LaTeX file writer for partialdec visualization"
 
#define READER_EXTENSION   "tex"
 

Functions

 SCIP_DECL_READERFREE (readerFreeTex)
 
 SCIP_DECL_READERREAD (readerReadTex)
 
 SCIP_DECL_READERWRITE (readerWriteTex)
 
static SCIP_RETCODE getRgbFromHex (const char *hex, int *red, int *green, int *blue)
 
static SCIP_RETCODE getTexColorFromHex (const char *hex, const char *colorname, char *code)
 
static SCIP_RETCODE writeTexHeader (GCG *gcg, FILE *file, SCIP_Bool externalizepics)
 
static SCIP_RETCODE writeTexTitlepage (GCG *gcg, FILE *file, int *npresentedpartialdecs)
 
static SCIP_RETCODE writeTexTableOfContents (SCIP *scip, FILE *file)
 
static SCIP_RETCODE writeTikzBox (SCIP *scip, FILE *file, int xmax, int ymax, int x1, int y1, int x2, int y2, const char *color)
 
static SCIP_RETCODE writeTikzNonzeros (SCIP *scip, FILE *file, PARTIALDECOMP *partialdec, float radius, int xmax, int ymax)
 
static SCIP_RETCODE writeTexPartialdec (GCG *gcg, FILE *file, PARTIALDECOMP *partialdec, SCIP_Bool nofigure)
 
static SCIP_RETCODE writeTexPartialdecStatistics (GCG *gcg, FILE *file, PARTIALDECOMP *partialdec)
 
static SCIP_RETCODE writeTexEnding (SCIP *scip, FILE *file)
 
SCIP_RETCODE GCGwriteTexReport (GCG *gcg, FILE *file, int *partialdecids, int *npartialdecs, SCIP_Bool titlepage, SCIP_Bool toc, SCIP_Bool statistics, SCIP_Bool usegp)
 
SCIP_RETCODE GCGwriteTexVisualization (GCG *gcg, FILE *file, int partialdecid, SCIP_Bool statistics, SCIP_Bool usegp)
 
SCIP_RETCODE GCGtexWriteMakefileAndReadme (GCG *gcg, FILE *file, SCIP_Bool usegp, SCIP_Bool compiletex)
 
SCIP_RETCODE GCGincludeReaderTex (GCG *gcg)
 

Macro Definition Documentation

◆ READER_NAME

#define READER_NAME   "texreader"

Definition at line 55 of file reader_tex.cpp.

◆ READER_DESC

#define READER_DESC   "LaTeX file writer for partialdec visualization"

Definition at line 56 of file reader_tex.cpp.

◆ READER_EXTENSION

#define READER_EXTENSION   "tex"

Definition at line 57 of file reader_tex.cpp.

Function Documentation

◆ SCIP_DECL_READERFREE()

SCIP_DECL_READERFREE ( readerFreeTex  )

Destructor of reader to free user data (called when SCIP is exiting)

Definition at line 68 of file reader_tex.cpp.

References NULL, SCIP_OKAY, SCIPfreeMemory, and SCIPreaderGetData().

◆ SCIP_DECL_READERREAD()

SCIP_DECL_READERREAD ( readerReadTex  )

Problem reading method of reader. Since the reader is not supposed to read files this returns a reading error.

Definition at line 82 of file reader_tex.cpp.

References SCIP_READERROR.

◆ SCIP_DECL_READERWRITE()

SCIP_DECL_READERWRITE ( readerWriteTex  )

◆ getRgbFromHex()

static SCIP_RETCODE getRgbFromHex ( const char *  hex,
int *  red,
int *  green,
int *  blue 
)
static

Outputs the r, g, b decimal values for the rgb hex input

Returns
SCIP status
Parameters
hexinput hex rgb code of form "#000000"
redoutput decimal r
greenoutput decimal g
blueoutput decimal b

Definition at line 121 of file reader_tex.cpp.

References b, r, SCIP_MAXSTRLEN, and SCIP_OKAY.

Referenced by getTexColorFromHex().

◆ getTexColorFromHex()

static SCIP_RETCODE getTexColorFromHex ( const char *  hex,
const char *  colorname,
char *  code 
)
static

Converts a hex color code into a tex-conform line of code that defines the color as "colorname"

Returns
SCIP status
Parameters
hexhex code for color
colornamename of color
codeoutput resulting code line

Definition at line 154 of file reader_tex.cpp.

References b, getRgbFromHex(), r, SCIP_MAXSTRLEN, and SCIP_OKAY.

Referenced by writeTexHeader().

◆ writeTexHeader()

static SCIP_RETCODE writeTexHeader ( GCG *  gcg,
FILE *  file,
SCIP_Bool  externalizepics 
)
static

Write LaTeX code header & begin of document to given file

Returns
SCIP status
Parameters
gcgGCG data structure
fileFile pointer to write to
externalizepicswhether to use the tikz externalize package

Definition at line 194 of file reader_tex.cpp.

References GCGgetOrigprob(), GCGgetUseGp(), GCGvisuGetColorBlock(), GCGvisuGetColorLine(), GCGvisuGetColorLinking(), GCGvisuGetColorMasterconss(), GCGvisuGetColorMastervars(), GCGvisuGetColorNonzero(), GCGvisuGetColorOpen(), GCGvisuGetColorStairlinking(), getTexColorFromHex(), SCIP_MAXSTRLEN, SCIP_OKAY, and SCIPinfoMessage().

Referenced by GCGwriteTexReport(), and GCGwriteTexVisualization().

◆ writeTexTitlepage()

static SCIP_RETCODE writeTexTitlepage ( GCG *  gcg,
FILE *  file,
int *  npresentedpartialdecs 
)
static

Write LaTeX code title page that includes general statistics about the problem to given file

Returns
SCIP status
Parameters
gcgGCG data structure
fileFile pointer to write to
npresentedpartialdecsNumber of decompositions to be shown in the file or NULL if unknown

Definition at line 297 of file reader_tex.cpp.

References GCGconshdlrDecompGetNDecomps(), GCGconshdlrDecompGetNPartialdecs(), GCGgetCurrentScore(), GCGgetOrigprob(), GCGscoreGetDesc(), NULL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPgetNOrigConss(), SCIPgetNOrigVars(), SCIPgetProbName(), SCIPinfoMessage(), and SCIPsplitFilename().

Referenced by GCGwriteTexReport().

◆ writeTexTableOfContents()

static SCIP_RETCODE writeTexTableOfContents ( SCIP *  scip,
FILE *  file 
)
static

Write LaTeX code for table of contents to given file

Returns
SCIP status
Parameters
scipSCIP data structure
fileFile pointer to write to

Definition at line 363 of file reader_tex.cpp.

References SCIP_OKAY, and SCIPinfoMessage().

Referenced by GCGwriteTexReport().

◆ writeTikzBox()

static SCIP_RETCODE writeTikzBox ( SCIP *  scip,
FILE *  file,
int  xmax,
int  ymax,
int  x1,
int  y1,
int  x2,
int  y2,
const char *  color 
)
static

Writes tikz code for a box

Returns
SCIP status
Parameters
scipSCIP data structure
fileFile pointer to write to
xmaxmaximum x axis value
ymaxmaximum y axis value
x1x value of lower left vertex coordinate
y1y value of lower left vertex coordinate
x2x value of upper right vertex coordinate
y2y value of upper right vertex coordinate
colorcolor name of box color

Definition at line 381 of file reader_tex.cpp.

References SCIP_OKAY, and SCIPinfoMessage().

Referenced by writeTexPartialdec().

◆ writeTikzNonzeros()

◆ writeTexPartialdec()

static SCIP_RETCODE writeTexPartialdec ( GCG *  gcg,
FILE *  file,
PARTIALDECOMP *  partialdec,
SCIP_Bool  nofigure 
)
static

◆ writeTexPartialdecStatistics()

static SCIP_RETCODE writeTexPartialdecStatistics ( GCG *  gcg,
FILE *  file,
PARTIALDECOMP *  partialdec 
)
static

Writes LaTeX code for some statistics about the partialdec:

  • amount of blocks
  • amount of master, linking, stairlinking variables
  • amount of master constraints
  • score
Returns
SCIP status
Parameters
gcgGCG data structure
filefile to write to
partialdecstatistics are about this partialdec

Definition at line 629 of file reader_tex.cpp.

References GCGdetectorGetName(), GCGgetCurrentScore(), GCGgetOrigprob(), gcg::PARTIALDECOMP::getDetectorchain(), gcg::PARTIALDECOMP::getNBlocks(), gcg::PARTIALDECOMP::getNLinkingvars(), gcg::PARTIALDECOMP::getNMasterconss(), gcg::PARTIALDECOMP::getNMastervars(), gcg::PARTIALDECOMP::getNTotalStairlinkingvars(), gcg::PARTIALDECOMP::getScore(), gcg::PARTIALDECOMP::getUsergiven(), gcg::NOT, SCIP_OKAY, and SCIPinfoMessage().

Referenced by GCGwriteTexReport(), and GCGwriteTexVisualization().

◆ writeTexEnding()

static SCIP_RETCODE writeTexEnding ( SCIP *  scip,
FILE *  file 
)
static

Write LaTeX code for end of document to given file

Returns
SCIP status
Parameters
scipSCIP data structure
fileFile pointer to write to

Definition at line 681 of file reader_tex.cpp.

References SCIP_OKAY, and SCIPinfoMessage().

Referenced by GCGwriteTexReport(), and GCGwriteTexVisualization().

◆ GCGwriteTexReport()

SCIP_RETCODE GCGwriteTexReport ( GCG *  gcg,
FILE *  file,
int *  partialdecids,
int *  npartialdecs,
SCIP_Bool  titlepage,
SCIP_Bool  toc,
SCIP_Bool  statistics,
SCIP_Bool  usegp 
)

Writes a report for the given partialdecs

Note
*npartialdecs will be set to the number of actually written decompositions.
Returns
SCIP status
Parameters
gcgGCG data structure
filefile in which to put the LaTeX code
partialdecidsids of partialdecs to visualize
npartialdecsnumber of partialdecs to visualize
titlepagetrue if a title page should be included in the document
toctrue if an interactive table of contents should be included
statisticstrue if statistics for each partialdec should be included
usegptrue if the gp reader should be used for the image generation

Definition at line 693 of file reader_tex.cpp.

References a, b, gcg::PARTIALDECOMP::buildDecChainString(), FALSE, GCGconshdlrDecompGetPartialdecFromID(), GCGgetFilePath(), GCGgetOrigprob(), GCGgetVisualizationFilename(), GCGreportGetMaxNDecomps(), GCGtexWriteMakefileAndReadme(), GCGwriteGpVisualization(), gcg::PARTIALDECOMP::getID(), gcg::PARTIALDECOMP::getNBlocks(), NULL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPinfoMessage(), SCIPsnprintf(), SCIPsplitFilename(), TRUE, writeTexEnding(), writeTexHeader(), writeTexPartialdec(), writeTexPartialdecStatistics(), writeTexTableOfContents(), and writeTexTitlepage().

Referenced by reportAllDecompositions().

◆ GCGwriteTexVisualization()

SCIP_RETCODE GCGwriteTexVisualization ( GCG *  gcg,
FILE *  file,
int  partialdecid,
SCIP_Bool  statistics,
SCIP_Bool  usegp 
)

Writes visualization LaTeX code for the given partialdec

Returns
SCIP status
Parameters
gcgGCG data structure
filefile in which to write the LaTeX code
partialdecidid of partialdec to visualize
statisticsadditionally to picture show statistics
usegptrue if the gp reader should be used for the image generation (instead of tikz)

Definition at line 785 of file reader_tex.cpp.

References FALSE, GCGconshdlrDecompGetPartialdecFromID(), GCGgetOrigprob(), GCGgetVisualizationFilename(), GCGwriteGpVisualization(), SCIP_MAXSTRLEN, SCIP_OKAY, SCIPinfoMessage(), writeTexEnding(), writeTexHeader(), writeTexPartialdec(), and writeTexPartialdecStatistics().

Referenced by SCIP_DECL_READERWRITE().

◆ GCGtexWriteMakefileAndReadme()

SCIP_RETCODE GCGtexWriteMakefileAndReadme ( GCG *  gcg,
FILE *  file,
SCIP_Bool  usegp,
SCIP_Bool  compiletex 
)

Makes a new makefile and readme for the given .tex file

Returns
SCIP status
Parameters
gcgSCIP data structure
filetex file for which the makefile & readme are generated
usegptrue if the gp reader was used for creation of images
compiletextrue if there are tex files to be compiled before main document

Definition at line 832 of file reader_tex.cpp.

References GCGgetFilePath(), GCGgetOrigprob(), NULL, SCIP_FILECREATEERROR, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPinfoMessage(), SCIPsnprintf(), and SCIPsplitFilename().

Referenced by GCGwriteTexReport().

◆ GCGincludeReaderTex()

SCIP_RETCODE GCGincludeReaderTex ( GCG *  gcg)

Includes the tex file reader into SCIP

Returns
SCIP status
Parameters
gcgGCG data structure

Definition at line 959 of file reader_tex.cpp.

References SCIP_ReaderData::gcg, GCGgetOrigprob(), NULL, READER_DESC, READER_EXTENSION, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPallocMemory, and SCIPincludeReader().

Referenced by GCGincludeGcgPlugins().