ommx_openjij_adapter#

Submodules#

Classes#

OMMXOpenJijSAAdapter

Sample an applicable Binary polynomial input with OpenJij simulated annealing.

Functions#

decode_to_samples(→ ommx.Samples)

Convert openjij.Response to Samples

Package 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.

sample() and solve() prepare an isolated copy with recommended_preparation_policy(). Use sample_without_preparation() or solve_without_preparation() after explicitly preparing an instance when caller-owned choices such as fixed penalty magnitudes are required.

classmethod check_applicability(ommx_instance: Instance) InstanceClassMembershipReport#

Check INPUT_CLASS membership without mutation.

decode(data: openjij.Response) Solution#

Decode sampler output and return its best feasible 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, converts the active objective 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) InstanceClassMembershipReport#

Return the membership 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, updater: str | None = None, sparse: bool | None = None, reinitialize_state: bool | None = None, seed: int | None = None, diagnostics: DiagnosticsSink | None = None) SampleSet#

Prepare and sample an isolated copy of ommx_instance.

OpenJij initial_state values are defined against the solver-variable representation of an exact Adapter input, so they are accepted only by sample_without_preparation().

classmethod sample_without_preparation(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 an exact OpenJij Adapter input without preparing it.

initial_state is defined against this exact input's solver-variable representation.

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, updater: str | None = None, sparse: bool | None = None, reinitialize_state: bool | None = None, seed: int | None = None, diagnostics: DiagnosticsSink | None = None) Solution#

Prepare, sample, and return the best feasible result.

OpenJij initial_state values are defined against the solver-variable representation of an exact Adapter input, so they are accepted only by solve_without_preparation().

classmethod solve_without_preparation(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 result from sample_without_preparation().

initial_state is defined against the exact Adapter input's solver-variable representation.

INPUT_CLASS: ClassVar[InstanceClass]#

Required condition for an exact Adapter input.

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, ...], 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, ...], float]#

Expose sampler_input through the SolverAdapter interface.

sparse: bool | None = None#

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

updater: str | None = None#

updater algorithm

decode_to_samples(response: openjij.Response) Samples#

Convert openjij.Response to Samples