Demonstrating “Bring Your Own Beamline” simulation with XRT#

In this tutorial we’ll show a simulation optimization workflow by loading arbitrary XRT setups using xml/json. By the end, you should be able to go to XRT qook/glow and build your beamline from there to export and drop in to Bluesky Adaptive. Or if you are lucky enough for an XRT model to be already built for you, export to xml and load in Bluesky Adaptive.

Some Environment Setup#

note, like all other demos you need the bluesky_adaptive_sim subpackage to run

import logging
import warnings

import matplotlib.pyplot as plt
import numpy as np
from bluesky.callbacks.best_effort import BestEffortCallback

# Import simulation devices (requires: pip install -e sim/)
from bluesky.run_engine import RunEngine
from bluesky.utils import ProgressBarManager
from bluesky_tiled_plugins import TiledWriter
from tiled.client import from_uri  # type: ignore[import-untyped]
from tiled.client.container import Container
from tiled.server import SimpleTiledServer

from bluesky_adaptive.ax import Agent, Objective, RangeDOF
from bluesky_adaptive.protocols import EvaluationFunction
from bluesky_adaptive_sim.backends import XRTBackend
from bluesky_adaptive_sim.devices.xrt import infer_detectors, infer_variables

# Suppress noisy logs from httpx and dependency deprecation warnings
logging.getLogger("httpx").setLevel(logging.WARNING)
warnings.filterwarnings("ignore", category=FutureWarning)

# Enable interactive plotting
plt.ion()

