API Documentation

This section provides detailed API documentation for all LINE Solver Python modules.

API Submodules

Cache API (line_solver.api.cache)

Cache modeling algorithms and analysis functions.

This module provides low-level functions for analyzing cache systems, including miss ratios, replacement policies, and performance metrics for various cache configurations.

These functions are primarily used internally by higher-level cache models and solvers.

cache_mva(gamma, m)[source]

Mean Value Analysis for cache systems.

Computes cache performance metrics using MVA approach.

Parameters:
  • gamma – Request rate matrix.

  • m – Cache size parameters.

Returns:

(pi, pi0, pij, x, u, E) containing steady-state probabilities,

throughputs, utilizations, and error metrics.

Return type:

tuple

cache_prob_asy(gamma, m)[source]

Compute asymptotic cache miss probabilities.

Parameters:
  • gamma – Request rate matrix.

  • m – Cache size parameters.

Returns:

Asymptotic miss probabilities.

Return type:

numpy.ndarray

cache_gamma_lp(lambda_array, R)[source]

Linear programming method for cache analysis using gamma parameters.

This function solves cache performance analysis using linear programming optimization techniques to compute hit probabilities and performance metrics.

Parameters:
  • lambda_array – Array of arrival rate matrices for different cache levels.

  • R – 2D array of cache replacement rate matrices.

Returns:

Cache performance metrics from the linear programming solution.

cache_spm(gamma, m)[source]

Singular perturbation method for cache system analysis.

This function performs rayint (singular perturbation) analysis to compute cache performance and hit probabilities using specified gamma and m parameters.

Parameters:
  • gamma – Gamma parameter matrix.

  • m – Cache configuration parameter matrix.

Returns:

(Z, lZ, xi) where:
  • Z: Normalization constant

  • lZ: Log normalization constant

  • xi: State probability matrix

Return type:

tuple

cache_xi_fp(gamma, m, xi=None)[source]

Fixed point iteration method for cache analysis.

This function uses fixed point iteration to solve for cache state probabilities and performance metrics.

Parameters:
  • gamma – Gamma parameter matrix.

  • m – Cache configuration parameter matrix.

  • xi – Optional initial state probability matrix for iteration.

Returns:

Cache performance metrics from fixed point iteration.

cache_prob_erec(gamma, m)[source]

Compute cache miss probabilities using Exact Recursion method.

Estimates cache miss probabilities using the EREC (Exact Recursion) algorithm for LRU-based cache policies.

Parameters:
  • gamma – Request rate matrix.

  • m – Cache size parameters.

Returns:

Miss probabilities for each cache level.

Return type:

numpy.ndarray

cache_prob_fpi(gamma, m)[source]

Compute cache miss probabilities using Fixed Point Iteration.

Uses fixed point iteration to compute steady-state miss probabilities for hierarchical cache systems with LRU replacement policies.

Parameters:
  • gamma – Request rate matrix.

  • m – Cache size parameters.

Returns:

Miss probabilities computed via FPI.

Return type:

numpy.ndarray

cache_prob_spm(gamma, m)[source]

Compute cache miss probabilities using singular perturbation method.

Applies rayint (singular perturbation) method to compute miss probabilities for cache systems, providing accurate results for hierarchical cache configurations.

Parameters:
  • gamma – Request rate matrix.

  • m – Cache size parameters.

Returns:

Miss probabilities computed via singular perturbation.

Return type:

numpy.ndarray

cache_erec(parameters)[source]

Exact Recursion algorithm for cache analysis.

Implements EREC (Exact Recursion) algorithm for analyzing cache replacement policies with precise computational methods.

Parameters:

parameters – Configuration parameters (dict or matrix).

Returns:

Performance metrics or numerical result from EREC computation.

cache_t_hlru(lambda_rates, capacities, n_levels=2)[source]

Compute characteristic times for H-LRU cache replacement policy.

Parameters:
  • lambda_rates – Request arrival rates matrix.

  • capacities – Cache capacity vector.

  • n_levels – Number of cache levels (default: 2).

Returns:

Characteristic time values for each cache level.

cache_t_lrum(lambda_rates, capacity, m_parameter=1)[source]

Compute characteristic times for LRU-M cache replacement policy.

Parameters:
  • lambda_rates – Request arrival rates matrix.

  • capacity – Cache capacity.

  • m_parameter – LRU-M parameter (default: 1).

Returns:

Characteristic time values.

cache_t_lrum_map(MAP, capacity, m_parameter=1)[source]

Analyze cache performance with TTI-LRU policy for MAP request arrivals.

Computes cache performance metrics for a Time-To-Idle Least Recently Used (TTI-LRU) cache replacement policy with requests arriving according to a Markovian Arrival Process (MAP).

Parameters:
  • MAP – Request arrival process as tuple (D0, D1) or MAP container {D0, D1}

  • capacity – Cache capacity (number of items that can be stored)

  • m_parameter – TTI-LRU specific parameter controlling idle time threshold (default: 1)

Returns:

Cache performance metrics including hit rates, miss rates, and other statistics

Note

TTI-LRU (Time-To-Idle LRU) is a cache replacement policy that evicts items based on both recency and idle time considerations.

cache_ttl_hlru(lambda_rates, capacities, ttl_values)[source]

Time-to-live analysis for hierarchical LRU cache.

Parameters:
  • lambda_rates – Request rates for cache items

  • capacities – Cache capacities at each level

  • ttl_values – Time-to-live values for cache items

Returns:

Cache performance metrics with TTL effects

cache_ttl_lrua(lambda_rates, capacity, alpha=1.0)[source]

Time-to-live analysis for LRU-A cache policy.

Parameters:
  • lambda_rates – Request rates for cache items

  • capacity – Cache capacity

  • alpha – Alpha parameter for LRU-A policy (default: 1.0)

Returns:

Cache performance metrics with TTL effects

cache_ttl_lrum(lambda_rates, capacity, m_parameter=1)[source]

Time-to-live analysis for LRU-M cache policy.

Parameters:
  • lambda_rates – Request rates for cache items

  • capacity – Cache capacity

  • m_parameter – M parameter for LRU-M policy (default: 1)

Returns:

Cache performance metrics with TTL effects

cache_ttl_lrum_map(MAP, capacity, m_parameter=1)[source]

Analyze cache performance with TTL-LRU-M policy for MAP request arrivals.

Computes cache performance metrics for a Time-To-Live Least Recently Used with M-parameter (TTL-LRU-M) cache replacement policy with requests arriving according to a Markovian Arrival Process (MAP).

Parameters:
  • MAP – Request arrival process as tuple (D0, D1) or MAP container {D0, D1}

  • capacity – Cache capacity (number of items that can be stored)

  • m_parameter – TTL-LRU-M specific parameter controlling eviction behavior (default: 1)

Returns:

Cache performance metrics including hit rates, miss rates, and statistics

Return type:

numpy.ndarray

Note

TTL-LRU-M combines time-to-live expiration with LRU replacement, where the m_parameter controls the eviction threshold behavior.

cache_ttl_tree(lambda_rates, tree_structure, capacities)[source]

Time-to-live analysis for tree-structured cache.

Parameters:
  • lambda_rates – Request rates for cache items

  • tree_structure – Tree structure specification

  • capacities – Cache capacities at tree nodes

Returns:

Cache performance metrics for tree structure with TTL

cache_xi_bvh(lambda_rates, capacity, bvh_params)[source]

Cache analysis with bounded virtual heap parameters.

Parameters:
  • lambda_rates – Request rates for cache items

  • capacity – Cache capacity

  • bvh_params – Bounded virtual heap parameters

Returns:

Cache performance metrics with BVH effects

cache_miss(gamma, m, lambda_matrix=None)[source]
cache_mva_miss(p, m, R)[source]
cache_miss_asy(gamma, m, max_iter=1000, tolerance=1e-8)[source]
cache_erec_aux(gamma, m, k)[source]

Auxiliary function for Exact Recursion cache analysis.

Helper function for the EREC (Exact Recursion) algorithm, handling specific parameter configurations.

Parameters:
  • gamma – Cache request rate matrix.

  • m – Cache size configuration.

  • k – Auxiliary parameter for computation.

Returns:

Auxiliary computation results.

Return type:

numpy.ndarray

cache_miss_spm(gamma, m, lambda_matrix)[source]
cache_par(R, j)[source]
cache_t_hlru_aux(x, gamma, m, n, h)[source]
cache_t_lrum_aux(x, gamma, m, n, h)[source]
cache_gamma_approx(gamma, m, options=None)[source]
cache_opt_capacity(gamma, constraints=None, options=None)[source]
cache_gamma(rates, routing)[source]

Computes cache access factors from request arrival rates and routing matrices.

Parameters:
  • rates – Arrival rates vector

  • routing – Routing probability matrix

Returns:

Cache access factors (gamma values)

Return type:

numpy.ndarray

cache_miss_fpi(cache_size, access_probs, replacement_policy='lru')[source]

Computes cache miss probabilities using fixed-point iteration methods.

Parameters:
  • cache_size – Size of the cache

  • access_probs – Item access probabilities

  • replacement_policy – Cache replacement policy (default: ‘lru’)

Returns:

Miss probabilities per item

Return type:

numpy.ndarray

cache_rrm_meanfield_ode(cache_size, access_rates, time_horizon)[source]

Implements the mean field ordinary differential equation system for Random Replacement Model (RRM) cache analysis.

Parameters:
  • cache_size – Size of the cache

  • access_rates – Item access rates

  • time_horizon – Time horizon for ODE solution

Returns:

ODE solution with time points and state probabilities

Return type:

dict

cache_rayint(cache_size, access_probs, num_items=None)[source]

Implements ray integration techniques for cache system analysis.

Uses ray method for solving partial differential equations to analyze cache behavior and compute steady-state probabilities.

Parameters:
  • cache_size – Cache capacity.

  • access_probs – Item access probabilities.

  • num_items – Number of items (optional, defaults to length of access_probs).

Returns:

Ray integration analysis results.

Return type:

dict

cache_miss_rayint(cache_size, access_probs, replacement_policy='lru')[source]

Estimates cache miss rates using ray method for partial differential equations.

Applies ray integration techniques to compute miss probabilities for different cache replacement policies.

Parameters:
  • cache_size – Cache capacity.

  • access_probs – Item access probabilities.

  • replacement_policy – Cache replacement policy (‘lru’, ‘fifo’, ‘random’).

Returns:

Miss rate and analysis results.

Return type:

dict

cache_prob_rayint(cache_size, access_probs, initial_state=None)[source]

Computes cache state probabilities using ray integration methods.

Solves the steady-state probability distribution using ray techniques for analyzing cache occupancy and state transitions.

Parameters:
  • cache_size – Cache capacity.

  • access_probs – Item access probabilities.

  • initial_state – Initial cache state (optional).

Returns:

State probabilities and convergence metrics.

Return type:

dict

Product-Form Queueing Networks (line_solver.api.pfqn)

Product-form queueing network (PFQN) algorithms.

This module implements analytical algorithms for product-form queueing networks, including Mean Value Analysis (MVA), normalizing constant methods, and various approximation techniques.

Key algorithms: - pfqn_mva: Standard Mean Value Analysis - pfqn_ca: Convolution Algorithm - pfqn_nc: Normalizing Constant methods - pfqn_bs: Balanced System analysis - pfqn_aql: Approximate queueing lengths - Various load-dependent and multi-class extensions

These functions provide the computational core for product-form network analysis in LINE.

pfqn_ca(N, L, Z)[source]

Convolution Algorithm for product-form networks.

Computes normalizing constants using the convolution algorithm.

Parameters:
  • N – Population vector.

  • L – Demand matrix (service demands = mean visits × mean service times).

  • Z – Think time vector.

Returns:

(G, lG) where G is normalizing constant and lG is log(G).

Return type:

tuple

pfqn_panacea(N, L, Z)[source]

PANACEA algorithm for product-form networks.

A hybrid algorithm that combines convolution and MVA techniques for efficient computation of normalizing constants.

Parameters:
  • N – Population vector

  • L – Demand matrix (service demands)

  • Z – Think time vector

Returns:

(G, lG) where G is normalizing constant and lG is log(G)

Return type:

tuple

pfqn_bs(N, L, Z)[source]

Balanced System analysis for product-form networks.

Computes performance measures assuming balanced system conditions.

Parameters:
  • N – Population vector

  • L – Demand matrix (service demands)

  • Z – Think time vector

Returns:

(XN, CN, QN, UN, RN, TN, AN) where:
  • XN: Throughputs

  • CN: Response times

  • QN: Queue lengths

  • UN: Utilizations

  • RN: Residence times

  • TN: Node throughputs

  • AN: Arrival rates

Return type:

tuple

pfqn_mva(N, L, Z)[source]

Mean Value Analysis for product-form networks.

Computes performance measures using the MVA algorithm.

Parameters:
  • N – Population vector.

  • L – Demand matrix (service demands = mean visits × mean service times).

  • Z – Think time vector.

Returns:

Performance measures including throughputs, response times, queue lengths, and utilizations.

pfqn_aql(N, L, Z)[source]

Approximate Queue Length algorithm for product-form networks.

Provides approximations for queue lengths in product-form networks when exact algorithms are computationally expensive.

Parameters:
  • N – Population vector

  • L – Demand matrix (service demands)

  • Z – Think time vector

Returns:

(XN, CN, QN, UN, RN, TN, AN) - Performance measures

Return type:

tuple

pfqn_mvald(L, N, Z, mu, stabilize=True)[source]

MVA with Load-Dependent service rates.

Mean Value Analysis for networks with load-dependent service rates.

Parameters:
  • L – Demand matrix

  • N – Population vector

  • Z – Think time vector

  • mu – Load-dependent service rate functions

  • stabilize – Whether to use numerical stabilization (default: True)

Returns:

(XN, QN, UN, CN, lGN, isNumStable, newpi) where:
  • Performance measures and numerical stability indicators

Return type:

tuple

pfqn_mvaldms(lambda_rates, D, N, Z, S)[source]

MVA with Load-Dependent Multi-Server stations.

Mean Value Analysis for networks with load-dependent multi-server stations.

Parameters:
  • lambda_rates – Arrival rates

  • D – Service demands

  • N – Population vector

  • Z – Think times

  • S – Server configurations

Returns:

Performance measures for load-dependent multi-server network

pfqn_mvaldmx(lambda_rates, D, N, Z, mu=None, S=None)[source]

MVA with Load-Dependent mixed service stations.

Mean Value Analysis for networks with mixed load-dependent service stations that can have both load-dependent rates and multiple servers.

Parameters:
  • lambda_rates – Arrival rates

  • D – Service demands

  • N – Population vector

  • Z – Think times

  • mu – Load-dependent service rates (optional)

  • S – Server configurations (optional)

Returns:

(XN, QN, UN, CN, lGN, newPc) - Performance measures with corrected parameters

Return type:

tuple

pfqn_mvams(lambda_rates, L, N, Z, mi=None, S=None)[source]

MVA for Multi-Server stations.

Mean Value Analysis algorithm extended for multi-server stations.

Parameters:
  • lambda_rates – Arrival rates

  • L – Service demands

  • N – Population vector

  • Z – Think times

  • mi – Service rates (optional)

  • S – Number of servers per station (optional)

Returns:

Performance measures for multi-server network

pfqn_mvamx(lambda_rates, D, N, Z, mi=None)[source]

MVA for mixed open/closed networks.

Mean Value Analysis for mixed networks containing both open and closed classes.

Parameters:
  • lambda_rates – Arrival rates for open classes

  • D – Service demands

  • N – Population vector for closed classes

  • Z – Think times

  • mi – Service rates (optional)

Returns:

(XN, QN, UN, CN, lGN) - Performance measures

Return type:

tuple

pfqn_gldsingle(L, N, mu, options=None)[source]

GLD algorithm for single load-dependent station.

Specialized version for networks with a single load-dependent station.

Parameters:
  • L – Service demands

  • N – Population vector

  • mu – Load-dependent service rates

  • options – Algorithm options (optional)

Returns:

(G, lG) - Normalizing constant and its logarithm

Return type:

tuple

pfqn_comomrm(L, N, Z, m=None, atol=1e-8)[source]

Co-moment matching algorithm for product-form networks.

Uses moment matching techniques to approximate performance metrics in product-form queueing networks with high accuracy.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • m – Number of moments to match (optional)

  • atol – Absolute tolerance for convergence

Returns:

Performance metrics computed via co-moment matching

pfqn_linearizer(L, N, Z, schedule_types, tol=1e-8, maxiter=1000)[source]

Linearizer algorithm for non-product-form networks.

Uses iterative approximation to analyze networks with non-product-form scheduling disciplines (e.g., priority, LCFS-PR).

Parameters:
  • L – Service demands

  • N – Population vector

  • Z – Think times

  • schedule_types – Scheduling disciplines for each station

  • tol – Convergence tolerance (default: 1e-8)

  • maxiter – Maximum iterations (default: 1000)

Returns:

(Q, U, R, C, X, totiter) where:
  • Q: Queue lengths

  • U: Utilizations

  • R: Response times

  • C: Class response times

  • X: Throughputs

  • totiter: Total iterations performed

Return type:

tuple

pfqn_linearizerms(L, N, Z, nservers, schedule_types, tol=1e-8, maxiter=1000)[source]

Linearizer algorithm for multi-server non-product-form networks.

Extended linearizer for networks with multi-server stations and non-product-form scheduling disciplines.

Parameters:
  • L – Service demands

  • N – Population vector

  • Z – Think times

  • nservers – Number of servers per station

  • schedule_types – Scheduling disciplines

  • tol – Convergence tolerance (default: 1e-8)

  • maxiter – Maximum iterations (default: 1000)

Returns:

(Q, U, W, C, X, totiter) - Performance measures and iterations

Return type:

tuple

pfqn_linearizerpp(L, N, Z, level=2, tol=1e-8, maxiter=1000, flag=0)[source]

Priority Preemptive linearizer algorithm.

Specialized linearizer for networks with priority preemptive scheduling.

Parameters:
  • L – Service demands

  • N – Population vector

  • Z – Think times

  • level – Priority level (default: 2)

  • tol – Convergence tolerance (default: 1e-8)

  • maxiter – Maximum iterations (default: 1000)

  • flag – Algorithm flag (default: 0)

Returns:

Performance measures for priority preemptive network

pfqn_linearizermx(lambda_rates, L, N, Z, nservers, schedule_types, tol=1e-8, maxiter=1000, method='lin')[source]

Mixed linearizer algorithm for open/closed networks with multi-server stations.

Extended linearizer for mixed networks containing both open and closed classes with multi-server stations and non-product-form scheduling.

Parameters:
  • lambda_rates – Arrival rates for open classes

  • L – Service demands

  • N – Population vector for closed classes

  • Z – Think times

  • nservers – Number of servers per station

  • schedule_types – Scheduling disciplines

  • tol – Convergence tolerance (default: 1e-8)

  • maxiter – Maximum iterations (default: 1000)

  • method – Solution method (default: “lin”)

Returns:

(Q, U, R, C, X, totiter) - Performance measures and iterations

Return type:

tuple

pfqn_kt(L, N, Z)[source]

Korkmazoglu-Tucci (KT) algorithm for normalizing constants.

Efficient algorithm for computing normalizing constants in product-form networks.

Parameters:
  • L – Service demands

  • N – Population vector

  • Z – Think times

Returns:

(G, lG) - Normalizing constant and its logarithm

Return type:

tuple

pfqn_recal(L, N, Z=None, m0=None)[source]

Recurrence algorithm for normalizing constants.

Uses recurrence relations to compute normalizing constants.

Parameters:
  • L – Service demands

  • N – Population vector

  • Z – Think times (optional)

  • m0 – Initial multiplicities (optional)

Returns:

(G, lG) - Normalizing constant and its logarithm

Return type:

tuple

pfqn_cub(L, N, Z, order=3, atol=1e-8)[source]

Cubic spline approximation for normalizing constants.

Uses cubic spline interpolation for approximate computation of normalizing constants.

Parameters:
  • L – Service demands

  • N – Population vector

  • Z – Think times

  • order – Spline order (default: 3)

  • atol – Absolute tolerance (default: 1e-8)

Returns:

(G, lG) - Normalizing constant and its logarithm

Return type:

tuple

pfqn_mmint2(L, N, Z)[source]

Two-moment interpolation algorithm for normalizing constants.

Uses moment interpolation to approximate normalizing constants.

Parameters:
  • L – Service demands

  • N – Population vector

  • Z – Think times

Returns:

(G, lG) - Normalizing constant and its logarithm

Return type:

tuple

pfqn_ls(L, N, Z=None, I=10000, seed=12345)[source]

Large-Scale approximation algorithm for normalizing constants.

Monte Carlo based approximation for large-scale product-form networks.

Parameters:
  • L – Service demands

  • N – Population vector

  • Z – Think times (optional)

  • I – Number of Monte Carlo samples (default: 10000)

  • seed – Random seed (default: 12345)

Returns:

(G, lG) - Normalizing constant and its logarithm

Return type:

tuple

pfqn_rd(L, N, Z, mu, options=None)[source]

Recursive Doubling algorithm for load-dependent networks.

Parameters:
  • L – Service demands

  • N – Population vector

  • Z – Think times

  • mu – Load-dependent service rates

  • options – Algorithm options (optional)

Returns:

(lG, Cgamma) - Log normalizing constant and performance measures

Return type:

tuple

pfqn_fnc(alpha, c)[source]

Flow-equivalent Node Centralization algorithm.

Parameters:
  • alpha – Alpha parameters

  • c – Capacity parameters

Returns:

(mu, c) - Service rates and updated capacities

Return type:

tuple

pfqn_propfair(L, N, Z)[source]

Proportional fair algorithm for product-form networks.

Parameters:
  • L – Service demands

  • N – Population vector

  • Z – Think times

Returns:

(G, lG, X, Q, method) - Performance measures and method used

Return type:

tuple

