本文整理汇总了C++中SmartPtr::MakeNewIteratesVectorCopy方法的典型用法代码示例。如果您正苦于以下问题:C++ SmartPtr::MakeNewIteratesVectorCopy方法的具体用法?C++ SmartPtr::MakeNewIteratesVectorCopy怎么用?C++ SmartPtr::MakeNewIteratesVectorCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmartPtr
的用法示例。
在下文中一共展示了SmartPtr::MakeNewIteratesVectorCopy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
/** Main loop: Wait for new measurement, Get new step, maybe deal with
* bounds, see to it that everything happens in the required
* timeframe. */
SensAlgorithmExitStatus SensAlgorithm::Run()
{
DBG_START_METH("SensAlgorithm::Run", dbg_verbosity);
SensAlgorithmExitStatus retval = SOLVE_SUCCESS;
/* Loop through all steps */
SmartPtr<IteratesVector> sol = IpData().curr()->MakeNewIteratesVector();
SmartPtr<DenseVector> delta_u;
SmartPtr<const Vector> unscaled_x;
SmartPtr<const Vector> unscaled_yc;
SmartPtr<IteratesVector> trialcopy;
for (Index step_i=0; step_i<n_sens_steps_; ++step_i) {
sens_step_calc_->SetSchurDriver(driver_vec_[step_i]);
delta_u = measurement_->GetMeasurement(step_i+1);
delta_u->Print(Jnlst(),J_VECTOR,J_USER1,"delta_u");
sens_step_calc_->Step(*delta_u, *sol);
SmartPtr<IteratesVector> saved_sol = sol->MakeNewIteratesVectorCopy();
saved_sol->Print(Jnlst(),J_VECTOR,J_USER1,"sol_vec");
// unscale solution...
UnScaleIteratesVector(&saved_sol) ;
// update variables
measurement_->SetSolution(step_i+1, saved_sol);
// get sensitivity vector
GetDirectionalDerivatives() ;
}
return retval;
}
示例2: ComputeSensitivityMatrix
SensAlgorithmExitStatus SensAlgorithm::ComputeSensitivityMatrix(void) {
DBG_START_METH("SensAlgorithm::ComputeSensitivityMatrix", dbg_verbosity);
SensAlgorithmExitStatus retval = SOLVE_SUCCESS;
/* Loop through all steps */
SmartPtr<IteratesVector> sol = IpData().curr()->MakeNewIteratesVector();
SmartPtr<const Vector> unscaled_x;
SmartPtr<const Vector> unscaled_yc;
SmartPtr<IteratesVector> trialcopy;
SmartPtr<DenseVectorSpace> delta_u_space;
delta_u_space = new DenseVectorSpace(2);
SmartPtr<DenseVector> delta_u = new DenseVector(GetRawPtr(ConstPtr(delta_u_space)));
Number* du_val = delta_u->Values();
std::string state;
std::string statevalue;
state = "sens_init_constr";
statevalue = "sens_init_constr";
SmartPtr<const DenseVectorSpace> x_owner_space_ = dynamic_cast<const DenseVectorSpace*>(GetRawPtr(IpData().curr()->y_c()->OwnerSpace())) ;
//= dynamic_cast<const DenseVectorSpace*>(GetRawPtr(IpData().curr()->x()->OwnerSpace()));
const std::vector<Index> idx_ipopt = x_owner_space_->GetIntegerMetaData(state.c_str());
char buffer[250] ;
Index col = 0 ;
for (Index Scol =0; Scol < idx_ipopt.size(); ++Scol) {
if ( idx_ipopt[Scol] > 0 ) {
// reset rhs vector to zero
for (Index j = 0; j < idx_ipopt.size(); ++j) {
if ( idx_ipopt[j] > 0 ) du_val[ idx_ipopt[j] - 1 ] = 0 ;
}
sprintf(buffer,"Column %i",idx_ipopt[Scol]) ;
sens_step_calc_->SetSchurDriver(driver_vec_[0]);
// set rhs to 1 (eq. 9-10)
du_val[idx_ipopt[Scol]-1] = 1;
delta_u->SetValues(du_val) ;
//delta_u->Print(Jnlst(),J_VECTOR,J_USER1,"delta_u 1234567");
sens_step_calc_->Step(*delta_u, *sol);
SmartPtr<IteratesVector> saved_sol = sol->MakeNewIteratesVectorCopy();
saved_sol->Print(Jnlst(),J_VECTOR,J_USER1,"sol_vec");
// unscale solution...
UnScaleIteratesVector(&saved_sol) ;
saved_sol->Print(Jnlst(),J_VECTOR,J_USER1,buffer);
// Save column
GetSensitivityMatrix(col) ;
++col ; // increase column counter
}
}
return retval ;
}