def expand(self, context, budget_progress):
if budget_progress >= exploration_budget_percent:
# Exploitation: expand top-scoring nodes
selected_nodes = [self.nodes[exp.node_id] for exp in top_experiments]
else:
# Exploration: LLM selects promising nodes
selected_nodes = self.select(context, criteria="potential for improvement")
for node in selected_nodes:
new_solutions = self.solution_generation(parent_solution=node.solution)
for solution in new_solutions:
child = Node(parent=node, solution=solution)
node.children.append(child)