pfqn_xia(L, N, s, options=None)[source]

Xia’s algorithm for multi-server networks.

Parameters:
  • L – Service demands

  • N – Population count

  • s – Server configurations

  • options – Algorithm options (optional)

Returns:

Algorithm results

pfqn_xzabalow(L, N, Z)[source]

Lower bound algorithm by Zahorjan and Abadir.

Parameters:
  • L – Service demands

  • N – Population count

  • Z – Think time

Returns:

Lower bound estimates

pfqn_xzabaup(L, N, Z)[source]

Upper bound algorithm by Zahorjan and Abadir.

Parameters:
  • L – Service demands

  • N – Population count

  • Z – Think time

Returns:

Upper bound estimates

pfqn_xzgsblow(L, N, Z)[source]

Lower bound algorithm by Zahorjan, Gesbert, and Sevcik.

Parameters:
  • L – Service demands

  • N – Population count

  • Z – Think time

Returns:

Lower bound estimates

pfqn_xzgsbup(L, N, Z)[source]

Upper bound algorithm by Zahorjan, Gesbert, and Sevcik.

Parameters:
  • L – Service demands

  • N – Population count

  • Z – Think time

Returns:

Upper bound estimates

pfqn_egflinearizer(L, N, Z, tol=1e-8, maxiter=1000)[source]

Enhanced Gauss-Friedman linearizer for product-form networks.

Advanced linearization algorithm that provides improved convergence and accuracy compared to standard linearizer methods.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • tol – Convergence tolerance

  • maxiter – Maximum number of iterations

Returns:

Performance metrics computed via enhanced linearizer

pfqn_gflinearizer(L, N, Z, tol=1e-8, maxiter=1000)[source]

Gauss-Friedman linearizer for product-form networks.

Uses the Gauss-Friedman linearization method to approximate performance metrics in product-form queueing networks.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • tol – Convergence tolerance

  • maxiter – Maximum number of iterations

Returns:

Performance metrics computed via Gauss-Friedman linearizer

pfqn_gld_complex(L, N, mu=None, options=None)[source]

Complex variant of Generalized Load-Dependent algorithm.

Enhanced GLD method for complex load-dependent service configurations with support for advanced service rate dependencies.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • mu – Load-dependent service rates (optional)

  • options – Optional solver options

Returns:

Performance metrics for complex load-dependent systems

pfqn_gldsingle_complex(L, N, mu, options=None)[source]

Complex GLD algorithm for single load-dependent station.

Specialized version for networks with one complex load-dependent station with sophisticated service rate modeling.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • mu – Complex load-dependent service rates

  • options – Optional solver options

Returns:

Performance metrics for single complex load-dependent station

pfqn_mushift(L, N, Z, mu, shift_factor=1.0)[source]

Service rate shifting algorithm for load-dependent networks.

Applies a shifting transformation to service rates for improved numerical stability in load-dependent network analysis.

Parameters:
  • L – Service demand matrix.

  • N – Population vector.

  • Z – Think time vector.

  • mu – Load-dependent service rates.

  • shift_factor – Shifting parameter (default: 1.0).

Returns:

(mu_shifted, G, lG) - Shifted rates and normalizing constants.

Return type:

tuple

pfqn_le_fpiZ(L, N, Z, max_iter=1000, tol=1e-6)[source]

Load Evaluation FPI with Z-parameter computation.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • max_iter – Maximum iterations (default: 1000)

  • tol – Convergence tolerance (default: 1e-6)

Returns:

Performance metrics with Z coefficients

Return type:

dict

pfqn_le_hessian(L, N, Z, step_size=1e-6)[source]
pfqn_le_hessianZ(L, N, Z, step_size=1e-6)[source]
pfqn_lldfun(L, N, Z, lambda_vec)[source]
pfqn_mci(L, N, Z, num_samples=10000, confidence=0.95)[source]

Monte Carlo Integration with confidence intervals.

Extended MCI method that provides confidence interval estimates for the computed performance metrics.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • num_samples – Number of Monte Carlo samples

  • confidence – Confidence level for intervals (e.g., 0.95)

Returns:

Performance metrics with confidence intervals

pfqn_mmint2_gausslegendre(L, N, Z, order=10)[source]
pfqn_mmsample2(L, N, Z, num_samples=1000)[source]
pfqn_nrl(L, N, Z, options=None)[source]

Newton-Raphson Linearization for product-form networks.

Uses Newton-Raphson optimization to solve the linearized system of equations for performance metrics computation.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • options – Optional solver options

Returns:

Performance metrics computed via Newton-Raphson linearization

pfqn_nrp(L, N, Z, options=None)[source]

Newton-Raphson method for performance measures.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • options – Algorithm options (optional)

Returns:

Performance measures with convergence status

Return type:

dict

pfqn_stdf(L, N, Z, S, fcfs_nodes, rates, tset)[source]

Service Time Distribution Function computation.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • S – Server configuration

  • fcfs_nodes – FCFS node indicators

  • rates – Service rates

  • tset – Time set for evaluation

Returns:

Distribution function values (CDF, PDF, mean)

Return type:

dict

pfqn_stdf_heur(L, N, Z, S, fcfs_nodes, rates, tset, options=None)[source]

Service Time Distribution Function with heuristic approximation.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • S – Server configuration

  • fcfs_nodes – FCFS node indicators

  • rates – Service rates

  • tset – Time set for evaluation

  • options – Algorithm options (optional)

Returns:

Approximate distribution function values

Return type:

dict

pfqn_conwayms_core(L, N, Z, S, options=None)[source]

Conway multi-server algorithm core computation.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • S – Server configuration

  • options – Algorithm options (optional)

Returns:

Core performance metrics (XN, QN, RN, UN)

Return type:

dict

pfqn_conwayms_estimate(L, N, Z, S, options=None)[source]

Conway multi-server algorithm with estimation.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • S – Server configuration

  • options – Algorithm options (optional)

Returns:

Estimated performance metrics

Return type:

dict

pfqn_conwayms_forwardmva(L, N, Z, S, options=None)[source]

Conway multi-server algorithm with forward MVA.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • S – Server configuration

  • options – Algorithm options (optional)

Returns:

Performance metrics via forward MVA

Return type:

dict

pfqn_mu_ms_gnaux(L, N, Z, S, mu, options=None)[source]

Multi-server service rate computation with auxiliary variables.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think time vector

  • S – Server configuration

  • mu – Service rates

  • options – Algorithm options (optional)

Returns:

Scaling factors and convergence information

Return type:

dict

pfqn_nc(N, L, Z, options=None)[source]

Normalizing Constant algorithm variant for product-form networks.

Alternative interface to the normalizing constant method that computes performance measures using exact or approximate NC techniques.

Parameters:
  • N – Population vector

  • L – Service demand matrix

  • Z – Think time vector

  • options – Optional solver options

Returns:

Performance metrics computed via normalizing constants

pfqn_gld(L, N, mu, options=None)[source]

Generalized Load-Dependent algorithm variant.

Alternative interface to the GLD method with explicit service rate parameters for load-dependent stations.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • mu – Load-dependent service rate matrix

  • options – Optional solver options

Returns:

Performance metrics for load-dependent network

pfqn_conwayms(N, L, Z, S, options=None)[source]

Conway Multi-Server algorithm with server specifications.

Alternative interface for Conway’s multi-server method that takes explicit server configuration parameters.

Parameters:
  • N – Population vector

  • L – Service demand matrix

  • Z – Think time vector

  • S – Server configuration matrix

  • options – Optional solver options

Returns:

Performance metrics with detailed server utilization

pfqn_cdfun(N, L, Z, options=None)[source]

Cumulative distribution function computation for product-form networks.

Computes the cumulative distribution function of response times or other performance metrics in product-form queueing networks.

Parameters:
  • N – Population vector.

  • L – Service demand matrix.

  • Z – Think time vector.

  • options – Algorithm options (optional).

Returns:

Contains ‘cdf’ values and ‘support’ points.

Return type:

dict

pfqn_nca(N, L, Z, options=None)[source]

Normalizing Constant Approximation algorithm.

Computes performance measures using approximation techniques for the normalizing constant in product-form networks.

Parameters:
  • N – Population vector.

  • L – Service demand matrix.

  • Z – Think time vector.

  • options – Algorithm options (optional).

Returns:

Performance measures (QN, UN, RN, TN).

Return type:

dict

pfqn_ncld(N, L, Z, mu, options=None)[source]

Normalizing Constant for Load-Dependent networks.

Computes performance measures using normalizing constant methods for networks with load-dependent service rates.

Parameters:
  • N – Population vector.

  • L – Service demand matrix.

  • Z – Think time vector.

  • mu – Load-dependent service rates.

  • options – Algorithm options (optional).

Returns:

Performance measures (QN, UN, RN, TN).

Return type:

dict

pfqn_pff_delay(N, L, Z, options=None)[source]

Product-form approximation for delay networks.

Parameters:
  • N – Population vector

  • L – Service demand matrix

  • Z – Think time vector

  • options – Algorithm options (optional)

Returns:

Performance metrics for delay networks

Return type:

dict

pfqn_sqni(N, L, Z, options=None)[source]

Single Queue Network Iteration algorithm.

Parameters:
  • N – Population vector

  • L – Service demand matrix

  • Z – Think time vector

  • options – Algorithm options (optional)

Returns:

Performance metrics via SQNI method

Return type:

dict

pfqn_qzgblow(M, N)[source]

Zahorjan-Gesbert lower bound algorithm.

Computes lower bounds for queue lengths using the Zahorjan-Gesbert approximation method.

Parameters:
  • M – Service demand matrix.

  • N – Population vector.

Returns:

Lower bound estimate.

Return type:

float

pfqn_qzgbup(M, N)[source]

Zahorjan-Gesbert upper bound algorithm.

Computes upper bounds for queue lengths using the Zahorjan-Gesbert approximation method.

Parameters:
  • M – Service demand matrix.

  • N – Population vector.

Returns:

Upper bound estimate.

Return type:

float

pfqn_nc_sanitize(L, N, Z)[source]

Sanitize parameters for normalizing constant computation.

Preprocesses and validates input parameters to ensure numerical stability in normalizing constant algorithms.

Parameters:
  • L – Service demand matrix.

  • N – Population vector.

  • Z – Think time vector.

Returns:

Sanitized parameters with scaling information.

Return type:

dict

pfqn_comomrm_ld(L, N, Z, S)[source]

Co-moment matching algorithm for load-dependent networks.

Applies moment matching techniques to product-form networks with load-dependent service stations.

Parameters:
  • L – Service demand matrix.

  • N – Population vector.

  • Z – Think time vector.

  • S – Server configuration matrix.

Returns:

Performance measures including normalizing constant G.

Return type:

dict

pfqn_mvaldmx_ec(L, N, Z, S)[source]

MVA for Load-Dependent Mixed networks with Error Control.

Mean Value Analysis for mixed networks with load-dependent service rates and enhanced error control mechanisms.

Parameters:
  • L – Service demand matrix.

  • N – Population vector.

  • Z – Think time vector.

  • S – Server configuration matrix.

Returns:

Performance measures with error-controlled computation.

Return type:

dict

pfqn_ab(L, N, Z=None, type='exact')[source]

Asymptotic bounds for product-form queueing networks.

Parameters:
  • L – Service demand matrix (stations x classes)

  • N – Population vector

  • Z – Think times (optional)

  • type – Type of bounds (‘exact’ or ‘approx’)

Returns:

Asymptotic bounds on throughput and response time

Return type:

dict

pfqn_le(L, N, Z=None)[source]

Little’s law equations for product-form networks.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think times (optional)

Returns:

Performance metrics from Little’s law

Return type:

dict

pfqn_le_fpi(L, N, Z=None, max_iter=100)[source]

Fixed-point iteration for Little’s law equations.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think times (optional)

  • max_iter – Maximum iterations

Returns:

Converged performance metrics

Return type:

dict

pfqn_le_fpiz(L, N, Z, max_iter=100)[source]

Fixed-point iteration with think time adjustment.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think times

  • max_iter – Maximum iterations

Returns:

Converged performance metrics

Return type:

dict

pfqn_le_hessianz(L, N, Z)[source]

Hessian computation for product-form networks with think times.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think times

Returns:

Hessian matrix

Return type:

numpy.ndarray

pfqn_mom(L, N, Z=None)[source]

Method of moments for product-form networks.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think times (optional)

Returns:

First and second moments

Return type:

dict

pfqn_mu_ms(L, N, m)[source]

Service rates for multi-server product-form networks.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • m – Number of servers at each station

Returns:

Effective service rates

Return type:

numpy.ndarray

pfqn_procomom2(L, N, Z=None)[source]

Second-order product-form complementary moments.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think times (optional)

Returns:

Second-order complementary moments

Return type:

dict

pfqn_schmidt(L, N, Z=None)[source]

Schmidt’s approximation for product-form networks.

Parameters:
  • L – Service demand matrix

  • N – Population vector

  • Z – Think times (optional)

Returns:

Performance metrics using Schmidt’s method

Return type:

dict

pfqn_lcfsqn_ca(alpha, beta, N=None)[source]

Convolution algorithm for multiclass LCFS queueing networks.

Computes the normalizing constant for a 2-station closed queueing network with:
  • Station 1: LCFS (Last-Come-First-Served, non-preemptive)

  • Station 2: LCFS-PR (LCFS with Preemption-Resume)

Parameters:
  • alpha – Vector of inverse service rates at station 1 (LCFS). alpha[r] = 1/mu(1,r) for class r

  • beta – Vector of inverse service rates at station 2 (LCFS-PR). beta[r] = 1/mu(2,r) for class r

  • N – Population vector, N[r] = number of jobs of class r. Default: ones(1,R) - one job per class

Returns:

(G, V) where G is the normalizing constant and V is the auxiliary term.

Return type:

tuple

Reference:

G. Casale, “A family of multiclass LCFS queueing networks with order-dependent product-form solutions”, QUESTA 2026.

pfqn_lcfsqn_mva(alpha, beta, N=None)[source]

Mean Value Analysis for multiclass LCFS queueing networks.

Computes performance metrics for a 2-station closed queueing network with:
  • Station 1: LCFS (Last-Come-First-Served, non-preemptive)

  • Station 2: LCFS-PR (LCFS with Preemption-Resume)

This implementation uses log-space arithmetic to prevent numerical underflow. The results are mathematically exact (up to floating-point precision) - no approximations are made.

Parameters:
  • alpha – Vector of inverse service rates at station 1 (LCFS). alpha[r] = 1/mu(1,r) for class r

  • beta – Vector of inverse service rates at station 2 (LCFS-PR). beta[r] = 1/mu(2,r) for class r

  • N – Population vector, N[r] = number of jobs of class r. Default: ones(1,R) - one job per class

Returns:

Dictionary containing:
  • ’T’: Throughput vector (1 x R)

  • ’Q’: Queue length matrix (2 x R)

  • ’U’: Utilization matrix (2 x R)

  • ’B’: Back probability matrix (2 x R)

Return type:

dict

Reference:

G. Casale, “A family of multiclass LCFS queueing networks with order-dependent product-form solutions”, QUESTA 2026.

pfqn_lcfsqn_nc(alpha, beta, N)[source]

Normalizing constant for multiclass LCFS queueing networks.

Computes the normalizing constant using matrix permanent calculations for a 2-station closed queueing network with Station 1 using LCFS (Last-Come-First-Served, non-preemptive) and Station 2 using LCFS-PR (LCFS with Preemption-Resume).

Parameters:
  • alpha – Vector of inverse service rates at station 1 (LCFS). alpha[r] = 1/mu(1,r) for class r

  • beta – Vector of inverse service rates at station 2 (LCFS-PR). beta[r] = 1/mu(2,r) for class r

  • N – Population vector, N[r] = number of jobs of class r.

Returns:

(G, Ax) where G is the normalizing constant and Ax is the

array of A matrices for each state.

Return type:

tuple

Reference:

G. Casale, “A family of multiclass LCFS queueing networks with order-dependent product-form solutions”, QUESTA 2026.

CTMC API (line_solver.api.ctmc)

Continuous-Time Markov Chain (CTMC) analysis algorithms.

This module provides low-level functions for analyzing continuous-time Markov chains, including transient and steady-state analysis, uniformization, simulation, and various computational methods.

These functions support the CTMC solver and other analytical methods.

ctmc_uniformization(pi0, Q, t)[source]

Compute transient probabilities using uniformization method.

Parameters:
  • pi0 – Initial probability distribution.

  • Q – Infinitesimal generator matrix.

  • t – Time points for transient analysis.

Returns:

Transient probability distributions.

Return type:

numpy.ndarray

ctmc_timereverse(matrix)[source]

Compute time-reversed CTMC.

Constructs the time-reversed continuous-time Markov chain using the detailed balance equations and steady-state probabilities.

Parameters:

matrix – Original infinitesimal generator matrix.

Returns:

Time-reversed generator matrix.

Return type:

numpy.ndarray

ctmc_makeinfgen(matrix)[source]

Construct infinitesimal generator matrix.

Converts a rate matrix to a proper infinitesimal generator by setting diagonal elements to negative row sums.

Parameters:

matrix – Rate matrix with non-negative off-diagonal elements.

Returns:

Infinitesimal generator matrix.

Return type:

numpy.ndarray

ctmc_solve(matrix)[source]

Solve for steady-state probabilities of a CTMC.

Computes the stationary distribution of a continuous-time Markov chain by solving the system πQ = 0 with the normalization constraint.

Parameters:

matrix – Infinitesimal generator matrix Q.

Returns:

Steady-state probability distribution π.

Return type:

numpy.ndarray

ctmc_transient(Q, pi0=None, t0=None, t1=None)[source]

Compute transient probabilities of a CTMC.

Parameters:
  • Q – Infinitesimal generator matrix.

  • pi0 – Initial probability distribution (optional).

  • t0 – Start time (optional).

  • t1 – End time (required).

Returns:

(times, probabilities) arrays.

Return type:

tuple

ctmc_simulate(Q, pi0=None, n=1000)[source]

Simulate a CTMC using Monte Carlo methods.

Parameters:
  • Q – Infinitesimal generator matrix.

  • pi0 – Initial distribution (optional).

  • n – Number of simulation steps (default: 1000).

Returns:

(states, sojourn_times) arrays.

Return type:

tuple

ctmc_rand(length)[source]

Generate random CTMC generator matrix.

Creates a random infinitesimal generator matrix suitable for use as a continuous-time Markov chain generator.

Parameters:

length – Size of the square matrix (number of states).

Returns:

Random infinitesimal generator matrix.

Return type:

numpy.ndarray

ctmc_ssg(sn, options)[source]

Generate state space for CTMC from service network.

Parameters:
  • sn – Service network model.

  • options – Generation options.

Returns:

State space information including matrices and mappings.

Return type:

dict

ctmc_stochcomp(Q, I_list=None)[source]

Compute stochastic complementarity decomposition of CTMC.

Parameters:
  • Q – Infinitesimal generator matrix.

  • I_list – Index list for decomposition (optional).

Returns:

Decomposed matrices (S, Q11, Q12, Q21, Q22, T).

Return type:

dict

ctmc_ssg_reachability(sn, options=None)[source]

Generate reachable state space for CTMC from service network.

Parameters:
  • sn – Service network model.

  • options – Reachability analysis options (optional).

Returns:

Reachable state space information.

Return type:

dict

ctmc_randomization(Q, q=None)[source]

Apply randomization (uniformization) to CTMC.

Parameters:
  • Q – Infinitesimal generator matrix.

  • q – Randomization rate (optional, auto-computed if None).

Returns:

(P_matrix, q_rate) - transition matrix and rate.

Return type:

tuple

ctmc_krylov(Q, pi0, t, options=None)[source]

Compute CTMC transient probabilities using Krylov subspace methods.

Parameters:
  • Q – Infinitesimal generator matrix.

  • pi0 – Initial probability distribution.

  • t – Time point.

  • options – Krylov method options (optional).

Returns:

Transient probability distribution at time t.

Return type:

numpy.ndarray

DTMC API (line_solver.api.dtmc)

Discrete-Time Markov Chain (DTMC) analysis algorithms.

This module provides functions for analyzing discrete-time Markov chains, including steady-state analysis, stochastic complement operations, time-reversal, and simulation methods.

These functions are used by various solvers and analysis methods.

dtmc_solve(matrix)[source]

Solve for steady-state probabilities of a DTMC.

Parameters:

matrix – Transition probability matrix.

Returns:

Steady-state probability distribution.

Return type:

numpy.ndarray

dtmc_stochcomp(matrix, indexes)[source]

Compute stochastic complement of a DTMC.

Performs state space reduction by computing the stochastic complement, eliminating specified states while preserving transition probabilities.

Parameters:
  • matrix – Transition probability matrix.

  • indexes – List of state indexes to eliminate.

Returns:

Reduced transition matrix (stochastic complement).

Return type:

numpy.ndarray

dtmc_timereverse(matrix)[source]

Compute time-reversed DTMC.

Constructs the time-reversed discrete-time Markov chain using the detailed balance equations and steady-state probabilities.

Parameters:

matrix – Original transition probability matrix.

Returns:

Time-reversed transition probability matrix.

Return type:

numpy.ndarray

dtmc_makestochastic(matrix)[source]

Normalize matrix to be row-stochastic.

Converts a non-negative matrix to a proper stochastic matrix by normalizing rows to sum to 1.

Parameters:

matrix – Non-negative matrix to normalize.

Returns:

Row-stochastic matrix.

Return type:

numpy.ndarray

dtmc_rand(length)[source]

Generate random DTMC transition matrix.

Creates a random row-stochastic matrix suitable for use as a discrete-time Markov chain transition matrix.

Parameters:

length – Size of the square matrix (number of states).

Returns:

Random stochastic transition matrix.

Return type:

numpy.ndarray

dtmc_simulate(P, pi0, n)[source]

Simulate DTMC state trajectory.

