Stochastic Network Utilities
Network analysis and transformation utilities.
The sn module contains utility functions for stochastic networks, including
routing probability calculations, visit ratios, and network transformations.
Key function categories:
Network properties:
sn_has_product_form(),sn_has_class_switching(),sn_has_fork_join()Scheduling queries:
sn_has_fcfs(),sn_has_ps(),sn_has_lcfs(),sn_has_priorities()Model type queries:
sn_is_open_model(),sn_is_closed_model(),sn_is_mixed_model()Performance metrics:
sn_get_demands_chain(),sn_get_arvr_from_tput(),sn_get_residt_from_respt()State management:
sn_get_state_aggr(),sn_is_state_valid(),sn_deaggregate_chain_results()Routing utilities:
sn_refresh_visits(),sn_rtnodes_to_rtorig(),sn_print_routing_matrix()
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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- sn_validate(sn)[source]
Validate stochastic network structure.
- Parameters:
sn – NetworkStruct object
- Returns:
(is_valid, error_messages)
- Return type:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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: