source: branches/dev/Algorithm/IpOptErrorConvCheck.cpp @ 381

Last change on this file since 381 was 381, checked in by andreasw, 14 years ago

corrected a few things related to options

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1// Copyright (C) 2004, International Business Machines and others.
2// All Rights Reserved.
3// This code is published under the Common Public License.
4//
5// $Id: IpOptErrorConvCheck.cpp 381 2005-07-19 02:34:32Z andreasw $
6//
7// Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
8
9#include "IpOptErrorConvCheck.hpp"
10
11namespace Ipopt
12{
13  DBG_SET_VERBOSITY(0);
14
15  DefineIpoptType(OptimalityErrorConvergenceCheck);
16
17  OptimalityErrorConvergenceCheck::OptimalityErrorConvergenceCheck()
18  {}
19
20  OptimalityErrorConvergenceCheck::~OptimalityErrorConvergenceCheck()
21  {}
22
23  void OptimalityErrorConvergenceCheck::RegisterOptions(SmartPtr<RegisteredOptions> roptions)
24  {
25    roptions->AddLowerBoundedIntegerOption(
26      "max_iter",
27      "Maximum number of iterations.",
28      0, 3000,
29      "The algorithm terminates with an error message if the number of "
30      "iterations exceeded this number. [Also used in RestoFilterConvCheck]");
31  }
32
33  bool
34  OptimalityErrorConvergenceCheck::InitializeImpl(const OptionsList& options,
35      const std::string& prefix)
36  {
37    options.GetIntegerValue("max_iter", max_iterations_, prefix);
38
39    return true;
40  }
41
42  ConvergenceCheck::ConvergenceStatus OptimalityErrorConvergenceCheck::CheckConvergence()
43  {
44    DBG_START_METH("OptimalityErrorConvergenceCheck::CheckConvergence", dbg_verbosity);
45    // maybe we should throw exceptions here instead?
46
47    if (IpData().iter_count() >= max_iterations_) {
48      return ConvergenceCheck::MAXITER_EXCEEDED;
49    }
50
51    Number overall_error = IpCq().curr_nlp_error();
52    Number dual_inf = IpCq().curr_dual_infeasibility(NORM_MAX);
53    Number primal_inf = IpCq().curr_primal_infeasibility(NORM_MAX);
54    Number compl_inf = IpCq().curr_complementarity(0., NORM_MAX);
55    DBG_PRINT((1,"overall_error = %8.2e\n",overall_error));
56    if (overall_error <= IpData().tol() &&
57        dual_inf <= IpData().dual_inf_tol() &&
58        primal_inf <= IpData().primal_inf_tol() &&
59        compl_inf <= IpData().compl_inf_tol()) {
60      return ConvergenceCheck::CONVERGED;
61    }
62
63    return ConvergenceCheck::CONTINUE;
64  }
65} // namespace Ipopt
Note: See TracBrowser for help on using the repository browser.