IpSolveStatistics.hpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // Copyright (C) 2005, 2009 International Business Machines and others.
  2. // All Rights Reserved.
  3. // This code is published under the Eclipse Public License.
  4. //
  5. // $Id: IpSolveStatistics.hpp 1861 2010-12-21 21:34:47Z andreasw $
  6. //
  7. // Authors: Carl Laird, Andreas Waechter IBM 2005-08-15
  8. #ifndef __IPSOLVESTATISTICS_HPP__
  9. #define __IPSOLVESTATISTICS_HPP__
  10. #include "IpReferenced.hpp"
  11. #include "IpSmartPtr.hpp"
  12. namespace Ipopt
  13. {
  14. // forward declaration (to avoid inclusion of too many header files)
  15. class IpoptNLP;
  16. class IpoptData;
  17. class IpoptCalculatedQuantities;
  18. /** This class collects statistics about an optimziation run, such
  19. * as iteration count, final infeasibilities etc. It is meant to
  20. * provide such information to a user of Ipopt during the
  21. * finalize_solution call.
  22. */
  23. class SolveStatistics : public ReferencedObject
  24. {
  25. public:
  26. /**@name Constructors/Destructors */
  27. //@{
  28. /** Default constructor. It takes in those collecting Ipopt
  29. * objects that can provide the statistics information. Those
  30. * statistics are retrieved at the time of the constructor
  31. * call. */
  32. SolveStatistics(const SmartPtr<IpoptNLP>& ip_nlp,
  33. const SmartPtr<IpoptData>& ip_data,
  34. const SmartPtr<IpoptCalculatedQuantities>& ip_cq);
  35. /** Default destructor */
  36. virtual ~SolveStatistics()
  37. {}
  38. //@}
  39. /** @name Accessor methods for retrieving different kind of solver
  40. * statistics information */
  41. //@{
  42. /** Iteration counts. */
  43. virtual Index IterationCount() const;
  44. /** Total CPU time, including function evaluations. */
  45. virtual Number TotalCpuTime() const;
  46. /** Total CPU time, including function evaluations. Included for
  47. * backward compatibility. */
  48. Number TotalCPUTime() const
  49. {
  50. return TotalCpuTime();
  51. }
  52. /** Total System time, including function evaluations. */
  53. virtual Number TotalSysTime() const;
  54. /** Total wall clock time, including function evaluations. */
  55. virtual Number TotalWallclockTime() const;
  56. /** Number of NLP function evaluations. */
  57. virtual void NumberOfEvaluations(Index& num_obj_evals,
  58. Index& num_constr_evals,
  59. Index& num_obj_grad_evals,
  60. Index& num_constr_jac_evals,
  61. Index& num_hess_evals) const;
  62. /** Unscaled solution infeasibilities */
  63. virtual void Infeasibilities(Number& dual_inf,
  64. Number& constr_viol,
  65. Number& complementarity,
  66. Number& kkt_error) const;
  67. /** Scaled solution infeasibilities */
  68. virtual void ScaledInfeasibilities(Number& scaled_dual_inf,
  69. Number& scaled_constr_viol,
  70. Number& scaled_complementarity,
  71. Number& scaled_kkt_error) const;
  72. /** Final value of objective function */
  73. virtual Number FinalObjective() const;
  74. /** Final scaled value of objective function */
  75. virtual Number FinalScaledObjective() const;
  76. //@}
  77. private:
  78. /**@name Default Compiler Generated Methods
  79. * (Hidden to avoid implicit creation/calling).
  80. * These methods are not implemented and
  81. * we do not want the compiler to implement
  82. * them for us, so we declare them private
  83. * and do not define them. This ensures that
  84. * they will not be implicitly created/called. */
  85. //@{
  86. /** Default Constructor */
  87. SolveStatistics();
  88. /** Copy Constructor */
  89. SolveStatistics(const SolveStatistics&);
  90. /** Overloaded Equals Operator */
  91. void operator=(const SolveStatistics&);
  92. //@}
  93. /** @name Fields for storing the statistics data */
  94. //@{
  95. /** Number of iterations. */
  96. Index num_iters_;
  97. /* Total CPU time */
  98. Number total_cpu_time_;
  99. /* Total system time */
  100. Number total_sys_time_;
  101. /* Total wall clock time */
  102. Number total_wallclock_time_;
  103. /** Number of objective function evaluations. */
  104. Index num_obj_evals_;
  105. /** Number of constraints evaluations (max of equality and
  106. * inequality) */
  107. Index num_constr_evals_;
  108. /** Number of objective gradient evaluations. */
  109. Index num_obj_grad_evals_;
  110. /** Number of constraint Jacobian evaluations. */
  111. Index num_constr_jac_evals_;
  112. /** Number of Lagrangian Hessian evaluations. */
  113. Index num_hess_evals_;
  114. /** Final scaled value of objective function */
  115. Number scaled_obj_val_;
  116. /** Final unscaled value of objective function */
  117. Number obj_val_;
  118. /** Final scaled dual infeasibility (max-norm) */
  119. Number scaled_dual_inf_;
  120. /** Final unscaled dual infeasibility (max-norm) */
  121. Number dual_inf_;
  122. /** Final scaled constraint violation (max-norm) */
  123. Number scaled_constr_viol_;
  124. /** Final unscaled constraint violation (max-norm) */
  125. Number constr_viol_;
  126. /** Final scaled complementarity error (max-norm) */
  127. Number scaled_compl_;
  128. /** Final unscaled complementarity error (max-norm) */
  129. Number compl_;
  130. /** Final overall scaled KKT error (max-norm) */
  131. Number scaled_kkt_error_;
  132. /** Final overall unscaled KKT error (max-norm) */
  133. Number kkt_error_;
  134. //@}
  135. };
  136. } // namespace Ipopt
  137. #endif