***********************************************************************
*                                                                     *
*         PLIV - A LIMITED MEMORY VARIABLE METRIC ALGORITHM WITH      *
*                MULTIPLE CORRECTIONS FOR LARGE-SCALE OPTIMIZATION.   *
*                                                                     *
***********************************************************************


1. Introduction:
----------------

      The double-precision FORTRAN 77 basic subroutine PLIV is designed
to find a close approximation to a local minimum of a nonlinear
function F(X) with simple bounds on variables. Here X is a vector of NF
variables and F(X) is a smooth function. We suppose that NF is large
but the sparsity pattern of the Hessian matrix is not known (or the
Hessian matrix is dense). Simple bounds are assumed in the form

               X(I) unbounded if  IX(I) = 0,
      XL(I) <= X(I)           if  IX(I) = 1,
               X(I) <= XU(I)  if  IX(I) = 2,
      XL(I) <= X(I) <= XU(I)  if  IX(I) = 3,
      XL(I)  = X(I)  = XU(I)  if  IX(I) = 5,

where 1 <= I <= NF. To simplify user's work, two additional easy to use
subroutines are added. They call the basic general subroutine PLIV:

      PLIVU - unconstrained large-scale optimization,
      PLIVS - large-scale optimization with simple bounds.

All subroutines contain a description of formal parameters and
extensive comments. Furthermore, two test programs TLIVU and TLIVS are
included, which contain several test problems (see e.g. [2]). These
test programs serve as examples for using the subroutines, verify their
correctness and demonstrate their efficiency.
      In this short guide, we describe all subroutines which can be
called from the user's program. A detailed description of the method is
given in [1]. In the description of formal parameters, we introduce a
type of the argument that specifies whether the argument must have a
value defined on entry to the subroutine (I), whether it is a value
which will be returned (O), or both (U), or whether it is an auxiliary
value (A). Besides formal parameters, we can use a COMMON /STAT/ block
containing statistical information. This block, used in each subroutine
has the following form:

      COMMON /STAT/ NRES,NDEC,NIN,NIT,NFV,NFG,NFH

The arguments have the following meaning:

 Argument  Type Significance
 ----------------------------------------------------------------------
  NRES      O   Positive INTEGER variable that indicates the number of
                restarts.
  NDEC      O   Positive INTEGER variable that indicates the number of
                matrix decompositions.
  NIN       O   Positive INTEGER variable that indicates the number of
                inner iterations (for solving linear systems).
  NIT       O   Positive INTEGER variable that indicates the number of
                iterations.
  NFV       O   Positive INTEGER variable that indicates the number of
                function evaluations.
  NFG       O   Positive INTEGER variable that indicates the number of
                gradient evaluations.
  NFH       O   Positive INTEGER variable that indicates the number of
                Hessian evaluations.


2. Subroutines PLIVU, PLIVS:
----------------------------

The calling sequences are

      CALL PLIVU(NF,X,IPAR,RPAR,F,GMAX,IPRNT,ITERM)
      CALL PLIVS(NF,X,IX,XL,XU,IPAR,RPAR,F,GMAX,IPRNT,ITERM)

