NSLS-II-PDF / mmm-experiments

Python package for running multimodal madness experiments with BMM
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Add EXAFS distance agent #1

Closed matthewcarbone closed 2 years ago

matthewcarbone commented 2 years ago

Added a dumb EXAFS agent. It can actually be applied to any vector intensity/observation. It works as follows: you give it one or more "phases" (reference spectra) and at every instance of taking a sample it takes the minimum distance of your observation to the reference spectra. To find "new phases", maximize this quantity.

@maffettone, unrelated, but I believe you have a bug in your current PDF agent. If batch_size is greater than 1 the analytic UCB acquisition function is going to fail. You need to use the q version here (see the EXAFS agent to see what I mean).

Also, please check out where I wrote TODO. These are areas I'm not (yet) familiar with 👍

maffettone commented 2 years ago

Good catch, you can tell I quickly put together something that worked, as opposed to something with tunable hyperparameters.

We can run down some of the TODOs a bit later, as most of those are beamline specific things (server locations, keywords for measurement plans to push to the servers).

I have assumed the sample_origin to be the (x,y) origin of the motors that control sample position. These are the values we can grab from the meta data, but the agent will be more interested in relative positions. Kept the y in there for alignment purposes and rich metadata.

The reason for returning a full doc is similar. We want rich meta data. That doc will be unpacked and published to a database (complexity tba) during an experimental run. Should the agent crash, network fail, or you decide to change hyperparameters, this gives you an opportunity to reload previous data and any visualization. It also gives a concrete record to replay the actions and thoughts of an agent for visualization in posterity (shiny gifs for presentations etc). Lastly it fully separates the actions of the agent and anything that depends on the agent (i.e. plotting or collaborative agents).