def _default_generate_more_terms(self, transform_term=None): signature_to_term = self.signature_to_term bunch_generator_state = self.bunch_generator_state try: bunch = next(bunch_generator_state) except StopIteration: return False for term in bunch: if transform_term is not None: term = transform_term(term) sig = self._compute_term_signature(term) # collecting data if self.stat_model is not None and options.use_phog(): self.stat_model.add_for_statistics(term) # w/o indistinguishability # do not apply indis when using PHOG (indistinguishability is done in phog.py) if (sig in signature_to_term or sig.is_empty()) and (not options.use_phog()): continue signature_to_term[sig] = term # for sig,term in signature_to_term.items(): # print(exprs.expression_to_string(term), ' : ', sig) self.full_signature = self.full_signature | sig if sig.is_full(): self.one_full_signature = True # print statistics when using PHOG if options.use_phog() and self.stat_model is not None: self.stat_model.print_statistics() return True
def _default_solve(self, restart_everytime): num_points = len(self.points) if (num_points == 0): # No points, any term will do return self._trivial_solve() signature_to_term = self.signature_to_term # no restart (incremental search in using PHOG) if (options.inc or options.noindis) and options.use_phog(): restart_everytime = False if restart_everytime or self.bunch_generator is None: self.restart_bunched_generator() while True: success = self.generate_more_terms() if not success: return False if (self.stopping_condition == StoppingCondition.term_sufficiency and self.full_signature.is_full()): return True elif (self.stopping_condition == StoppingCondition.one_term_sufficiency and self.one_full_signature): return True
def __init__(self, options): self.points = [] self.current_largest_term_size = 0 self.signature_to_term = {} self.noindis = options.noindis self.use_phog = options.use_phog() self.inc = options.inc