source: trunk/Algorithm/IpOptErrorConvCheck.cpp @ 2

Last change on this file since 2 was 2, checked in by andreasw, 15 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 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 2 2004-10-21 01:03:09Z andreasw $
6//
7// Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
8
9#include "IpOptErrorConvCheck.hpp"
10
11namespace Ipopt
12{
13  OptimalityErrorConvergenceCheck::OptimalityErrorConvergenceCheck()
14  {}
15
16  OptimalityErrorConvergenceCheck::~OptimalityErrorConvergenceCheck()
17  {}
18
19  bool
20  OptimalityErrorConvergenceCheck::InitializeImpl(const OptionsList& options,
21      const std::string& prefix)
22  {
23    Index value = 0;
24
25    // Check for the algorithm options
26    if (options.GetIntegerValue("maxiter", value, prefix)) {
27      ASSERT_EXCEPTION(value >= 0, OptionsList::OPTION_OUT_OF_RANGE,
28                       "Option \"maxiter\": This value must be >= 0.");
29      max_iterations_ = value;
30    }
31    else {
32      max_iterations_ = 1000;
33    }
34
35    return true;
36  }
37
38  ConvergenceCheck::ConvergenceStatus OptimalityErrorConvergenceCheck::CheckConvergence()
39  {
40    // maybe we should throw exceptions here instead?
41
42    if (IpData().iter_count() >= max_iterations_) {
43      return ConvergenceCheck::MAXITER_EXCEEDED;
44    }
45
46    Number overall_error = IpCq().curr_nlp_error();
47    if (overall_error <= IpData().epsilon_tol()) {
48      return ConvergenceCheck::CONVERGED;
49    }
50
51    return ConvergenceCheck::CONTINUE;
52  }
53} // namespace Ipopt
Note: See TracBrowser for help on using the repository browser.