Generates a sample path of the discrete-time Markov chain starting from an initial distribution.

Parameters:
  • P – Transition probability matrix.

  • pi0 – Initial state distribution.

  • n – Number of time steps to simulate.

Returns:

Sequence of visited states.

Return type:

numpy.ndarray

dtmc_isfeasible(P)[source]

Check if matrix is a valid DTMC transition matrix.

Verifies that the matrix satisfies the requirements for a discrete-time Markov chain: non-negative entries and row sums equal to 1.

Parameters:

P – Matrix to check.

Returns:

True if matrix is a valid DTMC transition matrix.

Return type:

bool

Matrix-Analytic Methods (line_solver.api.mam)

Matrix-Analytic Methods (MAM) for MAP/PH distributions.

This module provides functions for analyzing Markovian Arrival Processes (MAPs), Phase-Type (PH) distributions, and related matrix-analytic methods. It includes fitting algorithms, moment calculations, and various transformations.

Key function categories: - MAP analysis: map_pie, map_mean, map_var, map_scv, map_skew - MAP fitting: map2_fit, mmpp2_fit, aph_fit, aph2_fit - PH distributions: Phase-type analysis and fitting - Transformations: map_scale, map_normalize, map_timereverse - QBD methods: qbd_R, qbd_mapmap1, qbd_raprap1 - Compression: compress_adaptive, compress_spectral

These functions support advanced stochastic modeling with correlated arrivals and non-exponential service times.

map_pie(D0, D1=None)[source]

Compute equilibrium distribution of the embedded discrete-time process.

Calculates the stationary distribution of the discrete-time Markov chain embedded at departure instants for a Markovian Arrival Process (MAP). The embedded process has transition matrix P = (-D0)^(-1) * D1.

Parameters:
  • D0 – Generator matrix for non-arrival transitions, or MAP as container {D0,D1}.

  • D1 – Generator matrix for arrival transitions (optional if D0 is container).

Returns:

Equilibrium distribution of the discrete-time Markov chain

embedded at departure instants.

Return type:

numpy.ndarray

map_mean(D0, D1=None)[source]

Calculate mean inter-arrival time of a MAP.

Computes the expected inter-arrival time for a Markovian Arrival Process.

Parameters:
  • D0 – Generator matrix for non-arrival transitions, or MAP container

  • D1 – Generator matrix for arrival transitions (optional if D0 is container)

Returns:

Mean inter-arrival time

Return type:

float

map_var(D0, D1=None)[source]

Calculate variance of inter-arrival times of a MAP.

Computes the variance of inter-arrival times for a Markovian Arrival Process.

Parameters:
  • D0 – Generator matrix for non-arrival transitions, or MAP container

  • D1 – Generator matrix for arrival transitions (optional if D0 is container)

Returns:

Variance of inter-arrival times

Return type:

float

map_scv(D0, D1=None)[source]

Calculate squared coefficient of variation of a MAP.

Computes the SCV (variance/mean²) of inter-arrival times.

Parameters:
  • D0 – Generator matrix for non-arrival transitions, or MAP container

  • D1 – Generator matrix for arrival transitions (optional if D0 is container)

Returns:

Squared coefficient of variation

Return type:

float

map_skew(D0, D1=None)[source]

Calculate skewness of inter-arrival times of a MAP.

Computes the third central moment normalized by variance^(3/2).

Parameters:
  • D0 – Generator matrix for non-arrival transitions, or MAP container

  • D1 – Generator matrix for arrival transitions (optional if D0 is container)

Returns:

Skewness of inter-arrival times

Return type:

float

map_moment(D0, D1, order)[source]

Compute (power) moments of interarrival times of the specified order.

Calculates the k-th moment E[X^k] where X is the interarrival time random variable of the MAP.

Parameters:
  • D0 – Generator matrix for non-arrival transitions

  • D1 – Generator matrix for arrival transitions

  • order – Moment order to calculate (1=>E[X], 2=>E[X^2], …)

Returns:

The k-th power moment of interarrival times

Return type:

float

Examples

  • map_moment(D0, D1, 1) returns the first moment E[X]

  • map_moment(D0, D1, 2) returns the second moment E[X^2]

map_lambda(D0, D1=None)[source]

Calculate arrival rate of a MAP.

Computes the long-run arrival rate (λ) of the Markovian Arrival Process.

Parameters:
  • D0 – Generator matrix for non-arrival transitions, or MAP container

  • D1 – Generator matrix for arrival transitions (optional if D0 is container)

Returns:

Arrival rate λ

Return type:

float

map_acf(D0, D1, lags)[source]

Compute autocorrelation coefficients of interarrival times.

Calculates the lag-k autocorrelation coefficients of the interarrival times for a Markovian Arrival Process. The autocorrelation coefficient at lag k measures the correlation between interarrival times that are k arrivals apart.

Parameters:
  • D0 – Generator matrix for non-arrival transitions

  • D1 – Generator matrix for arrival transitions

  • lags – Array of positive integers specifying the lags of the autocorrelation coefficients to compute

Returns:

Autocorrelation coefficients returned in the same

order as the lags vector

Return type:

numpy.ndarray

Examples

  • map_acf(D0, D1, [1]) returns the lag-1 autocorrelation coefficient

  • map_acf(D0, D1, [1, 2, 3, 4, 5]) returns the first five autocorrelation coefficients

  • map_acf(D0, D1, np.logspace(0, 4, 5)) returns five logarithmically spaced autocorrelation coefficients in [1e0, 1e4]

map_acfc(D0, D1, lags, u)[source]

Compute autocorrelation of a MAP’s counting process at specified lags.

Calculates the autocorrelation function of the counting process N(t) representing the number of arrivals in time interval [0,t], evaluated at discrete time points separated by timeslot length u.

Parameters:
  • D0 – Generator matrix for non-arrival transitions

  • D1 – Generator matrix for arrival transitions

  • lags – Array of lag values (positive integers)

  • u – Length of timeslot (timescale parameter)

Returns:

Autocorrelation values of the counting process

at the specified lags

Return type:

numpy.ndarray

map_idc(D0, D1=None)[source]

Compute the asymptotic index of dispersion.

Calculates I = SCV(1 + 2*sum_{k=1}^∞ ρ_k) where SCV is the squared coefficient of variation and ρ_k is the lag-k autocorrelation coefficient of inter-arrival times. I is also the limiting value of the index of dispersion for counts and of the index of dispersion for intervals.

Parameters:
  • D0 – Generator matrix for non-arrival transitions, or MAP container {D0,D1}

  • D1 – Generator matrix for arrival transitions (optional if D0 is container)

Returns:

Asymptotic index of dispersion

Return type:

float

Examples

  • For a renewal process: map_idc(map_renewal(MAP)) equals the SCV of the MAP

map_gamma(D0, D1=None)[source]

Estimate the auto-correlation decay rate of a MAP.

For MAPs of order higher than 2, performs an approximation of the autocorrelation function (ACF) curve using non-linear least squares fitting. For second-order MAPs, returns the geometric ACF decay rate. For Poisson processes (order 1), returns 0.

Parameters:
  • D0 – Generator matrix for non-arrival transitions, or MAP container {D0,D1}

  • D1 – Generator matrix for arrival transitions (optional if D0 is container)

Returns:

Autocorrelation decay rate (GAMMA parameter)

Return type:

float

map_gamma2(MAP)[source]

Calculate the second largest eigenvalue of the embedded transition matrix.

Computes the second-order gamma parameter (γ₂) which is the second largest eigenvalue (in absolute value) of the embedded discrete-time transition matrix P = (-D0)^(-1) * D1. This parameter characterizes the autocorrelation structure of the MAP beyond the dominant eigenvalue.

Parameters:

MAP – MAP structure or container {D0, D1}

Returns:

Second largest eigenvalue of the embedded transition matrix

(complex number, but typically real for feasible MAPs)

Return type:

complex

Note

The eigenvalues are sorted by descending absolute value, where the first eigenvalue is 1 (for irreducible MAPs) and γ₂ is the second eigenvalue. This parameter is important for analyzing higher-order correlation properties.

map_cdf(D0, D1, points)[source]

Calculate cumulative distribution function of a MAP.

Evaluates the CDF of inter-arrival times at specified points.

Parameters:
  • D0 – Generator matrix for non-arrival transitions

  • D1 – Generator matrix for arrival transitions

  • points – Array of points to evaluate CDF at

Returns:

CDF values at specified points

Return type:

numpy.ndarray

map_piq(D0, D1=None)[source]

Compute the probability in queue (piq) for a MAP.

Parameters:
  • D0 – Generator matrix for non-arrival transitions, or MAP container

  • D1 – Generator matrix for arrival transitions (optional if D0 is container)

Returns:

Probability in queue vector

Return type:

numpy.ndarray

map_embedded(D0, D1=None)[source]

Compute the embedded discrete-time process transition matrix.

Returns the transition matrix P of the discrete-time Markov chain embedded at arrival instants. If the MAP is feasible, then P must be an irreducible stochastic matrix. P(i,j) gives the probability that the MAP restarts in phase j if the last arrival occurred in phase i.

Parameters:
  • D0 – Generator matrix for non-arrival transitions, or MAP container {D0,D1}

  • D1 – Generator matrix for arrival transitions (optional if D0 is container)

Returns:

Transition matrix P = (-D0)^(-1) * D1 of the embedded process

Return type:

numpy.ndarray

map_count_mean(MAP, t)[source]

Compute the mean of the counting process.

Calculates the expected number of arrivals in time interval (0, t] for a Markovian Arrival Process.

Parameters:
  • MAP – Markovian Arrival Process as container {D0, D1}

  • t – The time period considered for each sample of the counting process

Returns:

Mean number of arrivals in (0, t]

Return type:

float

map_count_var(MAP, t)[source]

Compute the variance of the counting process.

Calculates the variance of the number of arrivals in time interval (0, t] for a Markovian Arrival Process.

Parameters:
  • MAP – Markovian Arrival Process as container {D0, D1}

  • t – The time period considered for each sample of the counting process

Returns:

Variance of number of arrivals in (0, t]

Return type:

float

Reference:

He and Neuts, “Markov chains with marked transitions”, 1998 Verified special case of MMPP(2) with Andresen and Nielsen, 1998

map_varcount(D0, D1, t)[source]

Compute variance of the counting process for a MAP.

Calculates the variance of the number of arrivals in time interval [0,t] for a Markovian Arrival Process. This is an alternative interface for map_count_var with direct matrix input.

Parameters:
  • D0 – Generator matrix for non-arrival transitions

  • D1 – Generator matrix for arrival transitions

  • t – Time interval length

Returns:

Variance of number of arrivals in time interval [0,t]

Return type:

float

Note

This function provides the same computation as map_count_var but accepts the D0, D1 matrices directly rather than a MAP container.

map2_fit(e1, e2, e3, g2)[source]

Fit a second-order MAP from moments and autocorrelation.

Constructs a Markovian Arrival Process of order 2 from given statistical moments and lag-1 autocorrelation coefficient using the explicit inverse characterization method for acyclic MAPs of second order.

Parameters:
  • e1 – First moment E[X] (mean inter-arrival time)

  • e2 – Second moment E[X²]

  • e3 – Third moment E[X³] (if not provided, automatically selected)

  • g2 – Lag-1 autocorrelation coefficient

Returns:

(D0, D1) - Generator matrices for the fitted MAP or None if infeasible

Return type:

tuple

Reference:

A. Heindl, G. Horvath, K. Gross “Explicit inverse characterization of acyclic MAPs of second order”

Note

The method automatically handles hyperexponential (h2>0) and hypoexponential (h2<0) cases, where h2 = (r2-r1²)/r1² with r1=e1, r2=e2/2.

aph_fit(e1, e2, e3, nmax=10)[source]

Fit an Acyclic Phase-Type distribution to moments.

Fits an APH distribution to match the first three moments using the EC (Expectation-Conditional) algorithm.

Parameters:
  • e1 – First moment (mean)

  • e2 – Second moment

  • e3 – Third moment

  • nmax – Maximum number of phases (default: 10)

Returns:

(alpha, T, feasible) where:
  • alpha: Initial probability vector

  • T: Sub-generator matrix

  • feasible: Whether the fit was feasible

Return type:

tuple

aph2_fit(M1, M2, M3)[source]

Fit a 2-phase APH distribution to moments.

Fits a 2-phase Acyclic Phase-Type distribution to match the first three moments.

Parameters:
  • M1 – First moment (mean)

  • M2 – Second moment

  • M3 – Third moment

Returns:

(alpha, T, feasible) where:
  • alpha: Initial probability vector

  • T: Sub-generator matrix

  • feasible: Whether the fit was feasible

Return type:

tuple

aph2_fitall(M1, M2, M3)[source]

Fit a 2-phase APH distribution with all possible structures.

Tries all possible 2-phase APH structures to fit the given moments.

Parameters:
  • M1 – First moment (mean)

  • M2 – Second moment

  • M3 – Third moment

Returns:

Results for all feasible APH structures

aph2_adjust(M1, M2, M3, method='default')[source]

Adjust moments to ensure feasible APH fitting.

Adjusts the input moments to be in the feasible region for 2-phase APH distribution fitting.

Parameters:
  • M1 – First moment (mean)

  • M2 – Second moment

  • M3 – Third moment

  • method – Adjustment method (default: “default”)

Returns:

(M1, M2, M3) - Adjusted moments

Return type:

tuple

mmpp2_fit(E1, E2, E3, G2)[source]

Fit a 2-state MMPP (Markov Modulated Poisson Process) to moments.

Fits a 2-state MMPP to match the first three moments and lag-1 autocorrelation of inter-arrival times.

Parameters:
  • E1 – First moment (mean)

  • E2 – Second moment

  • E3 – Third moment

  • G2 – Lag-1 autocorrelation coefficient

Returns:

(D0, D1, feasible) where:
  • D0: Generator matrix for non-arrival transitions

  • D1: Generator matrix for arrival transitions

  • feasible: Whether the fit was successful

Return type:

tuple

mmpp2_fit1(mean, scv, skew, idc)[source]

Fit a 2-state MMPP using alternative parameterization.

Fits a 2-state MMPP using mean, SCV, skewness, and index of dispersion.

Parameters:
  • mean – Mean inter-arrival time

  • scv – Squared coefficient of variation

  • skew – Skewness

  • idc – Index of dispersion for counts

Returns:

(D0, D1, feasible) where:
  • D0: Generator matrix for non-arrival transitions

  • D1: Generator matrix for arrival transitions

  • feasible: Whether the fit was successful

Return type:

tuple

mmap_mixture_fit(P2, M1, M2, M3)[source]

Fit a mixture of MMAPs to given moments.

Parameters:
  • P2 – Mixing probabilities matrix

  • M1 – First moment matrix

  • M2 – Second moment matrix

  • M3 – Third moment matrix

Returns:

Fitted MMAP mixture parameters

mmap_mixture_fit_mmap(mmap)[source]

Fit mixture of MMAPs from MMAP representation.

Parameters:

mmap – MMAP object or structure to fit mixture from

Returns:

(D0, D1, components) where:
  • D0: Generator matrix for non-arrival transitions

  • D1: Generator matrix for arrival transitions

  • components: List of mixture components

Return type:

tuple

mamap2m_fit_gamma_fb_mmap(mmap)[source]

Fit 2-moment MAMAP using gamma forward-backward algorithm from MMAP.

Parameters:

mmap – MMAP structure to fit

Returns:

Fitted MAMAP parameters

mamap2m_fit_gamma_fb(M1, M2, M3, GAMMA, P, F, B)[source]

Fit 2-moment MAMAP using gamma forward-backward algorithm.

Parameters:
  • M1 – First moment

  • M2 – Second moment

  • M3 – Third moment

  • GAMMA – Gamma parameter

  • P – Probability parameters

  • F – Forward parameters

  • B – Backward parameters

Returns:

(D0, D1, D_classes) - Fitted MAMAP matrices and class matrices

Return type:

tuple

map_exponential(mean)[source]

Fit a Poisson process as a MAP.

Creates a Markovian Arrival Process representing a Poisson process (exponential inter-arrival times) with the specified mean.

Parameters:

mean – Mean inter-arrival time of the process

Returns:

(D0, D1) - MAP matrices representing the Poisson process

Return type:

tuple

Examples

  • map_exponential(2) returns a Poisson process with rate λ=0.5

map_erlang(mean, k)[source]

Fit an Erlang-k process as a MAP.

Creates a Markovian Arrival Process representing an Erlang-k distribution with the specified mean and number of phases.

Parameters:
  • mean – Mean inter-arrival time of the process

  • k – Number of phases in the Erlang distribution

Returns:

(D0, D1) - MAP matrices representing the Erlang-k process

Return type:

tuple

Examples

  • map_erlang(2, 3) creates an Erlang-3 process with mean 2

map_hyperexp(mean, scv, p)[source]

Fit a two-phase Hyperexponential process as a MAP.

Creates a Markovian Arrival Process representing a two-phase hyperexponential distribution with specified mean, squared coefficient of variation, and phase selection probability.

Parameters:
  • mean – Mean inter-arrival time of the process

  • scv – Squared coefficient of variation of inter-arrival times

  • p – Probability of being served in phase 1 (default: p=0.99)

Returns:

(D0, D1) - MAP matrices representing the hyperexponential process

Return type:

tuple

Examples

  • map_hyperexp(1, 2, 0.99) creates a two-phase hyperexponential process where phase 1 is selected with probability 0.99

  • map_hyperexp(1, 2, 0.2) creates a two-phase hyperexponential process where phase 1 is selected with probability 0.2

Note

For some parameter combinations, a feasible solution may not exist. Use map_isfeasible() to check if the returned MAP is valid.

map_scale(D0, D1, newMean)[source]

Rescale mean inter-arrival time of a MAP.

Returns a MAP with the same normalized moments and correlations as the input MAP, except for the mean inter-arrival time which is set to the specified new value.

Parameters:
  • D0 – Generator matrix for non-arrival transitions

  • D1 – Generator matrix for arrival transitions

  • newMean – New mean inter-arrival time

Returns:

(D0_scaled, D1_scaled) - Scaled and normalized MAP matrices

Return type:

tuple

Examples

  • map_mean(map_scale(map_exponential(1), 2)) has mean 2

map_normalize(D0, D1)[source]

Try to make a MAP feasible through normalization.

Normalizes the MAP matrices by: (1) ensuring D0+D1 is an infinitesimal generator, (2) setting all negative off-diagonal entries to zero, and (3) taking the real part of any complex values.

Parameters:
  • D0 – Generator matrix for non-arrival transitions

  • D1 – Generator matrix for arrival transitions

Returns:

(D0_norm, D1_norm) - Normalized MAP matrices that form a valid MAP

Return type:

tuple

Examples

  • map_normalize([[0,0],[0,0]], [[1,2],[3,4]]) produces a valid MAP

map_timereverse(map_input)[source]

Compute time-reversed MAP.

Parameters:

map_input – Either tuple (D0, D1) or MAP container

Returns:

(D0_rev, D1_rev) - Time-reversed MAP matrices

Return type:

tuple

map_mark(MAP, prob)[source]

Mark arrivals from a MAP according to given probabilities.

Takes a MAP with a single arrival type and returns a MMAP (Marked MAP) with the same unmarked inter-arrival process but marked arrivals specified by prob. prob[k] is the probability that an arrival will be marked with type k.

Parameters:
  • MAP – Either tuple (D0, D1) or MAP container representing the input MAP

  • prob – Probability vector where prob[k] is the probability that arrivals are marked with type k (probabilities are normalized if they don’t sum to 1)

Returns:

Marked MAP (MMAP) with multiple arrival types

Note

Input marking probabilities are automatically normalized if they don’t sum to 1.

map_infgen(D0, D1)[source]

Compute infinitesimal generator matrix of MAP.

Parameters:
  • D0 – Generator matrix for non-arrival transitions

  • D1 – Generator matrix for arrival transitions

Returns:

Infinitesimal generator matrix

Return type:

numpy.ndarray

map_super(MAPa, MAPb)[source]

Compute superposition of two independent MAPs.

Creates a MAP that represents the superposition (sum) of two independent Markovian Arrival Processes using Kronecker sum operations. The resulting MAP has arrivals from both input MAPs combined.

Parameters:
  • MAPa – First MAP as tuple (D0_a, D1_a) or container {D0_a, D1_a}

  • MAPb – Second MAP as tuple (D0_b, D1_b) or container {D0_b, D1_b}

Returns:

(D0_super, D1_super) - Superposition MAP matrices where:

D0_super = kron(D0_a, I_b) + kron(I_a, D0_b) D1_super = kron(D1_a, I_b) + kron(I_a, D1_b)

Return type:

tuple

Note

The output is automatically normalized to ensure a valid MAP.

map_sum(MAP, n)[source]

Compute sum of n identical independent MAPs.

Parameters:
  • MAP – MAP as tuple (D0, D1) or container

  • n – Number of identical MAPs to sum

Returns:

(D0_sum, D1_sum) - Sum MAP matrices

Return type:

tuple

map_sumind(MAPs)[source]

Compute sum of multiple independent MAPs.

Parameters:

MAPs – List of MAPs, each as tuple (D0, D1) or container

Returns:

(D0_sum, D1_sum) - Sum MAP matrices

Return type:

tuple

map_checkfeasible(MAP, TOL=1e-10)[source]

Check if MAP satisfies feasibility conditions and return diagnostics.

Parameters:
  • MAP – MAP as tuple (D0, D1) or container

  • TOL – Numerical tolerance (default: 1e-10)

Returns:

Feasibility check results with diagnostic information

map_isfeasible(MAP, TOL=1e-10)[source]

Evaluate feasibility of a MAP process.

Checks if a Markovian Arrival Process satisfies all feasibility conditions including proper matrix structure, non-negativity constraints, stochasticity, and irreducibility requirements.

Parameters:
  • MAP – MAP as tuple (D0, D1) or container {D0, D1}

  • TOL – Numerical tolerance for feasibility checks (default: 1e-10)

