foxes 0.7.4.25__py3-none-any.whl → 0.8.1__py3-none-any.whl

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.

Potentially problematic release.


This version of foxes might be problematic. Click here for more details.

Files changed (33) hide show
  1. foxes/VERSION +1 -1
  2. {foxes-0.7.4.25.dist-info → foxes-0.8.1.dist-info}/METADATA +20 -116
  3. {foxes-0.7.4.25.dist-info → foxes-0.8.1.dist-info}/RECORD +7 -33
  4. foxes/opt/__init__.py +0 -9
  5. foxes/opt/constraints/__init__.py +0 -6
  6. foxes/opt/constraints/area_geometry.py +0 -214
  7. foxes/opt/constraints/min_dist.py +0 -239
  8. foxes/opt/core/__init__.py +0 -9
  9. foxes/opt/core/farm_constraint.py +0 -96
  10. foxes/opt/core/farm_objective.py +0 -97
  11. foxes/opt/core/farm_opt_problem.py +0 -346
  12. foxes/opt/core/farm_vars_problem.py +0 -219
  13. foxes/opt/core/pop_states.py +0 -206
  14. foxes/opt/objectives/__init__.py +0 -6
  15. foxes/opt/objectives/farm_vars.py +0 -323
  16. foxes/opt/objectives/max_n_turbines.py +0 -142
  17. foxes/opt/problems/__init__.py +0 -7
  18. foxes/opt/problems/layout/__init__.py +0 -9
  19. foxes/opt/problems/layout/farm_layout.py +0 -137
  20. foxes/opt/problems/layout/geom_layouts/__init__.py +0 -10
  21. foxes/opt/problems/layout/geom_layouts/constraints.py +0 -802
  22. foxes/opt/problems/layout/geom_layouts/geom_layout.py +0 -290
  23. foxes/opt/problems/layout/geom_layouts/geom_layout_gridded.py +0 -276
  24. foxes/opt/problems/layout/geom_layouts/geom_reggrid.py +0 -351
  25. foxes/opt/problems/layout/geom_layouts/geom_reggrids.py +0 -482
  26. foxes/opt/problems/layout/geom_layouts/objectives.py +0 -666
  27. foxes/opt/problems/layout/reggrids_layout.py +0 -417
  28. foxes/opt/problems/layout/regular_layout.py +0 -350
  29. foxes/opt/problems/opt_farm_vars.py +0 -586
  30. {foxes-0.7.4.25.dist-info → foxes-0.8.1.dist-info}/LICENSE +0 -0
  31. {foxes-0.7.4.25.dist-info → foxes-0.8.1.dist-info}/WHEEL +0 -0
  32. {foxes-0.7.4.25.dist-info → foxes-0.8.1.dist-info}/top_level.txt +0 -0
  33. {foxes-0.7.4.25.dist-info → foxes-0.8.1.dist-info}/zip-safe +0 -0
foxes/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.4.25
1
+ 0.8.1
@@ -1,15 +1,23 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foxes
3
- Version: 0.7.4.25
3
+ Version: 0.8.1
4
4
  Summary: Farm Optimization and eXtended yield Evaluation Software
5
5
  Author: Fraunhofer IWES
6
- Author-email: jonas.schmidt@iwes.fraunhofer.de
6
+ Author-email: jonas.schulte@iwes.fraunhofer.de
7
7
  License: MIT
8
8
  Project-URL: Source Code, https://github.com/FraunhoferIWES/foxes
9
9
  Project-URL: Bug Tracker, https://github.com/FraunhoferIWES/foxes/issues
10
10
  Project-URL: Documentation, https://fraunhoferiwes.github.io/foxes.docs/index.html
11
11
  Keywords: Wind farm,Wake modelling,Wind farm optimization
12
+ Classifier: Topic :: Scientific/Engineering
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
12
15
  Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
13
21
  Classifier: License :: OSI Approved :: MIT License
14
22
  Classifier: Operating System :: OS Independent