The arguments have the following meaning.

 Argument  Type Significance
 ----------------------------------------------------------------------
  NF        I   Positive INTEGER variable that specifies the number of
                variables of the objective function.
  X(NF)     U   On input, DOUBLE PRECISION vector with the initial
                estimate to the solution. On output, the approximation
                to the minimum.
  IX(NF)    I   On input (significant only for PLIVS) INTEGER vector
                containing the simple bounds types:
                   IX(I)=0 - the variable X(I) is unbounded,
                   IX(I)=1 - the lower bound X(I) >= XL(I),
                   IX(I)=2 - the upper bound X(I) <= XU(I),
                   IX(I)=3 - the two side bound XL(I) <= X(I) <= XU(I),
                   IX(I)=5 - the variable X(I) is fixed (given by its
                             initial estimate).
  XL(NF)    I   DOUBLE PRECISION vector with lower bounds for variables
                (significant only for PLIVS).
  XU(NF)    I   DOUBLE PRECISION vector with upper bounds for variables
                (significant only for PLIVS).
  IPAR(7)   U   INTEGER parameters: 
                  IPAR(1)=MIT,  IPAR(2)=MFV, IPAR(3)-unused,
                  IPAR(4)=IEST, IPAR(5)-MET, IPAR(6)-unused,
                  IPAR(7)=MF.
                Parameters MIT, MFV, IEST, MF are described in Section 3
                together with other parameters of the subroutine PLIV.
  RPAR(9)   U   DOUBLE PRECISION parameters:
                  RPAR(1)=XMAX,    RPAR(2)=TOLX,    RPAR(3)=TOLF,
                  RPAR(4)=TOLB,    RPAR(5)=TOLG,    RPAR(6)=FMIN,
                  RPAR(7)-unused,  RPAR(6)-unused,  RPAR(9)-unused.
                Parameters XMAX, TOLX, TOLF, TOLB, TOLG, FMIN are
                described in Section 3 together with other parameters
                of the subroutine PLIV.
  F         O   DOUBLE PRECISION value of the objective function at the
                solution X.
  GMAX      O   DOUBLE PRECISION maximum absolute value of a partial
                derivative of the objective function.
  IPRNT     I   INTEGER variable that specifies PRINT:
                  IPRNT= 0 - print is suppressed,
                  IPRNT= 1 - basic print of final results,
                  IPRNT=-1 - extended print of final results,
                  IPRNT= 2 - basic print of intermediate and final
                             results,
                  IPRNT=-2 - extended print of intermediate and final
                             results.
  ITERM     O   INTEGER variable that indicates the cause of termination:
                  ITERM= 1 - if |X - XO| was less than or equal to TOLX
                             in two subsequent iterations,
                  ITERM= 2 - if |F - FO| was less than or equal to TOLF
                             in two subsequent iterations,
                  ITERM= 3 - if F is less than or equal to TOLB,
                  ITERM= 4 - if GMAX is less than or equal to TOLG,
                  ITERM= 6 - if termination criterion was not satisfied,
                             but the solution is probably acceptable,
                  ITERM=11 - if NIT exceeded MIT,
                  ITERM=12 - if NFV exceeded MFV,
                  ITERM< 0 - if the method failed.

      The subroutines PLIVU, PLIVS require the user supplied subroutines
OBJ and DOBJ that define the objective function and its gradient and
have the form

      SUBROUTINE  OBJ(NF,X,F)
      SUBROUTINE DOBJ(NF,X,G)

The arguments of the user supplied subroutines have the following
meaning.

 Argument  Type Significance
 ----------------------------------------------------------------------
  NF        I   Positive INTEGER variable that specifies the number of
                variables of the objective function.
  X(NF)     I   DOUBLE PRECISION an estimate to the solution.
  F         O   DOUBLE PRECISION value of the objective function at the
                point X.
  G(NF)     O   DOUBLE PRECISION gradient of the objective function
                at the point X.


3. Subroutine PLIV:
-------------------

      This general subroutine is called from all subroutines described
in Section 2. The calling sequence is

      CALL PLIV(NF,NB,X,IX,XL,XU,GF,S,XO,GO,XM,GM,XR,GR,IW,RW,XMAX,TOLX,
     & TOLF,TOLB,TOLG,FMIN,GMAX,F,MIT,MFV,IEST,MET,MF,IPRNT,ITERM)

The arguments NF, NB, X, IX, XL, XU, GMAX, F, IPRNT, ITERM, have the
same meaning as in Section 2. Other arguments have the following meaning:

 Argument  Type Significance
 ----------------------------------------------------------------------
  GF(NF)    A   DOUBLE PRECISION gradient of the objective function.
  S(NF)     A   DOUBLE PRECISION direction vector.
  XO(NF)    A   DOUBLE PRECISION array which contains increments of
                variables.
  GO(NF)    A   DOUBLE PRECISION array which contains increments of
                gradients.
  XM(NF*MF) A   DOUBLE PRECISION array which contains previous
                increments of variables.
  GM(NF*MF) A   DOUBLE PRECISION array which contains previous
                increments of gradients.
  XR(NZR)   A   DOUBLE PRECISION Auxiliary array (NCR is equal to 
                2*NF*NF).
  GR(NGR)   A   DOUBLE PRECISION Auxiliary array (NCR is equal to 
                NF*(NF+1)/2).
  IW(MF*MF) A   INTEGER  Auxiliary array.
  RW(9*MF)  A   DOUBLE PRECISION Auxiliary array.
  XMAX      U   DOUBLE PRECISION maximum stepsize; the choice XMAX=0
                causes that the default value 1.0D+16 will be taken.
  TOLX      U   DOUBLE PRECISION tolerance for the change of the
                coordinate vector X; the choice TOLX=0 causes that the
                default value TOLX=1.0D-16 will be taken.
  TOLF      U   DOUBLE PRECISION tolerance for the change of function
                values; the choice TOLF=0 causes that the default
                value TOLF=1.0D-14 will be taken. 
  TOLB      U   DOUBLE PRECISION minimum acceptable function value;
                the choice TOLB=0 causes that the default value
                TOLB=FMIN+1.0D-16 will be taken.
  TOLG      U   DOUBLE PRECISION tolerance for the Lagrangian function
                gradient; the choice TOLG=0 causes that the default
                value TOLG=1.0D-6 will be taken. 
  FMIN      U   DOUBLE PRECISION lower bound for the minimum function
                value. It is significant only if IEST=1. If IEST=0,
                the default value FMIN=-1.0D+60 will be taken.
  MIT       U   INTEGER variable that specifies the maximum number of
                iterations; the choice MIT=0 causes that the default
                value 9000 will be taken.
  MFV       U   INTEGER variable that specifies the maximum number of
                function evaluations; the choice MFV=0 causes that
                the default value 9000 will be taken.
  IEST      I   INTEGER estimation of the minimum functiom value for
                the line search:
                  IEST=0 - estimation is not used,
                  IEST=1 - lower bound FMIN is used as an estimation
                           for the minimum function value.
  MET       I   Maximum number of correction steps; the choice TOLX=0 
                causes that the default value MET=4 will be taken.                        
  MF        U   The number of limited-memory variable metric updates
                in each iteration (they use 2*MF stored vectors).
                The choice MF=0 causes that the default value MF=5 
                will be taken.
             
