Skip to content

Bugged recommendation cache check accessing allow_recommending_already_recommended when it's UNSPECIFIED #733

@juliaphilipp

Description

@juliaphilipp

Hi BayBe Team,

I am running in (for me) unexpected behavior when getting recommendations from a campaign with a continuous search space. The issue happens always when getting the second round of recommendations, independently of whether I add measurements before or not.

The error I get is a "NotImplementedError: 'UNSPECIFIED' has no Boolean representation." Pointing towards allow_recommending_already_recommended. When I try to set allow_recommending_already_recommended to False in the campaign, I get the following ValueError as expected: "ValueError: For search spaces of type other than 'SearchSpaceType.DISCRETE', 'allow_recommending_already_recommended' cannot be set since the flag is meaningless in such contexts."

Below a minimal example that produces the described error, using baybe 0.14.2. I'm sure I'm just missing something, I'd appreciate any input :)

from baybe.targets import NumericalTarget

from baybe.objectives import (
    ParetoObjective
)

from baybe.parameters import (
    NumericalContinuousParameter,
)
from baybe.constraints import (
    ContinuousLinearConstraint
)

from baybe.searchspace import SearchSpace

from baybe import Campaign
from baybe.utils.random import temporary_seed

from baybe.utils.dataframe import add_fake_measurements, add_parameter_noise

t1 = NumericalTarget(name="TargetA", minimize=False)
t2 = NumericalTarget(name="TargetB", minimize=True)

objective = ParetoObjective(targets=[t1, t2])

parameters = [
    NumericalContinuousParameter(
        name="ComponentA",
        bounds=(20,70)
    ),
    NumericalContinuousParameter(
        name="ComponentB",
        bounds=(0,100)
    ),
    NumericalContinuousParameter(
        name="ComponentC",
        bounds=(0, 100)
    ),
    NumericalContinuousParameter(
        name="ComponentD",
        bounds=(1,5)
    ),
    
]

constraints = [
    ContinuousLinearConstraint(
        parameters=["ComponentA","ComponentB", "ComponentC","ComponentD"], 
        operator="=", 
        coefficients=(1.0, 1.0, 1.0,1.0), 
        rhs=100
    ),
]

searchspace = SearchSpace.from_product(parameters=parameters, constraints=constraints)

campaign = Campaign(
    searchspace=searchspace,
)

with temporary_seed(123):
    recommendation = campaign.recommend(batch_size=12)
    
measurements = recommendation.copy()
add_fake_measurements(measurements, campaign.targets)
add_parameter_noise(measurements, campaign.parameters)

new_recommendation = campaign.recommend(batch_size=12)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions