47 #include "NLPInterfacePack_ExampleNLPObjGrad.hpp"
48 #include "ExampleNLPDirectRTOps.h"
49 #include "AbstractLinAlgPack_BasisSystemComposite.hpp"
50 #include "AbstractLinAlgPack_VectorMutable.hpp"
51 #include "AbstractLinAlgPack_VectorStdOps.hpp"
52 #include "AbstractLinAlgPack_VectorAuxiliaryOps.hpp"
53 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
54 #include "RTOpPack_RTOpC.hpp"
55 #include "Teuchos_dyn_cast.hpp"
56 #include "Teuchos_Assert.hpp"
57 #include "Teuchos_AbstractFactoryStd.hpp"
63 class init_rtop_server_t {
65 init_rtop_server_t() {
69 init_rtop_server_t init_rtop_server;
73 namespace NLPInterfacePack {
76 const VectorSpace::space_ptr_t& vec_space
81 :vec_space_(vec_space), vec_space_comp_(Teuchos::null)
82 ,initialized_(false), obj_scale_(1.0)
83 ,has_bounds_(has_bounds), force_xinit_in_bounds_(true), n_(2*vec_space->dim())
85 namespace rcp = MemMngPack;
89 vec_space->dim() <= 0, std::logic_error
90 ,
"ExampleNLPObjGrad::ExampleNLPObjGrad(...) Error!" );
93 BasisSystemComposite::initialize_space_x(
94 vec_space, vec_space, &var_dep_, &var_indep_, &vec_space_comp_ );
97 xinit_ = vec_space_comp_->create_member();
108 xl_ = vec_space_comp_->create_member();
109 xu_ = vec_space_comp_->create_member();
113 bounded_rng = ( dep_bounded ? var_dep_ : var_indep_ ),
114 unbounded_rng = ( dep_bounded ? var_indep_ : var_dep_ );
115 *xl_->sub_view(bounded_rng) = 0.01;
117 *xu_->sub_view(bounded_rng) = 20.0;
149 assert_is_initialized();
155 assert_is_initialized();
161 return vec_space_comp_;
171 return has_bounds_ ? n_/2 : 0;
181 return force_xinit_in_bounds_;
186 assert_is_initialized();
192 assert_is_initialized();
198 assert_is_initialized();
204 return std::numeric_limits<value_type>::max();
209 assert_is_initialized();
215 assert_is_initialized();
221 ,
const Vector* lambda
226 assert_is_initialized();
247 assert_is_initialized();
251 *zero_order_info.
f = obj_scale_ / 2.0 *
dot(x,x);
257 assert_is_initialized();
267 const Vector* vecs[] = { xD.get(), xI.get() };
268 VectorMutable* targ_vecs[] = { zero_order_info.
c };
269 AbstractLinAlgPack::apply_op(explnlp2_c_eval_op,2,vecs,1,targ_vecs,NULL);
274 const Vector& x,
bool newx,
const ZeroOrderInfo& zero_order_info)
const
284 assert_is_initialized();
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
const Vector & xu() const
void V_StV(VectorMutable *v_lhs, value_type alpha, const V &V_rhs)
void imp_calc_f(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const
void report_final_solution(const Vector &x, const Vector *lambda, const Vector *nu, bool optimal)
const Vector & xinit() const
virtual Range1D var_dep() const
bool is_initialized() const
int RTOp_TOp_explnlp2_c_eval_construct(struct RTOp_RTOp *op)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void imp_calc_c(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const
bool force_xinit_in_bounds() const
size_type num_bounded_x() const
void imp_calc_h(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const
This implementation does nothing (should never be called though).
value_type scale_f() const
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
virtual Range1D var_indep() const
vec_space_ptr_t space_x() const
ExampleNLPObjGrad(const VectorSpace::space_ptr_t &vec_space, value_type xo, bool has_bounds, bool dep_bounded)
Constructor.
void initialize(bool test_setup)
void force_in_bounds(const Vector &xl, const Vector &xu, VectorMutable *x)
const Vector & xl() const
value_type max_var_bounds_viol() const
vec_space_ptr_t space_c() const
virtual void initialize(bool test_setup=false)
static value_type infinite_bound()
void imp_calc_Gf(const Vector &x, bool newx, const ObjGradInfo &obj_grad_info) const
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)