| """
|
| Minimal example: Physics-Informed Bayesian Optimization in ~30 lines.
|
|
|
| Demonstrates the core workflow:
|
| 1. Define a physics model
|
| 2. Define the parameter space
|
| 3. Create a designer and suggest experiments
|
| """
|
|
|
| import torch
|
| from physics_informed_bo.experiment.parameter_space import ParameterSpace
|
| from physics_informed_bo.experiment.designer import ExperimentDesigner
|
|
|
|
|
|
|
| def physics_model(X):
|
| temp, conc = X[:, 0], X[:, 1]
|
| return torch.exp(-5000 / temp) * conc**0.5
|
|
|
|
|
|
|
| space = ParameterSpace()
|
| space.add_continuous("temperature", 300, 600, units="K")
|
| space.add_continuous("concentration", 0.1, 10.0, units="mol/L")
|
|
|
|
|
| X_init = torch.tensor([[350.0, 1.0], [450.0, 5.0], [500.0, 3.0]])
|
| y_init = torch.tensor([0.1, 0.8, 0.6])
|
|
|
|
|
| designer = ExperimentDesigner(
|
| parameter_space=space,
|
| physics_fn=physics_model,
|
| initial_data=(X_init, y_init),
|
| )
|
|
|
|
|
| next_experiments = designer.suggest(n=3)
|
| print("Suggested experiments:")
|
| for exp in space.to_dict(next_experiments):
|
| print(f" Temperature={exp['temperature']:.1f} K, Concentration={exp['concentration']:.2f} mol/L")
|
|
|
|
|
|
|
|
|