LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
network_writer.h File Reference

qn::NetworkStruct -> model.json, the inverse of network_reader.h. More...

#include <cctype>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <limits>
#include <map>
#include <string>
#include <vector>
#include "line/io/network_reader.h"
#include "line/lang/distribution.h"
#include "line/lang/lang_types.h"
#include "line/lang/qn/network_struct.h"
#include "line/num/number.h"
#include "line/util/error.h"
Include dependency graph for network_writer.h:

Go to the source code of this file.

Classes

struct  line::io::PasSaturation
 The per-class saturation cutoffs of a count-indexed rate table. More...

Namespaces

namespace  line
 Conservation laws of a layered queueing network, enumerated from its structure.
namespace  line::io

Functions

PasSaturation line::io::saturation_cutoffs (const std::function< std::vector< double >(const std::vector< int > &)> &f_at, std::size_t K, double cmax=std::numeric_limits< double >::infinity(), int max_cutoff=256, double tol=1e-9)
 Per-class saturation cutoffs of a count-indexed function f(n), the search behind the OI/PAS and class/joint-dependence table extents.
template<class T>
PasSaturation line::io::pas_saturation_cutoffs (const std::function< T(const std::vector< std::size_t > &)> &mu, std::size_t K, double cmax=std::numeric_limits< double >::infinity())
 The saturation cutoffs of an order-independent rate mu(c), searched over the states a buffer of cmax jobs can hold (see saturation_cutoffs).
template<class T>
detail::json line::io::network_to_json (const qn::NetworkStruct< T > &sn)
 qn::NetworkStruct -> the model.json model object.
template<class T>
detail::json line::io::network_json_envelope (const qn::NetworkStruct< T > &sn)
 The complete model.json envelope: {format, version, model}.
template<class T>
void line::io::require_finite_pas_buffers (const qn::NetworkStruct< T > &sn)
 Refuse an OI/PAS station with no finite buffer before it reaches LDES.
template<class T>
void line::io::write_network_json (const qn::NetworkStruct< T > &sn, const std::string &path)
 Write a model.json file, indented as the reference writers indent it.

Detailed Description

qn::NetworkStruct -> model.json, the inverse of network_reader.h.

The wire format is the one linemodel_save.m, the Python save_model and the JAR LineModelIO write, so a model saved here loads in any of the four codebases and a model saved by any of them and read back here is unchanged.

WHAT IS AND IS NOT ROUND-TRIPPABLE. Two things on a model are FUNCTIONS, and a function cannot cross JSON:

the rate-scaling handles beta_r(n), eta_i(n) and the OI mu(c) a reward built from a lambda

The reference solves the first by MATERIALIZING the handle over the per-class box lattice, and this writer does the same, with the same cutoffs (a closed class's population, or 10 for an open one) and the same comma-joined key, so the table is byte-comparable with MATLAB's. The second it solves by writing only the DECLARATIVE rewards and warning about the rest; here a reward with no kind is omitted for the same reason – emitting a guess would produce a model.json that reloads into a different reward.

EVERY OTHER KEY IS EXACT. The writer emits exactly the keys the reader consumes, which is what makes the round trip a test rather than a hope: a field added to one side without the other shows up as a read-back mismatch in test_network_roundtrip.cpp.

Definition in file network_writer.h.