Returns:

True if MAP is feasible, False if infeasible

Return type:

bool

Examples

  • map_isfeasible([[0,0],[0,0]], [[1,2],[3,4]]) returns False (infeasible MAP)

Note

Numerical tolerance is based on the standard toolbox value in map_feastol().

map_feastol()[source]

Get default feasibility tolerance for MAP validation.

Returns:

Default tolerance value

Return type:

float

map_largemap()[source]

Get threshold for determining if a MAP is considered large.

Returns:

Size threshold for large MAPs

Return type:

int

aph2_assemble(l1, l2, p1)[source]

Assemble a 2-phase APH distribution from parameters.

Parameters:
  • l1 – Rate parameter for first phase

  • l2 – Rate parameter for second phase

  • p1 – Initial probability for first phase

Returns:

(alpha, T) - Initial vector and generator matrix

Return type:

tuple

ph_reindex(PHs, stationToClass)[source]

Reindex phase-type distributions according to station-to-class mapping.

Parameters:
  • PHs – List of phase-type distributions

  • stationToClass – Mapping from stations to classes

Returns:

Reindexed phase-type distributions

map_rand(K)[source]

Generate a random MAP with K states.

Parameters:

K – Number of states in the MAP

Returns:

(D0, D1) - Randomly generated MAP matrices

Return type:

tuple

map_randn(K, mu, sigma)[source]

Generate a random MAP with normally distributed matrix elements.

Creates a random Markovian Arrival Process with K states where the matrix elements are drawn from normal distributions with specified mean and standard deviation parameters. The resulting matrices are normalized to ensure feasibility.

Parameters:
  • K – Number of states in the MAP

  • mu – Mean parameter for the normal distribution of matrix elements

  • sigma – Standard deviation parameter for the normal distribution

Returns:

(D0, D1) - Random MAP matrices with normalized feasible structure

Return type:

tuple

Note

The generated matrices undergo normalization via map_normalize() to ensure they form a valid MAP structure with proper generator properties.

mmap_lambda(MMAP)[source]

Calculate arrival rate for each class in a Marked MAP.

Computes the arrival rate (lambda) for each job class in a Marked Markovian Arrival Process (MMAP). For a MMAP with C classes, returns a vector of C arrival rates.

Parameters:

MMAP – Marked MAP structure as container {D0, D1, D2, …, DC+1} where D0 is the background generator and D1, D2, …, DC+1 are the arrival generators for each class

Returns:

Vector of arrival rates for each job class

Return type:

numpy.ndarray

Note

This function is equivalent to mmap_count_lambda(MMAP).

mmap_count_mean(MMAP, t)[source]

Compute the mean of the counting process for each class in a Marked MAP.

Calculates the expected number of arrivals in time interval (0, t] for each job class in a Marked Markovian Arrival Process (MMAP).

Parameters:
  • MMAP – Marked MAP structure as container {D0, D1, D2, …, DC+1}

  • t – The time period considered for each sample of the counting process

Returns:

Vector with the mean number of arrivals in (0, t] for each job class

Return type:

numpy.ndarray

Note

For a MMAP with C classes, returns a C-dimensional vector where mk[k] is the mean arrival count for class k in interval (0, t].

mmap_count_var(MMAP, t)[source]

Compute variance of number of arrivals per class in time interval t for an MMAP.

Parameters:
  • MMAP – Markovian Arrival Process with Multiple types

  • t – Time interval

Returns:

Variance of number of arrivals per class in time t

Return type:

numpy.ndarray

mmap_count_idc(MMAP, t)[source]

Compute index of dispersion for counts per class in time interval t for an MMAP.

Parameters:
  • MMAP – Markovian Arrival Process with Multiple types

  • t – Time interval

Returns:

Index of dispersion for counts per class

Return type:

numpy.ndarray

mmap_idc(MMAP)[source]

Compute index of dispersion for counts of an MMAP.

Parameters:

MMAP – Markovian Arrival Process with Multiple types

Returns:

Index of dispersion for counts

Return type:

float

mmap_sigma2(mmap)[source]

Compute second-order statistics (variance) for an MMAP.

Parameters:

mmap – Markovian Arrival Process with Multiple types

Returns:

Second-order statistics matrix

Return type:

numpy.ndarray

mmap_exponential(lambda_rates, n)[source]

Create an exponential MMAP with given arrival rates.

Parameters:
  • lambda_rates – Array of arrival rates for each class

  • n – Number of states

Returns:

Exponential MMAP with specified rates

Return type:

MMAP

mmap_mixture(alpha, MAPs)[source]

Create a mixture of MMAPs with given mixing probabilities.

Parameters:
  • alpha – Mixing probability vector

  • MAPs – List of MMAP components

Returns:

Mixture MMAP

Return type:

MMAP

mmap_super(MMAPa, MMAPb, opt='default')[source]

Compute superposition of two MMAPs.

Parameters:
  • MMAPa – First MMAP

  • MMAPb – Second MMAP

  • opt – Superposition method (default: “default”)

Returns:

Superposed MMAP

Return type:

MMAP

mmap_super_safe(MMAPS, maxorder=10, method='default')[source]

Safe superposition of multiple MMAPs with error checking.

Performs superposition of multiple Marked Markovian Arrival Processes with additional validation and error handling.

Parameters:
  • MMAPS – List of MMAP matrices to superpose

  • maxorder – Maximum order for approximation

  • method – Superposition method

Returns:

Superposed MMAP matrices

mmap_compress(MMAP, config='default')[source]

Compress an MMAP using specified configuration.

Reduces the number of states in an MMAP while preserving key statistical properties using the specified configuration.

Parameters:
  • MMAP – MMAP matrices to compress

  • config – Compression configuration

Returns:

Compressed MMAP matrices

mmap_normalize(MMAP)[source]

Fix MMAP feasibility by normalization.

Normalizes a Marked MAP to ensure feasibility by setting negative values to zero and enforcing the proper conditions for a valid MMAP structure. This includes ensuring the background matrix D0 has negative diagonal elements and the arrival matrices are non-negative.

Parameters:

MMAP – Marked MAP structure as container {D0, D1, D2, …, DC+1}

Returns:

Normalized MMAP structure that satisfies feasibility conditions

Note

The normalization process: 1. Sets negative off-diagonal elements in D0 to zero 2. Sets negative elements in arrival matrices to zero 3. Adjusts diagonal elements of D0 to maintain generator property

mmap_scale(MMAP, M, maxIter=100)[source]

Scale an MMAP using iterative algorithm.

Adjusts the MMAP parameters using matrix M through an iterative scaling procedure.

Parameters:
  • MMAP – MMAP matrices to scale

  • M – Scaling matrix

  • maxIter – Maximum number of iterations

Returns:

Scaled MMAP matrices

mmap_timereverse(mmap)[source]

Compute time-reversed MMAP.

Creates the time-reversed version of a Marked Markovian Arrival Process, reversing the direction of time.

Parameters:

mmap – MMAP matrices to time-reverse

Returns:

Time-reversed MMAP matrices

mmap_hide(MMAP, types)[source]

Hide specific arrival types from an MMAP.

Removes specified arrival types from the MMAP, effectively filtering out those arrival classes.

Parameters:
  • MMAP – MMAP matrices

  • types – Matrix specifying types to hide

Returns:

MMAP with specified types hidden

mmap_shorten(mmap)[source]

Shorten an MMAP by removing redundant elements.

Reduces the size of the MMAP representation by eliminating unnecessary components.

Parameters:

mmap – MMAP matrices to shorten

Returns:

Shortened MMAP matrices

mmap_maps(MMAP)[source]

Extract individual MAP components from an MMAP.

Decomposes a Marked Markovian Arrival Process into its constituent MAP components.

Parameters:

MMAP – MMAP matrices to decompose

Returns:

List of individual MAP matrices

Return type:

list

mmap_pc(MMAP)[source]

Compute probability matrix for MMAP.

Calculates the probability matrix associated with the Marked Markovian Arrival Process.

Parameters:

MMAP – MMAP matrices

Returns:

Probability matrix

Return type:

numpy.ndarray

mmap_forward_moment(MMAP, ORDERS, NORM=True)[source]

Compute forward moments for MMAP.

Calculates forward moments of the inter-arrival times for a Marked Markovian Arrival Process.

Parameters:
  • MMAP – MMAP matrices

  • ORDERS – Array of moment orders to compute

  • NORM – Whether to normalize the moments

Returns:

Forward moment matrix

Return type:

numpy.ndarray

mmap_backward_moment(MMAP, ORDERS, NORM=True)[source]

Compute backward moments for MMAP.

Calculates backward moments of the inter-arrival times for a Marked Markovian Arrival Process.

Parameters:
  • MMAP – MMAP matrices

  • ORDERS – Array of moment orders to compute

  • NORM – Whether to normalize the moments

Returns:

Backward moment matrix

Return type:

numpy.ndarray

mmap_cross_moment(mmap, k)[source]

Compute cross moments for MMAP.

Calculates cross moments between different arrival types in a Marked Markovian Arrival Process.

Parameters:
  • mmap – MMAP matrices

  • k – Cross moment order

Returns:

Cross moment matrix

Return type:

numpy.ndarray

mmap_sample(MMAP, n, random=None)[source]

Generate random samples from an MMAP.

Produces random arrival times and classes according to the specified Marked Markovian Arrival Process.

Parameters:
  • MMAP – MMAP matrices to sample from

  • n – Number of samples to generate

  • random – Random number generator (optional)

Returns:

(times, classes) - Arrays of arrival times and class indices

Return type:

tuple

mmap_rand(order, classes)[source]

Generate a random MMAP with specified parameters.

Creates a random Marked Markovian Arrival Process with the given order (number of states) and number of classes.

Parameters:
  • order – Number of states in the MMAP

  • classes – Number of arrival classes

Returns:

Random MMAP matrices

map_sample(MAP, n, random=None)[source]

Generate a random sample of inter-arrival times.

Produces random inter-arrival time samples according to the specified Markovian Arrival Process using Monte Carlo simulation.

Parameters:
  • MAP – MAP as tuple (D0, D1) or MAP container {D0, D1}

  • n – Number of samples to be generated

  • random – Random number generator or seed (optional)

Returns:

Set of n inter-arrival time samples

Return type:

numpy.ndarray

Examples

  • map_sample(MAP, 10) generates a sample of 10 inter-arrival times

  • map_sample(MAP, 1000, seed=42) generates 1000 samples with fixed seed

Warning

The function can be memory consuming and quite slow for sample sizes greater than n=10000.

mmap_count_lambda(mmap)[source]

Compute arrival rate lambda for MMAP counting process.

Calculates the lambda parameters for the counting process associated with the Marked Markovian Arrival Process.

Parameters:

mmap – MMAP matrices or MMAP object

Returns:

Lambda parameters for counting process

Return type:

numpy.ndarray

mmap_isfeasible(mmap)[source]

Check if an MMAP is feasible (valid).

Determines whether the given Marked Markovian Arrival Process satisfies all necessary conditions for validity.

Parameters:

mmap – MMAP matrices or MMAP object

Returns:

True if MMAP is feasible, False otherwise

Return type:

bool

mmap_mark(mmap, prob)[source]

Mark an MMAP with specified probabilities.

Applies probability markings to a Markovian Arrival Process to create a Marked MAP with specified marking probabilities.

Parameters:
  • mmap – MMAP matrices or MMAP object

  • prob – Marking probabilities matrix

Returns:

Marked MMAP with applied probabilities

aph_bernstein(f, order)[source]

Compute Bernstein approximation of function using Acyclic PH.

Approximates a function using Bernstein polynomials with an Acyclic Phase-type distribution representation.

Parameters:
  • f – Function to approximate

  • order – Order of Bernstein approximation

Returns:

Acyclic PH approximation result

map_jointpdf_derivative(map_matrices, iset)[source]

Compute joint PDF derivative for MAP.

Calculates the derivative of the joint probability density function for a Markovian Arrival Process with respect to specified indices.

Parameters:
  • map_matrices – List of MAP matrices [D0, D1]

  • iset – Set of indices for derivative computation

Returns:

Joint PDF derivative result

map_ccdf_derivative(map_matrices, i)[source]

Compute complementary CDF derivative for MAP.

Calculates the derivative of the complementary cumulative distribution function for a Markovian Arrival Process.

Parameters:
  • map_matrices – List of MAP matrices [D0, D1]

  • i – Index parameter for derivative computation

Returns:

Complementary CDF derivative result

qbd_R(B, L, F, iter_max=100000)[source]

Compute the R matrix for a Quasi-Birth-Death process.

Solves the matrix equation R = F + R*L*R + R^2*B using iterative methods. The R matrix is fundamental in QBD analysis.

Parameters:
  • B – Backward transition matrix

  • L – Local transition matrix

  • F – Forward transition matrix

  • iter_max – Maximum number of iterations (default: 100000)

Returns:

The R matrix

Return type:

numpy.ndarray

qbd_R_logred(B, L, F, iter_max=100000)[source]

Compute the R matrix using logarithmic reduction algorithm.

Alternative method for computing the R matrix that can be more numerically stable for certain QBD problems.

Parameters:
  • B – Backward transition matrix

  • L – Local transition matrix

  • F – Forward transition matrix

  • iter_max – Maximum number of iterations (default: 100000)

Returns:

The R matrix

Return type:

numpy.ndarray

qbd_rg(map_a, map_s, util=None)[source]

Analyze a MAP/MAP/1 queue using QBD methods.

Analyzes a single-server queue with MAP arrivals and MAP service times using Quasi-Birth-Death process techniques.

Parameters:
  • map_a – Arrival MAP (list/array with D0, D1 matrices)

  • map_s – Service MAP (list/array with D0, D1 matrices)

  • util – Utilization constraint (optional)

Returns:

QBD analysis results including performance measures

map_pdf(MAP, points)[source]

Compute probability density function of interarrival times.

Evaluates the probability density function (PDF) of the interarrival time distribution for a Markovian Arrival Process at the specified time points.

Parameters:
  • MAP – MAP as tuple (D0, D1) representing the Markovian Arrival Process

  • points – Array of time points to evaluate the PDF at

Returns:

PDF values at the specified points, returned in the

same order as the points vector

Return type:

numpy.ndarray

Examples

  • map_pdf(MAP, [0.5, 1.0, 2.0]) returns PDF values at t=0.5, 1.0, 2.0

map_prob(MAP, t)[source]

Compute probability for MAP at time t.

Calculates the probability measure associated with the Markovian Arrival Process at the specified time.

Parameters:
  • MAP – MAP as tuple (D0, D1) matrices

  • t – Time point for probability computation

Returns:

Probability value at time t

Return type:

float

map_joint(MAP1, MAP2)[source]

Compute joint distribution of two MAPs.

Creates the joint distribution representation of two independent Markovian Arrival Processes.

Parameters:
  • MAP1 – First MAP as tuple (D0, D1)

  • MAP2 – Second MAP as tuple (D0, D1)

Returns:

Joint MAP representation

map_mixture(alpha, MAPs)[source]

Create mixture of multiple MAPs.

Constructs a mixture distribution from multiple Markovian Arrival Processes with given mixing probabilities.

Parameters:
  • alpha – Mixing probabilities (weights) for each MAP

  • MAPs – List of MAP matrices to mix

Returns:

Mixture MAP representation

map_max(MAP1, MAP2)[source]

Compute maximum of two independent MAPs.

Parameters:
  • MAP1 – First MAP as tuple (D0, D1)

  • MAP2 – Second MAP as tuple (D0, D1)

Returns:

MAP representing max(X,Y) where X~MAP1, Y~MAP2

map_renewal(MAPIN)[source]

Remove all correlations from a MAP to create a renewal process.

Transforms a Markovian Arrival Process into a renewal MAP process with the same cumulative distribution function (CDF) as the input MAP, but with no correlations between inter-arrival times.

Parameters:

MAPIN – Input MAP as tuple (D0, D1) representing the original MAP

Returns:

Renewal MAP with same marginal distribution but independent inter-arrival times

Note

The resulting process maintains the same inter-arrival time distribution but removes all temporal dependencies, making it a renewal process.

map_stochcomp(MAP)[source]

Compute stochastic complement of MAP by eliminating states.

Parameters:

MAP – MAP as tuple (D0, D1)

Returns:

Reduced MAP with eliminated transient states

qbd_mapmap1(MAP_A, MAP_S, mu=None)[source]

Analyze MAP/MAP/1 queueing system using QBD methods.

Parameters:
  • MAP_A – Arrival MAP as tuple (D0, D1)

  • MAP_S – Service MAP as tuple (D0, D1)

  • mu – Service rate parameter (optional)

Returns:

QBD analysis results including performance measures

Return type:

dict

qbd_raprap1(RAP_A, RAP_S, util=None)[source]

Analyze RAP/RAP/1 queueing system using QBD methods.

Parameters:
  • RAP_A – Arrival RAP (Rational Arrival Process)

  • RAP_S – Service RAP

  • util – Utilization parameter (optional)

Returns:

QBD analysis results for RAP/RAP/1 queue

Return type:

dict

qbd_bmapbmap1(BMAP_A, BMAP_S)[source]

Analyze BMAP/BMAP/1 queueing system using QBD methods.

Parameters:
  • BMAP_A – Arrival Batch MAP

  • BMAP_S – Service Batch MAP

Returns:

QBD analysis results for batch arrival/service system

Return type:

dict

qbd_setupdelayoff(MAP_A, MAP_S, setup_time, delay_time, off_time)[source]

Analyze queue with setup, delay, and off periods using QBD methods.

Models a queueing system with server setup times, processing delays, and off periods using Quasi-Birth-Death process analysis.

Parameters:
  • MAP_A – Arrival MAP as tuple (D0, D1).

  • MAP_S – Service MAP as tuple (D0, D1).

  • setup_time – Server setup time.

  • delay_time – Processing delay time.

  • off_time – Server off time.

Returns:

Performance measures for the system with timing constraints.

Return type:

dict

aph_simplify(a1, T1, a2, T2, p1, p2, pattern)[source]

Simplify APH representation using specified pattern.

Parameters:
  • a1 – Initial vector for first APH

  • T1 – Generator matrix for first APH

  • a2 – Initial vector for second APH

  • T2 – Generator matrix for second APH

  • p1 – Probability parameter for first APH

  • p2 – Probability parameter for second APH

  • pattern – Simplification pattern identifier

Returns:

(alpha, T) simplified APH representation

Return type:

tuple

randp(P, rows, cols=None)[source]

Pick random values with relative probability.

Returns integers in the range from 1 to len(P) with a relative probability, so that the value X is present approximately (P[X-1]/sum(P)) times.

Parameters:
  • P – Probability vector (all values should be >= 0)

  • rows – Number of rows for output matrix

  • cols – Number of columns for output matrix (defaults to rows if not specified)

Returns:

Matrix of random integers with specified probabilities

aph_rand(n)[source]

Generate random APH distribution with n phases.

Parameters:

n – Number of phases

Returns:

(alpha, T) random APH representation

Return type:

tuple

amap2_fit_gamma(mean1, var1, mean2, var2, p)[source]

Fit 2-phase AMAP using gamma matching method.

Parameters:
  • mean1 – Mean for first phase

  • var1 – Variance for first phase

  • mean2 – Mean for second phase

  • var2 – Variance for second phase

  • p – Phase probability

Returns:

(D0, D1) fitted AMAP matrices

Return type:

tuple

mamap2m_fit_fb_multiclass(data, classes, options=None)[source]

Fit multiclass MAMAP using feedback method.

Parameters:
  • data – Input data for fitting

  • classes – Number of classes

  • options – Fitting options (optional)

Returns:

Fitted AMAP and quality metrics

Return type:

dict

mmpp_rand(states, lambda_range=(0.1, 5.0))[source]
map_count_moment(MAP, k, lag=0)[source]

Compute count moments of MAP arrivals.

Parameters:
  • MAP – MAP as tuple (D0, D1)

  • k – Moment order

  • lag – Time lag (default: 0)

Returns:

Count moment value

Return type:

float

map_kurt(MAP)[source]

Calculate kurtosis of inter-arrival times for a MAP.

Computes the fourth moment (kurtosis) of the inter-arrival time distribution for a Markovian Arrival Process.

Parameters:

MAP – MAP as tuple (D0, D1) of generator matrices.

Returns:

Kurtosis of inter-arrival times.

Return type:

float

mmap_sigma2_cell(MMAP)[source]

Compute two-step class transition probabilities for MMAP (cell version).

Parameters:

MMAP – Multi-class MAP matrices as cell structure

Returns:

3D matrix of class transition probabilities

amap2_adjust_gamma(mean1, var1, mean2, var2, p, target_mean, target_var)[source]

Adjust 2-phase AMAP gamma parameters to target moments.

Parameters:
  • mean1 – Mean for first phase

  • var1 – Variance for first phase

  • mean2 – Mean for second phase

  • var2 – Variance for second phase

  • p – Phase probability

  • target_mean – Target mean value

  • target_var – Target variance value

Returns:

Adjusted AMAP parameters

amap2_fitall_gamma(data, options=None)[source]

Fit all gamma parameters for 2-phase AMAP from data.

Parameters:
  • data – Input data for fitting

  • options – Fitting options (optional)

Returns:

Fitted AMAP parameters and quality metrics

Return type:

dict

mmpp2_fit_mu00(data, options=None)[source]

Fit 2-phase MMPP parameter mu00 from data.

Parameters:
  • data – Input data for parameter fitting

  • options – Fitting options (optional)

Returns:

Fitted mu00 parameter

mmpp2_fit_mu11(data, options=None)[source]

Fit 2-phase MMPP parameter mu11 from data.

Parameters:
  • data – Input data for parameter fitting

  • options – Fitting options (optional)

Returns:

Fitted mu11 parameter

mmpp2_fit_q01(data, options=None)[source]

Fit 2-phase MMPP parameter q01 from data.