15
23
  Classifier: Development Status :: 4 - Beta
@@ -17,7 +25,7 @@ Requires-Python: >=3.8
17
25
  Description-Content-Type: text/markdown
18
26
  License-File: LICENSE
19
27
  Requires-Dist: matplotlib
20
- Requires-Dist: numpy <2
28
+ Requires-Dist: numpy
21
29
  Requires-Dist: pandas
22
30
  Requires-Dist: xarray
23
31
  Requires-Dist: dask
@@ -25,19 +33,19 @@ Requires-Dist: distributed
25
33
  Requires-Dist: scipy
26
34
  Requires-Dist: netcdf4
27
35
  Requires-Dist: windrose
28
- Requires-Dist: iwopy >=0.1.4
29
36
  Requires-Dist: pyarrow
30
37
  Provides-Extra: all
31
38
  Requires-Dist: windio >=1 ; extra == 'all'
32
39
  Requires-Dist: flake8 ; extra == 'all'
33
40
  Requires-Dist: pytest ; extra == 'all'
34
- Requires-Dist: pymoo >=0.6 ; extra == 'all'
41
+ Requires-Dist: foxes-opt ; extra == 'all'
35
42
  Requires-Dist: sphinx ; extra == 'all'
36
43
  Requires-Dist: sphinx-immaterial ; extra == 'all'
37
44
  Requires-Dist: nbsphinx ; extra == 'all'
38
45
  Requires-Dist: ipykernel ; extra == 'all'
39
46
  Requires-Dist: ipywidgets ; extra == 'all'
40
47
  Requires-Dist: m2r2 ; extra == 'all'
48
+ Requires-Dist: lxml-html-clean ; extra == 'all'
41
49
  Provides-Extra: doc
42
50
  Requires-Dist: sphinx ; extra == 'doc'
43
51
  Requires-Dist: sphinx-immaterial ; extra == 'doc'
@@ -48,11 +56,12 @@ Requires-Dist: m2r2 ; extra == 'doc'
48
56
  Requires-Dist: lxml-html-clean ; extra == 'doc'
49
57
  Provides-Extra: io
50
58
  Requires-Dist: windio >=1 ; extra == 'io'
59
+ Provides-Extra: opt
60
+ Requires-Dist: foxes-opt ; extra == 'opt'
51
61
  Provides-Extra: scripts
52
62
  Provides-Extra: test
53
63
  Requires-Dist: flake8 ; extra == 'test'
54
64
  Requires-Dist: pytest ; extra == 'test'
55
- Requires-Dist: pymoo >=0.6 ; extra == 'test'
56
65
 
57
66
  # Welcome to foxes
58
67
 
@@ -105,7 +114,7 @@ Evaluation Software"`
105
114
  }
106
115
  ```
107
116
 
108
- ## Installation via pip
117
+ ## Requirements
109
118
 
110
119
  The supported Python versions are:
111
120
 
@@ -115,125 +124,20 @@ The supported Python versions are:
115
124
  - `Python 3.11`
116
125
  - `Python 3.12`
117
126
 
118
- ### Virtual Python environment
127
+ ## Installation
119
128
 
120
- First create a new `venv` environment, for example called `foxes` and located at `~/venv/foxes` (choose any other convenient name and location in your file system if you prefer), by
121
-
122
- ```console
123
- python3 -m venv ~/venv/foxes
124
- ```
125
-
126
- Then activate the environment every time you work with `foxes`, by
127
-
128
- ```console
129
- source ~/venv/foxes/bin/activate
130
- ```
131
-
132
- You can leave the environment by
133
-
134
- ```console
135
- deactivate
136
- ```
137
-
138
- The `pip` installation commands below should be executed within the active `foxes` environment.
139
-
140
- ### Standard users
141
-
142
- As a standard user, you can install the latest release via [pip](https://pypi.org/project/foxes/) by
129
+ Either install via pip:
143
130
 
144
131
  ```console
145
132
  pip install foxes
146
133
  ```
147
134
 
148
- This commands installs the version that correspond to the `main` branch at [github](https://github.com/FraunhoferIWES/foxes). Alternatively, you can decide to install the latest pre-release developments (non-stable) by
149
-
150
- ```console
151
- pip install git+https://github.com/FraunhoferIWES/foxes@dev#egg=foxes
152
- ```
153
-
154
- ### Developers
155
-
156
- For developers using `pip`, simply invoke the `-e` flag in the installation command in your local clone:
157
-
158
- ```console
159
- git clone https://github.com/FraunhoferIWES/foxes.git
160
- cd foxes
161
- pip install -e .
162
- ```
163
- The last line makes sure that all your code changes are included whenever importing `foxes`. Concerning the `git clone` line, we actually recommend that you fork `foxes` on GitHub and then replace that command by cloning your fork instead.
164
-
165
- ## Installation via conda
166
-
167
- The supported Python versions are:
168
-
169
- - `Python 3.8`
170
- - `Python 3.9`
171
- - `Python 3.10`
172
- - `Python 3.11`
173
- - `Python 3.12`
174
-
175
- ### Preparation (optional)
176
-
177
- It is strongly recommend to use the `libmamba` dependency solver instead of the default solver. Install it once by
178
-
179
- ```console
180
- conda install conda-libmamba-solver -n base -c conda-forge
181
- ```
182
-
183
- We recommend that you set this to be your default solver, by
184
-
185
- ```console
186
- conda config --set solver libmamba
187
- ```
188
-
189
- ### Virtual Python environment
190
-
191
- First create a new `conda` environment, for example called `foxes`, by
192
-
193
- ```console
194
- conda create -n foxes -c conda-forge
195
- ```
196
-
197
- Then activate the environment every time you work with `foxes`, by
198
-
199
- ```console
200
- conda activate foxes
201
- ```
202
-
203
- You can leave the environment by
135
+ Alternatively, install via conda:
204
136
 
205
137
  ```console
206
- conda deactivate
138
+ conda install foxes -c conda-forge
207
139
  ```
208
140
 
209
- The `conda` installation commands below should be executed within the active `foxes` environment.
210
-
211
- ### Standard users
212
-
213
- The `foxes` package is available on the channel [conda-forge](https://anaconda.org/conda-forge/foxes). You can install the latest version by
214
-
215
- ```console
216
- conda install foxes -c conda-forge --solver=libmamba
217
- ```
218
-
219
- The `--solver=libmamba` is optional. Note that it is not necessary if you have set the `libmamba` solver as your default, see above.
220
-
221
- ### Developers
222
-
223
- For developers using `conda`, we recommend first installing foxes as described above, then removing only the `foxes` package while keeping the dependencies, and then adding `foxes` again from a git using `conda develop`:
224
-
225
- ```console
226
- conda install foxes conda-build -c conda-forge --solver=libmamba
227
- conda remove foxes --force
228
- git clone https://github.com/FraunhoferIWES/foxes.git
229
- cd foxes
230
- conda develop .
231
- ```
232
-
233
- The last line makes sure that all your code changes are included whenever importing `foxes`. The `--solver=libmamba` is optional. Note that it is not necessary if you have set the `libmamba` solver as your default, see above.
234
-
235
- Concerning the `git clone` line, we actually recommend that you fork `foxes` on GitHub and then replace that command by cloning your fork instead.
236
-
237
141
  ## Usage
238
142
 
239
143
  For detailed examples of how to run _foxes_, check the `examples` and `notebooks` folders in this repository. A minimal running example is the following, based on provided static `csv` data files:
@@ -1,4 +1,4 @@
1
- foxes/VERSION,sha256=wqudIC35UQ4X_ZXteUCZWmkgYOqn9W5YQaMpo8usws0,9
1
+ foxes/VERSION,sha256=qvZyHcN8QLQjOsz8CB8ld2_zvR0qS51c6nYNHCz4ZmU,6
2
2
  foxes/__init__.py,sha256=4ptDOBaQC8fAd_ZH5XH7d5pIgx3JXEY9xLcK3Nrs2Ow,718
3
3
  foxes/constants.py,sha256=AQepsPOCRnHycNKvFyltcPFa4yUqYtTBOzgp56KKewA,2713
4
4
  foxes/variables.py,sha256=I-S25WejH33ffOcVnmN2TDL1pIxWqg0aM1lhIBwZ9NQ,4454
@@ -186,32 +186,6 @@ foxes/models/wake_superpositions/ws_max.py,sha256=MktXVo3PfMgh172DJP_KRftiqs8jXs
186
186
  foxes/models/wake_superpositions/ws_pow.py,sha256=aPtm5NwQx6byNfetSX57Z7tVkXtgXIRleSf4grKtZF0,9602
187
187
  foxes/models/wake_superpositions/ws_product.py,sha256=8dCDaKfuzHfTEBo0_N7BR-x_qG2tWXTabzPsgpIAtXk,4672
188
188
  foxes/models/wake_superpositions/ws_quadratic.py,sha256=jUo4wFkrUPbj-27m3ozCEzab7iamkNZtVlrCwY-Yh2w,9197
189
- foxes/opt/__init__.py,sha256=okwZagHJMkUkLvKCSQLbE0cjx_47RLl3bEz576j6CdI,172
190
- foxes/opt/constraints/__init__.py,sha256=UZzN_JlxGaASdGtvBn5d5xwdSDpwO6bklj3vw70IZvU,159
191
- foxes/opt/constraints/area_geometry.py,sha256=9TFsyuM8_pp3HEUV4N0w0KnhxOk0OLPMKd6ZvNQGC80,6156
192
- foxes/opt/constraints/min_dist.py,sha256=27D3IzbyyCBeC_A4dIGqcUGCz39cw7HfQiPAexgzpbE,7532
193
- foxes/opt/core/__init__.py,sha256=ugGfoIhn64oo_fYKyiGZo3eyFJfd7dhdwgl8MzgUl5o,289
194
- foxes/opt/core/farm_constraint.py,sha256=OGyzcz-lhnT4XAzxSRP2gAxh8jKO7JiCTaOv_b6f5wI,2009
195
- foxes/opt/core/farm_objective.py,sha256=unBJbs9XB6i_T-B_gbIq-NJY7iiAyfBdd2yCeOiG45g,2039
196
- foxes/opt/core/farm_opt_problem.py,sha256=DVW3xAv8PLi874ielfPiFwSXXthyRx9JEynQl7Rjmw0,9039
197
- foxes/opt/core/farm_vars_problem.py,sha256=7bS_nX1HbhBl9ZE44vy3UrLJJFie1in555joO6zpB0E,7774
198
- foxes/opt/core/pop_states.py,sha256=nW4lqmF4YNqVJYfOOaSYOId-pyzmH-RK8paU3xqSwtA,5780
199
- foxes/opt/objectives/__init__.py,sha256=Cs1CciLB53G_LOcjqqSBhyojB3FmyGeg5dInXpcw1l8,153
200
- foxes/opt/objectives/farm_vars.py,sha256=JutO-rvlKwR6KWY2vTuEJEZundqqUy0w6X-JkP_hd5w,8984
201
- foxes/opt/objectives/max_n_turbines.py,sha256=59vbT0vsWYE5ui9J_SVBmbLKr6tNwrLQKNXkGI_VcIA,4149
202
- foxes/opt/problems/__init__.py,sha256=ZfyWlykuyeH5_XC0ebmvQtchwY1ZQS9-TxcHVr_-4Gw,103
203
- foxes/opt/problems/opt_farm_vars.py,sha256=xf__1gdqv6NDKjzn_Xmr_uRWx1YXXTqSDg5K7WRyDnE,19425
204
- foxes/opt/problems/layout/__init__.py,sha256=aou75vqe8bjhstQCK3Eemg8PLKtE2DCJt2Aw476i-YM,229
205
- foxes/opt/problems/layout/farm_layout.py,sha256=ui8LWoBrqHIGNqb7YtlH0e95AieaZTNZKK6qL4nrggw,3924
206
- foxes/opt/problems/layout/reggrids_layout.py,sha256=1xHXnBQPK_9w2mMsiVdp85WSu6IlQuPAjAFGZu5vA4w,11804
207
- foxes/opt/problems/layout/regular_layout.py,sha256=2EZWY43PfQ821vcMeYs9LarXt6gYDUiIV4ijBjs5HOY,10583
208
- foxes/opt/problems/layout/geom_layouts/__init__.py,sha256=8QpYPWdT2QA6laSL8t7nkqXApmEtu6A00-TXWn6j28g,386
209
- foxes/opt/problems/layout/geom_layouts/constraints.py,sha256=1pU7RlVTmDtQ2U1DqgBb66tET-xcWzTeGkYKBwnda2k,22624
210
- foxes/opt/problems/layout/geom_layouts/geom_layout.py,sha256=CRdta3H65mxdO705dVDImsWrl6U9f4dY40UVxVsXJd4,8164
211
- foxes/opt/problems/layout/geom_layouts/geom_layout_gridded.py,sha256=7vXKVkPOHj2rOKY1TzPLB9_rAOR6Iqp9z-8w-j5HNmU,7586
212
- foxes/opt/problems/layout/geom_layouts/geom_reggrid.py,sha256=muAquvY_VFNwh-dZ-pJ290X-91a87IW5sQQwUu86PZg,10104
213
- foxes/opt/problems/layout/geom_layouts/geom_reggrids.py,sha256=uKkmqENXniZFA-XpCYCw6F6CN1TP13ZRSaoO3jt3hGY,14222
214
- foxes/opt/problems/layout/geom_layouts/objectives.py,sha256=QtEjrnwiNasJlplJmVBJGR_Q3l3KhTGScwOA88o-t28,17834
215
189
  foxes/output/__init__.py,sha256=7JSbLw8oEI3f-aFDCQ11ygNLm9b--6va1vMBeCftlx8,675
216
190
  foxes/output/animation.py,sha256=zljekg6k2DjqVaBw0OamB4i3eopi6g2j0a12B9hx7VQ,2637
217
191
  foxes/output/calc_points.py,sha256=QRZuZ6joHbhkEYDBX87QgEWwMMYbohAK3ZFuVwErK3Q,4497
@@ -266,9 +240,9 @@ foxes/utils/geom2d/half_plane.py,sha256=kzZD6pkZxZ03MK9WAboWzXb5Ws5dWLQY9GIahD4D
266
240
  foxes/utils/geom2d/polygon.py,sha256=8ASfy7No_-Pt_xDSeNsDtLEkCjBWsNZK8nIxDQtqeOE,5534
267
241
  foxes/utils/runners/__init__.py,sha256=-WL4ZmdgNYldkqhCV6dR-aXCumBrH-Ea-V1shsRhsbs,55
268
242
  foxes/utils/runners/runners.py,sha256=Sc06qsCzPduMyxbywgf6G3uHRioDs1qWRSc6GZbLFAY,6932
269
- foxes-0.7.4.25.dist-info/LICENSE,sha256=bBCH6mYTPzSepk2s2UUZ3II_ZYXrn1bnSqB85-aZHxU,1071
270
- foxes-0.7.4.25.dist-info/METADATA,sha256=JcchAtLkIF8BTPLq753kYMbC8ENjZ6tECY6uMRRyT70,9569
271
- foxes-0.7.4.25.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
272
- foxes-0.7.4.25.dist-info/top_level.txt,sha256=B4spGR6JHsVHz7CEXsa68xsjYalAA70nBwHa1gfyRHc,6
273
- foxes-0.7.4.25.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
274
- foxes-0.7.4.25.dist-info/RECORD,,
243
+ foxes-0.8.1.dist-info/LICENSE,sha256=bBCH6mYTPzSepk2s2UUZ3II_ZYXrn1bnSqB85-aZHxU,1071
244
+ foxes-0.8.1.dist-info/METADATA,sha256=_f7NCLGS6rSP_jlZ4vbNdW1EgClDYwkEn0h0qD-Auy8,6619
245
+ foxes-0.8.1.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
246
+ foxes-0.8.1.dist-info/top_level.txt,sha256=B4spGR6JHsVHz7CEXsa68xsjYalAA70nBwHa1gfyRHc,6
247
+ foxes-0.8.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
248
+ foxes-0.8.1.dist-info/RECORD,,
foxes/opt/__init__.py DELETED
@@ -1,9 +0,0 @@
1
- """
2
- Wind farm optimization.
3
- """
4
-
5
- from .core import FarmOptProblem, FarmObjective, FarmConstraint
6
-
7
- from . import problems
8
- from . import constraints
9
- from . import objectives
@@ -1,6 +0,0 @@
1
- """
2
- Wind farm optimization constraints.
3
- """
4
-
5
- from .area_geometry import AreaGeometryConstraint, FarmBoundaryConstraint
6
- from .min_dist import MinDistConstraint
@@ -1,214 +0,0 @@
1
- import numpy as np
2
-
3
- from foxes.opt.core.farm_constraint import FarmConstraint
4
- import foxes.variables as FV
5
-
6
-
7
- class AreaGeometryConstraint(FarmConstraint):
8
- """
9
- Constrains turbine positions to the inside
10
- of a given area geometry.
11
-
12
- Attributes
13
- ----------
14
- farm: foxes.WindFarm
15
- The wind farm
16
- sel_turbines: list
17
- The selected turbines
18
- geometry: foxes.utils.geom2d.AreaGeometry
19
- The area geometry
20
- disc_inside: bool
21
- Ensure full rotor disc inside boundary
22
- D: float
23
- Use this radius for rotor disc inside condition
24
-
25
- :group: opt.constraints
26
-
27
- """
28
-
29
- def __init__(
30
- self,
31
- problem,
32
- name,
33
- geometry,
34
- sel_turbines=None,
35
- disc_inside=False,
36
- D=None,
37
- **kwargs,
38
- ):
39
- """
40
- Constructor.
41
-
42
- Parameters
43
- ----------
44
- problem : foxes.opt.FarmOptProblem
45
- The underlying optimization problem
46
- name : str
47
- The name of the constraint
48
- geometry : foxes.utils.geom2d.AreaGeometry
49
- The area geometry
50
- sel_turbines : list of int, optional
51
- The selected turbines
52
- disc_inside : bool
53
- Ensure full rotor disc inside boundary
54
- D : float, optional
55
- Use this radius for rotor disc inside condition
56
- kwargs : dict, optional
57
- Additional parameters for `iwopy.Constraint`
58
-
59
- """
60
- self.geometry = geometry
61
- self.disc_inside = disc_inside
62
- self.D = D
63
-
64
- selt = problem.sel_turbines if sel_turbines is None else sel_turbines
65
- vrs = []
66
- cns = []
67
- for ti in selt:
68
- vrs += [problem.tvar(FV.X, ti), problem.tvar(FV.Y, ti)]
69
- cns.append(f"{name}_{ti:04d}")
70
-
71
- super().__init__(
72
- problem, name, sel_turbines, vnames_float=vrs, cnames=cns, **kwargs
73
- )
74
-
75
- def n_components(self):
76
- """
77
- Returns the number of components of the
78
- function.
79
-
80
- Returns
81
- -------
82
- int:
83
- The number of components.
84
-
85
- """
86
- return self.n_sel_turbines
87
-
88
- def vardeps_float(self):
89
- """
90
- Gets the dependencies of all components
91
- on the function float variables
92
-
93
- Returns
94
- -------
95
- deps: numpy.ndarray of bool
96
- The dependencies of components on function
97
- variables, shape: (n_components, n_vars_float)
98
-
99
- """
100
- deps = np.zeros((self.n_components(), self.n_components(), 2), dtype=bool)
101
- np.fill_diagonal(deps[:, :, 0], True)
102
- np.fill_diagonal(deps[:, :, 1], True)
103
- return deps.reshape(self.n_components(), self.n_components() * 2)
104
-
105
- def calc_individual(self, vars_int, vars_float, problem_results, components=None):
106
- """
107
- Calculate values for a single individual of the
108
- underlying problem.
109
-
110
- Parameters
111
- ----------
112
- vars_int: np.array
113
- The integer variable values, shape: (n_vars_int,)
114
- vars_float: np.array
115
- The float variable values, shape: (n_vars_float,)
116
- problem_results: Any
117
- The results of the variable application
118
- to the problem
119
- components: list of int, optional
120
- The selected components or None for all
121
-
122
- Returns
123
- -------
124
- values: np.array
125
- The component values, shape: (n_sel_components,)
126
-
127
- """
128
- s = np.s_[:]
129
- if components is not None and len(components) < self.n_components():
130
- s = components
131
- xy = vars_float.reshape(self.n_components(), 2)[s]
132
-
133
- dists = self.geometry.points_distance(xy)
134
- dists[self.geometry.points_inside(xy)] *= -1
135
-
136
- if self.disc_inside:
137
- if self.D is None:
138
- dists += problem_results[FV.D].to_numpy()[0, self.sel_turbines][s] / 2
139
- else:
140
- dists += self.D / 2
141
-
142
- return dists
143
-
144
- def calc_population(self, vars_int, vars_float, problem_results, components=None):
145
- """
146
- Calculate values for all individuals of a population.
147
-
148
- Parameters
149
- ----------
150
- vars_int: np.array
151
- The integer variable values, shape: (n_pop, n_vars_int)
152
- vars_float: np.array
153
- The float variable values, shape: (n_pop, n_vars_float)
154
- problem_results: Any
155
- The results of the variable application
156
- to the problem
157
- components: list of int, optional
158
- The selected components or None for all
159
-
160
- Returns
161
- -------
162
- values: np.array
163
- The component values, shape: (n_pop, n_sel_components)
164
-
165
- """
166
- n_pop = len(vars_float)
167
- n_cmpnts = self.n_components()
168
- s = np.s_[:]
169
- if components is not None and len(components) < self.n_components():
170
- n_cmpnts = len(components)
171
- s = components
172
- xy = vars_float[:, s].reshape(n_pop * n_cmpnts, 2)
173
-
174
- dists = self.geometry.points_distance(xy)
175
- dists[self.geometry.points_inside(xy)] *= -1
176
- dists = dists.reshape(n_pop, n_cmpnts)
177
-
178
- if self.disc_inside:
179
- if self.D is None:
180
- dists += (
181
- problem_results[FV.D].to_numpy()[None, 0, self.sel_turbines][s] / 2
182
- )
183
- else:
184
- dists += self.D / 2
185
-
186
- return dists
187
-
188
-
189
- class FarmBoundaryConstraint(AreaGeometryConstraint):
190
- """
191
- Constrains turbine positions to the inside of
192
- the wind farm boundary
193
-
194
- :group: opt.constraints
195
-
196
- """
197
-
198
- def __init__(self, problem, name="boundary", **kwargs):
199
- """
200
- Constructor.
201
-
202
- Parameters
203
- ----------
204
- problem: foxes.opt.FarmOptProblem
205
- The underlying optimization problem
206
- name: str
207
- The name of the constraint
208
- kwargs: dict, optional
209
- Additional parameters for `AreaGeometryConstraint`
210
-
211
- """
212
- b = problem.farm.boundary
213
- assert b is not None, f"Constraint '{name}': Missing wind farm boundary."
214
- super().__init__(problem, name, geometry=b, **kwargs)