.. include:: ../../toolkit-substitutions

.. oe:namespace:: OEOpt



.. meta::
   :keywords: OEOptimizer2, Optimizer2


.. _OEOpt_OEOptimizer2:

.. oe:class:: OEOptimizer2

   .. attention::

      |TWOLANGUAGE|

   .. oe:api::


      class OEOptimizer2

   The :ref:`OEOptimizer2 <OEOpt_OEOptimizer2>` abstract class defines the interface for
   optimizing a set of variables for which a function, gradients and second
   derivatives (elements oh Hessian matrix) can be evaluated. Implementations of 
   :ref:`OEOptimizer2 <OEOpt_OEOptimizer2>` use function values, gradients and second
   derivatives of function during optimization.


   The :ref:`OEOptimizer2 <OEOpt_OEOptimizer2>` class defines the following public methods:
    * :oe:meth:`operator()<OEOpt::OEOptimizer2::operator()>`         
    * :oe:meth:`GetIterLimit<OEOpt::OEOptimizer2::GetIterLimit>` and
      :oe:meth:`SetIterLimit<OEOpt::OEOptimizer2::SetIterLimit>`
    * :oe:meth:`GetTolerance<OEOpt::OEOptimizer2::GetTolerance>` and
      :oe:meth:`SetTolerance<OEOpt::OEOptimizer2::SetTolerance>`


   The following classes derive from this class:  
    * :ref:`OENewtonOpt <OEOpt_OENewtonOpt>`

   .. oe:method:: operator()

      .. oe:language:: c++ java csharp

         .. oe:api::

            double operator()(OEFunc2& function, const double* var, double* opt_var)
            double operator()(OEFunc2& function, OECheckpoint1* check, const double* var, double* opt_var)

      .. oe:language:: python

         .. oe:api:: python

            __call__(function: OEFunc2, var: OEDoubleArray,
                     opt_var: OEDoubleArray) -> float
            __call__(function: OEFunc2, check: OECheckpoint1,
                     var: OEDoubleArray, opt_var: OEDoubleArray) -> float

      These virtual methods define the interface for optimizing a set of variables
      with the use of evaluated function values. The reference to the function object
      is passed as a first argument. Initial values of variables are passed in the
      array ``var``. The optimized variables are returned in the array ``opt_var``.
      Both operators return the value of the corresponding optimized function value.
      The second operator takes a pointer to the :ref:`OECheckpoint1 <OEOpt_OECheckpoint1>` object
      that can be used to monitor the progress of an optimization.

   .. oe:method:: GetIterLimit

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned GetIterLimit() const

      .. oe:language:: python

         .. oe:api:: python

            GetIterLimit() -> int

      See :oe:meth:`SetIterLimit<OEOpt::OEOptimizer2::SetIterLimit>`.

   .. oe:method:: GetTolerance

      .. oe:language:: c++ java csharp

         .. oe:api::

            double GetTolerance() const

      .. oe:language:: python

         .. oe:api:: python

            GetTolerance() -> float

      See :oe:meth:`SetTolerance<OEOpt::OEOptimizer2::SetTolerance>`.

   .. oe:method:: SetIterLimit

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetIterLimit(unsigned int itmax)

      .. oe:language:: python

         .. oe:api:: python

            SetIterLimit(itmax: int) -> None

      Defines the interface for setting the maximum number of iterations that an
      optimizer derived from the :ref:`OEOptimizer2 <OEOpt_OEOptimizer2>` will attempt while
      trying to identify a converged minimum function value. Optimization will cease if
      the iteration limit is reached without finding a converged minimum.

   .. oe:method:: SetTolerance

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetTolerance(double t)

      .. oe:language:: python

         .. oe:api:: python

            SetTolerance(t: float) -> None

      Defines the interface for setting the gradient convergence criteria. Depending
      on the implementation it might be the root mean square gradient, gradient norm
      or gradient dot product. Optimization will terminate normally if the convergence 
      criteria set by this method is achieved during an optimization.