Parameters:
  • data – Input data for parameter fitting

  • options – Fitting options (optional)

Returns:

Fitted q01 parameter

mmpp2_fit_q10(data, options=None)[source]

Fit 2-phase MMPP parameter q10 from data.

Parameters:
  • data – Input data for parameter fitting

  • options – Fitting options (optional)

Returns:

Fitted q10 parameter

assess_compression_quality(original_MAP, compressed_MAP, metrics=['mean', 'var', 'acf'])[source]

Assess quality of MAP compression by comparing metrics.

Evaluates how well a compressed MAP approximates the original MAP by comparing specified statistical metrics.

Parameters:
  • original_MAP – Original MAP as tuple (D0, D1).

  • compressed_MAP – Compressed MAP as tuple (D0, D1).

  • metrics – List of metrics to compare (default: [‘mean’, ‘var’, ‘acf’]).

Returns:

Quality assessment results for each metric.

Return type:

dict

compress_adaptive(MAP, target_order, options=None)[source]

Compress MAP using adaptive compression algorithm.

Parameters:
  • MAP – MAP as tuple (D0, D1)

  • target_order – Target order for compression

  • options – Compression options (optional)

Returns:

Compressed MAP with reduced order

compress_autocorrelation(MAP, target_order, options=None)[source]

Compress MAP preserving autocorrelation properties.

Parameters:
  • MAP – MAP as tuple (D0, D1)

  • target_order – Target order for compression

  • options – Compression options (optional)

Returns:

Compressed MAP preserving autocorrelation structure

compress_spectral(MAP, target_order, options=None)[source]

Compress MAP using spectral decomposition methods.

Parameters:
  • MAP – MAP as tuple (D0, D1)

  • target_order – Target order for compression

  • options – Compression options (optional)

Returns:

Compressed MAP using spectral techniques

compress_with_quality_control(MAP, target_order, quality_threshold=0.95, options=None)[source]

Compress MAP with quality control constraints.

Parameters:
  • MAP – MAP as tuple (D0, D1)

  • target_order – Target order for compression

  • quality_threshold – Quality threshold (default: 0.95)

  • options – Compression options (optional)

Returns:

Compressed MAP and quality metrics

Return type:

dict

qbd_G(A0, A1, A2)[source]

Compute G matrix for Quasi-Birth-Death (QBD) process.

Calculates the G matrix which represents the probability generating function for the first passage time from level k to k+1.

Parameters:
  • A0 – Transition rate matrix for level down

  • A1 – Transition rate matrix for same level

  • A2 – Transition rate matrix for level up

Returns:

G matrix

Return type:

numpy.ndarray

ph_fit(data, max_phases=10)[source]

Fit phase-type distribution to empirical data.

Estimates the parameters of a phase-type distribution that best fits the given data using maximum likelihood estimation.

Parameters:
  • data – Empirical data to fit

  • max_phases – Maximum number of phases to use

Returns:

(alpha, T) - Initial probability vector and transition rate matrix

Return type:

tuple

ph_mean(alpha, T)[source]

Compute mean of phase-type distribution.

Calculates the expected value (first moment) of a phase-type distribution with given initial vector and transition matrix.

Parameters:
  • alpha – Initial probability vector

  • T – Transition rate matrix

Returns:

Mean of the phase-type distribution

Return type:

float

ph_var(alpha, T)[source]

Compute variance of phase-type distribution.

Calculates the variance (second central moment) of a phase-type distribution with given parameters.

Parameters:
  • alpha – Initial probability vector

  • T – Transition rate matrix

Returns:

Variance of the phase-type distribution

Return type:

float

ph_pdf(alpha, T, points)[source]

Compute PDF of phase-type distribution at given points.

Evaluates the probability density function of a phase-type distribution at the specified points.

Parameters:
  • alpha – Initial probability vector

  • T – Transition rate matrix

  • points – Points at which to evaluate the PDF

Returns:

PDF values at the specified points

Return type:

numpy.ndarray

ph_cdf(alpha, T, points)[source]

Compute CDF of phase-type distribution at given points.

Evaluates the cumulative distribution function of a phase-type distribution at the specified points.

Parameters:
  • alpha – Initial probability vector

  • T – Transition rate matrix

  • points – Points at which to evaluate the CDF

Returns:

CDF values at the specified points

Return type:

numpy.ndarray

qbd_psif(A0, A1, A2, B, options=None)[source]

Compute finite QBD stationary probability vector.

Calculates the stationary probability vector for a finite Quasi-Birth-Death process with boundary conditions.

Parameters:
  • A0 – Transition rate matrix for level down

  • A1 – Transition rate matrix for same level

  • A2 – Transition rate matrix for level up

  • B – Boundary condition matrix

  • options – Optional solver options

Returns:

Stationary probability vector

Return type:

numpy.ndarray

qbd_psi(A0, A1, A2, options=None)[source]

Compute Psi matrix for QBD process using iterative methods.

Parameters:
  • A0 – QBD backward transition matrix

  • A1 – QBD local transition matrix

  • A2 – QBD forward transition matrix

  • options – Computational options (optional)

Returns:

Psi matrix for QBD fundamental matrices

Return type:

numpy.ndarray

aph2_check_feasibility(M1, M2, M3)[source]

Check feasibility of 2-phase APH distribution parameters.

Parameters:
  • M1 – First moment

  • M2 – Second moment

  • M3 – Third moment

Returns:

True if parameters are feasible for 2-phase APH

Return type:

bool

aph2_canonical(a1, t11, a2, t22)[source]

Convert 2-phase APH to canonical form.

Parameters:
  • a1 – Initial probability for first phase

  • t11 – Transition rate for first phase

  • a2 – Initial probability for second phase

  • t22 – Transition rate for second phase

Returns:

Canonical form APH parameters

Return type:

tuple

map_cdf_derivative(MAP, x, order=1)[source]

Compute derivative of MAP cumulative distribution function.

Parameters:
  • MAP – MAP as tuple (D0, D1)

  • x – Point at which to evaluate derivative

  • order – Derivative order (default: 1)

Returns:

CDF derivative value at point x

Return type:

float

map_rand_moment(K, target_mean=1.0, target_var=1.0)[source]

Generate random MAP with specified moments.

Creates a random Markovian Arrival Process with the given number of states and target statistical moments.

Parameters:
  • K – Number of states

  • target_mean – Target mean inter-arrival time

  • target_var – Target variance of inter-arrival time

Returns:

(D0, D1) - Random MAP matrices with target moments

Return type:

tuple

qbd_solve(A0, A1, A2)[source]

Solve Quasi-Birth-Death process for stationary distribution.

Computes the stationary probability distribution and rate matrix for an infinite QBD process.

Parameters:
  • A0 – Transition rate matrix for level down

  • A1 – Transition rate matrix for same level

  • A2 – Transition rate matrix for level up

Returns:

(pi0, R) - Boundary probabilities and rate matrix

Return type:

tuple

amap2_fit_gamma_map(map_obj)[source]

Fits AMAP(2) by approximating arbitrary-order MAP with preserved correlation structure.

Parameters:

map_obj – Input MAP object to approximate

Returns:

Fitted AMAP(2) parameters (D0, D1)

Return type:

tuple

amap2_fit_gamma_trace(trace)[source]

Fits AMAP(2) from empirical traces while preserving autocorrelation characteristics.

Parameters:

trace – Empirical trace data (array-like)

Returns:

Fitted AMAP(2) parameters (D0, D1)

Return type:

tuple

aph2_fit_map(map_obj)[source]

Fits APH(2) distributions by approximating arbitrary-order MAP processes.

Parameters:

map_obj – Input MAP object to approximate with APH(2)

Returns:

Fitted APH(2) parameters (alpha, T)

Return type:

tuple

aph2_fit_trace(trace)[source]

Fits APH(2) distributions from empirical inter-arrival time traces.

Parameters:

trace – Empirical trace data (array-like)

Returns:

Fitted APH(2) parameters (alpha, T)

Return type:

tuple

qbd_r(A0, A1, A2)[source]

Computes the rate matrix R for QBD processes.

Parameters:
  • A0 – Level down transition matrix

  • A1 – Level transition matrix

  • A2 – Level up transition matrix

Returns:

Rate matrix R

Return type:

numpy.ndarray

map_block(MAP, k)[source]

Extracts a block from a MAP representation.

Parameters:
  • MAP – Markovian Arrival Process representation

  • k – Block index

Returns:

The k-th block of the MAP

Return type:

numpy.ndarray

map_feasblock(MAP)[source]

Computes feasibility blocks for MAP representation.

Parameters:

MAP – Markovian Arrival Process representation

Returns:

Feasibility block information

Return type:

dict

map_kpc(MAP, k)[source]

Computes k-th order phase-type correlation for MAP.

Parameters:
  • MAP – Markovian Arrival Process representation

  • k – Correlation order

Returns:

k-th order correlation coefficient

Return type:

float

map_pntiter(MAP, n, epsilon=1e-8)[source]

Point process iteration method for MAP analysis.

Parameters:
  • MAP – Markovian Arrival Process representation

  • n – Number of iterations

  • epsilon – Convergence tolerance

Returns:

Iteration results

Return type:

dict

map_pntquad(MAP, n)[source]

Point process quadrature method for MAP analysis.

Parameters:
  • MAP – Markovian Arrival Process representation

  • n – Number of quadrature points

Returns:

Quadrature results

Return type:

dict

map2mmpp(MAP)[source]

Converts MAP to MMPP representation.

Parameters:

MAP – Markovian Arrival Process representation

Returns:

MMPP representation with D0 and D1 matrices

Return type:

dict

m3pp_rand(n, params=None)[source]

Generates random M3PP (third-order Markov-modulated Poisson process).

Parameters:
  • n – Number of states

  • params – Optional parameters for generation

Returns:

Random M3PP representation

Return type:

dict

m3pp_interleave_fitc_theoretical(M3PP1, M3PP2)[source]

Fits interleaved M3PP using theoretical approach.

Parameters:
  • M3PP1 – First M3PP process

  • M3PP2 – Second M3PP process

Returns:

Interleaved M3PP representation

Return type:

dict

m3pp_interleave_fitc_trace(trace1, trace2)[source]

Fits interleaved M3PP from trace data.

Parameters:
  • trace1 – First trace data

  • trace2 – Second trace data

Returns:

Fitted M3PP representation

Return type:

dict

m3pp_superpos_fitc(M3PPs)[source]

Fits superposition of multiple M3PP processes.

Parameters:

M3PPs – List of M3PP processes

Returns:

Superposed M3PP representation

Return type:

dict

m3pp_superpos_fitc_theoretical(M3PPs)[source]

Fits superposition of M3PP processes using theoretical approach.

Parameters:

M3PPs – List of M3PP processes

Returns:

Superposed M3PP representation

Return type:

dict

maph2m_fit(data, m, h)[source]

Fits PH(2,m) distribution to data.

Parameters:
  • data – Input data for fitting

  • m – Number of phases

  • h – Hyper-parameter

Returns:

Fitted PH(2,m) representation

Return type:

dict

maph2m_fitc_approx(moments, m)[source]

Approximate fitting of PH(2,m) from moments.

Parameters:
  • moments – Statistical moments

  • m – Number of phases

Returns:

Fitted PH(2,m) representation

Return type:

dict

maph2m_fitc_theoretical(params, m)[source]

Theoretical fitting of PH(2,m) distribution.

Parameters:
  • params – Theoretical parameters

  • m – Number of phases

Returns:

Fitted PH(2,m) representation

Return type:

dict

maph2m_fit_mmap(MMAP, m)[source]

Fits PH(2,m) from MMAP representation.

Parameters:
  • MMAP – Marked MAP representation

  • m – Number of phases

Returns:

Fitted PH(2,m) representation

Return type:

dict

maph2m_fit_multiclass(data, classes, m)[source]

Fits PH(2,m) for multiclass data.

Parameters:
  • data – Multiclass input data

  • classes – Class definitions

  • m – Number of phases

Returns:

Fitted multiclass PH(2,m) representation

Return type:

dict

maph2m_fit_trace(trace, m)[source]

Fits PH(2,m) from trace data.

Parameters:
  • trace – Trace data

  • m – Number of phases

Returns:

Fitted PH(2,m) representation

Return type:

dict

mmap_embedded(MMAP)[source]

Computes embedded process of MMAP.

Parameters:

MMAP – Marked MAP representation

Returns:

Embedded process representation

Return type:

numpy.ndarray

mmap_count_mcov(MMAP, lag)[source]

Computes cross-covariance of counts for MMAP.

Parameters:
  • MMAP – Marked MAP representation

  • lag – Time lag for covariance

Returns:

Cross-covariance matrix

Return type:

numpy.ndarray

mmap_issym(MMAP)[source]

Checks if MMAP is symmetric.

Parameters:

MMAP – Marked MAP representation

Returns:

True if MMAP is symmetric

Return type:

bool

mmap_max(MMAPs)[source]

Computes maximum of multiple MMAPs.

Parameters:

MMAPs – List of MMAP representations

Returns:

Maximum MMAP representation

Return type:

dict

mmap_mixture_order2(MMAPs, weights)[source]

Creates second-order mixture of MMAPs.

Parameters:
  • MMAPs – List of MMAP representations

  • weights – Mixture weights

Returns:

Mixed MMAP representation

Return type:

dict

mmap_modulate(MMAP, modulation)[source]

Modulates MMAP with given modulation function.

Parameters:
  • MMAP – Marked MAP representation

  • modulation – Modulation function or parameters

Returns:

Modulated MMAP representation

Return type:

dict

mmap_pie(MMAP)[source]

Computes stationary distribution of MMAP.

Parameters:

MMAP – Marked MAP representation

Returns:

Stationary distribution

Return type:

numpy.ndarray

mmap_sigma(MMAP)[source]

Computes sigma parameter for MMAP.

Parameters:

MMAP – Marked MAP representation

Returns:

Sigma parameter

Return type:

float

mmap_sum(MMAPs)[source]

Computes sum of multiple MMAPs.

Parameters:

MMAPs – List of MMAP representations

Returns:

Summed MMAP representation

Return type:

dict

mmpp2_fitc(data)[source]

Fits MMPP(2) using correlation fitting.

Parameters:

data – Input data for fitting

Returns:

Fitted MMPP(2) representation

Return type:

dict

mmpp2_fitc_approx(moments)[source]

Approximate fitting of MMPP(2) from moments.

Parameters:

moments – Statistical moments

Returns:

Fitted MMPP(2) representation

Return type:

dict

qbd_r_logred(A0, A1, A2)[source]

Computes the rate matrix R using logarithmic reduction.

Parameters:
  • A0 – Level down transition matrix

  • A1 – Level transition matrix

  • A2 – Level up transition matrix

Returns:

Rate matrix R computed via logarithmic reduction

Return type:

numpy.ndarray

mapqn_bnd_lr(MAP, N, Z=None)[source]

Computes lower and upper response time bounds for MAP queueing networks.

Parameters:
  • MAP – MAP representation of arrival process

  • N – Population vector

  • Z – Think times (optional)

Returns:

Lower and upper bounds

Return type:

dict

mapqn_bnd_lr_mva(MAP, N, Z=None)[source]

Computes MAP queueing network bounds using MVA approach.

Parameters:
  • MAP – MAP representation of arrival process

  • N – Population vector

  • Z – Think times (optional)

Returns:

MVA-based bounds

Return type:

dict

mapqn_bnd_lr_pf(MAP, N, Z=None)[source]

Computes MAP queueing network bounds using product-form approach.

Parameters:
  • MAP – MAP representation of arrival process

  • N – Population vector

  • Z – Think times (optional)

Returns:

Product-form based bounds

Return type:

dict

mapqn_bnd_qr(MAP, N, Z=None)[source]

Computes queue length and response time bounds for MAP queueing networks.

Parameters:
  • MAP – MAP representation of arrival process

  • N – Population vector

  • Z – Think times (optional)

Returns:

Queue and response time bounds

Return type:

dict

mapqn_bnd_qr_delay(MAP, N, Z, delay)[source]

Computes bounds for MAP queueing networks with delay.

Parameters:
  • MAP – MAP representation of arrival process

  • N – Population vector

  • Z – Think times

  • delay – Delay parameters

Returns:

Bounds with delay consideration

Return type:

dict

mapqn_bnd_qr_ld(MAP, N, Z, mu)[source]

Computes bounds for load-dependent MAP queueing networks.

Parameters:
  • MAP – MAP representation of arrival process

  • N – Population vector

  • Z – Think times

  • mu – Load-dependent service rates

Returns:

Load-dependent bounds

Return type:

dict

mapqn_lpmodel(MAP, N, Z=None)[source]

Creates linear programming model for MAP queueing network.

Parameters:
  • MAP – MAP representation of arrival process

  • N – Population vector

  • Z – Think times (optional)

Returns:

LP model components

Return type:

dict

mapqn_parameters(MAP, N)[source]

Extracts parameters from MAP queueing network.

Parameters:
  • MAP – MAP representation of arrival process

  • N – Population vector

Returns:

Network parameters

Return type:

dict

mapqn_parameters_factory(params_dict)[source]

Factory method to create MAP queueing network parameters.

Parameters:

params_dict – Dictionary of parameters

Returns:

Formatted network parameters

Return type:

dict

mapqn_qr_bounds_bas(MAP, N, Z=None)[source]

Computes Balanced Asymptotic System (BAS) bounds for MAP queueing networks.

Parameters:
  • MAP – MAP representation of arrival process

  • N – Population vector

  • Z – Think times (optional)

Returns:

BAS bounds

Return type:

dict

mapqn_qr_bounds_rsrd(MAP, N, Z=None)[source]

Computes Response-time Scaled Routing Delay (RSRD) bounds for MAP queueing networks.

Parameters:
  • MAP – MAP representation of arrival process

  • N – Population vector

  • Z – Think times (optional)

Returns:

RSRD bounds

Return type:

dict

m3pp22_fitc_approx_cov(mean, scv, skew, cov)[source]

Implements parameter fitting for second-order Marked Markov Modulated Poisson Process.

Parameters:
  • mean – Mean inter-arrival time

  • scv – Squared coefficient of variation

  • skew – Skewness

  • cov – Covariance matrix

Returns:

Fitted M3PP(2,2) parameters

Return type:

dict

mamap2m_coefficients(mean, scv, skew)[source]

Computes coefficients for MAMAP(2,m) fitting.

Parameters:
  • mean – Mean value

  • scv – Squared coefficient of variation

  • skew – Skewness

Returns:

Coefficient matrix

Return type:

numpy.ndarray

m3pp22_fitc_approx_cov_multiclass(means, scvs, skews, covs)[source]

Implements constrained optimization for fitting M3PP(2,2) parameters given an underlying.

Parameters:
  • means – Mean inter-arrival times per class

  • scvs – Squared coefficients of variation per class

  • skews – Skewness values per class

  • covs – Covariance matrices

Returns:

Fitted M3PP(2,2) parameters for multiple classes

Return type:

dict

m3pp22_interleave_fitc(processes)[source]

Implements lumped superposition of multiple M3PP(2,2) processes using interleaved.

Parameters:

processes – List of M3PP(2,2) process parameters

Returns:

Interleaved M3PP(2,2) parameters

Return type:

dict

m3pp2m_fitc(mean, scv, skew, num_classes)[source]

Implements exact fitting of second-order Marked Markov Modulated Poisson Process.

Parameters:
  • mean – Mean inter-arrival time

  • scv – Squared coefficient of variation

  • skew – Skewness

  • num_classes – Number of classes

Returns:

Fitted M3PP(2,m) parameters

Return type:

dict

m3pp2m_fitc_approx(mean, scv, skew, num_classes)[source]

Implements approximation-based fitting for M3PP(2,m) using optimization methods.

Parameters:
  • mean – Mean inter-arrival time

  • scv – Squared coefficient of variation

  • skew – Skewness

  • num_classes – Number of classes

Returns:

Fitted M3PP(2,m) parameters

Return type:

dict

m3pp2m_fitc_approx_ag(mean, scv, skew, num_classes)[source]

Implements auto-gamma approximation method for M3PP(2,m) parameter fitting.

Parameters:
  • mean – Mean inter-arrival time

  • scv – Squared coefficient of variation

  • skew – Skewness

  • num_classes – Number of classes

Returns:

Fitted M3PP(2,m) parameters using auto-gamma

Return type:

dict

m3pp2m_fitc_approx_ag_multiclass(means, scvs, skews, num_classes)[source]

Implements multiclass auto-gamma fitting for M3PP(2,m) with variance and covariance.

Parameters:
  • means – Mean inter-arrival times per class

  • scvs – Squared coefficients of variation per class

  • skews – Skewness values per class

  • num_classes – Number of classes

Returns:

Fitted M3PP(2,m) parameters for multiple classes

Return type:

dict

m3pp2m_interleave(processes)[source]

Implements interleaved superposition of multiple M3PP(2,m) processes to construct.

Parameters:

processes – List of M3PP(2,m) process parameters

Returns:

Interleaved M3PP(2,m) parameters

Return type:

dict

m3pp_interleave_fitc(processes)[source]

Implements fitting and interleaving of k second-order M3PP processes with varying.

Parameters:

processes – List of M3PP process parameters

Returns:

Interleaved M3PP parameters

Return type:

dict

mamap22_fit_gamma_fs_trace(trace)[source]

Fits MAMAP(2,2) from trace data using gamma autocorrelation and forward-sigma characteristics.

Parameters:

trace – Empirical trace data

Returns:

Fitted MAMAP(2,2) parameters

Return type:

dict

mamap22_fit_multiclass(class_data)[source]

Fits MAMAP(2,2) processes for two-class systems with forward moments and sigma characteristics.

Parameters:

class_data – Data for multiple classes

Returns:

Fitted MAMAP(2,2) parameters for multiple classes

Return type:

dict

mamap2m_fit(mean, scv, skew, num_states)[source]

Fits MAMAP(2,m) processes matching moments, autocorrelation, and class characteristics.

Parameters:
  • mean – Mean value

  • scv – Squared coefficient of variation

  • skew – Skewness

  • num_states – Number of states

Returns:

Fitted MAMAP(2,m) parameters

Return type:

dict

mamap2m_fit_mmap(mmap_obj)[source]

Fits MAPH/MAMAP(2,m) by approximating characteristics of input MMAP processes.

Parameters:

mmap_obj – Input MMAP object

Returns:

Fitted MAMAP(2,m) parameters

Return type:

dict

mamap2m_fit_trace(trace, num_states)[source]

Fits MAMAP(2,m) processes from empirical trace data with inter-arrival times and class labels.

Parameters:
  • trace – Empirical trace data

  • num_states – Number of states

Returns:

Fitted MAMAP(2,m) parameters

Return type:

dict

Markov Chain API (line_solver.api.mc)

Markov Chain analysis functions.

This module provides unified access to both continuous-time (CTMC) and discrete-time (DTMC) Markov chain analysis functions. It serves as a consolidated interface for Markov chain computations used throughout LINE.

Functions include both CTMC and DTMC methods: - ctmc_makeinfgen: Construct infinitesimal generator - ctmc_solve: Steady-state CTMC analysis - dtmc_solve: Steady-state DTMC analysis - Transient analysis methods - Simulation functions - Time-reversal and other transformations

This module aggregates functions from both ctmc and dtmc modules.

ctmc_makeinfgen(birth_rates, death_rates, max_states=None)[source]

Construct infinitesimal generator for birth-death process.

Creates a tridiagonal generator matrix for a birth-death CTMC with specified birth and death rates.

Parameters:
  • birth_rates – Array of birth rates (transitions i -> i+1).

  • death_rates – Array of death rates (transitions i -> i-1).

  • max_states – Maximum number of states (optional).

Returns:

Infinitesimal generator matrix Q.

Return type:

numpy.ndarray

ctmc_solve(Q)[source]

Solve for steady-state probabilities of a CTMC.

Computes the stationary distribution π by solving πQ = 0 with normalization constraint.

Parameters:

Q – Infinitesimal generator matrix.

Returns:

Steady-state probability distribution.

Return type:

numpy.ndarray

ctmc_transient(Q, initial_dist, time_points)[source]

Compute transient probabilities of a CTMC.

Calculates time-dependent state probabilities π(t) for specified time points using matrix exponential methods.

Parameters:
  • Q – Infinitesimal generator matrix.

  • initial_dist – Initial probability distribution π(0).

  • time_points – Array of time points to evaluate.

Returns:

Transient probabilities at each time point.

Return type:

numpy.ndarray

ctmc_simulate(Q, initial_state, max_time, max_events=10000)[source]

Simulate CTMC sample path.

Generates a realization of the continuous-time Markov chain using the Gillespie algorithm or similar Monte Carlo method.

Parameters:
  • Q – Infinitesimal generator matrix.

  • initial_state – Starting state (integer index).

  • max_time – Maximum simulation time.

  • max_events – Maximum number of transitions (default: 10000).

Returns:

Simulation results with ‘states’, ‘times’, and ‘sojourn_times’.

Return type:

dict

ctmc_randomization(Q, initial_dist, time_points, precision=1e-10)[source]

Compute CTMC transient probabilities using randomization.

Uses Jensen’s randomization method to compute transient probabilities by converting the CTMC to a uniformized DTMC.

Parameters:
  • Q – Infinitesimal generator matrix.

  • initial_dist – Initial probability distribution.

  • time_points – Array of time points to evaluate.

  • precision – Numerical precision for truncation (default: 1e-10).

Returns:

Transient probabilities via randomization.

Return type:

numpy.ndarray

ctmc_uniformization(Q, lambda_rate=None)[source]

Uniformize CTMC generator matrix.

Converts CTMC to an equivalent uniformized discrete-time chain for numerical analysis and simulation purposes.

Parameters:
  • Q – Infinitesimal generator matrix.

  • lambda_rate – Uniformization rate (optional, auto-computed if None).

Returns:

Contains uniformized transition matrix ‘P’ and rate ‘lambda’.

Return type:

dict

ctmc_stochcomp(Q, keep_states, eliminate_states)[source]

Compute stochastic complement of CTMC.

Parameters:
  • Q – Infinitesimal generator matrix.

  • keep_states – States to retain in reduced model.

  • eliminate_states – States to eliminate from model.

Returns:

Reduced generator matrix.

Return type:

numpy.ndarray

ctmc_timereverse(Q, pi=None)[source]

Compute time-reversed CTMC generator.

Parameters:
  • Q – Original infinitesimal generator matrix.

  • pi – Steady-state distribution (optional, computed if None).

Returns:

Time-reversed generator matrix.

Return type:

numpy.ndarray

ctmc_rand(n, density=0.3, max_rate=10.0)[source]

Generate random CTMC generator matrix.

Parameters:
  • n – Number of states.

  • density – Sparsity density (default: 0.3).

  • max_rate – Maximum transition rate (default: 10.0).

Returns:

Random infinitesimal generator matrix.

Return type:

numpy.ndarray

dtmc_solve(P)[source]

Solve for steady-state probabilities of DTMC.

Parameters:

P – Transition probability matrix.

Returns:

Steady-state probability distribution.

Return type:

numpy.ndarray

dtmc_makestochastic(A)[source]

Convert matrix to stochastic transition matrix.

Parameters:

A – Input matrix to normalize.

Returns:

Row-stochastic matrix.

Return type:

numpy.ndarray

dtmc_isfeasible(P, tolerance=1e-10)[source]

Check if matrix is a valid DTMC transition matrix.

Parameters:
  • P – Candidate transition matrix.

  • tolerance – Numerical tolerance (default: 1e-10).

Returns:

True if matrix is valid DTMC.

Return type:

bool

dtmc_simulate(P, initial_state, num_steps)[source]

Simulate DTMC sample path.

Parameters:
  • P – Transition probability matrix.

  • initial_state – Starting state index.

  • num_steps – Number of simulation steps.

Returns:

Sequence of visited states.

Return type:

numpy.ndarray

dtmc_rand(n, density=0.5)[source]

Generate random DTMC transition matrix.

Parameters:
  • n – Number of states.

  • density – Sparsity density (default: 0.5).

Returns:

Random transition probability matrix.

Return type:

numpy.ndarray

dtmc_stochcomp(P, keep_states, eliminate_states)[source]

Compute stochastic complement of DTMC.

Parameters:
  • P – Transition probability matrix.

  • keep_states – States to retain in reduced model.

  • eliminate_states – States to eliminate from model.

Returns:

Reduced transition matrix.

Return type:

numpy.ndarray

dtmc_timereverse(P, pi=None)[source]

Compute time-reversed DTMC transition matrix.

Parameters:
  • P – Original transition matrix.

  • pi – Steady-state distribution (optional, computed if None).

Returns:

Time-reversed transition matrix.

Return type:

numpy.ndarray

ctmc_courtois(Q, epsilon=1e-6)[source]

Courtois decomposition for nearly completely decomposable CTMCs.

Parameters:
  • Q – Infinitesimal generator matrix

  • epsilon – Decomposition threshold (default: 1e-6)

Returns:

Decomposition results with aggregated chain and coupling matrices

Return type:

dict

ctmc_kms(Q, blocks)[source]

Koury-McAllister-Stewart aggregation-disaggregation method for CTMCs.

Parameters:
  • Q – Infinitesimal generator matrix

  • blocks – Block structure specification

Returns:

Steady-state probability vector

Return type:

numpy.ndarray

ctmc_multi(Q, levels)[source]

Multi-level aggregation method for CTMCs.

Parameters:
  • Q – Infinitesimal generator matrix

  • levels – Number of aggregation levels

Returns:

Multi-level aggregation results

Return type:

dict

ctmc_pseudostochcomp(Q, partition)[source]

Pseudo-stochastic complementation for CTMCs.

Parameters:
  • Q – Infinitesimal generator matrix

  • partition – State partition specification

Returns:

Reduced generator matrix

Return type:

numpy.ndarray

ctmc_relsolve(Q, ref_states)[source]

Equilibrium distribution of a continuous-time Markov chain re-normalized with respect to reference states.

Parameters:
  • Q – Infinitesimal generator matrix

  • ref_states – Reference state indices

Returns:

Re-normalized steady-state probabilities

Return type:

numpy.ndarray

ctmc_solve_reducible(Q)[source]

Solve reducible CTMCs by converting to DTMC via randomization.

Parameters:

Q – Infinitesimal generator matrix (possibly reducible)

Returns:

Steady-state probability vector

Return type:

numpy.ndarray

ctmc_stmonotone(Q)[source]

Computes the stochastically monotone upper bound for a CTMC.

Parameters:

Q – Infinitesimal generator matrix

Returns:

Stochastically monotone upper bound generator

Return type:

numpy.ndarray

ctmc_takahashi(Q, epsilon=1e-8)[source]

Takahashi’s aggregation-disaggregation method for CTMCs.

Parameters:
  • Q – Infinitesimal generator matrix

  • epsilon – Convergence threshold (default: 1e-8)

Returns:

Steady-state probability vector

Return type:

numpy.ndarray

ctmc_testpf_kolmogorov(Q)[source]

Test if a CTMC has product form using Kolmogorov’s criteria.

Parameters:

Q – Infinitesimal generator matrix

Returns:

True if the CTMC has product form

Return type:

bool

dtmc_solve_reducible(P)[source]

Solve reducible DTMCs.

Parameters:

P – Transition probability matrix (possibly reducible)

Returns:

Steady-state probability vector

Return type:

numpy.ndarray

dtmc_uniformization(P, steps)[source]

DTMC uniformization analysis.

Parameters:
  • P – Transition probability matrix

  • steps – Number of uniformization steps

Returns:

Uniformization results with probability vector and iterations

Return type:

dict

Queueing Systems (line_solver.api.qsys)

Single queueing system analysis functions.

This module provides analytical formulas and approximations for single queueing systems, including classical models like M/M/1, M/M/k, M/G/1, and various G/G/1 approximations.

Supported queueing systems: - qsys_mm1: M/M/1 queue (Poisson arrivals, exponential service) - qsys_mmk: M/M/k queue (Poisson arrivals, k exponential servers) - qsys_gm1: G/M/1 queue (general arrivals, exponential service) - qsys_mg1: M/G/1 queue (Poisson arrivals, general service) - Various G/G/1 approximations (Whitt, Allen-Cunneen, Kingman, etc.)

These functions compute exact results where available, or high-quality approximations for more general cases.

qsys_mm1(lambda_val, mu)[source]

Analyze M/M/1 queue (Poisson arrivals, exponential service).

Parameters:
  • lambda_val (float) – Arrival rate.

  • mu (float) – Service rate.

Returns:

Performance measures including:
  • L: Mean number in system

  • Lq: Mean number in queue

  • W: Mean response time

  • Wq: Mean waiting time

  • rho: Utilization (λ/μ)

Return type:

dict

qsys_mmk(lambda_val, mu, k)[source]

Analyze M/M/k queue (Poisson arrivals, k exponential servers).

Parameters:
  • lambda_val (float) – Arrival rate.

  • mu (float) – Service rate per server.

  • k (int) – Number of parallel servers.

Returns:

Performance measures including L, Lq, W, Wq, rho, P0.

Return type:

dict

qsys_gm1(lambda_val, mu, sigma_s_squared)[source]

Analyze G/M/1 queue (general arrivals, exponential service).

Parameters:
  • lambda_val (float) – Arrival rate.

  • mu (float) – Service rate.

  • sigma_s_squared (float) – Variance of service times.

Returns:

Performance measures including L, Lq, W, Wq, rho.

Return type:

dict

qsys_mg1(lambda_val, mu, sigma_s_squared)[source]

Analyze M/G/1 queue (Poisson arrivals, general service).

Parameters:
  • lambda_val (float) – Arrival rate.

  • mu (float) – Mean service rate.

  • sigma_s_squared (float) – Variance of service times.

Returns:

Performance measures including L, Lq, W, Wq, rho.

Return type:

dict

qsys_gig1_approx_lin(lambda_val, mu, ca_squared, cs_squared)[source]

G/G/1 queue approximation using linear interpolation.

Parameters:
  • lambda_val (float) – Arrival rate.

  • mu (float) – Service rate.

  • ca_squared (float) – Squared coefficient of variation of arrivals.

  • cs_squared (float) – Squared coefficient of variation of service.

Returns:

Approximate performance measures.

Return type:

dict

qsys_gig1_approx_kk(lambda_val, mu, ca_squared, cs_squared)[source]

G/G/1 queue approximation using Kraemer-Langenbach-Belz method.

Parameters:
  • lambda_val (float) – Arrival rate.

  • mu (float) – Service rate.

  • ca_squared (float) – Squared coefficient of variation of arrivals.

  • cs_squared (float) – Squared coefficient of variation of service.

Returns:

Approximate performance measures.

Return type:

dict

qsys_gig1_approx_whitt(lambda_val, mu, ca_squared, cs_squared)[source]

G/G/1 queue approximation using Whitt’s method.

Parameters:
  • lambda_val (float) – Arrival rate.

  • mu (float) – Service rate.

  • ca_squared (float) – Squared coefficient of variation of arrivals.

  • cs_squared (float) – Squared coefficient of variation of service.

Returns:

Approximate performance measures.

Return type:

dict

qsys_gig1_approx_allencunneen(lambda_val, mu, ca_squared, cs_squared)[source]

G/G/1 queue approximation using Allen-Cunneen method.

Parameters:
  • lambda_val – Arrival rate

  • mu – Service rate

  • ca_squared – Squared coefficient of variation of arrivals

  • cs_squared – Squared coefficient of variation of service

Returns:

Performance measures (W, rho)

Return type:

dict

qsys_gig1_approx_heyman(lambda_val, mu, ca_squared, cs_squared)[source]

G/G/1 queue approximation using Heyman method.

Parameters:
  • lambda_val – Arrival rate

  • mu – Service rate

  • ca_squared – Squared coefficient of variation of arrivals

  • cs_squared – Squared coefficient of variation of service

Returns:

Performance measures (W, rho)

Return type:

dict

qsys_gig1_approx_kobayashi(lambda_val, mu, ca_squared, cs_squared)[source]

G/G/1 queue approximation using Kobayashi method.

Parameters:
  • lambda_val – Arrival rate

  • mu – Service rate

  • ca_squared – Squared coefficient of variation of arrivals

  • cs_squared – Squared coefficient of variation of service

Returns:

Performance measures (W, rho)

Return type:

dict

qsys_gig1_approx_marchal(lambda_val, mu, ca_squared, cs_squared)[source]

G/G/1 queue approximation using Marchal method.

Parameters:
  • lambda_val – Arrival rate

  • mu – Service rate

  • ca_squared – Squared coefficient of variation of arrivals

  • cs_squared – Squared coefficient of variation of service

Returns:

Performance measures (W, rho)

Return type:

dict

qsys_gig1_ubnd_kingman(lambda_val, mu, ca_squared, cs_squared)[source]

G/G/1 queue upper bound using Kingman method.

Parameters:
  • lambda_val – Arrival rate

  • mu – Service rate

  • ca_squared – Squared coefficient of variation of arrivals

  • cs_squared – Squared coefficient of variation of service

Returns:

Upper bound performance measures (W, rho)

Return type:

dict

qsys_gigk_approx(lambda_val, mu, ca_squared, cs_squared, k)[source]

G/G/k queue approximation for k servers.

Parameters:
  • lambda_val – Arrival rate

  • mu – Service rate per server

  • ca_squared – Squared coefficient of variation of arrivals

  • cs_squared – Squared coefficient of variation of service

  • k – Number of servers

Returns:

Performance measures (W, rho)

Return type:

dict

qsys_gigk_approx_kingman(lambda_val, mu, ca_squared, cs_squared, k)[source]

G/G/k queue approximation using Kingman method.

Parameters:
  • lambda_val – Arrival rate

  • mu – Service rate per server

  • ca_squared – Squared coefficient of variation of arrivals

  • cs_squared – Squared coefficient of variation of service

  • k – Number of servers

Returns:

Performance measures (W, rho)

Return type:

dict

qsys_gg1(arrival_mean, arrival_scv, service_mean, service_scv)[source]

Analyze G/G/1 queueing system.

Parameters:
  • arrival_mean – Mean inter-arrival time

  • arrival_scv – Squared coefficient of variation of inter-arrival times

  • service_mean – Mean service time

  • service_scv – Squared coefficient of variation of service times

Returns:

Performance metrics including utilization, queue length, and waiting time

Return type:

dict

qsys_gig1_approx_gelenbe(arrival_mean, arrival_scv, service_mean, service_scv)[source]

G/G/1 approximation using Gelenbe’s method.

Parameters:
  • arrival_mean – Mean inter-arrival time

  • arrival_scv – Squared coefficient of variation of inter-arrival times

  • service_mean – Mean service time

  • service_scv – Squared coefficient of variation of service times

Returns:

Approximate performance metrics

Return type:

dict

qsys_gig1_approx_kimura(arrival_mean, arrival_scv, service_mean, service_scv)[source]

G/G/1 approximation using Kimura’s method.

Parameters:
  • arrival_mean – Mean inter-arrival time

  • arrival_scv – Squared coefficient of variation of inter-arrival times

  • service_mean – Mean service time

  • service_scv – Squared coefficient of variation of service times

Returns:

Approximate performance metrics

Return type:

dict

qsys_gig1_approx_klb(arrival_mean, arrival_scv, service_mean, service_scv)[source]

G/G/1 approximation using Kraemer-Langenbach-Belz formula.

Parameters:
  • arrival_mean – Mean inter-arrival time

  • arrival_scv – Squared coefficient of variation of inter-arrival times

  • service_mean – Mean service time

  • service_scv – Squared coefficient of variation of service times

Returns:

Approximate performance metrics

Return type:

dict

qsys_gig1_approx_myskja(arrival_mean, arrival_scv, service_mean, service_scv)[source]

G/G/1 approximation using Myskja’s method.

Parameters:
  • arrival_mean – Mean inter-arrival time

  • arrival_scv – Squared coefficient of variation of inter-arrival times

  • service_mean – Mean service time

  • service_scv – Squared coefficient of variation of service times

Returns:

Approximate performance metrics

Return type:

dict

qsys_gig1_approx_myskja2(arrival_mean, arrival_scv, service_mean, service_scv)[source]

G/G/1 approximation using Myskja’s refined method.

Parameters:
  • arrival_mean – Mean inter-arrival time

  • arrival_scv – Squared coefficient of variation of inter-arrival times

  • service_mean – Mean service time

  • service_scv – Squared coefficient of variation of service times

Returns:

Approximate performance metrics

Return type:

dict

qsys_gig1_lbnd(arrival_mean, arrival_scv, service_mean, service_scv)[source]

Lower bound for G/G/1 queue performance.

Parameters:
  • arrival_mean – Mean inter-arrival time

  • arrival_scv – Squared coefficient of variation of inter-arrival times

  • service_mean – Mean service time

  • service_scv – Squared coefficient of variation of service times

Returns:

Lower bounds on performance metrics

Return type:

dict

qsys_gigk_approx_cosmetatos(arrival_mean, arrival_scv, service_mean, service_scv, num_servers)[source]

G/G/k approximation using Cosmetatos method.

Parameters:
  • arrival_mean – Mean inter-arrival time

  • arrival_scv – Squared coefficient of variation of inter-arrival times

  • service_mean – Mean service time

  • service_scv – Squared coefficient of variation of service times

  • num_servers – Number of servers

Returns:

Approximate performance metrics

Return type:

dict

qsys_gigk_approx_whitt(arrival_mean, arrival_scv, service_mean, service_scv, num_servers)[source]

G/G/k approximation using Whitt’s method.

Parameters:
  • arrival_mean – Mean inter-arrival time

  • arrival_scv – Squared coefficient of variation of inter-arrival times

  • service_mean – Mean service time

  • service_scv – Squared coefficient of variation of service times

  • num_servers – Number of servers

Returns:

Approximate performance metrics

Return type:

dict

qsys_mg1k_loss(arrival_rate, service_mean, service_scv, buffer_size)[source]

M/G/1/k queue with finite buffer - compute loss probability.

Parameters:
  • arrival_rate – Arrival rate

  • service_mean – Mean service time

  • service_scv – Squared coefficient of variation of service times

  • buffer_size – Buffer capacity

Returns:

Performance metrics including loss probability

Return type:

dict

qsys_mmkk(arrival_rate, service_rate, num_servers, buffer_size)[source]

M/M/k/k Erlang loss system.

Parameters:
  • arrival_rate – Arrival rate

  • service_rate – Service rate per server

  • num_servers – Number of servers

  • buffer_size – System capacity (including servers)

Returns:

Performance metrics including blocking probability

Return type:

dict

qsys_mmm(arrival_rate, service_rate, num_servers)[source]

M/M/m infinite buffer multi-server queue.

Parameters:
  • arrival_rate – Arrival rate

  • service_rate – Service rate per server

  • num_servers – Number of servers

Returns:

Performance metrics

Return type:

dict

qsys_mminf(arrival_rate, service_rate)[source]

M/M/∞ infinite server queue.

Parameters:
  • arrival_rate – Arrival rate

  • service_rate – Service rate per server

Returns:

Performance metrics

Return type:

dict

qsys_mginf(arrival_rate, service_mean, service_scv)[source]

Analyzes M/G/∞ queue (infinite servers).

Computes performance metrics for a queue with Poisson arrivals, general service times, and infinite servers.

Parameters:
  • arrival_rate – Arrival rate.

  • service_mean – Mean service time.

  • service_scv – Squared coefficient of variation of service time.

Returns:

Performance metrics.

Return type:

dict

qsys_mm1k_loss(arrival_rate, service_rate, buffer_size)[source]

Analyzes M/M/1/K queue with finite buffer.

