![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Port of jline.io.tikz.TikZExporter, the network diagram behind MATLAB's MNetwork.toTikZ, exportTikZToFile, exportTikZ and tikzExportPNG. More...
#include <cstdlib>#include <fstream>#include <iostream>#include <sstream>#include <string>#include <vector>#include <sys/stat.h>#include "line/io/tikz/tikz_edge_router.h"#include "line/io/tikz/tikz_graph.h"#include "line/io/tikz/tikz_layout.h"#include "line/io/tikz/tikz_node_renderer.h"#include "line/io/tikz/tikz_options.h"#include "line/lang/qn/network_builder.h"#include "line/lang/qn/network_struct.h"#include "line/util/error.h"#include "line/util/subprocess.h"#include "line/util/tempdir.h"Go to the source code of this file.
Classes | |
| struct | line::io::TikzViewResult |
| What tikz_view produced. More... | |
Namespaces | |
| namespace | line |
| Conservation laws of a layered queueing network, enumerated from its structure. | |
| namespace | line::io |
| namespace | line::io::tikz_detail |
Functions | |
| bool | line::io::tikz_detail::is_auto_generated (const TikzNode &nd) |
| isAutoGeneratedNode: a ClassSwitch named CS_..._to_..., the name link gives the switch it inserts. | |
| std::string | line::io::tikz_detail::output_anchor (const TikzNode &nd, const TikzOptions &opt) |
| getOutputAnchor: a Queue's arrows leave its server circle when one is drawn; every other node, a Delay included, its box. | |
| std::string | line::io::tikz_detail::self_loop (const std::string &id, const TikzNode &nd, const TikzOptions &opt) |
| renderSelfLoop: the wide loop from the server circle of a Queue that draws one, the plain-node loop otherwise. | |
| bool | line::io::tikz_detail::file_exists (const std::string &p) |
| bool | line::io::tikz_detail::ends_with (const std::string &s, const std::string &suf) |
| void | line::io::tikz_detail::write_text (const std::string &path, const std::string &text) |
| void | line::io::tikz_detail::copy_file (const std::string &from, const std::string &to) |
| std::string | line::io::tikz_detail::compile_pdf (const std::string &tex, const util::TempDir &dir) |
| exportToPDF: compile tex in a fresh directory and return the PDF path. | |
| std::string | line::io::to_tikz (const TikzGraph &g, const TikzOptions &opt=TikzOptions()) |
| TikZExporter.generateTikZ over an extracted graph. | |
| template<class T> | |
| std::string | line::io::to_tikz (const qn::NetworkStruct< T > &sn, const TikzOptions &opt=TikzOptions()) |
| Network.toTikZ(options) over a network struct. | |
| template<class T> | |
| std::string | line::io::to_tikz (qn::Network< T > &model, const TikzOptions &opt=TikzOptions()) |
| Network.toTikZ(options); refreshes the struct, as the JAR's getStruct() does. | |
| bool | line::io::tikz_pdflatex_available () |
| Can pdflatex --version run? | |
| template<class M> | |
| void | line::io::export_tikz_to_file (M &model, const std::string &tex_path, const TikzOptions &opt=TikzOptions()) |
| Network.exportTikZToFile: the document, written to tex_path as given. | |
| template<class M> | |
| std::string | line::io::export_tikz (M &model, const std::string &path, const TikzOptions &opt=TikzOptions()) |
| Network.exportTikZ: write <stem>.tex and compile it to <stem>.pdf, where the stem is path less a .pdf or .tex suffix. | |
| template<class M> | |
| std::string | line::io::tikz_export_png (M &model, const std::string &path, int dpi=150, const TikzOptions &opt=TikzOptions()) |
| Network.tikzExportPNG(path, dpi): compile the document and rasterise it with pdftoppm -png -r dpi -singlefile. | |
| std::string | line::io::tikz_detail::find_on_path (const std::string &cmd) |
| The first executable named cmd on PATH, empty when there is none (TikZViewer.isCommandAvailable). | |
| bool | line::io::tikz_detail::spawn_detached (const std::vector< std::string > &argv) |
| Start argv detached (own session, std streams on /dev/null, double fork so no zombie); false if it cannot start. | |
| bool | line::io::tikz_detail::display_pdf (const std::string &pdf) |
| TikZViewer.displayPDF: a standalone viewer first, then the desktop default; false when neither is found. | |
| const std::string & | line::io::tikz_detail::model_name (const TikzGraph &g) |
| template<class T> | |
| const std::string & | line::io::tikz_detail::model_name (const qn::NetworkStruct< T > &sn) |
| template<class T> | |
| const std::string & | line::io::tikz_detail::model_name (qn::Network< T > &m) |
| template<class M> | |
| TikzViewResult | line::io::tikz_view (M &model, const TikzOptions &opt=TikzOptions(), bool open_viewer=true) |
| MNetwork.tikzView (TikZExporter.display). | |
Variables | |
| constexpr int | line::io::tikz_detail::kToolTimeout = 600 |
| Seconds a pdflatex or pdftoppm run may take before it is killed; a TikZ picture needs a few. | |
Port of jline.io.tikz.TikZExporter, the network diagram behind MATLAB's MNetwork.toTikZ, exportTikZToFile, exportTikZ and tikzExportPNG.
to_tikz returns a complete standalone LaTeX document: the JAR's preamble and styles, one TikZ node per network node at its layered-layout position (tikz/tikz_layout.h), then one arrow per connection, routed around the nodes in its way (tikz/tikz_edge_router.h). The text is the JAR's for the same model and options, byte for byte.
EDGE ORDER. Source nodes in model order (the drawn ones), and for each its targets in ascending node index, the order of the connection-matrix row, whether they are reached directly or through hidden class switches. The JAR writes the same order (a node-index TreeSet, since it replaced a HashSet of identity-hashed nodes), and so does MATLAB, which draws through the JAR.
Every arrow is unlabelled: generateTikZ passes a NaN probability for every edge, so show_routing_prob never takes effect, here as there.
export_tikz and tikz_export_png shell out to pdflatex (and pdftoppm, from poppler-utils) through util::capture; tikz_pdflatex_available says whether the first can run. tikz_view is MNetwork.tikzView (the JAR's TikZExporter.display): it compiles the PDF into a directory it leaves in place and opens it in a standalone viewer when asked to and one is on PATH.
Definition in file tikz.h.