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 <cmath>
#include <fstream>
#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.

Namespaces

namespace  line
namespace  line::io

Functions

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::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.