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

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