The choice of parameter XMAX can be sensitive in many cases. First, the
objective function can be evaluated only in a relatively small region
(if it contains exponentials) so that the maximum stepsize is necessary.
Secondly, the problem can be very ill-conditioned far from the solution
point so that large steps can be unsuitable. Finally, if the problem has
more local solutions, a suitably chosen maximum stepsize can lead to
obtaining a better local solution.
      The subroutine PLIV requires the user supplied subroutines OBJ
and DOBJ which are described in Section 2.

4. Verification of the subroutines:
-----------------------------------

      Subroutine PLIVU can be verified and tested using the program
TLIVU. This program calls the subroutines TIUD14 (initiation), TFFU14
(function evaluation) and TFGU14 (gradient evaluation) containing
22 unconstrained test problems with at most 1000 variables [2]. The
results obtained by the program TLIVU on a PC computer with Microsoft
Power Station Fortran compiler have the following form.

NIT= 4957  NFV= 5479  NFG= 5479  F= 0.731101738E-13  G= 0.882E-06  ITERM=  4
NIT=  353  NFV=  411  NFG=  411  F=  14.9944763      G= 0.101E-04  ITERM=  2
NIT=  113  NFV=  122  NFG=  122  F= 0.575809315E-12  G= 0.119E-06  ITERM=  4
NIT=  107  NFV=  112  NFG=  112  F=  269.499543      G= 0.284E-05  ITERM=  2
NIT=   23  NFV=   26  NFG=   26  F= 0.457722424E-12  G= 0.268E-06  ITERM=  4
NIT=   30  NFV=   31  NFG=   31  F= 0.196012198E-10  G= 0.929E-06  ITERM=  4
NIT=   39  NFV=   44  NFG=   44  F=  335.137433      G= 0.144E-05  ITERM=  2
NIT=   28  NFV=   31  NFG=   31  F=  761774.954      G= 0.164E-03  ITERM=  2
NIT=   13  NFV=   16  NFG=   16  F=  316.436141      G= 0.291E-06  ITERM=  4
NIT= 2007  NFV= 2029  NFG= 2029  F= -124.750000      G= 0.675E-05  ITERM=  2
NIT=  103  NFV=  124  NFG=  124  F=  10.7765879      G= 0.580E-06  ITERM=  4
NIT=  242  NFV=  265  NFG=  265  F=  982.273617      G= 0.170E-04  ITERM=  2
NIT=    7  NFV=    8  NFG=    8  F= 0.279448694E-15  G= 0.311E-07  ITERM=  4
NIT=    7  NFV=    9  NFG=    9  F= 0.128843969E-08  G= 0.991E-06  ITERM=  4
NIT=  996  NFV= 1005  NFG= 1005  F=  1.92401599      G= 0.731E-06  ITERM=  4
NIT=  199  NFV=  206  NFG=  206  F= -427.404476      G= 0.511E-05  ITERM=  2
NIT=  503  NFV=  505  NFG=  505  F=-0.379921091E-01  G= 0.929E-06  ITERM=  4
NIT=  501  NFV=  504  NFG=  504  F=-0.245741193E-01  G= 0.117E-13  ITERM=  4
NIT=  501  NFV=  504  NFG=  504  F=  59.5986241      G= 0.661E-10  ITERM=  4
NIT= 2178  NFV= 2182  NFG= 2182  F= -1.00013520      G= 0.863E-06  ITERM=  4
NIT= 2231  NFV= 2234  NFG= 2234  F=  2.13866377      G= 0.905E-06  ITERM=  4
NIT= 1369  NFV= 1399  NFG= 1399  F=  1.00000000      G= 0.938E-06  ITERM=  4
NITER =16507    NFVAL =17246    NGVAL =17246    NSUCC =   22
TIME= 0:00:03.28

