ommx_openjij_adapter.adapter
============================

.. py:module:: ommx_openjij_adapter.adapter

.. autoapi-nested-parse::

   Direct OpenJij Adapter implementation.



Classes
-------

.. autoapisummary::

   ommx_openjij_adapter.adapter.OMMXOpenJijSAAdapter


Module Contents
---------------

.. py:class:: OMMXOpenJijSAAdapter(ommx_instance: ommx.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.

   :meth:`sample` and :meth:`solve` prepare an isolated copy with
   :meth:`recommended_preparation_policy`. Use :meth:`sample_without_preparation` or
   :meth:`solve_without_preparation` after explicitly preparing an instance when
   caller-owned choices such as fixed penalty magnitudes are required.


   .. py:method:: check_applicability(ommx_instance: ommx.Instance) -> ommx.InstanceClassMembershipReport
      :classmethod:


      Check ``INPUT_CLASS`` membership without mutation.



   .. py:method:: decode(data: openjij.Response) -> ommx.Solution

      Decode sampler output and return its best feasible solution.



   .. py:method:: decode_to_samples(data: openjij.Response) -> ommx.Samples

      Convert `openjij.Response <https://openjij.github.io/OpenJij/reference/openjij/index.html#openjij.Response>`_ to :class:`Samples`

      There is a static method :meth:`decode_to_samples` that does the same thing.



   .. py:method:: decode_to_sampleset(data: openjij.Response) -> ommx.SampleSet


   .. py:method:: recommended_preparation_policy() -> ommx.PreparationPolicy
      :classmethod:


      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 ``Instance``
      owner operation validates their nonnegative-with-tolerance domain. Set
      ``fixed_penalty`` on the fresh returned policy when active constraints
      must be removed.



   .. py:method:: require_applicable(ommx_instance: ommx.Instance) -> ommx.InstanceClassMembershipReport
      :classmethod:


      Return the membership report or raise ``AdapterNotApplicableError``.



   .. py:method:: sample(ommx_instance: ommx.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: ommx.adapter.DiagnosticsSink | None = None) -> ommx.SampleSet
      :classmethod:


      Prepare and sample an isolated copy of ``ommx_instance``.

      OpenJij ``initial_state`` values are defined against the solver-variable
      representation of an exact Adapter input, so they are accepted only by
      :meth:`sample_without_preparation`.



   .. py:method:: sample_without_preparation(ommx_instance: ommx.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: ommx.adapter.DiagnosticsSink | None = None) -> ommx.SampleSet
      :classmethod:


      Sample an exact OpenJij Adapter input without preparing it.

      ``initial_state`` is defined against this exact input's solver-variable
      representation.



   .. py:method:: solve(ommx_instance: ommx.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: ommx.adapter.DiagnosticsSink | None = None) -> ommx.Solution
      :classmethod:


      Prepare, sample, and return the best feasible result.

      OpenJij ``initial_state`` values are defined against the solver-variable
      representation of an exact Adapter input, so they are accepted only by
      :meth:`solve_without_preparation`.



   .. py:method:: solve_without_preparation(ommx_instance: ommx.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: ommx.adapter.DiagnosticsSink | None = None) -> ommx.Solution
      :classmethod:


      Return the best feasible result from :meth:`sample_without_preparation`.

      ``initial_state`` is defined against the exact Adapter input's
      solver-variable representation.



   .. py:attribute:: INPUT_CLASS
      :type:  ClassVar[ommx.InstanceClass]

      Required condition for an exact Adapter input.



   .. py:attribute:: MAX_OPENJIJ_VARIABLE_ID
      :type:  ClassVar[int]
      :value: 9223372036854775807



   .. py:attribute:: beta_max
      :type:  float | None
      :value: None


      maximum value of inverse temperature 



   .. py:attribute:: beta_min
      :type:  float | None
      :value: None


      minimal value of inverse temperature 



   .. py:attribute:: initial_state
      :type:  list | dict | None
      :value: None


      initial state (parameter only used if problem is QUBO)



   .. py:attribute:: num_reads
      :type:  int | None
      :value: None


      number of reads 



   .. py:attribute:: num_sweeps
      :type:  int | None
      :value: None


      number of sweeps 



   .. py:attribute:: ommx_instance
      :type:  ommx.Instance

      Isolated copy of the exact Adapter input used to evaluate returned samples.



   .. py:attribute:: reinitialize_state
      :type:  bool | None
      :value: None


      if true reinitialize state for each run (parameter only used if problem is QUBO)



   .. py:property:: sampler_input
      :type: dict[tuple[int, ...], float]



   .. py:attribute:: schedule
      :type:  list | None
      :value: None


      list of inverse temperature (parameter only used if problem is QUBO)



   .. py:attribute:: seed
      :type:  int | None
      :value: None


      seed for Monte Carlo algorithm 



   .. py:property:: solver_input
      :type: dict[tuple[int, ...], float]


      Expose :attr:`sampler_input` through the SolverAdapter interface.



   .. py:attribute:: sparse
      :type:  bool | None
      :value: None


      use sparse matrix or not (parameter only used if problem is QUBO)



   .. py:attribute:: updater
      :type:  str | None
      :value: None


      updater algorithm 



