Skip to content

Latest commit

 

History

History

python

README.md

LINE Solver for Python

The Python version of the LINE solver for queueing models.

Installation

Requires Python 3.11 or later.

pip install line-solver

To install from source, run pip install . in this folder. Then run line-install to check optional dependencies such as Java and the symbolic backend (it only warns, never fails).

Quick start

The tutorials ship with the package and run from any directory:

python3 -m line_solver.examples.gettingstarted.tut01_mm1_basics

From a source checkout, python3 mm1.py solves an M/M/1 queue at 50% utilization and prints:

Station  JobClass  QLen  Util  RespT  ResidT  ArvR  Tput
Source   Class1       0     0      0       0     0     1
Queue    Class1       1   0.5      1       1     1     1

You can also open mm1.ipynb in Jupyter. More tutorials are in examples/gettingstarted/.

Documentation

See the Python manual. The syntax closely mirrors the MATLAB version: compare the examples/gettingstarted/ scripts of the two.

Choosing the engine (lang=)

Every solver takes a lang keyword that selects which engine does the work. The model code stays the same:

MVA(model).avg_table()                  # native Python (default)
MVA(model, lang="java").avg_table()     # Java engine (jline.jar)
MVA(model, lang="cpp").avg_table()      # C++ engine (line-cli)
lang Needs Solvers
"python" nothing all
"java" a Java runtime all
"cpp" the line-cli binary MVA, NC, CTMC, MAM, FLD, SSA, BA, AG, AUTO, JMT, LN (steady state), ENV
  • Java: the JAR is taken from $LINE_JLINE_JAR, the installed package or a checkout's common/, and downloaded automatically if none is found.
  • C++: the binary is taken from $LINE_CLI_BINARY, a checkout's common/ or cpp/build/, or PATH, and downloaded automatically (Linux x86-64) if none is found. From a source checkout you can instead build it with cmake -S cpp -B cpp/build -DCMAKE_BUILD_TYPE=Release && cmake --build cpp/build --target line-cli. It also accepts arith="exact" or arith="real:<digits>" (16, 32, 64, 128 or 256 digits) for exact or extended-precision arithmetic.

Set LINE_SOLVER_LANG=java (or cpp) to change the default for a session. If the C++ binary cannot be found or run, LINE falls back to native Python with a warning; any other error, including a missing Java runtime for lang="java", is raised.

Symbolic backend (optional)

Symbolic analysis in SolverCTMC and SolverFLD runs on a SageMath service, falling back on sympy when it is not available. To enable it, pull its Docker image once:

docker pull imperialqore/line-sage-rest:latest

LINE then starts and stops the container automatically.

License

Released under the BSD-3 license.