← 返回 Skills 市场
wu-uk

locational-marginal-prices

作者 wu-uk · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ 安全检测通过
71
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install energy-market-pricing-locational-marginal-prices
功能描述
Extract locational marginal prices (LMPs) from DC-OPF solutions using dual values. Use when computing nodal electricity prices, reserve clearing prices, or p...
使用说明 (SKILL.md)

Locational Marginal Prices (LMPs)

LMPs are the marginal cost of serving one additional MW of load at each bus. In optimization terms, they are the dual values (shadow prices) of the nodal power balance constraints.

LMP Extraction from CVXPY

To extract LMPs, you must:

  1. Store references to the balance constraints
  2. Solve the problem
  3. Read the dual values after solving
import cvxpy as cp

# Store balance constraints separately for dual extraction
balance_constraints = []

for i in range(n_bus):
    pg_at_bus = sum(Pg[g] for g in range(n_gen) if gen_bus[g] == i)
    pd = buses[i, 2] / baseMVA

    # Create constraint and store reference
    balance_con = pg_at_bus - pd == B[i, :] @ theta
    balance_constraints.append(balance_con)
    constraints.append(balance_con)

# Solve
prob = cp.Problem(cp.Minimize(cost), constraints)
prob.solve(solver=cp.CLARABEL)

# Extract LMPs from duals
lmp_by_bus = []
for i in range(n_bus):
    bus_num = int(buses[i, 0])
    dual_val = balance_constraints[i].dual_value

    # Scale: constraint is in per-unit, multiply by baseMVA to get $/MWh
    lmp = float(dual_val) * baseMVA if dual_val is not None else 0.0
    lmp_by_bus.append({
        "bus": bus_num,
        "lmp_dollars_per_MWh": round(lmp, 2)
    })

LMP Sign Convention

For a balance constraint written as generation - load == net_export:

  • Positive LMP: Increasing load at that bus increases total cost (typical case)
  • Negative LMP: Increasing load at that bus decreases total cost

