![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
#include <algorithm>#include <chrono>#include <cctype>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <fstream>#include <iostream>#include <iterator>#include <limits>#include <sstream>#include <string>#include <vector>#include "line/util/line_console.h"#include "line/api/sn/sn_node_metrics.h"#include "line/solvers/solver_node_tables.h"#include "line/api/sn/sn_state.h"#include "line/api/sym/sym_engines.h"#include "line/io/docker_image.h"#include "line/io/environment_reader.h"#include "line/io/jsim_reader.h"#include "line/io/network_reader.h"#include "line/io/pnml.h"#include "line/io/lqn_json_reader.h"#include "line/lang/lqn/lqn_reader.h"#include "line/num/number.h"#include "line/reg/api_dispatch.h"#include "line/reg/registry.h"#include "line/util/method_type.h"#include "line/solvers/auto/auto_methods.h"#include "line/solvers/auto/solver_auto.h"#include "line/solvers/ba/solver_ba_runner.h"#include "line/solvers/solver_default_cdf.h"#include "line/solvers/ctmc/solver_ctmc_analyzer.h"#include "line/solvers/ctmc/solver_ctmc_cdf.h"#include "line/solvers/ctmc/solver_ctmc_cftp.h"#include "line/solvers/ctmc/solver_ctmc_getters.h"#include "line/solvers/ctmc/solver_ctmc_mdd_analyzer.h"#include "line/solvers/ctmc/solver_ctmc_prob.h"#include "line/solvers/ctmc/solver_ctmc_reward.h"#include "line/solvers/ctmc/solver_ctmc_sample.h"#include "line/solvers/ctmc/solver_ctmc_sens.h"#include "line/solvers/ctmc/solver_ctmc_waitq.h"#include "line/solvers/env/env_dispatch.h"#include "line/solvers/fluid/fluid_jacobian.h"#include "line/solvers/fluid/fluid_runner.h"#include "line/solvers/fluid/solver_fluid.h"#include "line/solvers/ldes/ldes_ln_engine.h"#include "line/solvers/ln/solver_ln.h"#include "line/solvers/ag/ag_dispatch.h"#include "line/solvers/mam/solver_mam_runner.h"#include "line/solvers/mva/solver_mva_prob.h"#include "line/solvers/mva/solver_mva_runner.h"#include "line/solvers/nc/solver_nc_busyp.h"#include "line/solvers/nc/solver_nc_cdf.h"#include "line/solvers/nc/solver_nc_prob.h"#include "line/solvers/nc/solver_nc_runner.h"#include "line/solvers/sens/solver_sens_table.h"#include "line/solvers/solver_chain_tables.h"#include "line/solvers/ssa/solver_ssa_getters.h"#include "line/solvers/ssa/ssa_dispatch.h"#include "line/solvers/uq/uq_dispatch.h"#include "line/solvers/wrappers/ldes/solver_ldes.h"#include "line/solvers/wrappers/jmt/jmt_logs.h"#include "line/solvers/wrappers/jmt/solver_jmt.h"#include "line/solvers/wrappers/lqns/solver_lqns.h"#include "line/solvers/wrappers/qns/solver_qns.h"#include "line/util/error.h"#include "line/util/websocket.h"Go to the source code of this file.
Macros | |
| #define | LINE_CLI_TABLE_LADDER(FN) |
Functions | |
| int | find_solver_report (const Options &o) |
| Everything one invocation does once the arguments are in hand. | |
| int | run_invocation (Options o) |
| std::string | run_invocation_captured (Options o, int &rc) |
| Run one invocation with stdout captured, and return what it printed. | |
| int | run_server (const Options &base) |
| -p/--port: serve solve requests over a WebSocket, as LineWebSocketServer does. | |
| int | main (int argc, char **argv) |
| #define LINE_CLI_TABLE_LADDER | ( | FN | ) |
| int find_solver_report | ( | const Options & | o | ) |
Everything one invocation does once the arguments are in hand.
SPLIT OUT OF main FOR SERVER MODE, which runs it once per request with a different -f and a captured stdout. Keeping one body means a request served over the socket takes exactly the path the same command line takes at the shell – the failure this avoids is a server that answers slightly differently from the CLI it is supposed to BE. --find-solver: which solvers and methods can analyze the model named by -f.
It reports rather than solves, so it stops before the solver ladder in solve_model_dispatch and before every knob that describes a run. The answer is arithmetic-independent – auto_find_solver asks feature sets, shapes and gates, never numbers – so the model is read at double whatever –arith says, and a caller who passed one is told rather than silently obeyed.
The layered path is not covered: auto_find_solver narrows the flat Network families, and a LayeredNetwork's are ln and lqns, which this port reaches through solve_lqn_dispatch and not through an AUTO of its own.
Definition at line 10391 of file line_cli.cpp.
References line::autosolver::auto_find_solver(), line::autosolver::auto_find_solver_table(), find_solver_report(), line::qn::Network< T >::get_struct(), and line::io::is_layered_json().
Referenced by find_solver_report(), and main().
| int main | ( | int | argc, |
| char ** | argv ) |
Definition at line 10645 of file line_cli.cpp.
References line::util::DEBUG, find_solver_report(), main(), run_invocation(), run_server(), line::util::LineConsole::set_verbose(), line::util::SILENT, and line::util::STD.
| int run_invocation | ( | Options | o | ) |
Definition at line 10405 of file line_cli.cpp.
References line::reg::api_invoke(), line::reg::api_render_readable(), line::io::is_layered_json(), line::reg::parse_arith(), and run_invocation().
Referenced by main(), run_invocation(), and run_invocation_captured().
| std::string run_invocation_captured | ( | Options | o, |
| int & | rc ) |
Run one invocation with stdout captured, and return what it printed.
SERVER MODE'S ONE PIECE OF MACHINERY. Every arm of this CLI writes its answer with printf, which is the right thing for a command-line tool and leaves a server nothing to send. Redirecting fd 1 around the call means the arms need no server-aware variant and cannot drift from the command-line behaviour; stderr is deliberately NOT captured, so a warning still reaches the operator's console rather than being folded into the client's answer.
Definition at line 10510 of file line_cli.cpp.
References run_invocation(), and run_invocation_captured().
Referenced by run_invocation_captured(), and run_server().
| int run_server | ( | const Options & | base | ) |
-p/--port: serve solve requests over a WebSocket, as LineWebSocketServer does.
THE PROTOCOL IS THE JAR's, unchanged: one text message per connection, whose FIRST LINE is the comma-separated argument list and whose remainder is the model document. The JAR overwrites the first two arguments with --file and the path it staged the document at, so the client's own first two tokens are placeholders; the same substitution happens here, which is what lets an existing client talk to this server without knowing which binary answered.
Definition at line 10558 of file line_cli.cpp.
References run_invocation_captured(), run_server(), and line::ws::Server::serve_one().
Referenced by main(), and run_server().