source: branches/dev/Algorithm/IpRestoFilterConvCheck.cpp @ 490

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

Modified the text in all the options and added
a method to RegisteredOptions? to print options
in latex format for documentation.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.3 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: IpRestoFilterConvCheck.cpp 490 2005-08-24 22:20:52Z claird $
6//
7// Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
8
9#include "IpRestoFilterConvCheck.hpp"
10#include "IpCompoundVector.hpp"
11#include "IpRestoIpoptNLP.hpp"
12
13namespace Ipopt
14{
15#ifdef IP_DEBUG
16  static const Index dbg_verbosity = 0;
17#endif
18
19  RestoFilterConvergenceCheck::RestoFilterConvergenceCheck()
20      :
21      orig_filter_line_search_(NULL)
22  {
23    DBG_START_FUN("RestoFilterConvergenceCheck::RestoFilterConvergenceCheck()",
24                  dbg_verbosity);
25
26  }
27
28  RestoFilterConvergenceCheck::~RestoFilterConvergenceCheck()
29  {
30    DBG_START_FUN("RestoFilterConvergenceCheck::RestoFilterConvergenceCheck()",
31                  dbg_verbosity);
32  }
33
34  void
35  RestoFilterConvergenceCheck::SetOrigFilterLineSearch
36  (const FilterLineSearch& orig_filter_line_search)
37  {
38    orig_filter_line_search_ = &orig_filter_line_search;
39  }
40
41  void RestoFilterConvergenceCheck::RegisterOptions(SmartPtr<RegisteredOptions> roptions)
42  {
43    roptions->AddBoundedNumberOption(
44      "required_infeasibility_reduction",
45      "Required reduction of infeasibility before leaving restoration phase.",
46      0.0, false, 1.0, true,
47      0.9,
48      "The restoration phase algorithm is performed, until a point is found "
49      "that is acceptable to the filter and the infeasibility has been "
50      "reduced by at least the fraction given by this option.");
51  }
52
53  bool RestoFilterConvergenceCheck::InitializeImpl(const OptionsList& options,
54      const std::string& prefix)
55  {
56    DBG_ASSERT(orig_filter_line_search_ && "Need to call RestoFilterConvergenceCheck::SetOrigFilterLineSearch before Initialize");
57    options.GetNumericValue("required_infeasibility_reduction", kappa_resto_, prefix);
58    options.GetIntegerValue("max_iter", maximum_iters_, prefix);
59
60    first_resto_iter_ = true;
61
62    return OptimalityErrorConvergenceCheck::InitializeImpl(options, prefix);
63  }
64
65  ConvergenceCheck::ConvergenceStatus
66  RestoFilterConvergenceCheck::CheckConvergence()
67  {
68    if (IpData().iter_count() >= maximum_iters_) {
69      return ConvergenceCheck::MAXITER_EXCEEDED;
70    }
71
72    // First check if the point is now acceptable for the outer filter
73    ConvergenceStatus status;
74
75    // Get pointers to the Original NLP objects
76    const RestoIpoptNLP* resto_ipopt_nlp =
77      dynamic_cast<const RestoIpoptNLP*>(&IpNLP());
78    DBG_ASSERT(resto_ipopt_nlp);
79
80    SmartPtr<IpoptData> orig_ip_data = &resto_ipopt_nlp->OrigIpData();
81    SmartPtr<IpoptCalculatedQuantities> orig_ip_cq =
82      &resto_ipopt_nlp->OrigIpCq();
83
84    // set the trial point for the original problem
85    SmartPtr<const Vector> x = IpData().curr()->x();
86    const CompoundVector* cx =
87      dynamic_cast<const CompoundVector*>(GetRawPtr(x));
88    DBG_ASSERT(cx);
89
90    SmartPtr<IteratesVector> trial = orig_ip_data->curr()->MakeNewContainer();
91    trial->Set_x(*cx->GetComp(0));
92    trial->Set_s(*IpData().curr()->s());
93    orig_ip_data->set_trial(trial);
94
95    // Calculate the f and theta for the original problem
96    Number orig_trial_theta = orig_ip_cq->trial_constraint_violation();
97    Number orig_curr_theta = orig_ip_cq->curr_constraint_violation();
98
99    // check acceptability to the filter
100    Jnlst().Printf(J_DETAILED, J_MAIN,
101                   "orig_curr_theta = %8.2e, orig_trial_theta = %8.2e\n",
102                   orig_curr_theta, orig_trial_theta);
103
104    // ToDo: In the following we might want to be more careful with the lower bound
105    Number orig_theta_max = Max(kappa_resto_*orig_curr_theta,
106                                1.e1*Min(orig_ip_data->tol(),
107                                         constr_viol_tol_));
108
109    if (first_resto_iter_) {
110      Jnlst().Printf(J_DETAILED, J_MAIN,
111                     "This is the first iteration - continue to take at least one step.\n");
112      status = CONTINUE;
113    }
114    else if (orig_trial_theta > orig_theta_max) {
115      Jnlst().Printf(J_DETAILED, J_MAIN,
116                     "Point does not provide sufficient reduction w.r.t the original theta.\n");
117      status = CONTINUE;
118    }
119    else if (orig_ip_cq->IsSquareProblem() &&
120             orig_trial_theta <= orig_ip_data->tol()) {
121      Jnlst().Printf(J_DETAILED, J_MAIN,
122                     "Restoration phase found points satisfying feasibility tolerance in square problem.\n");
123      status = CONVERGED;
124    }
125    else {
126      Number orig_trial_barr = orig_ip_cq->trial_barrier_obj();
127
128      Jnlst().Printf(J_DETAILED, J_MAIN,
129                     "orig_trial_barr = %8.2e\n", orig_trial_barr);
130
131      if (!orig_filter_line_search_->IsAcceptableToCurrentFilter(orig_trial_barr, orig_trial_theta)) {
132        Jnlst().Printf(J_DETAILED, J_MAIN,
133                       "Point is not acceptable to the original filter.\n");
134        status = CONTINUE;
135      }
136      else if (!orig_filter_line_search_->IsAcceptableToCurrentIterate(orig_trial_barr, orig_trial_theta, true) ) {
137        Jnlst().Printf(J_DETAILED, J_MAIN,
138                       "Point is not acceptable to the original current point.\n");
139        status = CONTINUE;
140      }
141      else {
142        Jnlst().Printf(J_DETAILED, J_MAIN,
143                       "Restoration found a point that provides sufficient reduction in"
144                       " theta and is acceptable to the current filter.\n");
145        status = CONVERGED;
146      }
147    }
148
149    // If the point is not yet acceptable to the filter, check if the problem
150    // is maybe locally infeasible
151
152    if (status==CONTINUE) {
153
154      status = OptimalityErrorConvergenceCheck::CheckConvergence();
155      if (status == CONVERGED || status == CONVERGED_TO_ACCEPTABLE_POINT) {
156        Number orig_trial_primal_inf =
157          orig_ip_cq->trial_primal_infeasibility(NORM_MAX);
158        // ToDo make the factor in following line an option
159        if (orig_trial_primal_inf <= 1e2*orig_ip_data->tol()) {
160          THROW_EXCEPTION(RESTORATION_CONVERGED_TO_FEASIBLE_POINT,
161                          "Restoration phase converged to a feasible point that was "
162                          "unacceptable to the filter for the original problem.");
163        }
164        else {
165          THROW_EXCEPTION(LOCALLY_INFEASIBLE,
166                          "Restoration phase converged to a point of local infeasibility");
167        }
168      }
169    }
170
171    first_resto_iter_ = false;
172
173    return status;
174  }
175
176} // namespace Ipopt
Note: See TracBrowser for help on using the repository browser.