Skip to content
dsh.fish
Bundle

xby-mm1-simulation

一个用于M/M/1和M/M/c队列系统模拟和分析的Model Context Protocol服务器,提供全面的资源、工具和提示。

Source
xby-skill
License
MIT
Updated
Updated 2 days ago

Readme

# xby-mm1-simulation

DeepSeek Harness (DSH) 的插件:队列模拟服务

一个用于M/M/1和M/M/c队列系统模拟和分析的Model Context Protocol服务器,提供全面的资源、工具和提示。

## 功能

- **set_xby_apikey** — 在聊天中设置 API 密钥(自动持久化,重启有效)
- **validate_config** — Validate M/M/1 configuration parameters

Checks parameter validity and system stability condition.

Args:
    arrival_rate: Customer arrival rate (λ)
    service_rate: Service rate (μ)
    simulation_time: Simulation duration

Returns:
    Dictionary with validation result:
        - valid: bool
        - errors: List[str] (if any)
        - warnings: List[str] (if any)
        - utilization: float (if valid)
- **calculate_metrics** — Calculate theoretical M/M/1 performance metrics

Uses exact formulas to compute steady-state performance.

Args:
    arrival_rate: λ (customers per time unit)
    service_rate: μ (customers per time unit)

Returns:
    Dictionary of theoretical metrics:
        - utilization: ρ = λ/μ
        - avg_queue_length: L_q = ρ²/(1-ρ)
        - avg_num_in_system: L = ρ/(1-ρ)
        - avg_waiting_time: W_q
        - avg_system_time: W

Raises:
    ValueError: If system is unstable (λ >= μ)
- **run_simulation** — Run M/M/1 queue simulation using SimPy

Executes discrete event simulation and returns performance metrics.

Args:
    arrival_rate: λ (customers per time unit)
    service_rate: μ (customers per time unit)
    simulation_time: Duration of simulation
    random_seed: Random seed for reproducibility

Returns:
    Dictionary with:
        - simulation_metrics: Dict of simulated values
        - theoretical_metrics: Dict of exact values
        - comparison: Comparison analysis
        - config: Simulation configuration used
- **compare_results** — Compare simulation results with theoretical values

Analyzes accuracy of simulation by comparing against exact formulas.

Args:
    simulation_metrics: Dictionary of simulated performance metrics
    arrival_rate: λ used in simulation
    service_rate: μ used in simulation

Returns:
    Comparison analysis with:
        - comparisons: Per-metric comparison
        - mean_abs_error_pct: Average error
        - max_error_pct: Maximum error
        - within_10pct: bool
        - accuracy_grade: Quality assessment
- **recommend_parameters** — Recommend simulation parameters for target utilization

Suggests appropriate arrival rate, service rate, and simulation time
for a given target utilization level.

Args:
    target_utilization: Desired ρ (default: 0.7)
    service_rate: Fixed μ (if None, suggests μ=10)
    min_customers: Minimum customers to simulate

Returns:
    Recommended parameters and expected metrics

## 安装

### 方式一:从 GitHub 直接安装(推荐)

```bash
# 格式: dsh plugin --profile <profile> add github:<owner>/<repo>
dsh plugin --profile web add github:xby_skill/xby-mm1-simulation
```

### 方式二:从本地目录安装(开发模式)

```bash
# 仅用于本地开发调试
dsh plugin --profile web add /absolute/path/to/xby-mm1-simulation
```

### 方式三:通过 cordis.patch.yml 开发调试

```bash
dsh web --profile web --patch /absolute/path/to/dsh-ocr-plugin/cordis.patch.yml
```



## 配置

### 获取 API 密钥

前往 [小笨羊官网](https://xiaobenyang.com) 注册并获取 API 密钥。

Install

dsh plugin --profile web add github:xby-skill/xby-mm1-simulation

Profile: web

  • This package builds from source on install. pnpm will ask you to allow its build script — that is permission to run the package’s code on your machine, outside the agent sandbox. Only allow sources you trust.
  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source