当前位置: 首页>>代码示例>>C++>>正文


C++ SampleGenerator类代码示例

本文整理汇总了C++中SampleGenerator的典型用法代码示例。如果您正苦于以下问题:C++ SampleGenerator类的具体用法?C++ SampleGenerator怎么用?C++ SampleGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SampleGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getHessVec

  void getHessVec(Vector<Real> &hv, SampleGenerator<Real> &sampler) {
    Real one(1);
    std::vector<Real> myval(5,0), val(5,0);
    myval[0] = RiskMeasure<Real>::val_;
    myval[1] = RiskMeasure<Real>::gv_;
    myval[2] = dval1_;
    myval[3] = dval2_;
    myval[4] = dval3_;
    sampler.sumAll(&myval[0],&val[0],5);

    Real xs2 = xstat_*xstat_;
    Real xs3 = xs2*xstat_;
    Real v02 = val[0]*val[0];
    Real h11 = (val[3]*val[0] - val[2]*val[2])/(v02*xs3) * vstat_;
    Real h12 = (val[1]*val[2] - val[4]*val[0])/(v02*xs2); 

    sampler.sumAll(*(RiskMeasure<Real>::hv_),*dualVector1_);
    sampler.sumAll(*scaledGradient1_,*dualVector2_);
    dualVector1_->axpy(one/xstat_,*dualVector2_);
    dualVector1_->scale(one/val[0]);
    dualVector2_->zero();
    sampler.sumAll(*(RiskMeasure<Real>::g_),*dualVector2_);
    dualVector1_->axpy(vstat_*val[2]/(xs2*v02)-val[1]/(v02*xstat_),*dualVector2_);
    dualVector2_->zero();
    sampler.sumAll(*scaledGradient2_,*dualVector2_);
    dualVector1_->axpy(-vstat_/val[0],*dualVector2_);

    (Teuchos::dyn_cast<RiskVector<Real> >(hv)).setVector(*dualVector1_);
    (Teuchos::dyn_cast<RiskVector<Real> >(hv)).setStatistic(h11+h12);
  }
开发者ID:agrippa,项目名称:Trilinos,代码行数:30,代码来源:ROL_CoherentExpUtility.hpp

示例2: getHessVec

  void getHessVec(Vector<Real> &hv, SampleGenerator<Real> &sampler) {
    RiskVector<Real> &hs = Teuchos::dyn_cast<RiskVector<Real> >(hv);
    std::vector<Real> var(2);
    sampler.sumAll(&vec_[0],&var[0],2);

    sampler.sumAll(*(RiskMeasure<Real>::hv_),*dualVector_);
    hs.setStatistic(var);
    hs.setVector(*dualVector_);
  }
开发者ID:mhoemmen,项目名称:Trilinos,代码行数:9,代码来源:ROL_QuantileRadiusQuadrangle.hpp

示例3: getGradient

    void getGradient(Vector<Real> &g, SampleGenerator<Real> &sampler) {
        Real val = RiskMeasure<Real>::val_, ev(0), one(1);
        sampler.sumAll(&val,&ev,1);

        sampler.sumAll(*(RiskMeasure<Real>::g_),*dualVector1_);
        dualVector1_->scale(one/ev);

        (Teuchos::dyn_cast<RiskVector<Real> >(g)).setVector(*dualVector1_);
    }
开发者ID:uppatispr,项目名称:trilinos-official,代码行数:9,代码来源:ROL_ExpUtility.hpp

示例4: getHessVec

  void getHessVec(Vector<Real> &hv, SampleGenerator<Real> &sampler) {
    RiskVector<Real> &hs = Teuchos::dyn_cast<RiskVector<Real> >(hv);
    Real val = RiskMeasure<Real>::val_, var(0), one(1);
    sampler.sumAll(&val,&var,1);

    sampler.sumAll(*(RiskMeasure<Real>::hv_),*dualVector_);
    var *= coeff_/(one-prob_);
    hs.setStatistic(var);
    hs.setVector(*dualVector_);
  }
开发者ID:agrippa,项目名称:Trilinos,代码行数:10,代码来源:ROL_CVaR.hpp

示例5: getGradient

 void getGradient(Vector<Real> &g, SampleGenerator<Real> &sampler) {
   RiskVector<Real> &gs = Teuchos::dyn_cast<RiskVector<Real> >(g);
   Real val = RiskMeasure<Real>::val_, var(0), one(1);
   sampler.sumAll(&val,&var,1);
   
   sampler.sumAll(*(RiskMeasure<Real>::g_),*dualVector_);
   var *= -coeff_/(one-prob_);
   var += coeff_;
   gs.setStatistic(var);
   gs.setVector(*dualVector_); 
 }
