00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef EXAMPLE_NLP_OBJ_GRADIENT_H
00030 #define EXAMPLE_NLP_OBJ_GRADIENT_H
00031
00032 #include "NLPInterfacePack_NLPObjGrad.hpp"
00033 #include "AbstractLinAlgPack_VectorMutable.hpp"
00034 #include "AbstractLinAlgPack_VectorSpace.hpp"
00035 #include "AbstractLinAlgPack_VectorSpaceBlocked.hpp"
00036 #include "Teuchos_TestForException.hpp"
00037
00038 namespace NLPInterfacePack {
00039
00059 class ExampleNLPObjGrad : virtual public NLPObjGrad {
00060 public:
00061
00075 ExampleNLPObjGrad(
00076 const VectorSpace::space_ptr_t& vec_space
00077 ,value_type xo
00078 ,bool has_bounds
00079 ,bool dep_bounded
00080 );
00081
00084
00086 virtual Range1D var_dep() const;
00088 virtual Range1D var_indep() const;
00089
00091
00094
00096 void initialize(bool test_setup);
00098 bool is_initialized() const;
00100 size_type n() const;
00102 size_type m() const;
00104 vec_space_ptr_t space_x() const;
00106 vec_space_ptr_t space_c() const;
00108 size_type num_bounded_x() const;
00110 void force_xinit_in_bounds(bool force_xinit_in_bounds);
00112 bool force_xinit_in_bounds() const;
00114 const Vector& xinit() const;
00116 const Vector& xl() const;
00118 const Vector& xu() const;
00120 value_type max_var_bounds_viol() const;
00122 void scale_f( value_type scale_f );
00124 value_type scale_f() const;
00126 void report_final_solution(
00127 const Vector& x
00128 ,const Vector* lambda
00129 ,const Vector* nu
00130 ,bool optimal
00131 );
00132
00134
00135 protected:
00136
00139
00141 void imp_calc_f(
00142 const Vector& x, bool newx
00143 ,const ZeroOrderInfo& zero_order_info) const;
00145 void imp_calc_c(
00146 const Vector& x, bool newx
00147 ,const ZeroOrderInfo& zero_order_info) const;
00149 void imp_calc_h(const Vector& x, bool newx, const ZeroOrderInfo& zero_order_info) const;
00150
00152
00155
00157 void imp_calc_Gf(
00158 const Vector& x, bool newx
00159 ,const ObjGradInfo& obj_grad_info) const;
00160
00162
00163 private:
00164
00165
00166
00167
00168 VectorSpace::space_ptr_t vec_space_;
00169 VectorSpace::space_ptr_t vec_space_comp_;
00170 Range1D var_dep_;
00171 Range1D var_indep_;
00172
00173 bool initialized_;
00174 value_type obj_scale_;
00175 bool has_bounds_;
00176 bool force_xinit_in_bounds_;
00177
00178 size_type n_;
00179 VectorSpace::vec_mut_ptr_t xinit_;
00180 VectorSpace::vec_mut_ptr_t xl_;
00181 VectorSpace::vec_mut_ptr_t xu_;
00182
00183
00184
00185
00187 void assert_is_initialized() const;
00188
00189 };
00190
00191
00192
00193
00194 inline
00195 void ExampleNLPObjGrad::assert_is_initialized() const
00196 {
00197 using NLPInterfacePack::NLP;
00198 TEST_FOR_EXCEPTION(
00199 !is_initialized(), NLP::UnInitialized
00200 ,"ExampleNLPObjGrad::assert_is_initialized() : Error, "
00201 "ExampleNLPObjGrad::initialize() has not been called yet." );
00202 }
00203
00204 }
00205
00206 #endif // EXAMPLE_NLP_OBJ_GRADIENT_H