Digital Annealer¶
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 placeholders. | 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 of the equality constraints can be set from JijDA3SolverParameters. | {} |
parameters | Optional[JijDA3SolverParameters] | Parameters used in Ditital Annealer 3. If | None |
normalize_qubo | bool | Option to normalize the QUBO coefficient. Defaults to | False |
timeout | Optional[int] | The number of timeout [sec] for post request. If | None |
sync | bool | Synchronous mode. | True |
queue_name | Optional[str] | Queue name. | None |
kwargs | Digital Annealer 3 parameters using **kwags. If both | {} |
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 energy savings reaches the target energy. |
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 ~ 1024. |
gs_level | int | Set the level of global search. The higher this value, the longer the constraint utilization search will search in the range 0 ~ 100. If set the 1way 1hot or 2way 1hot, it is recommended that 0 be set for gs_level. |
gs_cutoff | int | Set the convergence decision level in the constraint utilization search of the solver in the range 0 ~ 1000000. If |
penalty_auto_mode | int | Set the coefficient adjustment mode for the constaint term. If |
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 maximum value is specified, set to 0. |
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 placeholders. | 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 of the equality constraints can be set from JijDA4SolverParameters. | {} |
parameters | Optional[JijDA4SolverParameters] | Parameters used in Ditital Annealer 4. If | None |
normalize_qubo | bool | Option to normalize the QUBO coefficient and inequality constraint conditions. Defaults to | False |
timeout | Optional[int] | The number of timeout [sec] for post request. If | None |
sync | bool | Synchronous mode. | True |
queue_name | Optional[str] | Queue name. | None |
kwargs | Digital Annealer 4 parameters using **kwags. If both | {} |
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 energy savings reaches the target energy. |
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 ~ 1024. |
gs_level | int | Set the level of global search. The higher this value, the longer the constraint utilization search will search in the range 0 ~ 100. If set the 1way 1hot or 2way 1hot, it is recommended that 0 be set for gs_level. |
gs_cutoff | int | Set the convergence decision level in the constraint utilization search of the solver in the range 0 ~ 1000000. If |
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 turned off. |
internal_penalty | int | 1hot constraint internal generation mode. Note that if 1way- or 2way 1hot constraints are specified to |
penalty_auto_mode | int | Set the coefficient adjustment mode for the constaint term. If |
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 maximum value is specified, set to 0. |