开发者ID:agrippa,项目名称:Trilinos,代码行数:11,代码来源:ROL_CVaR.hpp

示例6: getValue

 Real getValue(SampleGenerator<Real> &sampler) {
   Real val = RiskMeasure<Real>::val_;
   Real dev = 0.0;
   sampler.sumAll(&val,&dev,1);
   std::vector<Real> pval_sum(NumMoments_);
   sampler.sumAll(&(pval_)[0],&pval_sum[0],NumMoments_);
   for ( uint p = 0; p < NumMoments_; p++ ) {
     dev += coeff_[p] * std::pow(pval_sum[p],1.0/order_[p]);
   }
   return dev;
 }
开发者ID:Russell-Jones-OxPhys,项目名称:Trilinos,代码行数:11,代码来源:ROL_MeanDeviationFromTarget.hpp

示例7: getGradient

 void getGradient(Vector<Real> &g, SampleGenerator<Real> &sampler) {
   Real half(0.5);
   RiskVector<Real> &gs = Teuchos::dyn_cast<RiskVector<Real> >(g);
   std::vector<Real> var(2);
   sampler.sumAll(&vec_[0],&var[0],2);
   
   sampler.sumAll(*(RiskMeasure<Real>::g_),*dualVector_);
   var[0] += half*coeff_;
   var[1] += half*coeff_;
   gs.setStatistic(var);
   gs.setVector(*dualVector_); 
 }
开发者ID:mhoemmen,项目名称:Trilinos,代码行数:12,代码来源:ROL_QuantileRadiusQuadrangle.hpp

示例8: getGradient

 void getGradient(Vector<Real> &g, SampleGenerator<Real> &sampler) {
   RiskVector<Real> &gs = Teuchos::dyn_cast<RiskVector<Real> >(g);
   std::vector<Real> var(size_);
   sampler.sumAll(&vec_[0],&var[0],size_);
   
   sampler.sumAll(*(RiskMeasure<Real>::g_),*dualVector_);
   for (int i = 0; i < size_; i++) {
     var[i] += coeff_[i];
   }
   gs.setStatistic(var);
   gs.setVector(*dualVector_); 
 }
开发者ID:mhoemmen,项目名称:Trilinos,代码行数:12,代码来源:ROL_MixedQuantileQuadrangle.hpp

示例9: getHessVec

  void getHessVec(Vector<Real> &hv, SampleGenerator<Real> &sampler) {
    RiskVector<Real> &hs = Teuchos::dyn_cast<RiskVector<Real> >(hv);
    std::vector<Real> var(size_);
    sampler.sumAll(&vec_[0],&var[0],size_);

    sampler.sumAll(*(RiskMeasure<Real>::hv_),*dualVector_);
//    for (int i = 0; i < size_; i++) {
//      var[i] *= coeff_[i]/(1.0-prob_[i]);
//    }
    hs.setStatistic(var);
    hs.setVector(*dualVector_);
  }
开发者ID:mhoemmen,项目名称:Trilinos,代码行数:12,代码来源:ROL_MixedQuantileQuadrangle.hpp

示例10: getGradient

 void getGradient(Vector<Real> &g, SampleGenerator<Real> &sampler) {
   sampler.sumAll(*(RiskMeasure<Real>::g_),*dualVector1_);
   std::vector<Real> pval_sum(NumMoments_);
   sampler.sumAll(&(pval_)[0],&pval_sum[0],NumMoments_);
   Teuchos::RCP<Vector<Real> > pg;
   for ( uint p = 0; p < NumMoments_; p++ ) {
     if ( pval_sum[p] > 0.0 ) {
       pg = (pg_[p])->clone();
       sampler.sumAll(*(pg_[p]),*pg);
       dualVector1_->axpy(coeff_[p]/std::pow(pval_sum[p],1.0-1.0/order_[p]),*pg);
     }
   }
   // Set RiskVector
   (Teuchos::dyn_cast<RiskVector<Real> >(g)).setVector(*dualVector1_);
 }
开发者ID:Russell-Jones-OxPhys,项目名称:Trilinos,代码行数:15,代码来源:ROL_MeanDeviationFromTarget.hpp

