44 #include "NLPInterfacePack_NLPWBCounterExample.hpp"
45 #include "DenseLinAlgPack_PermVecMat.hpp"
46 #include "DenseLinAlgPack_LinAlgOpPack.hpp"
47 #include "Teuchos_Assert.hpp"
49 namespace NLPInterfacePack {
53 NLPWBCounterExample::NLPWBCounterExample(
54 value_type xinit[3], value_type a, value_type b,
bool nlp_selects_basis,
bool linear_obj
56 :is_initialized_(false),nlp_selects_basis_(nlp_selects_basis),basis_selection_was_given_(false)
57 ,linear_obj_(linear_obj),n_orig_(3),m_orig_(2),Gc_orig_nz_(4),a_(a),b_(b)
60 const char msg_err_head[] =
"NLPWBCounterExample::NLPWBCounterExample(...) : Error";
67 xinit_orig_.resize(n_orig_); xl_orig_.resize(n_orig_); xu_orig_.resize(n_orig_);
69 xinit_orig_(1) = xinit[0]; xl_orig_(1) = -inf; xu_orig_(1) = +inf;
70 xinit_orig_(2) = xinit[1]; xl_orig_(2) = 0.0; xu_orig_(2) = +inf;
71 xinit_orig_(3) = xinit[2]; xl_orig_(3) = 0.0; xu_orig_(3) = +inf;
80 is_initialized_ =
true;
85 return is_initialized_;
97 return !is_initialized_;
117 return xinit_orig_();
138 return xinit_orig_();
144 return xinit_orig_();
150 DVectorSlice x =
x_full(1,n_orig_);
151 *zero_order_info.
f = ( linear_obj_ ? x(1) : 0.5*x(1)*x(1) );
157 DVectorSlice x =
x_full(1,n_orig_);
158 DVector &
c = *zero_order_info.
c;
159 c(1) = x(1)*x(1) - x(2) + a_;
160 c(2) = x(1) - x(3) - b_;
170 const DVectorSlice &x_full,
bool newx,
const ObjGradInfoSerial &obj_grad_info )
const
172 DVectorSlice x =
x_full(1,n_orig_);
173 DVector &Gf = *obj_grad_info.
Gf;
174 Gf(1) = (linear_obj_ ? 1.0 : x(1) ); Gf(2) = 0.0; Gf(3) = 0.0;
178 IVector *var_perm_full
179 ,IVector *equ_perm_full
190 if(basis_selection_was_given_)
return false;
192 var_perm_full->resize(n_orig_);
193 (*var_perm_full)(1) = 2;
194 (*var_perm_full)(2) = 3;
195 (*var_perm_full)(3) = 1;
196 equ_perm_full->resize(m_orig_);
197 DenseLinAlgPack::identity_perm( equ_perm_full );
198 *rank_full = m_orig_;
200 basis_selection_was_given_ =
true;
205 const DVectorSlice &x_orig
206 ,
const DVectorSlice *lambda_orig
207 ,
const DVectorSlice *lambdaI_orig
208 ,
const DVectorSlice *nu_orig
217 return nlp_selects_basis_;
233 const DVectorSlice& x_full,
bool newx,
const FirstOrderExplInfo& first_order_expl_info )
const
235 DVectorSlice x =
x_full(1,n_orig_);
237 index_type &Gc_nz = *first_order_expl_info.
Gc_nz;
238 value_type *Gc_v = &(*first_order_expl_info.
Gc_val)[0];
239 index_type *Gc_i = ( first_order_expl_info.
Gc_ivect ? &(*first_order_expl_info.
Gc_ivect)[0] : NULL );
240 index_type *Gc_j = ( first_order_expl_info.
Gc_jvect ? &(*first_order_expl_info.
Gc_jvect)[0] : NULL );
243 Gc_j[0] = 1; Gc_i[0] = 1;
244 Gc_j[1] = 1; Gc_i[1] = 2;
245 Gc_j[2] = 2; Gc_i[2] = 1;
246 Gc_j[3] = 2; Gc_i[3] = 3;
258 const DVectorSlice& x_full,
bool newx,
const FirstOrderExplInfo& first_order_expl_info )
const
bool imp_get_next_basis(IVector *var_perm_full, IVector *equ_perm_full, size_type *rank_full, size_type *rank)
bool imp_nlp_has_changed() const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
size_type imp_Gc_nz_orig() const
size_type imp_m_orig() const
void imp_calc_c_orig(const DVectorSlice &x_full, bool newx, const ZeroOrderInfoSerial &zero_order_info) const
const DVectorSlice imp_hl_orig() const
DVectorSlice x_full() const
void initialize(bool test_setup)
size_type imp_Gh_nz_orig() const
const DVectorSlice imp_xl_orig() const
void imp_calc_Gf_orig(const DVectorSlice &x_full, bool newx, const ObjGradInfoSerial &obj_grad_info) const
void imp_calc_Gh_orig(const DVectorSlice &x_full, bool newx, const FirstOrderExplInfo &first_order_expl_info) const
bool is_initialized() const
bool nlp_selects_basis() const
const DVectorSlice imp_hu_orig() const
void imp_calc_f_orig(const DVectorSlice &x_full, bool newx, const ZeroOrderInfoSerial &zero_order_info) const
bool imp_has_var_bounds() const
void imp_calc_Gc_orig(const DVectorSlice &x_full, bool newx, const FirstOrderExplInfo &first_order_expl_info) const
size_type imp_n_orig() const
size_type imp_mI_orig() const
void imp_report_orig_final_solution(const DVectorSlice &x_orig, const DVectorSlice *lambda_orig, const DVectorSlice *lambdaI_orig, const DVectorSlice *nu_orig, bool is_optimal)
const DVectorSlice imp_xinit_orig() const
void imp_calc_h_orig(const DVectorSlice &x_full, bool newx, const ZeroOrderInfoSerial &zero_order_info) const
value_type max_var_bounds_viol() const
static value_type infinite_bound()
const DVectorSlice imp_xu_orig() const
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
virtual VectorMutable & c()
void initialize(bool test_setup)