ommx_openjij_adapter.adapter#
Direct OpenJij Adapter implementation.
Classes#
Sample an applicable Binary polynomial input with OpenJij simulated annealing. |
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)#
Sample an applicable Binary polynomial input with OpenJij simulated annealing.
The direct Adapter input must use only Binary decision variables, have no active regular or special constraints, and be a minimization problem. Arbitrary polynomial objective degree is supported through OpenJij’s QUBO and Binary-HUBO paths.
sample()andsolve()prepare an isolated copy withrecommended_preparation_policy(). Usesample_without_preparation()orsolve_without_preparation()after explicitly preparing an instance when caller-owned choices such as fixed penalty magnitudes are required.- 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
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.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.
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.
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().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)