Home Contact Us Site Map  
 
       
    next up previous contents
Next: 5.2.5 The control variables Up: 5.2 TLM and ADM Previous: 5.2.3 The AD build   Contents

Subsections


5.2.4 The cost function (dependent variable)

The cost function $ {\cal J} $ is referred to as the dependent variable. It is a function of the input variables $ \vec{u}$ via the composition $ {\cal J}(\vec{u}) \, = \, {\cal J}(M(\vec{u})) $ . The input are referred to as the independent variables or control variables. All aspects relevant to the treatment of the cost function $ {\cal J} $ (parameter setting, initialization, accumulation, final evaluation), are controlled by the package pkg/cost. The aspects relevant to the treatment of the independent variables are controlled by the package pkg/ctrl and will be treated in the next section.

Figure 5.3:  
\begin{figure}\par
{\scriptsize
\begin{verbatim}the_model_main
\vert
\vert-...
...r
\vert end do
\vert
\vert-- cost_final
o\end{verbatim}
}
\par\end{figure}

5.2.4.1 Enabling the package

\fbox{
\begin{minipage}{12cm}
{\it packages.conf}, {\it ECCO\_CPPOPTIONS.h}
\end{minipage}}

  • The package is enabled by adding cost to your file packages.conf (see Section ???)

N.B.: In general the following packages ought to be enabled simultaneously: autodiff, cost, ctrl. The basic CPP option to enable the cost function is ALLOW_COST. Each specific cost function contribution has its own option. For the present example the option is ALLOW_COST_TRACER. All cost-specific options are set in ECCO_CPPOPTIONS.h Since the cost function is usually used in conjunction with automatic differentiation, the CPP option ALLOW_ADJOINT_RUN (file CPP_OPTIONS.h) and ALLOW_AUTODIFF_TAMC (file ECCO_CPPOPTIONS.h) should be defined.

5.2.4.2 Initialization

The initialization of the cost package is readily enabled as soon as the CPP option ALLOW_COST is defined.
  • \fbox{
\begin{minipage}{12cm}
Parameters: {\it cost\_readparms}
\end{minipage}}
    This S/R reads runtime flags and parameters from file data.cost. For the present example the only relevant parameter read is mult_tracer. This multiplier enables different cost function contributions to be switched on ( = 1.) or off ( = 0.) at runtime. For more complex cost functions which involve model vs. data misfits, the corresponding data filenames and data specifications (start date and time, period, ...) are read in this S/R.
  • \fbox{
\begin{minipage}{12cm}
Variables: {\it cost\_init}
\end{minipage}}
    This S/R initializes the different cost function contributions. The contribution for the present example is objf_tracer which is defined on each tile (bi,bj).

5.2.4.3 Accumulation

  • \fbox{
\begin{minipage}{12cm}
{\it cost\_tile}, {\it cost\_tracer}
\end{minipage}}
The 'driver' routine cost_tile is called at the end of each time step. Within this 'driver' routine, S/R are called for each of the chosen cost function contributions. In the present example (ALLOW_COST_TRACER), S/R cost_tracer is called. It accumulates objf_tracer according to eqn. (ref:ask-the-author).

5.2.4.4 Finalize all contributions

  • \fbox{
\begin{minipage}{12cm}
{\it cost\_final}
\end{minipage}}
At the end of the forward integration S/R cost_final is called. It accumulates the total cost function fc from each contribution and sums over all tiles:

$\displaystyle {\cal J} \, = \, {\rm fc} \, = \, {\rm mult\_tracer} \sum_{\text{global sum}} \sum_{bi,\,bj}^{nSx,\,nSy} {\rm objf\_tracer}(bi,bj) \, + \, ...$ (5.13)

The total cost function fc will be the 'dependent' variable in the argument list for TAF, i.e.
taf -output 'fc' ...

Figure 5.4:  
\begin{figure}\par
{\scriptsize
\begin{verbatim}*************
the_main_loop
...
...ALLOW_COST
\vert call cost_final
\vert  ...


next up previous contents
Next: 5.2.5 The control variables Up: 5.2 TLM and ADM Previous: 5.2.3 The AD build   Contents
mitgcm-support@mitgcm.org
Copyright © 2006 Massachusetts Institute of Technology Last update 2018-01-23