示例11: getGradient

 void getGradient(Vector<Real> &g, SampleGenerator<Real> &sampler) {
   Real one(1);
   // Perform sum over batches
   std::vector<Real> myval(2,0), val(2,0);
   myval[0] = RiskMeasure<Real>::val_;
   myval[1] = RiskMeasure<Real>::gv_;
   sampler.sumAll(&myval[0],&val[0],2);
   sampler.sumAll(*(RiskMeasure<Real>::g_),*dualVector1_);
   // Compute partial derivatives
   Real gstat = std::log(myval[0]) - myval[1]/(myval[0]*xstat_);
   dualVector1_->scale(one/myval[0]);
   // Set partial derivatives in g vector
   (Teuchos::dyn_cast<RiskVector<Real> >(g)).setVector(*dualVector1_);
   (Teuchos::dyn_cast<RiskVector<Real> >(g)).setStatistic(gstat);
 }
开发者ID:agrippa,项目名称:Trilinos,代码行数:15,代码来源:ROL_CoherentExpUtility.hpp

示例12: getGradient

  void getGradient(Vector<Real> &g, SampleGenerator<Real> &sampler) {
    RiskVector<Real> &gs = Teuchos::dyn_cast<RiskVector<Real> >(g);

    std::vector<Real> mygval(3,0.0), gval(3,0.0);
    mygval[0] = RiskMeasure<Real>::val_;
    mygval[1] = valLam_;
    mygval[2] = valMu_;
    sampler.sumAll(&mygval[0],&gval[0],3);

    std::vector<Real> stat(2,0.0);
    stat[0] = thresh_ + gval[0] + gval[1];
    stat[1] = (Real)1 + gval[2];
    gs.setStatistic(stat);

    sampler.sumAll(*(RiskMeasure<Real>::g_),*dualVector_);
    gs.setVector(*dualVector_);
  }
开发者ID:Russell-Jones-OxPhys,项目名称:Trilinos,代码行数:17,代码来源:ROL_FDivergence.hpp

示例13: getValue

 Real getValue(SampleGenerator<Real> &sampler) {
   Real val  = RiskMeasure<Real>::val_, cvar(0);
   sampler.sumAll(&val,&cvar,1);
   for (int i = 0; i < size_; i++) {
     cvar += coeff_[i]*xvar_[i];
   }
   return cvar;
 }
开发者ID:mhoemmen,项目名称:Trilinos,代码行数:8,代码来源:ROL_MixedQuantileQuadrangle.hpp

示例14: getHessVec

    void getHessVec(Vector<Real> &hv, SampleGenerator<Real> &sampler) {
        Real one(1);
        std::vector<Real> myval(2), val(2);
        myval[0] = RiskMeasure<Real>::val_;
        myval[1] = RiskMeasure<Real>::gv_;
        sampler.sumAll(&myval[0],&val[0],2);

        sampler.sumAll(*(RiskMeasure<Real>::hv_),*dualVector1_);

        sampler.sumAll(*scaledGradient_,*dualVector2_);
        dualVector1_->axpy(coeff_,*dualVector2_);
        dualVector1_->scale(one/val[0]);

        dualVector2_->zero();
        sampler.sumAll(*(RiskMeasure<Real>::g_),*dualVector2_);
        dualVector1_->axpy(coeff_*val[1]/(val[0]*val[0]),*dualVector2_);

        (Teuchos::dyn_cast<RiskVector<Real> >(hv)).setVector(*dualVector1_);
    }
开发者ID:uppatispr,项目名称:trilinos-official,代码行数:19,代码来源:ROL_ExpUtility.hpp

示例15: getHessVec

  void getHessVec(Vector<Real> &hv, SampleGenerator<Real> &sampler) {
    RiskVector<Real> &hs = Teuchos::dyn_cast<RiskVector<Real> >(hv);

    std::vector<Real> myhval(5,0.0), hval(5,0.0);
    myhval[0] = RiskMeasure<Real>::val_;
    myhval[1] = valLam_;
    myhval[2] = valLam2_;
    myhval[3] = valMu_;
    myhval[4] = valMu2_;
    sampler.sumAll(&myhval[0],&hval[0],5);

    std::vector<Real> stat(2,0.0);
    stat[0] = (vlam_ * hval[1] + vmu_ * hval[0] + hval[2])/xlam_;
    stat[1] = (vlam_ * hval[0] + vmu_ * hval[3] + hval[4])/xlam_;
    hs.setStatistic(stat);

    sampler.sumAll(*(RiskMeasure<Real>::hv_),*dualVector_);
    hs.setVector(*dualVector_);
  }
开发者ID:Russell-Jones-OxPhys,项目名称:Trilinos,代码行数:19,代码来源:ROL_FDivergence.hpp


注:本文中的SampleGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。