Tutorial 2 - Backend and Solver Configuration¶
In [1]:
Copied!
#import networkx as nx
#from mis import MISInstance, MISSolver
#from mis.config import SolverConfig, BackendType
# 1. Define a small graph
#graph = nx.Graph()
#graph.add_edges_from([(0, 1), (0, 2)])
#import networkx as nx
#from mis import MISInstance, MISSolver
#from mis.config import SolverConfig, BackendType
# 1. Define a small graph
#graph = nx.Graph()
#graph.add_edges_from([(0, 1), (0, 2)])
This is how the user can review the pulse and register
In [2]:
Copied!
#instance = MISInstance(graph)
#config = SolverConfig(
# method = "wmis", # or "greedy"
# use_quantum=False,
# backend=BackendType.QUTIP,
# max_iterations=3,
# username="your_username",
# password="your_password",
# project_id="optional_project_id"
#)
#solver = MISSolver(instance, config)
# get the register
#register = solver.embedding()
# get the pulse
#pulse = solver.pulse(register) if config.use_quantum else None
# solve
#result = solver.solve()
#instance = MISInstance(graph)
#config = SolverConfig(
# method = "wmis", # or "greedy"
# use_quantum=False,
# backend=BackendType.QUTIP,
# max_iterations=3,
# username="your_username",
# password="your_password",
# project_id="optional_project_id"
#)
#solver = MISSolver(instance, config)
# get the register
#register = solver.embedding()
# get the pulse
#pulse = solver.pulse(register) if config.use_quantum else None
# solve
#result = solver.solve()
For extra customization
In [3]:
Copied!
#import networkx as nx
#from mis import MISInstance, MISSolution, MISSolver
#from mis.config import SolverConfig, BackendType
#from mis.pipeline import BaseEmbedder, BasePulseShaper
#from mis.pipeline.targets import Register, Pulse
#graph = nx.Graph()
#graph.add_edges_from([(0, 1), (1, 2)])
#instance = MISInstance(graph)
#import networkx as nx
#from mis import MISInstance, MISSolution, MISSolver
#from mis.config import SolverConfig, BackendType
#from mis.pipeline import BaseEmbedder, BasePulseShaper
#from mis.pipeline.targets import Register, Pulse
#graph = nx.Graph()
#graph.add_edges_from([(0, 1), (1, 2)])
#instance = MISInstance(graph)
In [4]:
Copied!
#config = SolverConfig(
# use_quantum=True,
# backend=BackendType.REMOTE_EMUMPS,
# max_iterations=2,
# username="user",
# password="pass",
# project_id="proj123"
#)
#solver = MISSolver(instance, config)
#config = SolverConfig(
# use_quantum=True,
# backend=BackendType.REMOTE_EMUMPS,
# max_iterations=2,
# username="user",
# password="pass",
# project_id="proj123"
#)
#solver = MISSolver(instance, config)
In [5]:
Copied!
# Define a register
#class MyCustomEmbedder(BaseEmbedder):
# def embed(self) -> Register:
# return Register(atoms={0: (0, 0), 1: (1, 0), 2: (0.5, 0.866)})
# have access to layouts?
# We dont teavh users about layouts
#class MyCustomPulseShaper(BasePulseShaper):
# def embed(self) -> Register:
# return Pulse({})
# Inject your embedder
#solver._solver.embedder = MyCustomEmbedder(instance, config)
#solver._solver.pulsershaper = MyCustomPulseShaper(instance, config)
# Define a register
#class MyCustomEmbedder(BaseEmbedder):
# def embed(self) -> Register:
# return Register(atoms={0: (0, 0), 1: (1, 0), 2: (0.5, 0.866)})
# have access to layouts?
# We dont teavh users about layouts
#class MyCustomPulseShaper(BasePulseShaper):
# def embed(self) -> Register:
# return Pulse({})
# Inject your embedder
#solver._solver.embedder = MyCustomEmbedder(instance, config)
#solver._solver.pulsershaper = MyCustomPulseShaper(instance, config)
In [6]:
Copied!
#solution: MISSolution = solver.solve()
#print("Final bitstring:", solution.bitstrings)
#print("Final cost:", solution.costs)
#solution: MISSolution = solver.solve()
#print("Final bitstring:", solution.bitstrings)
#print("Final cost:", solution.costs)