-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39c19e4
commit d84fa74
Showing
5 changed files
with
127 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,7 @@ | ||
import torch | ||
from botorch.acquisition.analytic import LogExpectedImprovement, LogProbabilityOfImprovement | ||
import bluesky.plans as bp | ||
import numpy as np | ||
|
||
|
||
class Acquisition: | ||
def __init__(self, *args, **kwargs): | ||
... | ||
|
||
@staticmethod | ||
def log_expected_improvement(candidates, agent): | ||
*input_shape, n_dim = candidates.shape | ||
|
||
x = torch.as_tensor(candidates.reshape(-1, 1, n_dim)).double() | ||
|
||
LEI = LogExpectedImprovement( | ||
model=agent.task_model, best_f=agent.best_sum_of_tasks, posterior_transform=agent.scalarization | ||
) | ||
|
||
lei = LEI.forward(x) | ||
feas_log_prob = agent.feas_model(x) | ||
|
||
return (lei.reshape(input_shape) + feas_log_prob.reshape(input_shape)).detach().numpy() | ||
|
||
@staticmethod | ||
def log_probability_of_improvement(candidates, agent): | ||
*input_shape, n_dim = candidates.shape | ||
|
||
x = torch.as_tensor(candidates.reshape(-1, 1, n_dim)).double() | ||
|
||
LPI = LogProbabilityOfImprovement( | ||
model=agent.task_model, best_f=agent.best_sum_of_tasks, posterior_transform=agent.scalarization | ||
) | ||
|
||
lpi = LPI.forward(x) | ||
feas_log_prob = agent.feas_model(x) | ||
|
||
return (lpi.reshape(input_shape) + feas_log_prob.reshape(input_shape)).detach().numpy() | ||
def default_acquisition_plan(dofs, inputs, dets): | ||
uid = yield from bp.list_scan(dets, *[_ for items in zip(dofs, np.atleast_2d(inputs).T) for _ in items]) | ||
return uid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def default_digestion_function(db, uid): | ||
return db[uid].table(fill=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters