Quick Start Guide
This guide will help you get started with LINE Solver for Python. The solvers are a native
Python implementation and need no JVM; the same model can also be handed to LINE’s Java or
C++ engine with the lang keyword, as shown in Choosing the Engine: lang='java' and lang='cpp' below.
Creating a Simple Model
Here’s a simple M/M/1 queue example:
from line_solver import *
model = Network('M/M/1 Queue')
# Create nodes
source = Source(model, 'Source')
queue = Queue(model, 'Queue', SchedStrategy.FCFS)
sink = Sink(model, 'Sink')
# Create job class
jobclass = OpenClass(model, 'Class1')
# Set service process
queue.set_service(jobclass, Exp(1.0))
# Set arrival process
source.set_arrival(jobclass, Exp(0.5))
# Link nodes
model.link(Network.serial_routing([source, queue, sink]))
# Solve
solver = MVA(model)
result = solver.avg_table()
print(result)
Choosing the Engine: lang='java' and lang='cpp'
Every solver constructor accepts a lang keyword naming the codebase that should
actually solve the model. The model script itself does not change:
MVA(model).avg_table() # native Python (default)
MVA(model, lang="java").avg_table() # solved by the Java JAR (jline.jar)
MVA(model, lang="cpp").avg_table() # solved by the C++ engine (line-cli)
lang='java' needs a Java runtime and serves every solver; lang='cpp' needs the
line-cli binary and serves MVA, NC, CTMC, MAM, FLD, SSA,
BA, AG, AUTO, JMT, LN and ENV. Setting LINE_SOLVER_LANG
switches the default for a whole session. See Solver Backends: lang='java', lang='cpp' for the full details.
Available Solvers
LINE provides multiple solvers for Network models:
AUTO: Wrapper for Automatic Solver Selection
CTMC: Continuous-Time Markov Chain solver
FLD: Fluid/Mean-Field ODE Solver
MAM: Matrix Analytic Methods solver
MVA: Mean Value Analysis solver
NC: Normalizing Constant Analyzer
SSA: Stochastic Simulation Algorithm solver
Composite models such as LayeredNetworks or models coupled with a random environment can be evaluated by the following solvers:
ENV: Blending solver for Random Environments
LN: Layered Network Solver
Wrappers for external solvers include:
JMT: Wrapper for Java Modelling Tools
QNS: Wrapper for the QNS utility part of LQNS
LQNS: Wrapper for the Layered Queueing Network Solver