def test_simple_complete_graph_sample_ising(self):
        """sample_ising on a K4."""

        K4 = VirtualGraphComposite(self.sampler,
                                   embedding={
                                       0: {0, 4},
                                       1: {1, 5},
                                       2: {2, 6},
                                       3: {3, 7}
                                   },
                                   flux_biases=False)

        K4.sample_ising({0: .1, 1: .2}, {(0, 1): 1.5})
    def test_smoke(self):
        child_sampler = MockDWaveSampler()
        sampler = VirtualGraphComposite(child_sampler, {'a': [0]},
                                        flux_bias_num_reads=1)

        # depending on how recenlty flux bias data was gathered, this may be true
        child_sampler.flux_biases_flag = False

        if sampler.flux_biases:
            sampler.sample_ising({'a': -1}, {})
            self.assertTrue(
                child_sampler.flux_biases_flag
            )  # true when some have been provided to sample_ising
Exemplo n.º 3
0
    def test_construction(self):
        child_sampler = DWaveSampler()

        # get an embedding
        K10_edges = list(itertools.combinations(range(10), 2))
        embedding = minorminer.find_embedding(K10_edges,
                                              child_sampler.edgelist)

        sampler = VirtualGraphComposite(child_sampler, embedding)

        dtest.assert_sampler_api(sampler)

        h = {}
        J = {edge: -1 for edge in K10_edges}
        sampler.sample_ising(h, J)

        sampler.sample_ising(h, J, apply_flux_bias_offsets=False)
Exemplo n.º 4
0
    def test_construction(self):
        child_sampler = self.qpu

        # get an embedding
        K10_edges = list(itertools.combinations(range(10), 2))
        embedding = minorminer.find_embedding(K10_edges,
                                              child_sampler.edgelist)

        sampler = VirtualGraphComposite(child_sampler,
                                        embedding,
                                        flux_bias_num_reads=10)

        dtest.assert_sampler_api(sampler)

        h = {}
        J = {edge: -1 for edge in K10_edges}

        # run with fbo
        sampler.sample_ising(h, J).resolve()

        # and again without
        sampler.sample_ising(h, J, apply_flux_bias_offsets=False).resolve()
Exemplo n.º 5
0
    def test_reverse_annealing(self):
        child_sampler = DWaveSampler()

        # get an embedding
        K10_edges = list(itertools.combinations(range(10), 2))
        embedding = minorminer.find_embedding(K10_edges,
                                              child_sampler.edgelist)

        sampler = VirtualGraphComposite(child_sampler, embedding)

        h = {}
        J = {edge: -1 for edge in K10_edges}

        kwargs = {
            'initial_state': {v: 0
                              for v in set().union(*J)},
            'anneal_schedule': [(0, 1), (55.0, 0.45), (155.0, 0.45),
                                (210.0, 1)]
        }

        # sample and resolve
        sampler.sample_ising(h, J, **kwargs).samples()