Skip to content

Commit 6f28022

Browse files
b0661NormannK
andauthored
fix: optimization fail after restart (#1007)
Fix documentation for the loadforecast_power_w key. Fix documentation to explain the usage of import file/ JSON string to primarily initialise prediction data. Fix code scanning alert no. 6: URL redirection from remote source Enable to automatically save the configuration to the configuration file by default, which is a widespread user expectation. Make the genetic parameters non optional for better pydantic compliance. Update: - bump pytest to 9.0.3 - bump pillow to 12.2.0 - bump platformdirs to 4.9.6 - bump typespyyaml to 6.0.12.20260408 - bump tzfpy to 1.2.0 - bump pydantic to 2.13.0 - bump types-requests to 2.33.0.20260408 Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com> Co-authored-by: Normann <github@koldrack.com>
1 parent 29cc3d7 commit 6f28022

19 files changed

Lines changed: 725 additions & 679 deletions

File tree

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ DOCKER_COMPOSE_DATA_DIR=${HOME}/.local/share/net.akkudoktor.eos
1111
# -----------------------------------------------------------------------------
1212
# Image / build
1313
# -----------------------------------------------------------------------------
14-
VERSION=0.3.0.dev2603180781250771
14+
VERSION=0.3.0.dev2604141105859917
1515
PYTHON_VERSION=3.13.9
1616

1717
# -----------------------------------------------------------------------------

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ repos:
3535
hooks:
3636
- id: mypy
3737
additional_dependencies:
38-
- types-requests==2.32.4.20260107
38+
- types-requests==2.33.0.20260408
3939
- pandas-stubs==3.0.0.260204
4040
- tokenize-rt==6.2.0
4141
- types-docutils==0.22.3.20260322
42-
- types-PyYaml==6.0.12.20250915
42+
- types-PyYaml==6.0.12.20260408
4343
pass_filenames: false
4444

4545
# --- Markdown linter ---

config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# the root directory (no add-on folder as usual).
77

88
name: "Akkudoktor-EOS"
9-
version: "0.3.0.dev2603180781250771"
9+
version: "0.3.0.dev2604141105859917"
1010
slug: "eos"
1111
description: "Akkudoktor-EOS add-on"
1212
url: "https://github.com/Akkudoktor-EOS/EOS"

docs/_generated/configexample.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@
125125
}
126126
},
127127
"general": {
128+
"config_save_mode": "AUTOMATIC",
129+
"config_save_interval_sec": 60,
128130
"version": "0.0.0",
129131
"data_folder_path": "/home/user/.local/share/net.akkudoktoreos.net",
130132
"data_output_subpath": "output",

docs/_generated/configgeneral.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
| ---- | -------------------- | ---- | --------- | ------- | ----------- |
1010
| config_file_path | | `Optional[pathlib.Path]` | `ro` | `N/A` | Path to EOS configuration file. |
1111
| config_folder_path | | `Optional[pathlib.Path]` | `ro` | `N/A` | Path to EOS configuration directory. |
12+
| config_save_interval_sec | `EOS_GENERAL__CONFIG_SAVE_INTERVAL_SEC` | `int` | `rw` | `60` | Automatic configuration file saving interval [seconds]. |
13+
| config_save_mode | `EOS_GENERAL__CONFIG_SAVE_MODE` | `<enum 'ConfigSaveMode'>` | `rw` | `AUTOMATIC` | Configuration file save mode for configuration changes ['MANUAL', 'AUTOMATIC']. Defaults to 'AUTOMATIC'. |
1214
| data_folder_path | `EOS_GENERAL__DATA_FOLDER_PATH` | `Path` | `rw` | `required` | Path to EOS data folder. |
1315
| data_output_path | | `Optional[pathlib.Path]` | `ro` | `N/A` | Computed data_output_path based on data_folder_path. |
1416
| data_output_subpath | `EOS_GENERAL__DATA_OUTPUT_SUBPATH` | `Optional[pathlib.Path]` | `rw` | `output` | Sub-path for the EOS output data folder. |
@@ -28,6 +30,8 @@
2830
```json
2931
{
3032
"general": {
33+
"config_save_mode": "AUTOMATIC",
34+
"config_save_interval_sec": 60,
3135
"version": "0.0.0",
3236
"data_folder_path": "/home/user/.local/share/net.akkudoktoreos.net",
3337
"data_output_subpath": "output",
@@ -46,6 +50,8 @@
4650
```json
4751
{
4852
"general": {
53+
"config_save_mode": "AUTOMATIC",
54+
"config_save_interval_sec": 60,
4955
"version": "0.0.0",
5056
"data_folder_path": "/home/user/.local/share/net.akkudoktoreos.net",
5157
"data_output_subpath": "output",

docs/_generated/configload.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
"load": {
127127
"loadimport": {
128128
"import_file_path": null,
129-
"import_json": "{\"load0_mean\": [676.71, 876.19, 527.13]}"
129+
"import_json": "{\"loadforecast_power_w\": [676.71, 876.19, 527.13]}"
130130
}
131131
}
132132
}

docs/_generated/configoptimization.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
| Name | Environment Variable | Type | Read-Only | Default | Description |
99
| ---- | -------------------- | ---- | --------- | ------- | ----------- |
10-
| algorithm | `EOS_OPTIMIZATION__ALGORITHM` | `Optional[str]` | `rw` | `GENETIC` | The optimization algorithm. |
11-
| genetic | `EOS_OPTIMIZATION__GENETIC` | `Optional[akkudoktoreos.optimization.optimization.GeneticCommonSettings]` | `rw` | `None` | Genetic optimization algorithm configuration. |
12-
| horizon_hours | `EOS_OPTIMIZATION__HORIZON_HOURS` | `Optional[int]` | `rw` | `24` | The general time window within which the energy optimization goal shall be achieved [h]. Defaults to 24 hours. |
13-
| interval | `EOS_OPTIMIZATION__INTERVAL` | `Optional[int]` | `rw` | `3600` | The optimization interval [sec]. |
10+
| algorithm | `EOS_OPTIMIZATION__ALGORITHM` | `str` | `rw` | `GENETIC` | The optimization algorithm. Defaults to GENETIC |
11+
| genetic | `EOS_OPTIMIZATION__GENETIC` | `GeneticCommonSettings` | `rw` | `required` | Genetic optimization algorithm configuration. |
12+
| horizon | | `int` | `ro` | `N/A` | Number of optimization steps. |
13+
| horizon_hours | `EOS_OPTIMIZATION__HORIZON_HOURS` | `int` | `rw` | `24` | The general time window within which the energy optimization goal shall be achieved [h]. Defaults to 24 hours. |
14+
| interval | `EOS_OPTIMIZATION__INTERVAL` | `int` | `rw` | `3600` | The optimization interval [sec]. Defaults to 3600 seconds (1 hour) |
1415
| keys | | `list[str]` | `ro` | `N/A` | The keys of the solution. |
1516
:::
1617
<!-- pyml enable line-length -->
@@ -58,7 +59,8 @@
5859
"ev_soc_miss": 10
5960
}
6061
},
61-
"keys": []
62+
"keys": [],
63+
"horizon": 24
6264
}
6365
}
6466
```
@@ -73,10 +75,10 @@
7375

7476
| Name | Type | Read-Only | Default | Description |
7577
| ---- | ---- | --------- | ------- | ----------- |
76-
| generations | `Optional[int]` | `rw` | `400` | Number of generations to evaluate the optimal solution [>= 10]. Defaults to 400. |
77-
| individuals | `Optional[int]` | `rw` | `300` | Number of individuals (solutions) to generate for the (initial) generation [>= 10]. Defaults to 300. |
78-
| penalties | `dict[str, Union[float, int, str]]` | `rw` | `required` | A dictionary of penalty function parameters consisting of a penalty function parameter name and the associated value. |
79-
| seed | `Optional[int]` | `rw` | `None` | Fixed seed for genetic algorithm. Defaults to 'None' which means random seed. |
78+
| generations | `Optional[int]` | `rw` | `400` | Number of generations to evolve [>= 10]. Defaults to 400. |
79+
| individuals | `Optional[int]` | `rw` | `300` | Number of individuals (solutions) in the population [>= 10]. Defaults to 300. |
80+
| penalties | `dict[str, Union[float, int, str]]` | `rw` | `required` | Penalty parameters used in fitness evaluation. |
81+
| seed | `Optional[int]` | `rw` | `None` | Random seed for reproducibility. None = random. |
8082
:::
8183
<!-- pyml enable line-length -->
8284

docs/_generated/openapi.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Akkudoktor-EOS
22

3-
**Version**: `v0.3.0.dev2603180781250771`
3+
**Version**: `v0.3.0.dev2604141105859917`
44

55
<!-- pyml disable line-length -->
66
**Description**: This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period.
@@ -1348,13 +1348,13 @@ Return:
13481348
- `application/json`: {
13491349
"anyOf": [
13501350
{
1351-
"$ref": "#/components/schemas/PowerMeasurement-Input"
1351+
"$ref": "#/components/schemas/PowerMeasurement"
13521352
},
13531353
{
1354-
"$ref": "#/components/schemas/EnergyMeasurement-Input"
1354+
"$ref": "#/components/schemas/EnergyMeasurement"
13551355
},
13561356
{
1357-
"$ref": "#/components/schemas/PPBCPowerProfileStatus-Input"
1357+
"$ref": "#/components/schemas/PPBCPowerProfileStatus"
13581358
},
13591359
{
13601360
"$ref": "#/components/schemas/OMBCStatus"
@@ -1363,7 +1363,7 @@ Return:
13631363
"$ref": "#/components/schemas/FRBCActuatorStatus"
13641364
},
13651365
{
1366-
"$ref": "#/components/schemas/FRBCEnergyStatus-Input"
1366+
"$ref": "#/components/schemas/FRBCEnergyStatus"
13671367
},
13681368
{
13691369
"$ref": "#/components/schemas/FRBCStorageStatus"

docs/akkudoktoreos/configuration.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,26 @@ management.
88

99
## Storing Configuration
1010

11-
EOS stores configuration data in a `nested structure`. Note that configuration changes inside EOS
12-
are updated in memory, meaning all changes will be lost upon restarting the EOS REST server if not
13-
saved to the `EOS configuration file`.
11+
EOS stores configuration data in a `nested structure`.
1412

1513
Some `configuration keys` are read-only and cannot be altered. These keys are either set up by other
1614
means, such as environment variables, or determined from other information.
1715

1816
Several endpoints of the EOS REST server allow for the management and retrieval of configuration
1917
data.
2018

19+
:::{admonition} Note
20+
:class: note
21+
Configuration changes inside EOS are updated in memory, meaning all changes will be lost upon
22+
restarting the EOS REST server unless the configuration is saved to the `EOS configuration file`.
23+
This can be done manually or is done automatically by default.
24+
:::
25+
2126
### Save Configuration File
2227

28+
Configure EOS for `AUTOMATIC` (vs. `MANUAL`) configuration file update in case of configuration
29+
changes.
30+
2331
Use endpoint `PUT /v1/config/file` to save the current configuration to the
2432
`EOS configuration file`.
2533

@@ -39,13 +47,18 @@ The configuration sources and their priorities are as follows:
3947

4048
### Runtime Config Updates
4149

42-
The EOS configuration can be updated at runtime. Note that those updates are not persistent
43-
automatically. However it is possible to save the configuration to the `EOS configuration file`.
50+
The EOS configuration can be updated at runtime.
4451

4552
Use the following endpoints to change the current runtime configuration:
4653

4754
- `PUT /v1/config`: Update the entire or parts of the configuration.
4855

56+
:::{admonition} Note
57+
:class: note
58+
Those updates are not persistent automatically. However it is possible to save the configuration to
59+
the `EOS configuration file`. See [Save Configuration File](#save-configuration-file) above.
60+
:::
61+
4962
### Environment Variables
5063

5164
All `configuration keys` can be set by environment variables prefixed with `EOS_` and separated by

0 commit comments

Comments
 (0)