Negative LMPs commonly occur when:

  • Cheap generation is trapped behind a congested line (can't export power)
  • Adding load at that bus relieves congestion by consuming local excess generation
  • The magnitude can be very large in heavily congested networks (thousands of $/MWh)

Negative LMPs are physically valid and expected in congested systems — they are not errors.

Reserve Clearing Price

The reserve MCP is the dual of the system reserve requirement constraint:

# Store reference to reserve constraint
reserve_con = cp.sum(Rg) >= reserve_requirement
constraints.append(reserve_con)

# After solving:
reserve_mcp = float(reserve_con.dual_value) if reserve_con.dual_value is not None else 0.0

The reserve MCP represents the marginal cost of providing one additional MW of reserve capacity system-wide.

Finding Binding Lines

Lines at or near thermal limits (≥99% loading) cause congestion and LMP separation. See the dc-power-flow skill for line flow calculation details.

BINDING_THRESHOLD = 99.0  # Percent loading

binding_lines = []
for k, br in enumerate(branches):
    f = bus_num_to_idx[int(br[0])]
    t = bus_num_to_idx[int(br[1])]
    x, rate = br[3], br[5]

    if x != 0 and rate > 0:
        b = 1.0 / x
        flow_MW = b * (theta.value[f] - theta.value[t]) * baseMVA
        loading_pct = abs(flow_MW) / rate * 100

        if loading_pct >= BINDING_THRESHOLD:
            binding_lines.append({
                "from": int(br[0]),
                "to": int(br[1]),
                "flow_MW": round(float(flow_MW), 2),
                "limit_MW": round(float(rate), 2)
            })

Counterfactual Analysis

To analyze the impact of relaxing a transmission constraint:

  1. Solve base case — record costs, LMPs, and binding lines
  2. Modify constraint — e.g., increase a line's thermal limit
  3. Solve counterfactual — with the relaxed constraint
  4. Compute impact — compare costs and LMPs
# Modify line limit (e.g., increase by 20%)
for k in range(n_branch):
    br_from, br_to = int(branches[k, 0]), int(branches[k, 1])
    if (br_from == target_from and br_to == target_to) or \
       (br_from == target_to and br_to == target_from):
        branches[k, 5] *= 1.20  # 20% increase
        break

# After solving both cases:
cost_reduction = base_cost - cf_cost  # Should be >= 0

# LMP changes per bus
for bus_num in base_lmp_map:
    delta = cf_lmp_map[bus_num] - base_lmp_map[bus_num]
    # Negative delta = price decreased (congestion relieved)

# Congestion relieved if line was binding in base but not in counterfactual
congestion_relieved = was_binding_in_base and not is_binding_in_cf

Economic Intuition

  • Relaxing a binding constraint cannot increase cost (may decrease or stay same)
  • Cost reduction quantifies the shadow price of the constraint
  • LMP convergence after relieving congestion indicates reduced price separation
安全使用建议
This skill is a focused how-to for extracting LMPs from a CVXPY DC-OPF model and appears coherent. Before using it, ensure your runtime provides the expected data structures (buses, gens, branches, baseMVA, Pg, theta, etc.) and that CVXPY and a solver that exposes duals (or an alternative solver) are installed. Verify scaling (per-unit × baseMVA) and sign conventions for your model. Because it is instruction-only, it doesn't request credentials or install software itself — but running the provided code requires a Python environment with the correct solver and data; confirm those are trustworthy and present.
功能分析
Type: OpenClaw Skill Name: energy-market-pricing-locational-marginal-prices Version: 0.1.0 The skill bundle provides documentation and Python code snippets for calculating Locational Marginal Prices (LMPs) in power systems using the CVXPY optimization library. The content in SKILL.md is strictly focused on power system economics, including extracting dual values from constraints, identifying binding transmission lines, and performing counterfactual analysis. No indicators of data exfiltration, malicious execution, or prompt injection were found.
能力评估
Purpose & Capability
Name/description match the instructions: the SKILL.md describes how to capture balance constraints, solve a CVXPY problem, and read duals to produce LMPs. Nothing in the file requests unrelated services, binaries, or secrets.
Instruction Scope
Instructions are narrowly focused on extracting dual values and computing related diagnostics (binding lines, reserve MCP, counterfactuals). They assume pre-existing variables and data structures (n_bus, buses, Pg, gen_bus, B, theta, baseMVA, branches, Rg, reserve_requirement, etc.) and reference another skill ('dc-power-flow') for flow details. Also the code uses cp.CLARABEL as the solver; the user/agent must ensure an appropriate solver that exposes duals is available. These assumptions are normal for an instruction snippet but require the runtime to provide the expected context.
Install Mechanism
Instruction-only skill with no install spec and no code files. No downloads or package installs are declared by the skill itself.
Credentials
The skill requires no environment variables, credentials, or config paths. There are no requests for unrelated secrets or system access.
Persistence & Privilege
always is false and the skill is user-invocable; it does not request persistent system-wide privileges or attempt to modify other skills or agent settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install energy-market-pricing-locational-marginal-prices
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /energy-market-pricing-locational-marginal-prices 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Bulk publish from all-task-skills-dedup
元数据
Slug energy-market-pricing-locational-marginal-prices
版本 0.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

locational-marginal-prices 是什么?

Extract locational marginal prices (LMPs) from DC-OPF solutions using dual values. Use when computing nodal electricity prices, reserve clearing prices, or p... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 71 次。

如何安装 locational-marginal-prices?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install energy-market-pricing-locational-marginal-prices」即可一键安装,无需额外配置。

locational-marginal-prices 是免费的吗?

是的,locational-marginal-prices 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

locational-marginal-prices 支持哪些平台?

locational-marginal-prices 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 locational-marginal-prices?

由 wu-uk(@wu-uk)开发并维护,当前版本 v0.1.0。

💬 留言讨论