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

[!WARNING] The meaning of SampleSet.objectives changed in OMMX v3. In v2, when OMMXOpenJijSAAdapter.sample() applied a penalty method, SampleSet.objectives included the penalty terms from the QUBO/HUBO energy (with the source sense restored for maximization). In v3 and later, SampleSet.objectives contains the original problem's objective value. Penalty terms still affect OpenJij's sampling but are not included in the returned objective. Update code that treated SampleSet.objectives as the OpenJij energy.

The easy API prepares an isolated copy with the Adapter's recommended policy, so it can directly accept inputs such as an Integer maximization model without modifying the caller's Instance:

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

OpenJij's initial_state is defined over the exact Adapter-input solver variables; dictionary keys are those variable IDs. Because Preparation may replace source variables with encoded or slack variables, pass initial_state only to the exact-input constructor, sample_without_preparation(), or solve_without_preparation() after preparing the Instance explicitly.

Preparation choices that require application knowledge remain explicit. For example, prepare the Instance with a selected fixed penalty weight and use the preparation-free API for a constrained model:

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,
)

policy = OMMXOpenJijSAAdapter.recommended_preparation_policy()
policy.fixed_penalty = FixedPenaltyPreparation.uniform_penalty_method_with_fixed_weight(
    weight=2.0
)
instance.prepare(OMMXOpenJijSAAdapter.INPUT_CLASS, policy)

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

The fixed penalty weight is part of the preparation policy, not an OpenJij sampler parameter. 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.

Accepted models and recommended preparation

This adapter directly accepts:

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

For the shared semantics of adapter input classes and preparation, see Adapter Input Classes and Explicit Constraint Lowering.

When building OpenJij sampler input, used variable IDs must fit a signed 64-bit integer and converted interaction coefficients must be finite. Violations are reported as conversion errors.

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

  • lowering active Indicator, OneHot, and SOS1 constraints;
  • converting the active objective from 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.

Pass the prepared Instance to sample_without_preparation. It remains the evaluation owner for the returned SampleSet and retains the data needed to restore source-variable values and evaluate removed constraints. The easy sample API performs the copy and recommended preparation automatically when no custom preparation choices are needed.

Integer log encoding follows the representability and bit-count limits of the OMMX encoding operation. OMMX does not yet implement Kind::Spin; direct OpenJij Spin input is tracked separately in OMMX issue #1082.

Metadata

Release files for ommx-openjij-adapter 3.0.0b5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ommx-openjij-adapter 3.0.0b5
File Size Uploaded
ommx_openjij_adapter-3.0.0b5.tar.gz 14.0 kB Details

Release files / ommx_openjij_adapter-3.0.0b5.tar.gz

Download URL ommx_openjij_adapter-3.0.0b5.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2a5500f432ddddc6db1e10ec516b8a8cce76b6ae6844ee493414fd44bd9e4a33
BLAKE2b-256 checksum
How to use checksums
7c12d1f8c7bdfb04489f011242e4befc224ca96e01fdcc630a571046c467f9d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

3.0.0b5 This release

1 release file

2.9.2

1 release file

2.9.1

1 release file

2.9.0

1 release file

2.8.0

1 release file

2.7.0

1 release file

2.6.3

1 release file

2.6.2

1 release file

2.6.1

1 release file

2.6.0

1 release file

2.5.2

1 release file

2.5.1

1 release file

2.5.0

1 release file

2.4.0

1 release file

2.3.6

1 release file

2.3.5

1 release file

2.3.4

1 release file

2.3.3

1 release file

2.3.2

1 release file

2.3.1

1 release file

2.3.0

1 release file

2.2.0

1 release file

2.1.0

1 release file

2.0.12

1 release file

2.0.11

1 release file

2.0.10

1 release file

2.0.9

1 release file

2.0.8

1 release file

2.0.7

1 release file

2.0.6

1 release file

2.0.5

1 release file

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.9.5

1 release file

1.9.4

1 release file

1.9.3

1 release file

1.9.2

1 release file

1.9.1

1 release file

1.9.0

1 release file

1.8.6

1 release file

1.8.5

1 release file

1.8.4

1 release file

1.8.3

1 release file

1.8.2

1 release file

1.8.1

1 release file

1.8.0

1 release file

1.7.0

1 release file

1.6.0

1 release 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