DETECTOR_STORAGE = "/tmp/bluesky-adaptive/sim"
/home/runner/work/bluesky-adaptive/bluesky-adaptive/.pixi/envs/docs/lib/python3.13/site-packages/torch/jit/_script.py:1491: FutureWarning: `torch.jit.script` is deprecated. Please switch to `torch.compile` or `torch.export`.
  warnings.warn(
[INFO 10-26 21:34:31] ax.storage.sqa_store.with_db_settings_base: Ax SQL storage initialized with SQLAlchemy 2.0.55
fileName = r"toroid_focus.xml"
beam = XRTBackend(file=fileName)
dets = infer_detectors(beam)
motors = infer_variables(beam, filter_for=None)
created inferred variable toroid_focus:screen01:center:z of float type as value is None or auto.
                Be careful when setting this variable as the type is guessed as float by default.

A small view of the inferred motors#

for name, element in motors.items():
    print(name)
    for nm, motor in element.items():
        print(f"{nm} : {motor}")
bendingMagnet01
B0 : <InferredVariable::toroid_focus:bendingMagnet01:B0=<class 'float'>:1.0>
rho : <InferredVariable::toroid_focus:bendingMagnet01:rho=<class 'float'>:10.00692285594456>
toroidMirror01
R : <InferredVariable::toroid_focus:toroidMirror01:R=<class 'float'>:152982.84327559808>
r : <InferredVariable::toroid_focus:toroidMirror01:r=<class 'float'>:1162.0765699687756>
screen01
center:x : <InferredVariable::toroid_focus:screen01:center:x=<class 'int'>:0>
center:y : <InferredVariable::toroid_focus:screen01:center:y=<class 'int'>:30000>
center:z : <InferredVariable::toroid_focus:screen01:center:z=<class 'float'>:auto>
x:x : <InferredVariable::toroid_focus:screen01:x:x=<class 'float'>:1.0>
x:y : <InferredVariable::toroid_focus:screen01:x:y=<class 'float'>:-0.0>
x:z : <InferredVariable::toroid_focus:screen01:x:z=<class 'float'>:0.0>
z:x : <InferredVariable::toroid_focus:screen01:z:x=<class 'float'>:0.0>
z:y : <InferredVariable::toroid_focus:screen01:z:y=<class 'float'>:0.0>
z:z : <InferredVariable::toroid_focus:screen01:z:z=<class 'float'>:1.0>

Another glimpse into the inferred detectors#

for name, det in dets.items():
    print(f"{name} : {det}")
bendingMagnet01 : <bluesky_adaptive_sim.devices.xrt.auto_element.InferredDetector object at 0x7f62a04c7620>
toroidMirror01 : <bluesky_adaptive_sim.devices.xrt.auto_element.InferredDetector object at 0x7f62a04ab250>
screen01 : <bluesky_adaptive_sim.devices.xrt.auto_element.InferredDetector object at 0x7f62a04ab390>

Setting up an optimization#

toro_R = motors["toroidMirror01"]["R"]
toro_R.alias = "big_r"
toro_r = motors["toroidMirror01"]["r"]

screen = dets["screen01"]
screen.set_primary()


VERTICAL_BOUNDS = (toro_R.val - 15000, toro_R.val + 15000)
HORIZONTAL_BOUNDS = (toro_r.val - 500, toro_r.val + 500)
# Define DOFs using mirror radius signals
dofs = [
    RangeDOF(actuator=toro_R, bounds=VERTICAL_BOUNDS, parameter_type="float"),
    RangeDOF(actuator=toro_r, bounds=HORIZONTAL_BOUNDS, parameter_type="float"),
]
tiled_server = SimpleTiledServer()
tiled_client = from_uri(tiled_server.uri)
tiled_writer = TiledWriter(tiled_client)

RE = RunEngine({})
bec = BestEffortCallback()

# Send all metadata/data captured to the BestEffortCallback.
# RE.subscribe(bec)
RE.waiting_hook = ProgressBarManager()

tiled_client = from_uri(tiled_server.uri)
tiled_writer = TiledWriter(tiled_client)
RE.subscribe(tiled_writer)
0
# Single objective: minimize the geometric-mean FWHM
objectives = [
    Objective(name="fwhm", minimize=True),
]
from collections.abc import Mapping, Sequence

class DetectorEvaluation(EvaluationFunction):
    def __init__(self, tiled_client: Container):
        self.tiled_client = tiled_client

    def _fwhm_from_profile(self, profile: np.ndarray) -> float:
        """Compute FWHM from a 1D marginal profile.

        Finds the half-maximum crossing points with sub-pixel interpolation.
        Returns a large value if the beam is too dim or fills the entire detector.
        """
        peak = profile.max()
        if peak == 0:
            return float(len(profile))  # No signal — return detector width as penalty

        half_max = peak / 2.0
        above = profile >= half_max
        if not above.any():
            return float(len(profile))

        indices = np.where(above)[0]
        left_idx = indices[0]
        right_idx = indices[-1]

        # Sub-pixel interpolation at left crossing
        if left_idx > 0:
            left = left_idx - 1 + (half_max - profile[left_idx - 1]) / (profile[left_idx] - profile[left_idx - 1])
        else:
            left = 0.0

        # Sub-pixel interpolation at right crossing
        if right_idx < len(profile) - 1:
            right = right_idx + (half_max - profile[right_idx]) / (profile[right_idx + 1] - profile[right_idx])
        else:
            right = float(len(profile) - 1)

        return right - left

    def _compute_stats(self, image: np.ndarray) -> tuple[float, float]:
        """Compute FWHM and integrated intensity from a beam image.

        Returns
        -------
        fwhm : float
            Geometric mean of the horizontal and vertical FWHM (in pixels).
        intensity : float
            Total integrated intensity (sum of all pixel values).
        """
        gray = image.squeeze().astype(np.float64)
        if gray.ndim == 3:
            gray = gray.mean(axis=-1)

        # Integrated intensity (total flux on detector)
        intensity = gray.sum()

        if intensity == 0:
            return 400.0, 0.0  # No beam — return max FWHM penalty

        # Marginal profiles: project onto each axis
        x_profile = gray.sum(axis=0)  # sum along Y rows -> X profile
        y_profile = gray.sum(axis=1)  # sum along X cols -> Y profile

        fwhm_x = self._fwhm_from_profile(x_profile)
        fwhm_y = self._fwhm_from_profile(y_profile)

        # Geometric mean FWHM — targets a small, round spot
        fwhm = np.sqrt(fwhm_x * fwhm_y)

        return float(fwhm), float(intensity)

    def __call__(self, uid: str, suggestions: Sequence[Mapping]) -> Sequence[Mapping]:
        outcomes = []
        run = self.tiled_client[uid]

        # Read beam images from detector
        images = run[f"primary/{screen.name}"].read()

        # These IDs, not positions in suggestions, are ordered to match acquired images.
        acquisition_order = run.metadata["start"]["blop_acquisition_order"]

        # Compute statistics from each image
        for idx, suggestion_id in enumerate(acquisition_order):
            image = images[idx]
            fwhm, intensity = self._compute_stats(image)

            outcome = {
                "_id": suggestion_id,
                "fwhm": fwhm,
                # "intensity": intensity,
            }
            outcomes.append(outcome)
        return outcomes
agent = Agent(
    sensors=[screen],
    dofs=dofs,
    objectives=objectives,
    evaluation_function=DetectorEvaluation(tiled_client),
    name="xrt-bluesky-adaptive-demo",
    description="A demo of the Bluesky Adaptive agent with XRT simulated beamline",
)
# Run 1 iteration with a batch of 10 points for initial exploration
RE(agent.optimize(1, n_points=10))
╭───────────────────────────────────────────────── Optimization ──────────────────────────────────────────────────╮
│ Optimizer  AxOptimizer                                                                                          │
│ Actuators  big_r, toroid_focus:toroidMirror01:r                                                                 │
│ Sensors    screen01                                                                                             │
│ Iterations 1  Points/iter 10                                                                                    │
│ Run UID    65a44d3a-68fc-4013-81a4-244440aed880                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
125077 rays of 500000
250518 rays of 500000
375235 rays of 500000
499998 rays of 500000
625605 rays of 500000
screen01
center:
[0.0, 30000.0, 1763.26063213065]
[INFO 10-26 21:34:36] ax.api.client: GenerationStrategy(name='Center+Sobol+MBM:fast', nodes=[CenterGenerationNode(next_node_name='Sobol', use_existing_trials_for_initialization=True), GenerationNode(name='Sobol', generator_specs=[GeneratorSpec(generator_enum=Sobol, generator_key_override=None)], transition_criteria=[MinTrials(transition_to='MBM'), MinTrials(transition_to='MBM')], suggested_experiment_status=ExperimentStatus.INITIALIZATION, pausing_criteria=[MaxTrialsAwaitingData(threshold=5)]), GenerationNode(name='MBM', generator_specs=[GeneratorSpec(generator_enum=BoTorch, generator_key_override=None)], transition_criteria=None, suggested_experiment_status=ExperimentStatus.OPTIMIZATION, pausing_criteria=None)]) chosen based on user input and problem structure.
[INFO 10-26 21:34:36] ax.api.client: Generated new trial 0 with parameters {'big_r': 152982.843276, 'toroid_focus:toroidMirror01:r': 1162.07657} using GenerationNode CenterOfSearchSpace.
[INFO 10-26 21:34:36] ax.api.client: Generated new trial 1 with parameters {'big_r': 150408.231969, 'toroid_focus:toroidMirror01:r': 1647.62} using GenerationNode Sobol.
[INFO 10-26 21:34:36] ax.api.client: Generated new trial 2 with parameters {'big_r': 158880.774499, 'toroid_focus:toroidMirror01:r': 1144.90698} using GenerationNode Sobol.
[INFO 10-26 21:34:36] ax.api.client: Generated new trial 3 with parameters {'big_r': 163631.489332, 'toroid_focus:toroidMirror01:r': 1378.602872} using GenerationNode Sobol.
[INFO 10-26 21:34:36] ax.api.client: Generated new trial 4 with parameters {'big_r': 138282.114239, 'toroid_focus:toroidMirror01:r': 852.38515} using GenerationNode Sobol.
[INFO 10-26 21:34:36] ax.api.client: Generated new trial 5 with parameters {'big_r': 144139.712024, 'toroid_focus:toroidMirror01:r': 1247.423026} using GenerationNode Sobol.
[INFO 10-26 21:34:36] ax.api.client: Generated new trial 6 with parameters {'big_r': 165739.093879, 'toroid_focus:toroidMirror01:r': 732.619339} using GenerationNode Sobol.
[INFO 10-26 21:34:36] ax.api.client: Generated new trial 7 with parameters {'big_r': 153488.26589, 'toroid_focus:toroidMirror01:r': 1533.102956} using GenerationNode Sobol.
[INFO 10-26 21:34:36] ax.api.client: Generated new trial 8 with parameters {'big_r': 148765.713581, 'toroid_focus:toroidMirror01:r': 1010.430996} using GenerationNode Sobol.
[INFO 10-26 21:34:36] ax.api.client: Generated new trial 9 with parameters {'big_r': 146477.294117, 'toroid_focus:toroidMirror01:r': 1341.131407} using GenerationNode Sobol.
[INFO 10-26 21:35:01] ax.api.client: Trial 0 marked COMPLETED.
[INFO 10-26 21:35:01] ax.api.client: Trial 7 marked COMPLETED.
[INFO 10-26 21:35:01] ax.api.client: Trial 1 marked COMPLETED.
[INFO 10-26 21:35:01] ax.api.client: Trial 8 marked COMPLETED.
[INFO 10-26 21:35:01] ax.api.client: Trial 9 marked COMPLETED.
[INFO 10-26 21:35:01] ax.api.client: Trial 5 marked COMPLETED.
[INFO 10-26 21:35:01] ax.api.client: Trial 4 marked COMPLETED.
[INFO 10-26 21:35:01] ax.api.client: Trial 2 marked COMPLETED.
[INFO 10-26 21:35:01] ax.api.client: Trial 3 marked COMPLETED.
[INFO 10-26 21:35:01] ax.api.client: Trial 6 marked COMPLETED.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Suggestion ID              ┃ big_r                      ┃ toroid_focus:toroidMirro… ┃ fwhm                      ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
└────────────────────────────┴────────────────────────────┴───────────────────────────┴───────────────────────────┘
┃                            ┃                            ┃                           ┃                           ┃
┃ 0                          ┃                     152983 ┃                   1162.08 ┃                   41.5468 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 1                          ┃                     150408 ┃                   1647.62 ┃                   47.9782 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 2                          ┃                     158881 ┃                   1144.91 ┃                    60.536 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 3                          ┃                     163631 ┃                    1378.6 ┃                   63.3483 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 4                          ┃                     138282 ┃                   852.385 ┃                   19.9809 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
───────────────────────────────────────────────── Iteration 1 / 1 ─────────────────────────────────────────────────
  fwhm  min: 19.9809  max: 63.3483  mean: 46.678
  (5 pts sampled)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┃                            ┃                            ┃                           ┃                           ┃
┃ 5                          ┃                     144140 ┃                   1247.42 ┃                   14.3631 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 6                          ┃                     165739 ┃                   732.619 ┃                   56.2448 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 7                          ┃                     153488 ┃                    1533.1 ┃                   82.5546 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 8                          ┃                     148766 ┃                   1010.43 ┃                   17.1926 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 9                          ┃                     146477 ┃                   1341.13 ┃                   20.5228 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
───────────────────────────────────────────────── Iteration 1 / 1 ─────────────────────────────────────────────────
  fwhm  min: 14.3631  max: 82.5546  mean: 42.4268
  (10 pts sampled)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────

                                    Summary Statistics                                     
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━┓
┃ Name                          ┃ Type    ┃     Min ┃     Max ┃    Mean ┃     Std ┃ Count ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━┩
│ big_r                         │ param   │  138282 │  165739 │  152280 │ 8610.44 │    10 │
│ toroid_focus:toroidMirror01:r │ param   │ 732.619 │ 1647.62 │ 1205.03 │ 287.677 │    10 │
│ fwhm                          │ outcome │ 14.3631 │ 82.5546 │ 42.4268 │ 23.5852 │    10 │
└───────────────────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────┘
────────────────────────────────────────────── Optimization Complete ──────────────────────────────────────────────
('65a44d3a-68fc-4013-81a4-244440aed880',
 '12f17437-c460-4dd7-8c92-c95db538ce3f')
# Run more iterations
RE(agent.optimize(5, n_points=5))
╭───────────────────────────────────────────────── Optimization ──────────────────────────────────────────────────╮
│ Optimizer  AxOptimizer                                                                                          │
│ Actuators  big_r, toroid_focus:toroidMirror01:r                                                                 │
│ Sensors    screen01                                                                                             │
│ Iterations 5 more (1 completed, 6 total)  Points/iter 5                                                         │
│ Run UID    ce2b43d5-8baf-4a8e-bb44-a3fa19c516cb                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
[INFO 10-26 21:35:07] ax.api.client: Generated new trial 10 with parameters {'big_r': 143017.484449, 'toroid_focus:toroidMirror01:r': 1662.07657} using GenerationNode MBM.
[INFO 10-26 21:35:07] ax.api.client: Generated new trial 11 with parameters {'big_r': 143732.333732, 'toroid_focus:toroidMirror01:r': 1017.719899} using GenerationNode MBM.
[INFO 10-26 21:35:07] ax.api.client: Generated new trial 12 with parameters {'big_r': 137982.843276, 'toroid_focus:toroidMirror01:r': 1205.528692} using GenerationNode MBM.
[INFO 10-26 21:35:07] ax.api.client: Generated new trial 13 with parameters {'big_r': 143544.590744, 'toroid_focus:toroidMirror01:r': 662.07657} using GenerationNode MBM.
[INFO 10-26 21:35:07] ax.api.client: Generated new trial 14 with parameters {'big_r': 152708.085767, 'toroid_focus:toroidMirror01:r': 690.891477} using GenerationNode MBM.
[INFO 10-26 21:35:18] ax.api.client: Trial 14 marked COMPLETED.
[INFO 10-26 21:35:18] ax.api.client: Trial 11 marked COMPLETED.
[INFO 10-26 21:35:18] ax.api.client: Trial 13 marked COMPLETED.
[INFO 10-26 21:35:18] ax.api.client: Trial 10 marked COMPLETED.
[INFO 10-26 21:35:18] ax.api.client: Trial 12 marked COMPLETED.
[INFO 10-26 21:35:24] ax.api.client: Generated new trial 15 with parameters {'big_r': 137982.843276, 'toroid_focus:toroidMirror01:r': 1662.07657} using GenerationNode MBM.
[INFO 10-26 21:35:24] ax.api.client: Generated new trial 16 with parameters {'big_r': 142521.08479, 'toroid_focus:toroidMirror01:r': 1483.98577} using GenerationNode MBM.
[INFO 10-26 21:35:24] ax.api.client: Generated new trial 17 with parameters {'big_r': 144435.487063, 'toroid_focus:toroidMirror01:r': 1662.07657} using GenerationNode MBM.
[INFO 10-26 21:35:24] ax.api.client: Generated new trial 18 with parameters {'big_r': 146767.941973, 'toroid_focus:toroidMirror01:r': 800.073551} using GenerationNode MBM.
[INFO 10-26 21:35:24] ax.api.client: Generated new trial 19 with parameters {'big_r': 137982.843276, 'toroid_focus:toroidMirror01:r': 1542.15134} using GenerationNode MBM.
[INFO 10-26 21:35:35] ax.api.client: Trial 19 marked COMPLETED.
[INFO 10-26 21:35:35] ax.api.client: Trial 15 marked COMPLETED.
[INFO 10-26 21:35:35] ax.api.client: Trial 16 marked COMPLETED.
[INFO 10-26 21:35:35] ax.api.client: Trial 17 marked COMPLETED.
[INFO 10-26 21:35:35] ax.api.client: Trial 18 marked COMPLETED.
/home/runner/work/bluesky-adaptive/bluesky-adaptive/.pixi/envs/docs/lib/python3.13/site-packages/linear_operator/utils/cholesky.py:41: NumericalWarning: A not p.d., added jitter of 1.0e-08 to the diagonal
  warnings.warn(
[INFO 10-26 21:35:41] ax.api.client: Generated new trial 20 with parameters {'big_r': 139739.236147, 'toroid_focus:toroidMirror01:r': 662.07657} using GenerationNode MBM.
[INFO 10-26 21:35:41] ax.api.client: Generated new trial 21 with parameters {'big_r': 142082.602807, 'toroid_focus:toroidMirror01:r': 1240.200781} using GenerationNode MBM.
[INFO 10-26 21:35:41] ax.api.client: Generated new trial 22 with parameters {'big_r': 167982.843276, 'toroid_focus:toroidMirror01:r': 1662.07657} using GenerationNode MBM.
[INFO 10-26 21:35:41] ax.api.client: Generated new trial 23 with parameters {'big_r': 141891.628022, 'toroid_focus:toroidMirror01:r': 1662.07657} using GenerationNode MBM.
[INFO 10-26 21:35:41] ax.api.client: Generated new trial 24 with parameters {'big_r': 141854.367334, 'toroid_focus:toroidMirror01:r': 880.362712} using GenerationNode MBM.
[INFO 10-26 21:35:52] ax.api.client: Trial 21 marked COMPLETED.
[INFO 10-26 21:35:52] ax.api.client: Trial 24 marked COMPLETED.
[INFO 10-26 21:35:52] ax.api.client: Trial 20 marked COMPLETED.
[INFO 10-26 21:35:52] ax.api.client: Trial 23 marked COMPLETED.
[INFO 10-26 21:35:52] ax.api.client: Trial 22 marked COMPLETED.
[INFO 10-26 21:35:59] ax.api.client: Generated new trial 25 with parameters {'big_r': 141157.352596, 'toroid_focus:toroidMirror01:r': 1662.07657} using GenerationNode MBM.
[INFO 10-26 21:35:59] ax.api.client: Generated new trial 26 with parameters {'big_r': 141037.320745, 'toroid_focus:toroidMirror01:r': 1496.198208} using GenerationNode MBM.
[INFO 10-26 21:35:59] ax.api.client: Generated new trial 27 with parameters {'big_r': 141052.424176, 'toroid_focus:toroidMirror01:r': 1238.382212} using GenerationNode MBM.
[INFO 10-26 21:35:59] ax.api.client: Generated new trial 28 with parameters {'big_r': 158358.762625, 'toroid_focus:toroidMirror01:r': 662.07657} using GenerationNode MBM.
[INFO 10-26 21:35:59] ax.api.client: Generated new trial 29 with parameters {'big_r': 141496.078239, 'toroid_focus:toroidMirror01:r': 1662.07657} using GenerationNode MBM.
[INFO 10-26 21:36:10] ax.api.client: Trial 28 marked COMPLETED.
[INFO 10-26 21:36:10] ax.api.client: Trial 29 marked COMPLETED.
[INFO 10-26 21:36:10] ax.api.client: Trial 25 marked COMPLETED.
[INFO 10-26 21:36:10] ax.api.client: Trial 26 marked COMPLETED.
[INFO 10-26 21:36:10] ax.api.client: Trial 27 marked COMPLETED.
[INFO 10-26 21:36:18] ax.api.client: Generated new trial 30 with parameters {'big_r': 140762.875995, 'toroid_focus:toroidMirror01:r': 1360.799098} using GenerationNode MBM.
[INFO 10-26 21:36:18] ax.api.client: Generated new trial 31 with parameters {'big_r': 159513.660312, 'toroid_focus:toroidMirror01:r': 1662.07657} using GenerationNode MBM.
[INFO 10-26 21:36:18] ax.api.client: Generated new trial 32 with parameters {'big_r': 140710.073323, 'toroid_focus:toroidMirror01:r': 1277.135536} using GenerationNode MBM.
[INFO 10-26 21:36:18] ax.api.client: Generated new trial 33 with parameters {'big_r': 140867.180613, 'toroid_focus:toroidMirror01:r': 1662.07657} using GenerationNode MBM.
[INFO 10-26 21:36:18] ax.api.client: Generated new trial 34 with parameters {'big_r': 140600.327434, 'toroid_focus:toroidMirror01:r': 1474.356716} using GenerationNode MBM.
[INFO 10-26 21:36:29] ax.api.client: Trial 30 marked COMPLETED.
[INFO 10-26 21:36:29] ax.api.client: Trial 32 marked COMPLETED.
[INFO 10-26 21:36:29] ax.api.client: Trial 34 marked COMPLETED.
[INFO 10-26 21:36:29] ax.api.client: Trial 33 marked COMPLETED.
[INFO 10-26 21:36:29] ax.api.client: Trial 31 marked COMPLETED.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Suggestion ID              ┃ big_r                      ┃ toroid_focus:toroidMirro… ┃ fwhm                      ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
└────────────────────────────┴────────────────────────────┴───────────────────────────┴───────────────────────────┘
┃                            ┃                            ┃                           ┃                           ┃
┃ 10                         ┃                     143017 ┃                   1662.08 ┃                   11.9597 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 11                         ┃                     143732 ┃                   1017.72 ┃                    13.709 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 12                         ┃                     137983 ┃                   1205.53 ┃                   18.4875 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 13                         ┃                     143545 ┃                   662.077 ┃                   16.5686 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 14                         ┃                     152708 ┃                   690.891 ┃                   27.0838 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
───────────────────────────────────────────────── Iteration 2 / 6 ─────────────────────────────────────────────────
  fwhm  min: 11.9597  max: 82.5546  mean: 34.1384
  (15 pts sampled)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┃                            ┃                            ┃                           ┃                           ┃
┃ 15                         ┃                     137983 ┃                   1662.08 ┃                   18.3734 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 16                         ┃                     142521 ┃                   1483.99 ┃                   12.4065 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 17                         ┃                     144435 ┃                   1662.08 ┃                   14.6948 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 18                         ┃                     146768 ┃                   800.074 ┃                   20.7041 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 19                         ┃                     137983 ┃                   1542.15 ┃                   18.7392 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
───────────────────────────────────────────────── Iteration 3 / 6 ─────────────────────────────────────────────────
  fwhm  min: 11.9597  max: 82.5546  mean: 29.8497
  (20 pts sampled)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┃                            ┃                            ┃                           ┃                           ┃
┃ 20                         ┃                     139739 ┃                   662.077 ┃                   18.0605 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 21                         ┃                     142083 ┃                    1240.2 ┃                   11.4168 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 22                         ┃                     167983 ┃                   1662.08 ┃                   62.0293 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 23                         ┃                     141892 ┃                   1662.08 ┃                    9.6232 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 24                         ┃                     141854 ┃                   880.363 ┃                   14.2929 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
───────────────────────────────────────────────── Iteration 4 / 6 ─────────────────────────────────────────────────
  fwhm  min: 9.6232  max: 82.5546  mean: 28.4967
  (25 pts sampled)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┃                            ┃                            ┃                           ┃                           ┃
┃ 25                         ┃                     141157 ┃                   1662.08 ┃                   10.1114 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 26                         ┃                     141037 ┃                    1496.2 ┃                   10.0838 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 27                         ┃                     141052 ┃                   1238.38 ┃                   10.0714 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 28                         ┃                     158359 ┃                   662.077 ┃                   23.1775 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 29                         ┃                     141496 ┃                   1662.08 ┃                   9.79146 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
───────────────────────────────────────────────── Iteration 5 / 6 ─────────────────────────────────────────────────
  fwhm  min: 9.6232  max: 82.5546  mean: 25.8551
  (30 pts sampled)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┃                            ┃                            ┃                           ┃                           ┃
┃ 30                         ┃                     140763 ┃                    1360.8 ┃                   13.2287 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 31                         ┃                     159514 ┃                   1662.08 ┃                    65.356 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 32                         ┃                     140710 ┃                   1277.14 ┃                   10.9102 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 33                         ┃                     140867 ┃                   1662.08 ┃                   10.5498 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
┃                            ┃                            ┃                           ┃                           ┃
┃ 34                         ┃                     140600 ┃                   1474.36 ┃                   10.4575 ┃
┡────────────────────────────╇────────────────────────────╇───────────────────────────╇───────────────────────────┩
───────────────────────────────────────────────── Iteration 6 / 6 ─────────────────────────────────────────────────
  fwhm  min: 9.6232  max: 82.5546  mean: 25.3187
  (35 pts sampled)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────

                                    Summary Statistics                                     
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━┓
┃ Name                          ┃ Type    ┃     Min ┃     Max ┃    Mean ┃     Std ┃ Count ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━┩
│ big_r                         │ param   │  137983 │  167983 │  146645 │  8455.8 │    35 │
│ toroid_focus:toroidMirror01:r │ param   │ 662.077 │ 1662.08 │ 1277.23 │ 354.642 │    35 │
│ fwhm                          │ outcome │  9.6232 │ 82.5546 │ 25.3187 │ 20.3383 │    35 │
└───────────────────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────┘
────────────────────────────────────────────── Optimization Complete ──────────────────────────────────────────────
('ce2b43d5-8baf-4a8e-bb44-a3fa19c516cb',
 '0ff568b3-2527-4c8e-b8d5-8979107dcf47',
 'ee9052e2-0a98-4e89-be71-07455ebdfd5e',
 'f3ffc359-38e0-4339-8cc7-b86fe8a0dd30',
 'e552fc9d-dfe2-41b3-bd13-ba23c0e09970',
 'f6e0d6f2-812c-47ed-8e7f-c04566bf8f00')
_ = agent.ax_client.compute_analyses()
[ERROR 10-26 21:36:31] ax.core.experiment: Encountered ValueError Data to attach is empty. while attaching results. Proceeding and returning results fetched without attaching.
[ERROR 10-26 21:36:31] ax.core.experiment: Encountered ValueError Data to attach is empty. while attaching results. Proceeding and returning results fetched without attaching.
[ERROR 10-26 21:36:31] ax.core.experiment: Encountered ValueError Data to attach is empty. while attaching results. Proceeding and returning results fetched without attaching.
[ERROR 10-26 21:36:31] ax.core.experiment: Encountered ValueError Data to attach is empty. while attaching results. Proceeding and returning results fetched without attaching.
[ERROR 10-26 21:36:32] ax.core.experiment: Encountered ValueError Data to attach is empty. while attaching results. Proceeding and returning results fetched without attaching.
[ERROR 10-26 21:36:32] ax.core.experiment: Encountered ValueError Data to attach is empty. while attaching results. Proceeding and returning results fetched without attaching.
[ERROR 10-26 21:36:32] ax.core.experiment: Encountered ValueError Data to attach is empty. while attaching results. Proceeding and returning results fetched without attaching.
Overview of the Entire Optimization Process

This analysis provides an overview of the entire optimization process. It includes visualizations of the results obtained so far, insights into the parameter and metric relationships learned by the Ax model, diagnostics such as model fit, and health checks to assess the overall health of the experiment.

Results Analysis

Result Analyses provide a high-level overview of the results of the optimization process so far with respect to the metrics specified in experiment design.

Metric Effects: Predicted and observed effects for all arms in the experiment

These pair of plots visualize the metric effects for each arm, with the Ax model predictions on the left and the raw observed data on the right. The predicted effects apply shrinkage for noise and adjust for non-stationarity in the data, so they are more representative of the reproducible effects that will manifest in a long-term validation experiment.

Metric Effects Pair for fwhm

Modeled Arm Effects on fwhm
Modeled effects on fwhm. This plot visualizes predictions of the true metric changes for each arm based on Ax's model. This is the expected delta you would expect if you (re-)ran that arm. This plot helps in anticipating the outcomes and performance of arms based on the model's predictions. Note, flat predictions across arms indicate that the model predicts that there is no effect, meaning if you were to re-run the experiment, the delta you would see would be small and fall within the confidence interval indicated in the plot.
Observed Arm Effects on fwhm
Observed effects on fwhm. This plot visualizes the effects from previously-run arms on a specific metric, providing insights into their performance. This plot allows one to compare and contrast the effectiveness of different arms, highlighting which configurations have yielded the most favorable outcomes.
Utility Progression
Shows the best fwhm value achieved so far across completed trials (objective is to minimize). The x-axis shows trial index. Only completed or early-stopped trials with complete metric data are included, so there may be gaps if some trials failed, were abandoned, or have incomplete data. The y-axis shows cumulative best utility. Only improvements are plotted, so flat segments indicate trials that didn't surpass the previous best. Infeasible trials (violating outcome constraints) don't contribute to the improvements.
Best Trial for Experiment
Displays the trial with the best objective value based on raw observations. This reflects actual measured performance during execution. This trial achieved the optimal objective value and represents the recommended configuration for your optimization goal. Only considering COMPLETED trials.
trial_index arm_name trial_status generation_node fwhm big_r toroid_focus:toroidMirror01:r
0 23 23_0 COMPLETED MBM 9.623203 141891.628022 1662.07657
Summary for xrt-bluesky-adaptive-demo
High-level summary of the `Trial`-s in this `Experiment`
trial_index arm_name trial_status generation_node fwhm big_r toroid_focus:toroidMirror01:r
0 0 0_0 COMPLETED CenterOfSearchSpace 41.546757 152982.843276 1162.076570
1 1 1_0 COMPLETED Sobol 47.978207 150408.231969 1647.620000
2 2 2_0 COMPLETED Sobol 60.535959 158880.774499 1144.906980
3 3 3_0 COMPLETED Sobol 63.348301 163631.489332 1378.602872
4 4 4_0 COMPLETED Sobol 19.980852 138282.114239 852.385150
5 5 5_0 COMPLETED Sobol 14.363077 144139.712024 1247.423026
6 6 6_0 COMPLETED Sobol 56.244805 165739.093879 732.619339
7 7 7_0 COMPLETED Sobol 82.554569 153488.265890 1533.102956
8 8 8_0 COMPLETED Sobol 17.192602 148765.713581 1010.430996
9 9 9_0 COMPLETED Sobol 20.522807 146477.294117 1341.131407
10 10 10_0 COMPLETED MBM 11.959748 143017.484449 1662.076570
11 11 11_0 COMPLETED MBM 13.708976 143732.333732 1017.719899
12 12 12_0 COMPLETED MBM 18.487517 137982.843276 1205.528692
13 13 13_0 COMPLETED MBM 16.568590 143544.590744 662.076570
14 14 14_0 COMPLETED MBM 27.083768 152708.085767 690.891477
15 15 15_0 COMPLETED MBM 18.373387 137982.843276 1662.076570
16 16 16_0 COMPLETED MBM 12.406459 142521.084790 1483.985770
17 17 17_0 COMPLETED MBM 14.694823 144435.487063 1662.076570
18 18 18_0 COMPLETED MBM 20.704117 146767.941973 800.073551
19 19 19_0 COMPLETED MBM 18.739202 137982.843276 1542.151340
20 20 20_0 COMPLETED MBM 18.060464 139739.236147 662.076570
21 21 21_0 COMPLETED MBM 11.416825 142082.602807 1240.200781
22 22 22_0 COMPLETED MBM 62.029306 167982.843276 1662.076570
23 23 23_0 COMPLETED MBM 9.623203 141891.628022 1662.076570
24 24 24_0 COMPLETED MBM 14.292945 141854.367334 880.362712
25 25 25_0 COMPLETED MBM 10.111432 141157.352596 1662.076570
26 26 26_0 COMPLETED MBM 10.083761 141037.320745 1496.198208
27 27 27_0 COMPLETED MBM 10.071363 141052.424176 1238.382212
28 28 28_0 COMPLETED MBM 23.177547 158358.762625 662.076570
29 29 29_0 COMPLETED MBM 9.791459 141496.078239 1662.076570
30 30 30_0 COMPLETED MBM 13.228698 140762.875995 1360.799098
31 31 31_0 COMPLETED MBM 65.355969 159513.660312 1662.076570
32 32 32_0 COMPLETED MBM 10.910181 140710.073323 1277.135536
33 33 33_0 COMPLETED MBM 10.549800 140867.180613 1662.076570
34 34 34_0 COMPLETED MBM 10.457468 140600.327434 1474.356716
Insights Analysis

Insight Analyses display information to help understand the underlying experiment i.e parameter and metric relationships learned by the Ax model.Use this information to better understand your experiment space and users.

Top Surfaces Analysis: Parameter sensitivity, slice, and contour plots

The top surfaces analysis displays three analyses in one. First, it shows parameter sensitivities, which shows the sensitivity of the metrics in the experiment to the most important parameters. Subsetting to only the most important parameters, it then shows slice plots and contour plots for each metric in the experiment, displaying the relationship between the metric and the most important parameters.

Sensitivity Analysis for fwhm
Understand how each parameter affects fwhm according to a second-order sensitivity analysis.
Slice Plots: Metric effects by parameter value

These plots show the relationship between a metric and a parameter. They show the predicted values of the metric on the y-axis as a function of the parameter on the x-axis while keeping all other parameters fixed at their status_quo value (if available), best trial value, or the center of the search space.

fwhm vs. big_r
The slice plot provides a one-dimensional view of predicted outcomes for fwhm as a function of a single parameter, while keeping all other parameters fixed at their best trial value (Arm 29_0). This visualization helps in understanding the sensitivity and impact of changes in the selected parameter on the predicted metric outcomes.
fwhm vs. toroid_focus:toroidMirror01:r
The slice plot provides a one-dimensional view of predicted outcomes for fwhm as a function of a single parameter, while keeping all other parameters fixed at their best trial value (Arm 29_0). This visualization helps in understanding the sensitivity and impact of changes in the selected parameter on the predicted metric outcomes.
Contour Plots: Metric effects by parameter values

These plots show the relationship between a metric and two parameters. They show the predicted values of the metric (indicated by color) as a function of the two parameters on the x- and y-axes while keeping all other parameters fixed at their status_quo value (if available), best trial value, or the center of the search space.

fwhm (Mean) vs. big_r, toroid_focus:toroidMirror01:r
The contour plot visualizes the predicted outcomes for fwhm across a two-dimensional parameter space, with other parameters held fixed at their best trial value (Arm 29_0). This plot helps in identifying regions of optimal performance and understanding how changes in the selected parameters influence the predicted outcomes. Contour lines represent levels of constant predicted values, providing insights into the gradient and potential optima within the parameter space.
Diagnostic Analysis

Diagnostic Analyses provide information about the optimization process and the quality of the model fit. You can use this information to understand if the experimental design should be adjusted to improve optimization quality.

Cross Validation: Assessing model fit

Cross-validation plots display the model fit for each metric in the experiment. The model is trained on a subset of the data and then predicts the outcome for the remaining subset. The plots show the predicted outcome for the validation set on the y-axis against its actual value on the x-axis. Points that align closely with the dotted diagonal line indicate a strong model fit, signifying accurate predictions. Additionally, the plots include confidence intervals that provide insight into the noise in observations and the uncertainty in model predictions.

NOTE: A horizontal, flat line of predictions indicates that the model has not picked up on sufficient signal in the data, and instead is just predicting the mean.

Cross Validation for fwhm (R² = 0.78)
The cross-validation plot displays the model fit for each metric in the experiment. It employs a leave-one-out approach, where the model is trained on all data except one sample, which is used for validation. The plot shows the predicted outcome for the validation set on the y-axis against its actual value on the x-axis. Points that align closely with the dotted diagonal line indicate a strong model fit, signifying accurate predictions. Additionally, the plot includes 95% confidence intervals that provide insight into the noise in observations and the uncertainty in model predictions. A horizontal, flat line of predictions indicates that the model has not picked up on sufficient signal in the data, and instead is just predicting the mean.
Summary of model fits
R² (coefficient of determination) measures how well the model predicts each metric. Higher values indicate better model fit. Metrics with R² >= 0.1 are highlighted in green.
Generation Strategy Graph
GenerationStrategy: Center+Sobol+MBM:fast Visualize the structure of a GenerationStrategy as a directed graph. Each node represents a GenerationNode in the strategy, and edges represent transitions between nodes based on TransitionCriterion. Edge labels show the criterion class names that trigger the transition.
b'\n\n\n\n\n\nGenerationStrategy\n\n\n\nCenterOfSearchSpace\n\nCenterOfSearchSpace\n()\n\n\n\nSobol\n\nSobol\n\n\n\nCenterOfSearchSpace->Sobol\n\n\nAutoTransitionAfterGen\n\n\n\nMBM\n\nMBM\n(BoTorch)\n\n\n\nSobol->MBM\n\n\nMinTrials(5)\nMinTrials(2)\n\n\n\n'
Health Checks

Comprehensive health checks designed to identify potential issues in the Ax experiment. These checks cover areas such as metric fetching, search space configuration, and candidate generation, with the aim of flagging areas where user intervention may be necessary to ensure the experiment's robustness and success.

Baseline Improvement Healthcheck
All 1 objective(s) improved over baseline. **Metric `fwhm` improved 76.84%** from `41.55` in arm `'0_0'` to `9.62` in arm `'23_0'`. **Note:** Using the first trial's first arm ('0_0') as the baseline since no explicit baseline was provided.
Metric Status Details
0 fwhm Improved **Metric `fwhm` improved 76.84%** from `41.55` in arm `'0_0'` to `9.62` in arm `'23_0'`.
agent.ax_client.summarize()
trial_index arm_name trial_status generation_node fwhm big_r toroid_focus:toroidMirror01:r
0 0 0_0 COMPLETED CenterOfSearchSpace 41.546757 152982.843276 1162.076570
1 1 1_0 COMPLETED Sobol 47.978207 150408.231969 1647.620000
2 2 2_0 COMPLETED Sobol 60.535959 158880.774499 1144.906980
3 3 3_0 COMPLETED Sobol 63.348301 163631.489332 1378.602872
4 4 4_0 COMPLETED Sobol 19.980852 138282.114239 852.385150
5 5 5_0 COMPLETED Sobol 14.363077 144139.712024 1247.423026
6 6 6_0 COMPLETED Sobol 56.244805 165739.093879 732.619339
7 7 7_0 COMPLETED Sobol 82.554569 153488.265890 1533.102956
8 8 8_0 COMPLETED Sobol 17.192602 148765.713581 1010.430996
9 9 9_0 COMPLETED Sobol 20.522807 146477.294117 1341.131407
10 10 10_0 COMPLETED MBM 11.959748 143017.484449 1662.076570
11 11 11_0 COMPLETED MBM 13.708976 143732.333732 1017.719899
12 12 12_0 COMPLETED MBM 18.487517 137982.843276 1205.528692
13 13 13_0 COMPLETED MBM 16.568590 143544.590744 662.076570
14 14 14_0 COMPLETED MBM 27.083768 152708.085767 690.891477
15 15 15_0 COMPLETED MBM 18.373387 137982.843276 1662.076570
16 16 16_0 COMPLETED MBM 12.406459 142521.084790 1483.985770
17 17 17_0 COMPLETED MBM 14.694823 144435.487063 1662.076570
18 18 18_0 COMPLETED MBM 20.704117 146767.941973 800.073551
19 19 19_0 COMPLETED MBM 18.739202 137982.843276 1542.151340
20 20 20_0 COMPLETED MBM 18.060464 139739.236147 662.076570
21 21 21_0 COMPLETED MBM 11.416825 142082.602807 1240.200781
22 22 22_0 COMPLETED MBM 62.029306 167982.843276 1662.076570
23 23 23_0 COMPLETED MBM 9.623203 141891.628022 1662.076570
24 24 24_0 COMPLETED MBM 14.292945 141854.367334 880.362712
25 25 25_0 COMPLETED MBM 10.111432 141157.352596 1662.076570
26 26 26_0 COMPLETED MBM 10.083761 141037.320745 1496.198208
27 27 27_0 COMPLETED MBM 10.071363 141052.424176 1238.382212
28 28 28_0 COMPLETED MBM 23.177547 158358.762625 662.076570
29 29 29_0 COMPLETED MBM 9.791459 141496.078239 1662.076570
30 30 30_0 COMPLETED MBM 13.228698 140762.875995 1360.799098
31 31 31_0 COMPLETED MBM 65.355969 159513.660312 1662.076570
32 32 32_0 COMPLETED MBM 10.910181 140710.073323 1277.135536
33 33 33_0 COMPLETED MBM 10.549800 140867.180613 1662.076570
34 34 34_0 COMPLETED MBM 10.457468 140600.327434 1474.356716
optimal_parameters, metrics, _, _ = agent.ax_client.get_best_parameterization(use_model_predictions=False)
optimal_parameters
{'big_r': 141891.62802223567,
 'toroid_focus:toroidMirror01:r': 1662.0765699687756}
from bluesky.plans import list_scan

uid = RE(
    list_scan(
        [screen],
        toro_r,
        [optimal_parameters[toro_r.name]],
        toro_R,
        [optimal_parameters[toro_R.name]],
    )
)
image = tiled_client[uid[0]][f"primary/{screen.name}"].read().squeeze()
plt.imshow(image)
plt.colorbar()
plt.title("Optimized toroid Mirror Beam")
plt.show()