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 multipliers. If multiplier is not set, it will be set true. Defaults to False. |
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
Sampler using Fixstars Amplify.
__init__(token=None, url=None, proxy=None, config=None, config_env='default', fixstars_token=None, fixstars_url=None)
¶
Sets Jijzept token and url and fixstars amplify token and url.
If fixstars_token
and 'fixstars_urlare not specified in the arguments, JijZept configuration file is used. If
fixstars_tokenand
fixstars_url` are specified in the arguments, that will be used as priority setting.
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 | Optional[str] | Token string for Fixstars Amplify. | None |
fixstars_url | Optional[str] | Url string for Fixstars Ampplify. | None |
Raises:
Type | Description |
---|---|
ConfigError | if |
sample_model(model, feed_dict, multipliers={}, fixed_variables={}, parameters=None, normalize_qubo=False, max_wait_time=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.
To configure the solver, instantiate the JijFixstarsAmplifyParameters
class and pass the instance to the parameters
argument.
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 |
multipliers | dict[str, Number] | The actual multipliers for penalty terms, derived from constraint conditions. | {} |
fixed_variables | dict[str, dict[tuple[int, ...], Number]] | Dictionary of variables to fix. | {} |
parameters | Optional[JijFixstarsAmplifyParameters] | Parameters used in Fixstars Amplify. If | None |
normalize_qubo | bool | Option to normalize the QUBO coefficient. Defaults to | False |
max_wait_time | int | float | None | The number of timeout [sec] for post request. If | None |
sync | bool | Synchronous mode. | True |
queue_name | Optional[str] | Queue name. | None |
**kwargs | Fixstars Amplify parameters using **kwargs. If both | {} |
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
)