bilarem 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. bilarem-0.4.0/CHANGELOG.md +153 -0
  2. bilarem-0.4.0/Cargo.lock +824 -0
  3. bilarem-0.4.0/Cargo.toml +81 -0
  4. bilarem-0.4.0/LICENSE-APACHE +201 -0
  5. bilarem-0.4.0/LICENSE-MIT +21 -0
  6. bilarem-0.4.0/PKG-INFO +92 -0
  7. bilarem-0.4.0/README.md +178 -0
  8. bilarem-0.4.0/examples/data/case.json +5 -0
  9. bilarem-0.4.0/examples/data/rows.csv +9 -0
  10. bilarem-0.4.0/examples/data/theirs.csv +5 -0
  11. bilarem-0.4.0/examples/settle.rs +53 -0
  12. bilarem-0.4.0/pyproject.toml +64 -0
  13. bilarem-0.4.0/python/Cargo.toml +33 -0
  14. bilarem-0.4.0/python/README.md +67 -0
  15. bilarem-0.4.0/python/bilarem/__init__.py +29 -0
  16. bilarem-0.4.0/python/bilarem/__init__.pyi +206 -0
  17. bilarem-0.4.0/python/bilarem/py.typed +0 -0
  18. bilarem-0.4.0/python/src/lib.rs +615 -0
  19. bilarem-0.4.0/python/tests/test_bilarem.py +256 -0
  20. bilarem-0.4.0/src/balancing.rs +148 -0
  21. bilarem-0.4.0/src/bin/bilarem.rs +137 -0
  22. bilarem-0.4.0/src/calendar.rs +176 -0
  23. bilarem-0.4.0/src/deadlines.rs +144 -0
  24. bilarem-0.4.0/src/dispatchable.rs +85 -0
  25. bilarem-0.4.0/src/error.rs +562 -0
  26. bilarem-0.4.0/src/glossary.rs +51 -0
  27. bilarem-0.4.0/src/input.rs +74 -0
  28. bilarem-0.4.0/src/lib.rs +58 -0
  29. bilarem-0.4.0/src/limit.rs +63 -0
  30. bilarem-0.4.0/src/method.rs +391 -0
  31. bilarem-0.4.0/src/num.rs +94 -0
  32. bilarem-0.4.0/src/overbuild.rs +103 -0
  33. bilarem-0.4.0/src/result.rs +275 -0
  34. bilarem-0.4.0/src/rule_set.rs +38 -0
  35. bilarem-0.4.0/src/settlement/compare.rs +200 -0
  36. bilarem-0.4.0/src/settlement/csv.rs +95 -0
  37. bilarem-0.4.0/src/settlement/location.rs +252 -0
  38. bilarem-0.4.0/src/settlement/read.rs +538 -0
  39. bilarem-0.4.0/src/settlement.rs +940 -0
  40. bilarem-0.4.0/src/solar.rs +291 -0
  41. bilarem-0.4.0/src/split.rs +97 -0
  42. bilarem-0.4.0/src/time.rs +508 -0
  43. bilarem-0.4.0/src/wind/bin.rs +271 -0
  44. bilarem-0.4.0/src/wind/curve.rs +150 -0
  45. bilarem-0.4.0/src/wind.rs +450 -0
  46. bilarem-0.4.0/tests/calendar_mako.rs +75 -0
  47. bilarem-0.4.0/tests/cli.rs +83 -0
  48. bilarem-0.4.0/tests/data/bdew_mako_non_working_weekdays.txt +1545 -0
  49. bilarem-0.4.0/tests/data_contract.rs +312 -0
  50. bilarem-0.4.0/tests/dst.rs +53 -0
  51. bilarem-0.4.0/tests/errors.rs +78 -0
  52. bilarem-0.4.0/tests/location.rs +268 -0
  53. bilarem-0.4.0/tests/oracle/cases.csv +2800 -0
  54. bilarem-0.4.0/tests/oracle/oracle.py +159 -0
  55. bilarem-0.4.0/tests/oracle.rs +94 -0
  56. bilarem-0.4.0/tests/properties.proptest-regressions +8 -0
  57. bilarem-0.4.0/tests/properties.rs +338 -0
  58. bilarem-0.4.0/tests/ramps_and_reports.rs +203 -0
  59. bilarem-0.4.0/tests/security.rs +156 -0
  60. bilarem-0.4.0/tests/serde.rs +67 -0
  61. bilarem-0.4.0/tests/settlement.rs +591 -0
  62. bilarem-0.4.0/tests/worked_cases.rs +1004 -0