The rows corresponding to individual test problems contain the number of
iterations NIT, the number of function evaluations NFV, the number of
gradient evaluations NFG, the final value of the objective function F,
the norm of gradient G and the cause of termination ITERM.
      Subroutine PLIVS can be verified and tested using the program
TLIVS. This program calls the subroutines TIUD14 (initiation), TFFU14
(function evaluation), TFGU14 (gradient evaluation) containing 22 box
constrained test problems with at most 1000 variables [2]. The results
obtained by the program TLIVS on a PC computer with Microsoft Power
Station Fortran compiler have the following form.

NIT= 5112  NFV= 5627  NFG= 5627  F=  0.00000000      G= 0.000E+00  ITERM=  3
NIT= 2207  NFV= 2853  NFG= 2853  F=  3926.45961      G= 0.183E-04  ITERM=  2
NIT=  113  NFV=  125  NFG=  125  F= 0.312399241E-12  G= 0.299E-06  ITERM=  4
NIT=   59  NFV=   72  NFG=   72  F=  269.522686      G= 0.742E-06  ITERM=  4
NIT=   23  NFV=   26  NFG=   26  F= 0.457722424E-12  G= 0.268E-06  ITERM=  4
NIT=   30  NFV=   31  NFG=   31  F= 0.196012198E-10  G= 0.929E-06  ITERM=  4
NIT=   40  NFV=   45  NFG=   45  F=  336.134919      G= 0.380E-06  ITERM=  4
NIT=   54  NFV=   56  NFG=   56  F=  761925.725      G= 0.227E-03  ITERM=  2
NIT=  505  NFV=  507  NFG=  507  F=  428.056916      G= 0.272E-06  ITERM=  4
NIT= 1014  NFV= 1039  NFG= 1039  F= -81.0572252      G= 0.672E-05  ITERM=  2
NIT=   13  NFV=   23  NFG=   23  F=  96517.2947      G= 0.971E-06  ITERM=  4
NIT=   66  NFV=   81  NFG=   81  F=  4994.21410      G= 0.712E-06  ITERM=  4
NIT=    7  NFV=    8  NFG=    8  F= 0.279448694E-15  G= 0.311E-07  ITERM=  4
NIT=    7  NFV=    9  NFG=    9  F= 0.128843969E-08  G= 0.991E-06  ITERM=  4
NIT=  996  NFV= 1005  NFG= 1005  F=  1.92401599      G= 0.731E-06  ITERM=  4
NIT=  180  NFV=  181  NFG=  181  F= -427.391653      G= 0.108E-04  ITERM=  2
NIT=  503  NFV=  505  NFG=  505  F=-0.379921091E-01  G= 0.929E-06  ITERM=  4
NIT=  501  NFV=  504  NFG=  504  F=-0.245741193E-01  G= 0.117E-13  ITERM=  4
NIT=  915  NFV=  920  NFG=  920  F=  1654.94525      G= 0.224E-04  ITERM=  2
NIT= 2022  NFV= 2025  NFG= 2025  F= -1.00013520      G= 0.973E-06  ITERM=  4
NIT= 1385  NFV= 1386  NFG= 1386  F=  2.41354873      G= 0.991E-06  ITERM=  4
NIT= 1488  NFV= 1530  NFG= 1530  F=  1.00000000      G= 0.986E-06  ITERM=  4
NITER =17240    NFVAL =18558    NGVAL =18558    NSUCC =   22
TIME= 0:00:03.55

References:
-----------

[1] Vlcek J., Luksan L.: A modified limited-memory BNS method for 
    unconstrained minimization based on the conjugate directions idea. 
    Techical Report V-1203, Prague, ICS AS CR, 2014.

[2] Luksan L., Vlcek J.: Sparse and partially separable test problems
    for unconstrained and equality constrained optimization. Research
    Report V-767, Institute of Computer Science, Academy of Sciences
    of the Czech Republic, Prague, Czech Republic, 1998.