Skip to content

Bayesian Optimization attempts for European XFEL tuning

Notifications You must be signed in to change notification settings

cr-xu/bo-4-euxfel

Repository files navigation

Bayesian Optimization attempts for European XFEL tuning

It reads the configuration from a dict or a json / yaml file and starts the Bayesian optimization.

Important notes for new BO Practitioner: The code in this repository serves as a good initial point to understand how BO can be implemented. For a more systematic and maintainable solution, we kindly refer to the Xopt package, which provides more BO variants and is designed to be a generic optimizer.

The results are published in the IPAC'23 proceeding: https://doi.org/10.18429/JACoW-IPAC-23-THPL028 (Pre-proceeding version)

Additional Notes

  • Currently a basic plotting is implemented in utils.plot_progress, but using it in VS-Code shows some flickering (see this issue), in plain jupyter notebook it works smoothly.
  • pydoocs require additional package jpeg that needs to be installed via conda conda install -c conda-forge jpeg.

Problem

The json configuration files contain the following tuning tasks

  • SASE1_CAX_CAY.json SASE1 tuning with undulator air coil correctors
  • SASE1_matching_quads.json SASE1 tuning with quadrupole magnets
  • SASE2_CAX_CAY.json, SASE2_CAX_CAY_Launch.json SASE2 tuning with air coil correctors
  • SASE2_matching_quads.json SASE2 tuning with quadrupole magnets

Repository Structure

  • simplebo.py Implements the basic BO logic
  • conf/*.json Configuration files for optimization tasks
    • test_rosenbrock.json A template for optimizating a test function
  • utils.py Utility functions, e.g. the proximial acquisition function implemented in Xopt

Usage

Installing Requirements

It is recommended to use a virtual environment, e.g. conda. With the environment activated, simply do

pip install -r requirements.txt

Using BO

(For pydoocs users): Simply define your problem in a json file structured as the Ocelot optimizer configuration. Load the config into the SimpleBO object and start with optimize.


Tasks

TODO:

  • Basic BO functionality
    • BO Loop
    • Basic logging
  • Advanced control:
    • Custom start condition: random initialization, start from current setting
    • Fine tuning the Acq, Prior...
    • Step size control: hard / proximal biasing
    • More information in the logging
  • Preliminary Tests:
    • BO test with simple mathematical functions
    • I/O test with pydoocs
    • Environment test on xfeluser server
    • (Check compatibility) Environment test on control room PCs
    • Provide a beam time note book with the defined procedures
  • Other features
    • live progress plot
  • (If enough time): try direct interface with Xopt, this will be a sustainable and more preferred way for productive tools.

About

Bayesian Optimization attempts for European XFEL tuning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published