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_generator_calls()

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

store_history

Whether to store the historical values generated by the generators.

executor

The executor.

generator_calls

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.

generator_calls_successful

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.

  • args (Tuple[Any, ...]) – the arguments of the generator.

  • 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:

Iterator[Tuple[Tuple[str, int], Any]]

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:

Dict[str, List[Tuple[Tuple[Any, …], Tuple[Any, …], bool]]]

export_generator_stats(divide_by=1)[source]#

Export the generator statistics.

Returns:

a string containing the generator statistics.

Parameters:

divide_by (float)

Return type:

str

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.

generator_calls_successful: Dict[str, List[bool]]#

Mappings from generator names to the list of Boolean values indicating whether the generated values lead to successful solution.

property store_history: bool#

Whether to store the historical values generated by the generators.