def _generate_efms(self): self.efm_einstrs, self.efm_specs, self.efm_einpaths = [], [], [] if self.gen_efms: for edgs,ws in zip(self.edges, self.weights): einstr, efm_spec = efp2efms(EFP(edgs, weights=ws).graph) self.efm_einstrs.append(einstr) self.efm_specs.append(efm_spec) self.efm_einpaths.append(np.einsum_path(einstr, *[np.empty([4]*sum(s)) for s in efm_spec], optimize=self.ve.np_optimize)[0])
def __init__(self, edges, weights=None, efpset_args=None, np_optimize=True, **kwargs): r"""Since a standalone EFP defines and holds a `Measure` instance, all `Measure` keywords are accepted. **Arguments** - **edges** : _list_ - Edges of the EFP graph specified by pairs of vertices. - **weights** : _list_ of _int_ or `None` - If not `None`, the multiplicities of each edge. - **measure** : {`'hadr'`, `'hadrdot'`, `'hadrefm'`, `'ee'`, `'eeefm'`} - The choice of measure. See [Measures](../measures) for additional info. - **beta** : _float_ - The parameter $\beta$ appearing in the measure. Must be greater than zero. - **kappa** : {_float_, `'pf'`} - If a number, the energy weighting parameter $\kappa$. If `'pf'`, use $\kappa=v-1$ where $v$ is the valency of the vertex. - **normed** : _bool_ - Controls normalization of the energies in the measure. - **coords** : {`'ptyphim'`, `'epxpypz'`, `None`} - Controls which coordinates are assumed for the input. See [Measures](../measures) for additional info. - **check_input** : _bool_ - Whether to check the type of the input each time or assume the first input type. - **np_optimize** : {`True`, `False`, `'greedy'`, `'optimal'`} - The `optimize` keyword of `numpy.einsum_path`. """ # initialize base class super(EFP, self).__init__(kwargs) # store options self._np_optimize = np_optimize self._weights = weights # generate our own information from the edges if efpset_args is not None: (self._einstr, self._einpath, self._spec, self._efm_einstr, self._efm_einpath, self._efm_spec) = efpset_args # ensure that EFM spec is a list of tuples if self.efm_spec is not None: self._efm_spec = list(map(tuple, self.efm_spec)) # process edges self._process_edges(edges, self.weights) # compute specs if needed if efpset_args is None: # compute EFM specs self._efm_einstr, self._efm_spec = efp2efms(self.graph) # only store an EFMSet if this is an external EFP using EFMs if self.has_measure and self.use_efms: self._efmset = EFMSet(self._efm_spec, subslicing=self.subslicing, no_measure=True) args = [np.empty([4] * sum(s)) for s in self._efm_spec] self._efm_einpath = einsum_path(self._efm_einstr, *args, optimize=np_optimize)[0] # setup traditional VE computation ve = VariableElimination(self.np_optimize) (self._einstr, self._einpath, self._c) = ve.einspecs(self.simple_graph, self.n) # compute and store spec information vs = valencies(self.graph).values() self._e = len(self.simple_graph) self._d = sum(self.weights) self._v = max(vs) if len(vs) else 0 self._k = -1 self._p = len(get_components( self.simple_graph)) if self.d > 0 else 1 self._h = Counter(vs)[1] self._spec = np.array([ self.n, self.e, self.d, self.v, self.k, self.c, self.p, self.h ]) # store properties from given spec else: self._e, self._d, self._v, self._k, self._c, self._p, self._h = self.spec[ 1:] assert self.n == self.spec[ 0], 'n from spec does not match internally computed n'