本文整理汇总了C++中DVector::dim方法的典型用法代码示例。如果您正苦于以下问题:C++ DVector::dim方法的具体用法?C++ DVector::dim怎么用?C++ DVector::dim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DVector
的用法示例。
在下文中一共展示了DVector::dim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: imp_calc_point
//.........这里部分代码省略.........
model_->compute_response(dakota_asv_);
const Dakota::Response& local_response = model_->current_response();
const Dakota::RealVector& local_function_values = local_response.function_values();
const Dakota::RealMatrix& local_function_gradients = local_response.function_gradients();
// Look for failed response
const bool eval_failed = (local_function_values[0] == dakota_failed_value_);
//
// Map to the NLP objects
//
if(!eval_failed) {
//
// The evaluation succeeded so copy the values
//
// f, Gf
if(calc_f) *f = 0.0;
if(calc_Gf) *Gf = 0.0;
for( int i = 0; i < num_obj_funcs; ++i ) {
if(calc_f) {
*f += multi_obj_weights_[i] * local_function_values[i];
dakota_functions_[i] = local_function_values[i]; // Save in dakota_functions
}
if(calc_Gf) {
Vp_StV(
&(*Gf)(1,n_orig_), multi_obj_weights_[i]
,DVectorSlice(&const_cast<Dakota::RealMatrix&>(local_function_gradients)[i][0],n_orig_)
);
}
}
if(calc_Gf && Gf->dim() > n_orig_ )
(*Gf)(n_orig_+1,Gf->dim()) = 0.0; // Zero for slack variables
// c = [ A_lin_eq' * x - lin_eq_targ ]
// [ response(num_obj_funcs+num_nonlin_ineq+1:num_obj_funs+num_nonlin_ineq+num_nonlin_eq) - nonlin_eq_targ ]
if( calc_c ) {
if( num_lin_eq_ ) {
DVectorSlice c_lin = (*c)(1,num_lin_eq_);
V_mV( &c_lin, my_vec_view(dakota_rsqp_opt_->lin_eq_targ()) );
const Dakota::RealMatrix &lin_eq_jac = dakota_rsqp_opt_->lin_eq_jac();
for( int j = 0; j < num_lin_eq_; ++j ) {
for( int i = 0; i < n_orig_; ++i ) {
c_lin[j] += lin_eq_jac[j][i] * x_orig[i];
}
}
}
if( num_nonlin_eq_ ) {
const value_type
*nonlin_eq_ptr = &const_cast<Dakota::RealVector&>(local_function_values)[num_obj_funcs+num_nonlin_ineq_];
V_VmV(
&(*c)(num_lin_eq_+1,num_lin_eq_+num_nonlin_eq_)
,DVectorSlice(const_cast<value_type*>(nonlin_eq_ptr),num_nonlin_eq_)
,my_vec_view(dakota_rsqp_opt_->nonlin_eq_targ())
);
// Save in dakota_functions
std::copy( nonlin_eq_ptr, nonlin_eq_ptr + num_nonlin_eq_, &dakota_functions_[num_obj_funcs+num_nonlin_ineq_] );
}
}
// h = [ A_lin_ineq' * x ]
// [ response(num_obj_funcs+1:num_obj_funs+num_lin_eq) ]
if( calc_h ) {
//