You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to add multiple conditions that affect the same hyperparameter, ConfigSpace complains that adding multiple conditions is ambiguous. For example:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/Code/spack/var/spack/environments/bedrock-env/.spack-env/view/lib/python3.11/site-packages/ConfigSpace/configuration_space.py", line 330, in add
self._dag.add_condition(condition)
File "/home/ubuntu/Code/spack/var/spack/environments/bedrock-env/.spack-env/view/lib/python3.11/site-packages/ConfigSpace/_condition_tree.py", line 681, in add_condition
raise AmbiguousConditionError(
ConfigSpace.exceptions.AmbiguousConditionError: Adding a second parent condition for a for a hyperparameter is ambiguous and therefore forbidden. Use an `OrConjunction` or `AndConjunction` to combine conditions instead.
Already inserted: z | x == 3
New one: z | y == 3
I don't understand why it would be ambiguous. When adding multiple conditions, it would seem obvious to me that they are in conjunction with each other, not in disjonction (if anything, simply because conditions that affect distinct parameters are already in conjunction with each other).
More practically speaking, the reason this is annoying in my use-case is that, as part of a library, I have a function that returns a ConfigurationSpace for the parameters available to the library. The user then has a chance to further constrain this space by adding conditions on parameters. But some of the parameters already have some conditions attached to them by the library itself.
As is, ConfigSpace doesn't seem to provide an API to remove a previously defined condition and add it back as part of an AndConjunction, or add more conditions to an existing AndConjunction.
The text was updated successfully, but these errors were encountered:
mdorier
changed the title
[question] Why not allow multiple conditions on the same parameter?
Feature request: allow multiple conditions on the same parameter
Jul 26, 2024
I edited the title to make it a feature request. I've been trying to get around this constraint in my code but it's becoming unmanageable. I really need a way to add multiple conditions to the same hyperparameter from different points in the code (which may be from potentially different libraries).
I looked at the code to see how this could be done. One way I would see this doable would be to allow adding conditions to an existing AndConjunction (and allow an AndConjunction to initially have a single subcondition -- checking that there are at least 2 conditions in the constructor right now isn't necessary, the code would work just the same with a single subcondition). But I'm not sure it's as simple as this... does the DAG need to be updated as well?
As long as everything is put into one AndConjunction, the DAG part of the code shouldn't need to be touched too much. There is an outstanding issue where diamond OR conditions don't work though which is something to be aware of.
I'm not sure when I'll have time to implement, test and document this but I'm happy to review a PR if you're up for it.
The primary alternative from your code to build around this fact would be for you to collect conditions from a user of your API and when it comes time to using the ConfigurationSpace, you would add all of the conditions into it.
When I try to add multiple conditions that affect the same hyperparameter, ConfigSpace complains that adding multiple conditions is ambiguous. For example:
Gives me:
I don't understand why it would be ambiguous. When adding multiple conditions, it would seem obvious to me that they are in conjunction with each other, not in disjonction (if anything, simply because conditions that affect distinct parameters are already in conjunction with each other).
More practically speaking, the reason this is annoying in my use-case is that, as part of a library, I have a function that returns a
ConfigurationSpace
for the parameters available to the library. The user then has a chance to further constrain this space by adding conditions on parameters. But some of the parameters already have some conditions attached to them by the library itself.As is, ConfigSpace doesn't seem to provide an API to remove a previously defined condition and add it back as part of an
AndConjunction
, or add more conditions to an existingAndConjunction
.The text was updated successfully, but these errors were encountered: