print("BQM size: {}, subproblem size: {}".format(len(bqm), subproblem_size)) # Classical solvers #subproblem = hybrid.EnergyImpactDecomposer(size=50, rolling_history=0.15) #subproblem = hybrid.EnergyImpactDecomposer(size=1024, rolling_history=0.15, traversal="bfs") # Parallel subproblem subproblem = hybrid.Unwind( #hybrid.EnergyImpactDecomposer(size=subproblem_size, rolling_history=0.15, traversal="bfs") hybrid.EnergyImpactDecomposer(size=subproblem_size, rolling_history=0.1)) # QPU #subsampler = hybrid.QPUSubproblemAutoEmbeddingSampler() | hybrid.SplatComposer() subsampler = hybrid.Map( hybrid.QPUSubproblemAutoEmbeddingSampler()) | hybrid.Reduce( hybrid.Lambda(merge_substates)) | hybrid.SplatComposer() # Define the workflow # iteration = hybrid.RacingBranches( # hybrid.InterruptableTabuSampler(), # hybrid.EnergyImpactDecomposer(size=2) # | hybrid.QPUSubproblemAutoEmbeddingSampler() # | hybrid.SplatComposer() # ) | hybrid.ArgMin() #iteration = hybrid.RacingBranches( iteration = hybrid.Race( hybrid.InterruptableTabuSampler(), #hybrid.SimulatedAnnealingProblemSampler(), subproblem | subsampler) | hybrid.ArgMin()
# define the solver def merge_substates(component, substates): a, b = substates return a.updated( subsamples=hybrid.utils.meld_samplesets(a.subsamples, b.subsamples) ) subproblems = hybrid.Unwind( hybrid.EnergyImpactDecomposer(size=50, silent_rewind=False, rolling_history=0.15) ) qpu = hybrid.Map( hybrid.QPUSubproblemAutoEmbeddingSampler() ) | hybrid.Reduce( hybrid.Lambda(merge_substates) ) | hybrid.SplatComposer() random = hybrid.Map( hybrid.RandomSubproblemSampler() ) | hybrid.Reduce( hybrid.Lambda(merge_substates) ) | hybrid.SplatComposer() subsampler = hybrid.Parallel(qpu, random, endomorphic=False) | hybrid.ArgMin() iteration = hybrid.Race( hybrid.InterruptableTabuSampler(), subproblems | subsampler ) | hybrid.ArgMin()