ommx_openjij_adapter.adapter#

Direct OpenJij Adapter implementation.

Classes#

OMMXOpenJijSAAdapter

Sample an applicable Binary polynomial input with OpenJij simulated annealing.

Module Contents#

class OMMXOpenJijSAAdapter(ommx_instance: Instance, *, beta_min: float | None = None, beta_max: float | None = None, num_sweeps: int | None = None, num_reads: int | None = None, schedule: list | None = None, initial_state: list | dict | None = None, updater: str | None = None, sparse: bool | None = None, reinitialize_state: bool | None = None, seed: int | None = None)#

Sample an applicable Binary polynomial input with OpenJij simulated annealing.

The direct Adapter input must use only Binary decision variables, have no active regular or special constraints, and be a minimization problem. Arbitrary polynomial objective degree is supported through OpenJij’s QUBO and Binary-HUBO paths.

Integer encoding, sense normalization, slack introduction, and fixed constraint penalties are explicit preparation operations, not part of the declared input class. Start from recommended_preparation_policy(), edit caller-owned choices such as fixed penalty magnitudes, and apply the policy with Instance.prepare().

classmethod check_applicability(ommx_instance: Instance) AdapterApplicabilityReport#

Inspect applicability without mutating or preparing ommx_instance.

Adapter-specific preconditions run only after at least one complete input-class clause contains the instance. The hook receives an isolated copy so it cannot mutate the caller’s instance. Any explicitly transformed value is a different input and must be checked separately.

decode(data: openjij.Response) Solution#
decode_to_samples(data: openjij.Response) Samples#

Convert openjij.Response to Samples

There is a static method decode_to_samples() that does the same thing.

decode_to_sampleset(data: openjij.Response) SampleSet#
classmethod recommended_preparation_policy() PreparationPolicy#

Recommend the model changes commonly needed by OpenJij.

The recommendation lowers every special-constraint family, normalizes maximization to minimization, adds Integer slack while permitting an inequality to remain when exact equality conversion is unavailable, and log-encodes every used Integer variable. Both Integer slack ranges use 32.

Fixed penalty magnitudes remain explicit caller parameters because sufficient values depend on the application. The shared Instance owner operation validates their nonnegative-with-tolerance domain. Set fixed_penalty on the fresh returned policy when active constraints must be removed.

classmethod require_applicable(ommx_instance: Instance) AdapterApplicabilityReport#

Return the report or raise AdapterNotApplicableError.

classmethod sample(ommx_instance: Instance, *, beta_min: float | None = None, beta_max: float | None = None, num_sweeps: int | None = None, num_reads: int | None = None, schedule: list | None = None, initial_state: list | dict | None = None, updater: str | None = None, sparse: bool | None = None, reinitialize_state: bool | None = None, seed: int | None = None, diagnostics: DiagnosticsSink | None = None) SampleSet#

Sample the exact applicable ommx_instance passed to the Adapter.

classmethod solve(ommx_instance: Instance, *, beta_min: float | None = None, beta_max: float | None = None, num_sweeps: int | None = None, num_reads: int | None = None, schedule: list | None = None, initial_state: list | dict | None = None, updater: str | None = None, sparse: bool | None = None, reinitialize_state: bool | None = None, seed: int | None = None, diagnostics: DiagnosticsSink | None = None) Solution#

Return the best feasible sample from sample().

INPUT_CLASS: ClassVar[InstanceClass | None]#
MAX_OPENJIJ_VARIABLE_ID: ClassVar[int] = 9223372036854775807#
beta_max: float | None = None#

maximum value of inverse temperature

beta_min: float | None = None#

minimal value of inverse temperature

initial_state: list | dict | None = None#

initial state (parameter only used if problem is QUBO)

num_reads: int | None = None#

number of reads

num_sweeps: int | None = None#

number of sweeps

ommx_instance: Instance#

Isolated copy of the exact Adapter input used to evaluate returned samples.

reinitialize_state: bool | None = None#

if true reinitialize state for each run (parameter only used if problem is QUBO)

property sampler_input: dict[tuple[int, Ellipsis], float]#
schedule: list | None = None#

list of inverse temperature (parameter only used if problem is QUBO)

seed: int | None = None#

seed for Monte Carlo algorithm

property solver_input: dict[tuple[int, Ellipsis], float]#
sparse: bool | None = None#

use sparse matrix or not (parameter only used if problem is QUBO)

updater: str | None = None#

updater algorithm