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


C++ DataPoint::addTag方法代码示例

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


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

示例1:

 // create data points and add to analysis
 BOOST_FOREACH(const std::vector<QVariant>& value,variableValues) {
   DataPoint dataPoint = analysis.problem().createDataPoint(value).get();
   dataPoint.addTag("DOE");
   bool added = analysis.addDataPoint(dataPoint);
   if (added) {
     ++result;
     ++totPoints;
     if (mxSim && (totPoints == mxSim.get())) {
       break;
     }
   }
 }
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:13,代码来源:DesignOfExperiments.cpp

示例2: createNextIteration

  int DesignOfExperiments_Impl::createNextIteration(Analysis& analysis) {
    int result(0);

    // to make sure problem type check has already occurred. this is stated usage in header.
    OS_ASSERT(analysis.algorithm().get() == getPublicObject<DesignOfExperiments>());
    // nothing else is supported yet
    DesignOfExperimentsOptions options = designOfExperimentsOptions();
    OS_ASSERT(options.designType() == DesignOfExperimentsType::FullFactorial);

    if (isComplete()) {
      LOG(Info,"Algorithm is already marked as complete. Returning without creating new points.");
      return result;
    }

    if (options.maxIter() && options.maxIter().get() < 1) {
      LOG(Info,"Maximum iterations set to less than one. No DataPoints will be added to Analysis '"
          << analysis.name() << "', and the Algorithm will be marked complete.");
      markComplete();
      return result;
    }

    OptionalInt mxSim = options.maxSims();
    DataPointVector dataPoints = analysis.getDataPoints("DOE");
    int totPoints = dataPoints.size();
    if (mxSim && (totPoints >= *mxSim)) {
      LOG(Info,"Analysis '" << analysis.name() << "' already contains " << totPoints
          << " DataPoints added by the DesignOfExperiments algorithm, which meets or exceeds the "
          << "maximum number specified in this algorithm's options object, " << *mxSim << ". "
          << "No data points will be added and the Algorithm will be marked complete.");
      markComplete();
      return result;
    } 

    m_iter = 1;

    // determine all combinations
    std::vector< std::vector<QVariant> > variableValues;
    for (const Variable& variable : analysis.problem().variables()) {
      // variable must be DiscreteVariable, otherwise !isCompatibleProblemType(analysis.problem())
      DiscreteVariable discreteVariable = variable.cast<DiscreteVariable>();
      IntVector dvValues = discreteVariable.validValues(true);
      std::vector< std::vector<QVariant> > currentValues = variableValues;
      for (IntVector::const_iterator it = dvValues.begin(), itEnd = dvValues.end();
           it != itEnd; ++it)
      {
        std::vector< std::vector<QVariant> > nextSet = currentValues;
        if (currentValues.empty()) {
          variableValues.push_back(std::vector<QVariant>(1u,QVariant(*it)));
        }
        else {
          for (std::vector<QVariant>& point : nextSet) {
            point.push_back(QVariant(*it));
          }
          if (it == dvValues.begin()) {
            variableValues = nextSet;
          }
          else {
            variableValues.insert(variableValues.end(),nextSet.begin(),nextSet.end());
          }
        }
      }
    }

    // create data points and add to analysis
    for (const std::vector<QVariant>& value : variableValues) {
      DataPoint dataPoint = analysis.problem().createDataPoint(value).get();
      dataPoint.addTag("DOE");
      bool added = analysis.addDataPoint(dataPoint);
      if (added) {
        ++result;
        ++totPoints;
        if (mxSim && (totPoints == mxSim.get())) {
          break;
        }
      }
    }

    if (result == 0) {
      LOG(Trace,"No new points were added, so marking this DesignOfExperiments complete.");
      markComplete();
    }

    return result;
  }
开发者ID:CheyenneBerlin,项目名称:OpenStudio,代码行数:84,代码来源:DesignOfExperiments.cpp


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