Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproduction and fixes to the issue #6 #7

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions carbs/carbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ def _get_mask_for_invalid_points_in_basic(self, input_in_basic: Tensor) -> Tenso
input_in_basic < self.max_bounds_in_basic.unsqueeze(0)
)
mask = torch.logical_and(is_above_min_bounds, is_below_max_bounds)

# Also remove the samples that are in the success and failure observations
# Seeding in other places can lead to repeated samples, so we need to remove them here
observed_samples = [x.real_number_input for x in self.success_observations + self.failure_observations]
if len(observed_samples) > 0:
observed_samples = torch.stack(observed_samples)
new_sample_mask = ~torch.any(torch.isclose(input_in_basic[:, None], observed_samples[None, :]).all(dim=2), dim=1)
mask = torch.logical_and(mask, new_sample_mask)

return mask

def _round_integer_values_in_basic(self, input_in_basic: Tensor) -> Tensor:
Expand Down
9 changes: 9 additions & 0 deletions carbs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,15 @@ def get_pareto_groups_conservative(
for group in grouped_observations
if observation_group_cost(group) <= min_pareto_cost
]
# When there happens to be no observations below the min threshold, inspect observations' cost individually
if len(observations_below_min_threshold) == 0:
logger.warning(
"There is no grouped obs below min_pareto_cost. So inspect observations' cost individually."
)
observations_below_min_threshold = [
(x,) for group in grouped_observations for x in group if x.cost <= min_pareto_cost
]

resampled_observations_below_min_threshold = [
group for group in observations_below_min_threshold if len(group) > 1
]
Expand Down