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

.. oe:namespace:: OEOpt

.. meta::
   :keywords: OECheckpoint1, Checkpoint1


.. _OEOpt_OECheckpoint1:

.. oe:class:: OECheckpoint1

   .. attention::

      |TWOLANGUAGE|

   .. oe:api::

      class OECheckpoint1 : public OECheckpoint0

   The :ref:`OECheckpoint1 <OEOpt_OECheckpoint1>` provides a "callback" facility to monitor the progress of
   an optimization. In addition, it can also be used to control the termination of an optimization.
   This class may be used with optimizers that do not use gradients as well as those that use 
   gradients

   The following methods are publicly inherited from
   :ref:`OECheckpoint0 <OEOpt_OECheckpoint0>`:

    * :oe:meth:`operator()<OEOpt::OECheckpoint0::operator()>` 

   The :ref:`OECheckpoint1 <OEOpt_OECheckpoint1>` class defines the following public
   methods:   

    * :oe:meth:`operator()<OEOpt::OECheckpoint1::operator()>` 
   
   .. oe:method:: operator()

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

         .. oe:api::

            bool operator()(unsigned int iteration, unsigned int nvar, double fval, double gnorm, const double* var = (double *) 0, const double* grad = (double *) 0, unsigned int state = 0)=0

      .. oe:language:: python

         .. oe:api:: python

            __call__(iteration: int, nvar: int, fval: float, gnorm: float,
                     var: OEDoubleArray = (OEDoubleArray),
                     grad: OEDoubleArray = (OEDoubleArray), state: int = 0) -> bool

      This operator method is called by an optimizer at least once per iteration during 
      an optimization. The variables passed to the method from the optimizer reflect the 
      current state of an optimization. 

      *iteration*
         The iteration number.

      *nvar*
         The number of variables.

      *fval* 
         The most recent function evaluation during the current iteration.

      *gnorm* 
         The most recent gradient norm evaluation during the current
         iteration. The gradient norm is defined as
         :math:`\sqrt{\sum_i {g_ig_i}}`

      *var* 
         Array containing current set of optimized variables.  If available, the array has a length of ``nvar``.

      *grad* 
         Array containing current set of optimized variables.  If available, the array has a length of ``nvar``.

      *state*
         The current state of optimization.
