Exemplo n.º 1
0
 def __init__(self, child_sampler, **embedding_parameters):
     if not isinstance(child_sampler, dimod.Structured):
         raise dimod.InvalidComposition("MinorMinerEmbeddingComposite should only be applied to a Structured sampler")
     self._children = [child_sampler]
     self._embedding = None
     self._child_response = None
     self._embedding_parameters = embedding_parameters
Exemplo n.º 2
0
    def __init__(self, child_sampler, embedding):
        if not isinstance(child_sampler, dimod.Structured):
            raise dimod.InvalidComposition(
                "EmbeddingComposite should only be applied to a Structured sampler"
            )

        self.children = [child_sampler]

        # Derive the structure of our composed sampler from the target graph and the embedding
        source_adjacency = dimod.embedding.target_to_source(
            child_sampler.adjacency, embedding)
        try:
            nodelist = sorted(source_adjacency)
            edgelist = sorted(_adjacency_to_edges(source_adjacency))
        except TypeError:
            # python3 does not allow sorting of unlike types, so if nodes have
            # different type names just choose an arbitrary order
            nodelist = list(source_adjacency)
            edgelist = list(_adjacency_to_edges(source_adjacency))
        self.nodelist = nodelist
        self.edgelist = edgelist
        self.adjacency = source_adjacency

        self.parameters = parameters = child_sampler.parameters.copy()
        parameters['chain_strength'] = []
        parameters['chain_break_fraction'] = []

        self.properties = {'child_properties': child_sampler.properties.copy()}

        self.embedding = self.properties['embedding'] = embedding
Exemplo n.º 3
0
    def _set_child_related_init(self, child_sampler):
        if not isinstance(child_sampler, dimod.Structured):
            raise dimod.InvalidComposition("{} should only be applied to a Structured sampler"
                                           .format(type(self).__name__))

        self.children = [child_sampler]

        self.parameters = parameters = self.child.parameters.copy()
        parameters['chain_strength'] = []
        parameters['chain_break_fraction'] = []

        self.properties = {'child_properties': self.child.properties.copy()}
Exemplo n.º 4
0
    def __init__(self,
                 child_sampler,
                 layout=None,
                 embedding_method=minorminer,
                 candidates_method=diffusion_placer,
                 architecture_method=dw2000q_graph,
                 embedding_parameters={},
                 candidates_parameters={}):

        if not isinstance(child_sampler, dimod.Structured):
            raise dimod.InvalidComposition(
                "LayoutAwareEmbeddingComposite should only be applied to a Structured sampler"
            )
        self._children = [child_sampler]
        self._layout = layout
        self._embedding = None
        self._embedding_method = embedding_method
        self._candidates_method = candidates_method
        self._architecture_method = architecture_method
        self._embedding_parameters = embedding_parameters
        self._candidates_parameters = candidates_parameters
Exemplo n.º 5
0
 def __init__(self, child_sampler):
     if not isinstance(child_sampler, dimod.Structured):
         raise dimod.InvalidComposition(
             "EmbeddingComposite should only be applied to a Structured sampler"
         )
     self._children = [child_sampler]