invrs-opt 0.9.3__tar.gz → 0.9.4__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.
Files changed (25) hide show
  1. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/PKG-INFO +2 -2
  2. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/README.md +1 -1
  3. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/pyproject.toml +1 -1
  4. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/__init__.py +1 -1
  5. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/parameterization/gaussian_levelset.py +46 -23
  6. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt.egg-info/PKG-INFO +2 -2
  7. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/LICENSE +0 -0
  8. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/setup.cfg +0 -0
  9. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/experimental/__init__.py +0 -0
  10. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/experimental/client.py +0 -0
  11. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/experimental/labels.py +0 -0
  12. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/optimizers/__init__.py +0 -0
  13. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/optimizers/base.py +0 -0
  14. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/optimizers/lbfgsb.py +0 -0
  15. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/optimizers/wrapped_optax.py +0 -0
  16. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/parameterization/__init__.py +0 -0
  17. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/parameterization/base.py +0 -0
  18. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/parameterization/filter_project.py +0 -0
  19. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/parameterization/pixel.py +0 -0
  20. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/parameterization/transforms.py +0 -0
  21. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt/py.typed +0 -0
  22. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt.egg-info/SOURCES.txt +0 -0
  23. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt.egg-info/dependency_links.txt +0 -0
  24. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt.egg-info/requires.txt +0 -0
  25. {invrs_opt-0.9.3 → invrs_opt-0.9.4}/src/invrs_opt.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: invrs_opt
3
- Version: 0.9.3
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: mypy; extra == "dev"
533
533
  Requires-Dist: pre-commit; extra == "dev"
534
534
 
535
535
  # invrs-opt - Optimization algorithms for inverse design
536
- `v0.9.3`
536
+ `v0.9.4`
537
537
 
538
538
  ## Overview
539
539
 
@@ -1,5 +1,5 @@
1
1
  # invrs-opt - Optimization algorithms for inverse design
2
- `v0.9.3`
2
+ `v0.9.4`
3
3
 
4
4
  ## Overview
5
5
 
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
 
3
3
  name = "invrs_opt"
4
- version = "v0.9.3"
4
+ version = "v0.9.4"
5
5
  description = "Algorithms for inverse design"
6
6
  keywords = ["topology", "optimization", "jax", "inverse design"]
7
7
  readme = "README.md"
@@ -3,7 +3,7 @@
3
3
  Copyright (c) 2023 The INVRS-IO authors.
4
4
  """
5
5
 
6
- __version__ = "v0.9.3"
6
+ __version__ = "v0.9.4"
7
7
  __author__ = "Martin F. Schubert <mfschubert@gmail.com>"
8
8
 
9
9
  from invrs_opt import parameterization as parameterization
@@ -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
- length_scale_constraint, curvature_constraint = _levelset_constraints(
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
- pad_pixels=pad_pixels,
226
- )
227
- fixed_pixel_constraint = _fixed_pixel_constraint(
228
- params,
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
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: mypy; extra == "dev"
533
533
  Requires-Dist: pre-commit; extra == "dev"
534
534
 
535
535
  # invrs-opt - Optimization algorithms for inverse design
536
- `v0.9.3`
536
+ `v0.9.4`
537
537
 
538
538
  ## Overview
539
539
 
File without changes
File without changes