scipy minimize generator#424
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@copilot address the coverage, linting and notebook failures |
…fix notebook ruff format
Fixed in commits
|
|
@copilot add tests to achieve needed coverage |
Added 8 new tests in the latest commit covering all previously untested branches in
Also removed a dead-code |
There was a problem hiding this comment.
Pull request overview
This pull request adds a new sequential optimization generator, ScipyGenerator, that adapts scipy.optimize.minimize to Xopt’s external ask/tell workflow, and updates tests, docs, and generator registration to support it.
Changes:
- Introduce
ScipyGenerator(sequential wrapper aroundscipy.optimize.minimize) and register it under generator namescipy. - Add unit tests (including serialization/restart coverage) for the new generator and update existing sequential serialization tests.
- Add documentation + example notebook for
ScipyGenerator, and update MkDocs navigation and algorithms/index references; refactor LatinHypercubeGenerator imports/location.
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| xopt/generators/sequential/scipy.py | New ScipyGenerator implementation wrapping scipy.optimize.minimize in a sequential ask/tell pattern |
| xopt/generators/sequential/init.py | Export ScipyGenerator from the sequential generators package |
| xopt/generators/init.py | Register ScipyGenerator for dynamic loading; improve defaults handling for default_factory fields |
| xopt/generators/scipy/init.py | Removes old scipy generator re-exports (package content removed) |
| xopt/generators/latin_hypercube.py | Adds/relocates LatinHypercubeGenerator under a new import path |
| xopt/tests/generators/sequential/test_scipy.py | Adds test coverage for ScipyGenerator |
| xopt/tests/generators/sequential/test_serialization.py | Adds ScipyGenerator to sequential generator serialization/restart tests |
| xopt/tests/generators/test_latin_hypercube.py | Updates import path for LatinHypercubeGenerator |
| docs/api/generators/sequential/scipy.md | API documentation page for ScipyGenerator |
| docs/examples/sequential/scipy.ipynb | New example notebook demonstrating ScipyGenerator usage |
| docs/examples/other/latin_hypercube.ipynb | Updates import path for LatinHypercubeGenerator and relocates example |
| mkdocs.yml | Adds new docs + example notebook to navigation; updates Latin Hypercube example path |
| docs/index.md | Mentions the new scipy sequential generator in the feature list |
| docs/algorithms.md | Adds ScipyGenerator to algorithms list (but link maintenance needed) |
| .gitignore | Ignores local test output artifacts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
FYI I'll try catch up this week |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Overview
This pull request introduces a new generic sequential optimization generator,
ScipyGenerator, that wrapsscipy.optimize.minimizeand integrates it with Xopt's ask/tell workflow. It includes comprehensive documentation, an example notebook, and full test coverage. Additionally, it updates the generator registry and navigation to reflect the new functionality, and refactors some imports for consistency.Integration Model
Xopt evaluates objective functions externally, one point at a time.
scipy.optimize.minimizeexpects an in-process callable objective.ScipyGeneratorbridges this mismatch by replaying known evaluations:X.data.minimizeis called with an objective wrapper that checks the cache first.minimize, and returns that point to Xopt.step,minimizeis called again with the larger cache.Performance Notes
step, where N is the number of collected evaluations.minimizerestarts eachstep, so there is repeated optimizer bookkeeping overhead.Key changes:
New Feature: Generic Scipy Minimize Generator
ScipyGeneratorinxopt.generators.sequential.scipy, providing a sequential ask/tell interface to anyscipy.optimize.minimizemethod. The generator bridges the difference between Xopt's external evaluation and scipy's in-process callable objective, including robust caching and replay logic.ScipyGeneratorcovering point generation, multiple point error handling, restart/serialization, and direct generator usage intest_scipy.py.ScipyGeneratorin the serialization test suite. [1] [2]Documentation & Examples
ScipyGeneratordescribing its integration model, performance considerations, and configuration indocs/api/generators/sequential/scipy.md.docs/examples/sequential/scipy.ipynbdemonstrating usage with the Rosenbrock function and showing convergence.mkdocs.ymlto include the new example and API documentation. [1] [2]Generator Registry & Import Refactoring
scipyas a generator name and addedScipyGeneratorto the dynamic generator import logic and__all__lists. [1] [2] [3]xopt/generators/scipy/__init__.pyand refactoredLatinHypercubeGeneratorimports for consistency. [1] [2]