mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-10-13 09:31:56 +00:00
perf(prediction): optional SciPy-free evaluation of the self-consumption tables (#1378)
* perf(prediction): evaluate self-consumption tables without SciPy The GENETIC inverter (and the GENETIC0 one) evaluates a pickled scipy.interpolate.RegularGridInterpolator for the self-consumption probabilities. SciPy is used nowhere else in EOS, yet loading it costs about 35 MB RSS (21 MB anonymous) on Linux arm64, which every optimization run pays. Add utils/gridinterpolator.py: - LinearGridInterpolator: 2-D linear interpolation with the same steps as SciPy's linear 2-D path (interval search, normalised distances, corner weights summed in the same order, fill value outside the grid, NaN for NaN input). - load_grid_interpolator(): reads the shipped pickles with a restricted unpickler that maps the SciPy class to a stand-in and accepts only the NumPy globals needed for the arrays. SciPy is not imported, and the data files no longer depend on SciPy's private module paths. Results are bit-identical to SciPy on Linux (aarch64, checked on 3.6M points per table including the query pattern of the inverter). The macOS arm64 SciPy wheel fuses multiply-add, so there SciPy itself differs by <= 1.1e-16; GENETIC plans for fixed seeds are unchanged on both platforms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(prediction): make the SciPy-free table evaluation opt-in Add optimization.self_consumption_interpolator (scipy | numpy, default scipy). The default keeps evaluating the self-consumption tables with SciPy's RegularGridInterpolator, built from the same grid, values and fill value the pickle holds, so results are unchanged. With numpy the tables are evaluated by LinearGridInterpolator and SciPy is never imported. The backend is read on every evaluation, so a config change applies to the next run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Christin <christin@BigBrother.bikini.bottom.zone> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Andreas <drbacke@gmx.de>
This commit is contained in:
co-authored by
Claude Opus 5.5
Christin
Andreas
parent
14d8587c9c
commit
560370281f
+28
-1
@@ -8,7 +8,7 @@
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
},
|
||||
"version": "v0.3.0.dev2609171762020752"
|
||||
"version": "v0.3.0.dev2610021392659061"
|
||||
},
|
||||
"paths": {
|
||||
"/v1/measurement/battery-capacity/{battery_id}": {
|
||||
@@ -9970,6 +9970,15 @@
|
||||
],
|
||||
"title": "GesamtlastRequest"
|
||||
},
|
||||
"GridInterpolatorBackend": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"scipy",
|
||||
"numpy"
|
||||
],
|
||||
"title": "GridInterpolatorBackend",
|
||||
"description": "How the self-consumption tables are evaluated."
|
||||
},
|
||||
"HTTPValidationError": {
|
||||
"properties": {
|
||||
"detail": {
|
||||
@@ -13091,6 +13100,15 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"self_consumption_interpolator": {
|
||||
"$ref": "#/components/schemas/GridInterpolatorBackend",
|
||||
"description": "How the inverter's self-consumption probability table is evaluated [scipy | numpy]. 'scipy' (default) uses scipy.interpolate. 'numpy' gives the same values without importing SciPy, which saves about 35 MB RSS after the first optimization run (useful on devices with little RAM); a run takes about 2.5 % longer.",
|
||||
"default": "scipy",
|
||||
"examples": [
|
||||
"scipy",
|
||||
"numpy"
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
@@ -13131,6 +13149,15 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"self_consumption_interpolator": {
|
||||
"$ref": "#/components/schemas/GridInterpolatorBackend",
|
||||
"description": "How the inverter's self-consumption probability table is evaluated [scipy | numpy]. 'scipy' (default) uses scipy.interpolate. 'numpy' gives the same values without importing SciPy, which saves about 35 MB RSS after the first optimization run (useful on devices with little RAM); a run takes about 2.5 % longer.",
|
||||
"default": "scipy",
|
||||
"examples": [
|
||||
"scipy",
|
||||
"numpy"
|
||||
]
|
||||
},
|
||||
"algorithms": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
|
||||
Reference in New Issue
Block a user