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
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3bcef5d39542727f15b8e3dd132b81c0f8179b2a9e9a5136fd1511da4cf0558
|
|
| MD5 |
e6e6b047613b388e7b44069297e1d845
|
|
| BLAKE2b-256 |
6943a08a8732592ff3b722dfe92258365fca17f121f31ffdb5af3e4c4b12762d
|
Provenance
The following attestation bundles were made for ommx_openjij_adapter-3.0.0b3.tar.gz:
Publisher:
release_python.yml on Jij-Inc/ommx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ommx_openjij_adapter-3.0.0b3.tar.gz -
Subject digest:
f3bcef5d39542727f15b8e3dd132b81c0f8179b2a9e9a5136fd1511da4cf0558 - Sigstore transparency entry: 2435189073
- Sigstore integration time:
-
Permalink:
Jij-Inc/ommx@ffa59924d991bb25c73f0f0afc86baef4c4b18e4 -
Branch / Tag:
refs/tags/python-3.0.0b3 - Owner: https://github.com/Jij-Inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release_python.yml@ffa59924d991bb25c73f0f0afc86baef4c4b18e4 -
Trigger Event:
push
-
Statement type: