Skip to main content

vectorannealing

class JijVectorAnnealingParameters

Parameters for JijVectorAnnealingSampler.

Attributes

  • num_reads(int) : Number of reads. Defaults to None.
  • num_results(int) : Number of results. Defaults to None.
  • num_sweeps(int) : Number of sweeps. Defaults to None.
  • beta_range(list) : Beta range. Defaults to None.
  • beta_list(list[float]) : Beta list. Defaults to None.
  • init_spin(dict[str, int]) : Initial spin. Defaults to None.
  • dense(bool) : Dense. Defaults to None.
  • num_threads(int) : Number of threads. Defaults to None.
  • vector_mode(Literal["speed", "accuracy"]) : Vector mode. Defaults to None.
  • timeout(int) : Timeout. Defaults to None.
  • needs_square_constraints(dict[str, bool]) : Needs square constraints. Defaults to None.
  • relax_as_penalties(dict[str, bool]) : Relax as penalties. Defaults to None.

class JijVectorAnnealingSampler

Sampler using SX-Aurora Vector Annealing.

__init__ (self, token, url, proxy, config, config_env) -> -

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

  • token(str | None) : Token string. Defaults to None.
  • url(str | None) : API URL. Defaults to None.
  • proxy(str | None) : Proxy URL. Defaults to None.
  • config(str | None) : Config file path. Defaults to None.
  • config_env(str) : configure environment name. Defaults to 'default'.

Raises

  • TypeError: token, url, or config is not str.

sample_instance (self, instance_id, multipliers, fixed_variables, search, num_search, algorithm, parameters, max_wait_time, sync, queue_name, system_time, kwargs) -> JijModelingResponse

Sample using the uploaded instance by means of Jij SX-Aurora Annealing solver.

To configure the solver, instantiate the JijVectorAnnealingParameters class and pass the instance to the parameters argument.

Parameters

  • instance_id(str) : The ID of the upload instance.
  • multipliers(Dict[str, Number]) : The actual multipliers for penalty terms, derived from constraint conditions.
  • fixed_variables(dict[str, dict[tuple[int, ...], int]]) : dictionary of variables to fix.
  • search(bool) : If True, the parameter search will be carried out, which tries to find better values of multipliers for penalty terms.
  • num_search(int) : The number of parameter search iteration. Defaults to set 15. This option works if search is True.
  • algorithm(Optional[str]) : Algorithm for parameter search. Defaults to None.
  • parameters(Optional[JijVectorAnnealingParameters]) : parameters for SXAurora. Defaults to None.
  • max_wait_time(int | float | None) : The number of timeout [sec] for post request. If None, 600 will be set. Please note that this argument is for the jijzept timeout and not for configuring solver settings, such as solving time.
  • sync(bool) : Synchronous mode.
  • queue_name(Optional[str]) : Queue name.
  • system_time(jm.SystemTime) : Object to store system times other than upload time.
  • **kwargs : VectorAnnealing parameters using kwargs. If both `kwargsandparametersare exist, the value of**kwargs` takes precedence.

Returns

  • JijModelingResponse : Stores minimum energy samples and other information.

Examples

import jijzept as jz
import jijmodeling as jm

n = jm.Placeholder('n')
x = jm.BinaryVar('x', shape=(n,))
d = jm.Placeholder('d', ndim=1)
i = jm.Element("i", belong_to=n)
problem = jm.Problem('problem')
problem += jm.sum(i, d[i] * x[i])

# initialize sampler
sampler = jz.JijVectorAnnealingSampler(config='config.toml')

# upload instance
instance_id = sampler.upload_instance(problem, {'n': 5, 'd': [1,2,3,4,5]})

# sample instance
sample_set = sampler.sample_instance(instance_id)

sample_model (self, problem, feed_dict, multipliers, fixed_variables, search, num_search, algorithm, parameters, max_wait_time, sync, queue_name, kwargs) -> JijModelingResponse

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

To configure the solver, instantiate the JijVectorAnnealingParameters class and pass the instance to the parameters argument.

Parameters

  • problem(jm.Problem) : Mathematical expression of JijModeling.
  • feed_dict(dict[str, int | float | numpy.integer | numpy.floating | numpy.ndarray | list]) : The actual values to be assigned to the placeholders.
  • multipliers(Dict[str, Number]) : The actual multipliers for penalty terms, derived from constraint conditions.
  • fixed_variables(dict[str, dict[tuple[int, ...], int]]) : dictionary of variables to fix.
  • search(bool) : If True, the parameter search will be carried out, which tries to find better values of multipliers for penalty terms.
  • num_search(int) : The number of parameter search iteration. Defaults to set 15. This option works if search is True.
  • algorithm(Optional[str]) : Algorithm for parameter search. Defaults to None.
  • parameters(Optional[JijVectorAnnealingParameters]) : parameters for SXAurora. Defaults to None.
  • max_wait_time(int | float | None) : The number of timeout [sec] for post request. If None, 600 will be set. Please note that this argument is for the jijzept timeout and not for configuring solver settings, such as solving time.
  • sync(bool) : Synchronous mode.
  • queue_name(Optional[str]) : Queue name.
  • **kwargs : VectorAnnealing parameters using kwargs. If both `kwargsandparametersare exist, the value of**kwargs` takes precedence.

Returns

  • JijModelingResponse : Stores minimum energy samples and other information.

Examples

import jijzept as jz
import jijmodeling as jm

n = jm.Placeholder('n')
x = jm.BinaryVar('x', shape=(n,))
d = jm.Placeholder('d', ndim=1)
i = jm.Element("i", belong_to=n)
problem = jm.Problem('problem')
problem += jm.sum(i, d[i] * x[i])

sampler = jz.JijVectorAnnealingSampler(config='config.toml')
response = sampler.sample_model(problem, {'n': 5, 'd': [1,2,3,4,5]})

upload_instance (self, problem, feed_dict, system_time) -> str

Upload instance.

An instance is a pair of problem and feed_dict. This method stores the instance into the cloud.

Parameters

  • problem(jm.Problem) : Mathematical expression of JijModeling.
  • feed_dict(dict[str, int | float | numpy.integer | numpy.floating | numpy.ndarray | list]) : The actual values to be assigned to the placeholders.
  • system_time(jm.SystemTime) : Object to store upload time.

Returns

  • str : The ID of the uploaded instance.

Examples

import jijzept as jz
import jijmodeling as jm

n = jm.Placeholder('n')
x = jm.BinaryVar('x', shape=(n,))
d = jm.Placeholder('d', ndim=1)
i = jm.Element("i", belong_to=(n,))
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])

# initialize sampler
sampler = jz.JijSASampler(config='config.toml')

# upload instance
instance_id = sampler.upload_instance(problem, {'n': 5, 'd': [1,2,3,4,5]})

# sample uploaded instance
sample_set = sampler.sample_instance(instance_id)