1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// SPDX-License-Identifier: LicenseRef-PolyForm-Noncommercial-1.0.0
//! Virtual energy bids for day-ahead market clearing.
//!
//! A **virtual bid** (also called an "inc/dec bid" or "convergence bid") is a
//! financial position that injects or withdraws virtual MW at a bus to influence
//! LMPs. They are a day-ahead market construct — RTOs (ERCOT, PJM, ISO-NE) use
//! them for convergence bidding between day-ahead and real-time markets.
//!
//! # Economics
//!
//! - **Inc (increment) bid**: Injects MW at a bus, competing against physical
//! generators. Clears when the bus LMP ≥ bid price; drives LMP down at that bus.
//! - **Dec (decrement) bid**: Withdraws MW at a bus, competing against physical
//! loads. Clears when the bus LMP ≤ bid price; drives LMP up at that bus.
//!
//! # LP formulation
//!
//! Each in-service bid adds one variable `v_k ∈ [0, mw_limit / base_mva]`.
//!
//! **Objective** (minimise total production cost + virtual bid cost):
//! - Inc bid: `+price_per_mwh * base_mva * v_k` (paying for energy)
//! - Dec bid: `-price_per_mwh * base_mva * v_k` (receiving payment)
//!
//! **Power balance at bus** (LP constraint matrix coefficient for variable `v_k`):
//! - Inc bid: `-1.0` — injects power at the bus (same sign as a generator in the
//! B-theta formulation: `B·θ - Σ Pg + Σ Pd = 0`).
//! - Dec bid: `+1.0` — withdraws power from the bus (same sign as a load).
//!
//! Uneconomic bids clear at zero naturally: the LP will not award an Inc bid at
//! a price above the equilibrium LMP, nor a Dec bid at a price below it.
use ;
/// Direction of a virtual bid.
/// A virtual energy bid for day-ahead market clearing.
///
/// Virtual bids participate in DC-OPF / SCED / SCUC as purely financial
/// positions: they affect LMPs but do not represent physical generation or load.
/// They are a day-ahead instrument — do not use in real-time dispatch.
///
/// Each bid targets exactly one dispatch period (hour). A trader bidding the
/// same price/quantity at the same location for hours 14–18 submits five
/// separate positions, matching real ISO practice (ERCOT, PJM, ISO-NE).
/// Result for a single virtual bid after market clearing.