Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4ce8d2c
initial commit
roussel-ryan Jun 4, 2026
5560ac4
add tests
roussel-ryan Jun 4, 2026
07d06a0
Update test_optimizer.py
roussel-ryan Jun 4, 2026
4535a86
linting
roussel-ryan Jun 4, 2026
217258a
linting
roussel-ryan Jun 4, 2026
67910a8
inline comments
roussel-ryan Jun 4, 2026
8ddcff0
refactor code to only define an XoptOptimizer class
roussel-ryan Jun 5, 2026
623bc88
linting
roussel-ryan Jun 5, 2026
f4c2849
solving pre-commit issues
roussel-ryan Jun 5, 2026
209b8b1
change code to native xopt vocs methods
roussel-ryan Jun 5, 2026
c4348a8
remove python 3.10
roussel-ryan Jun 5, 2026
75b0863
linting
roussel-ryan Jun 5, 2026
4188b57
Update test_optimizer.py
roussel-ryan Jun 5, 2026
884543f
add tests for coverage
roussel-ryan Jun 8, 2026
72e0931
Merge remote-tracking branch 'upstream/main' into xopt
roussel-ryan Jun 16, 2026
d7cd2e9
Update pyproject.toml
roussel-ryan Jun 16, 2026
6ccf069
linting
roussel-ryan Jun 16, 2026
461dd96
create RunEngine test and random initial point generation
roussel-ryan Jul 2, 2026
d706e19
remove fixed parameters in favor of VOCS constants
roussel-ryan Jul 2, 2026
9b92a91
utilize pydantic serialization, fix ingest append/insert issues
roussel-ryan Jul 2, 2026
071415f
code simplification /modernization
roussel-ryan Jul 2, 2026
3ed87b8
additional code simplification
roussel-ryan Jul 2, 2026
6796670
linting
roussel-ryan Jul 2, 2026
c353a7a
Update xrt-kb-mirrors.md
roussel-ryan Jul 2, 2026
815871a
Update src/blop/__init__.py
thopkins32 Jul 9, 2026
a788fb3
Update src/blop/__init__.py
thopkins32 Jul 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions docs/source/tutorials/xrt-kb-mirrors.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,77 @@ plt.title("Optimized KB Mirror Beam")
plt.show()
```

## Solving the Same Problem with XoptOptimizer

Blop also supports Xopt through `XoptOptimizer`, which plugs directly into the
same `optimize` plan used throughout the package. This gives you a lower-level
optimization interface while reusing the same devices, acquisition flow, and
evaluation function from above.

For this section, we keep the exact same objective and constraint:

- Minimize `fwhm`
- Require `intensity >= 10000`

```{code-cell} ipython3
from xopt.generators.bayesian import ExpectedImprovementGenerator
from xopt.vocs import VOCS

from blop.plans import optimize
from blop.protocols import OptimizationProblem
from blop.xopt.optimizer import XoptOptimizer
```

Define the Xopt search space (`VOCS`) from the same mirror bounds and outcome names used earlier:

```{code-cell} ipython3
xopt_vocs = VOCS(
variables={
kbv.radius.name: list(VERTICAL_BOUNDS),
kbh.radius.name: list(HORIZONTAL_BOUNDS),
},
objectives={"fwhm": "MINIMIZE"},
constraints={"intensity": ["GREATER_THAN", 10000.0]},
)

xopt_optimizer = XoptOptimizer(generator=ExpectedImprovementGenerator(vocs=xopt_vocs))

xopt_problem = OptimizationProblem(
optimizer=xopt_optimizer,
actuators=[kbv.radius, kbh.radius],
sensors=[det],
evaluation_function=DetectorEvaluation(tiled_client),
)
```

Run an optimization loop. As with the Ax-based flow, this is executed via the Bluesky `RunEngine`.

```{code-cell} ipython3
RE(optimize(xopt_problem, iterations=10, n_points=1))
```

Visualize the GP model learned by the Xopt generator:

```{code-cell} ipython3
fig, _ = xopt_optimizer.generator.visualize_model(
output_names=["fwhm"],
variable_names=[kbv.radius.name, kbh.radius.name],
show_feasibility=True,
)
plt.show()
```

Inspect the best point found by Xopt and the collected trial data:

```{code-cell} ipython3
xopt_best_points = xopt_optimizer.get_best_points()
xopt_best_points
```

```{code-cell} ipython3
xopt_optimizer.generator.data.tail()
```

```{code-cell} ipython3
tiled_server.close()
```
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ dynamic = ["version"]
[project.optional-dependencies]
ax = ["ax-platform>=1.3.0,<1.4", "botorch>=0.18.0,<0.19.0", "gpytorch", "torch"]
queueserver = ["bluesky-queueserver-api"]
all = ["blop[ax,queueserver]"]
xopt = ["xopt>3.0.0"]
all = ["blop[ax,queueserver,xopt]"]
dev = [
"pytest",
"pytest-cov",
Expand Down
Loading
Loading