46 #include "NLPInterfacePack_NLPBarrier.hpp"
47 #include "AbstractLinAlgPack_VectorSpace.hpp"
48 #include "AbstractLinAlgPack_VectorAuxiliaryOps.hpp"
49 #include "AbstractLinAlgPack_VectorOut.hpp"
50 #include "Teuchos_Assert.hpp"
52 namespace NLPInterfacePack {
70 "null nlp passed to NLPBarrier decorator"
73 nlp_ = Teuchos::rcp_dynamic_cast<
NLPObjGrad>(original_nlp);
78 "non NLPObjGrad NLP passed to NLPBarrier decorator"
94 return objective_term_;
99 return grad_barrier_term_;
104 return grad_objective_term_;
110 nlp_->calc_f(x, newx);
111 value_type* f_val = nlp_->get_f();
113 objective_term_ = *f_val;
114 barrier_term_ = CalculateBarrierTerm(x);
116 (*f_val) += barrier_term_;
123 nlp_->calc_Gf(x, newx);
124 grad_objective_term_ = nlp_->get_Gf()->clone();
129 if (!grad_barrier_term_temp_.
get())
132 if (!grad_barrier_term_.
get())
135 *grad_barrier_term_temp_ = 0.0;
136 *grad_barrier_term_ = 0.0;
146 grad_barrier_term_->
axpy(-1.0, *grad_barrier_term_temp_);
148 nlp_->get_Gf()->axpy(1.0, *grad_barrier_term_);
200 value_type NLPBarrier::CalculateBarrierTerm(
const Vector& x)
const
205 barrier_term_ *= -mu_;
207 return barrier_term_;
NLP interface class that adds gradient information for the objective function {abstract}.
value_type barrier_term() const
Get the barrier term. Must be called after calc_f().
Struct for gradient (objective), objective and constriants (pointers)
virtual const VectorSpace & space() const =0
void imp_calc_c(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const
const Vector & xu() const
void calc_f(const Vector &x, bool newx=true) const
Overloaded to include barrier term.
void inv_of_difference(const value_type alpha, const Vector &v0, const Vector &v1, VectorMutable *z)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void InitializeFromNLP(Teuchos::RCP< NLP > original_nlp)
const Teuchos::RCP< Vector > grad_objective_term() const
Get the value of the gradient of the true objective term. Must be called after calc_Gf().
void imp_calc_c_breve(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info_breve) const
const Vector & xl() const
void mu(const value_type mu)
Set the barrier parameter.
virtual void axpy(value_type alpha, const Vector &x)
Struct for objective and constriants (pointer).
void imp_calc_h_breve(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info_breve) const
value_type objective_term() const
Get the true objective term value. Must be called after calc_f().
void imp_calc_Gf(const Vector &x, bool newx, const ObjGradInfo &obj_grad_info) const
value_type log_bound_barrier(const Vector &x, const Vector &xl, const Vector &xu)
const Teuchos::RCP< Vector > grad_barrier_term() const
Get the value of the gradient of the barrier term. Must be called after calc_Gf() ...
void imp_calc_f(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const
virtual vec_mut_ptr_t create_member() const =0
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
void calc_Gf(const Vector &x, bool newx=true) const
Overloaded to include barrier term.