ommx_openjij_adapter.adapter#
Direct OpenJij Adapter implementation.
Classes#
Implementation of |
Module 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)#
Implementation of
ommx_openjij_adapter.OMMXOpenJijSAAdapter.- classmethod check_applicability(ommx_instance: Instance) InstanceClassMembershipReport#
Check
INPUT_CLASSmembership 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
ommx.SamplesThere is a static method
decode_to_samples()that does the same thing.
- 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
Instanceowner operation validates their nonnegative-with-tolerance domain. Setfixed_penaltyon 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.This obtains a fresh recommended policy. For a complete example with an explicit penalty weight, see
ommx_openjij_adapter.OMMXOpenJijSAAdapter.OpenJij
initial_statevalues are defined against the solver-variable representation of an exact Adapter input, so they are accepted only bysample_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.
See
ommx_openjij_adapter.OMMXOpenJijSAAdapterfor a complete example from an explicitly prepared constrained model to candidate evaluation and selection.initial_stateis 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.
Selects from the obtained candidates and does not prove optimality. Raises
ValueErrorif no sampled candidate is feasible. Usesample()to retain all candidates for inspection.OpenJij
initial_statevalues are defined against the solver-variable representation of an exact Adapter input, so they are accepted only bysolve_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().Selection uses the reported objective and retained feasibility checks. It does not prove optimality and raises
ValueErrorwhen no feasible candidate was obtained. Usesample_without_preparation()to inspect all candidates, as shown inommx_openjij_adapter.OMMXOpenJijSAAdapter.initial_stateis defined against the exact Adapter input’s solver-variable representation.
- INPUT_CLASS: ClassVar[InstanceClass]#
Required condition for an exact Adapter input.
- 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)