Computes performance metrics and loss probability for a single-server queue with Poisson arrivals, exponential service, and finite capacity.

Parameters:
  • arrival_rate – Arrival rate.

  • service_rate – Service rate.

  • buffer_size – Maximum system capacity (including server).

Returns:

Performance metrics including loss probability.

Return type:

dict

qsys_mg1k_loss_mgs(arrival_rate, service_mean, service_scv, buffer_size)[source]

Analyzes M/G/1/K queue using modified generating function method.

Computes loss probability and performance metrics for finite capacity queues with general service time distributions using the MGS (Modified Generating Function with Spectral) method.

Parameters:
  • arrival_rate – Arrival rate.

  • service_mean – Mean service time.

  • service_scv – Squared coefficient of variation of service time.

  • buffer_size – Maximum system capacity.

Returns:

Performance metrics including loss probability.

Return type:

dict

Stochastic Networks (line_solver.api.sn)

Stochastic network (SN) utility functions.

This module provides utility functions for analyzing stochastic networks, including parameter extraction, model introspection, result processing, and various transformations.

Key function categories: - Model introspection: sn_has_* functions to check model properties - Parameter extraction: sn_get_* functions for demands, visits, etc. - Result processing: sn_deaggregate_chain_results - Model classification: sn_is_* functions (closed, open, mixed models) - Utility functions: state validation, routing matrix operations

These functions support the internal workings of LINE solvers by providing common operations on stochastic network models and results.

sn_deaggregate_chain_results(sn, Lchain, ST, STchain, Vchain, alpha, Qchain, Uchain, Rchain, Tchain, Cchain, Xchain)[source]

Deaggregate chain-level results back to individual node and class results.

Takes aggregated performance metrics at the chain level and disaggregates them to provide detailed node-level and class-level performance metrics.

Parameters:
  • sn – The stochastic network model

  • Lchain – Chain service demands

  • ST – Station service times

  • STchain – Chain station service times

  • Vchain – Chain visit ratios

  • alpha – Chain weights/proportions

  • Qchain – Chain queue lengths

  • Uchain – Chain utilizations

  • Rchain – Chain response times

  • Tchain – Chain throughputs

  • Cchain – Chain capacities

  • Xchain – Chain rates

Returns:

Dictionary containing disaggregated results with keys:
  • ’QN’: Node queue lengths

  • ’UN’: Node utilizations

  • ’RN’: Node response times

  • ’TN’: Node throughputs

  • ’CN’: Node capacities

  • ’XN’: Node rates

  • ’lG’: Log normalizing constant

Return type:

dict

sn_get_arvr_from_tput(sn, TN=None, TH=None)[source]

Calculate arrival rates from throughput values.

Computes arrival rates based on given throughput measurements, considering the network topology and routing probabilities.

Parameters:
  • sn – The stochastic network model

  • TN – Node throughputs (optional)

  • TH – System throughput (optional)

Returns:

Arrival rates for each node and class

Return type:

numpy.ndarray

sn_get_demands_chain(sn)[source]

Extract chain-level service demands and parameters.

Aggregates individual class service demands into chain-level parameters for analysis in the chain-decomposed representation of the model.

Parameters:

sn – The stochastic network model

Returns:

Dictionary containing chain parameters:
  • ’Lchain’: Chain service demands

  • ’Nchain’: Chain populations

  • ’Zchain’: Chain think times

  • ’refstat’: Reference station indices

  • ’alpha’: Chain mixing probabilities

  • ’sn’: Updated network model

Return type:

dict

sn_get_node_arvr_from_tput(sn, TN, TH=None, AN=None)[source]

Calculate node arrival rates from node throughput values.

Computes arrival rates at specific nodes based on measured throughput, accounting for network routing and feedback loops.

Parameters:
  • sn – The stochastic network model

  • TN – Node throughputs

  • TH – System throughput (optional)

  • AN – Node arrivals (optional)

Returns:

Node arrival rates

Return type:

numpy.ndarray

sn_get_node_tput_from_tput(sn, TN, TH=None, ANn=None)[source]

Calculate node throughput from system or other node throughputs.

Derives individual node throughput values from overall system throughput or other node throughput measurements using visit ratios.

Parameters:
  • sn – The stochastic network model

  • TN – Node throughputs

  • TH – System throughput (optional)

  • ANn – Node-specific arrivals (optional)

Returns:

Calculated node throughputs

Return type:

numpy.ndarray

sn_get_product_form_chain_params(sn)[source]

Extract product-form chain parameters for MVA and related algorithms.

Retrieves the parameters needed for product-form analysis at the chain level, including service demands, populations, and server characteristics.

Parameters:

sn – The stochastic network model

Returns:

Chain-level product-form parameters:
  • ’L’: Chain service demands

  • ’N’: Chain populations

  • ’Z’: Chain think times

  • ’mu’: Chain service rates

  • ’phi’: Chain service time distributions

  • ’nservers’: Number of servers per station

  • ’schedid’: Scheduling discipline identifiers

  • ’refstat’: Reference station index

  • ’sn’: Updated network model

Return type:

dict

sn_get_product_form_params(sn)[source]

Extract product-form parameters for class-level analysis.

Retrieves parameters needed for product-form queueing network analysis algorithms like MVA, AMVA, and Convolution algorithms.

Parameters:

sn – The stochastic network model

Returns:

Product-form parameters:
  • ’L’: Service demands matrix

  • ’N’: Population vector

  • ’Z’: Think times

  • ’mu’: Service rates

  • ’phi’: Service time coefficients

  • ’nservers’: Number of servers per station

  • ’schedid’: Scheduling discipline identifiers

  • ’refstat’: Reference station index

  • ’sn’: Updated network model

Return type:

dict

sn_get_residt_from_respt(sn, RNclass, WH=None)[source]

Calculate residence times from response times.

Computes node residence times based on measured response times, useful for performance analysis and bottleneck identification.

Parameters:
  • sn – The stochastic network model

  • RNclass – Response times by class

  • WH – Waiting times (optional)

Returns:

Residence times matrix

Return type:

numpy.ndarray

sn_get_state_aggr(sn)[source]

Get state space aggregation information for the network.

Returns aggregated state information for each node, which is useful for state-dependent analysis and Markov chain representations.

Parameters:

sn – The stochastic network model

Returns:

State aggregation mapping for each node

Return type:

dict

sn_is_state_valid(sn)[source]

Check if the current network state is valid.

Validates that the current state configuration satisfies all network constraints and population requirements.

Parameters:

sn – The stochastic network model

Returns:

True if the state is valid, False otherwise

Return type:

bool

sn_refresh_visits(sn, chains=None, rt=None, rtnodes=None)[source]

Refresh visit ratios for the network model.

Updates visit ratio calculations based on routing probabilities, ensuring consistency with the current network configuration.

Parameters:
  • sn – The stochastic network model

  • chains – Chain specifications (optional)

  • rt – Routing table (optional)

  • rtnodes – Routing nodes (optional)

Returns:

The updated stochastic network model

sn_has_class_switching(sn)[source]

Check if the network has class switching.

Determines whether jobs can change class while moving through the network.

Parameters:

sn – The stochastic network model

Returns:

True if the network has class switching, False otherwise

Return type:

bool

sn_has_fork_join(sn)[source]

Check if the network contains fork-join nodes.

Identifies the presence of fork-join synchronization points in the network.

Parameters:

sn – The stochastic network model

Returns:

True if fork-join nodes are present, False otherwise

Return type:

bool

sn_has_load_dependence(sn)[source]

Check if the network has load-dependent service rates.

Determines whether any stations have service rates that depend on the number of customers at the station.

Parameters:

sn – The stochastic network model

Returns:

True if load-dependent service is present, False otherwise

Return type:

bool

sn_has_multi_server(sn)[source]

Check if the network contains multi-server stations.

Identifies stations with more than one server.

Parameters:

sn – The stochastic network model

Returns:

True if multi-server stations exist, False otherwise

Return type:

bool

sn_has_priorities(sn)[source]

Check if the network uses priority scheduling.

Determines whether any stations implement priority-based job scheduling.

Parameters:

sn – The stochastic network model

Returns:

True if priority scheduling is used, False otherwise

Return type:

bool

sn_has_product_form(sn)[source]

Check if the network has product-form solution.

Determines whether the network satisfies the conditions for a product-form equilibrium distribution, enabling exact analysis.

Parameters:

sn – The stochastic network model

Returns:

True if the network has product-form, False otherwise

Return type:

bool

sn_has_closed_classes(sn)[source]

Check if the network contains closed job classes.

Identifies the presence of closed classes where jobs circulate indefinitely without external arrivals or departures.

Parameters:

sn – The stochastic network model

Returns:

True if closed classes exist, False otherwise

Return type:

bool

sn_has_open_classes(sn)[source]

Check if the network contains open job classes.

Identifies the presence of open classes with external arrivals and departures.

Parameters:

sn – The stochastic network model

Returns:

True if open classes exist, False otherwise

Return type:

bool

sn_has_mixed_classes(sn)[source]

Check if the network has both open and closed classes.

Determines whether the network is a mixed model with both open and closed job classes.

Parameters:

sn – The stochastic network model

Returns:

True if both open and closed classes exist, False otherwise

Return type:

bool

sn_has_multi_chain(sn)[source]

Check if the network has multiple chains.

Determines whether the network has more than one routing chain.

Parameters:

sn – The stochastic network model

Returns:

True if multiple chains exist, False otherwise

Return type:

bool

sn_is_closed_model(sn)[source]

Check if the network is a closed queueing model.

Determines whether all job classes are closed (no external arrivals/departures).

Parameters:

sn – The stochastic network model

Returns:

True if the model is closed, False otherwise

Return type:

bool

sn_is_open_model(sn)[source]

Check if the network is an open queueing model.

Determines whether all job classes are open (with external arrivals/departures).

Parameters:

sn – The stochastic network model

Returns:

True if the model is open, False otherwise

Return type:

bool

sn_is_mixed_model(sn)[source]

Check if the network is a mixed queueing model.

Determines whether the model contains both open and closed job classes.

Parameters:

sn – The stochastic network model

Returns:

True if the model is mixed, False otherwise

Return type:

bool

sn_has_product_form_not_het_fcfs(sn)[source]

Check if network has product-form but not heterogeneous FCFS.

Determines whether the network has product-form properties but does not contain heterogeneous First-Come-First-Served stations.

Parameters:

sn – The stochastic network model

Returns:

True if product-form without heterogeneous FCFS, False otherwise

Return type:

bool

sn_print_routing_matrix(sn, onlyclass=None)[source]

Print the routing matrix for the network.

Displays the routing probability matrix showing how jobs move between stations.

Parameters:
  • sn – The stochastic network model

  • onlyclass – Restrict output to specific class (optional)

sn_has_fcfs(sn)[source]

Check if the network has First-Come-First-Served scheduling.

Determines whether any stations use FCFS scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if FCFS scheduling is present, False otherwise

Return type:

bool

sn_has_lcfs(sn)[source]

Check if the network has Last-Come-First-Served scheduling.

Determines whether any stations use LCFS scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if LCFS scheduling is present, False otherwise

Return type:

bool

sn_has_lcfspr(sn)[source]

Check if the network has LCFS with preemptive resume scheduling.

Determines whether any stations use LCFS-PR scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if LCFS-PR scheduling is present, False otherwise

Return type:

bool

sn_has_ps(sn)[source]

Check if the network has Processor Sharing scheduling.

Determines whether any stations use PS scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if PS scheduling is present, False otherwise

Return type:

bool

sn_has_dps(sn)[source]

Check if the network has Discriminatory Processor Sharing scheduling.

Determines whether any stations use DPS scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if DPS scheduling is present, False otherwise

Return type:

bool

sn_has_gps(sn)[source]

Check if the network has Generalized Processor Sharing scheduling.

Determines whether any stations use GPS scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if GPS scheduling is present, False otherwise

Return type:

bool

sn_has_inf(sn)[source]

Check if the network has infinite server stations.

Determines whether any stations have unlimited server capacity.

Parameters:

sn – The stochastic network model

Returns:

True if infinite server stations exist, False otherwise

Return type:

bool

sn_has_hol(sn)[source]

Check if the network has Head-of-Line priority scheduling.

Determines whether any stations use HOL priority discipline.

Parameters:

sn – The stochastic network model

Returns:

True if HOL priority is present, False otherwise

Return type:

bool

sn_has_sjf(sn)[source]

Check if the network has Shortest Job First scheduling.

Determines whether any stations use SJF scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if SJF scheduling is present, False otherwise

Return type:

bool

sn_has_ljf(sn)[source]

Check if the network has Longest Job First scheduling.

Determines whether any stations use LJF scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if LJF scheduling is present, False otherwise

Return type:

bool

sn_has_sept(sn)[source]

Check if the network has Shortest Expected Processing Time scheduling.

Determines whether any stations use SEPT scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if SEPT scheduling is present, False otherwise

Return type:

bool

sn_has_lept(sn)[source]

Check if the network has Longest Expected Processing Time scheduling.

Determines whether any stations use LEPT scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if LEPT scheduling is present, False otherwise

Return type:

bool

sn_has_siro(sn)[source]

Check if the network has Service In Random Order scheduling.

Determines whether any stations use SIRO scheduling discipline.

Parameters:

sn – The stochastic network model

Returns:

True if SIRO scheduling is present, False otherwise

Return type:

bool

sn_has_dps_prio(sn)[source]

Check if the network has DPS with priority scheduling.

Determines whether any stations use DPS with priority discipline.

Parameters:

sn – The stochastic network model

Returns:

True if DPS-PRIO scheduling is present, False otherwise

Return type:

bool

sn_has_gps_prio(sn)[source]

Check if the network has GPS with priority scheduling.

Determines whether any stations use GPS with priority discipline.

Parameters:

sn – The stochastic network model

Returns:

True if GPS-PRIO scheduling is present, False otherwise

Return type:

bool

sn_has_ps_prio(sn)[source]

Check if the network has PS with priority scheduling.

Determines whether any stations use PS with priority discipline.

Parameters:

sn – The stochastic network model

Returns:

True if PS-PRIO scheduling is present, False otherwise

Return type:

bool

sn_has_single_class(sn)[source]

Check if the network has only a single job class.

Determines whether the network contains exactly one job class.

Parameters:

sn – The stochastic network model

Returns:

True if single class, False otherwise

Return type:

bool

sn_has_single_chain(sn)[source]

Check if the network has only a single routing chain.

Determines whether the network contains exactly one routing chain.

Parameters:

sn – The stochastic network model

Returns:

True if single chain, False otherwise

Return type:

bool

sn_has_fractional_populations(sn)[source]

Check if the network has non-integer job populations.

Determines whether any job classes have fractional population values.

Parameters:

sn – The stochastic network model

Returns:

True if fractional populations exist, False otherwise

Return type:

bool

sn_has_multiple_closed_classes(sn)[source]

Check if the network has multiple closed job classes.

Determines whether the network contains more than one closed job class.

Parameters:

sn – The stochastic network model

Returns:

True if multiple closed classes exist, False otherwise

Return type:

bool

sn_has_multiclass_fcfs(sn)[source]

Check if the network has multi-class FCFS stations.

Determines whether any FCFS stations serve multiple job classes.

Parameters:

sn – The stochastic network model

Returns:

True if multi-class FCFS stations exist, False otherwise

Return type:

bool

sn_has_multiclass_heter_fcfs(sn)[source]

Check if the network has heterogeneous multi-class FCFS stations.

Determines whether any FCFS stations serve multiple classes with different service time distributions.

Parameters:

sn – The stochastic network model

Returns:

True if heterogeneous multi-class FCFS exists, False otherwise

Return type:

bool

sn_has_multiclass_heter_exp_fcfs(sn)[source]

Check if the network has heterogeneous exponential multi-class FCFS stations.

Determines whether any FCFS stations serve multiple classes with different exponential service time distributions.

Parameters:

sn – The stochastic network model

Returns:

True if heterogeneous exponential multi-class FCFS exists, False otherwise

Return type:

bool

sn_has_homogeneous_scheduling(sn, strategy)[source]

Check if the network has homogeneous scheduling for a given strategy.

Determines whether all stations use the same scheduling discipline.

Parameters:
  • sn – The stochastic network model

  • strategy – The scheduling strategy to check for

Returns:

True if all stations use the specified strategy, False otherwise

Return type:

bool

sn_has_multi_class(sn)[source]

Check if the network has multiple job classes.

Determines whether the network contains more than one job class.

Parameters:

sn – The stochastic network model

Returns:

True if multiple job classes exist, False otherwise

Return type:

bool

sn_chain_analysis(sn, options=None)[source]

Perform chain-level analysis of the stochastic network.

Analyzes the network at the routing chain level, providing insights into chain behavior and performance characteristics.

Parameters:
  • sn – The stochastic network model

  • options – Analysis options (optional)

Returns:

Chain analysis results containing:
  • ’chain_info’: Information about each chain

  • ’analysis_result’: Performance analysis results

Return type:

dict

sn_get_demands(sn, options=None)[source]

Extract service demands from the stochastic network.

Computes service demand matrix, service times, and visit ratios for all stations and job classes.

Parameters:
  • sn – The stochastic network model

  • options – Extraction options (optional)

Returns:

(D, ST, V) where:
  • D: Service demands matrix

  • ST: Service times matrix

  • V: Visit ratios matrix

Return type:

tuple

sn_get_visits_chain(sn, options=None)[source]

Get visit ratios at the chain level.

Computes visit ratios aggregated at the routing chain level rather than individual class level.

Parameters:
  • sn – The stochastic network model

  • options – Computation options (optional)

Returns:

Chain-level visit ratios

Return type:

numpy.ndarray

sn_check_balance(sn, options=None)[source]

Check traffic balance in the stochastic network.

Verifies that flow conservation equations are satisfied at all nodes, ensuring the routing probabilities are consistent.

Parameters:
  • sn – The stochastic network model

  • options – Check options (optional)

Returns:

Balance check results:
  • ’is_balanced’: Whether traffic is balanced

  • ’violations’: List of balance violations

  • ’details’: Detailed balance information

Return type:

dict

sn_check_consistency(sn, options=None)[source]

Check model consistency in the stochastic network.

Validates that the network model is internally consistent and all parameters are properly defined.

Parameters:
  • sn – The stochastic network model

  • options – Check options (optional)

Returns:

Consistency check results:
  • ’is_consistent’: Whether the model is consistent

  • ’errors’: List of consistency errors

  • ’warnings’: List of warnings

  • ’details’: Detailed consistency information

Return type:

dict

sn_check_feasibility(sn, options=None)[source]

Check model feasibility in the stochastic network.

Determines whether the network model represents a feasible queueing system that can be analyzed or simulated.

Parameters:
  • sn – The stochastic network model

  • options – Check options (optional)

Returns:

Feasibility check results:
  • ’is_feasible’: Whether the model is feasible

  • ’issues’: List of feasibility issues

  • ’recommendations’: Suggested fixes

Return type:

dict

sn_has_blocking(sn)[source]

Check if the network has blocking (finite capacity) stations.

Determines whether any stations have finite buffer capacity that can block arriving customers.

Parameters:

sn – The stochastic network model

Returns:

True if blocking stations exist, False otherwise

Return type:

bool

sn_has_caches(sn)[source]

Check if the network contains cache stations.

Determines whether any stations implement caching behavior.

Parameters:

sn – The stochastic network model

Returns:

True if cache stations exist, False otherwise

Return type:

bool

sn_has_delays(sn)[source]

Check if the network contains delay (infinite server) stations.

Determines whether any stations are delay stations with no queueing.

Parameters:

sn – The stochastic network model

Returns:

True if delay stations exist, False otherwise

Return type:

bool

sn_has_finite_capacity(sn)[source]

Check if the network has stations with finite capacity.

Determines whether any stations have capacity constraints.

Parameters:

sn – The stochastic network model

Returns:

True if finite capacity stations exist, False otherwise

Return type:

bool

sn_has_loadindep(sn)[source]

Check if the network has load-independent service rates.

Determines whether any stations have service rates that do not depend on the queue length.

Parameters:

sn – The stochastic network model

Returns:

True if load-independent stations exist, False otherwise

Return type:

bool

sn_has_state_dependent(sn)[source]

Check if the network has state-dependent service rates.

Determines whether any stations have service rates that depend on the system state.

Parameters:

sn – The stochastic network model

Returns:

True if state-dependent stations exist, False otherwise

Return type:

bool

sn_validate_model(sn, options=None)[source]

Perform comprehensive validation of the stochastic network model.

Runs all validation checks including consistency, feasibility, and balance checks to ensure the model is ready for analysis.

Parameters:
  • sn – The stochastic network model

  • options – Validation options (optional)

Returns:

Complete validation results:
  • ’is_valid’: Overall validity status

  • ’consistency’: Consistency check results

  • ’feasibility’: Feasibility check results

  • ’balance’: Traffic balance results

  • ’summary’: Validation summary

Return type:

dict

sn_has_polling(sn)[source]

Check if stochastic network has polling stations.

Parameters:

sn – NetworkStruct object

Returns:

True if network has polling stations

Return type:

bool

sn_has_rr(sn)[source]

Check if stochastic network has round-robin scheduling.

Parameters:

sn – NetworkStruct object

Returns:

True if network has RR stations

Return type:

bool

sn_has_slc(sn)[source]

Check if stochastic network has self-looping classes.

Parameters:

sn – NetworkStruct object

Returns:

True if network has self-looping classes

Return type:

bool

sn_has_snc(sn)[source]

Check if stochastic network has state-dependent node capacities.

Parameters:

sn – NetworkStruct object

Returns:

True if network has state-dependent node capacities

Return type:

bool

sn_has_srpt(sn)[source]

Check if stochastic network has shortest remaining processing time scheduling.

Parameters:

sn – NetworkStruct object

Returns:

True if network has SRPT stations

Return type:

bool

sn_has_state_dependence(sn)[source]

Check if stochastic network has state-dependent behavior.

Parameters:

sn – NetworkStruct object

Returns:

True if network has state-dependent behavior

Return type:

bool

sn_print(sn)[source]

Print stochastic network structure information.

Parameters:

sn – NetworkStruct object

Returns:

None

sn_summary(sn)[source]

Get summary information about stochastic network.

Parameters:

sn – NetworkStruct object

Returns:

Summary information

Return type:

dict

sn_validate(sn)[source]

Validate stochastic network structure.

Parameters:

sn – NetworkStruct object

Returns:

(is_valid, error_messages)

Return type:

tuple

sn_get_arv_r_from_tput(sn, tput)[source]

Computes arrival rates from throughput values.

Note: This is an alias for sn_get_arvr_from_tput with corrected name.

Parameters:
  • sn – Stochastic network object

  • tput – Throughput matrix

Returns:

Arrival rates

Return type:

numpy.ndarray

sn_get_node_arv_r_from_tput(sn, tput)[source]

Computes node arrival rates from throughput values.

Note: This is an alias for sn_get_node_arvr_from_tput with corrected name.

Parameters:
  • sn – Stochastic network object

  • tput – Throughput matrix

Returns:

Node arrival rates

Return type:

numpy.ndarray

sn_has_lcfs_pr(sn)[source]

Checks if network has LCFS-PR (Last Come First Served - Preemptive Resume) nodes.

Note: This is an alias for sn_has_lcfspr.

Parameters:

sn – Stochastic network object

Returns:

True if network has LCFS-PR nodes

Return type:

bool

sn_has_multi_class_fcfs(sn)[source]

Checks if network has multi-class FCFS nodes.

Parameters:

sn – Stochastic network object

Returns:

True if network has multi-class FCFS nodes

Return type:

bool

sn_has_multi_class_heter_exp_fcfs(sn)[source]

Checks if network has multi-class heterogeneous exponential FCFS nodes.

Parameters:

sn – Stochastic network object

Returns:

True if network has multi-class heterogeneous exponential FCFS nodes

Return type:

bool

sn_has_multi_class_heter_fcfs(sn)[source]

Checks if network has multi-class heterogeneous FCFS nodes.

Parameters:

sn – Stochastic network object

Returns:

True if network has multi-class heterogeneous FCFS nodes

Return type:

bool

sn_is_population_model(sn)[source]

Checks if the network is a population model.

Parameters:

sn – Stochastic network object

Returns:

True if the network is a population model

Return type:

bool

sn_rtnodes_to_rtorig(sn, rt_nodes)[source]

Converts response times at nodes to original response times.

Maps response times from individual nodes back to the original station/class structure of the network.

Parameters:
  • sn – Stochastic network object

  • rt_nodes – Response times at nodes

Returns:

Original response times

Return type:

numpy.ndarray

Non-Product-Form Networks (line_solver.api.npfqn)

Non-product-form queueing network (NPFQN) approximations.

This module provides approximation algorithms for queueing networks that do not satisfy product-form conditions, including traffic merging and splitting operations for non-exponential service times.

These approximations enable analysis of more general queueing networks beyond the product-form assumption.

npfqn_nonexp_approx(method, sn, ST, V, SCV, Tin, Uin, gamma, nservers)[source]

Non-exponential approximation for non-product-form queueing networks.

Applies approximation methods to analyze queueing networks with non-exponential service time distributions.

Parameters:
  • method – Approximation method identifier.

  • sn – Service network structure.

  • ST – Service time matrix.

  • V – Visit count matrix.

  • SCV – Squared coefficient of variation matrix.

  • Tin – Input think times.

  • Uin – Input utilizations.

  • gamma – Load balancing parameters.

  • nservers – Number of servers per station.

Returns:

[ST_new, gamma_new, nservers_new, rho, scva, scvs, eta].

Return type:

list

npfqn_traffic_merge(lambda_rates, scv_rates)[source]

Merge traffic streams with different arrival rates and variabilities.

Combines multiple traffic streams into a single merged stream, computing the resulting arrival rate and variability.

Parameters:
  • lambda_rates – Array of arrival rates for each stream.

  • scv_rates – Array of squared coefficients of variation.

Returns:

(lambda_merged, scv_merged) - Merged traffic parameters.

Return type:

tuple

npfqn_traffic_merge_cs(lambda_rates, scv_rates, P)[source]

Merge traffic streams with class switching probabilities.

Combines multiple traffic streams considering class switching behavior and routing probabilities.

Parameters:
  • lambda_rates – Array of arrival rates for each stream.

  • scv_rates – Array of squared coefficients of variation.

  • P – Class switching probability matrix.

Returns:

(lambda_merged, scv_merged) - Merged traffic with class switching.

Return type:

tuple

npfqn_traffic_split_cs(lambda_rate, scv_rate, P)[source]

Split traffic stream with class switching probabilities.

Divides a single traffic stream into multiple streams based on class switching probabilities.

Parameters:
  • lambda_rate – Input arrival rate.

  • scv_rate – Input squared coefficient of variation.

  • P – Class switching probability matrix.

Returns:

(lambda_split, scv_split) - Split traffic streams.

Return type:

tuple

Polling Systems (line_solver.api.polling)

Polling system analysis functions.

This module provides analytical methods for polling systems where a single server visits multiple queues according to a polling protocol. Supports various polling disciplines including exhaustive, gated, and k-limited service.

These functions analyze systems with switchover times and different service disciplines at each queue.

polling_qsys_1limited(arv_maps, svc_maps, switch_maps)[source]

Analyze 1-limited polling system.

Models a polling system where the server serves at most one customer per visit to each queue before moving to the next queue.

Parameters:
  • arv_maps – List of arrival MAPs for each queue.

  • svc_maps – List of service MAPs for each queue.

  • switch_maps – List of switchover time MAPs between queues.

Returns:

Performance measures for the 1-limited polling system.

Return type:

dict

polling_qsys_exhaustive(arv_maps, svc_maps, switch_maps)[source]

Analyze exhaustive service polling system.

Parameters:
  • arv_maps – List of arrival MAPs for each queue.

  • svc_maps – List of service MAPs for each queue.

  • switch_maps – List of switchover time MAPs between queues.

Returns:

Performance measures for exhaustive polling system.

Return type:

numpy.ndarray

polling_qsys_gated(arv_maps, svc_maps, switch_maps)[source]

Analyze gated service polling system.

Parameters:
  • arv_maps – List of arrival MAPs for each queue.

  • svc_maps – List of service MAPs for each queue.

  • switch_maps – List of switchover time MAPs between queues.

Returns:

Performance measures for gated polling system.

Return type:

numpy.ndarray

Loss Networks (line_solver.api.lossn)

Loss network analysis functions.

This module provides functions for analyzing loss networks, where customers are blocked and lost when all servers are busy. The primary function implements the Erlang fixed-point algorithm for multi-service loss networks.

Loss networks are used to model circuit-switched networks, call centers with blocking, and other systems where customers are rejected when resources are unavailable.

lossn_erlangfp(nu_vec, amat, c_vec)[source]

Erlang fixed-point algorithm for multi-service loss networks.

Computes blocking probabilities and performance measures for loss networks where blocked customers are lost (not queued).

Parameters:
  • nu_vec – Vector of traffic intensities.

  • amat – Service requirement matrix.

  • c_vec – Vector of link capacities.

Returns:

(qlen, loss_prob, block_prob, niter) containing:
  • qlen: Mean queue lengths

  • loss_prob: Loss probabilities

  • block_prob: Blocking probabilities

  • niter: Number of iterations to convergence

Return type:

tuple

Layered Stochastic Networks (line_solver.api.lsn)

Layered stochastic network (LSN) analysis functions.

This module provides utility functions for analyzing layered stochastic networks, which model systems with hierarchical service dependencies and multiplicities.

Layered stochastic networks extend basic queueing networks to capture complex service dependencies and resource constraints in distributed systems and software architectures.

lsn_max_multiplicity(lsn)[source]

Compute maximum multiplicity constraints for layered stochastic network.

Determines the maximum allowable multiplicities for each layer in the stochastic network based on capacity and dependency constraints.

Parameters:

lsn – Layered stochastic network object.

Returns:

Maximum multiplicity values for each layer.

Return type:

numpy.ndarray

Trace Analysis (line_solver.api.trace)

Trace data analysis functions.

This module provides functions for analyzing empirical trace data, including statistical measures and transformations of time series and event traces.

These functions support trace-driven modeling and empirical analysis of system measurements and workload characterization.

trace_mean(trace)[source]

Calculate the mean of a trace.

Parameters:

trace – Array of trace values

Returns:

Mean value of the trace

Return type:

float

trace_var(trace)[source]

Calculate the variance of a trace.

Parameters:

trace – Array of trace values

Returns:

Variance of the trace

Return type:

float

mtrace_mean(trace, ntypes, type_array)[source]

Calculate mean of multi-type trace data.

Computes the mean for each type in a multi-type trace dataset.

Parameters:
  • trace – Array of trace values

  • ntypes – Number of different types in the trace

  • type_array – Array indicating the type of each trace element

Returns:

Mean values for each type

Return type:

numpy.ndarray

trace_scv(trace)[source]

Calculate the squared coefficient of variation of a trace.

Parameters:

trace – Array of trace values

Returns:

Squared coefficient of variation (variance/mean²)

Return type:

float

trace_acf(trace, lags=None)[source]

Calculate the autocorrelation function of a trace.

Parameters:
  • trace – Array of trace values

  • lags – List of lag values to compute autocorrelation for (default: [1])

Returns:

Autocorrelation values at specified lags

Return type:

numpy.ndarray

trace_gamma(trace, limit=1000)[source]

Fit gamma distribution parameters to trace data.

Parameters:
  • trace – Array of trace values

  • limit – Maximum number of iterations for fitting (default: 1000)

Returns:

(shape, scale, rate) parameters of fitted gamma distribution

Return type:

tuple

trace_iat2counts(trace, scale)[source]

Convert inter-arrival times to count data.

Parameters:
  • trace – Array of inter-arrival times

  • scale – Time scale for binning

Returns:

Count values in each time bin

Return type:

numpy.ndarray

trace_idi(trace, kset, option=None, n=1)[source]

Calculate index of dispersion for intervals.

Measures the variability of intervals in the trace data.

Parameters:
  • trace – Array of trace values

  • kset – Array of interval lengths to analyze

  • option – Analysis option (optional)

  • n – Parameter for analysis method (default: 1)

Returns:

(idi_values, support_values) - IDI values and their support

Return type:

tuple

trace_idc(trace)[source]

Calculate index of dispersion for counts.

Parameters:

trace – Array of trace values

Returns:

Index of dispersion for counts

Return type:

float

trace_pmf(data)[source]

Calculate probability mass function of discrete data.

Parameters:

data – Array of discrete data values

Returns:

(pmf_values, unique_values) - PMF and corresponding unique values

Return type:

tuple

trace_shuffle(trace)[source]

Randomly shuffle trace data.

Parameters:

trace – Array of trace values

Returns:

Shuffled trace data

Return type:

numpy.ndarray

trace_bicov(trace, grid)[source]

Calculate bicovariance of trace data.

Parameters:
  • trace – Array of trace values

  • grid – Grid of lag values for bicovariance calculation

Returns:

(bicov_values, lag_combinations) - Bicovariance values and lag pairs

Return type:

tuple

trace_iat2bins(trace, scale)[source]

Convert inter-arrival times to histogram bins.

Parameters:
  • trace – Array of inter-arrival times

  • scale – Time scale for binning

Returns:

(counts, bin_membership) - Bin counts and membership array

Return type:

tuple

trace_joint(trace, lag, order)[source]

Calculate joint statistics of trace data.

Parameters:
  • trace – Array of trace values

  • lag – Array of lag values

  • order – Array of moment orders

Returns:

Joint statistic value

Return type:

float

trace_summary(trace)[source]

Calculate comprehensive summary statistics for trace data.

Parameters:

trace – Array of trace values

Returns:

Dictionary containing various statistics:
  • mean, scv, mad, skew, kurt: Basic statistics

  • q25, q50, q75, p95: Quantiles and percentiles

  • min, max, iqr: Range statistics

  • acf1-acf4: Autocorrelation at lags 1-4

  • idc_scv_ratio: IDC to SCV ratio

Return type:

dict

trace_cdf(trace, x_values=None)[source]

Calculate cumulative distribution function of trace data.

Parameters:
  • trace – Array of trace values

  • x_values – X values to evaluate CDF at (optional, defaults to unique sorted trace values)

Returns:

Dictionary with ‘x’ and ‘y’ arrays for CDF plot

Return type:

dict

trace_pdf(trace, x_values=None, bandwidth=None)[source]

Calculate probability density function using kernel density estimation.

Parameters:
  • trace – Array of trace values

  • x_values – X values to evaluate PDF at (optional)

  • bandwidth – KDE bandwidth (optional, uses default if None)

Returns:

Dictionary with ‘x’ and ‘y’ arrays for PDF plot

Return type:

dict

trace_hist(trace, bins=None)[source]

Calculate histogram of trace data.

Parameters:
  • trace – Array of trace values

  • bins – Number of bins or bin specification (optional, defaults to ‘auto’)

Returns:

Dictionary with ‘counts’, ‘bin_edges’, and ‘bin_centers’

Return type:

dict

trace_moment(trace, k)[source]

Calculate the k-th moment of trace data.

Parameters:
  • trace – Array of trace values

  • k – Moment order

Returns:

k-th moment value

Return type:

float

trace_skew(trace)[source]

Calculate skewness of trace data.

Parameters:

trace – Array of trace values

Returns:

Skewness value

Return type:

float

trace_kurt(trace)[source]

Calculate kurtosis of trace data.

Parameters:

trace – Array of trace values

Returns:

Excess kurtosis value (Fisher’s definition)

Return type:

float

trace_fit_gamma(trace)[source]

Fit gamma distribution to trace data using method of moments.

Parameters:

trace – Array of positive trace values

Returns:

Gamma distribution parameters:
  • ’shape’: Shape parameter (alpha)

  • ’scale’: Scale parameter (beta)

  • ’rate’: Rate parameter (1/beta)

  • ’mean’: Sample mean

  • ’var’: Sample variance

Return type:

dict

Raises:

ValueError – If no positive finite values or zero variance

mtrace_corr(trace, ntypes, type_array, lags=None)[source]

Calculate cross-correlation matrix for multi-type trace data.

Parameters:
  • trace – Array of trace values

  • ntypes – Number of different types

  • type_array – Array indicating the type of each trace element

  • lags – Array of lag values (default: [0,1,2,3,4])

Returns:

Dictionary with:
  • ’correlations’: 3D array (ntypes x ntypes x nlags)

  • ’lags’: Array of lag values used

Return type:

dict

Raises:

ValueError – If trace and type_array have different lengths

mtrace_cov(trace, ntypes, type_array, lags=None)[source]

Calculate cross-covariance matrix for multi-type trace data.

Parameters:
  • trace – Array of trace values

  • ntypes – Number of different types

  • type_array – Array indicating the type of each trace element

  • lags – Array of lag values (default: [0,1,2,3,4])

Returns:

Dictionary with:
  • ’covariances’: 3D array (ntypes x ntypes x nlags)

  • ’lags’: Array of lag values used

Return type:

dict

Raises:

ValueError – If trace and type_array have different lengths

mtrace_backward_moment(traces, order)[source]

Computes backward moments for multiple traces.

Parameters:
  • traces – List of trace data

  • order – Moment order

Returns:

Backward moments

Return type:

numpy.ndarray

mtrace_bootstrap(traces, n_bootstrap=100, statistic='mean')[source]

Performs bootstrap analysis on multiple traces.

Parameters:
  • traces – List of trace data

  • n_bootstrap – Number of bootstrap samples

  • statistic – Statistic to compute (‘mean’, ‘var’, etc.)

Returns:

Bootstrap results

Return type:

dict

mtrace_count(traces)[source]

Counts events in multiple traces.

Parameters:

traces – List of trace data

Returns:

Event counts per trace

Return type:

numpy.ndarray

mtrace_cross_moment(trace1, trace2, order1, order2)[source]

Computes cross moments between two traces.

Parameters:
  • trace1 – First trace data

  • trace2 – Second trace data

  • order1 – Moment order for trace1

  • order2 – Moment order for trace2

Returns:

Cross moment value

Return type:

float

mtrace_forward_moment(traces, order)[source]

Computes forward moments for multiple traces.

Parameters:
  • traces – List of trace data

  • order – Moment order

Returns:

Forward moments

Return type:

numpy.ndarray

mtrace_iat2counts(traces, interval_length)[source]

Converts inter-arrival times to counts for multiple traces.

Parameters:
  • traces – List of inter-arrival time traces

  • interval_length – Length of counting interval

Returns:

Count data for each trace

Return type:

dict

mtrace_joint(traces, bins=None)[source]

Computes joint distribution for multiple traces.

Parameters:
  • traces – List of trace data

  • bins – Number of bins for histogram (optional)

Returns:

Joint distribution information

Return type:

dict

mtrace_merge(traces)[source]

Merges multiple traces into a single trace.

Parameters:

traces – List of trace data to merge

Returns:

Merged trace

Return type:

numpy.ndarray

mtrace_moment(traces, order)[source]

Computes moments of specified order for multiple traces.

Parameters:
  • traces – List of trace data

  • order – Moment order

Returns:

Moments for each trace

Return type:

numpy.ndarray

mtrace_moment_simple(traces)[source]

Computes simple moments (mean, variance) for multiple traces.

Parameters:

traces – List of trace data

Returns:

Simple moments for each trace

Return type:

dict

mtrace_pc(traces)[source]

Computes principal components for multiple traces.

Parameters:

traces – List of trace data

Returns:

Principal component analysis results

Return type:

dict

mtrace_sigma(traces)[source]

Computes sigma parameter for multiple traces.

Parameters:

traces – List of trace data

Returns:

Sigma values for each trace

Return type:

numpy.ndarray

mtrace_sigma2(traces)[source]

Computes squared sigma parameter for multiple traces.

Parameters:

traces – List of trace data

Returns:

Squared sigma values for each trace

Return type:

numpy.ndarray

mtrace_split(trace, n_parts)[source]

Splits a trace into multiple parts.

Parameters:
  • trace – Trace data to split

  • n_parts – Number of parts to split into

Returns:

List of trace parts

Return type:

list

mtrace_summary(traces)[source]

Computes summary statistics for multiple traces.

Parameters:

traces – List of trace data

Returns:

Summary statistics

Return type:

dict

Reinforcement Learning (line_solver.api.rl)

Reinforcement learning environments for queueing networks.

This module provides reinforcement learning (RL) environments that integrate with LINE queueing network models, enabling RL agents to learn control policies for queueing systems.

Key classes: - RlEnv: Basic RL environment for queueing networks - RlEnvGeneral: General-purpose RL environment - RlTDAgent: Temporal difference learning agent - RlTDAgentGeneral: General TD agent

These environments support research into adaptive control of queueing systems using reinforcement learning techniques.

class RlEnv(model, idx_of_queue_in_nodes, idx_of_source_in_nodes, state_size, gamma)[source]

Bases: object

Initialize the RL environment.

__init__(model, idx_of_queue_in_nodes, idx_of_source_in_nodes, state_size, gamma)[source]

Initialize the RL environment.

property model

Get the network model.

property action_size

Get the number of possible actions.

is_in_state_space(nodes)[source]

Check if nodes configuration is in state space.

is_in_action_space(nodes)[source]

Check if nodes configuration is in action space.

sample()[source]

Sample state and action from environment.

update(new_state)[source]

Update environment with new state.

reset()[source]

Reset environment to initial state.

class RlEnvGeneral(model, idx_of_queue_in_nodes, idx_of_action_nodes, state_size, gamma)[source]

Bases: object

Initialize the general RL environment.

__init__(model, idx_of_queue_in_nodes, idx_of_action_nodes, state_size, gamma)[source]

Initialize the general RL environment.

property model

Get the network model.

property nqueues

Get the number of queues.

property action_space

Get the action space mapping.

is_in_state_space(state)[source]

Check if state is in state space.

is_in_action_space(state)[source]

Check if state is in action space.

sample()[source]

Sample from environment.

update(sample)[source]

Update environment with sample.

reset()[source]

Reset environment to initial state.

class RlTDAgent(lr=0.05, epsilon=1.0, eps_decay=0.99)[source]

Bases: object

Initialize the TD agent.

__init__(lr=0.05, epsilon=1.0, eps_decay=0.99)[source]

Initialize the TD agent.

reset(env)[source]

Reset agent with environment.

get_value_function()[source]

Get value function as numpy array.

get_q_function()[source]

Get Q-function as numpy array.

solve(env)[source]

Solve RL problem in environment.

static create_greedy_policy(state_q, epsilon, n_a)[source]

Create greedy policy from Q-values.

static get_state_from_loc(obj_size, loc)[source]

Get state vector from location indices.

class RlTDAgentGeneral(lr=0.1, epsilon=1.0, eps_decay=0.9999)[source]

Bases: object

Initialize the advanced TD agent.

__init__(lr=0.1, epsilon=1.0, eps_decay=0.9999)[source]

Initialize the advanced TD agent.

reset(env)[source]

Reset agent with environment.

get_value_function()[source]

Get value function as numpy array.

solve_for_fixed_policy(env, num_episodes=10000)[source]

Solve for fixed policy with given episodes.

solve(env, num_episodes=10000)[source]

Solve RL problem with given episodes.

solve_by_hashmap(env, num_episodes=10000)[source]

Solve using hashmap-based value iteration.

solve_by_linear(env, num_episodes=10000)[source]

Solve using linear function approximation.

solve_by_quad(env, num_episodes=10000)[source]

Solve using quadratic function approximation.

static create_greedy_policy(state_q, epsilon, n_a)[source]

Create greedy policy from Q-values.

Utilities Module (line_solver.utils)

Mock module that can handle any attribute access