Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ommx-openjij-adapter

Provides an adapter between OMMX and OpenJij.

Usage

ommx-openjij-adapter can be installed from PyPI:

pip install ommx-openjij-adapter

OpenJij directly accepts a Binary, unconstrained minimization model through this adapter. Prepare a constrained model in place before sampling it:

from ommx import DecisionVariable, FixedPenaltyPreparation, Instance
from ommx_openjij_adapter import OMMXOpenJijSAAdapter

x = DecisionVariable.binary(0, name="x")
instance = Instance.from_components(
    decision_variables=[x],
    objective=x,
    constraints={0: x == 1},
    sense=Instance.MINIMIZE,
)

input_class = OMMXOpenJijSAAdapter.INPUT_CLASS
assert input_class is not None
policy = OMMXOpenJijSAAdapter.recommended_preparation_policy()
policy.fixed_penalty = FixedPenaltyPreparation.uniform_penalty_method_with_fixed_weight(
    weight=2.0
)
instance.prepare(input_class, policy)
OMMXOpenJijSAAdapter.require_applicable(instance)

sample_set = OMMXOpenJijSAAdapter.sample(
    instance,
    num_reads=16,
)
print(sample_set.summary)

The fixed penalty weight is a nonnegative magnitude in the caller-owned preparation policy, not an OpenJij backend sampler parameter. The owner operation accepts values down to -atol and normalizes tolerated negative values to zero. The adapter deliberately does not choose a magnitude: zero adds no preference for feasibility, while a sufficiently large positive value is application-specific and still does not guarantee that every returned sample is feasible.

Input class and preparation recommendation

OMMXOpenJijSAAdapter.INPUT_CLASS describes the instances that the adapter accepts directly:

  • Binary decision variables
  • a polynomial objective of any degree (QUBO or Binary HUBO)
  • no active regular or special constraints
  • minimization

check_applicability() and the constructor are strict and never transform an input. In addition to input-class membership, they check the OpenJij-specific requirements that used variable IDs fit a signed 64-bit integer and converted interaction coefficients are finite.

recommended_preparation_policy() returns a fresh editable ommx.PreparationPolicy. It recommends:

  • lowering active Indicator, OneHot, and SOS1 constraints;
  • normalizing maximization to minimization;
  • attempting exact Integer slack with range 32, while permitting inequality-preserving Integer slack with upper bound 32 when exact equality conversion is unavailable; and
  • log-encoding all used Integer variables.

Fixed penalty remains disabled until the caller selects either a uniform magnitude or magnitudes keyed by active regular constraint ID. Uniform weights are usually the convenient choice when special-constraint lowering creates regular constraints with generated IDs. OMMX validates the weight domain; the caller remains responsible for selecting a sufficient magnitude.

Instance.prepare() mutates the same Instance that is then passed to the adapter. Success guarantees membership in INPUT_CLASS; the adapter-specific preconditions must still be checked normally. Preparation uses the shared OMMX owner operations and their existing exception types. It is not globally transactional, so changes completed before a later error remain.

The mutated instance remains the evaluation owner for the returned SampleSet. It retains the dependency and removed-constraint data needed for evaluation; there is no separate OpenJij preparation result or source-reconstruction API. If an application separately needs the pre-transformation model, it should copy that model before calling prepare().

The exact representability and bit-count limits of Integer log encoding belong to the OMMX encoding operation, not to the OpenJij input class or an ommx.v2.Feature. OMMX does not yet implement Kind::Spin; direct OpenJij Spin input is tracked separately in OMMX issue #1082.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ommx_openjij_adapter-3.0.0b3.tar.gz (12.0 kB view details)

Uploaded Source

File details

Details for the file ommx_openjij_adapter-3.0.0b3.tar.gz.

File metadata

  • Download URL: ommx_openjij_adapter-3.0.0b3.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ommx_openjij_adapter-3.0.0b3.tar.gz
Algorithm Hash digest
SHA256 f3bcef5d39542727f15b8e3dd132b81c0f8179b2a9e9a5136fd1511da4cf0558
MD5 e6e6b047613b388e7b44069297e1d845
BLAKE2b-256 6943a08a8732592ff3b722dfe92258365fca17f121f31ffdb5af3e4c4b12762d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ommx_openjij_adapter-3.0.0b3.tar.gz:

Publisher: release_python.yml on Jij-Inc/ommx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

3.0.0b3 This release

1 file

2.6.2

1 file

2.6.1

1 file

2.6.0

1 file

2.5.2

1 file

2.5.1

1 file

2.5.0

1 file

2.4.0

1 file

2.3.6

1 file

2.3.5

1 file

2.3.4

1 file

2.3.3

1 file

2.3.2

1 file

2.3.1

1 file

2.3.0

1 file

2.2.0

1 file

2.1.0

1 file

2.0.12

1 file

2.0.11

1 file

2.0.10

1 file

2.0.9

1 file

2.0.8

1 file

2.0.7

1 file

2.0.6

1 file

2.0.5

1 file

2.0.4

1 file

2.0.3

1 file

2.0.2

1 file

2.0.1

1 file

2.0.0

1 file

1.9.5

1 file

1.9.4

1 file

1.9.3

1 file

1.9.2

1 file

1.9.1

1 file

1.9.0

1 file

1.8.6

1 file

1.8.5

1 file

1.8.4

1 file

1.8.3

1 file

1.8.2

1 file

1.8.1

1 file

1.8.0

1 file

1.7.0

1 file

1.6.1

1 file

1.6.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page