Description
Hello ConfigSpace package developers.
I'm having a problem with ForbiddenInClause and ForbiddenAndConjunction.
Here is an example:
import numpy as np
from openbox import space as sp
from ConfigSpace import ConfigurationSpace, Categorical, Float, Integer,Constant
from ConfigSpace import ForbiddenAndConjunction, ForbiddenEqualsClause, ForbiddenInClause
space = sp.Space()
lp2=Categorical('lp2', [1, 2, 8, 64])
A=Categorical('A', [1, 2, 8])
x=Categorical('x', [1, 2, 8])
tmp=Categorical('tmp', [1, 2, 8])
#I hope that
#When lp2=1, A and tmp cannot be in [1,2], and x cannot be in [1,2]
#When lp2=2, A and tmp cannot be in [1,8], and x cannot be in [1,8]
#When lp2=8, A and tmp cannot be in [1,2], and x cannot be in [1,2]
#When lp2=64, A and tmp cannot be in [1,2], and x cannot be in [1,2]
F1=ForbiddenAndConjunction(
ForbiddenInClause(lp2,[1]),
ForbiddenInClause(A,[2,8]),
ForbiddenInClause(tmp,[2,8]),
ForbiddenInClause(x,[2,8]))
F2=ForbiddenAndConjunction(
ForbiddenInClause(lp2,[2]),
ForbiddenInClause(A,[1,8]),
ForbiddenInClause(tmp,[1,8]),
ForbiddenInClause(x,[1,8]))
F3=ForbiddenAndConjunction(
ForbiddenInClause(lp2,[8,64]),
ForbiddenInClause(A,[1,2]),
ForbiddenInClause(tmp,[1,2]),
ForbiddenInClause(x,[1,2]))
F=[F1,F2,F3]
names = [lp2,A ,x ,tmp]
space.add_variables(names)
space.add(F)
space.sample_configuration(1)
The output is:
Configuration space object:
Hyperparameters:
A, Type: Categorical, Choices: {1, 2, 8}, Default: 1
lp2, Type: Categorical, Choices: {1, 2, 8, 64}, Default: 1
tmp, Type: Categorical, Choices: {1, 2, 8}, Default: 1
x, Type: Categorical, Choices: {1, 2, 8}, Default: 1
Forbidden Clauses:
(Forbidden: lp2 in {1} && Forbidden: A in {2, 8} && Forbidden: tmp in {2, 8} && Forbidden: x in {2, 8})
(Forbidden: lp2 in {2} && Forbidden: A in {1, 8} && Forbidden: tmp in {1, 8} && Forbidden: x in {1, 8})
(Forbidden: lp2 in {8, 64} && Forbidden: A in {1, 2} && Forbidden: tmp in {1, 2} && Forbidden: x in {1, 2})
The result of sample space.sample_configuration (1) is:
Configuration(values={
'A': 2,
'lp2': 2,
'tmp': 8,
'x': 8,
})
But this does not conform to the forbidden clause F2.
F2=ForbiddenAndConjunction(
ForbiddenInClause(lp2,[2]),
ForbiddenInClause(A,[1,8]),
ForbiddenInClause(tmp,[1,8]),
ForbiddenInClause(x,[1,8]))
When lp2= 2, x should not be equal to 8, and y should not be equal to 8.
According to the Boolean calculation of your source code, the sampling configuration must trigger 4 clauses of F2 at the same time to achieve the effect I want, if only 3 clauses of F2 and less are triggered at the same time, it will also be successfully sampled, and the effect I want will not be achieved. Please how can I modify it to achieve 【When lp2=2, A and tmp cannot be in [1,8], and x cannot be in [1,8]】?
I look forward to your answers and thank you for your help!