invrs-opt 0.9.3__py3-none-any.whl → 0.9.4__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.
- invrs_opt/__init__.py +1 -1
- invrs_opt/parameterization/gaussian_levelset.py +46 -23
- {invrs_opt-0.9.3.dist-info → invrs_opt-0.9.4.dist-info}/METADATA +2 -2
- {invrs_opt-0.9.3.dist-info → invrs_opt-0.9.4.dist-info}/RECORD +7 -7
- {invrs_opt-0.9.3.dist-info → invrs_opt-0.9.4.dist-info}/WHEEL +1 -1
- {invrs_opt-0.9.3.dist-info → invrs_opt-0.9.4.dist-info}/LICENSE +0 -0
- {invrs_opt-0.9.3.dist-info → invrs_opt-0.9.4.dist-info}/top_level.txt +0 -0
invrs_opt/__init__.py
CHANGED
@@ -218,34 +218,17 @@ def gaussian_levelset(
|
|
218
218
|
pad_pixels: int = 2,
|
219
219
|
) -> jnp.ndarray:
|
220
220
|
"""Computes constraints associated with the params."""
|
221
|
-
|
222
|
-
params,
|
223
|
-
beta=length_scale_constraint_beta,
|
221
|
+
return analytical_constraints(
|
222
|
+
params=params,
|
224
223
|
length_scale_constraint_factor=length_scale_constraint_factor,
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
224
|
+
length_scale_constraint_beta=length_scale_constraint_beta,
|
225
|
+
length_scale_constraint_weight=length_scale_constraint_weight,
|
226
|
+
curvature_constraint_weight=curvature_constraint_weight,
|
227
|
+
fixed_pixel_constraint_weight=fixed_pixel_constraint_weight,
|
229
228
|
mask_gradient=mask_gradient,
|
230
229
|
pad_pixels=pad_pixels,
|
231
230
|
)
|
232
231
|
|
233
|
-
constraints = jnp.stack(
|
234
|
-
[
|
235
|
-
length_scale_constraint * length_scale_constraint_weight,
|
236
|
-
curvature_constraint * curvature_constraint_weight,
|
237
|
-
fixed_pixel_constraint * fixed_pixel_constraint_weight,
|
238
|
-
],
|
239
|
-
axis=-1,
|
240
|
-
)
|
241
|
-
|
242
|
-
# Normalize constraints to make them (somewhat) resolution-independent.
|
243
|
-
example_density = _example_density(params)
|
244
|
-
length_scale = 0.5 * (
|
245
|
-
example_density.minimum_spacing + example_density.minimum_width
|
246
|
-
)
|
247
|
-
return constraints / length_scale**2
|
248
|
-
|
249
232
|
def update_fn(params: GaussianLevelsetParams, step: int) -> GaussianLevelsetParams:
|
250
233
|
"""Perform updates to `params` required for the given `step`."""
|
251
234
|
del step
|
@@ -403,6 +386,46 @@ def _phi_from_params(
|
|
403
386
|
# -----------------------------------------------------------------------------
|
404
387
|
|
405
388
|
|
389
|
+
def analytical_constraints(
|
390
|
+
params: GaussianLevelsetParams,
|
391
|
+
length_scale_constraint_factor: float,
|
392
|
+
length_scale_constraint_beta: float,
|
393
|
+
length_scale_constraint_weight: float,
|
394
|
+
curvature_constraint_weight: float,
|
395
|
+
fixed_pixel_constraint_weight: float,
|
396
|
+
mask_gradient: bool,
|
397
|
+
pad_pixels: int,
|
398
|
+
) -> jnp.ndarray:
|
399
|
+
"""Computes analytical levelset constraints associated with the params."""
|
400
|
+
length_scale_constraint, curvature_constraint = _levelset_constraints(
|
401
|
+
params,
|
402
|
+
beta=length_scale_constraint_beta,
|
403
|
+
length_scale_constraint_factor=length_scale_constraint_factor,
|
404
|
+
pad_pixels=pad_pixels,
|
405
|
+
)
|
406
|
+
fixed_pixel_constraint = _fixed_pixel_constraint(
|
407
|
+
params,
|
408
|
+
mask_gradient=mask_gradient,
|
409
|
+
pad_pixels=pad_pixels,
|
410
|
+
)
|
411
|
+
|
412
|
+
constraints = jnp.stack(
|
413
|
+
[
|
414
|
+
length_scale_constraint * length_scale_constraint_weight,
|
415
|
+
curvature_constraint * curvature_constraint_weight,
|
416
|
+
fixed_pixel_constraint * fixed_pixel_constraint_weight,
|
417
|
+
],
|
418
|
+
axis=-1,
|
419
|
+
)
|
420
|
+
|
421
|
+
# Normalize constraints to make them (somewhat) resolution-independent.
|
422
|
+
example_density = _example_density(params)
|
423
|
+
length_scale = 0.5 * (
|
424
|
+
example_density.minimum_spacing + example_density.minimum_width
|
425
|
+
)
|
426
|
+
return constraints / length_scale**2
|
427
|
+
|
428
|
+
|
406
429
|
def _fixed_pixel_constraint(
|
407
430
|
params: GaussianLevelsetParams,
|
408
431
|
mask_gradient: bool,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: invrs_opt
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.4
|
4
4
|
Summary: Algorithms for inverse design
|
5
5
|
Author-email: "Martin F. Schubert" <mfschubert@gmail.com>
|
6
6
|
Maintainer-email: "Martin F. Schubert" <mfschubert@gmail.com>
|
@@ -533,7 +533,7 @@ Requires-Dist: pytest-cov; extra == "tests"
|
|
533
533
|
Requires-Dist: pytest-subtests; extra == "tests"
|
534
534
|
|
535
535
|
# invrs-opt - Optimization algorithms for inverse design
|
536
|
-
`v0.9.
|
536
|
+
`v0.9.4`
|
537
537
|
|
538
538
|
## Overview
|
539
539
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
invrs_opt/__init__.py,sha256=
|
1
|
+
invrs_opt/__init__.py,sha256=bVIs0NxPxNuRUOypBIE68qx-SA1lFCmqmo5cqvRpxmU,585
|
2
2
|
invrs_opt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
invrs_opt/experimental/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
invrs_opt/experimental/client.py,sha256=t4XxnditYbM9DWZeyBPj0Sa2acvkikT0ybhUdmH2r-Y,4852
|
@@ -10,11 +10,11 @@ invrs_opt/optimizers/wrapped_optax.py,sha256=VXdCteT2kumqhP81l3p6QiEqwBffoUuJ3Uj
|
|
10
10
|
invrs_opt/parameterization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
invrs_opt/parameterization/base.py,sha256=BObzbz6efT2nBjib0_5BSdkCmFi2f0mcZ9VJYpDzO6Q,5278
|
12
12
|
invrs_opt/parameterization/filter_project.py,sha256=7Jb8JVENmBTdx3-XmI-VRm4aMjxg_Wtin8tMKKKxWvQ,4309
|
13
|
-
invrs_opt/parameterization/gaussian_levelset.py,sha256=
|
13
|
+
invrs_opt/parameterization/gaussian_levelset.py,sha256=Ka4hW_OLxUaIPHQsyIOlryG7i1mC-LTIgiQQhCPwHPk,25626
|
14
14
|
invrs_opt/parameterization/pixel.py,sha256=AwC4GBNNOysdICvYHv_D2tZdqJmYiRzOUZNq_-R9Z70,1617
|
15
15
|
invrs_opt/parameterization/transforms.py,sha256=8GzaIsUuuXvMCLiqAEEfxmi9qE9KqHzbuTj_m0GjH3w,8216
|
16
|
-
invrs_opt-0.9.
|
17
|
-
invrs_opt-0.9.
|
18
|
-
invrs_opt-0.9.
|
19
|
-
invrs_opt-0.9.
|
20
|
-
invrs_opt-0.9.
|
16
|
+
invrs_opt-0.9.4.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
17
|
+
invrs_opt-0.9.4.dist-info/METADATA,sha256=SOt6aECrbTQNI0QuznoPrWKzUdMeahaST0G4Q7sccxE,32641
|
18
|
+
invrs_opt-0.9.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
19
|
+
invrs_opt-0.9.4.dist-info/top_level.txt,sha256=hOziS2uJ_NgwaW9yhtOfeuYnm1X7vobPBcp_6eVWKfM,10
|
20
|
+
invrs_opt-0.9.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|