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.

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.0b4.tar.gz (14.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: ommx_openjij_adapter-3.0.0b4.tar.gz
  • Upload date:
  • Size: 14.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.0b4.tar.gz
Algorithm Hash digest
SHA256 b7468fa52bb5d9c7595282f4e83e260726335759857323968c3811ae39cc97a0
MD5 e9c8edd8d92aa4ae553bc40e14cbe318
BLAKE2b-256 43d63449e325ac04ea3e75577f03e621cc0ce54986898aa1d7e127accc2f2efd

See more details on using hashes here.

Provenance

The following attestation bundles were made for ommx_openjij_adapter-3.0.0b4.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.0b4 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