@@ -180,7 +180,7 @@ function combine(iter::BottomUpIterator, state)
180
180
non_terminal_shapes = UniformHole .(partition (Hole (nonterminals), grammar), ([],))
181
181
182
182
# if we have exceeded the maximum number of programs to generate
183
- if max_in_bank >= state[:max ]
183
+ if max_in_bank >= state[:max_combination_depth ]
184
184
return nothing , nothing
185
185
end
186
186
241
241
242
242
Returns the initial state for the first `combine` call
243
243
"""
244
- function init_combine_structure (iter:: BottomUpIterator )
245
- Dict (:max => 4 )
246
- end
244
+ function init_combine_structure end
247
245
248
246
249
247
"""
@@ -293,7 +291,7 @@ function _get_next_program(iter::BottomUpIterator, state::GenericBUState)
293
291
end
294
292
end
295
293
296
- function derivation_heuristic (:: BottomUpIterator , indices:: Vector{Int } )
294
+ function derivation_heuristic (:: BottomUpIterator , indices:: Vector{Integer } )
297
295
return sort (indices);
298
296
end
299
297
@@ -346,14 +344,19 @@ function Base.iterate(iter::BottomUpIterator, state::GenericBUState)
346
344
# program is `nothing`, so we stop
347
345
return nothing
348
346
elseif typeof (program_combination) == AccessAddress
347
+ @error " Should never reach this branch with uniform trees"
349
348
# we only need to access the program, it is already in the bank
350
349
program = retrieve (iter, program_combination)
351
350
solver = iter. solver
352
351
uniform_solver = UniformSolver (get_grammar (solver), get_tree (solver), with_statistics= solver. statistics)
353
352
new_state. current_uniform_iterator = UniformIterator (uniform_solver, iter)
354
353
next_solution = next_solution! (state. current_uniform_iterator)
355
354
356
- return next_solution, new_state
355
+ if depth (next_solution) > iter. solver. max_depth
356
+ return nothing
357
+ else
358
+ return next_solution, new_state
359
+ end
357
360
else
358
361
# we have to combine programs from the bank
359
362
# updates iter.solver with the combined program
@@ -371,7 +374,11 @@ function Base.iterate(iter::BottomUpIterator, state::GenericBUState)
371
374
next_solution = next_solution! (state. current_uniform_iterator)
372
375
# take the program (uniform tree) convert to UniformIterator, and add to state
373
376
# return the first concrete tree from the UniformIterator in the state (and the updated state)
374
- return next_solution, new_state
377
+ if depth (next_solution) > iter. solver. max_depth
378
+ return nothing
379
+ else
380
+ return next_solution, new_state
381
+ end
375
382
else
376
383
return Base. iterate (iter, new_state)
377
384
end
0 commit comments