NEC
NEC is developing quantum annealers using superconducting parametron qubits with a greater number of all-to-all connected qubits.
Solver
Model | Solvers |
---|---|
Quadratic Unconstrained Binary Optimization (QUBO) | nec.vector_annealer , nec_3.vector_annealer |
QUBO
import strangeworks as sw
from strangeworks_optimization import StrangeworksOptimizer
from strangeworks_optimization_models.parameter_models import NEC2ParameterModel
from dimod import BinaryQuadraticModel
sw.authenticate(api_key)
linear = {1: -2, 2: -2, 3: -3, 4: -3, 5: -2}
quadratic = {(1, 2): 2, (1, 3): 2, (2, 4): 2, (3, 4): 2, (3, 5): 2, (4, 5): 2}
model = BinaryQuadraticModel(linear, quadratic, "BINARY")
options = NEC2ParameterModel(offset=0, num_reads=2, num_results=2, timeout=100)
solver = "nec.vector_annealer"
so = StrangeworksOptimizer(
model=model,
solver=solver,
options=options)
sw_job = so.run()
print(f"Job slug: {sw_job.slug}")
print(f"Job status: {so.status(sw_job.slug)}")
results = so.results(sw_job.slug)
Native QUBO
The native NEC QUBO Dictionary is a representation of a Quadratic Unconstrained Binary Optimization (QUBO) problem. In the QUBO Dictionary, each key-value pair represents a term in the QUBO problem. The keys are tuples that represent the variables involved in the term, and the values represent the coefficients of those terms.
For example, a QUBO Dictionary may look like this:
QuboDict({("x1", "x1"): 1.0, ("x1", "x2"): -2.0})
In this case, the QUBO problem has two variables, x1
and x2
. The first term (x1, x1)
has a coefficient of 1.0
, and the second term (x1, x2)
has a coefficient of -2.0
.
import strangeworks as sw
from strangeworks_optimization import StrangeworksOptimizer
from strangeworks_optimization_models.parameter_models import NECParameterModel
from strangeworks_optimization_models.problem_models import QuboDict
sw.authenticate(api_key)
model = QuboDict({("x1", "x1"): 1.0, ("x1", "x2"): -2.0})
options = NECParameterModel(offset=0, num_reads=2, num_results=2, timeout=100)
solver = "nec.vector_annealer"
so = StrangeworksOptimizer(
model=model,
solver=solver,
options=options)
sw_job = so.run()
print(f"Job slug: {sw_job.slug}")
print(f"Job status: {so.status(sw_job.slug)}")
results = so.results(sw_job.slug)
Results
As with other solvers, the results are returned as a sample set.
NEC includes additional information for each sample in the vectors
field, an array-like structure containing data fields for spin constraint satisfaction (constraint
), memory usage (memory_usage
), and Vector Annealer operation time (time
). This allows for detailed analysis and aggregation using dimod.SampleSet
methods.
sampleset = so.results(sw_job.slug).solution
for datum in sampleset.data(fields=["vectors"]):
print(datum)
Notebooks
Traveling Salesman Problem
Number Problem
NEC 2.0
Parameters
from strangeworks_optimization_models.parameter_models import NEC2ParameterModel
options = NEC2ParameterModel(.....)
Name | Description | Default | Values (Range) |
---|---|---|---|
offset | Offset to normalize weights in the QUBO formulation. | 0.0 | [-3.402823E+38, 3.402823E+38] |
num_reads | Number of annealing sweeps to perform, determining solution attempts. | 1 | [1, 20] |
num_results | Number of top solutions to retrieve from the annealing process. | 1 | [1, num_reads] |
num_sweeps | Number of sweeps per annealing. | 500 | [1, 100000] |
beta_range | Beta value range for VA in [start, end, steps]. | [10.0, 100.0, 200] | start: [1.1754945E-38, 3.402823E+38], end: [1.1754945E-38, 3.402823E+38], steps: [1, 100000] |
beta_list | Array of beta values for the annealing schedule. | None | [1.1754945E-38, 3.402823E+38] |
dense | Matrix mode for VA. True for dense, False for sparse. | None | [None, True, False] |
vector_mode | Mode during VA annealing: speed or accuracy. | speed | [speed, accuracy] |
timeout | Time limit in seconds for job execution. | 1800 | [1, 7200] |
Ve_num | Number of Vector Engines (VEs) engaged in the annealing process. | 1 | [1, max VE available] |
onehot | One-hot encoding constraints. | [] | Example: [["x[0]", "x[1]"], ["x[2]", "x[3]"]] |
fixed | Fixed value constraints for variables. | {} | Example: {"x[0]": 1, "x[1]": 0} |
andzero | Constraints ensuring combinations result in zero. | [] | Example: [["x[0]", "x[1]"], ["x[2]", "x[3]"]] |
orone | Constraints ensuring at least one variable equals one. | [] | Example: [["x[0]", "x[1]"], ["x[2]", "x[3]"]] |
supplement | Additional constraints for solution space exploration. | [] | Example: [["x[0]", "x[1]"], ["x[2]", "x[3]"]] |
maxone | Max number of ones in a solution subset. | [] | Example: [[1, ["x[0]", "x[1]"]], [2, ["x[2]", "x[3]"]]] |
minmaxone | Min limit on max number of ones in a subset. | [] | Example: [[1, ["x[0]", "x[1]"]], [2, ["x[2]", "x[3]"]]] |
init_spin | Initial spin settings for the annealing process. | {} | Example: {"x[0]": 1, "x[1]": 0} |
spin_list | List of initial spin values used to define constraints or initial conditions. | [] | Example: ["x[0]", "x[1]", "x[2]"] |
Solvers
- nec.vector_annealer
NEC 3.0
Parameters
from strangeworks_optimization_models.parameter_models import NEC3ParameterModel
options = NEC3ParameterModel(.....)
Name | Description | Default | Values (Range) |
---|---|---|---|
offset | Offset to normalize weights in the QUBO formulation. | 0.0 | [-3.402823E+38, 3.402823E+38] |
num_reads | Number of annealing sweeps to perform, determining solution attempts. | 1 | [1, 20] |
num_results | Number of top solutions to retrieve from the annealing process. | 1 | [1, num_reads] |
timeout | Time limit in seconds for job execution. | 1800 | [1, 7200] |
num_sweeps | Number of sweeps per annealing. | 500 | [1, 100000] |
beta_range | Beta value range for VA in [start, end, steps]. | [10.0, 100.0, 200] | start: [1.1754945E-38, 3.402823E+38], end: [1.1754945E-38, 3.402823E+38], steps: [1, 100000] |
beta_list | Array of beta values for the annealing schedule. | None | [1.1754945E-38, 3.402823E+38] |
dense | Matrix mode for VA. True for dense, False for sparse. | None | [None, True, False] |
num_threads | Number of threads for computation. | None | [1, 128] |
vector_mode | Mode during VA annealing: speed or accuracy. | speed | [speed, accuracy] |
precision | Precision level for computations. | None | [1, 64] |
onehot | One-hot encoding constraints. | None | Example: [["x[0]", "x[1]"], ["x[2]", "x[3]"]] |
fixed | Fixed value constraints for variables. | {} | Example: {"x[0]": 1, "x[1]": 0} |
andzero | Constraints ensuring combinations result in zero. | [] | Example: [["x[0]", "x[1]"], ["x[2]", "x[3]"]] |
orone | Constraints ensuring at least one variable equals one. | [] | Example: [["x[0]", "x[1]"], ["x[2]", "x[3]"]] |
supplement | Additional constraints for solution space exploration. | [] | Example: [["x[0]", "x[1]"], ["x[2]", "x[3]"]] |
maxone | Max number of ones in a solution subset. | [[2, ["1", "2"]]] | Example: [[1, ["x[0]", "x[1]"]], [2, ["x[2]", "x[3]"]]] |
minmaxone | Min limit on max number of ones in a subset. | [] | Example: [[1, ["x[0]", "x[1]"]], [2, ["x[2]", "x[3]"]]] |
high_order | High-order constraints for the problem. | None | Example: {"x[0]": 1, "x[1]": 0} |
pattern | Pattern constraints for the problem. | None | Example: [["x[0]", "x[1]"], ["x[2]", "x[3]"]] |
weighted_sum | Weighted sum constraints for the problem. | None | Example: [["x[0]", "x[1]"], ["x[2]", "x[3]"]] |
init_spin | Initial spin settings for the annealing process. | {} | Example: {"x[0]": 1, "x[1]": 0} |
Solvers
- nec_3.vector_annealer