iesopt 2.13.1__tar.gz → 2.14.1.dev0__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.
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.github/actions/set-versions/action.yml +2 -3
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.github/workflows/pypi_publish.yml +1 -1
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.pre-commit-config.yaml +2 -2
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/PKG-INFO +4 -4
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/_extensions/julia_domain.py +5 -2
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/conf.py +4 -4
- iesopt-2.14.1.dev0/docs/pages/manual/yaml/core_components.md +90 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/yaml/top_level.md +4 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/general/common_errors.md +8 -1
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/pyproject.toml +10 -3
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/__init__.py +16 -17
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/alg/mga/__init__.py +0 -1
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/alg/mga/nvp.py +1 -1
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/alg/mga/util.py +0 -1
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/config.py +9 -7
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/iesopt.py +4 -6
- iesopt-2.14.1.dev0/src/iesopt/julia/__init__.py +3 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/julia/general.py +5 -3
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/julia/setup.py +14 -16
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/julia/util.py +6 -5
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/model.py +4 -4
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/results.py +20 -20
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/util/__init__.py +3 -1
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/tests/test_examples.py +30 -43
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/tests/test_files.py +2 -1
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/tests/test_julia_consistency.py +4 -3
- iesopt-2.14.1.dev0/uv.lock +2288 -0
- iesopt-2.13.1/docs/pages/manual/yaml/core_components.md +0 -23
- iesopt-2.13.1/src/iesopt/julia/__init__.py +0 -2
- iesopt-2.13.1/uv.lock +0 -1738
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.codespellrc +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.editorconfig +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.github/workflows/documentation.yml +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.github/workflows/pytest.yml +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.gitignore +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/.python-version +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/CHANGELOG.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/LICENSE +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/README.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/Makefile +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/_static/.gitkeep +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/_static/custom.css +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/_static/favicon.ico +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/dynamic/core.py +1 -1
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/dynamic/create.py +1 -1
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/dynamic/julia.py +1 -1
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/dynamic/out/.gitignore +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/getting_started.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/index.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/make.bat +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/notebooks/.gitignore +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/notebooks/custom_results_1.ipynb +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/notebooks/custom_results_2.ipynb +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/notebooks/example_52.ipynb +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/notebooks/example_53.ipynb +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/notebooks/example_54.ipynb +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/notebooks/example_55.ipynb +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/notebooks/first_model.ipynb +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/notebooks/pyproject.toml +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/notebooks/ruff.toml +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/dev/core.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/dev/general.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/dev/updating.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/julia/.gitignore +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/julia/index.md_template +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/python/configuration.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/python/index.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/python/jump.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/python/model.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/python/results.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/python/util.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/yaml/core/.gitignore +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/manual/yaml/index.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/references/projects.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/references/publications.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/tutorials/.gitkeep +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/tutorials/addons.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/tutorials/templates/getter_setter.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/tutorials/templates_1.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/tutorials/templates_2.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/general/best_practice.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/general/global_parameters.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/general/kwargs_config.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/general/linking_components.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/general/monte_carlo.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/general/solvers.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/index.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/qna/cop_interpolation.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/qna/dynamic_marginal_costs.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/qna/passive_charging.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/qna/profiles_sign.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/qna/snapshot_duration.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/toc_general.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/pages/user_guides/toc_qna.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/tocs/examples.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/tocs/tutorials_extracting_results.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/docs/tocs/tutorials_templates.md +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/alg/__init__.py +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/alg/algorithm.py +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/util/logging.py +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/src/iesopt/util/util.py +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/tag_release.sh +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/tests/__init__.py +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/tests/test_python_julia_conversion.py +0 -0
- {iesopt-2.13.1 → iesopt-2.14.1.dev0}/tests/test_results.py +0 -0
|
@@ -6,10 +6,9 @@ runs:
|
|
|
6
6
|
steps:
|
|
7
7
|
- name: "set UV version"
|
|
8
8
|
shell: bash
|
|
9
|
-
run: echo "VERSION_UV=0.
|
|
9
|
+
run: echo "VERSION_UV=0.13.5" >> $GITHUB_ENV
|
|
10
10
|
|
|
11
11
|
- name: "set Julia version"
|
|
12
12
|
shell: bash
|
|
13
|
-
run: echo "VERSION_JULIA=1.
|
|
14
|
-
|
|
13
|
+
run: echo "VERSION_JULIA=1.13.3" >> $GITHUB_ENV
|
|
15
14
|
|
|
@@ -3,7 +3,7 @@ default_language_version:
|
|
|
3
3
|
|
|
4
4
|
repos:
|
|
5
5
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
6
|
-
rev: v0.
|
|
6
|
+
rev: v0.17.2
|
|
7
7
|
hooks:
|
|
8
8
|
- id: ruff
|
|
9
9
|
types_or: [python, pyi, jupyter] # make sure to include jupyter files
|
|
@@ -12,7 +12,7 @@ repos:
|
|
|
12
12
|
types_or: [python, pyi, jupyter]
|
|
13
13
|
|
|
14
14
|
- repo: https://github.com/codespell-project/codespell
|
|
15
|
-
rev: v2.4.
|
|
15
|
+
rev: v2.4.3
|
|
16
16
|
hooks:
|
|
17
17
|
- id: codespell
|
|
18
18
|
additional_dependencies:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: iesopt
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.14.1.dev0
|
|
4
4
|
Summary: IESopt -- an Integrated Energy System Optimization framework.
|
|
5
5
|
Project-URL: Homepage, https://github.com/ait-energy/iesopt
|
|
6
6
|
Project-URL: Documentation, https://ait-energy.github.io/iesopt
|
|
@@ -17,8 +17,8 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.14
|
|
19
19
|
Requires-Python: >=3.13
|
|
20
|
-
Requires-Dist: juliacall==0.9.
|
|
21
|
-
Requires-Dist: juliapkg==0.1.
|
|
20
|
+
Requires-Dist: juliacall==0.9.37
|
|
21
|
+
Requires-Dist: juliapkg==0.1.28
|
|
22
22
|
Requires-Dist: pandas<3.0,>=2.0
|
|
23
23
|
Requires-Dist: pathlib>=1.0.0
|
|
24
24
|
Requires-Dist: pydantic>=2.7.4
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# See: DocumenterInterLinks.jl
|
|
2
2
|
# > https://github.com/JuliaDocs/DocumenterInterLinks.jl/
|
|
3
3
|
# > "sphinx-to-documenter-links"
|
|
4
|
+
from typing import ClassVar
|
|
5
|
+
|
|
4
6
|
from sphinx.domains import Domain, ObjType
|
|
5
7
|
from sphinx.roles import XRefRole
|
|
8
|
+
from sphinx.util.typing import RoleFunction
|
|
6
9
|
|
|
7
10
|
|
|
8
11
|
class JuliaDomain(Domain):
|
|
@@ -10,7 +13,7 @@ class JuliaDomain(Domain):
|
|
|
10
13
|
|
|
11
14
|
name = "jl"
|
|
12
15
|
label = "Julia"
|
|
13
|
-
object_types = {
|
|
16
|
+
object_types: ClassVar[dict[str, ObjType]] = {
|
|
14
17
|
# name => (localized name, *roles)
|
|
15
18
|
"macro": ObjType("macro", "macro", "obj"),
|
|
16
19
|
"keyword": ObjType("keyword", "keyword", "obj"),
|
|
@@ -21,7 +24,7 @@ class JuliaDomain(Domain):
|
|
|
21
24
|
"constant": ObjType("constant", "const", "constant", "obj"),
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
roles = {
|
|
27
|
+
roles: ClassVar[dict[str, RoleFunction]] = {
|
|
25
28
|
"macro": XRefRole(),
|
|
26
29
|
"keyword": XRefRole(),
|
|
27
30
|
"function": XRefRole(fix_parens=True),
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import importlib.metadata
|
|
1
2
|
import sys
|
|
2
3
|
from pathlib import Path
|
|
3
|
-
import importlib.metadata
|
|
4
4
|
|
|
5
5
|
from sphinxawesome_theme.postprocess import Icons
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
# -- Setup -------------------------------------------------------------------
|
|
9
8
|
|
|
10
9
|
DOCS = Path(__file__).parent
|
|
@@ -12,6 +11,9 @@ sys.path.insert(0, str((DOCS / "_extensions").resolve()))
|
|
|
12
11
|
sys.path.insert(0, str((DOCS / ".." / "src").resolve()))
|
|
13
12
|
sys.path.insert(0, str((DOCS / "..").resolve()))
|
|
14
13
|
|
|
14
|
+
import docs.dynamic.core as ddcore
|
|
15
|
+
import docs.dynamic.julia # noqa: F401
|
|
16
|
+
|
|
15
17
|
CREATE_DYNAMIC_DOCSTRINGS = [
|
|
16
18
|
# ("test", "getfield", "some_foo(...)")
|
|
17
19
|
# and then use:
|
|
@@ -23,7 +25,6 @@ if len(CREATE_DYNAMIC_DOCSTRINGS) > 0:
|
|
|
23
25
|
|
|
24
26
|
ddcreate.create_md(CREATE_DYNAMIC_DOCSTRINGS)
|
|
25
27
|
|
|
26
|
-
import docs.dynamic.core as ddcore # noqa: E402
|
|
27
28
|
|
|
28
29
|
ddcore._dyn_core_create_md("Connection")
|
|
29
30
|
ddcore._dyn_core_create_md("Decision")
|
|
@@ -31,7 +32,6 @@ ddcore._dyn_core_create_md("Node")
|
|
|
31
32
|
ddcore._dyn_core_create_md("Profile")
|
|
32
33
|
ddcore._dyn_core_create_md("Unit")
|
|
33
34
|
|
|
34
|
-
import docs.dynamic.julia # noqa: E402, F401
|
|
35
35
|
|
|
36
36
|
# -- General -----------------------------------------------------------------
|
|
37
37
|
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Components
|
|
2
|
+
|
|
3
|
+
- A [Connection](./core/connection.md) is used to model arbitrary flows of energy between Nodes. It allows for limits, costs, delays, ...
|
|
4
|
+
- A [Decision](./core/decision.md) represents a basic decision variable in the model that can be used as input for various other core component's settings, as well as have associated costs.
|
|
5
|
+
- A [Node](./core/node.md) represents a basic intersection/hub for energy flows. This can for example be some sort of bus (for electrical systems). It enforces a nodal balance equation (= "energy that flows into it must flow out") for every Snapshot. Enabling the internal state of the `Node` allows it to act as energy storage, modifying the nodal balance equation. This allows using `Node`s for various storage tasks (like batteries, hydro reservoirs, heat storages, ...).
|
|
6
|
+
- A [Profile](./core/profile.md) allows representing "model boundaries" - parts of initial problem that are not endogenously modelled - with a support for time series data. Examples are hydro reservoir inflows, electricity demand, importing gas, and so on. Besides modelling fixed [Profiles](/pages/manual/yaml/core/profile.md)s, they also allow different ways to modify the value endogenously.
|
|
7
|
+
- A [Unit](./core/unit.md) allows transforming one (or many) forms of energy into another one (or many), given some constraints and costs.
|
|
8
|
+
|
|
9
|
+
:::{tip}
|
|
10
|
+
There exists a further type, called `Virtual`, that works almost exactly the same as any other core component - but is only a virtual placeholder for non-existing components of your model. These are ones that a user might expect to exist, but are removed due to flattening the model topology: Each template that gets instantiated is dropped from the model and replaced by the components that it actually constructs. To allow accessing these components, `Virtual` components are used.
|
|
11
|
+
|
|
12
|
+
Their usage, and various internal details, are rather advanced and currently not fully documented.
|
|
13
|
+
:::
|
|
14
|
+
|
|
15
|
+
## Enable core components
|
|
16
|
+
|
|
17
|
+
You can assign an enable-parameter to switch core components on and off via bools. A disable-parameter is also available. Tip: Never mix both parameters in one project to not get confused by bools working in two directions.
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
unit:
|
|
21
|
+
enabled: true
|
|
22
|
+
type: Unit
|
|
23
|
+
inputs: {}
|
|
24
|
+
outputs: {}
|
|
25
|
+
conversion: foo -> bar
|
|
26
|
+
capacity: 5 out:electricity
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
You might want to use multiple bools, you can combine them using boolean operators according to [Julia syntax](https://docs.julialang.org/en/v1/manual/mathematical-operations/#Boolean-Operators).
|
|
30
|
+
|
|
31
|
+
```yaml
|
|
32
|
+
unit:
|
|
33
|
+
enabled: <enable_unit> && <enable_scenario>
|
|
34
|
+
type: Unit
|
|
35
|
+
inputs: {}
|
|
36
|
+
outputs: {}
|
|
37
|
+
conversion: foo -> bar
|
|
38
|
+
capacity: 5 out:electricity
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
or using the disabled-syntax and further including a more complicated condition.
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
unit:
|
|
45
|
+
disabled: !<enable_unit> || <mode> == "something"
|
|
46
|
+
type: Unit
|
|
47
|
+
inputs: {}
|
|
48
|
+
outputs: {}
|
|
49
|
+
conversion: foo -> bar
|
|
50
|
+
capacity: 5 out:electricity
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Custom config for core components
|
|
54
|
+
|
|
55
|
+
It can be useful to assign additional variables to a core component. For example, to give every unit of the same type a variable, so that you may use it in a single addon where you loop over all those units (marked by a tag).
|
|
56
|
+
You can see this approach applied in the [CHP core template](https://github.com/ait-energy/IESopt.jl/blob/54c36a51dc8d57e686ecfeaec42abf8114f20819/assets/templates/CHP.iesopt.template.yaml#L44-L47).
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
unit:
|
|
60
|
+
type: Unit
|
|
61
|
+
inputs: {}
|
|
62
|
+
outputs: {}
|
|
63
|
+
conversion: foo -> bar
|
|
64
|
+
capacity: 5 out:electricity
|
|
65
|
+
config: {my_variable: <value>}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Fixed cost of core components
|
|
69
|
+
|
|
70
|
+
Although not relevant for the optimization, it can be convenient to be able to add fixed costs to a core component, e.g., the fixed operational cost of an existing unit. It will add this amount to the objective value. Look at example [46_constants_in_objective](https://github.com/ait-energy/IESopt.jl/blob/54c36a51dc8d57e686ecfeaec42abf8114f20819/assets/examples/46_constants_in_objective.iesopt.yaml) to see it applied.
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
unit:
|
|
74
|
+
type: Unit
|
|
75
|
+
inputs: {}
|
|
76
|
+
outputs: {}
|
|
77
|
+
conversion: foo -> bar
|
|
78
|
+
capacity: 5 out:electricity
|
|
79
|
+
objectives: {total_cost: <cost_per_unit_per_optimization_horizon>}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
:::{toctree}
|
|
83
|
+
:hidden:
|
|
84
|
+
|
|
85
|
+
core/connection.md
|
|
86
|
+
core/decision.md
|
|
87
|
+
core/node.md
|
|
88
|
+
core/profile.md
|
|
89
|
+
core/unit.md
|
|
90
|
+
:::
|
|
@@ -365,6 +365,10 @@ In the above example, the file `inputs_2023_base.csv` is linked to the name `dat
|
|
|
365
365
|
Assuming that, in the above example, we call `data` the file's "descriptor" and `inputs_2023_base.csv` the file's "name", then make sure that **the descriptor does not start with an underscore**, and further only uses alphanumeric characters and underscores (so no `!`, `~`, or other "unexpected" special characters).
|
|
366
366
|
:::
|
|
367
367
|
|
|
368
|
+
:::{tip}
|
|
369
|
+
You can ignore columns in the csv by putting a "$" in front of the respective column name. For example, it allows to include extra information (beyond model parameters) in the csv, which it otherwise could not since IESopt then complains about a column it does not understand or expect.
|
|
370
|
+
:::
|
|
371
|
+
|
|
368
372
|
#### `_csv_config`
|
|
369
373
|
|
|
370
374
|
:::{caution}
|
|
@@ -12,4 +12,11 @@ Errors that may occur when executing `import iesopt`.
|
|
|
12
12
|
- '=1.12.5' at ...\\.venv\lib\site-packages\iesopt\juliapkg.json
|
|
13
13
|
- '1.0.0 - 1.11' at ...\\.venv\lib\site-packages\juliacall\juliapkg.json (OpenSSL_jll)
|
|
14
14
|
```
|
|
15
|
-
|
|
15
|
+
You can either:
|
|
16
|
+
1. Try installing Python via `uv` instead of the standard [Python Installer](https://www.python.org/downloads/release/pymanager-260/); this can be done, e.g., by running `uv python install 3.14 --force`. Currently, versions published directly by CPython come with an outdated `OpenSSL` version.
|
|
17
|
+
2. Or (most likely better), try a general fix by telling `uv` to use only Python installations managed by them (instead of a global / system-wide CPython), by adding this to your `pyproject.toml`:
|
|
18
|
+
```toml
|
|
19
|
+
[tool.uv]
|
|
20
|
+
python-preference = "only-managed"
|
|
21
|
+
```
|
|
22
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "iesopt"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.14.1.dev0"
|
|
4
4
|
description = "IESopt -- an Integrated Energy System Optimization framework."
|
|
5
5
|
keywords = ["integrated energy systems", "optimization", "energy model", "modelling"]
|
|
6
6
|
authors = [
|
|
@@ -25,8 +25,8 @@ dependencies = [
|
|
|
25
25
|
"pydantic >= 2.7.4",
|
|
26
26
|
"python-dotenv >= 1.0.1",
|
|
27
27
|
# the Julia dependencies are intentionally pinned!
|
|
28
|
-
"juliacall == 0.9.
|
|
29
|
-
"juliapkg == 0.1.
|
|
28
|
+
"juliacall == 0.9.37",
|
|
29
|
+
"juliapkg == 0.1.28",
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
[project.urls]
|
|
@@ -65,6 +65,13 @@ line-length = 120
|
|
|
65
65
|
extend-exclude = ["*.jl"]
|
|
66
66
|
target-version = "py313"
|
|
67
67
|
|
|
68
|
+
[tool.ruff.lint]
|
|
69
|
+
ignore = [
|
|
70
|
+
"E402", # Module level import not at top of file
|
|
71
|
+
"BLE001", # Do not catch blind exception: `Exception`
|
|
72
|
+
"TRY002", # Create your own exception
|
|
73
|
+
]
|
|
74
|
+
|
|
68
75
|
[tool.pytest.ini_options]
|
|
69
76
|
addopts = [
|
|
70
77
|
"--import-mode=importlib",
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import importlib.metadata
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
3
4
|
from pathlib import Path
|
|
4
5
|
|
|
6
|
+
from iesopt.iesopt import examples as examples
|
|
7
|
+
from iesopt.iesopt import make_example as make_example
|
|
8
|
+
from iesopt.iesopt import run as run
|
|
9
|
+
from iesopt.model import Model as Model
|
|
10
|
+
from iesopt.model import ModelStatus as ModelStatus
|
|
11
|
+
from iesopt.results import Results as Results
|
|
12
|
+
|
|
13
|
+
from .julia import initialize as _initialize_everything
|
|
14
|
+
from .julia import jl_isa as jl_isa
|
|
15
|
+
from .julia.util import jl_docs
|
|
16
|
+
from .julia.util import jl_symbol as jl_symbol
|
|
17
|
+
from .util import get_iesopt_module_attr as _get_iesopt_module_attr
|
|
18
|
+
|
|
5
19
|
# Set version.
|
|
6
20
|
__version__ = importlib.metadata.version("iesopt")
|
|
7
21
|
|
|
@@ -36,46 +50,31 @@ JuMP = None
|
|
|
36
50
|
|
|
37
51
|
def jump_value(item):
|
|
38
52
|
"""Calls `JuMP.value.(item)`."""
|
|
39
|
-
pass
|
|
40
53
|
|
|
41
54
|
|
|
42
55
|
def jump_dual(item):
|
|
43
56
|
"""Calls `JuMP.dual.(item)`."""
|
|
44
|
-
pass
|
|
45
57
|
|
|
46
58
|
|
|
47
59
|
def jump_reduced_cost(item):
|
|
48
60
|
"""Calls `JuMP.reduced_cost.(item)`."""
|
|
49
|
-
pass
|
|
50
61
|
|
|
51
62
|
|
|
52
63
|
def jump_shadow_price(item):
|
|
53
64
|
"""Calls `JuMP.shadow_price.(item)`."""
|
|
54
|
-
pass
|
|
55
65
|
|
|
56
66
|
|
|
57
67
|
def get_jl_docstr(obj: str):
|
|
58
68
|
"""Get the documentation string of a Julia object inside the IESopt module."""
|
|
59
|
-
pass
|
|
60
69
|
|
|
61
70
|
|
|
62
71
|
# =======================================================================
|
|
63
72
|
|
|
64
73
|
# Setup Julia.
|
|
65
|
-
from .julia import initialize as _initialize_everything # noqa: E402
|
|
66
|
-
from .util import get_iesopt_module_attr as _get_iesopt_module_attr # noqa: E402
|
|
67
|
-
|
|
68
74
|
julia = _initialize_everything(
|
|
69
75
|
__target__, __sysimage__, reuse_julia_env=os.environ.get("IESOPT_REUSE_JULIA_ENV", "no") == "yes"
|
|
70
76
|
)
|
|
71
77
|
|
|
72
|
-
# Export everything.
|
|
73
|
-
from iesopt.model import Model as Model, ModelStatus as ModelStatus # noqa: E402
|
|
74
|
-
from iesopt.results import Results as Results # noqa: E402
|
|
75
|
-
from iesopt.iesopt import run as run, examples as examples, make_example as make_example # noqa: E402
|
|
76
|
-
|
|
77
|
-
from .julia.util import jl_symbol as jl_symbol, jl_docs # noqa: E402
|
|
78
|
-
from .julia import jl_isa as jl_isa # noqa: E402
|
|
79
78
|
|
|
80
79
|
Symbol = jl_symbol
|
|
81
80
|
|
|
@@ -108,4 +107,4 @@ def create_sysimage():
|
|
|
108
107
|
)
|
|
109
108
|
|
|
110
109
|
print("Successfully created sysimage; launch your script/code again to use it")
|
|
111
|
-
exit(0)
|
|
110
|
+
sys.exit(0)
|
|
@@ -13,7 +13,7 @@ except ImportError:
|
|
|
13
13
|
|
|
14
14
|
from ...model import Model
|
|
15
15
|
from ..algorithm import Algorithm
|
|
16
|
-
from .util import
|
|
16
|
+
from .util import add_obj_threshold_constraint, set_weighted_objective
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
# Calculate the normal vector pointing inward the convex hull
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import ClassVar
|
|
2
|
+
|
|
1
3
|
from dotenv import dotenv_values
|
|
2
4
|
|
|
3
5
|
|
|
@@ -7,15 +9,15 @@ def _strtobool(val: str):
|
|
|
7
9
|
return 1
|
|
8
10
|
if val in ("n", "no", "f", "false", "off", "0"):
|
|
9
11
|
return 0
|
|
10
|
-
raise ValueError("Invalid truth value
|
|
12
|
+
raise ValueError(f"Invalid truth value {val!r}")
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
class Config:
|
|
14
|
-
DEFAULTS = {
|
|
15
|
-
"IESOPT_JULIA": "1.
|
|
16
|
-
"IESOPT_CORE": "https://github.com/ait-energy/IESopt.jl#v2.
|
|
17
|
-
"IESOPT_JUMP": "1.
|
|
18
|
-
"IESOPT_SOLVER_HIGHS": "1.
|
|
16
|
+
DEFAULTS: ClassVar[dict[str, str]] = {
|
|
17
|
+
"IESOPT_JULIA": "1.13.3",
|
|
18
|
+
"IESOPT_CORE": "https://github.com/ait-energy/IESopt.jl#v2.12.0",
|
|
19
|
+
"IESOPT_JUMP": "1.32.1",
|
|
20
|
+
"IESOPT_SOLVER_HIGHS": "1.26.1",
|
|
19
21
|
"IESOPT_MULTITHREADED": "no", # yes, no
|
|
20
22
|
"IESOPT_OPTIMIZATION": "latency", # rapid, latency, normal, performance
|
|
21
23
|
}
|
|
@@ -44,7 +46,7 @@ class Config:
|
|
|
44
46
|
|
|
45
47
|
@classmethod
|
|
46
48
|
def find(cls, prefix: str):
|
|
47
|
-
for k in cls._config
|
|
49
|
+
for k in cls._config:
|
|
48
50
|
if k.startswith(prefix):
|
|
49
51
|
yield k
|
|
50
52
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
|
|
3
|
-
from .util import logger, get_iesopt_module_attr
|
|
4
3
|
from .model import Model, ModelStatus
|
|
4
|
+
from .util import get_iesopt_module_attr, logger
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def run(filename: str | Path, **kwargs) -> Model:
|
|
@@ -71,8 +71,8 @@ def make_example(example: str, dst_dir: str | Path = "./", dst_name: str | None
|
|
|
71
71
|
Returns:
|
|
72
72
|
Path to the generated example file.
|
|
73
73
|
"""
|
|
74
|
-
import shutil
|
|
75
74
|
import os
|
|
75
|
+
import shutil
|
|
76
76
|
import stat
|
|
77
77
|
|
|
78
78
|
julia = get_iesopt_module_attr("julia")
|
|
@@ -91,13 +91,11 @@ def make_example(example: str, dst_dir: str | Path = "./", dst_name: str | None
|
|
|
91
91
|
logger.info("Data folder for examples already exists; NOT copying ANY contents")
|
|
92
92
|
|
|
93
93
|
# Copy the config file.
|
|
94
|
-
logger.info("Creating example ('
|
|
94
|
+
logger.info(f"Creating example ('{example}') at: '{target_filename}'")
|
|
95
95
|
shutil.copy(filename, target_filename)
|
|
96
96
|
|
|
97
97
|
# Make everything editable.
|
|
98
|
-
logger.info(
|
|
99
|
-
"Set write permissions for example ('%s'), and data folder ('%s')" % (target_filename, target_datafolder)
|
|
100
|
-
)
|
|
98
|
+
logger.info(f"Set write permissions for example ('{target_filename}'), and data folder ('{target_datafolder}')")
|
|
101
99
|
os.chmod(target_filename, os.stat(target_filename).st_mode & ~stat.S_IWRITE | stat.S_IWUSR)
|
|
102
100
|
for dirpath, _, filenames in os.walk(target_datafolder):
|
|
103
101
|
os.chmod(dirpath, os.stat(dirpath).st_mode & ~stat.S_IWRITE | stat.S_IWUSR)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import importlib.metadata
|
|
2
|
+
import os
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
5
|
from ..util import logger, set_iesopt_module_attr
|
|
6
|
-
from .setup import
|
|
6
|
+
from .setup import import_modules, setup_julia, use_existing_julia_environment
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def initialize(target: Path, sysimage: Path, *, reuse_julia_env: bool = False):
|
|
@@ -26,7 +26,9 @@ def initialize(target: Path, sysimage: Path, *, reuse_julia_env: bool = False):
|
|
|
26
26
|
|
|
27
27
|
import_modules()
|
|
28
28
|
logger.info(
|
|
29
|
-
"Loaded versions: py
|
|
29
|
+
"Loaded versions: py={}, jl={}".format(
|
|
30
|
+
importlib.metadata.version("iesopt"), str(julia.pkgversion(julia.IESopt))
|
|
31
|
+
)
|
|
30
32
|
)
|
|
31
33
|
|
|
32
34
|
set_iesopt_module_attr("IESopt", julia.IESopt)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import ssl
|
|
2
3
|
import sys
|
|
3
4
|
from pathlib import Path
|
|
4
|
-
import ssl
|
|
5
5
|
|
|
6
|
+
from ..config import Config
|
|
6
7
|
from ..util import logger
|
|
7
8
|
from .util import jl_import
|
|
8
|
-
from ..config import Config
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def lookup_package(name: str):
|
|
@@ -69,7 +69,7 @@ def _handle_env_vars():
|
|
|
69
69
|
|
|
70
70
|
def _handle_sysimage(sysimage: Path):
|
|
71
71
|
if sysimage.exists():
|
|
72
|
-
logger.info(" Using custom sysimage:
|
|
72
|
+
logger.info(f" Using custom sysimage: {sysimage!s}")
|
|
73
73
|
os.environ["PYTHON_JULIACALL_SYSIMAGE"] = str(sysimage)
|
|
74
74
|
else:
|
|
75
75
|
logger.info(" Using default sysimage")
|
|
@@ -109,12 +109,11 @@ def use_existing_julia_environment(sysimage: Path):
|
|
|
109
109
|
logger.warning(
|
|
110
110
|
" It seems we are running on a cluster; if you encounter an error related to 'GLIBCXX_*.*.*, "
|
|
111
111
|
+ "or 'Unable to load dependent library', please manually set the LD_LIBRARY_PATH environment "
|
|
112
|
-
+ "variable (e.g., by using 'export LD_LIBRARY_PATH=\"...\"')to: '
|
|
112
|
+
+ f"variable (e.g., by using 'export LD_LIBRARY_PATH=\"...\"')to: '{libdir}'."
|
|
113
113
|
)
|
|
114
114
|
|
|
115
|
-
logger.info(" Executable:
|
|
116
|
-
logger.info(" Project:
|
|
117
|
-
os.environ["PYTHON_JULIACALL_BINDIR"] = str(Path(juliapkg.executable()).parent)
|
|
115
|
+
logger.info(f" Executable: {juliapkg.executable()}")
|
|
116
|
+
logger.info(f" Project: {juliapkg.project()}")
|
|
118
117
|
|
|
119
118
|
import juliacall
|
|
120
119
|
|
|
@@ -162,8 +161,9 @@ def setup_julia(target: Path, sysimage: Path):
|
|
|
162
161
|
if "JULIA_SSL_CA_ROOTS_PATH" in os.environ:
|
|
163
162
|
if os.environ["JULIA_SSL_CA_ROOTS_PATH"] != "":
|
|
164
163
|
logger.info(
|
|
165
|
-
"Overwriting the env. variable `JULIA_SSL_CA_ROOTS_PATH` (current:
|
|
166
|
-
|
|
164
|
+
"Overwriting the env. variable `JULIA_SSL_CA_ROOTS_PATH` (current: `{}`) to prevent SSL issues during the Julia setup".format(
|
|
165
|
+
str(os.environ["JULIA_SSL_CA_ROOTS_PATH"])
|
|
166
|
+
)
|
|
167
167
|
)
|
|
168
168
|
os.environ["JULIA_SSL_CA_ROOTS_PATH"] = ""
|
|
169
169
|
else:
|
|
@@ -180,9 +180,9 @@ def setup_julia(target: Path, sysimage: Path):
|
|
|
180
180
|
for f in all_deps_files:
|
|
181
181
|
f, p = Path(f), Path(f).parent
|
|
182
182
|
if any((p.stem == el[0] and f.stem == el[1]) for el in allowed_deps_files):
|
|
183
|
-
logger.debug(" Detected valid `juliapkg.json` file: '
|
|
183
|
+
logger.debug(f" Detected valid `juliapkg.json` file: '{f}'")
|
|
184
184
|
continue
|
|
185
|
-
logger.warning("Detected invalid `juliapkg.json` file, renaming to render it stale: '
|
|
185
|
+
logger.warning(f"Detected invalid `juliapkg.json` file, renaming to render it stale: '{f}'")
|
|
186
186
|
f.rename(f.with_suffix(".json.DISABLED"))
|
|
187
187
|
|
|
188
188
|
# Set Julia version.
|
|
@@ -208,8 +208,8 @@ def setup_julia(target: Path, sysimage: Path):
|
|
|
208
208
|
_handle_env_vars()
|
|
209
209
|
_handle_sysimage(sysimage)
|
|
210
210
|
|
|
211
|
-
logger.info(" Executable:
|
|
212
|
-
logger.info(" Project:
|
|
211
|
+
logger.info(f" Executable: {juliapkg.executable()}")
|
|
212
|
+
logger.info(f" Project: {juliapkg.project()}")
|
|
213
213
|
|
|
214
214
|
# Try to find out if we are running on an old cluster, that might have issues with GLIBC.
|
|
215
215
|
if sys.platform == "linux":
|
|
@@ -219,11 +219,9 @@ def setup_julia(target: Path, sysimage: Path):
|
|
|
219
219
|
logger.warning(
|
|
220
220
|
" It seems we are running on a cluster; if you encounter an error related to 'GLIBCXX_*.*.*, "
|
|
221
221
|
+ "or 'Unable to load dependent library', please manually set the LD_LIBRARY_PATH environment "
|
|
222
|
-
+ "variable (e.g., by using 'export LD_LIBRARY_PATH=\"...\"')to: '
|
|
222
|
+
+ f"variable (e.g., by using 'export LD_LIBRARY_PATH=\"...\"')to: '{libdir}'."
|
|
223
223
|
)
|
|
224
224
|
|
|
225
|
-
os.environ["PYTHON_JULIACALL_BINDIR"] = str(Path(juliapkg.executable()).parent)
|
|
226
|
-
|
|
227
225
|
import juliacall
|
|
228
226
|
|
|
229
227
|
logger.info("Julia setup complete")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import pandas as pd
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
from ..util import get_iesopt_module_attr, logger
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
def jl_safe_seval(code: str):
|
|
@@ -7,16 +8,16 @@ def jl_safe_seval(code: str):
|
|
|
7
8
|
try:
|
|
8
9
|
return get_iesopt_module_attr("julia").seval(code)
|
|
9
10
|
except Exception as e:
|
|
10
|
-
logger.error("Exception while trying to execute Julia code:
|
|
11
|
-
logger.error("Exception:
|
|
12
|
-
logger.error("Exception details:
|
|
11
|
+
logger.error(f"Exception while trying to execute Julia code: `{code}`")
|
|
12
|
+
logger.error(f"Exception: `{e!s}`")
|
|
13
|
+
logger.error("Exception details: `{}`".format(getattr(e, "exception", "missing")))
|
|
13
14
|
|
|
14
15
|
return None
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
def jl_import(module: str):
|
|
18
19
|
"""Import a Julia module."""
|
|
19
|
-
logger.info("
|
|
20
|
+
logger.info(f" {module}")
|
|
20
21
|
jl_safe_seval(f"import {module}")
|
|
21
22
|
|
|
22
23
|
|
|
@@ -2,9 +2,9 @@ from enum import Enum
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from warnings import warn
|
|
4
4
|
|
|
5
|
-
from .util import
|
|
6
|
-
from .julia.util import jl_symbol, recursive_convert_py2jl, jl_safe_seval
|
|
5
|
+
from .julia.util import jl_safe_seval, jl_symbol, recursive_convert_py2jl
|
|
7
6
|
from .results import Results
|
|
7
|
+
from .util import get_iesopt_module_attr, logger
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ModelStatus(Enum):
|
|
@@ -226,7 +226,7 @@ class Model:
|
|
|
226
226
|
else:
|
|
227
227
|
self._IESopt.compute_IIS(self.core, filename=str(filename))
|
|
228
228
|
except Exception as e:
|
|
229
|
-
logger.error("Error while computing IIS:
|
|
229
|
+
logger.error(f"Error while computing IIS: `{e.args[0]!s}`")
|
|
230
230
|
|
|
231
231
|
@property
|
|
232
232
|
def results(self) -> Results:
|
|
@@ -248,7 +248,7 @@ class Model:
|
|
|
248
248
|
t = getattr(c, fieldtype)
|
|
249
249
|
f = getattr(t, field)
|
|
250
250
|
break
|
|
251
|
-
except Exception:
|
|
251
|
+
except Exception: # noqa: S110
|
|
252
252
|
pass
|
|
253
253
|
|
|
254
254
|
if f is None:
|