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 <strings.h>
#include <cstdio>
#include <vector>
#include <sstream>
#include <algorithm>
#include "reader_tex.h"
#include "scip_misc.h"
#include "reader_gp.h"
#include "cons_decomp.h"
#include "cons_decomp.hpp"
#include "pub_decomp.h"
#include "miscvisualization.h"
#include "class_partialdecomp.h"
#include "class_detprobdata.h"
#include "params_visu.h"
#include "scoretype.h"

Go to the source code of this file.

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 (SCIP *scip, FILE *file, SCIP_Bool externalizepics)
 
static SCIP_RETCODE writeTexTitlepage (SCIP *scip, 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 (SCIP *scip, FILE *file, PARTIALDECOMP *partialdec, SCIP_Bool nofigure)
 
static SCIP_RETCODE writeTexPartialdecStatistics (SCIP *scip, FILE *file, PARTIALDECOMP *partialdec)
 
static SCIP_RETCODE writeTexEnding (SCIP *scip, FILE *file)
 
SCIP_RETCODE GCGwriteTexReport (SCIP *scip, FILE *file, int *partialdecids, int *npartialdecs, SCIP_Bool titlepage, SCIP_Bool toc, SCIP_Bool statistics, SCIP_Bool usegp)
 
SCIP_RETCODE GCGwriteTexVisualization (SCIP *scip, FILE *file, int partialdecid, SCIP_Bool statistics, SCIP_Bool usegp)
 
SCIP_RETCODE GCGtexWriteMakefileAndReadme (SCIP *scip, FILE *file, SCIP_Bool usegp, SCIP_Bool compiletex)
 
SCIP_RETCODE SCIPincludeReaderTex (SCIP *scip)
 

Macro Definition Documentation

◆ READER_NAME

#define READER_NAME   "texreader"

Definition at line 59 of file reader_tex.cpp.

◆ READER_DESC

#define READER_DESC   "LaTeX file writer for partialdec visualization"

Definition at line 60 of file reader_tex.cpp.

◆ READER_EXTENSION

#define READER_EXTENSION   "tex"

Definition at line 61 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 66 of file reader_tex.cpp.

◆ 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 73 of file reader_tex.cpp.

◆ SCIP_DECL_READERWRITE()

SCIP_DECL_READERWRITE ( readerWriteTex  )

Problem writing method of reader

Definition at line 79 of file reader_tex.cpp.

References DECgetPartialdecToWrite(), RefInput::file, GCGwriteTexVisualization(), and gcg::PARTIALDECOMP::getID().

◆ 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 108 of file reader_tex.cpp.

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 141 of file reader_tex.cpp.

References getRgbFromHex().

Referenced by writeTexHeader().

◆ writeTexHeader()

static SCIP_RETCODE writeTexHeader ( SCIP *  scip,
FILE *  file,
SCIP_Bool  externalizepics 
)
static

Write LaTeX code header & begin of document to given file

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

Definition at line 181 of file reader_tex.cpp.

References RefInput::file, GCGgetUseGp(), getTexColorFromHex(), SCIPvisuGetColorBlock(), SCIPvisuGetColorLine(), SCIPvisuGetColorLinking(), SCIPvisuGetColorMasterconss(), SCIPvisuGetColorMastervars(), SCIPvisuGetColorNonzero(), SCIPvisuGetColorOpen(), and SCIPvisuGetColorStairlinking().

Referenced by GCGwriteTexReport(), and GCGwriteTexVisualization().

◆ writeTexTitlepage()

static SCIP_RETCODE writeTexTitlepage ( SCIP *  scip,
FILE *  file,
int *  npresentedpartialdecs 
)
static

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

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

Definition at line 282 of file reader_tex.cpp.

References RefInput::file, GCGconshdlrDecompGetNDecomps(), GCGconshdlrDecompGetNPartialdecs(), GCGconshdlrDecompGetScoretype(), and GCGscoretypeGetDescription().

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 347 of file reader_tex.cpp.

References RefInput::file.

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 365 of file reader_tex.cpp.

References RefInput::file.

Referenced by writeTexPartialdec().

◆ writeTikzNonzeros()

◆ writeTexPartialdec()

static SCIP_RETCODE writeTexPartialdec ( SCIP *  scip,
FILE *  file,
PARTIALDECOMP partialdec,
SCIP_Bool  nofigure 
)
static

Writes LaTeX code that contains a figure with a tikz picture of the given partialdec

Returns
SCIP status
Parameters
scipSCIP data structure
filefile to write to
partialdecPARTIALDECOMP to be visualized
nofigureif true there will be no figure environment around tikz code

Definition at line 511 of file reader_tex.cpp.

References RefInput::file, gcg::PARTIALDECOMP::getNBlocks(), gcg::PARTIALDECOMP::getNConss(), gcg::PARTIALDECOMP::getNConssForBlock(), gcg::PARTIALDECOMP::getNLinkingvars(), gcg::PARTIALDECOMP::getNMasterconss(), gcg::PARTIALDECOMP::getNMastervars(), gcg::PARTIALDECOMP::getNOpenconss(), gcg::PARTIALDECOMP::getNOpenvars(), gcg::PARTIALDECOMP::getNStairlinkingvars(), gcg::PARTIALDECOMP::getNVars(), gcg::PARTIALDECOMP::getNVarsForBlock(), SCIPvisuGetDraftmode(), SCIPvisuGetNonzeroRadius(), writeTikzBox(), and writeTikzNonzeros().

Referenced by GCGwriteTexReport(), and GCGwriteTexVisualization().

◆ writeTexPartialdecStatistics()

static SCIP_RETCODE writeTexPartialdecStatistics ( SCIP *  scip,
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
scipSCIP data structure
filefile to write to
partialdecstatistics are about this partialdec

Definition at line 612 of file reader_tex.cpp.

References DECdetectorGetName(), RefInput::file, GCGconshdlrDecompGetScoretype(), gcg::PARTIALDECOMP::getDetectorchain(), gcg::PARTIALDECOMP::getNBlocks(), gcg::PARTIALDECOMP::getNLinkingvars(), gcg::PARTIALDECOMP::getNMasterconss(), gcg::PARTIALDECOMP::getNMastervars(), gcg::PARTIALDECOMP::getNTotalStairlinkingvars(), gcg::PARTIALDECOMP::getScore(), gcg::PARTIALDECOMP::getUsergiven(), and gcg::NOT.

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 663 of file reader_tex.cpp.

References RefInput::file.

Referenced by GCGwriteTexReport(), and GCGwriteTexVisualization().

◆ GCGwriteTexReport()

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

◆ GCGwriteTexVisualization()

SCIP_RETCODE GCGwriteTexVisualization ( SCIP *  scip,
FILE *  file,
int  partialdecid,
SCIP_Bool  statistics,
SCIP_Bool  usegp 
)

Writes visualization LaTeX code for the given partialdec

Returns
SCIP status

Definition at line 767 of file reader_tex.cpp.

References RefInput::file, GCGconshdlrDecompGetPartialdecFromID(), GCGgetVisualizationFilename(), GCGwriteGpVisualization(), writeTexEnding(), writeTexHeader(), writeTexPartialdec(), and writeTexPartialdecStatistics().

Referenced by SCIP_DECL_READERWRITE().

◆ GCGtexWriteMakefileAndReadme()

SCIP_RETCODE GCGtexWriteMakefileAndReadme ( SCIP *  scip,
FILE *  file,
SCIP_Bool  usegp,
SCIP_Bool  compiletex 
)

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

Returns
SCIP status

Definition at line 813 of file reader_tex.cpp.

References RefInput::file, and GCGgetFilePath().

Referenced by GCGwriteTexReport().

◆ SCIPincludeReaderTex()

SCIP_RETCODE SCIPincludeReaderTex ( SCIP *  scip)

Includes the tex file reader into SCIP

Returns
SCIP status

Definition at line 939 of file reader_tex.cpp.

References READER_DESC, READER_EXTENSION, and READER_NAME.

Referenced by SCIPincludeGcgPlugins().