In materials science, evaluating a candidate material (composition, processing parameters, microstructure choices) can be expensive:
- time-consuming lab experiments
- costly characterization and synthesis
- limited throughput
Because each “experiment” costs a lot, we want to pick the next experiment intelligently rather than sampling randomly.
This project simulates that idea using Bayesian Optimization (BO) with a Gaussian Process (GP) surrogate model.
- Defines a synthetic, unknown “material property” function (a bumpy multimodal landscape)
- Fits a Gaussian Process to noisy sampled observations
- Uses an acquisition function (Expected Improvement or UCB) to select the next sample
- Visualizes:
- true function
- GP mean prediction
- GP uncertainty (standard deviation)
- sampled points
- best-observed progress over iterations
bayesian-materials/
main.py # runs BO + plots results
gp_model.py # scikit-learn GP wrapper
acquisition.py # EI + UCB
optimizer.py # BO loop (fit -> acquire -> sample -> update)
utils.py # helpers (bounds, normal pdf/cdf)
README.md
Bayesian Optimization treats the unknown objective (f(x)) (here: a material property) as something we can model probabilistically. A Gaussian Process gives a mean prediction and an uncertainty estimate. An acquisition function uses both to decide where to sample next, balancing:
- exploitation: sample near high predicted values
- exploration: sample where uncertainty is high and we might discover something better
A GP is like a distribution over functions. After observing data points ((x_i, y_i)), it produces:
- ( \mu(x) ): best guess of the function at (x)
- ( \sigma(x) ): uncertainty (how unsure we are)
As you sample more points, uncertainty shrinks near observed regions.
This repo implements:
- Expected Improvement (EI) (default): prefers points that are likely to improve over the best value seen so far
- Upper Confidence Bound (UCB): uses ( \mu(x) + \kappa \sigma(x) ) to trade off exploration/exploitation
pip install numpy matplotlib scikit-learnFrom inside bayesian-materials/:
python main.pyTry different settings:
python main.py --acq ei --iters 25
python main.py --acq ucb --iters 25
python main.py --noise-std 0.10
python main.py --save outputs/boThe script shows:
- snapshots of the surrogate model (initial, middle, final)
- a progress curve of “best observed value so far”
You should see BO quickly focus sampling near the best peak, while still occasionally exploring uncertain regions.
- This demo is 1D for clear plotting; real materials design is often high-dimensional
- Uses a dense candidate grid for acquisition maximization (fine in 1D, not scalable)
- Synthetic function is a simplification of real experimental noise and constraints
- Extend to multi-dimensional design spaces (2D/ND) with smarter optimizers for acquisition maximization
- Add constraints (feasible regions, safety constraints)
- Use real benchmark datasets or integrate with experiment/simulation pipelines
- Multi-objective BO (tradeoffs like strength vs weight vs cost)