LuksanVlcek4.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Copyright (C) 2005, 2006 International Business Machines and others.
  2. // All Rights Reserved.
  3. // This code is published under the Eclipse Public License.
  4. //
  5. // $Id: LuksanVlcek4.hpp 1861 2010-12-21 21:34:47Z andreasw $
  6. //
  7. // Authors: Andreas Waechter IBM 2005-10-127
  8. #ifndef __LUKSANVLCEK4_HPP__
  9. #define __LUKSANVLCEK4_HPP__
  10. #include "RegisteredTNLP.hpp"
  11. using namespace Ipopt;
  12. /** Implementation of Example 5.4 from "Sparse and Parially Separable
  13. * Test Problems for Unconstrained and Equality Constrained
  14. * Optimization" by L. Luksan and J. Vlcek. */
  15. class LuksanVlcek4 : public RegisteredTNLP
  16. {
  17. public:
  18. /** Constructor. Here, g_l and g_u are the bounds for the
  19. * constraints. The original formulation is obtained by setting
  20. * g_l and g_u to zero. Using g_l<g_u allows the obtain a problem
  21. * formulation with inequality constraints. */
  22. LuksanVlcek4(Number g_l, Number g_u);
  23. /** Default destructor */
  24. virtual ~LuksanVlcek4()
  25. {}
  26. ;
  27. /** Overloaded from RegisteredTNLP. */
  28. virtual bool InitializeProblem(Index N);
  29. /**@name Overloaded from TNLP */
  30. //@{
  31. /** Method to return some info about the nlp */
  32. virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
  33. Index& nnz_h_lag, IndexStyleEnum& index_style);
  34. /** Method to return the bounds for my problem */
  35. virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
  36. Index m, Number* g_l, Number* g_u);
  37. /** Method to return the starting point for the algorithm */
  38. virtual bool get_starting_point(Index n, bool init_x, Number* x,
  39. bool init_z, Number* z_L, Number* z_U,
  40. Index m, bool init_lambda,
  41. Number* lambda);
  42. /** Method to return the objective value */
  43. virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
  44. /** Method to return the gradient of the objective */
  45. virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
  46. /** Method to return the constraint residuals */
  47. virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
  48. /** Method to return:
  49. * 1) The structure of the jacobian (if "values" is NULL)
  50. * 2) The values of the jacobian (if "values" is not NULL)
  51. */
  52. virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
  53. Index m, Index nele_jac, Index* iRow, Index *jCol,
  54. Number* values);
  55. /** Method to return:
  56. * 1) The structure of the hessian of the lagrangian (if "values" is NULL)
  57. * 2) The values of the hessian of the lagrangian (if "values" is not NULL)
  58. */
  59. virtual bool eval_h(Index n, const Number* x, bool new_x,
  60. Number obj_factor, Index m, const Number* lambda,
  61. bool new_lambda, Index nele_hess, Index* iRow,
  62. Index* jCol, Number* values);
  63. //@}
  64. /** @name Solution Methods */
  65. //@{
  66. /** This method is called when the algorithm is complete so the TNLP can store/write the solution */
  67. virtual void finalize_solution(SolverReturn status,
  68. Index n, const Number* x, const Number* z_L, const Number* z_U,
  69. Index m, const Number* g, const Number* lambda,
  70. Number obj_value,
  71. const IpoptData* ip_data,
  72. IpoptCalculatedQuantities* ip_cq);
  73. //@}
  74. private:
  75. /**@name Methods to block default compiler methods.
  76. * The compiler automatically generates the following three methods.
  77. * Since the default compiler implementation is generally not what
  78. * you want (for all but the most simple classes), we usually
  79. * put the declarations of these methods in the private section
  80. * and never implement them. This prevents the compiler from
  81. * implementing an incorrect "default" behavior without us
  82. * knowing. (See Scott Meyers book, "Effective C++")
  83. *
  84. */
  85. //@{
  86. LuksanVlcek4();
  87. LuksanVlcek4(const LuksanVlcek4&);
  88. LuksanVlcek4& operator=(const LuksanVlcek4&);
  89. //@}
  90. /** Parameter determining problem size */
  91. Index N_;
  92. /** General lower bound for all constraints */
  93. Number g_l_;
  94. /** General upper bound for all constraints */
  95. Number g_u_;
  96. };
  97. #endif