Skip to content

JijZept

JijAmazonBraketDWaveSampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, parameters=None, algorithm=None, num_search=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using D-Wave via Amazon Braket.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

None
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
num_reads Optional[int]

The number of samples. If None, 1000 will be set.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronization mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijAmazonBraketDWaveSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

JijDA3Sampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', da3_token='', da3_url='https://api.aispf.global.fujitsu.com/da')

Sets Jijzept token and url and Digital Annealer v3 token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Optional[Union[str, dict]]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
da3_token str

Token string for Degital Annealer 3.

''
da3_url Optional[str]

API Url string for Degital Annealer 3.

'https://api.aispf.global.fujitsu.com/da'

sample_model(model, feed_dict, fixed_variables={}, inequalities_lambda={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Digital Annealer v3.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
inequalities_lambda dict[str, int]

Coefficient of inequality. If omitted, set to 1. The coefficients

{}
parameters Optional[JijDA3SolverParameters]

Parameters used in Ditital Annealer 3. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient. Defaults to False.

False
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Digital Annealer 3 parameters using **kwags. If both **kwargs and parameters are exist,

{}

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijDA3Sampler, JijDA3SolverParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint(
    "knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j
)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
inequalities_lambda = {"knapsack_constraint": 22}

sampler = JijDA3Sampler(config="xx", da3_token="oo")
parameters = JijDA3SolverParameters(penalty_coef=2)

sampleset = sampler.sample_model(
    problem, feed_dict, inequalities_lambda=inequalities_lambda, parameters=parameters
)

JijDA3SolverParameters dataclass

Manage Parameters for using Digital Annealer v3.

Attributes:

Name Type Description
time_limit_sec int

Set the timeout in seconds in the range 1 ~ 1800.

target_energy Optional[float]

Set the target energy value. The calculation is terminated when the minimum

num_run int

Set the number of parallel trial iterations in the range 1 ~ 16.

num_group int

Set the number of groups of parallel trials in the range 1 ~ 16.

num_output_solution int

Set the number of output solutions for each parallel trial group in the range 1 ~

gs_level int

Set the level of global search. The higher this value, the longer the constraint utilization

gs_cutoff int

Set the convergence decision level in the constraint utilization search of the solver in the

penalty_auto_mode int

Set the coefficient adjustment mode for the constaint term. If 0, fixed to the

penalty_coef int

Set the coefficients of the constraint term.

penalty_inc_rate int

Set parameters for automatic adjustment of constriant term.

max_penalty_coef int

Set the maximum value of the constraint term coefficient in the global search. If no

JijDA4Sampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', da4_token='', da4_url='https://api.aispf.global.fujitsu.com/da')

Sets Jijzept token and url and Digital Annealer v4 token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Optional[Union[str, dict]]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
da4_token str

Token string for Degital Annealer 4.

''
da4_url Optional[str]

API Url string for Degital Annealer 4.

'https://api.aispf.global.fujitsu.com/da'

sample_model(model, feed_dict, fixed_variables={}, inequalities_lambda={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Digital Annealer v4.

Note that this sampler solve problems with using Azure Blob Storage, which is a feature of Digital Annealer v4, and there is no option not to use Azure Blob Storage.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
inequalities_lambda dict[str, int]

Coefficient of inequality. If omitted, set to 1. The coefficients

{}
parameters Optional[JijDA4SolverParameters]

Parameters used in Ditital Annealer 4. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient and inequality constraint conditions.

False
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Digital Annealer 4 parameters using **kwags. If both **kwargs and parameters are exist,

{}

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijDA4Sampler, JijDA4SolverParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint(
    "knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j
)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
inequalities_lambda = {"knapsack_constraint": 22}

sampler = JijDA4Sampler(config="xx", da4_token="oo")
parameters = JijDA4SolverParameters(penalty_coef=2)

sampleset = sampler.sample_model(
    problem, feed_dict, inequalities_lambda=inequalities_lambda, parameters=parameters
)

JijDA4SolverParameters dataclass

Manage Parameters for using Digital Annealer v4.

Attributes:

Name Type Description
time_limit_sec int

Set the timeout in seconds in the range 1 ~ 1800.

target_energy Optional[float]

Set the target energy value. The calculation is terminated when the minimum

num_run int

Set the number of parallel trial iterations in the range 1 ~ 16.

num_group int

Set the number of groups of parallel trials in the range 1 ~ 16.

num_output_solution int

Set the number of output solutions for each parallel trial group in the range 1 ~

gs_level int

Set the level of global search. The higher this value, the longer the constraint utilization

gs_cutoff int

Set the convergence decision level in the constraint utilization search of the solver in the

one_hot_level int

Levels of 1hot constraints search.

one_hot_cutoff int

Convergence decision level for 1hot constraints search. If 0 is set, this function is

internal_penalty int

1hot constraint internal generation mode. Note that if 1way- or 2way 1hot constraints

penalty_auto_mode int

Set the coefficient adjustment mode for the constaint term. If 0, fixed to the

penalty_coef int

Set the coefficients of the constraint term.

penalty_inc_rate int

Set parameters for automatic adjustment of constriant term.

max_penalty_coef int

Set the maximum value of the constraint term coefficient in the global search. If no

JijFixstarsAmplifyParameters dataclass

Manage Parameters for using Fixstars Amplify.

Attributes:

Name Type Description
amplify_timeout int

Set the timeout in milliseconds. Defaults to 1000.

num_gpus int

Set the number of GPUs to be used. The maximum number of GPUs available depends on the subscription plan, and 0 means the maximum number available. Defaults to 1.

penalty_calibration bool

Set whether to enable the automatic adjustment of the penalty function's

duplicate bool

If True, all solutions with the same energy and the same feasibility are output. Otherwise, only one solution with the same energy and feasibility is output.

num_outputs int

The number of solutions to be output which have different energies and feasibility. Assumed 1 if no value is set. If set to 0, all the solutions are output. Defaults to 1.

JijFixstarsAmplifySampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', fixstars_token='', fixstars_url='')

Sets Jijzept token and url and fixstars amplify token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Union[str, dict]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
fixstars_token str

Token string for Fixstars Amplify.

''
fixstars_url str

Url string for Fixstars Ampplify.

''

sample_model(model, feed_dict, multipliers={}, fixed_variables={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Converts the given problem to amplify.BinaryQuadraticModel and run.

Fixstars Amplify Solver. Note here that the supported type of decision variables is only Binary when using Fixstars Ampplify Solver from Jijzept.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers dict[str, Number]

The actual multipliers for penalty terms, derived from constraint

{}
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
parameters Optional[JijFixstarsAmplifyParameters]

Parameters used in Fixstars Amplify. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient. Defaults to False.

False
jm_sampleset bool

Selects whether the argument value should be JijModelingResponse.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None

Returns:

Type Description
JijModelingResponse

Union[DimodResponse, JijModelingResponse]: Stores samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijFixstarsAmplifySampler, JijFixstarsAmplifyParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint("knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
multipliers = {"onehot_constraint": 11, "knapsack_constraint": 22}

sampler = JijFixstarsAmplifySampler(config="xx", fixstars_token="oo")
parameters = JijFixstarsAmplifyParameters(amplify_timeout=1000, num_outputs=1, filter_solution=False,
penalty_calibration=False)
sampleset = sampler.sample_model(
    problem, feed_dict, multipliers, parameters=parameters
)

JijLeapHybridCQMParameters dataclass

Manage Parameters for using Leap Hybrid CQM Sampler.

Attributes:

Name Type Description
time_limit Optional[Union[int, float]]

the maximum run time, in seconds, the solver is allowed to work on

label str

The problem label given to the dimod.SampelSet instance returned by the JijLeapHybridCQMSampler.

JijLeapHybridCQMSampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', leap_token=None, leap_url=None)

Sets token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string for JijZept.

None
url Optional[str]

API URL for JijZept.

None
proxy Optional[str]

Proxy URL. Defaults to None.

None
config Optional[str]

Config file path for JijZept.

None
token_leap Optional[str]

Token string for Dwave Leap.

required
url_leap Optional[str]

API URL for Dwave Leap.

required

sample_model(model, feed_dict, fixed_variables=None, relax_list=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Converts the given problem to dimod.ConstrainedQuadraticModel and runs.

Dwave's LeapHybridCQMSampler. Note here that the supported type of decision variables is only Binary when using LeapHybridCQMSolver from Jijzept.

Parameters:

Name Type Description Default
problem Problem

Optimization problem of JijModeling.

required
feed_dict Dict[str, Union[Number, List, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables Optional[Dict[str, Dict[Tuple[int, ...], Union[int, float]]]]

variables to fix.

None
relax_list Optional[List[str]]

variable labels for continuous relaxation.

None
parameters Optional[JijLeapHybridCQMParameters]

Parameters used in Dwave Leap Hybrid CQMSampler. If

None
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Dwave Leap parameters using **kwags. If both **kwargs and parameters are exist, the value of

{}

Returns:

Name Type Description
JijModelingSampleset JijModelingResponse

Stores samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijLeapHybridCQMSampler, JijLeapHybridCQMParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint("knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j)
feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}

sampler = JijLeapHybridCQMSampler(config="XX", token_leap="XX")
parameters = JijLeapHybridCQMParameters(label="bin_packing")
sampleset = sampler.sample_model(
    problem, feed_dict, parameters=parameters
)

JijSASampler

Bases: JijZeptBaseSampler

Simulated annealing sampler on CPU.

This class is a sampler using SA that allows you to check if the mathematical model is correct in small problems.

See JijZeptBaseSampler for the constructor of the class.

sample_hubo(J, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sampling from higher unconstrained binary optimization model (HUBO).

Parameters:

Name Type Description Default
J dict

Polynomial interactions.

required
parameters JijSAParameters | None

(JijSAParameters | None, optional): defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

An extended type of jijmodleing.SampleSet that stores sampling results.

Examples:

import jijzept as jz
sampler = jz.JijSASampler(config='config.toml')
J = {(0,): -1, (0, 1): -1, (0, 1, 2): 1}
response = sampler.sample_hubo(J)

sample_model(model, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

sample_qubo(qubo, constant=0, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sampling from QUBO.

Parameters:

Name Type Description Default
qubo dict[tuple[int, int], float]

QUBO dictionary.

required
parameters JijSAParameters | None

SA parameters, defaults None.

None
timeout int | None

The number of timeout [sec] for post request. If None, 3600 (one hour)

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None
**kwargs

You can pass SA parameters as keyword arguments instead of specifying them in parameters. See

{}

Returns:

Type Description
JijModelingResponse

An extended type of jijmodleing.SampleSet that stores sampling results.

Examples:

import jijzept as jz
Q = {(0, 0): -1, (1, 1): -1, (2, 2): 1, (0, 1): -1, (1, 2): 1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_qubo(Q)

JijSQASampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

sample_qubo(qubo, constant=0, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using BinaryQuadraticModel by means of the simulated annealing.

Parameters:

Name Type Description Default
bqm Union[cimod.BinaryQuadraticModel, openjij.BinaryQuadraticModel]

Binary quadratic model.

required
parameters JijSQAParameters | None

(JijSAParameters | None, optional): defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

For cimod.BinaryQuadraticModel case:

import jijzept as jz
import cimod
bqm = cimod.BinaryQuadraticModel({0: -1, 1: -1}, {(0, 1): -1, (1, 2): -1}, "SPIN")
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample(bqm)
One can also use sample_ising and sample_qubo methods.

For Ising case:

import jijzept as jz
h = {0: -1, 1: -1, 2: 1, 3: 1}
J = {(0, 1): -1, (3, 4): -1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_ising(h, J)

For QUBO case:

import jijzept as jz
Q = {(0, 0): -1, (1, 1): -1, (2, 2): 1, (0, 1): -1, (1, 2): 1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_qubo(Q)

JijSXAuroraSampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Jij SX-Aurora Annealing solver.

Parameters:

Name Type Description Default
problem Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, this will be set

required
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

required
beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

required
num_reads Optional[int]

The number of samples. If None, this will be set automatically.

required
tsallis_q Optional[float]

q value of tsallis statistics. If None, this will be set

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSXAuroraSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

JijSwapMovingSampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default')

Sets token and url.

Parameters:

Name Type Description Default
token str

Token string. Defaults to None.

None
url Union[str, dict]

API URL. Defaults to None.

None
proxy str

Proxy URL. Defaults to None.

None
config str

Config file path. Defaults to None.

None

Raises:

Type Description
:obj:`TypeError`

token, url, or config is not str.

sample_hubo(J, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

The simulated annealing is performed for higher ordered unconstraind.

binary optimizations (hubo) with the linear constraint conditions. Note here that the linear constraint conditions are strictly satisfied.

Parameters:

Name Type Description Default
J Dict

Polynomial interactions.

required
parameters JijSwapMovingParameters | None

defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

import jijzept as jz
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_hubo(J={(0,1,2,3,4): -1}, vartype="SPIN",
                               constraints=[([0,1], 0), ([2,3,4], 1)])

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling. The decision variable type should be Binary.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

required
beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

required
num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, 1000 will be set.

required
num_reads Optional[int]

The number of samples. If None, 1 will be set.

required
updater Optional[str]

Updater algorithm must be "swap moving" for now. If None,

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
problem += jm.Constraint("one-hot", jm.Sum(i, x[i]) == 1)
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

sample_qubo(Q, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

The simulated annealing is performed for binary quadratic models with.

the linear constraint conditions. Note here that the linear constraint conditions are strictly satisfied.

Parameters:

Name Type Description Default
Q Dict

The linear or quadratic terms.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

import jijzept as jz
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_qubo(Q={(0,0): -0.5, (0,1): -1, (0,2): -1, (2,3): -1},
                               constraints=[([0,1], 1), ([2,3], 1)])

client

JijZeptClient

__init__(*, url=None, token=None, proxy=None, config=None, config_env='default')

Constructor of JijZept client.

Parameters:

Name Type Description Default
url str | None

url. Defaults to None.

None
token str | None

token string. Defaults to None.

None
proxy str | None

proxy string. Defaults to None.

None
config PATH_TYPE | None

config path. Defaults to None.

None
config_env str

config_env. Defaults to "default".

'default'

fetch_result(solution_id=None, endpoint='/query/solution')

Fetch result and solution from JijZept.

Parameters:

Name Type Description Default
solution_id Optional[str]

solution id. Defaults to None.

None
endpoint str

endpoint. Defaults to "/query/solution".

'/query/solution'

Returns:

Name Type Description
dict dict

serialized result of derived information

post_instance(instance_type, instance, endpoint='/instance')

Send instance to JijZept.

Parameters:

Name Type Description Default
instance_type str

instance_type of the instance

required
instance Dict[str, Any]

serialized instance object. This object is compressed by zstandard

required
endpoint str

endpoint. Defaults to "/instance".

'/instance'

Raises:

Type Description
TypeError

instance_type or instance

Returns:

Name Type Description
str str

returned instance id

submit_solve_query(queue_name, solver_name, parameters, instance_id=None, timeout=None, endpoint='/query/solution')

Submit solve request to JijZept.

Parameters:

Name Type Description Default
queue_name str

queue_name

required
solver_name str

solver_name

required
parameters dict

parameters to be sent to queue

required
instance_id Optional[str]

problem instance id. Defaults to None.

None
timeout Optional[float]

timeout paraemter [second]. if None, timeout is set to inifite.

None
endpoint str

endpoint. Defaults to "/query/solution".

'/query/solution'

Returns:

Type Description
dict[str, str]

Dict[str, str]: solution id information.

status_check(res)

Do status check of response data.

If request has some HTTPError, this function raises Exception.

Parameters:

Name Type Description Default
res requests.Response

response from http request

required

Raises:

Type Description
requests.exceptions.HTTPError

response has some error.

client

JijZeptClient

__init__(*, url=None, token=None, proxy=None, config=None, config_env='default')

Constructor of JijZept client.

Parameters:

Name Type Description Default
url str | None

url. Defaults to None.

None
token str | None

token string. Defaults to None.

None
proxy str | None

proxy string. Defaults to None.

None
config PATH_TYPE | None

config path. Defaults to None.

None
config_env str

config_env. Defaults to "default".

'default'
fetch_result(solution_id=None, endpoint='/query/solution')

Fetch result and solution from JijZept.

Parameters:

Name Type Description Default
solution_id Optional[str]

solution id. Defaults to None.

None
endpoint str

endpoint. Defaults to "/query/solution".

'/query/solution'

Returns:

Name Type Description
dict dict

serialized result of derived information

post_instance(instance_type, instance, endpoint='/instance')

Send instance to JijZept.

Parameters:

Name Type Description Default
instance_type str

instance_type of the instance

required
instance Dict[str, Any]

serialized instance object. This object is compressed by zstandard

required
endpoint str

endpoint. Defaults to "/instance".

'/instance'

Raises:

Type Description
TypeError

instance_type or instance

Returns:

Name Type Description
str str

returned instance id

submit_solve_query(queue_name, solver_name, parameters, instance_id=None, timeout=None, endpoint='/query/solution')

Submit solve request to JijZept.

Parameters:

Name Type Description Default
queue_name str

queue_name

required
solver_name str

solver_name

required
parameters dict

parameters to be sent to queue

required
instance_id Optional[str]

problem instance id. Defaults to None.

None
timeout Optional[float]

timeout paraemter [second]. if None, timeout is set to inifite.

None
endpoint str

endpoint. Defaults to "/query/solution".

'/query/solution'

Returns:

Type Description
dict[str, str]

Dict[str, str]: solution id information.

status_check(res)

Do status check of response data.

If request has some HTTPError, this function raises Exception.

Parameters:

Name Type Description Default
res requests.Response

response from http request

required

Raises:

Type Description
requests.exceptions.HTTPError

response has some error.

config

Config dataclass

proxy: typ.Optional[pydantic.AnyUrl] class-attribute

JijZept API Config.

Attributes:

Name Type Description
query_url str

Endpoint for Query API.

post_url str

Endpoint for Post Instance API.

proxy str

Proxy URL. Defaults to None.

token str

Secret token to connect API.

__init__(*, url=None, token=None, proxy=None, config=None, config_env='default')

Parameters:

Name Type Description Default
url str | dict[str, str] | None

Endpoint for connecting to JijZept API. If you want to set

None
token str | None

token to connect JijZept API. Defaults to None.

None
proxy str | None

proxy server. Defaults to None.

None
config PATH_TYPE | None

config file path. Defaults to None.

None
config_env str

config environment name. Defaults to "default".

'default'

Raises:

Type Description
jijzept.exception.ConfigError

parse error.

TypeError

url schema or config path is invaild.

pydantic.error_wrappers.ValidationError

url schema or config path is invaild.

handle_config

Config dataclass

proxy: typ.Optional[pydantic.AnyUrl] class-attribute

JijZept API Config.

Attributes:

Name Type Description
query_url str

Endpoint for Query API.

post_url str

Endpoint for Post Instance API.

proxy str

Proxy URL. Defaults to None.

token str

Secret token to connect API.

__init__(*, url=None, token=None, proxy=None, config=None, config_env='default')

Parameters:

Name Type Description Default
url str | dict[str, str] | None

Endpoint for connecting to JijZept API. If you want to set

None
token str | None

token to connect JijZept API. Defaults to None.

None
proxy str | None

proxy server. Defaults to None.

None
config PATH_TYPE | None

config file path. Defaults to None.

None
config_env str

config environment name. Defaults to "default".

'default'

Raises:

Type Description
jijzept.exception.ConfigError

parse error.

TypeError

url schema or config path is invaild.

pydantic.error_wrappers.ValidationError

url schema or config path is invaild.

config_file_path(file_path)

Get config file path.

Configuration files are explored in the following order When found, the path to the file is returned, or None if not found. If the user specifies a file path in file_path arguments, it is returned in preference to all of the following.

The search goes for the jijzept and jijzept_config.toml files in the following directories.

  1. Current directory: pathlib.Path().cwd()
  2. $XDG_CONFIG_HOME
  3. ~/.config

The search order of this function is the priority order of config files in JijZept.

Parameters:

Name Type Description Default
file_path typ.Union[pathlib.Path, str, None]

file path. Defaults to None.

required

Returns:

Type Description
typ.Optional[pathlib.Path]

pathlib.Path | None: config file path

load_config(*, file_path, config='default')

Load config file (TOML file).

Parameters:

Name Type Description Default
file_path pathlib.Path

path to config file.

required
config str

loading enviroment name. Defaults to 'default'.

'default'

Raises:

Type Description
TypeError

if 'config' enviroment is not defined in config file.

Returns:

Name Type Description
dict dict

ex. {'token': 'xxxx', 'url': 'xxxx'}

post_api

post_instance_and_query(ResponseType, client, instance_type, instance, queue_name, solver, parameters, timeout, sync=True)

Low-level API for sending instance and solve request to JijZept.

Parameters:

Name Type Description Default
client JijZeptClient

JijZept client object

required
instance_type str

instance type

required
instance Dict[str, Any]

serialized instance object.

required
queue_name str

queue_name that specifies which solver the request to be sent to.

required
solver str

solver string that is used in JijZept solvers.

required
parameters dict

additional parameters to be sent to JijZept solvers.

required
timeout Optional[float]

solver timeout [second]

required
ResponseType Type[TypeVar

Response Type. Defaults to "BaseResponse")].

required
sync bool

set sync model. if True, this function does polling until the solution status is

True

Returns:

Name Type Description
ResponseType

response object

post_api

post_instance_and_query(ResponseType, client, instance_type, instance, queue_name, solver, parameters, timeout, sync=True)

Low-level API for sending instance and solve request to JijZept.

Parameters:

Name Type Description Default
client JijZeptClient

JijZept client object

required
instance_type str

instance type

required
instance Dict[str, Any]

serialized instance object.

required
queue_name str

queue_name that specifies which solver the request to be sent to.

required
solver str

solver string that is used in JijZept solvers.

required
parameters dict

additional parameters to be sent to JijZept solvers.

required
timeout Optional[float]

solver timeout [second]

required
ResponseType Type[TypeVar

Response Type. Defaults to "BaseResponse")].

required
sync bool

set sync model. if True, this function does polling until the solution status is

True

Returns:

Name Type Description
ResponseType

response object

response

APIStatus

Bases: AutoName

API Status.

PENDING shows that the request has been sent but not caught by solvers.

RUNNING shows that the request has been sent and caught by solvers.

SUCCESS shows that solver returns the solution successfully.

FAILED shows that solver fails to return solutions with some errors.

UNKNOWNERROR and VALIDATIONERROR shows that solver fails to return solutions with some errors that is not expected. Please contact to Jij development team if you find this error.

BaseResponse

empty_data() classmethod abstractmethod

Abstract method for generating empty data.

empty_response(status, client, solution_id, err_dict={}) classmethod

Generate empty_response.

Parameters:

Name Type Description Default
status APIStatus

status

required
client JijZeptClient

client

required
solution_id str

solution_id

required
err_dict {}

from_json_obj(json_obj) classmethod abstractmethod

Abstract method for initializing object from JSON data.

Parameters:

Name Type Description Default
json_obj

JSON data

required

get_result(solution_id=None)

Get result from cloud.

If solution_id is specified. use this id. Otherwise, use self.solution_id

If status is updated. update self data

Parameters:

Name Type Description Default
solution_id Optional[str]

specified solution id. Defaults to None.

None

Returns:

Name Type Description
_TBaseResponse _TBaseResponse

description

JijModelingResponse

Bases: BaseResponse, jm.SampleSet

Return object from JijZept.

This class inherits from jijmodeling.sampleset.SampleSet.

from_json_obj(json_obj) classmethod

Generate object from JSON object.

Parameters:

Name Type Description Default
json_obj str

JSON object

required

Returns:

Name Type Description
Any Any

object

base

APIStatus

Bases: AutoName

API Status.

PENDING shows that the request has been sent but not caught by solvers.

RUNNING shows that the request has been sent and caught by solvers.

SUCCESS shows that solver returns the solution successfully.

FAILED shows that solver fails to return solutions with some errors.

UNKNOWNERROR and VALIDATIONERROR shows that solver fails to return solutions with some errors that is not expected. Please contact to Jij development team if you find this error.

BaseResponse

empty_data() classmethod abstractmethod

Abstract method for generating empty data.

empty_response(status, client, solution_id, err_dict={}) classmethod

Generate empty_response.

Parameters:

Name Type Description Default
status APIStatus

status

required
client JijZeptClient

client

required
solution_id str

solution_id

required
err_dict {}
from_json_obj(json_obj) classmethod abstractmethod

Abstract method for initializing object from JSON data.

Parameters:

Name Type Description Default
json_obj

JSON data

required
get_result(solution_id=None)

Get result from cloud.

If solution_id is specified. use this id. Otherwise, use self.solution_id

If status is updated. update self data

Parameters:

Name Type Description Default
solution_id Optional[str]

specified solution id. Defaults to None.

None

Returns:

Name Type Description
_TBaseResponse _TBaseResponse

description

jmresponse

JijModelingResponse

Bases: BaseResponse, jm.SampleSet

Return object from JijZept.

This class inherits from jijmodeling.sampleset.SampleSet.

from_json_obj(json_obj) classmethod

Generate object from JSON object.

Parameters:

Name Type Description Default
json_obj str

JSON object

required

Returns:

Name Type Description
Any Any

object

sampler

JijAmazonBraketDWaveSampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, parameters=None, algorithm=None, num_search=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using D-Wave via Amazon Braket.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

None
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
num_reads Optional[int]

The number of samples. If None, 1000 will be set.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronization mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijAmazonBraketDWaveSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

JijDA3Sampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', da3_token='', da3_url='https://api.aispf.global.fujitsu.com/da')

Sets Jijzept token and url and Digital Annealer v3 token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Optional[Union[str, dict]]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
da3_token str

Token string for Degital Annealer 3.

''
da3_url Optional[str]

API Url string for Degital Annealer 3.

'https://api.aispf.global.fujitsu.com/da'

sample_model(model, feed_dict, fixed_variables={}, inequalities_lambda={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Digital Annealer v3.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
inequalities_lambda dict[str, int]

Coefficient of inequality. If omitted, set to 1. The coefficients

{}
parameters Optional[JijDA3SolverParameters]

Parameters used in Ditital Annealer 3. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient. Defaults to False.

False
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Digital Annealer 3 parameters using **kwags. If both **kwargs and parameters are exist,

{}

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijDA3Sampler, JijDA3SolverParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint(
    "knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j
)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
inequalities_lambda = {"knapsack_constraint": 22}

sampler = JijDA3Sampler(config="xx", da3_token="oo")
parameters = JijDA3SolverParameters(penalty_coef=2)

sampleset = sampler.sample_model(
    problem, feed_dict, inequalities_lambda=inequalities_lambda, parameters=parameters
)

JijDA3SolverParameters dataclass

Manage Parameters for using Digital Annealer v3.

Attributes:

Name Type Description
time_limit_sec int

Set the timeout in seconds in the range 1 ~ 1800.

target_energy Optional[float]

Set the target energy value. The calculation is terminated when the minimum

num_run int

Set the number of parallel trial iterations in the range 1 ~ 16.

num_group int

Set the number of groups of parallel trials in the range 1 ~ 16.

num_output_solution int

Set the number of output solutions for each parallel trial group in the range 1 ~

gs_level int

Set the level of global search. The higher this value, the longer the constraint utilization

gs_cutoff int

Set the convergence decision level in the constraint utilization search of the solver in the

penalty_auto_mode int

Set the coefficient adjustment mode for the constaint term. If 0, fixed to the

penalty_coef int

Set the coefficients of the constraint term.

penalty_inc_rate int

Set parameters for automatic adjustment of constriant term.

max_penalty_coef int

Set the maximum value of the constraint term coefficient in the global search. If no

JijDA4Sampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', da4_token='', da4_url='https://api.aispf.global.fujitsu.com/da')

Sets Jijzept token and url and Digital Annealer v4 token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Optional[Union[str, dict]]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
da4_token str

Token string for Degital Annealer 4.

''
da4_url Optional[str]

API Url string for Degital Annealer 4.

'https://api.aispf.global.fujitsu.com/da'

sample_model(model, feed_dict, fixed_variables={}, inequalities_lambda={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Digital Annealer v4.

Note that this sampler solve problems with using Azure Blob Storage, which is a feature of Digital Annealer v4, and there is no option not to use Azure Blob Storage.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
inequalities_lambda dict[str, int]

Coefficient of inequality. If omitted, set to 1. The coefficients

{}
parameters Optional[JijDA4SolverParameters]

Parameters used in Ditital Annealer 4. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient and inequality constraint conditions.

False
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Digital Annealer 4 parameters using **kwags. If both **kwargs and parameters are exist,

{}

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijDA4Sampler, JijDA4SolverParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint(
    "knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j
)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
inequalities_lambda = {"knapsack_constraint": 22}

sampler = JijDA4Sampler(config="xx", da4_token="oo")
parameters = JijDA4SolverParameters(penalty_coef=2)

sampleset = sampler.sample_model(
    problem, feed_dict, inequalities_lambda=inequalities_lambda, parameters=parameters
)

JijDA4SolverParameters dataclass

Manage Parameters for using Digital Annealer v4.

Attributes:

Name Type Description
time_limit_sec int

Set the timeout in seconds in the range 1 ~ 1800.

target_energy Optional[float]

Set the target energy value. The calculation is terminated when the minimum

num_run int

Set the number of parallel trial iterations in the range 1 ~ 16.

num_group int

Set the number of groups of parallel trials in the range 1 ~ 16.

num_output_solution int

Set the number of output solutions for each parallel trial group in the range 1 ~

gs_level int

Set the level of global search. The higher this value, the longer the constraint utilization

gs_cutoff int

Set the convergence decision level in the constraint utilization search of the solver in the

one_hot_level int

Levels of 1hot constraints search.

one_hot_cutoff int

Convergence decision level for 1hot constraints search. If 0 is set, this function is

internal_penalty int

1hot constraint internal generation mode. Note that if 1way- or 2way 1hot constraints

penalty_auto_mode int

Set the coefficient adjustment mode for the constaint term. If 0, fixed to the

penalty_coef int

Set the coefficients of the constraint term.

penalty_inc_rate int

Set parameters for automatic adjustment of constriant term.

max_penalty_coef int

Set the maximum value of the constraint term coefficient in the global search. If no

JijFixstarsAmplifyParameters dataclass

Manage Parameters for using Fixstars Amplify.

Attributes:

Name Type Description
amplify_timeout int

Set the timeout in milliseconds. Defaults to 1000.

num_gpus int

Set the number of GPUs to be used. The maximum number of GPUs available depends on the subscription plan, and 0 means the maximum number available. Defaults to 1.

penalty_calibration bool

Set whether to enable the automatic adjustment of the penalty function's

duplicate bool

If True, all solutions with the same energy and the same feasibility are output. Otherwise, only one solution with the same energy and feasibility is output.

num_outputs int

The number of solutions to be output which have different energies and feasibility. Assumed 1 if no value is set. If set to 0, all the solutions are output. Defaults to 1.

JijFixstarsAmplifySampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', fixstars_token='', fixstars_url='')

Sets Jijzept token and url and fixstars amplify token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Union[str, dict]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
fixstars_token str

Token string for Fixstars Amplify.

''
fixstars_url str

Url string for Fixstars Ampplify.

''

sample_model(model, feed_dict, multipliers={}, fixed_variables={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Converts the given problem to amplify.BinaryQuadraticModel and run.

Fixstars Amplify Solver. Note here that the supported type of decision variables is only Binary when using Fixstars Ampplify Solver from Jijzept.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers dict[str, Number]

The actual multipliers for penalty terms, derived from constraint

{}
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
parameters Optional[JijFixstarsAmplifyParameters]

Parameters used in Fixstars Amplify. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient. Defaults to False.

False
jm_sampleset bool

Selects whether the argument value should be JijModelingResponse.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None

Returns:

Type Description
JijModelingResponse

Union[DimodResponse, JijModelingResponse]: Stores samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijFixstarsAmplifySampler, JijFixstarsAmplifyParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint("knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
multipliers = {"onehot_constraint": 11, "knapsack_constraint": 22}

sampler = JijFixstarsAmplifySampler(config="xx", fixstars_token="oo")
parameters = JijFixstarsAmplifyParameters(amplify_timeout=1000, num_outputs=1, filter_solution=False,
penalty_calibration=False)
sampleset = sampler.sample_model(
    problem, feed_dict, multipliers, parameters=parameters
)

JijLeapHybridCQMParameters dataclass

Manage Parameters for using Leap Hybrid CQM Sampler.

Attributes:

Name Type Description
time_limit Optional[Union[int, float]]

the maximum run time, in seconds, the solver is allowed to work on

label str

The problem label given to the dimod.SampelSet instance returned by the JijLeapHybridCQMSampler.

JijLeapHybridCQMSampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', leap_token=None, leap_url=None)

Sets token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string for JijZept.

None
url Optional[str]

API URL for JijZept.

None
proxy Optional[str]

Proxy URL. Defaults to None.

None
config Optional[str]

Config file path for JijZept.

None
token_leap Optional[str]

Token string for Dwave Leap.

required
url_leap Optional[str]

API URL for Dwave Leap.

required

sample_model(model, feed_dict, fixed_variables=None, relax_list=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Converts the given problem to dimod.ConstrainedQuadraticModel and runs.

Dwave's LeapHybridCQMSampler. Note here that the supported type of decision variables is only Binary when using LeapHybridCQMSolver from Jijzept.

Parameters:

Name Type Description Default
problem Problem

Optimization problem of JijModeling.

required
feed_dict Dict[str, Union[Number, List, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables Optional[Dict[str, Dict[Tuple[int, ...], Union[int, float]]]]

variables to fix.

None
relax_list Optional[List[str]]

variable labels for continuous relaxation.

None
parameters Optional[JijLeapHybridCQMParameters]

Parameters used in Dwave Leap Hybrid CQMSampler. If

None
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Dwave Leap parameters using **kwags. If both **kwargs and parameters are exist, the value of

{}

Returns:

Name Type Description
JijModelingSampleset JijModelingResponse

Stores samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijLeapHybridCQMSampler, JijLeapHybridCQMParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint("knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j)
feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}

sampler = JijLeapHybridCQMSampler(config="XX", token_leap="XX")
parameters = JijLeapHybridCQMParameters(label="bin_packing")
sampleset = sampler.sample_model(
    problem, feed_dict, parameters=parameters
)

JijSAParameters dataclass

Parameters for JijSASampler.

Attributes:

Name Type Description
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, 1000 will be set.

num_reads Optional[int]

The number of samples. If None, 1 will be set.

initial_state Optional[dict]

Initial state. If None, this will be set automatically.

updater Optional[str]

Updater algorithm. "single spin flip" or "swendsen wang". If None,

sparse Optional[bool]

If True, only non-zero matrix elements are stored, which will save

reinitialize_state Optional[bool]

If True, reinitialize state for each run. If None,

seed Optional[int]

Seed for Monte Carlo algorithm. If None, this will be set automatically.

JijSASampler

Bases: JijZeptBaseSampler

Simulated annealing sampler on CPU.

This class is a sampler using SA that allows you to check if the mathematical model is correct in small problems.

See JijZeptBaseSampler for the constructor of the class.

sample_hubo(J, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sampling from higher unconstrained binary optimization model (HUBO).

Parameters:

Name Type Description Default
J dict

Polynomial interactions.

required
parameters JijSAParameters | None

(JijSAParameters | None, optional): defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

An extended type of jijmodleing.SampleSet that stores sampling results.

Examples:

import jijzept as jz
sampler = jz.JijSASampler(config='config.toml')
J = {(0,): -1, (0, 1): -1, (0, 1, 2): 1}
response = sampler.sample_hubo(J)

sample_model(model, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

sample_qubo(qubo, constant=0, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sampling from QUBO.

Parameters:

Name Type Description Default
qubo dict[tuple[int, int], float]

QUBO dictionary.

required
parameters JijSAParameters | None

SA parameters, defaults None.

None
timeout int | None

The number of timeout [sec] for post request. If None, 3600 (one hour)

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None
**kwargs

You can pass SA parameters as keyword arguments instead of specifying them in parameters. See

{}

Returns:

Type Description
JijModelingResponse

An extended type of jijmodleing.SampleSet that stores sampling results.

Examples:

import jijzept as jz
Q = {(0, 0): -1, (1, 1): -1, (2, 2): 1, (0, 1): -1, (1, 2): 1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_qubo(Q)

JijSQASampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

sample_qubo(qubo, constant=0, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using BinaryQuadraticModel by means of the simulated annealing.

Parameters:

Name Type Description Default
bqm Union[cimod.BinaryQuadraticModel, openjij.BinaryQuadraticModel]

Binary quadratic model.

required
parameters JijSQAParameters | None

(JijSAParameters | None, optional): defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

For cimod.BinaryQuadraticModel case:

import jijzept as jz
import cimod
bqm = cimod.BinaryQuadraticModel({0: -1, 1: -1}, {(0, 1): -1, (1, 2): -1}, "SPIN")
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample(bqm)
One can also use sample_ising and sample_qubo methods.

For Ising case:

import jijzept as jz
h = {0: -1, 1: -1, 2: 1, 3: 1}
J = {(0, 1): -1, (3, 4): -1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_ising(h, J)

For QUBO case:

import jijzept as jz
Q = {(0, 0): -1, (1, 1): -1, (2, 2): 1, (0, 1): -1, (1, 2): 1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_qubo(Q)

JijSXAuroraSampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Jij SX-Aurora Annealing solver.

Parameters:

Name Type Description Default
problem Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, this will be set

required
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

required
beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

required
num_reads Optional[int]

The number of samples. If None, this will be set automatically.

required
tsallis_q Optional[float]

q value of tsallis statistics. If None, this will be set

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSXAuroraSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

JijSwapMovingSampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default')

Sets token and url.

Parameters:

Name Type Description Default
token str

Token string. Defaults to None.

None
url Union[str, dict]

API URL. Defaults to None.

None
proxy str

Proxy URL. Defaults to None.

None
config str

Config file path. Defaults to None.

None

Raises:

Type Description
:obj:`TypeError`

token, url, or config is not str.

sample_hubo(J, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

The simulated annealing is performed for higher ordered unconstraind.

binary optimizations (hubo) with the linear constraint conditions. Note here that the linear constraint conditions are strictly satisfied.

Parameters:

Name Type Description Default
J Dict

Polynomial interactions.

required
parameters JijSwapMovingParameters | None

defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

import jijzept as jz
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_hubo(J={(0,1,2,3,4): -1}, vartype="SPIN",
                               constraints=[([0,1], 0), ([2,3,4], 1)])

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling. The decision variable type should be Binary.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

required
beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

required
num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, 1000 will be set.

required
num_reads Optional[int]

The number of samples. If None, 1 will be set.

required
updater Optional[str]

Updater algorithm must be "swap moving" for now. If None,

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
problem += jm.Constraint("one-hot", jm.Sum(i, x[i]) == 1)
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

sample_qubo(Q, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

The simulated annealing is performed for binary quadratic models with.

the linear constraint conditions. Note here that the linear constraint conditions are strictly satisfied.

Parameters:

Name Type Description Default
Q Dict

The linear or quadratic terms.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

import jijzept as jz
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_qubo(Q={(0,0): -0.5, (0,1): -1, (0,2): -1, (2,3): -1},
                               constraints=[([0,1], 1), ([2,3], 1)])

amazonbraket

JijAmazonBraketDWaveSampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, parameters=None, algorithm=None, num_search=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using D-Wave via Amazon Braket.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

None
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
num_reads Optional[int]

The number of samples. If None, 1000 will be set.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronization mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijAmazonBraketDWaveSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

amazonbraket

JijAmazonBraketDWaveSampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, parameters=None, algorithm=None, num_search=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using D-Wave via Amazon Braket.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

None
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
num_reads Optional[int]

The number of samples. If None, 1000 will be set.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronization mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijAmazonBraketDWaveSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

base_sampler

JijZeptBaseSampler

Parent class for each sampler in JijZept.

This class only provide the constructor. The actual sampling method are implemented by each sampler.

__init__(token=None, url=None, proxy=None, config=None, config_env='default')

Sets token and url.

If you do not set any arguments, JijZept configuration file is used. If you set the url or token here, that will be used as the priority setting for connecting to the API. See JijZeptClient for details.

Parameters:

Name Type Description Default
token str | None

Token string. Defaults to None.

None
url str | None

API URL. Defaults to None.

None
proxy str | None

Proxy URL. Defaults to None.

None
config str | None

Config file path. Defaults to None.

None
config_env str

configure environment name. Defaults to 'default'.

'default'

Raises:

Type Description
TypeError

token, url, or config is not str.

ms_qio

ms_qio

JijQIOBaseSampler

Bases: JijZeptBaseSampler, typ.Generic[P]

sample_hubo(J, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Microsoft QIO simulated annealing solver is performed for binary polynomial models.

Parameters:

Name Type Description Default
J Dict

Polynomial interactions.

required
vartype str

The variable type. "SPIN" or "BINARY".

required
num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, this will be set

required
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

required
beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

required
num_reads Optional[int]

The number of samples. If None, this will be set automatically.

required
seed Optional[int]

Seed for Monte Carlo algorithm. If None, this will be set automatically.

required
platform Optional[str]

"CPU" or "FPGA". If None, "CPU" will be set.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

import jijzept as jz
sampler = jz.JijQIOSASampler(config='config.toml')
response = sampler.sample_hubo(J={(0,1,2,3,4): -1}, vartype="SPIN")
sample_model(model, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Microsoft QIO Simulated Annealing solver.

Parameters:

Name Type Description Default
model jijmodeling.Problem

Mathematical model is constracted by JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
parameters P | None

(P | None, optional): parameters for QIO. Defaults to None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijQIOSASampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})
sample_qubo(Q, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Microsoft QIO solver is performed for binary quadratic models.

Parameters:

Name Type Description Default
Q Dict

The linear or quadratic terms.

required
num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, this will be set

required
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

required
beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

required
num_reads Optional[int]

The number of samples. If None, this will be set automatically.

required
seed Optional[int]

Seed for Monte Carlo algorithm. If None, this will be set automatically.

required
platform Optional[str]

"CPU" or "FPGA". If None, "CPU" will be set.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

import jijzept as jz
sampler = jz.JijQIOSASampler(config='config.toml')
response = sampler.sample_qubo(Q={(0,0): -0.5, (0,1): -1, (0,2): -1, (2,3): -1})

openjij

JijSAParameters dataclass

Parameters for JijSASampler.

Attributes:

Name Type Description
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, 1000 will be set.

num_reads Optional[int]

The number of samples. If None, 1 will be set.

initial_state Optional[dict]

Initial state. If None, this will be set automatically.

updater Optional[str]

Updater algorithm. "single spin flip" or "swendsen wang". If None,

sparse Optional[bool]

If True, only non-zero matrix elements are stored, which will save

reinitialize_state Optional[bool]

If True, reinitialize state for each run. If None,

seed Optional[int]

Seed for Monte Carlo algorithm. If None, this will be set automatically.

JijSASampler

Bases: JijZeptBaseSampler

Simulated annealing sampler on CPU.

This class is a sampler using SA that allows you to check if the mathematical model is correct in small problems.

See JijZeptBaseSampler for the constructor of the class.

sample_hubo(J, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sampling from higher unconstrained binary optimization model (HUBO).

Parameters:

Name Type Description Default
J dict

Polynomial interactions.

required
parameters JijSAParameters | None

(JijSAParameters | None, optional): defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

An extended type of jijmodleing.SampleSet that stores sampling results.

Examples:

import jijzept as jz
sampler = jz.JijSASampler(config='config.toml')
J = {(0,): -1, (0, 1): -1, (0, 1, 2): 1}
response = sampler.sample_hubo(J)
sample_model(model, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})
sample_qubo(qubo, constant=0, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sampling from QUBO.

Parameters:

Name Type Description Default
qubo dict[tuple[int, int], float]

QUBO dictionary.

required
parameters JijSAParameters | None

SA parameters, defaults None.

None
timeout int | None

The number of timeout [sec] for post request. If None, 3600 (one hour)

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None
**kwargs

You can pass SA parameters as keyword arguments instead of specifying them in parameters. See

{}

Returns:

Type Description
JijModelingResponse

An extended type of jijmodleing.SampleSet that stores sampling results.

Examples:

import jijzept as jz
Q = {(0, 0): -1, (1, 1): -1, (2, 2): 1, (0, 1): -1, (1, 2): 1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_qubo(Q)

JijSQASampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})
sample_qubo(qubo, constant=0, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using BinaryQuadraticModel by means of the simulated annealing.

Parameters:

Name Type Description Default
bqm Union[cimod.BinaryQuadraticModel, openjij.BinaryQuadraticModel]

Binary quadratic model.

required
parameters JijSQAParameters | None

(JijSAParameters | None, optional): defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

For cimod.BinaryQuadraticModel case:

import jijzept as jz
import cimod
bqm = cimod.BinaryQuadraticModel({0: -1, 1: -1}, {(0, 1): -1, (1, 2): -1}, "SPIN")
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample(bqm)
One can also use sample_ising and sample_qubo methods.

For Ising case:

import jijzept as jz
h = {0: -1, 1: -1, 2: 1, 3: 1}
J = {(0, 1): -1, (3, 4): -1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_ising(h, J)

For QUBO case:

import jijzept as jz
Q = {(0, 0): -1, (1, 1): -1, (2, 2): 1, (0, 1): -1, (1, 2): 1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_qubo(Q)

sa_cpu

JijSAParameters dataclass

Parameters for JijSASampler.

Attributes:

Name Type Description
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, 1000 will be set.

num_reads Optional[int]

The number of samples. If None, 1 will be set.

initial_state Optional[dict]

Initial state. If None, this will be set automatically.

updater Optional[str]

Updater algorithm. "single spin flip" or "swendsen wang". If None,

sparse Optional[bool]

If True, only non-zero matrix elements are stored, which will save

reinitialize_state Optional[bool]

If True, reinitialize state for each run. If None,

seed Optional[int]

Seed for Monte Carlo algorithm. If None, this will be set automatically.

JijSASampler

Bases: JijZeptBaseSampler

Simulated annealing sampler on CPU.

This class is a sampler using SA that allows you to check if the mathematical model is correct in small problems.

See JijZeptBaseSampler for the constructor of the class.

sample_hubo(J, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sampling from higher unconstrained binary optimization model (HUBO).

Parameters:

Name Type Description Default
J dict

Polynomial interactions.

required
parameters JijSAParameters | None

(JijSAParameters | None, optional): defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

An extended type of jijmodleing.SampleSet that stores sampling results.

Examples:

import jijzept as jz
sampler = jz.JijSASampler(config='config.toml')
J = {(0,): -1, (0, 1): -1, (0, 1, 2): 1}
response = sampler.sample_hubo(J)
sample_model(model, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})
sample_qubo(qubo, constant=0, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sampling from QUBO.

Parameters:

Name Type Description Default
qubo dict[tuple[int, int], float]

QUBO dictionary.

required
parameters JijSAParameters | None

SA parameters, defaults None.

None
timeout int | None

The number of timeout [sec] for post request. If None, 3600 (one hour)

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None
**kwargs

You can pass SA parameters as keyword arguments instead of specifying them in parameters. See

{}

Returns:

Type Description
JijModelingResponse

An extended type of jijmodleing.SampleSet that stores sampling results.

Examples:

import jijzept as jz
Q = {(0, 0): -1, (1, 1): -1, (2, 2): 1, (0, 1): -1, (1, 2): 1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_qubo(Q)

sqa_cpu

JijSQASampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})
sample_qubo(qubo, constant=0, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using BinaryQuadraticModel by means of the simulated annealing.

Parameters:

Name Type Description Default
bqm Union[cimod.BinaryQuadraticModel, openjij.BinaryQuadraticModel]

Binary quadratic model.

required
parameters JijSQAParameters | None

(JijSAParameters | None, optional): defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

For cimod.BinaryQuadraticModel case:

import jijzept as jz
import cimod
bqm = cimod.BinaryQuadraticModel({0: -1, 1: -1}, {(0, 1): -1, (1, 2): -1}, "SPIN")
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample(bqm)
One can also use sample_ising and sample_qubo methods.

For Ising case:

import jijzept as jz
h = {0: -1, 1: -1, 2: 1, 3: 1}
J = {(0, 1): -1, (3, 4): -1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_ising(h, J)

For QUBO case:

import jijzept as jz
Q = {(0, 0): -1, (1, 1): -1, (2, 2): 1, (0, 1): -1, (1, 2): 1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_qubo(Q)

swap_moving

JijSwapMovingSampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default')

Sets token and url.

Parameters:

Name Type Description Default
token str

Token string. Defaults to None.

None
url Union[str, dict]

API URL. Defaults to None.

None
proxy str

Proxy URL. Defaults to None.

None
config str

Config file path. Defaults to None.

None

Raises:

Type Description
:obj:`TypeError`

token, url, or config is not str.

sample_hubo(J, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

The simulated annealing is performed for higher ordered unconstraind.

binary optimizations (hubo) with the linear constraint conditions. Note here that the linear constraint conditions are strictly satisfied.

Parameters:

Name Type Description Default
J Dict

Polynomial interactions.

required
parameters JijSwapMovingParameters | None

defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

import jijzept as jz
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_hubo(J={(0,1,2,3,4): -1}, vartype="SPIN",
                               constraints=[([0,1], 0), ([2,3,4], 1)])
sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling. The decision variable type should be Binary.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

required
beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

required
num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, 1000 will be set.

required
num_reads Optional[int]

The number of samples. If None, 1 will be set.

required
updater Optional[str]

Updater algorithm must be "swap moving" for now. If None,

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
problem += jm.Constraint("one-hot", jm.Sum(i, x[i]) == 1)
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})
sample_qubo(Q, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

The simulated annealing is performed for binary quadratic models with.

the linear constraint conditions. Note here that the linear constraint conditions are strictly satisfied.

Parameters:

Name Type Description Default
Q Dict

The linear or quadratic terms.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

import jijzept as jz
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_qubo(Q={(0,0): -0.5, (0,1): -1, (0,2): -1, (2,3): -1},
                               constraints=[([0,1], 1), ([2,3], 1)])

swap_moving

NHOT_CONSTRAINTS = typ.List[typ.Tuple[typ.List[int], int]] module-attribute

N-hot constraint indices.

x0 + x1 + x2 = 3 x3 + x4 + x5 = 1 -> [([0, 1, 2], 3), ([3, 4, 5], 1)]

JijSwapMovingSampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default')

Sets token and url.

Parameters:

Name Type Description Default
token str

Token string. Defaults to None.

None
url Union[str, dict]

API URL. Defaults to None.

None
proxy str

Proxy URL. Defaults to None.

None
config str

Config file path. Defaults to None.

None

Raises:

Type Description
:obj:`TypeError`

token, url, or config is not str.

sample_hubo(J, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

The simulated annealing is performed for higher ordered unconstraind.

binary optimizations (hubo) with the linear constraint conditions. Note here that the linear constraint conditions are strictly satisfied.

Parameters:

Name Type Description Default
J Dict

Polynomial interactions.

required
parameters JijSwapMovingParameters | None

defaults None.

None
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

import jijzept as jz
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_hubo(J={(0,1,2,3,4): -1}, vartype="SPIN",
                               constraints=[([0,1], 0), ([2,3,4], 1)])
sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

Parameters:

Name Type Description Default
model Expression

Mathematical expression of JijModeling. The decision variable type should be Binary.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

required
beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

required
num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, 1000 will be set.

required
num_reads Optional[int]

The number of samples. If None, 1 will be set.

required
updater Optional[str]

Updater algorithm must be "swap moving" for now. If None,

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
problem += jm.Constraint("one-hot", jm.Sum(i, x[i]) == 1)
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})
sample_qubo(Q, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

The simulated annealing is performed for binary quadratic models with.

the linear constraint conditions. Note here that the linear constraint conditions are strictly satisfied.

Parameters:

Name Type Description Default
Q Dict

The linear or quadratic terms.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True
queue_name str

queue_name.

None

Returns:

Type Description
JijModelingResponse

dimod.SampleSet: Stores minimum energy samples and other information.

Examples:

import jijzept as jz
sampler = jz.JijSwapMovingSampler(config='config.toml')
response = sampler.sample_qubo(Q={(0,0): -0.5, (0,1): -1, (0,2): -1, (2,3): -1},
                               constraints=[([0,1], 1), ([2,3], 1)])

sxaurora

JijSXAuroraSampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Jij SX-Aurora Annealing solver.

Parameters:

Name Type Description Default
problem Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, this will be set

required
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

required
beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

required
num_reads Optional[int]

The number of samples. If None, this will be set automatically.

required
tsallis_q Optional[float]

q value of tsallis statistics. If None, this will be set

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSXAuroraSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

sxaurorasampler

JijSXAuroraSampler

Bases: JijZeptBaseSampler

sample_model(problem, feed_dict, multipliers={}, fixed_variables={}, search=False, num_search=15, algorithm=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Jij SX-Aurora Annealing solver.

Parameters:

Name Type Description Default
problem Expression

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from

{}
fixed_variables Dict[str, Dict[Tuple[int, ...], Union[int, float]]]

dictionary of variables to fix.

{}
search bool

If True, the parameter search will be carried out, which tries to find better

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, this will be set

required
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set

required
beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set

required
num_reads Optional[int]

The number of samples. If None, this will be set automatically.

required
tsallis_q Optional[float]

q value of tsallis statistics. If None, this will be set

required
timeout Optional[int]

The number of timeout [sec] for post request. If None,

None
sync bool

Synchronous mode.

True

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSXAuroraSampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

thirdparty

JijDA3Sampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', da3_token='', da3_url='https://api.aispf.global.fujitsu.com/da')

Sets Jijzept token and url and Digital Annealer v3 token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Optional[Union[str, dict]]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
da3_token str

Token string for Degital Annealer 3.

''
da3_url Optional[str]

API Url string for Degital Annealer 3.

'https://api.aispf.global.fujitsu.com/da'
sample_model(model, feed_dict, fixed_variables={}, inequalities_lambda={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Digital Annealer v3.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
inequalities_lambda dict[str, int]

Coefficient of inequality. If omitted, set to 1. The coefficients

{}
parameters Optional[JijDA3SolverParameters]

Parameters used in Ditital Annealer 3. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient. Defaults to False.

False
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Digital Annealer 3 parameters using **kwags. If both **kwargs and parameters are exist,

{}

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijDA3Sampler, JijDA3SolverParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint(
    "knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j
)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
inequalities_lambda = {"knapsack_constraint": 22}

sampler = JijDA3Sampler(config="xx", da3_token="oo")
parameters = JijDA3SolverParameters(penalty_coef=2)

sampleset = sampler.sample_model(
    problem, feed_dict, inequalities_lambda=inequalities_lambda, parameters=parameters
)

JijDA3SolverParameters dataclass

Manage Parameters for using Digital Annealer v3.

Attributes:

Name Type Description
time_limit_sec int

Set the timeout in seconds in the range 1 ~ 1800.

target_energy Optional[float]

Set the target energy value. The calculation is terminated when the minimum

num_run int

Set the number of parallel trial iterations in the range 1 ~ 16.

num_group int

Set the number of groups of parallel trials in the range 1 ~ 16.

num_output_solution int

Set the number of output solutions for each parallel trial group in the range 1 ~

gs_level int

Set the level of global search. The higher this value, the longer the constraint utilization

gs_cutoff int

Set the convergence decision level in the constraint utilization search of the solver in the

penalty_auto_mode int

Set the coefficient adjustment mode for the constaint term. If 0, fixed to the

penalty_coef int

Set the coefficients of the constraint term.

penalty_inc_rate int

Set parameters for automatic adjustment of constriant term.

max_penalty_coef int

Set the maximum value of the constraint term coefficient in the global search. If no

JijDA4Sampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', da4_token='', da4_url='https://api.aispf.global.fujitsu.com/da')

Sets Jijzept token and url and Digital Annealer v4 token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Optional[Union[str, dict]]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
da4_token str

Token string for Degital Annealer 4.

''
da4_url Optional[str]

API Url string for Degital Annealer 4.

'https://api.aispf.global.fujitsu.com/da'
sample_model(model, feed_dict, fixed_variables={}, inequalities_lambda={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Digital Annealer v4.

Note that this sampler solve problems with using Azure Blob Storage, which is a feature of Digital Annealer v4, and there is no option not to use Azure Blob Storage.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
inequalities_lambda dict[str, int]

Coefficient of inequality. If omitted, set to 1. The coefficients

{}
parameters Optional[JijDA4SolverParameters]

Parameters used in Ditital Annealer 4. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient and inequality constraint conditions.

False
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Digital Annealer 4 parameters using **kwags. If both **kwargs and parameters are exist,

{}

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijDA4Sampler, JijDA4SolverParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint(
    "knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j
)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
inequalities_lambda = {"knapsack_constraint": 22}

sampler = JijDA4Sampler(config="xx", da4_token="oo")
parameters = JijDA4SolverParameters(penalty_coef=2)

sampleset = sampler.sample_model(
    problem, feed_dict, inequalities_lambda=inequalities_lambda, parameters=parameters
)

JijDA4SolverParameters dataclass

Manage Parameters for using Digital Annealer v4.

Attributes:

Name Type Description
time_limit_sec int

Set the timeout in seconds in the range 1 ~ 1800.

target_energy Optional[float]

Set the target energy value. The calculation is terminated when the minimum

num_run int

Set the number of parallel trial iterations in the range 1 ~ 16.

num_group int

Set the number of groups of parallel trials in the range 1 ~ 16.

num_output_solution int

Set the number of output solutions for each parallel trial group in the range 1 ~

gs_level int

Set the level of global search. The higher this value, the longer the constraint utilization

gs_cutoff int

Set the convergence decision level in the constraint utilization search of the solver in the

one_hot_level int

Levels of 1hot constraints search.

one_hot_cutoff int

Convergence decision level for 1hot constraints search. If 0 is set, this function is

internal_penalty int

1hot constraint internal generation mode. Note that if 1way- or 2way 1hot constraints

penalty_auto_mode int

Set the coefficient adjustment mode for the constaint term. If 0, fixed to the

penalty_coef int

Set the coefficients of the constraint term.

penalty_inc_rate int

Set parameters for automatic adjustment of constriant term.

max_penalty_coef int

Set the maximum value of the constraint term coefficient in the global search. If no

JijFixstarsAmplifyParameters dataclass

Manage Parameters for using Fixstars Amplify.

Attributes:

Name Type Description
amplify_timeout int

Set the timeout in milliseconds. Defaults to 1000.

num_gpus int

Set the number of GPUs to be used. The maximum number of GPUs available depends on the subscription plan, and 0 means the maximum number available. Defaults to 1.

penalty_calibration bool

Set whether to enable the automatic adjustment of the penalty function's

duplicate bool

If True, all solutions with the same energy and the same feasibility are output. Otherwise, only one solution with the same energy and feasibility is output.

num_outputs int

The number of solutions to be output which have different energies and feasibility. Assumed 1 if no value is set. If set to 0, all the solutions are output. Defaults to 1.

JijFixstarsAmplifySampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', fixstars_token='', fixstars_url='')

Sets Jijzept token and url and fixstars amplify token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Union[str, dict]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
fixstars_token str

Token string for Fixstars Amplify.

''
fixstars_url str

Url string for Fixstars Ampplify.

''
sample_model(model, feed_dict, multipliers={}, fixed_variables={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Converts the given problem to amplify.BinaryQuadraticModel and run.

Fixstars Amplify Solver. Note here that the supported type of decision variables is only Binary when using Fixstars Ampplify Solver from Jijzept.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers dict[str, Number]

The actual multipliers for penalty terms, derived from constraint

{}
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
parameters Optional[JijFixstarsAmplifyParameters]

Parameters used in Fixstars Amplify. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient. Defaults to False.

False
jm_sampleset bool

Selects whether the argument value should be JijModelingResponse.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None

Returns:

Type Description
JijModelingResponse

Union[DimodResponse, JijModelingResponse]: Stores samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijFixstarsAmplifySampler, JijFixstarsAmplifyParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint("knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
multipliers = {"onehot_constraint": 11, "knapsack_constraint": 22}

sampler = JijFixstarsAmplifySampler(config="xx", fixstars_token="oo")
parameters = JijFixstarsAmplifyParameters(amplify_timeout=1000, num_outputs=1, filter_solution=False,
penalty_calibration=False)
sampleset = sampler.sample_model(
    problem, feed_dict, multipliers, parameters=parameters
)

JijLeapHybridCQMParameters dataclass

Manage Parameters for using Leap Hybrid CQM Sampler.

Attributes:

Name Type Description
time_limit Optional[Union[int, float]]

the maximum run time, in seconds, the solver is allowed to work on

label str

The problem label given to the dimod.SampelSet instance returned by the JijLeapHybridCQMSampler.

JijLeapHybridCQMSampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', leap_token=None, leap_url=None)

Sets token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string for JijZept.

None
url Optional[str]

API URL for JijZept.

None
proxy Optional[str]

Proxy URL. Defaults to None.

None
config Optional[str]

Config file path for JijZept.

None
token_leap Optional[str]

Token string for Dwave Leap.

required
url_leap Optional[str]

API URL for Dwave Leap.

required
sample_model(model, feed_dict, fixed_variables=None, relax_list=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Converts the given problem to dimod.ConstrainedQuadraticModel and runs.

Dwave's LeapHybridCQMSampler. Note here that the supported type of decision variables is only Binary when using LeapHybridCQMSolver from Jijzept.

Parameters:

Name Type Description Default
problem Problem

Optimization problem of JijModeling.

required
feed_dict Dict[str, Union[Number, List, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables Optional[Dict[str, Dict[Tuple[int, ...], Union[int, float]]]]

variables to fix.

None
relax_list Optional[List[str]]

variable labels for continuous relaxation.

None
parameters Optional[JijLeapHybridCQMParameters]

Parameters used in Dwave Leap Hybrid CQMSampler. If

None
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Dwave Leap parameters using **kwags. If both **kwargs and parameters are exist, the value of

{}

Returns:

Name Type Description
JijModelingSampleset JijModelingResponse

Stores samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijLeapHybridCQMSampler, JijLeapHybridCQMParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint("knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j)
feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}

sampler = JijLeapHybridCQMSampler(config="XX", token_leap="XX")
parameters = JijLeapHybridCQMParameters(label="bin_packing")
sampleset = sampler.sample_model(
    problem, feed_dict, parameters=parameters
)

digitalannealer

JijDA3Sampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', da3_token='', da3_url='https://api.aispf.global.fujitsu.com/da')

Sets Jijzept token and url and Digital Annealer v3 token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Optional[Union[str, dict]]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
da3_token str

Token string for Degital Annealer 3.

''
da3_url Optional[str]

API Url string for Degital Annealer 3.

'https://api.aispf.global.fujitsu.com/da'
sample_model(model, feed_dict, fixed_variables={}, inequalities_lambda={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Digital Annealer v3.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
inequalities_lambda dict[str, int]

Coefficient of inequality. If omitted, set to 1. The coefficients

{}
parameters Optional[JijDA3SolverParameters]

Parameters used in Ditital Annealer 3. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient. Defaults to False.

False
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Digital Annealer 3 parameters using **kwags. If both **kwargs and parameters are exist,

{}

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijDA3Sampler, JijDA3SolverParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint(
    "knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j
)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
inequalities_lambda = {"knapsack_constraint": 22}

sampler = JijDA3Sampler(config="xx", da3_token="oo")
parameters = JijDA3SolverParameters(penalty_coef=2)

sampleset = sampler.sample_model(
    problem, feed_dict, inequalities_lambda=inequalities_lambda, parameters=parameters
)
JijDA3SolverParameters dataclass

Manage Parameters for using Digital Annealer v3.

Attributes:

Name Type Description
time_limit_sec int

Set the timeout in seconds in the range 1 ~ 1800.

target_energy Optional[float]

Set the target energy value. The calculation is terminated when the minimum

num_run int

Set the number of parallel trial iterations in the range 1 ~ 16.

num_group int

Set the number of groups of parallel trials in the range 1 ~ 16.

num_output_solution int

Set the number of output solutions for each parallel trial group in the range 1 ~

gs_level int

Set the level of global search. The higher this value, the longer the constraint utilization

gs_cutoff int

Set the convergence decision level in the constraint utilization search of the solver in the

penalty_auto_mode int

Set the coefficient adjustment mode for the constaint term. If 0, fixed to the

penalty_coef int

Set the coefficients of the constraint term.

penalty_inc_rate int

Set parameters for automatic adjustment of constriant term.

max_penalty_coef int

Set the maximum value of the constraint term coefficient in the global search. If no

JijDA4Sampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', da4_token='', da4_url='https://api.aispf.global.fujitsu.com/da')

Sets Jijzept token and url and Digital Annealer v4 token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Optional[Union[str, dict]]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
da4_token str

Token string for Degital Annealer 4.

''
da4_url Optional[str]

API Url string for Degital Annealer 4.

'https://api.aispf.global.fujitsu.com/da'
sample_model(model, feed_dict, fixed_variables={}, inequalities_lambda={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of Digital Annealer v4.

Note that this sampler solve problems with using Azure Blob Storage, which is a feature of Digital Annealer v4, and there is no option not to use Azure Blob Storage.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
inequalities_lambda dict[str, int]

Coefficient of inequality. If omitted, set to 1. The coefficients

{}
parameters Optional[JijDA4SolverParameters]

Parameters used in Ditital Annealer 4. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient and inequality constraint conditions.

False
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Digital Annealer 4 parameters using **kwags. If both **kwargs and parameters are exist,

{}

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijDA4Sampler, JijDA4SolverParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint(
    "knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j
)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
inequalities_lambda = {"knapsack_constraint": 22}

sampler = JijDA4Sampler(config="xx", da4_token="oo")
parameters = JijDA4SolverParameters(penalty_coef=2)

sampleset = sampler.sample_model(
    problem, feed_dict, inequalities_lambda=inequalities_lambda, parameters=parameters
)
JijDA4SolverParameters dataclass

Manage Parameters for using Digital Annealer v4.

Attributes:

Name Type Description
time_limit_sec int

Set the timeout in seconds in the range 1 ~ 1800.

target_energy Optional[float]

Set the target energy value. The calculation is terminated when the minimum

num_run int

Set the number of parallel trial iterations in the range 1 ~ 16.

num_group int

Set the number of groups of parallel trials in the range 1 ~ 16.

num_output_solution int

Set the number of output solutions for each parallel trial group in the range 1 ~

gs_level int

Set the level of global search. The higher this value, the longer the constraint utilization

gs_cutoff int

Set the convergence decision level in the constraint utilization search of the solver in the

one_hot_level int

Levels of 1hot constraints search.

one_hot_cutoff int

Convergence decision level for 1hot constraints search. If 0 is set, this function is

internal_penalty int

1hot constraint internal generation mode. Note that if 1way- or 2way 1hot constraints

penalty_auto_mode int

Set the coefficient adjustment mode for the constaint term. If 0, fixed to the

penalty_coef int

Set the coefficients of the constraint term.

penalty_inc_rate int

Set parameters for automatic adjustment of constriant term.

max_penalty_coef int

Set the maximum value of the constraint term coefficient in the global search. If no

dwaveleaphybridcqm

JijLeapHybridCQMParameters dataclass

Manage Parameters for using Leap Hybrid CQM Sampler.

Attributes:

Name Type Description
time_limit Optional[Union[int, float]]

the maximum run time, in seconds, the solver is allowed to work on

label str

The problem label given to the dimod.SampelSet instance returned by the JijLeapHybridCQMSampler.

JijLeapHybridCQMSampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', leap_token=None, leap_url=None)

Sets token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string for JijZept.

None
url Optional[str]

API URL for JijZept.

None
proxy Optional[str]

Proxy URL. Defaults to None.

None
config Optional[str]

Config file path for JijZept.

None
token_leap Optional[str]

Token string for Dwave Leap.

required
url_leap Optional[str]

API URL for Dwave Leap.

required
sample_model(model, feed_dict, fixed_variables=None, relax_list=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)

Converts the given problem to dimod.ConstrainedQuadraticModel and runs.

Dwave's LeapHybridCQMSampler. Note here that the supported type of decision variables is only Binary when using LeapHybridCQMSolver from Jijzept.

Parameters:

Name Type Description Default
problem Problem

Optimization problem of JijModeling.

required
feed_dict Dict[str, Union[Number, List, np.ndarray]]

The actual values to be assigned to the

required
fixed_variables Optional[Dict[str, Dict[Tuple[int, ...], Union[int, float]]]]

variables to fix.

None
relax_list Optional[List[str]]

variable labels for continuous relaxation.

None
parameters Optional[JijLeapHybridCQMParameters]

Parameters used in Dwave Leap Hybrid CQMSampler. If

None
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
kwargs

Dwave Leap parameters using **kwags. If both **kwargs and parameters are exist, the value of

{}

Returns:

Name Type Description
JijModelingSampleset JijModelingResponse

Stores samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijLeapHybridCQMSampler, JijLeapHybridCQMParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint("knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j)
feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}

sampler = JijLeapHybridCQMSampler(config="XX", token_leap="XX")
parameters = JijLeapHybridCQMParameters(label="bin_packing")
sampleset = sampler.sample_model(
    problem, feed_dict, parameters=parameters
)

fixstars_amplify

JijFixstarsAmplifyParameters dataclass

Manage Parameters for using Fixstars Amplify.

Attributes:

Name Type Description
amplify_timeout int

Set the timeout in milliseconds. Defaults to 1000.

num_gpus int

Set the number of GPUs to be used. The maximum number of GPUs available depends on the subscription plan, and 0 means the maximum number available. Defaults to 1.

penalty_calibration bool

Set whether to enable the automatic adjustment of the penalty function's

duplicate bool

If True, all solutions with the same energy and the same feasibility are output. Otherwise, only one solution with the same energy and feasibility is output.

num_outputs int

The number of solutions to be output which have different energies and feasibility. Assumed 1 if no value is set. If set to 0, all the solutions are output. Defaults to 1.

JijFixstarsAmplifySampler

Bases: JijZeptBaseSampler

__init__(token=None, url=None, proxy=None, config=None, config_env='default', fixstars_token='', fixstars_url='')

Sets Jijzept token and url and fixstars amplify token and url.

Parameters:

Name Type Description Default
token Optional[str]

Token string.

None
url Union[str, dict]

API URL.

None
proxy Optional[str]

Proxy URL.

None
config Optional[str]

Config file path for JijZept.

None
config_env str

config env.

'default'
fixstars_token str

Token string for Fixstars Amplify.

''
fixstars_url str

Url string for Fixstars Ampplify.

''
sample_model(model, feed_dict, multipliers={}, fixed_variables={}, parameters=None, normalize_qubo=False, timeout=None, sync=True, queue_name=None, **kwargs)

Converts the given problem to amplify.BinaryQuadraticModel and run.

Fixstars Amplify Solver. Note here that the supported type of decision variables is only Binary when using Fixstars Ampplify Solver from Jijzept.

Parameters:

Name Type Description Default
model Problem

Mathematical expression of JijModeling.

required
feed_dict dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the

required
multipliers dict[str, Number]

The actual multipliers for penalty terms, derived from constraint

{}
fixed_variables dict[str, dict[tuple[int, ...], Number]]

Dictionary of variables to fix.

{}
parameters Optional[JijFixstarsAmplifyParameters]

Parameters used in Fixstars Amplify. If None,

None
normalize_qubo bool

Option to normalize the QUBO coefficient. Defaults to False.

False
jm_sampleset bool

Selects whether the argument value should be JijModelingResponse.

required
timeout Optional[int]

The number of timeout [sec] for post request. If None, 3600 (one hour) will be

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None

Returns:

Type Description
JijModelingResponse

Union[DimodResponse, JijModelingResponse]: Stores samples and other information.

Examples:

import jijmodeling as jm
from jijzept import JijFixstarsAmplifySampler, JijFixstarsAmplifyParameters

w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint("knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j)

feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
multipliers = {"onehot_constraint": 11, "knapsack_constraint": 22}

sampler = JijFixstarsAmplifySampler(config="xx", fixstars_token="oo")
parameters = JijFixstarsAmplifyParameters(amplify_timeout=1000, num_outputs=1, filter_solution=False,
penalty_calibration=False)
sampleset = sampler.sample_model(
    problem, feed_dict, multipliers, parameters=parameters
)

setting

load_config(file_name, config='default')

Loads config file (TOML file).

Parameters:

Name Type Description Default
file_name Union[str, pathlib.Path, os.PathLike, pathlib.PurePath]

Path to config file.

required
config str

Loading enviroment name. Defaults to 'default'.

'default'

Raises:

Type Description
TypeError

If 'config' enviroment is not defined in config file.

Returns:

Name Type Description
dict dict

{'token': 'xxxx', 'url': 'xxxx'}

setting

load_config(file_name, config='default')

Loads config file (TOML file).

Parameters:

Name Type Description Default
file_name Union[str, pathlib.Path, os.PathLike, pathlib.PurePath]

Path to config file.

required
config str

Loading enviroment name. Defaults to 'default'.

'default'

Raises:

Type Description
TypeError

If 'config' enviroment is not defined in config file.

Returns:

Name Type Description
dict dict

{'token': 'xxxx', 'url': 'xxxx'}


Last update: 2023年3月17日