source: branches/dev/Algorithm/IpAlgBuilder.cpp @ 501

Last change on this file since 501 was 501, checked in by claird, 14 years ago

Cleaned up all the Copyright comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.0 KB
Line 
1// Copyright (C) 2004, 2005 International Business Machines and others.
2// All Rights Reserved.
3// This code is published under the Common Public License.
4//
5// $Id: IpAlgBuilder.cpp 501 2005-08-26 15:43:07Z claird $
6//
7// Authors:  Carl Laird, Andreas Waechter     IBM    2004-09-29
8
9#include "IpAlgBuilder.hpp"
10
11#include "IpStdAugSystemSolver.hpp"
12#include "IpAugRestoSystemSolver.hpp"
13#include "IpPDFullSpaceSolver.hpp"
14#include "IpPDPerturbationHandler.hpp"
15#include "IpOptErrorConvCheck.hpp"
16#include "IpFilterLineSearch.hpp"
17#include "IpMonotoneMuUpdate.hpp"
18#include "IpAdaptiveMuUpdate.hpp"
19#include "IpLoqoMuOracle.hpp"
20#include "IpProbingMuOracle.hpp"
21#include "IpQualityFunctionMuOracle.hpp"
22#include "IpRestoMinC_1Nrm.hpp"
23#include "IpLeastSquareMults.hpp"
24#include "IpDefaultIterateInitializer.hpp"
25#include "IpWarmStartIterateInitializer.hpp"
26#include "IpOrigIterationOutput.hpp"
27#include "IpRestoIterationOutput.hpp"
28#include "IpRestoFilterConvCheck.hpp"
29#include "IpRestoIterateInitializer.hpp"
30#include "IpRestoRestoPhase.hpp"
31#include "IpTSymLinearSolver.hpp"
32
33#ifdef HAVE_MA27
34# include "IpMa27TSolverInterface.hpp"
35#endif
36#ifdef HAVE_MC19
37# include "IpMc19TSymScalingMethod.hpp"
38#endif
39#ifdef HAVE_PARDISO
40# include "IpPardisoSolverInterface.hpp"
41#endif
42#ifdef HAVE_TAUCS
43# include "IpTAUCSSolverInterface.hpp"
44#endif
45
46namespace Ipopt
47{
48#ifdef IP_DEBUG
49  static const Index dbg_verbosity = 0;
50#endif
51
52  void AlgorithmBuilder::RegisterOptions(SmartPtr<RegisteredOptions> roptions)
53  {
54    roptions->SetRegisteringCategory("Undocumented");
55    roptions->AddStringOption3(
56      "linear_solver",
57      "Linear solver used for step computations.",
58      "ma27",
59      "ma27", "use the Harwell routine MA27",
60      "pardiso", "use the Pardiso package",
61      "taucs", "use TAUCS package",
62      "Determines which linear algebra package is to be used for the "
63      "solution of the augmented linear system (for obtaining the search "
64      "directions). "
65      "Note that depending on your Ipopt installation, not all "
66      "options may be available.");
67    roptions->SetRegisteringCategory("Linear Solver");
68    roptions->AddStringOption2(
69      "linear_system_scaling",
70      "Method for scaling the linear system.",
71      "none",
72      "none", "no scaling will be performed",
73      "mc19", "use the Harwell routine mc19",
74      "Determines the method used to compute symmetric scaling "
75      "factors for the augmented system. This scaling will be done "
76      "in addition to any NLP problem scaling.");
77
78    roptions->SetRegisteringCategory("Mu Update");
79    roptions->AddStringOption2(
80      "mu_strategy",
81      "Update strategy for barrier parameter.",
82      "monotone",
83      "monotone", "use the monotone (Fiacco-McCormick) strategy",
84      "adaptive", "use the adaptive update strategy",
85      "Determines which barrier parameter update strategy is to be used.");
86    roptions->AddStringOption3(
87      "mu_oracle",
88      "Oracle for a new barrier parameter in the adaptive strategy.",
89      "probing",
90      "probing", "Mehrotra's probing heuristic",
91      "loqo", "LOQO's centrality rule",
92      "quality_function", "minimize a quality function",
93      "Determines how a new barrier parameter is computed in each "
94      "\"free-mode\" iteration of the adaptive barrier parameter "
95      "strategy. (Only considered if \"adaptive\" is selected for "
96      "option \"mu_strategy\").");
97    roptions->AddStringOption4(
98      "fixed_mu_oracle",
99      "Oracle for the barrier parameter when switching to fixed mode.",
100      "average_compl",
101      "probing", "Mehrotra's probing heuristic",
102      "loqo", "LOQO's centrality rule",
103      "quality_function", "minimize a quality function",
104      "average_compl", "base on current average complementarity",
105      "Determines how the first value of the barrier parameter should be "
106      "computed when switching to the \"monotone mode\" in the adaptive "
107      "strategy. (Only considered if \"adaptive\" is selected for option "
108      "\"mu_strategy\".)");
109    roptions->SetRegisteringCategory("Initialization");
110    roptions->AddStringOption2(
111      "warm_start_init_point",
112      "Warm-start for initial point", "no",
113      "no", "do not use the warm start initialization",
114      "yes", "use the warm start initialization",
115      "Indicates whether this optimization should use a warm start "
116      "initialization, where values of primal and dual variables are "
117      "given (e.g., from a previous optimization of a related problem.)");
118  }
119
120  SmartPtr<IpoptAlgorithm>
121  AlgorithmBuilder::BuildBasicAlgorithm(const Journalist& jnlst,
122                                        const OptionsList& options,
123                                        const std::string& prefix)
124  {
125    DBG_START_FUN("AlgorithmBuilder::BuildBasicAlgorithm",
126                  dbg_verbosity);
127    // Create the convergence check
128    SmartPtr<ConvergenceCheck> convCheck =
129      new OptimalityErrorConvergenceCheck();
130
131    // Create the solvers that will be used by the main algorithm
132    SmartPtr<TSymScalingMethod> ScalingMethod;
133    std::string linear_system_scaling;
134    options.GetStringValue("linear_system_scaling",
135                           linear_system_scaling, prefix);
136    if (linear_system_scaling=="mc19") {
137#ifdef HAVE_MC19
138      ScalingMethod = new Mc19TSymScalingMethod();
139#else
140
141      THROW_EXCEPTION(OPTION_INVALID,
142                      "Selected linear system scaling method MC19 not available.");
143#endif
144
145    }
146
147    SmartPtr<SparseSymLinearSolverInterface> SolverInterface;
148    std::string linear_solver;
149    options.GetStringValue("linear_solver", linear_solver, prefix);
150    if (linear_solver=="ma27") {
151#ifdef HAVE_MA27
152      SolverInterface = new Ma27TSolverInterface();
153#else
154
155      THROW_EXCEPTION(OPTION_INVALID,
156                      "Selected linear solver MA27 not available.");
157#endif
158
159    }
160    else if (linear_solver=="pardiso") {
161#ifdef HAVE_PARDISO
162      SolverInterface = new PardisoSolverInterface();
163#else
164
165      THROW_EXCEPTION(OPTION_INVALID,
166                      "Selected linear solver Pardiso not available.");
167#endif
168
169    }
170    else if (linear_solver=="taucs") {
171#ifdef HAVE_TAUCS
172      SolverInterface = new TAUCSSolverInterface();
173#else
174
175      THROW_EXCEPTION(OPTION_INVALID,
176                      "Selected linear solver TAUCS not available.");
177#endif
178
179    }
180
181    SmartPtr<SymLinearSolver> ScaledSolver =
182      new TSymLinearSolver(SolverInterface, ScalingMethod);
183
184    SmartPtr<AugSystemSolver> AugSolver =
185      //        = new AugTSystemSolver(*Ma27Solver);
186      new StdAugSystemSolver(*ScaledSolver);
187    SmartPtr<PDPerturbationHandler> pertHandler =
188      new PDPerturbationHandler();
189    SmartPtr<PDSystemSolver> PDSolver =
190      new PDFullSpaceSolver(*AugSolver, *pertHandler);
191
192    // Create the object for initializing the iterates
193    // Initialization object
194    SmartPtr<EqMultiplierCalculator> EqMultCalculator =
195      new LeastSquareMultipliers(*AugSolver);
196    SmartPtr<IterateInitializer> IterInitializer;
197    bool warm_start_init_point;
198    std::string warm_start_option;
199    options.GetStringValue("warm_start_init_point", warm_start_option, prefix);
200    warm_start_init_point = (warm_start_option == "yes");
201
202    if (warm_start_init_point) {
203      IterInitializer = new WarmStartIterateInitializer();
204    }
205    else {
206      IterInitializer = new DefaultIterateInitializer(EqMultCalculator);
207    }
208
209    // Solver for the restoration phase
210    SmartPtr<AugSystemSolver> resto_AugSolver =
211      new AugRestoSystemSolver(*AugSolver);
212    SmartPtr<PDPerturbationHandler> resto_pertHandler =
213      new PDPerturbationHandler();
214    SmartPtr<PDSystemSolver> resto_PDSolver =
215      new PDFullSpaceSolver(*resto_AugSolver, *resto_pertHandler);
216
217    // Convergence check in the restoration phase
218    SmartPtr<RestoFilterConvergenceCheck> resto_convCheck =
219      new RestoFilterConvergenceCheck();
220
221    // Line search method for the restoration phase
222    SmartPtr<RestoRestorationPhase> resto_resto =
223      new RestoRestorationPhase();
224    SmartPtr<FilterLineSearch> resto_LineSearch =
225      new FilterLineSearch(GetRawPtr(resto_resto), GetRawPtr(resto_PDSolver),
226                           GetRawPtr(resto_convCheck));
227
228    // Create the mu update that will be used by the restoration phase
229    // algorithm
230    SmartPtr<MuUpdate> resto_MuUpdate;
231    std::string resto_smuupdate;
232    options.GetStringValue("mu_strategy", resto_smuupdate, "resto."+prefix);
233
234    std::string resto_smuoracle;
235    std::string resto_sfixmuoracle;
236    if (resto_smuupdate=="adaptive" ) {
237      options.GetStringValue("mu_oracle", resto_smuoracle, "resto."+prefix);
238      options.GetStringValue("fixed_mu_oracle", resto_sfixmuoracle, "resto."+prefix);
239    }
240
241    if (resto_smuupdate=="monotone" ) {
242      resto_MuUpdate = new MonotoneMuUpdate(GetRawPtr(resto_LineSearch));
243    }
244    else if (resto_smuupdate=="adaptive") {
245      SmartPtr<MuOracle> resto_MuOracle;
246      if (resto_smuoracle=="loqo") {
247        resto_MuOracle = new LoqoMuOracle();
248      }
249      else if (resto_smuoracle=="probing") {
250        resto_MuOracle = new ProbingMuOracle(resto_PDSolver);
251      }
252      else if (resto_smuoracle=="quality_function") {
253        resto_MuOracle = new QualityFunctionMuOracle(resto_PDSolver);
254      }
255      SmartPtr<MuOracle> resto_FixMuOracle;
256      if (resto_sfixmuoracle=="loqo") {
257        resto_FixMuOracle = new LoqoMuOracle();
258      }
259      else if (resto_sfixmuoracle=="probing") {
260        resto_FixMuOracle = new ProbingMuOracle(resto_PDSolver);
261      }
262      else if (resto_sfixmuoracle=="quality_function") {
263        resto_FixMuOracle = new QualityFunctionMuOracle(resto_PDSolver);
264      }
265      else {
266        resto_FixMuOracle = NULL;
267      }
268      resto_MuUpdate =
269        new AdaptiveMuUpdate(GetRawPtr(resto_LineSearch),
270                             resto_MuOracle, resto_FixMuOracle);
271    }
272
273    // Initialization of the iterates for the restoration phase
274    SmartPtr<EqMultiplierCalculator> resto_EqMultCalculator =
275      new LeastSquareMultipliers(*resto_AugSolver);
276    SmartPtr<IterateInitializer> resto_IterInitializer =
277      new RestoIterateInitializer(resto_EqMultCalculator);
278
279    // Create the object for the iteration output during restoration
280    SmartPtr<OrigIterationOutput> resto_OrigIterOutput = NULL;
281    //   new OrigIterationOutput();
282    SmartPtr<IterationOutput> resto_IterOutput =
283      new RestoIterationOutput(resto_OrigIterOutput);
284
285    // Put together the overall restoration phase IP algorithm
286    SmartPtr<IpoptAlgorithm> resto_alg =
287      new IpoptAlgorithm(resto_PDSolver,
288                         GetRawPtr(resto_LineSearch),
289                         GetRawPtr(resto_MuUpdate),
290                         GetRawPtr(resto_convCheck),
291                         resto_IterInitializer,
292                         resto_IterOutput);
293
294    // Set the restoration phase
295    SmartPtr<RestorationPhase> resto_phase =
296      new MinC_1NrmRestorationPhase(*resto_alg, EqMultCalculator);
297
298    // Create the line search to be used by the main algorithm
299    SmartPtr<FilterLineSearch> lineSearch =
300      new FilterLineSearch(GetRawPtr(resto_phase), GetRawPtr(PDSolver),
301                           convCheck);
302
303    // The following cross reference is not good: We have to store a
304    // pointer to the lineSearch object in resto_convCheck as a
305    // non-SmartPtr to make sure that things are properly deleted when
306    // the IpoptAlgorithm return by the Builder is destructed.
307    resto_convCheck->SetOrigFilterLineSearch(*lineSearch);
308
309    // Create the mu update that will be used by the main algorithm
310    SmartPtr<MuUpdate> MuUpdate;
311    std::string smuupdate;
312    options.GetStringValue("mu_strategy", smuupdate, prefix);
313    std::string smuoracle;
314    std::string sfixmuoracle;
315    if (smuupdate=="adaptive" ) {
316      options.GetStringValue("mu_oracle", smuoracle, prefix);
317      options.GetStringValue("fixed_mu_oracle", sfixmuoracle, prefix);
318    }
319
320    if (smuupdate=="monotone" ) {
321      MuUpdate = new MonotoneMuUpdate(GetRawPtr(lineSearch));
322    }
323    else if (smuupdate=="adaptive") {
324      SmartPtr<MuOracle> muOracle;
325      if (smuoracle=="loqo") {
326        muOracle = new LoqoMuOracle();
327      }
328      else if (smuoracle=="probing") {
329        muOracle = new ProbingMuOracle(PDSolver);
330      }
331      else if (smuoracle=="quality_function") {
332        muOracle = new QualityFunctionMuOracle(PDSolver);
333      }
334      SmartPtr<MuOracle> FixMuOracle;
335      if (sfixmuoracle=="loqo") {
336        FixMuOracle = new LoqoMuOracle();
337      }
338      else if (sfixmuoracle=="probing") {
339        FixMuOracle = new ProbingMuOracle(PDSolver);
340      }
341      else if (sfixmuoracle=="quality_function") {
342        FixMuOracle = new QualityFunctionMuOracle(PDSolver);
343      }
344      else {
345        FixMuOracle = NULL;
346      }
347      MuUpdate = new AdaptiveMuUpdate(GetRawPtr(lineSearch),
348                                      muOracle, FixMuOracle);
349    }
350
351    // Create the object for the iteration output
352    SmartPtr<IterationOutput> IterOutput =
353      new OrigIterationOutput();
354
355    // Create the main algorithm
356    SmartPtr<IpoptAlgorithm> alg =
357      new IpoptAlgorithm(PDSolver,
358                         GetRawPtr(lineSearch), MuUpdate,
359                         convCheck, IterInitializer, IterOutput);
360
361    return alg;
362  }
363
364} // namespace
Note: See TracBrowser for help on using the repository browser.