locational-marginal-prices
Extract locational marginal prices (LMPs) from DC-OPF solutions using dual values
Install / Use
npx skills add benchflow-ai/skillsbench --skill locational-marginal-pricesInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Tags
Our assessment of locational-marginal-prices
locational-marginal-prices scores 86/100 on our quality scale, 1569th of 3,997 Development & Engineering skills we index (top 40%).
Its SKILL.md is 4.6 KB long, well organised into 16 sections with 4 code examples: a solid amount of guidance for an agent.
With 1,813 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated about 2 months ago, so locational-marginal-prices is actively maintained.
- It is released under the Apache-2.0 license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
locational-marginal-prices compared with similar skills
All 4 of these similar skills score higher than locational-marginal-prices; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| locational-marginal-prices (this skill)by benchflow-ai | 86 | 1.8k | 2mo ago | SKILL.md |
| ai-job-searchby MadsLorentzen | 100 | 44.6k | today | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 41.7k | today | CLAUDE.md |
| algorithmic-artby anthropics | 100 | 177.9k | 7d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 7d ago | SKILL.md |
Frequently asked questions
- How do I install locational-marginal-prices?
- Run
npx skills add benchflow-ai/skillsbench --skill locational-marginal-prices. The install tabs above show the steps for each supported agent. - Which AI agents does locational-marginal-prices work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is locational-marginal-prices safe to use?
- It is Apache-2.0-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is locational-marginal-prices still maintained?
- The repository was last updated about 2 months ago, so locational-marginal-prices is actively maintained.
Skill content
View source on GitHubname: locational-marginal-prices description: "Extract locational marginal prices (LMPs) from DC-OPF solutions using dual values. Use when computing nodal electricity prices, reserve clearing prices, or performing price impact analysis."
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:
- Store references to the balance constraints
- Solve the problem
- 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:
- Solve base case — record costs, LMPs, and binding lines
- Modify constraint — e.g., increase a line's thermal limit
- Solve counterfactual — with the relaxed constraint
- 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
Related Skills
ai-job-search
44.6kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
41.7kA visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em…
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