@@ -0,0 +1,153 @@
1
+ # Changelog
2
+
3
+ All notable changes to this crate. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## Unreleased
8
+
9
+ ### Added
10
+
11
+ - **Python package** `bilarem` on PyPI: `settle` and `compare` over the case format, with
12
+ `Decimal` and `datetime` in and out, rows and their values from CSV, pandas or polars,
13
+ `bilarem.Error` and `bilarem.CsvError` with the chapter, the remedy and every problem;
14
+ typed, one abi3 wheel per platform for CPython 3.11 and up.
15
+
16
+ ## 0.4.0 (2026-12-05)
17
+
18
+ ### Added
19
+
20
+ - `Measure::covering(start, end, direction)`: an instruction at any instants covers every
21
+ quarter hour it touches, whole (the decision's reasons, p. 26).
22
+ - `input::m_per_s(f64)`: a wind speed from a float, to 0.01 m/s, half away from zero;
23
+ NaN, infinities and negatives refused.
24
+
25
+ ### Changed
26
+
27
+ - A measure in JSON is the instruction: `start` and `end` at any instants, read with
28
+ `Measure::covering`. The calculator takes the instruction's times the same way.
29
+ - CSV keywords (`limit`, `restriction`) are case-insensitive, like the column names.
30
+
31
+ ## 0.3.0 (2026-12-05)
32
+
33
+ ### Added
34
+
35
+ - **Files** (`rows_from_csv`, `lost_energy_from_csv`): rows and the other party's lost
36
+ energy from CSV, as German Excel saves it or with commas; every problem in one
37
+ `Error::Csv`. `settle`'s own CSV reads back.
38
+ - **Berlin local times**: `QuarterHour` parses `2026-07-14 10:00` and `14.07.2026 10:00`;
39
+ a time in the repeated or skipped hour is `Error::LocalTime`.
40
+ - **`Case`**: measure, plant, method and rows as one JSON value (feature `serde`).
41
+ - **The `bilarem` command** (feature `cli`, Homebrew `hupe1980/tap/bilarem`):
42
+ `bilarem settle` and `bilarem compare` from files.
43
+ - **A calculator** on the site: the library compiled to WebAssembly, in the browser.
44
+
45
+ ### Changed
46
+
47
+ - `Row::fully_measured` is now `Row::partly_measured`, default `false`, so a row read
48
+ from JSON or CSV with an actual value is fully measured unless marked.
49
+ - JSON: unknown fields are refused; `Plant` writes `installed_kw` only where it differs
50
+ from `rated_kw`, and `inverter_kw` only for solar.
51
+ - Unparsable time text is `Error::NotATime`, not `Error::TimeOutOfRange`.
52
+
53
+ ## 0.2.0 (2026-12-05)
54
+
55
+ ### Added
56
+
57
+ - **Ramps** (2, 3): `Measure::with_ramps(before, after)` settles the ramp quarter hours a
58
+ measure caused with it; `Measure::instructed_start`, `Measure::ramps`. The trace names
59
+ them.
60
+ - **Report times**: `Row::market(kw, reported_at)` and `Row::available(kw, reported_at)`.
61
+ `settle` does not apply a value reported at or after the measure began and lists it in
62
+ `Settlement::ignored()` and the trace (BK8-26-001-A draft 2.5, Rahmendokument 6.1.5).
63
+
64
+ ### Changed
65
+
66
+ - `Row::market_kw` and `Row::available_kw` are now `Row::market` and `Row::available`
67
+ of type `Reported { kw, reported_at }`.
68
+
69
+ ## 0.1.0 (2026-12-05)
70
+
71
+ The settlement engine: the rules of BilAReM (BNetzA BK6-23-241, 7 May 2026) as exact,
72
+ total functions, and a measure settled in one call.
73
+
74
+ ### Added
75
+
76
+ - **Settlement** (3, 6.4.3): `settle(measure, plant, method, rows)` settles one TR for one
77
+ measure: it reports every missing row, duplicate and missing value at once
78
+ (`Error::Rows`), derives the comparison window, day or `P_0` from the rows, applies the
79
+ rule to each quarter hour and totals the rounded values. `Settlement` prints a trace
80
+ table and exports CSV (`Dialect::English`, `Dialect::German` for German Excel).
81
+ `compare(settlement, theirs)` lists the quarter hours that differ after rounding, with
82
+ our binding term, and those present on one side only. `Plant`, `Row`, `Basis`.
83
+ - **A grid location** (3.4): `settle_location(settlements, connection_kw, fed_in)` caps
84
+ every TR behind one grid location per quarter hour on exact values and re-totals each.
85
+ The cut shows in the trace and the CSV (`SettledQuarter::cut_kwh`); `Location` prints
86
+ the farm. `Error::NotOneLocation` for mixed or already capped settlements.
87
+ - **Clearing threshold** (Rahmendokument 6.1.5, draft):
88
+ `Comparison::clearing_threshold_reached()`, `|theirs − ours| ≥ 100 kWh`.
89
+ - **Time**: `QuarterHour` (a UTC instant on a 15-minute boundary), `Measure`, `Direction`,
90
+ `Restriction`, `PlantKind`. Days and months in Europe/Berlin, the plant factor in UTC+1.
91
+ - **The limit** (3.1): `limit::Limit` for the request, toleration and reference-profile
92
+ cases.
93
+ - **Wind** (3.2.2): `wind::exact`, `wind::flat_rate`, `wind::comparison_window`,
94
+ `wind::last_unrestricted` (`P_0`), and `wind::CertifiedCurve`, the certified power-curve
95
+ lookup with linear interpolation at 0.1 m/s and both readings of "the mean" as
96
+ `wind::Averaging`.
97
+ - **Wind-Bin** (3.2.3.2): `wind::bin` with bins of 0.5 m/s, the power factor, SCADA
98
+ statistics, the substitute chain with its source, the loss factor and the composed
99
+ correction.
100
+ - **Solar** (3.2.4): `solar::exact`, `solar::flat_rate`, `solar::comparison_day`,
101
+ `solar::plant_factor`.
102
+ - **Non-fluctuating plants** (3.3): `dispatchable::exact`, `dispatchable::flat_rate`.
103
+ - **Overbuild and split** (3, 3.4): `overbuild::cap` and `split::pro_rata` with a named
104
+ `SplitKey`; parts always sum exactly to the whole.
105
+ - **Methods** (3.2.1, 3.2.3.1, 3.3): `method::applicable` and `method::check` with the
106
+ reason, `Election` (annual and initial), `flat_rate_switch_end`, and the Wind-Bin
107
+ election for offshore wind.
108
+ - **Balancing** (2): `BalancingModel`, effective dates, `AssignmentNotice::validate`, the
109
+ 2.1.3 `financial_correction`.
110
+ - **Deadlines** (2.3.2, 3.2.1, 6.3.1, 6.4.3) over the `calendar::WorkingDays` trait, with
111
+ the MaKo working-day calendar shipped as `calendar::MaKo`.
112
+ - **Results and errors**: `QuarterResult` with every term, the binding term, the limit,
113
+ the clamp, the chapter and the rule set; one `Error` whose message names the chapter and
114
+ the text's remedy.
115
+ - `Binding::key`, `Chapter::SOLAR_SIMPLIFIED`, `Display` for `PlantKind`.
116
+ - `round_kwh`, the one rounding (3 decimals of kWh, half away from zero), and
117
+ `input::kw` / `input::kw_per_m2` to bring `f64` measurements in.
118
+ - Feature `serde`.
119
+
120
+ ### Where bilarem departs from earlier implementations
121
+
122
+ bilarem replaces the BilAReM engines of `mako-redispatch` and metering's
123
+ `grid::ausfallarbeit`. Where they departed from the final text, the text wins:
124
+
125
+ - **The previous month is allowed** for the wind comparison window and the solar
126
+ comparison day. The text excludes only the following month, because actual values may
127
+ still be corrected until its 4th working day; that reason does not reach back.
128
+ - **Days and months are Berlin's**, derived from the instant. Before, they came from the
129
+ caller's UTC offset, so a quarter hour at 00:30 on the 1st (Berlin) passed in UTC fell
130
+ into the previous day and month.
131
+ - **The plant factor reads UTC+1** from the instant. Before, the caller had to convert;
132
+ passing summer local time shifted every band by an hour.
133
+ - **Multiply first**: `P_VZ,ist × P_theo ÷ P_VZ,theo` and `P_VZ,ist × G_i ÷ G_VZ` are one
134
+ quotient each. Before, the ratio was divided out first, which can flip a last digit.
135
+ - **The split key is named**: reference yield, site yield or installed capacity, as the
136
+ text prescribes per case. Before, only installed capacity, and the parts did not
137
+ always sum to the whole.
138
+ - **Wind-Bin election** for offshore wind: annual, by 30 November, once the bin factors
139
+ are agreed. It was missing.
140
+ - **A Wind-Bin needs 30 minutes of valid data** as well as three pairs. Before, only the
141
+ three pairs, which is the same for 10-minute SCADA data but not for 1-minute data.
142
+ - **The solar comparison day**: quarter hours from 10 % of rated power count in the
143
+ means, but a day qualifies only with one *above* 10 %, as the text's two sentences say.
144
+ - **No panics**: no `expect`, checked arithmetic. Before, an irradiance of `1e-28` kW/m²
145
+ overflowed and panicked.
146
+ - **Errors carry the remedy**, such as a neighbouring plant's theoretical values when no
147
+ comparison window exists.
148
+ - **One rounding**, stated: `round_kwh` at the edge. Before, one engine rounded every
149
+ quarter hour and the other not at all.
150
+
151
+ ## 0.0.1 (2026-12-05)
152
+
153
+ - Name reserved; `is_planned_value_effective_date` (BilAReM 2.3.2).