// agent

外卖减碳调度智能体

by OxO · Sep 13, 2026 Public

Choose how to run this agent

Local runs on your GPU. For usable speed it needs a WebGPU-capable browser — Chrome or Edge on a machine with a graphics card, or an Apple Silicon Mac. Without a supported GPU, pick OpenAI or Anthropic above instead. Check your machine
Try it now

Requires an API key and an AgentOp account.

0 downloads
0 forks
0.0 rating

Description

输入城市区域,自动生成外卖油电混编车队的调度数据集,包含时间、区域、拥堵指数、电网强度、调度建议、预计碳排放、减碳量等列。程序会根据白天电网清洁、夜间电网高碳的规律,自动判断派电车还是派油车,并生成“减碳策略分析报告”,输出最优时段和三条具体策略建议。

What this agent can do

外卖减碳调度智能体 is built from the Data Analysis Agent Template template and loads matplotlib, numpy, pandas, scipy, jiter in the browser. Runs fully on your own device: llama.cpp compiled to WebAssembly, GPU-accelerated through WebGPU, with no API key and no server. After the one-time model download it works offline. Can run on OpenAI models with your own API key, encrypted in your browser. Can run on Anthropic Claude models with your own API key, encrypted in your browser.

Source Code

agent.py
import pandas as pd

def run_agent(city_name):
    # 自动识别地名(如果输入太复杂,就默认用徐汇区)
    if len(city_name) > 5 or "区" not in city_name:
        city_name = "徐汇区"

    hours = [f"{i:02d}:00-{i+1:02d}:00" for i in range(24)]
    data = []

    for i, h in enumerate(hours):
        if 7 <= i < 9:
            congestion = 1.8
        elif 17 <= i < 19:
            congestion = 2.0
        else:
            congestion = 1.2

        if 6 <= i < 17:
            grid = 0.45
        else:
            grid = 0.75

        if grid == 0.45 and congestion >= 1.8:
            advice = "派电车"
        elif grid == 0.75 and congestion >= 1.8:
            advice = "派油车"
        elif grid == 0.45 and congestion < 1.8:
            advice = "派电车"
        else:
            advice = "混合派"

        ev_carbon = 3 * 0.03 * grid
        fuel_carbon = 3 * 0.025 * 2.3
        reduce_carbon = fuel_carbon - ev_carbon if "电车" in advice else 0

        data.append([h, city_name, congestion, grid, advice, round(ev_carbon, 3), round(reduce_carbon, 3)])

    df = pd.DataFrame(data, columns=["时间", "区域", "拥堵指数", "电网强度", "调度建议", "预计碳排放(kg)", "减碳量(kg)"])

    good_hours = df[df["减碳量(kg)"] > 0]["时间"].tolist()
    total_reduce = df["减碳量(kg)"].sum()

    report = f"\n{'='*40}\n【{city_name}】外卖减碳调度策略分析报告\n{'='*40}\n"
    report += f"\n✅ 最适合派电动车的时段:\n"
    for t in good_hours:
        report += f"  - {t}\n"
    report += f"\n📊 全天单均减碳量:约 {df['减碳量(kg)'].mean():.3f} kg\n"
    report += f"\n【策略建议】\n"
    report += "1. 分时段调度策略:白天优先派电动车。\n"
    report += "2. 碳积分激励策略:对白天接单的电动车骑手给予奖励。\n"
    report += "3. 政企数据联动策略:电网与外卖平台数据互通。\n"

    return df, report

# 执行
df, report = run_agent("徐汇区")
print(df.to_string(index=False))
print(report)