Analytical queueing networks, service-level capacity sizing and exact integer server planning
| 使用者 | 输入、处理与输出 | 可运行集成 |
|---|---|---|
| 服务架构与平台工程师 | 外部流量、路由与节点服务率 → 解 Jackson 流量方程、找瓶颈、分配固定工作进程预算 → 新配置与平均响应时间 | examples/service_capacity |
| 客服/通信容量规划人员 | 来电率、处理率、等待 SLA 或有限等候席位 → 分别计算无限队列人员数、阻塞/放弃约束、无等待中继容量 → 明确模型假设的配置 | examples/contact_center |
| 教学、运筹研究与交互系统设计者 | 终端人口、访问次数、服务需求、思考时间 → 单类闭合网络 MVA 和人口目标搜索 → 吞吐量曲线、最小人口与守恒检查 | examples/closed_population |
moon add usersD609/moonqueuelab@0.1.0import {
"usersD609/moonqueuelab" @queue,
}
pkgtype(kind: "executable")///|
fn main raise {
let q : @queue.Mmc = { arrival: 2.0, service: 3.0, servers: 1 }
let m = q.analyze()
assert_true((m.mean_response - 1.0).abs() < 1.0e-10)
println(m.to_json().stringify())
println(q.response_quantile(0.95))
}moon run . --target wasm-gcmoon run examples/service_capacity --target js
moon run examples/contact_center --target js
moon run examples/closed_population --target js///|
fn main raise {
let network : @queue.JacksonNetwork = {
nodes: [{ service: 6.0, servers: 2 }, { service: 5.0, servers: 2 }],
external: [5.0, 1.0],
routing: [[0.0, 0.6], [0.1, 0.0]],
}
let plan = network.allocate_servers([1, 1], [5, 5], 6)
let configured = network.with_servers(plan.servers)
println(configured.analyze().to_json().stringify())
let finite : @queue.FiniteQueue = {
arrival: 5.0, service: 2.0, servers: 3, capacity: 7, abandonment: 0.1,
}
println(finite.outcomes().to_json().stringify())
}moon build --target js
python -c 'import subprocess,json; subprocess.run(["node","_build/js/debug/build/cmd/moonqueuelab/moonqueuelab.js",json.dumps(dict(op="loss",offered=12,channels=18))],check=True)'| op | 必填字段(除 op 外) | 输出主字段 |
|---|---|---|
| loss | offered, channels | blocking |
| mmc | arrival, service, servers, time, probability, state | metrics, wait_survival, response_survival, wait_quantile, response_quantile, state_probability, state_tail |
| finite | arrival, service, servers, capacity, abandonment | metrics, outcomes |
| engset | sources, channels, per_source, service | metrics |
| mg1 | arrival, mean_service, second_moment | metrics |
| staffing | arrival, service, target, time, maximum_utilization, maximum_servers | staffing |
| birth_death | birth 数组, death 数组 | states, summary, residual |
| jackson | services 数组, servers 整数数组, external 数组, routing 二维数组, maximum_utilization | metrics, load_limit |
| closed | kinds 字符串数组(fcfs/delay), service_times, visits, think_time, population | curve(包含人口0) |
| allocate | nodes 对象数组(arrival,service,minimum,maximum), budget | allocation |
moon info
moon fmt
moon fmt --check
moon check --deny-warn --target wasm-gc
moon test --deny-warn --target wasm-gc
moon build --deny-warn --target wasm-gc
moon build --target js
python tools/verify_single.py
python tools/verify_network.py
python tools/audit_source.pypub suberror QueueError {
Invalid(String)
Numerical(String)
Limit(String)
Unstable(String)
Infeasible(String)
} derive(Debug)pub(all) struct ClosedNetwork {
centers : Array[ClosedCenter]
visits : Array[Double]
think_time : Double
} derive(ToJson, Debug)fn ClosedNetwork::analyze_population(self : ClosedNetwork, population : Int) -> ClosedPopulationMetrics raise QueueErrorfn ClosedNetwork::population_curve(self : ClosedNetwork, maximum_population : Int) -> Array[ClosedPopulationMetrics] raise QueueErrorfn ClosedNetwork::population_for_throughput(self : ClosedNetwork, target : Double, maximum_population : Int) -> ClosedPopulationMetrics raise QueueErrorpub(all) struct ClosedPopulationMetrics {
population : Int
throughput : Double
mean_network_response : Double
mean_cycle_time : Double
mean_think_population : Double
centers : Array[ClosedCenterMetrics]
conservation_residual : Double
} derive(ToJson, Debug)pub(all) struct FiniteStaffing {
servers : Int
capacity : Int
metrics : FiniteMetrics
outcomes : FiniteOutcomes
} derive(ToJson, Debug)pub(all) struct JacksonMetrics {
nodes : Array[JacksonNodeMetrics]
external_arrival : Double
total_mean_customers : Double
mean_external_response : Double
relative_flow_residual : Double
} derive(ToJson, Debug)fn JacksonNetwork::allocate_servers(self : JacksonNetwork, minimum : Array[Int], maximum : Array[Int], budget : Int) -> ServerAllocation raise QueueErrorfn JacksonNetwork::load_limit(self : JacksonNetwork, maximum_utilization : Double) -> NetworkLoadLimit raise QueueErrorfn JacksonNetwork::scaled_load(self : JacksonNetwork, factor : Double) -> JacksonNetwork raise QueueErrorfn JacksonNetwork::with_servers(self : JacksonNetwork, counts : Array[Int]) -> JacksonNetwork raise QueueErrorpub(all) struct QueueScenario {
arrival : Double
stable : Bool
metrics : QueueMetrics?
wait_tail : Double?
} derive(ToJson, Debug)fn allocate_server_budget(nodes : Array[ServerBudgetNode], budget : Int) -> ServerAllocation raise QueueErrorfn arrival_capacity(service : Double, server_count : Int, target_probability : Double, wait_threshold : Double, upper : Double, maximum_utilization? : Double) -> ArrivalCapacity raise QueueErrorfn balance_residual(law : Array[Double], birth : Array[Double], death : Array[Double]) -> Double raise QueueErrorfn finite_staffing(arrival : Double, service : Double, waiting_places : Int, abandonment : Double, maximum_blocking : Double, maximum_abandonment : Double, maximum_servers : Int) -> FiniteStaffing raise QueueErrorfn gigc_approximation(model : Mmc, arrival_scv : Double, service_scv : Double) -> ApproximateQueue raise QueueErrorfn loss_staffing(offered : Double, maximum_loss : Double, maximum_channels : Int) -> Int raise QueueErrorfn loss_traffic_limit(channels : Int, maximum_loss : Double, upper : Double) -> Double raise QueueErrorfn mg1(arrival : Double, mean_service : Double, second_moment : Double) -> QueueMetrics raise QueueErrorfn mmc_sweep(service : Double, server_count : Int, arrivals : Array[Double], wait_threshold : Double) -> Array[QueueScenario] raise QueueErrorfn process_json(text : String) -> Stringfn sla_staffing(arrival : Double, service : Double, target_probability : Double, wait_threshold : Double, maximum_utilization? : Double, maximum_servers? : Int) -> SlaStaffing raise QueueErrorfn stationary_birth_death(birth : Array[Double], death : Array[Double]) -> Array[Double] raise QueueErrorInstall
Download zipAnalytical queueing networks, service-level capacity sizing and exact integer server planning