def test_instantiation_smoketest(self): sampler = PolyCutOffComposite( dimod.HigherOrderComposite(dimod.ExactSolver()), 0) self.assertTrue(hasattr(sampler, 'sample_poly')) self.assertTrue(hasattr(sampler, 'sample_hising')) self.assertTrue(hasattr(sampler, 'sample_hubo'))
def test_isolated(self): poly = dimod.BinaryPolynomial({ 'a': 3, 'abc': 4, 'ac': 0.2 }, dimod.SPIN) sampler = dimod.HigherOrderComposite(dimod.ExactSolver()) sampleset = PolyCutOffComposite(sampler, 4.1).sample_poly(poly)
Q[idx] = λ * v print("INFO: Complete HUBO model:") for k, v in Q.items(): print(k, ":", v) # Strength of the reduction constraint. # Insufficient strength can result in the binary quadratic model # not having the same minimizations as the polynomial. strength = 5.0 schedule = [(0.0, 1.0), (2.0, 0.5), (18.0, 0.5), (20.0, 1.0)] print("INFO: reverse annealing schedule:") print(schedule) neal_sampler = dimod.HigherOrderComposite(neal.SimulatedAnnealingSampler()) exact_sampler = dimod.HigherOrderComposite(dimod.ExactSolver()) qpu_sampler = dimod.HigherOrderComposite(EmbeddingComposite( DWaveSampler())) #initial_states = set( itertools.permutations( [1]*n_ferm + [0]*(n_so-n_ferm), n_so ) ) #initial_states = list( zip( np.arange(len(initial_states)), initial_states) ) initial_states = [(0, [1] * n_ferm + [0] * (n_so - n_ferm))] print( "INFO: possible initial states with %i particles in %i spin orbitals:" % (n_ferm, n_so)) for s in initial_states: print("%-3i =" % s[0], dirac(s[1])) n_solutions = nCr(n_so, n_ferm) print(
def setUp(self): self.child = dimod.HigherOrderComposite(dimod.ExactSolver())