예제 #1
0
def hybrid_solver():
    workflow = hybrid.LoopUntilNoImprovement(hybrid.RacingBranches(
        hybrid.InterruptableTabuSampler(),
        hybrid.EnergyImpactDecomposer(size=20)
        | hybrid.QPUSubproblemAutoEmbeddingSampler()
        | hybrid.SplatComposer()) | hybrid.ArgMin(),
                                             convergence=3)
    return hybrid.HybridSampler(workflow)
예제 #2
0
def hybrid_solver():
    workflow = hybrid.Loop(hybrid.RacingBranches(
        hybrid.InterruptableTabuSampler(),
        hybrid.EnergyImpactDecomposer(
            size=30, rolling=True, rolling_history=0.75)
        | hybrid.QPUSubproblemAutoEmbeddingSampler()
        | hybrid.SplatComposer()) | hybrid.ArgMin(),
                           convergence=1)
    return hybrid.HybridSampler(workflow)
예제 #3
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

import sys

import dimod
import hybrid

# load a problem
problem = sys.argv[1]
with open(problem) as fp:
    bqm = dimod.BinaryQuadraticModel.from_coo(fp)

# define the workflow
workflow = hybrid.Loop(hybrid.RacingBranches(
    hybrid.Identity(), hybrid.InterruptableTabuSampler(),
    hybrid.EnergyImpactDecomposer(size=50, rolling=True, traversal='bfs')
    | hybrid.QPUSubproblemAutoEmbeddingSampler()
    | hybrid.SplatComposer()) | hybrid.ArgMin(),
                       convergence=3)

# create a dimod sampler that runs the workflow and sample
result = hybrid.HybridSampler(workflow).sample(bqm)

# show results
print("Solution: sample={.first}".format(result))