concepts.pdsketch.executor.GeneratorManager#
- class GeneratorManager[source]#
Bases:
object
The
GeneratorManager
is used to manage calls to generators in the function dmoain. It is particularly useful for keep tracking of historical values generated by the generators.Methods
call
(g, max_generator_trials, args[, ...])Call a generator.
Export the generator calls.
export_generator_stats
([divide_by])Export the generator statistics.
mark_success
(assignment_dict)Mark the values in an assignment dictionary as successful.
Attributes
Whether to store the historical values generated by the generators.
The executor.
Mappings from generator names to the list of calls made to the generator, including a tuple of the arguments and a tuple of the return values.
Mappings from generator names to the list of Boolean values indicating whether the generated values lead to successful solution.
- __init__(executor, store_history=True)[source]#
Initialize the generator manager.
- Parameters:
executor (PDSketchExecutor) – the executor.
store_history (bool) – whether to store the historical values generated by the generators.
- __new__(**kwargs)#
- call(g, max_generator_trials, args, constraint_list=None)[source]#
Call a generator.
- Parameters:
g (Generator) – the generator.
max_generator_trials (int) – the maximum number of trials to generate values.
constraint_list (List[Constraint] | None) – the list of constraints to be satisfied by the generated values. This will be passed to the generator function if the list contains more than one constraint.
- Yields:
A tuple of (index, generated value). The index is a tuple of (generator_name, value_index).
- Return type:
- export_generator_calls()[source]#
Export the generator calls.
- Returns:
a dictionary mapping from generator names to the list of calls made to the generator, including a tuple of the arguments and a tuple of the return values, and a Boolean value indicating whether the generated values lead to successful solution.
- Return type:
- mark_success(assignment_dict)[source]#
Mark the values in an assignment dictionary as successful.
- Parameters:
assignment_dict (Dict[int, Assignment]) – the assignment dictionary.
- executor: PDSketchExecutor#
The executor.
- generator_calls: Dict[str, List[Tuple[Tuple[Any, ...], Tuple[Any, ...]]]]#
Mappings from generator names to the list of calls made to the generator, including a tuple of the arguments and a tuple of the return values.