62 namespace NLPInterfacePack {
69 const basis_sys_fcty_ptr_t &basis_sys_fcty
72 :initialized_(false),test_setup_(false)
74 this->set_basis_sys_fcty(basis_sys_fcty);
82 if(factory_Gc_full.
get())
105 namespace mmp = MemMngPack;
154 return fcty.create();
170 Permutation* P_var,
Range1D* var_dep
171 ,Permutation* P_equ,
Range1D* equ_decomp
175 P_var,var_dep,P_equ,equ_decomp
184 const Permutation &P_var,
const Range1D &var_dep
185 ,
const Permutation *P_equ,
const Range1D *equ_decomp
189 P_var,var_dep,P_equ,equ_decomp
197 const Vector& x,
bool newx
201 namespace mmp = MemMngPack;
217 n_full = n_orig + mI_orig,
218 m_full = m_orig + mI_orig;
229 &G_aggr =
dyn_cast<MatrixPermAggr>( *first_order_info.
Gc );
232 G_full = Teuchos::rcp_const_cast<MatrixOp>( G_aggr.mat_orig() );
234 P_row = Teuchos::rcp_dynamic_cast<PermutationSerial>(
235 Teuchos::rcp_const_cast<Permutation>( G_aggr.row_perm() ) );
237 P_col = Teuchos::rcp_dynamic_cast<PermutationSerial>(
238 Teuchos::rcp_const_cast<Permutation>( G_aggr.col_perm() ) );
240 G_perm = G_aggr.mat_perm();
242 G_aggr.set_uninitialized();
244 if( G_full.get() == NULL || G_full.total_count() > 1 )
247 MatrixLoadSparseElements
248 &G_lse =
dyn_cast<MatrixLoadSparseElements>(*G_full);
265 const bool load_struct = (G_lse.nz() == 0);
269 G_lse.reinitialize(n,num_cols,nz_full);
272 G_nz_previous = G_lse.nz();
273 G_lse.reset_to_load_values();
284 G_lse.get_load_nonzeros_buffers(
287 ,load_struct ? &ivect : NULL
288 ,load_struct ? &jvect : NULL
304 n, n_full, load_struct
306 ,val_orig, val_orig_end, ivect_orig, jvect_orig
318 n, n_full, load_struct
320 ,val_orig, val_orig_end, ivect_orig, jvect_orig
322 ,val + nz, ivect + nz, jvect + nz
339 *ivect_itr++ = var_idx;
340 *jvect_itr++ = m_orig + k;
364 G_nz_previous != nz, std::runtime_error
365 ,
"NLPSerialPreprocessExplJac::imp_calc_Gc(...): Error, "
366 "The number of added nonzeros does not match the number of nonzeros "
367 "in the previous matrix load!." );
371 G_lse.commit_load_nonzeros_buffers(
374 ,load_struct ? &ivect : NULL
375 ,load_struct ? &jvect : NULL
384 if( P_row.get() == NULL || P_col.
total_count() > 1 )
387 if( P_row->perm().get() == NULL ) var_perm =
Teuchos::rcp(
new IVector(n_full));
388 else var_perm = Teuchos::rcp_const_cast<IVector>(P_row->perm());
395 if( P_col->perm().
get() == NULL ) con_perm =
Teuchos::rcp(
new IVector(m_full));
396 else con_perm = Teuchos::rcp_const_cast<IVector>(P_col->perm());
400 int num_row_part, num_col_part;
405 row_part[1] = (var_dep.lbound() == 1 ? var_dep.ubound()+1 : var_dep.lbound());
417 col_part[2] = m_full+1;
422 col_part[1] = m_full+1;
425 G_perm = G_full->perm_view(
426 P_row.get(),row_part,num_row_part
427 ,P_col.
get(),col_part,num_col_part
431 G_perm = G_full->perm_view_update(
432 P_row.get(),row_part,num_row_part
433 ,P_col.
get(),col_part,num_col_part
443 G_aggr.initialize(G_full,P_row,P_col,G_perm);
452 ,
"NLPSerialPreprocessExplJac : The nlp has not been initialized yet" );
475 for( ; val_orig != val_orig_end ; ++val_orig, ++ivect_orig, ++jvect_orig) {
485 *val_itr++ = *val_orig;
487 *ivect_itr++ = var_idx;
488 *jvect_itr++ = col_offset + (*jvect_orig);
495 for( ; val_orig != val_orig_end ; ++val_orig, ++ivect_orig) {
505 *val_itr++ = *val_orig;
void set_basis(const Permutation &P_var, const Range1D &var_dep, const Permutation *P_equ, const Range1D *equ_decomp)
void set_basis(const Permutation &P_var, const Range1D &var_dep, const Permutation *P_equ, const Range1D *equ_decomp)
virtual bool imp_nlp_has_changed() const
Return if the definition of the NLP has changed since the last call to initialize() ...
AbstractLinAlgPack::size_type size_type
const IVector & var_full_to_remove_fixed() const
Inverse permutation vector of var_remove_fixed_to_full().
NLP node subclass complementing NLPSerialPreprocess for explicit Jacobians.
MatrixOp * Gc
Pointer to Jacobian of equality constraints Gc (may be NULL if not set)
void initialize(bool test_setup)
Initialize the NLP for its first use.
virtual size_type imp_m_orig() const =0
Return the number of general equality constraints in the original problem.
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
RTOp_index_type index_type
const basis_sys_ptr_t basis_sys() const
Calls basis_sys_fcty()->create()
const IVector & equ_perm() const
Permutes from the original constriant ordering to the current basis selection.
void set_factory_Gc_full(const factory_mat_ptr_t &factory_Gc_full)
Initialize with matrix factory for original matrices Gc.
NLPSerialPreprocessExplJac(const basis_sys_fcty_ptr_t &basis_sys_fcty=Teuchos::rcp(new BasisSystemFactoryStd()), const factory_mat_ptr_t &factory_Gc_full=Teuchos::null)
Calls this->set_basis_sys_fcty() and this->set_mat_factories() methods.
Range1D equ_decomp() const
FirstOrderExplInfo::ivect_t Gh_ivect_orig_
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
const FirstOrderExplInfo first_order_expl_info() const
virtual size_type imp_n_orig() const =0
Return the number of variables in the original problem (including those fixed by bounds) ...
const mat_fcty_ptr_t factory_Gc() const
bool get_next_basis(Permutation *P_var, Range1D *var_dep, Permutation *P_equ, Range1D *equ_decomp)
void imp_fill_jacobian_entries(size_type n, size_type n_full, bool load_struct, const index_type col_offset, const value_type *val_full, const value_type *val_full_end, const index_type *ivect_full, const index_type *jvect_full, index_type *nz, value_type *val_itr, index_type *ivect_itr, index_type *jvect_itr) const
const IVector & var_perm() const
Permutes from the compated variable vector (removing fixed variables) to the current basis selection...
DVectorSlice x_full() const
Give reference to current x_full.
bool is_initialized() const
bool Gc_perm_new_basis_updated_
const f_int f_dbl_prec const f_int const f_int const f_int jvect[]
mat_fcty_ptr_t factory_Gc_
FirstOrderExplInfo::jvect_t Gh_jvect_orig_
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void imp_calc_Gh_orig(const DVectorSlice &x_full, bool newx, const FirstOrderExplInfo &first_order_expl_info) const =0
Calculate the COOR matrix for the gradient for all of the h(x) constaints in the original NLP...
T_To & dyn_cast(T_From &from)
const options_ptr_t & get_options() const
Struct for zero and first order quantities (pointers)
void initialize(bool test_setup)
factory_mat_ptr_t factory_Gc_full_
virtual size_type imp_Gh_nz_orig() const =0
Return the number of nonzero elements in Gh before elements are removed for fixed variables...
FirstOrderExplInfo::jvect_t Gc_jvect_orig_
void set_Gc(MatrixOp *Gc)
Validates the type of Gc is correct.
const f_int f_dbl_prec const f_int const f_int ivect[]
Thrown if any member functions are called before initialize() has been called.
virtual size_type imp_mI_orig() const =0
Return the number of general inequality constraints in the original problem.
virtual void imp_calc_Gc_orig(const DVectorSlice &x_full, bool newx, const FirstOrderExplInfo &first_order_expl_info) const =0
Calculate the COOR matrix for the gradient for all of the c(x) constaints in the original NLP...
virtual size_type imp_Gc_nz_orig() const =0
Return the number of nonzero elements in Gc before elements are removed for fixed variables...
FirstOrderExplInfo::ivect_t Gc_ivect_orig_
void set_options(const options_ptr_t &options)
Passes these options on to this->basis_sys_fcty().set_options(options).
AbstractLinAlgPack::value_type value_type
virtual obj_ptr_t create() const =0
void assert_initialized() const
Assert if we have been initizlized (throws UnInitialized)
void set_x_full(const DVectorSlice &x, bool newx, DVectorSlice *x_full) const
Set the full x vector if newx == true
void imp_calc_Gc(const Vector &x, bool newx, const FirstOrderInfo &first_order_info) const
RangePack::Range1D Range1D
virtual void set_Gc(MatrixOp *Gc)
Set a pointer to a matrix object to be updated when this->calc_Gc() is called.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
FirstOrderExplInfo::val_t Gh_val_orig_
void initialize(bool test_setup)
bool get_next_basis(Permutation *P_var, Range1D *var_dep, Permutation *P_equ, Range1D *equ_decomp)
FirstOrderExplInfo::val_t Gc_val_orig_