1 | // Copyright (C) 2005 International Business Machines and others. |
---|
2 | // All Rights Reserved. |
---|
3 | // This code is published under the Common Public License. |
---|
4 | // |
---|
5 | // $Id: IpFilterLSAcceptor.hpp 542 2005-10-13 22:43:08Z andreasw $ |
---|
6 | // |
---|
7 | // Authors: Andreas Waechter IBM 2005-10-13 |
---|
8 | // derived file from IpFilterLineSearch.hpp |
---|
9 | |
---|
10 | #ifndef __IPFILTERLSACCEPTOR_HPP__ |
---|
11 | #define __IPFILTERLSACCEPTOR_HPP__ |
---|
12 | |
---|
13 | #include "IpFilter.hpp" |
---|
14 | #include "IpBacktrackingLSAcceptor.hpp" |
---|
15 | #include "IpPDSystemSolver.hpp" |
---|
16 | |
---|
17 | namespace Ipopt |
---|
18 | { |
---|
19 | |
---|
20 | /** Filter line search. This class implements the filter line |
---|
21 | * search procedure. |
---|
22 | */ |
---|
23 | class FilterLSAcceptor : public BacktrackingLSAcceptor |
---|
24 | { |
---|
25 | public: |
---|
26 | /**@name Constructors/Destructors */ |
---|
27 | //@{ |
---|
28 | /** Constructor. The PDSystemSolver object only needs to be |
---|
29 | * provided (i.e. not NULL) if second order correction or |
---|
30 | * corrector steps are to be used. */ |
---|
31 | FilterLSAcceptor(const SmartPtr<PDSystemSolver>& pd_solver); |
---|
32 | |
---|
33 | /** Default destructor */ |
---|
34 | virtual ~FilterLSAcceptor(); |
---|
35 | //@} |
---|
36 | |
---|
37 | /** InitializeImpl - overloaded from AlgorithmStrategyObject */ |
---|
38 | virtual bool InitializeImpl(const OptionsList& options, |
---|
39 | const std::string& prefix); |
---|
40 | |
---|
41 | /** Reset the acceptor. |
---|
42 | * This function should be called if all previous information |
---|
43 | * should be discarded when the line search is performed the |
---|
44 | * next time. For example, this method should be called if |
---|
45 | * the barrier parameter is changed. |
---|
46 | */ |
---|
47 | virtual void Reset(); |
---|
48 | |
---|
49 | /** Initialization for the next line search. The flag in_watchdog |
---|
50 | * indicates if we are currently in an active watchdog |
---|
51 | * procedure. */ |
---|
52 | virtual void InitThisLineSearch(bool in_watchdog); |
---|
53 | |
---|
54 | /** Method that is called before the restoration phase is called. |
---|
55 | * Here, we can set up things that are required in the |
---|
56 | * termination test for the restoration phase, such as augmenting |
---|
57 | * a filter. */ |
---|
58 | virtual void PrepareRestoPhaseStart(); |
---|
59 | |
---|
60 | /** Method returning the lower bound on the trial step sizes. If |
---|
61 | * the backtracking procedure encounters a trial step size below |
---|
62 | * this value after the first trial set, it swtiches to the |
---|
63 | * (soft) restoration phase. */ |
---|
64 | virtual Number CalculateAlphaMin(); |
---|
65 | |
---|
66 | /** Method for checking if current trial point is acceptable. |
---|
67 | * It is assumed that the delta information in ip_data is the |
---|
68 | * search direction used in criteria. The primal trial point has |
---|
69 | * to be set before the call. |
---|
70 | */ |
---|
71 | virtual bool CheckAcceptabilityOfTrialPoint(Number alpha_primal); |
---|
72 | |
---|
73 | /** Try a second order correction for the constraints. If the |
---|
74 | * first trial step (with incoming alpha_primal) has been reject, |
---|
75 | * this tries up to max_soc_ second order corrections for the |
---|
76 | * constraints. Here, alpha_primal_test is the step size that |
---|
77 | * has to be used in the filter acceptance tests. On output |
---|
78 | * actual_delta_ has been set to the step including the |
---|
79 | * second order correction if it has been accepted, otherwise it |
---|
80 | * is unchanged. If the SOC step has been accepted, alpha_primal |
---|
81 | * has the fraction-to-the-boundary value for the SOC step on output. |
---|
82 | * The return value is true, if a SOC step has been accepted. |
---|
83 | */ |
---|
84 | virtual bool TrySecondOrderCorrection(Number alpha_primal_test, |
---|
85 | Number& alpha_primal, |
---|
86 | SmartPtr<IteratesVector>& actual_delta); |
---|
87 | |
---|
88 | /** Try higher order corrector (for fast local convergence). In |
---|
89 | * contrast to a second order correction step, which tries to |
---|
90 | * make an unacceptable point acceptable by improving constraint |
---|
91 | * violation, this corrector step is tried even if the regular |
---|
92 | * primal-dual step is acceptable. |
---|
93 | */ |
---|
94 | virtual bool TryCorrector(Number alpha_primal_test, |
---|
95 | Number& alpha_primal, |
---|
96 | SmartPtr<IteratesVector>& actual_delta); |
---|
97 | |
---|
98 | /** Method for ending the current line search. When it is called, |
---|
99 | * the internal data should be updates, e.g., the filter might be |
---|
100 | * augmented. alpha_primal_test is the value of alpha that has |
---|
101 | * been used for in the acceptence test ealier. */ |
---|
102 | virtual char UpdateForNextIteration(Number alpha_primal_test); |
---|
103 | |
---|
104 | /** Method for setting internal data if the watchdog procedure is |
---|
105 | * started. */ |
---|
106 | virtual void StartWatchDog(); |
---|
107 | |
---|
108 | /** Method for setting internal data if the watchdog procedure is |
---|
109 | * stopped. */ |
---|
110 | virtual void StopWatchDog(); |
---|
111 | |
---|
112 | /**@name Trial Point Accepting Methods. Used internally to check certain |
---|
113 | * acceptability criteria and used externally (by the restoration phase |
---|
114 | * convergence check object, for instance) |
---|
115 | */ |
---|
116 | //@{ |
---|
117 | /** Checks if a trial point is acceptable to the current iterate */ |
---|
118 | bool IsAcceptableToCurrentIterate(Number trial_barr, Number trial_theta, |
---|
119 | bool called_from_restoration=false) const; |
---|
120 | |
---|
121 | /** Checks if a trial point is acceptable to the current filter */ |
---|
122 | bool IsAcceptableToCurrentFilter(Number trial_barr, Number trial_theta) const; |
---|
123 | //@} |
---|
124 | |
---|
125 | /** Methods for OptionsList */ |
---|
126 | //@{ |
---|
127 | static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); |
---|
128 | //@} |
---|
129 | |
---|
130 | private: |
---|
131 | /**@name Default Compiler Generated Methods |
---|
132 | * (Hidden to avoid implicit creation/calling). |
---|
133 | * These methods are not implemented and |
---|
134 | * we do not want the compiler to implement |
---|
135 | * them for us, so we declare them private |
---|
136 | * and do not define them. This ensures that |
---|
137 | * they will not be implicitly created/called. */ |
---|
138 | //@{ |
---|
139 | /** Copy Constructor */ |
---|
140 | FilterLSAcceptor(const FilterLSAcceptor&); |
---|
141 | |
---|
142 | /** Overloaded Equals Operator */ |
---|
143 | void operator=(const FilterLSAcceptor&); |
---|
144 | //@} |
---|
145 | |
---|
146 | /** @name Filter information */ |
---|
147 | //@{ |
---|
148 | /** Upper bound on infeasibility */ |
---|
149 | Number theta_max_; |
---|
150 | Number theta_max_fact_; |
---|
151 | |
---|
152 | /** Infeasibility switching bound */ |
---|
153 | Number theta_min_; |
---|
154 | Number theta_min_fact_; |
---|
155 | //@} |
---|
156 | |
---|
157 | /** Method for checking if the current step size satisfies the |
---|
158 | * f-type switching condition. Here, we use the search direction |
---|
159 | * stored in ip_data |
---|
160 | */ |
---|
161 | bool IsFtype(Number alpha_primal_test); |
---|
162 | |
---|
163 | /** Method for checking the Armijo condition, given a trial step |
---|
164 | * size. The test uses the search direction stored in ip_data, |
---|
165 | * and the values of the functions at the trial point in ip_data. |
---|
166 | */ |
---|
167 | bool ArmijoHolds(Number alpha_primal_test); |
---|
168 | |
---|
169 | /** Augment the filter used on the current values of the barrier |
---|
170 | * objective function and the contraint violation */ |
---|
171 | void AugmentFilter(); |
---|
172 | |
---|
173 | /** Check comparison "lhs <= rhs", using machine precision based on BasVal */ |
---|
174 | //ToDo This should probably not be a static member function if we want to |
---|
175 | // allow for different relaxation parameters values |
---|
176 | static bool Compare_le(Number lhs, Number rhs, Number BasVal); |
---|
177 | |
---|
178 | /** @name Parameters for the filter algorithm. Names as in the paper */ |
---|
179 | //@{ |
---|
180 | /** \f$ \eta_{\varphi} \f$ */ |
---|
181 | Number eta_phi_; |
---|
182 | /** \f$ \delta \f$ */ |
---|
183 | Number delta_; |
---|
184 | /** \f$ s_{\varphi} \f$ */ |
---|
185 | Number s_phi_; |
---|
186 | /** \f$ s_{\Theta} \f$ */ |
---|
187 | Number s_theta_; |
---|
188 | /** \f$ \gamma_{\varphi} \f$ */ |
---|
189 | Number gamma_phi_; |
---|
190 | /** \f$ \gamma_{\Theta} \f$ */ |
---|
191 | Number gamma_theta_; |
---|
192 | /** \f$ \gamma_{\alpha} \f$ */ |
---|
193 | Number alpha_min_frac_; |
---|
194 | /** Maximal number of second order correction steps */ |
---|
195 | Index max_soc_; |
---|
196 | /** Required reduction in constraint violation before trying |
---|
197 | * multiple second order correction steps \f$ \kappa_{soc}\f$. |
---|
198 | */ |
---|
199 | Number kappa_soc_; |
---|
200 | /** Maximal increase in objective function in orders of magnitute |
---|
201 | * (log10). If the log10(barrier objective function) is |
---|
202 | * increased more than this compared to the current point, the |
---|
203 | * trial point is rejected. */ |
---|
204 | Number obj_max_inc_; |
---|
205 | |
---|
206 | /** enumeration for the corrector type */ |
---|
207 | enum CorrectorTypeEnum { |
---|
208 | NO_CORRECTOR=0, |
---|
209 | AFFINE_CORRECTOR, |
---|
210 | PRIMAL_DUAL_CORRECTOR |
---|
211 | }; |
---|
212 | /** Type of corrector steps that should be tried. */ |
---|
213 | CorrectorTypeEnum corrector_type_; |
---|
214 | /** parameter in heurstic that determines whether corrector step |
---|
215 | should be tried. */ |
---|
216 | Number corrector_compl_avrg_red_fact_; |
---|
217 | /** Flag indicating whether the corrector should be skipped in an |
---|
218 | * iteration in which negative curvature is detected */ |
---|
219 | bool skip_corr_if_neg_curv_; |
---|
220 | /** Flag indicating whether the corrector should be skipped during |
---|
221 | * the monotone mu mode. */ |
---|
222 | bool skip_corr_in_monotone_mode_; |
---|
223 | //@} |
---|
224 | |
---|
225 | /** @name Information related to watchdog procedure */ |
---|
226 | //@{ |
---|
227 | /** Constraint violation at the point with respect to which |
---|
228 | * progress is to be made */ |
---|
229 | Number reference_theta_; |
---|
230 | /** Barrier objective function at the point with respect to which |
---|
231 | * progress is to be made */ |
---|
232 | Number reference_barr_; |
---|
233 | /** Barrier gradient transpose search direction at the point with |
---|
234 | * respect to which progress is to be made */ |
---|
235 | Number reference_gradBarrTDelta_; |
---|
236 | /** Constraint violation at reference point */ |
---|
237 | Number watchdog_theta_; |
---|
238 | /** Barrier objective function at reference point */ |
---|
239 | Number watchdog_barr_; |
---|
240 | /** Barrier gradient transpose search direction at reference point */ |
---|
241 | Number watchdog_gradBarrTDelta_; |
---|
242 | //@} |
---|
243 | |
---|
244 | /** Filter with entries */ |
---|
245 | Filter filter_; |
---|
246 | |
---|
247 | /** @name Strategy objective that are used */ |
---|
248 | //@{ |
---|
249 | SmartPtr<PDSystemSolver> pd_solver_; |
---|
250 | //@} |
---|
251 | }; |
---|
252 | |
---|
253 | } // namespace Ipopt |
---|
254 | |
---|
255 | #endif |
---|