def _check_edges(self, edges: List[Tuple[str, str]]) -> None:
for parent_node, child_node in edges:
# check if both nodes are already inserted into the graph
if child_node not in self._hyperparameters:
raise ValueError("Child hyperparameter '%s' not in configuration "
"space." % child_node)
if parent_node not in self._hyperparameters:
raise ValueError("Parent hyperparameter '%s' not in configuration "
"space." % parent_node)
# TODO: recursively check everything which is inside the conditions,
# this means we have to recursively traverse the condition
tmp_dag = self._create_tmp_dag()
for parent_node, child_node in edges:
tmp_dag.add_edge(parent_node, child_node)
if not ConfigSpace.nx.is_directed_acyclic_graph(tmp_dag):
cycles = list(ConfigSpace.nx.simple_cycles(tmp_dag)) # type: List[List[str]]
for cycle in cycles:
cycle.sort()
cycles.sort()
raise ValueError("Hyperparameter configuration contains a "
"cycle %s" % str(cycles))
评论列表
文章目录