Jij
Jij 🔗 is part of the Strangeworks Syndicate and is working on developing quantum annealing devices.
Solvers​
Model | Solvers |
---|---|
Quadratic Unconstrained Binary Optimization (QUBO) | jij.SA , jij.SQA |
Constrained Quadratic Model (CQM) | jij.LeapHybridCQM |
note
The maximum calculation time before solver timeout is 600.0s.
Simulated Annealing​
Quadratic Unconstrained Binary Optimization (QUBO)​
import strangeworks as sw
from strangeworks_optimization import StrangeworksOptimizer
from strangeworks_optimization_models.parameter_models import JijSAParameterModel
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")
solver = "jij.SA"
options = JijSAParameterModel(num_sweeps=2000, num_reads=100)
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)
Parameters​
from strangeworks_optimization_models.parameter_models import JijSAParameterModel
options = JijSAParameterModel(.....)
Solvers
- jij.SA
Name | Description | Default Value |
---|---|---|
feed_dict | Dictionary of coefficients for jm.Problem. | None |
num_search | Number of times algorithm will be run. | 1 |
multipliers | Multipliers for any constraints in jm.Problem | None |
beta_min | Inverse temperature. | None |
beta_max | Inverse temperature. | None |
num_sweeps | The number of Monte-Carlo steps. | 1000 |
num_reads | The number of samples. If `None`, 1 will be set. | 1 |
initial_state | Initial state. | None |
updater | Updater algorithm. "single spin flip" or "swendsen wang". | single spin flip |
sparse | If `True`, only non-zero matrix elements are stored, which will save memory. | False |
reinitialize_state | If `True`, reinitialize state for each run. | True |
seed | Seed for Monte Carlo algorithm. | None |
needs_square_constraints | This dictionary object is utilized to determine whether to square the constraint condition while incorporating it into the QUBO/HUBO penalty term. Here, the constraint's name is used as the key. If the value is set to True, the corresponding constraint is squared upon its addition to the QUBO/HUBO penalty term. | True for linear constraints, and to False for non-linear ones. |
relax_as_penalties | This dictionary object is designed to regulate the incorporation of constraint conditions into the QUBO/HUBO penalty term, with the constraint's name functioning as the key. If the key's value is True, the respective constraint is added to the QUBO/HUBO penalty term. If the value is False, the constraint is excluded from the penalty term, though it remains subject to evaluation to verify if it meets the constraint conditions. | True |
Simulated Quantum Annealing​
Quadratic Unconstrained Binary Optimization (QUBO)​
import strangeworks as sw
from strangeworks_optimization import StrangeworksOptimizer
from strangeworks_optimization_models.parameter_models import JijSQAParameterModel
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")
solver = "jij.SQA"
options = JijSQAParameterModel(num_sweeps=2000, num_reads=100)
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)
Parameters​
from strangeworks_optimization_models.parameter_models import JijSQAParameterModel
options = JijSQAParameterModel(.....)
Solvers
- jij.SQA
Name | Description | Default Value |
---|---|---|
feed_dict | Dictionary of coefficients for jm.Problem. | None |
num_search | Number of times algorithm will be run. | 1 |
multipliers | Multipliers for any constraints in jm.Problem | None |
beta | Inverse temperature. | None |
gamma | Strength of transverse field. | None |
num_sweeps | The number of Monte-Carlo steps. | 1000 |
num_reads | The number of samples. | 1 |
sparse | If `True`, only non-zero matrix elements are stored, which will save memory. | False |
reinitialize_state | If `True`, reinitialize state for each run. | True |
seed | Seed for Monte Carlo algorithm. | None |
needs_square_constraints | This dictionary object is utilized to determine whether to square the constraint condition while incorporating it into the QUBO/HUBO penalty term. Here, the constraint's name is used as the key. If the value is set to True, the corresponding constraint is squared upon its addition to the QUBO/HUBO penalty term. | True for linear constraints, and to False for non-linear ones. |
relax_as_penalties | This dictionary object is designed to regulate the incorporation of constraint conditions into the QUBO/HUBO penalty term, with the constraint's name functioning as the key. If the key's value is True, the respective constraint is added to the QUBO/HUBO penalty term. If the value is False, the constraint is excluded from the penalty term, though it remains subject to evaluation to verify if it meets the constraint conditions. | True |
Name | Description | Default Value |
---|---|---|
feed_dict | Dictionary of coefficients for jm.Problem. | None |
num_search | Number of times algorithm will be run. | 1 |
multipliers | Multipliers for any constraints in jm.Problem | None |
beta | Inverse temperature. | None |
gamma | Strength of transverse field. | None |
num_sweeps | The number of Monte-Carlo steps. | 1000 |
num_reads | The number of samples. | 1 |
sparse | If True , only non-zero matrix elements are stored, which will save memory. | False |
reinitialize_state | If True , reinitialize state for each run. | True |
seed | Seed for Monte Carlo algorithm. | None |
needs_square_constraints | This dictionary object is utilized to determine whether to square the constraint condition while incorporating it into the QUBO/HUBO penalty term. Here, the constraint's name is used as the key. If the value is set to True, the corresponding constraint is squared upon its addition to the QUBO/HUBO penalty term. | True for linear constraints, and to False for non-linear ones. |
relax_as_penalties | This dictionary object is designed to regulate the incorporation of constraint conditions into the QUBO/HUBO penalty term, with the constraint's name functioning as the key. If the key's value is True, the respective constraint is added to the QUBO/HUBO penalty term. If the value is False, the constraint is excluded from the penalty term, though it remains subject to evaluation to verify if it meets the constraint conditions. | True |
Leap Hybrid CQM​
Constrained Quadratic Model (CQM)​
import strangeworks as sw
from strangeworks_optimization import StrangeworksOptimizer
from strangeworks_optimization_models.parameter_models import JijLeapHybridCQMParameterModel
import jijmodeling as jm
d = jm.Placeholder("d", ndim=1) # Define variable d
d.len_at(0, latex="N") # Set latex expression of the length of d
x = jm.BinaryVar("x", shape=(d.shape[0],)) # Define binary variable
i = jm.Element("i", belong_to=(0, d.shape[0])) # Define dummy index in summation
model = jm.Problem("simple problem") # Create problem instance
model += jm.sum(i, d[i] * x[i]) # Add objective function
model += jm.Constraint("one hot", jm.sum(i, x[i]) == 1) # Add constraint condition
model # Display the problem
solver = "jij.LeapHybridCQM"
options = JijLeapHybridCQMParameterModel(feed_dict={"d": [1.0, 0.1, -2.0, 1.0]}, time_limit=10)
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)
Parameters​
from strangeworks_optimization_models.parameter_models import JijLeapHybridCQMParameterModel
options = JijLeapHybridCQMParameterModel(.....)
Solvers
- jij.LeapHybridCQM
Name | Description | Default Value |
---|---|---|
feed_dict | Dictionary of coefficients for jm.Problem. If `None`, an empty dictionary will be set. | {} |
num_search | Number of times algorithm will be run. If `None`, 1 will be set. | 1 |
time_limit | Time limit in seconds. If `None`, this will be set automatically. | None |