xref: /petsc/src/tao/unconstrained/impls/nls/nlsimpl.h (revision 5f309d014d30c8e30ef8d484fee079cd79b2cbfc)
1 /*
2 Context for a Newton line search method (unconstrained minimization)
3 */
4 
5 #if !defined(__TAO_NLS_H)
6 #define __TAO_NLS_H
7 #include <petsc/private/taoimpl.h>
8 
9 typedef struct {
10   Mat M;
11 
12   Vec D;
13   Vec W;
14 
15   Vec Xold;
16   Vec Gold;
17   Vec Diag;
18 
19   /* Parameters when updating the perturbation added to the Hessian matrix
20      according to the following scheme:
21 
22      pert = sval;
23 
24      do until convergence
25        shift Hessian by pert
26        solve Newton system
27 
28        if (linear solver failed or did not compute a descent direction)
29          use steepest descent direction and increase perturbation
30 
31          if (0 == pert)
32            initialize perturbation
33            pert = min(imax, max(imin, imfac * norm(G)))
34          else
35            increase perturbation
36            pert = min(pmax, max(pgfac * pert, pmgfac * norm(G)))
37          fi
38        else
39          use linear solver direction and decrease perturbation
40 
41          pert = min(psfac * pert, pmsfac * norm(G))
42          if (pert < pmin)
43            pert = 0
44          fi
45        fi
46 
47        perform line search
48        function and gradient evaluation
49        check convergence
50      od
51   */
52   PetscReal sval;               /*  Starting perturbation value, default zero */
53 
54   PetscReal imin;               /*  Minimum perturbation added during initialization  */
55   PetscReal imax;               /*  Maximum perturbation added during initialization */
56   PetscReal imfac;              /*  Merit function factor during initialization */
57 
58   PetscReal pmin;               /*  Minimim perturbation value */
59   PetscReal pmax;               /*  Maximum perturbation value */
60   PetscReal pgfac;              /*  Perturbation growth factor */
61   PetscReal psfac;              /*  Perturbation shrink factor */
62   PetscReal pmgfac;             /*  Merit function growth factor */
63   PetscReal pmsfac;             /*  Merit function shrink factor */
64 
65   /* Parameters when updating the trust-region radius based on steplength
66      if   step < nu1            (very bad step)
67        radius = omega1 * min(norm(d), radius)
68      elif step < nu2            (bad step)
69        radius = omega2 * min(norm(d), radius)
70      elif step < nu3            (okay step)
71        radius = omega3 * radius;
72      elif step < nu4            (good step)
73        radius = max(omega4 * norm(d), radius)
74      else                       (very good step)
75        radius = max(omega5 * norm(d), radius)
76      fi
77   */
78   PetscReal nu1;                /*  used to compute trust-region radius */
79   PetscReal nu2;                /*  used to compute trust-region radius */
80   PetscReal nu3;                /*  used to compute trust-region radius */
81   PetscReal nu4;                /*  used to compute trust-region radius */
82 
83   PetscReal omega1;             /*  factor used for trust-region update */
84   PetscReal omega2;             /*  factor used for trust-region update */
85   PetscReal omega3;             /*  factor used for trust-region update */
86   PetscReal omega4;             /*  factor used for trust-region update */
87   PetscReal omega5;             /*  factor used for trust-region update */
88 
89   /* Parameters when updating the trust-region radius based on reduction
90 
91      kappa = ared / pred
92      if   kappa < eta1          (very bad step)
93        radius = alpha1 * min(norm(d), radius)
94      elif kappa < eta2          (bad step)
95        radius = alpha2 * min(norm(d), radius)
96      elif kappa < eta3          (okay step)
97        radius = alpha3 * radius;
98      elif kappa < eta4          (good step)
99        radius = max(alpha4 * norm(d), radius)
100      else                       (very good step)
101        radius = max(alpha5 * norm(d), radius)
102      fi
103   */
104   PetscReal eta1;               /*  used to compute trust-region radius */
105   PetscReal eta2;               /*  used to compute trust-region radius */
106   PetscReal eta3;               /*  used to compute trust-region radius */
107   PetscReal eta4;               /*  used to compute trust-region radius */
108 
109   PetscReal alpha1;             /*  factor used for trust-region update */
110   PetscReal alpha2;             /*  factor used for trust-region update */
111   PetscReal alpha3;             /*  factor used for trust-region update */
112   PetscReal alpha4;             /*  factor used for trust-region update */
113   PetscReal alpha5;             /*  factor used for trust-region update */
114 
115   /* Parameters when updating the trust-region radius based on interpolation
116 
117      kappa = ared / pred
118      if   kappa >= 1.0 - mu1    (very good step)
119        choose tau in [gamma3, gamma4]
120        radius = max(tau * norm(d), radius)
121      elif kappa >= 1.0 - mu2    (good step)
122        choose tau in [gamma2, gamma3]
123        if (tau >= 1.0)
124          radius = max(tau * norm(d), radius)
125        else
126          radius = tau * min(norm(d), radius)
127        fi
128      else                       (bad step)
129        choose tau in [gamma1, 1.0]
130        radius = tau * min(norm(d), radius)
131      fi
132   */
133   PetscReal mu1;                /*  used for model agreement in interpolation */
134   PetscReal mu2;                /*  used for model agreement in interpolation */
135 
136   PetscReal gamma1;             /*  factor used for interpolation */
137   PetscReal gamma2;             /*  factor used for interpolation */
138   PetscReal gamma3;             /*  factor used for interpolation */
139   PetscReal gamma4;             /*  factor used for interpolation */
140 
141   PetscReal theta;              /*  factor used for interpolation */
142 
143   /*  Parameters when initializing trust-region radius based on interpolation */
144   PetscReal mu1_i;              /*  used for model agreement in interpolation */
145   PetscReal mu2_i;              /*  used for model agreement in interpolation */
146 
147   PetscReal gamma1_i;           /*  factor used for interpolation */
148   PetscReal gamma2_i;           /*  factor used for interpolation */
149   PetscReal gamma3_i;           /*  factor used for interpolation */
150   PetscReal gamma4_i;           /*  factor used for interpolation */
151 
152   PetscReal theta_i;            /*  factor used for interpolation */
153 
154   /*  Other parameters */
155   PetscReal min_radius;         /*  lower bound on initial radius value */
156   PetscReal max_radius;         /*  upper bound on trust region radius */
157   PetscReal epsilon;            /*  tolerance used when computing ared/pred */
158 
159   PetscInt newt;                /*  Newton directions attempted */
160   PetscInt bfgs;                /*  BFGS directions attempted */
161   PetscInt sgrad;               /*  Scaled gradient directions attempted */
162   PetscInt grad;                /*  Gradient directions attempted */
163 
164 
165   PetscInt pc_type;             /*  Preconditioner for the code */
166   PetscInt bfgs_scale_type;     /*  Scaling matrix to used for the bfgs preconditioner */
167   PetscInt init_type;           /*  Trust-region initialization method */
168   PetscInt update_type;         /*  Trust-region update method */
169 
170   PetscInt ksp_atol;
171   PetscInt ksp_rtol;
172   PetscInt ksp_ctol;
173   PetscInt ksp_negc;
174   PetscInt ksp_dtol;
175   PetscInt ksp_iter;
176   PetscInt ksp_othr;
177 } TAO_NLS;
178 
179 #endif /* if !defined(__TAO_NLS_H) */
180