Skip to main content

JijDA4Sampler

The Digital Annealer (DA) is a high-performance Ising machine provided by Fujitsu. DA achieves rapid optimization computations due to its advanced parallelization algorithm. A distinguishing feature of DA is its capability to specify constraint conditions separately. Because of this, it serves as a potent solver even for problems with constraint conditions. JijZept can automatically determine the constraint conditions to be specified to DA from Problems described in JijModeling and convert them to DA's schema. This means JijZept users can harness the full potential of DA without any special actions.

The JijDA4Sampler supports QUBO API V4, called “DA4” here. There are certain limitations to the mathematical models that JijDA4Sampler can handle:

  • the objective function and equality constraints must be at most quadratic.
  • inequality constraints must be linear.

Usage

  1. Update the config.toml by adding the [default.thirdparty-setting] section. Include the following two items:

    • da4_url: Endpoint for DA4. You can find the exact endpoint in the “Servers” dropdown of the "Digital Annealer API Reference (QUBO API V4)" (English, Japanese).
    • da4_token: The API key to use DA4. For more specific, consult the "API Getting Started" guide (English, Japanese).
    [default]
    url = "https://api.jijzept.com"
    token = "JIJ_ZEPT_API_KEY"

    [default.thirdparty-setting]
    da4_url = "https://api.aispf.global.fujitsu.com/da"
    da4_token = "DIGITAL_ANNEALER_V4_TOKEN"
  2. Use the two classes provided by the jijzept and run the method sample_model in the JijDA4Sampler class:

    • JijDA4Sampler: a class to sample using the DA4.
    • JijDA4SolverParameters: a class to set parameters specifically for the DA4.
    from jijzept import JijDA4Sampler, JijDA4SolverParameters

    sampler = JijDA4Sampler(config="./config.toml")
    parameters = JijDA4Parameters(time_limit_sec=5)

    response = sampler.sample_model(
    problem=problem,
    feed_dict=instance_data,
    parameters=parameters,
    )

What does JijZept automatically tune?

JijZept automatically detects the appropriate constraints for specification in DA4 and generates a schema tailored for DA4 using these constraints. As a result, JijZept users can harness the performance of DA4 without needing an in-depth understanding of its schema. This section explains the conditions under which the automatic detection operates.

1. One-Way One-Hot Constraints Detection

JijZept identifies constraints as One-Way One-Hot based on the following conditions:

  • The constraint is an equality.
  • The number of dimensions of the decision variable is 1.
  • All the coefficients and a bias term share the same value.

Examples

  • i=0N1xi,j=1, i{0,,M1}\sum_{i=0}^{N-1} x_{i,j} = 1,\ \forall i \in \{0,\ldots, M-1\}
  • eEaxe,s=a, sS, a0\sum_{e \in E} ax_{e,s} = a,\ \forall s \in S, \ a \neq 0

2. Two-Way One-Hot Constraints Detection

JijZept identifies constraints as Two-Way One-Hot based on the following conditions:

  • The constraint is an equality.
  • The coefficients of the decision variables are not explicitly described.
  • The constraint comprises just one type of decision variable.
  • The number of dimensions of the decision variable is 1.

Example

  • For the 2-dimensional TSP constraint (See the tutorial page of "Traveling Salesman Problem"): ixi,t=1, t,txi,t=1, i\sum_{i}x_{i,t}=1,\ \forall t, \sum_{t}x_{i,t}=1,\ \forall i

3. Priority between One-Hot Constraints

When a scenario arises where both One-Way and Two-Way One-Hot constraints are valid:

  • JijZept favors the one with a greater number of decision variables.
  • If both handle an equal count, Two-Way One-Hot is the preferred choice.

4. Automatic Detection of Inequality Constraints

JijZept can detect linear inequality constraints, relieving users from the need to manually describe the "Inequalities" schema in the DA4. To adjust constraint weights, simply use the inequalities_lambda parameter within JijDA4Sampler.sample_model.

Here’s a sample code to assign a weight of 10 to a linear inequality constraint termed “my inequality constraint”:

import jijmodeling as jm
from jijzept import JijDA4Sampler

N = jm.Placeholder("N")
x = jm.BinaryVar("x", shape=(N,))
problem = jm.Problem("problem")
problem += jm.Constraint("my inequality constraint", x[:].sum() <= 3) # linear inequality constraint

instance_data = {"N": 5}

sampler = JijDA4Sampler(config="./config.toml")
response = sampler.sample_model(
problem=problem,
feed_dict=instance_data,
inequalities_lambda={"my inequality constraint": 10},
)

Parameters

JijDA4SolverParameters

nametypedefaultdescription
time_limit_secint10Maximum running time of DA in seconds. For more details, please refer to the description of the time_limit_sec parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
target_energyOptional[float]NoneThreshold energy for fast exit. If you don't set it, the calculation will run without any target energy. For more details, please refer to the description of the target_energy parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
num_runint16The number of parallel attempts of each groups. For more details, please refer to the description of the num_run parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
num_groupint1The number of groups of parallel attempts. For more details, please refer to the description of the num_group parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
num_output_solutionint5The number of output solutions of each groups. For more details, please refer to the description of the num_output_solution parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
gs_levelint5Level of the global search. For more details, please refer to the description of the gs_level parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
gs_cutoffint8000Global search cutoff level. For more details, please refer to the description of the gs_cutoff parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
one_hot_levelint3Level of the one-hot constraint search. For more details, please refer to the description of the one_hot_level parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
one_hot_cutoffint100Level of the convergence for one-hot constraint search. For more details, please refer to the description of the one_hot_cutoff parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
internal_penaltyint0Mode of one-hot constraint internal generation. For more details, please refer to the description of the internal_penalty parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
penalty_auto_modeint1Coefficient adjustment mode. For more details, please refer to the description of the penalty_auto_mode parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
penalty_coefint1Coefficient of the constraint term. For more details, please refer to the description of the penalty_coef parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
penalty_inc_rateint150Parameters for automatic adjustment of constraint terms. For more details, please refer to the description of the penalty_inc_rate parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.
max_penalty_coefint0Maximum constraint term coefficent. For more details, please refer to the description of the max_penalty_coef parameter in the "FujitsuDA3Solver" item under the "Schemas" section of the API reference.

JijDA4Sampler.sample_model

nametypedefaultdescription
parametersOptional[JijDA4SolverParameters]NoneParameters for JijDA4Sampler.
inequalities_lambdadict[str, int]{}Pairs of inequality constraint names and their coefficients. If your Problem object have an inequality constraint but you do not set a coefficient for it, the coefficient is automatically set to 1. This matches the default value of the lambda parameter in "Inequalities". For more details, please refer to the description of the lambda parameter in the "Inequalities" item under the "Schemas" section of the API reference.
normalize_quboboolFalseIf True, during the creation of QUBO, both the objective function and the constraints are individually normalized by their largest absolute coefficients.
max_wait_timeOptional[Union[int, float]]NoneThe number of timeout [sec] for post request. If None, 60 (one minute) will be set.
syncboolTrueIf True, synchronous mode is enabled.
queue_nameOptional[str]NoneQueue name