本文整理汇总了C++中ConstPtr函数的典型用法代码示例。如果您正苦于以下问题:C++ ConstPtr函数的具体用法?C++ ConstPtr怎么用?C++ ConstPtr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ConstPtr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DBG_START_METH
SmartPtr<const Vector> NLPScalingObject::apply_vector_scaling_d_LU(
const Matrix& Pd_LU,
const SmartPtr<const Vector>& lu,
const VectorSpace& d_space)
{
DBG_START_METH("NLPScalingObject::apply_vector_scaling_d_LU", dbg_verbosity);
if (have_d_scaling()) {
return ConstPtr(apply_vector_scaling_d_LU_NonConst(Pd_LU, lu, d_space));
}
else {
return lu;
}
}
示例2: DBG_ASSERT
void AlgorithmBuilder::BuildIpoptObjects(const Journalist& jnlst,
const OptionsList& options,
const std::string& prefix,
const SmartPtr<NLP>& nlp,
SmartPtr<IpoptNLP>& ip_nlp,
SmartPtr<IpoptData>& ip_data,
SmartPtr<IpoptCalculatedQuantities>& ip_cq)
{
DBG_ASSERT(prefix == "");
SmartPtr<NLPScalingObject> nlp_scaling ;
std::string nlp_scaling_method;
options.GetStringValue("nlp_scaling_method", nlp_scaling_method, "");
if (nlp_scaling_method == "user-scaling") {
nlp_scaling = new UserScaling(ConstPtr(nlp));
}
else if (nlp_scaling_method == "gradient-based") {
nlp_scaling = new GradientScaling(nlp);
}
else if (nlp_scaling_method == "equilibration-based") {
nlp_scaling = new EquilibrationScaling(nlp);
}
else {
nlp_scaling = new NoNLPScalingObject();
}
ip_nlp = new OrigIpoptNLP(&jnlst, GetRawPtr(nlp), nlp_scaling);
// Create the IpoptData. Check if there is additional data that
// is needed
std::string lsmethod;
SmartPtr<IpoptAdditionalData> add_data;
options.GetStringValue("line_search_method", lsmethod, prefix);
if (lsmethod=="cg-penalty") {
add_data = new CGPenaltyData();
}
ip_data = new IpoptData(add_data);
// Create the IpoptCalculators. Check if there are additional
// calcluated quantities that are needed
ip_cq = new IpoptCalculatedQuantities(ip_nlp, ip_data);
if (lsmethod=="cg-penalty") {
SmartPtr<IpoptAdditionalCq> add_cq =
new CGPenaltyCq(GetRawPtr(ip_nlp), GetRawPtr(ip_data),
GetRawPtr(ip_cq));
ip_cq->SetAddCq(add_cq);
}
}
示例3: MakeNewIteratesVector
/** Use this method to create a new const IteratesVector. You must pass in
* valid pointers for all of the entries.
*/
const SmartPtr<const IteratesVector> MakeNewIteratesVector(const Vector& x, const Vector& s,
const Vector& y_c, const Vector& y_d,
const Vector& z_L, const Vector& z_U,
const Vector& v_L, const Vector& v_U)
{
SmartPtr<IteratesVector> newvec = MakeNewIteratesVector(false);
newvec->Set_x(x);
newvec->Set_s(s);
newvec->Set_y_c(y_c);
newvec->Set_y_d(y_d);
newvec->Set_z_L(z_L);
newvec->Set_z_U(z_U);
newvec->Set_v_L(v_L);
newvec->Set_v_U(v_U);
return ConstPtr(newvec);
}
示例4: DBG_START_METH
SmartPtr<const Vector>
AugRestoSystemSolver::Neg_Omega_c_plus_D_c(
const SmartPtr<const Vector>& sigma_tilde_n_c_inv,
const SmartPtr<const Vector>& sigma_tilde_p_c_inv,
const Vector* D_c,
const Vector& any_vec_in_c)
{
DBG_START_METH("AugRestoSystemSolver::Neg_Omega_c_plus_D_c",dbg_verbosity);
SmartPtr<Vector> retVec;
if (IsValid(sigma_tilde_n_c_inv) || IsValid(sigma_tilde_p_c_inv) || D_c) {
if (!neg_omega_c_plus_D_c_cache_.
GetCachedResult3Dep(retVec, GetRawPtr(sigma_tilde_n_c_inv), GetRawPtr(sigma_tilde_p_c_inv), D_c)) {
DBG_PRINT((1,"Not found in cache\n"));
retVec = any_vec_in_c.MakeNew();
Number fact1, fact2;
SmartPtr<const Vector> v1;
SmartPtr<const Vector> v2;
if (IsValid(sigma_tilde_n_c_inv)) {
v1 = sigma_tilde_n_c_inv;
fact1 = -1.;
}
else {
v1 = &any_vec_in_c;
fact1 = 0.;
}
if (IsValid(sigma_tilde_p_c_inv)) {
v2 = sigma_tilde_p_c_inv;
fact2 = -1.;
}
else {
v2 = &any_vec_in_c;
fact2 = 0.;
}
retVec->AddTwoVectors(fact1, *v1, fact2, *v2, 0.);
if (D_c) {
retVec->Axpy(1.0, *D_c);
}
neg_omega_c_plus_D_c_cache_.
AddCachedResult3Dep(retVec, GetRawPtr(sigma_tilde_n_c_inv), GetRawPtr(sigma_tilde_p_c_inv), D_c);
}
}
return ConstPtr(retVec);
}
示例5: DBG_START_METH
bool IndexPCalculator::ComputeP()
{
DBG_START_METH("IndexPCalculator::ComputeP", dbg_verbosity);
bool retval = true;
// 1. check whether all columns needed by data_A() are in map cols_ - we suppose data_A is IndexSchurData
const std::vector<Index>* p2col_idx = dynamic_cast<const IndexSchurData*>(GetRawPtr(data_A()))->GetColIndices();
Index col;
Number* col_values = NULL;
Index curr_dim, curr_schur_row=0;
SmartPtr<const DenseVector> comp_vec;
const Number* comp_values;
std::map< Index, SmartPtr<PColumn> >::iterator find_it;
SmartPtr<IteratesVector> col_vec = IpData().curr()->MakeNewIteratesVector();
SmartPtr<IteratesVector> sol_vec = col_vec->MakeNewIteratesVector();
for (std::vector<Index>::const_iterator col_it=p2col_idx->begin(); col_it!=p2col_idx->end(); ++col_it){
col = *col_it;
find_it = cols_.find(col);
if (find_it==cols_.end()) {
// column is in data_A but not in P-matrix ->create
data_A()->GetRow(curr_schur_row, *col_vec);
retval = Solver()->Solve(sol_vec, ConstPtr(col_vec));
DBG_ASSERT(retval);
/* This part is for displaying norm2(I_z*K^(-1)*I_1) */
DBG_PRINT((dbg_verbosity,"\ncurr_schur_row=%d, ",curr_schur_row));
DBG_PRINT((dbg_verbosity,"norm2(z)=%23.16e\n",sol_vec->x()->Nrm2()));
/* end displaying norm2 */
DBG_ASSERT(col_values== NULL);
col_values = new Number[nrows_];
curr_dim = 0;
for (Index j=0; j<sol_vec->NComps(); ++j) {
comp_vec = dynamic_cast<const DenseVector*>(GetRawPtr(sol_vec->GetComp(j)));
comp_values = comp_vec->Values();
IpBlasDcopy(comp_vec->Dim(), comp_values, 1, col_values+curr_dim,1);
curr_dim += comp_vec->Dim();
}
cols_[col] = new PColumn(nrows_, col_values);
col_values = NULL;
}
curr_schur_row++;
}
return retval;
}
示例6: ConstPtr
inline
void CGPenaltyData::set_delta_cgfast(SmartPtr<IteratesVector>& delta_cgfast)
{
delta_cgfast_ = ConstPtr(delta_cgfast);
#if COIN_IPOPT_CHECKLEVEL > 0
if (IsValid(delta_cgfast)) {
debug_delta_cgfast_tag_ = delta_cgfast->GetTag();
debug_delta_cgfast_tag_sum_ = delta_cgfast->GetTagSum();
}
else {
debug_delta_cgfast_tag_ = 0;
debug_delta_cgfast_tag_sum_ = delta_cgfast->GetTagSum();
}
#endif
delta_cgfast = NULL;
}
示例7: ConstPtr
inline
void IpoptData::set_delta_aff(SmartPtr<IteratesVector>& delta_aff)
{
delta_aff_ = ConstPtr(delta_aff);
#if COIN_IPOPT_CHECKLEVEL > 0
if (IsValid(delta_aff)) {
debug_delta_aff_tag_ = delta_aff->GetTag();
debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
}
else {
debug_delta_aff_tag_ = TaggedObject::Tag();
debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
}
#endif
delta_aff = NULL;
}
示例8: ConstPtr
inline
void CGPenaltyData::set_delta_cgpen(SmartPtr<IteratesVector>& delta_cgpen)
{
delta_cgpen_ = ConstPtr(delta_cgpen);
#if COIN_IPOPT_CHECKLEVEL > 0
if (IsValid(delta_cgpen)) {
debug_delta_cgpen_tag_ = delta_cgpen->GetTag();
debug_delta_cgpen_tag_sum_ = delta_cgpen->GetTagSum();
}
else {
debug_delta_cgpen_tag_ = TaggedObject::Tag();
debug_delta_cgpen_tag_sum_ = delta_cgpen->GetTagSum();
}
#endif
delta_cgpen = NULL;
}
示例9: ConstPtr
inline
void IpoptData::set_delta(SmartPtr<IteratesVector>& delta)
{
delta_ = ConstPtr(delta);
#if COIN_IPOPT_CHECKLEVEL > 0
if (IsValid(delta)) {
debug_delta_tag_ = delta->GetTag();
debug_delta_tag_sum_ = delta->GetTagSum();
}
else {
debug_delta_tag_ = 0;
debug_delta_tag_sum_ = 0;
}
#endif
delta = NULL;
}
示例10: apply_vector_scaling_x_NonConst
SmartPtr<Vector> NLPScalingObject::apply_vector_scaling_x_LU_NonConst(
const Matrix& Px_LU,
const SmartPtr<const Vector>& lu,
const VectorSpace& x_space)
{
SmartPtr<Vector> scaled_x_LU = lu->MakeNew();
if (have_x_scaling()) {
SmartPtr<Vector> tmp_x = x_space.MakeNew();
// move to full x space
Px_LU.MultVector(1.0, *lu, 0.0, *tmp_x);
// scale in full x space
tmp_x = apply_vector_scaling_x_NonConst(ConstPtr(tmp_x));
// move back to x_L space
Px_LU.TransMultVector(1.0, *tmp_x, 0.0, *scaled_x_LU);
}
else {
scaled_x_LU->Copy(*lu);
}
return scaled_x_LU;
}
示例11: unapply_vector_scaling_d_NonConst
SmartPtr<Vector> NLPScalingObject::unapply_vector_scaling_d_LU_NonConst(
const Matrix& Pd_LU,
const SmartPtr<const Vector>& lu,
const VectorSpace& d_space)
{
SmartPtr<Vector> unscaled_d_LU = lu->MakeNew();
if (have_d_scaling()) {
SmartPtr<Vector> tmp_d = d_space.MakeNew();
// move to full d space
Pd_LU.MultVector(1.0, *lu, 0.0, *tmp_d);
// scale in full x space
tmp_d = unapply_vector_scaling_d_NonConst(ConstPtr(tmp_d));
// move back to x_L space
Pd_LU.TransMultVector(1.0, *tmp_d, 0.0, *unscaled_d_LU);
}
else {
unscaled_d_LU->Copy(*lu);
}
return unscaled_d_LU;
}
示例12: ConstPtr
inline
SmartPtr<const Vector> ScaledMatrix::ColumnScaling() const
{
return ConstPtr(owner_space_->ColumnScaling());
}
示例13: ColumnScaling
/** return the vector for the column scaling */
SmartPtr<const Vector> ColumnScaling() const
{
return ConstPtr(column_scaling_);
}
示例14: RowScaling
/** return the vector for the row scaling */
SmartPtr<const Vector> RowScaling() const
{
return ConstPtr(row_scaling_);
}
示例15: DBG_START_METH
//.........这里部分代码省略.........
*ip_data_,
*ip_cq_,
*pd_solver_);
red_hess_calc->ComputeReducedHessian();
}
if (run_sens_ && n_sens_steps_>0 && !sens_internal_abort) {
SmartPtr<SensBuilder> schur_builder = new SensBuilder();
const std::string prefix = ""; // I should be getting this somewhere else...
SmartPtr<SensAlgorithm> controller = schur_builder->BuildSensAlg(*jnlst_,
*options_,
prefix,
*ip_nlp_,
*ip_data_,
*ip_cq_,
*pd_solver_);
retval = controller->Run();
}
else if (run_sens_) {
if (n_sens_steps_<=0) {
jnlst_->Printf(J_WARNING, J_MAIN, "\n"
"The run_sens option was set to true, but the specified\n"
"number of sensitivity steps was set to zero.\n"
"Computation is aborted.\n\n");
}
}
if (IsValid(ip_data_->curr()) && IsValid(ip_data_->curr()->x())) {
SmartPtr<const Vector> c;
SmartPtr<const Vector> d;
SmartPtr<const Vector> zL;
SmartPtr<const Vector> zU;
SmartPtr<const Vector> yc;
SmartPtr<const Vector> yd;
Number obj = 0.;
switch (status) {
case SUCCESS:
/*c = ip_cq_->curr_c();
d = ip_cq_->curr_d();
obj = ip_cq_->curr_f();
zL = ip_data_->curr()->z_L();
zU = ip_data_->curr()->z_U();
yc = ip_data_->curr()->y_c();
yd = ip_data_->curr()->y_d();*/
case MAXITER_EXCEEDED:
case STOP_AT_TINY_STEP:
case STOP_AT_ACCEPTABLE_POINT:
case LOCAL_INFEASIBILITY:
case USER_REQUESTED_STOP:
case FEASIBLE_POINT_FOUND:
case DIVERGING_ITERATES:
case RESTORATION_FAILURE:
case ERROR_IN_STEP_COMPUTATION:
c = ip_cq_->curr_c();
d = ip_cq_->curr_d();
obj = ip_cq_->curr_f();
zL = ip_data_->curr()->z_L();
zU = ip_data_->curr()->z_U();
yc = ip_data_->curr()->y_c();
yd = ip_data_->curr()->y_d();
break;
default:
SmartPtr<Vector> tmp = ip_data_->curr()->y_c()->MakeNew();
tmp->Set(0.);
c = ConstPtr(tmp);
yc = ConstPtr(tmp);
tmp = ip_data_->curr()->y_d()->MakeNew();
tmp->Set(0.);
d = ConstPtr(tmp);
yd = ConstPtr(tmp);
tmp = ip_data_->curr()->z_L()->MakeNew();
tmp->Set(0.);
zL = ConstPtr(tmp);
tmp = ip_data_->curr()->z_U()->MakeNew();
tmp->Set(0.);
zU = ConstPtr(tmp);
}
if (compute_red_hessian_ && redhess_internal_abort) {
jnlst_->Printf(J_WARNING, J_MAIN, "\nReduced hessian was not computed "
"because an error occured.\n"
"See exception message above for details.\n\n");
}
if (run_sens_ && sens_internal_abort) {
jnlst_->Printf(J_WARNING, J_MAIN, "\nsIPOPT was not called "
"because an error occured.\n"
"See exception message above for details.\n\n");
}
ip_nlp_->FinalizeSolution(status,
*ip_data_->curr()->x(),
*zL, *zU, *c, *d, *yc, *yd,
obj, GetRawPtr(ip_data_), GetRawPtr(ip_cq_));
}
return retval;
}