← 返回
未分类

通用数学建模工作流

Solve math modeling competition problems (Huazhong Cup, CUMCM, etc.) with a systematic workflow — data exploration, model building, algorithm implementation, result analysis.
Solve math modeling competition problems (Huazhong Cup, CUMCM, etc.) with a systematic workflow — data exploration, model building, algorithm implementation, result analysis.
KumnXi
未分类 community v1.0.0 1 版本 99545.5 Key: 无需
★ 1
Stars
📥 199
下载
💾 5
安装
1
版本
#latest

概述

Math Modeling Problem Solver

Use this skill when the user asks to solve a mathematical modeling competition problem, especially multi-part problems like the Huazhong Cup or CUMCM.

Workflow

Phase 1: Understand the Problem

  1. Read all problem descriptions and data files — Identify each sub-problem, its constraints, objectives, and how it differs from other parts
  2. Load and inspect data files — Check Excel/CSV contents, understand column meanings, identify data types (coordinates, time windows, orders, distance matrices)
  3. Extract all model parameters — List every constant, coefficient, and constraint from the problem statement (speeds, penalty rates, emission factors, etc.)

Phase 2: Design the Solution Architecture

  1. Define the directory structure:

```

problem_A/code/ ← solver scripts

problem_A/data/ ← input data (xlsx, csv)

problem_A/figures/ ← visualizations

problem_B/... ← same pattern for each sub-problem

```

  1. Choose the modeling approach — e.g., Mixed Integer Programming, heuristic algorithms, dynamic programming
  2. Design the solver pipeline:
    • Data loading and preprocessing (load Excel → normalize → index)
    • Initial solution construction (greedy, insertion heuristics)
    • Solution improvement (local search: 2-opt, swap, relocate)
    • Constraint checking (capacity, time windows, special restrictions)
    • Cost calculation (multi-component: startup + fuel + carbon + penalty)
  3. Plan output format — JSON for structured results + TXT for human-readable reports

Phase 3: Implement the Solver

  1. Use Python with pandas, numpy — Load Excel data, build distance matrices
  2. Build cost functions carefully:
    • Time-varying speeds → time-dependent travel times
    • U-shaped energy curves → speed-dependent fuel/kWh consumption
    • Load-dependent adjustments → linear interpolation between empty and full
    • Soft time windows → early/late penalty with different rates
    • Carbon pricing → fuel-to-CO₂ conversion × carbon price
  3. Implement greedy construction — Sort customers by priority (time window start), insert at minimum marginal cost position
  4. Implement 2-opt local search — Iterate until no improvement; check all possible 2-opt swaps
  5. Add fleet management — Track vehicle counts by type, enforce fleet limits
  6. For multi-problem progression — Reuse previous problem's solver as baseline, add new constraints incrementally

Phase 4: Validate and Debug

  1. Run and check for constraint violations — Verify capacity, time windows, special restrictions are all satisfied
  2. If violations found — Write targeted fix functions, not universal hacks:
    • Identify violating routes precisely
    • Understand root cause (timing calculation, boundary condition, etc.)
    • Fix the specific issue in cost/check functions
    • Re-run and verify all violations resolved
  3. Compare to baselines — Check if results are reasonable relative to simpler models

Phase 5: Analyze Results

  1. Generate structured output — Save full results as JSON (routes, costs, details per route)
  2. Print human-readable summary — Route-by-route breakdown with per-route costs
  3. Compute aggregate statistics — Total cost, distance, CO₂, vehicle counts by type, load rates
  4. Cross-problem comparison — Compare metrics across sub-problems to identify trends

Key Patterns

Data structure pattern

info = {
    'nodes': dict,      # node_id → {kg, m3, cid, tw_start, tw_end, priority}
    'ntw': dict,        # node_id → (tw_start, tw_end)
    'nd': 2D array,     # distance matrix (n+1 × n+1)
    'coords': dict,     # node_id → (x, y)
    'gz': set,          # green zone customer IDs
    'c2n': dict,        # customer_id → [node_ids]
    'agg': dict,        # customer_id → {total_kg, total_m3}
    'nn': list,         # node IDs sorted by distance from depot
}

Cost function pattern

def route_cost(route, vehicle_type, info):
    total = vehicle_type['startup_cost']
    t = 480.0  # start time in minutes from midnight
    has_violation = False
    for each segment (i→j) in route:
        speed = get_speed(t)  # time-dependent
        travel_time = distance / speed * 60
        arrival = t + travel_time
        energy = fpk(speed) * distance / 100 * load_factor
        carbon = energy * emission_factor
        carbon_cost = carbon * carbon_price
        tw_penalty = compute_penalty(arrival, time_window)
        total += energy_cost + carbon_cost + tw_penalty
    return total, has_violation

Greedy insertion pattern

for each customer (sorted by time window start):
    best_cost_increase = INF
    best_vehicle = None
    best_position = None
    for each vehicle:
        for each insertion position in vehicle.route:
            cost_delta = marginal_cost_of_insertion(customer, position)
            if cost_delta < best_cost_increase and constraints_satisfied:
                best = (vehicle, position, cost_delta)
    if best found:
        insert customer into best vehicle at best position
    else:
        create new vehicle for this customer

Violation fix pattern

def find_violations(routes, info):
    violations = []
    for each route:
        simulate arrival times (exactly matching route_cost logic)
        if any constraint violated:
            violations.append(detailed_violation_info)
    return violations

def fix_violations(routes, violations, info):
    for v in violations:
        try: reassign to EV, adjust timing, or re-optimize
        if unfixable: flag for manual review

Sub-problem progression for multi-part problems

When each sub-problem builds on the previous:

  • Problem N → solve independently
  • Problem N+1 → start from Problem N baseline, add new constraints, run and compare
  • Problem N+2 → start from Problem N+1 baseline, add dynamic event handling, compare to static

Save each problem's results separately, then generate cross-problem comparison analysis.

Deliverables

For each problem, produce:

  1. problemX_solver.py — Self-contained solver script
  2. problemX_result.json — Machine-readable results
  3. problemX_result.txt — Human-readable summary
  4. figures/*.png — Visualizations (route maps, cost breakdowns)

Cross-problem:

  1. Comprehensive comparison report (DOCX + TXT)
  2. Paper template (DOCX)
  3. All summary figures

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-04-25 17:17 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 672 📥 324,946
ai-intelligence

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,071 📥 804,805
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,223 📥 267,323