def __init__(self, grammar=None, value=None, f=None, maxnodes=25, args=['x'], **kwargs): # Save all of our keywords self.__dict__.update(locals()) if value is None and grammar is not None: value = grammar.generate() FunctionHypothesis.__init__(self, value=value, f=f, args=args, **kwargs) self.likelihood = 0.0 self.rules_vector = None
def __init__(self, grammar=None, value=None, f=None, maxnodes=25, **kwargs): if 'args' in kwargs: assert False, "*** Use of 'args' is deprecated. Use display='...' instead." # Save all of our keywords self_update(self, locals()) if value is None and grammar is not None: value = grammar.generate() FunctionHypothesis.__init__(self, value=value, f=f, **kwargs) self.likelihood = 0.0 self.rules_vector = None
def __init__(self, grammar, value=None, f=None, node_counts=None, maxnodes=25, recurse_bound=25, display="lambda recurse_, x: %s", **kwargs): """ Initializer. recurse gives the name for the recursion operation internally. """ assert "lambda recurse_" in display, "*** RecursiveLOTHypothesis must have 'recurse_' as first display element." # otherwise it can't eval # save recurse symbol self.recursive_depth_bound = recurse_bound # how deep can we recurse? self.recursive_call_depth = 0 # how far down have we recursed? if 'args' in kwargs: assert False, "*** Use of 'args' is deprecated. Use display='...' instead." # Save all of our keywords self_update(self, locals()) grammar.update_alphas() # make sure alpha/sigma arrays are initialized if value is None: value, self.node_counts = grammar.generate_with_counts() else: self.node_counts = node_counts self.tree_size = np.sum(self.node_counts) FunctionHypothesis.__init__(self, value=value, f=f, display=display, **kwargs) self.likelihood = 0.0 self.compute_prior() self.rules_vector = None
def __init__(self, grammar, value=None, f=None, start=None, ALPHA=0.9, maxnodes=25, args=['x'], proposal_function=None, **kwargs): self.grammar = grammar self.f = f self.ALPHA = ALPHA self.maxnodes = maxnodes # Save all of our keywords (though we don't need v) self.__dict__.update(locals()) # If this is not specified, defaultly use grammar if start is None: self.start = grammar.start if value is None: value = grammar.generate(self.start) FunctionHypothesis.__init__(self, value=value, f=f, args=args, **kwargs) # Save a proposal function # TODO: How to handle this in copying? if proposal_function is None: self.proposal_function = RegenerationProposal(self.grammar) self.likelihood = 0.0 self.rules_vector = None