-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoracles.py
More file actions
54 lines (38 loc) · 1.69 KB
/
Copy pathoracles.py
File metadata and controls
54 lines (38 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""Oracle functions for locking-parameter optimization.
The oracle wraps the simulation: given design parameters D, it runs the
(expensive) simulation to obtain accurate locking parameters L*.
The oracle can optionally use the trained surrogate model to provide
an initial guess for L, which helps the simulation converge faster.
"""
import numpy as np
from utils.sim import finesse_sim
class FPOracle:
"""Oracle that runs fabry-perot simulation.
Takes design params D, optionally uses surrogate model for initial
guess, runs simulation to get accurate locking params L*.
The oracle returns L* (not objectives). The mpBAX model trains on
(D, L*) pairs, learning the D -> L mapping. The algorithm computes
objectives internally from (D, L_predicted).
Attributes:
engine: Reference to the Engine instance (set after creation).
Used to access the trained surrogate model for initial guesses.
use_surrogate_init: Whether to use surrogate predictions as initial guess.
noise_scale: Simulation noise level.
"""
def __init__(self):
"""Initialize FPOracle.
Args:
use_surrogate_init: Use trained surrogate for initial guess (default True)
noise_scale: Simulation noise level (default 0.01)
"""
self.engine = None # Set after engine creation via: oracle.engine = engine
def __call__(self, D):
"""Run fabry-perot simulation on design parameters.
Args:
D: Design parameters, shape (d)
Returns:
cavity_power: Cavity power, float
"""
# Run expansive simulation
cavity_power = finesse_sim(D)
return cavity_power