def build_tree(return_type, allowed_functions=None, convert=True, selection_strategy=None):
if allowed_functions is not None:
allowed_functions = frozenset(allowed_functions)
starting_functions = find_functions(return_type, allowed_functions, convert)
for __ in xrange(99999):
try:
return Node(
random.choice(starting_functions),
allowed_functions=allowed_functions,
selection_strategy=selection_strategy,
)
except RuntimeError:
pass
raise TreeConstructionError(
"Unable to construct program, consider raising recursion depth limit."
)
评论列表
文章目录