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


C++ ParameterList::addParameter方法代码示例

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


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

示例1: optimizeTreeScale

unsigned int OptimizationTools::optimizeTreeScale(
  TreeLikelihood* tl,
  double tolerance,
  unsigned int tlEvalMax,
  OutputStream* messageHandler,
  OutputStream* profiler,
  unsigned int verbose)
throw (Exception)
{
  ScaleFunction sf(tl);
  BrentOneDimension bod(&sf);
  bod.setMessageHandler(messageHandler);
  bod.setProfiler(profiler);
  ParameterList singleParameter;
  singleParameter.addParameter(Parameter("scale factor", 0));
  bod.setInitialInterval(-0.5, 0.5);
  bod.init(singleParameter);
  ParametersStopCondition PS(&bod, tolerance);
  bod.setStopCondition(PS);
  bod.setMaximumNumberOfEvaluations(tlEvalMax);
  bod.optimize();
  ApplicationTools::displayTaskDone();
  if (verbose > 0)
    ApplicationTools::displayResult("Tree scaled by", exp(sf.getParameters()[0].getValue()));
  return bod.getNumberOfEvaluations();
}
开发者ID:matsen,项目名称:bpp-phyl,代码行数:26,代码来源:OptimizationTools.cpp

示例2: LoadParameterHistory

void LoadParameterHistory()
{
    FILE* parameterFile = _wfopen(g_ParameterFileName, ACE_TEXT("r"));

    if (parameterFile != 0) {
        while (feof(parameterFile) == 0) {
            // Note: Remember that fwprintf takes wide-character format specifier but
            // save string as ASCII.  Thus, history must be read as ASCII then converted
            // to wide-character (Unicode on WinCE).
            char singleParameter[MAX_COMMAND_LINE];
            int size = 0;
            fread(&singleParameter[size], sizeof(char), 1, parameterFile);

            // WinCE does not have function that reads upto the end of line.
            while (singleParameter[size] != '\n') {
                fread(&singleParameter[++size], sizeof(char), 1, parameterFile);
            }

            if (size > 0) {
                singleParameter[size] = 0;  // NULL terminator
                g_Parameter.addParameter(singleParameter);
            }
        }
        fclose(parameterFile);
    }
}
开发者ID:CCJY,项目名称:ACE,代码行数:26,代码来源:FaCE.cpp

示例3: catch

std::shared_ptr<ComPWA::Parameter> TreeNode::recalculate() const {
  // has been changed or is lead node -> return Parameter
  if (Parameter && (!HasChanged || !ChildNodes.size()))
    return Parameter;

  std::shared_ptr<ComPWA::Parameter> result;
  if (Parameter)
    result = Parameter;

  ParameterList newVals;
  for (auto ch : ChildNodes) {
    auto p = ch->parameter();
    if (p->isParameter())
      newVals.addParameter(p);
    else
      newVals.addValue(p);
  }
  try {
    Strat->execute(newVals, result);
  } catch (std::exception &ex) {
    LOG(INFO) << "TreeNode::Recalculate() | Strategy " << Strat
               << " failed on node " << name() << ": " << ex.what();
    throw;
  }

  return result;
}
开发者ID:ComPWA,项目名称:ComPWA,代码行数:27,代码来源:TreeNode.cpp

示例4: uniRoot

double NumTools::uniRoot(Function & f, const string & param, double a, double b, double tolerance) throw (Exception)
{
  ParameterList pl;
  pl.addParameter(Parameter(param, a));
  double fa = f.f(pl);
  pl[0]->setValue(b);
  double fb = f.f(pl);
  if(fa * fb > 0.) throw Exception("NumTools::uniRoot(). Initial interval values are not of opposite sign.");
  double c = (a + b) / 2.;
  double fc;
  while(abs(fb - fa) > tolerance)
  {
    c = (a + b) / 2.; //Better use golden section here...
    pl[0]->setValue(c);
    fc = f.f(pl);
    
    if(fc * fa < 0.)
    {
      b = c;
      fb = fc;
    }
    else
    {
      a = c;
      fa = fc;
    }
  }
  return c;
}
开发者ID:pjotrp,项目名称:bio---numcalc,代码行数:29,代码来源:NumTools.cpp

示例5: lineMinimization

unsigned int OneDimensionOptimizationTools::lineMinimization(DirectionFunction & f1dim, ParameterList & parameters, vector<double> & xi, double tolerance, ostream * profiler, ostream * messenger, int verbose)
{
  // Initial guess for brackets:
  double ax = 0.;
  double xx = 0.01;
  
  f1dim.setConstraintPolicy(AutoParameter::CONSTRAINTS_AUTO);
  f1dim.setMessageHandler(messenger);
  f1dim.init(parameters, xi);
  BrentOneDimension bod(&f1dim);
  bod.setMessageHandler(messenger);
  bod.setProfiler(profiler);
  bod.setVerbose(verbose >= 1 ? 1 : 0);
  bod.setOptimizationProgressCharacter(".");
  bod.getStopCondition()->setTolerance(0.01);
  bod.setInitialInterval(ax, xx);
  bod.setConstraintPolicy(AutoParameter::CONSTRAINTS_KEEP);
  ParameterList singleParameter;
  singleParameter.addParameter(Parameter("x", 0.0));
  bod.init(singleParameter);
  bod.optimize();
  //Update parameters:
  //parameters.matchParametersValues(f1dim.getFunction()->getParameters());
  
  double xmin = f1dim.getParameters()[0]->getValue();
  for(unsigned int j = 0; j < parameters.size(); j++)
  {
    xi[j] *= xmin;
    parameters[j]->setValue(parameters[j]->getValue() + xi[j]);
  }
  return bod.getNumberOfEvaluations();
}
开发者ID:pjotrp,项目名称:bio---numcalc,代码行数:32,代码来源:OneDimensionOptimizationTools.cpp

示例6: computeBranchLengthsFromHeights_

void GlobalClockTreeLikelihoodFunctionWrapper::computeBranchLengthsFromHeights_(const Node* node, double height, ParameterList& brlenPl) throw (Exception)
{
  for (unsigned int i = 0; i < node->getNumberOfSons(); i++)
  {
    const Node* son = node->getSon(i);
    if (son->isLeaf())
    {
      brlenPl.addParameter(Parameter("BrLen" + TextTools::toString(son->getId()), std::max(0.0000011, height), new IntervalConstraint(1, 0.000001, false), true));
    }
    else
    {
      double sonHeightP = getParameter("HeightP" + TextTools::toString(son->getId())).getValue();
      double sonHeight = sonHeightP * height;
      brlenPl.addParameter(Parameter("BrLen" + TextTools::toString(son->getId()), std::max(0.0000011, height - sonHeight), new IntervalConstraint(1, 0.000001, false), true));
      computeBranchLengthsFromHeights_(son, sonHeight, brlenPl);
    }
  }
}
开发者ID:KhaosResearch,项目名称:MORPHY,代码行数:18,代码来源:GlobalClockTreeLikelihoodFunctionWrapper.cpp

示例7: lineSearch

unsigned int OneDimensionOptimizationTools::lineSearch(DirectionFunction& f1dim,
        ParameterList& parameters,
        std::vector<double>& xi,
        std::vector<double>& gradient,
        OutputStream* profiler,
        OutputStream* messenger,
        int verbose)
{
    size_t size = xi.size();

    f1dim.setConstraintPolicy(AutoParameter::CONSTRAINTS_AUTO);
    f1dim.setMessageHandler(messenger);
    f1dim.init(parameters, xi);

    double slope=0;
    for (unsigned int i=0; i<size; i++)
        slope+=xi[i]*gradient[i];

    //  if (slope>=0)
    //  throw Exception("Slope problem in OneDimensionOptimizationTools::lineSearch. Slope="+TextTools::toString(slope));

    double x, temp, test=0;
    for (unsigned int i=0; i<size; i++) {
        x=abs(parameters[i].getValue());
        temp=abs(xi[i]);
        if (x>1.0)
            temp/=x;
        if (temp>test)
            test=temp;
    }

    NewtonBacktrackOneDimension nbod(&f1dim, slope, test);

    nbod.setMessageHandler(messenger);
    nbod.setProfiler(profiler);
    nbod.setVerbose(verbose >= 1 ? 1 : 0);
    nbod.setOptimizationProgressCharacter(".");
    nbod.getStopCondition()->setTolerance(0.0001);
    //  nbod.setInitialInterval(ax, xx);
    nbod.setConstraintPolicy(AutoParameter::CONSTRAINTS_KEEP);
    ParameterList singleParameter;
    singleParameter.addParameter(Parameter("x", 0.0));
    nbod.init(singleParameter);
    nbod.optimize();
    //Update parameters:
    //parameters.matchParametersValues(f1dim.getFunction()->getParameters());

    double xmin = f1dim.getParameters()[0].getValue();
    for(unsigned int j = 0; j < parameters.size(); j++)
    {
        xi[j] *= xmin;
        parameters[j].setValue(parameters[j].getValue() + xi[j]);
    }

    return nbod.getNumberOfEvaluations();
}
开发者ID:ajnebro,项目名称:MO-Phylogenetics,代码行数:56,代码来源:OneDimensionOptimizationTools.cpp

示例8: setFreqFromData

void AbstractBiblioSubstitutionModel::setFreqFromData(const SequenceContainer& data, double pseudoCount)
{
  getModel().setFreqFromData(data, pseudoCount);
  map<string, string>::iterator it;
  ParameterList pl;
  for (it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++)
  {
    pl.addParameter(Parameter(getNamespace() + it->second, getModel().getParameterValue(getModel().getParameterNameWithoutNamespace(it->first))));
  }

  matchParametersValues(pl);
}
开发者ID:KhaosResearch,项目名称:MORPHY,代码行数:12,代码来源:AbstractBiblioSubstitutionModel.cpp

示例9: getHeightParameters

ParameterList GlobalClockTreeLikelihoodFunctionWrapper::getHeightParameters() const
{
  ParameterList pl;

  for (unsigned int i = 0; i < getNumberOfParameters(); ++i)
  {
    Parameter p = getParameter_(i);
    if (p.getName().substr(0, 7) == "HeightP" || p.getName() == "TotalHeight")
      pl.addParameter(p);
  }
  return pl;
}
开发者ID:KhaosResearch,项目名称:MORPHY,代码行数:12,代码来源:GlobalClockTreeLikelihoodFunctionWrapper.cpp

示例10: setFreq

void AbstractBiblioSubstitutionModel::setFreq(std::map<int, double>& m)
{
  getModel().setFreq(m);

  map<string, string>::iterator it;
  ParameterList pl;
  for (it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++)
  {
    pl.addParameter(Parameter(getNamespace() + it->second, getModel().getParameterValue(getModel().getParameterNameWithoutNamespace(it->first))));
  }

  matchParametersValues(pl);
}
开发者ID:KhaosResearch,项目名称:MORPHY,代码行数:13,代码来源:AbstractBiblioSubstitutionModel.cpp

示例11: getModelParameters

ParameterList SubstitutionModelSet::getModelParameters(size_t modelIndex) const
{
  ParameterList pl;
  size_t offset = stationarity_ ? 0 : rootFrequencies_->getNumberOfParameters(); // Root frequencies are the first parameters! We should ignore them here.
  for (size_t i = 0; i < modelParameterNames_.size(); i++)
    {
      // Check associations:
      const vector<size_t>* modelIndexes = &paramToModels_[i];
      for (size_t j = 0; j < modelIndexes->size(); j++)
        {
          if ((*modelIndexes)[j] == modelIndex)
            {
              pl.addParameter(getParameter_(offset + i));
              break;
            }
        }
    }
  return pl;
}
开发者ID:KhaosResearch,项目名称:MORPHY,代码行数:19,代码来源:SubstitutionModelSet.cpp

示例12: CommandLine

LRESULT CALLBACK CommandLine(HWND hDlg, UINT message, WPARAM wParam, LPARAM)
{
    int wmId;
    int wmEvent;

    switch (message)
    {
    case WM_INITDIALOG:
        g_Parameter.sendParameterMSG(hDlg, CB_INSERTSTRING);
        SetDlgItemText(hDlg, IDC_CMDEDIT, g_CommandLine);  // pass existing command line for display
        return TRUE;

    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        case IDOK:
            // new command line accepted
            GetDlgItemText(hDlg, IDC_CMDEDIT, g_CommandLine, MAX_COMMAND_LINE - 1);
            EndDialog(hDlg, wmId);
            g_Parameter.addParameter(g_CommandLine);
            return TRUE;

        case IDCANCEL:
            EndDialog(hDlg, wmId);
            return TRUE;

        default:
            return FALSE;
        }
        break;
        default:
            return FALSE;
    }

    return FALSE;
}
开发者ID:CCJY,项目名称:ACE,代码行数:39,代码来源:FaCE.cpp

示例13: testNNI

double NNIHomogeneousTreeLikelihood::testNNI(int nodeId) const throw (NodeException)
{
    const Node * son    = _tree->getNode(nodeId);
    if(!son->hasFather()) throw NodeException("DRHomogeneousTreeLikelihood::testNNI(). Node 'son' must not be the root node.", son);
    const Node * parent = son->getFather();
    if(!parent->hasFather()) throw NodeException("DRHomogeneousTreeLikelihood::testNNI(). Node 'parent' must not be the root node.", parent);
    const Node * grandFather = parent->getFather();
    //From here: Bifurcation assumed.
    //In case of multifurcation, an arbitrary uncle is chosen.
    //If we are at root node with a trifurcation, this does not matter, since 2 NNI are possible (see doc of the NNISearchable interface).
    unsigned int parentPosition = grandFather->getSonPosition(*parent);
    //const Node * uncle = grandFather->getSon(parentPosition > 1 ? parentPosition - 1 : 1 - parentPosition);
    const Node * uncle = grandFather->getSon(parentPosition > 1 ? 0 : 1 - parentPosition);

    //Retrieving arrays of interest:
    const DRASDRTreeLikelihoodNodeData * parentData = & _likelihoodData->getNodeData(parent->getId());
    const VVVdouble                    * sonArray   = & parentData->getLikelihoodArrayForNeighbor(son->getId());
    vector<const Node *> parentNeighbors = TreeTemplateTools::getRemainingNeighbors(parent, grandFather, son);
    unsigned int nbParentNeighbors = parentNeighbors.size();
    vector<const VVVdouble *> parentArrays(nbParentNeighbors);
    vector<const VVVdouble *> parentTProbs(nbParentNeighbors);
    for(unsigned int k = 0; k < nbParentNeighbors; k++)
    {
        const Node * n = parentNeighbors[k]; // This neighbor
        parentArrays[k] = & parentData->getLikelihoodArrayForNeighbor(n->getId());
        //if(n != grandFather) parentTProbs[k] = & pxy_[n->getId()];
        //else                 parentTProbs[k] = & pxy_[parent->getId()];
        parentTProbs[k] = & pxy_[n->getId()];
    }

    const DRASDRTreeLikelihoodNodeData * grandFatherData = & _likelihoodData->getNodeData(grandFather->getId());
    const VVVdouble                    * uncleArray      = & grandFatherData->getLikelihoodArrayForNeighbor(uncle->getId());
    vector<const Node *> grandFatherNeighbors = TreeTemplateTools::getRemainingNeighbors(grandFather, parent, uncle);
    unsigned int nbGrandFatherNeighbors = grandFatherNeighbors.size();
    vector<const VVVdouble *> grandFatherArrays;
    vector<const VVVdouble *> grandFatherTProbs;
    for(unsigned int k = 0; k < nbGrandFatherNeighbors; k++)
    {
        const Node * n = grandFatherNeighbors[k]; // This neighbor
        if(grandFather->getFather() == NULL || n != grandFather->getFather())
        {
            grandFatherArrays.push_back(& grandFatherData->getLikelihoodArrayForNeighbor(n->getId()));
            grandFatherTProbs.push_back(& pxy_[n->getId()]);
        }
    }

    //Compute array 1: grand father array
    VVVdouble array1 = *sonArray;
    resetLikelihoodArray(array1);
    grandFatherArrays.push_back(sonArray);
    grandFatherTProbs.push_back(& pxy_[son->getId()]);
    if(grandFather->hasFather())
    {
        computeLikelihoodFromArrays(grandFatherArrays, grandFatherTProbs, & grandFatherData->getLikelihoodArrayForNeighbor(grandFather->getFather()->getId()), & pxy_[grandFather->getId()], array1, nbGrandFatherNeighbors, nbDistinctSites_, nbClasses_, nbStates_, false);
    }
    else
    {
        computeLikelihoodFromArrays(grandFatherArrays, grandFatherTProbs, array1, nbGrandFatherNeighbors + 1, nbDistinctSites_, nbClasses_, nbStates_, false);

        //This is the root node, we have to account for the ancestral frequencies:
        for(unsigned int i = 0; i < nbDistinctSites_; i++)
        {
            for(unsigned int j = 0; j < nbClasses_; j++)
            {
                for(unsigned int x = 0; x < nbStates_; x++)
                    array1[i][j][x] *= rootFreqs_[x];
            }
        }
    }

    //Compute array 2: parent array
    VVVdouble array2 = *uncleArray;
    resetLikelihoodArray(array2);
    parentArrays.push_back(uncleArray);
    parentTProbs.push_back(& pxy_[uncle->getId()]);
    computeLikelihoodFromArrays(parentArrays, parentTProbs, array2, nbParentNeighbors + 1, nbDistinctSites_, nbClasses_, nbStates_, false);

    //Initialize BranchLikelihood:
    _brLikFunction->initModel(model_, _rateDistribution);
    _brLikFunction->initLikelihoods(&array1, &array2);
    ParameterList parameters;
    unsigned int pos = 0;
    while(pos < nodes_.size() && nodes_[pos]->getId() != parent->getId()) pos++;
    if(pos == nodes_.size()) throw Exception("NNIHomogeneousTreeLikelihood::testNNI. Unvalid node id.");
    Parameter brLen = getParameter("BrLen" + TextTools::toString(pos));
    brLen.setName("BrLen");
    parameters.addParameter(brLen);
    _brLikFunction->setParameters(parameters);

    //Re-estimate branch length:
    _brentOptimizer->setFunction(_brLikFunction);
    _brentOptimizer->getStopCondition()->setTolerance(0.1);
    _brentOptimizer->setInitialInterval(brLen.getValue(), brLen.getValue()+0.01);
    _brentOptimizer->init(parameters);
    _brentOptimizer->optimize();
    //_brLenNNIValues[nodeId] = _brLikFunction->getParameterValue("BrLen");
    _brLenNNIValues[nodeId] = _brentOptimizer->getParameters().getParameter("BrLen").getValue();
    _brLikFunction->resetLikelihoods(); //Array1 and Array2 will be destroyed after this function call.
    //We should not keep pointers towards them...

//.........这里部分代码省略.........
开发者ID:pjotrp,项目名称:biopp,代码行数:101,代码来源:NNIHomogeneousTreeLikelihood.cpp

示例14: main


//.........这里部分代码省略.........
  {
    BioNJ* bionj = new BioNJ();
    bionj->outputPositiveLengths(true);
    distMethod = bionj;
  }
  else throw Exception("Unknown tree reconstruction method.");
  
  string type = ApplicationTools::getStringParameter("optimization.method", bppdist.getParams(), "init");
  ApplicationTools::displayResult("Model parameters estimation method", type);
  if (type == "init") type = OptimizationTools::DISTANCEMETHOD_INIT;
  else if (type == "pairwise") type = OptimizationTools::DISTANCEMETHOD_PAIRWISE;
  else if (type == "iterations") type = OptimizationTools::DISTANCEMETHOD_ITERATIONS;
  else throw Exception("Unknown parameter estimation procedure '" + type + "'.");
  
	unsigned int optVerbose = ApplicationTools::getParameter<unsigned int>("optimization.verbose", bppdist.getParams(), 2);
	
	string mhPath = ApplicationTools::getAFilePath("optimization.message_handler", bppdist.getParams(), false, false);
	OutputStream* messenger = 
		(mhPath == "none") ? 0 :
			(mhPath == "std") ? ApplicationTools::message :
				new StlOutputStream(new ofstream(mhPath.c_str(), ios::out));
	ApplicationTools::displayResult("Message handler", mhPath);

	string prPath = ApplicationTools::getAFilePath("optimization.profiler", bppdist.getParams(), false, false);
	OutputStream* profiler = 
		(prPath == "none") ? 0 :
			(prPath == "std") ? ApplicationTools::message :
				new StlOutputStream(new ofstream(prPath.c_str(), ios::out));
	if(profiler) profiler->setPrecision(20);
	ApplicationTools::displayResult("Profiler", prPath);

	// Should I ignore some parameters?
  ParameterList allParameters = model->getParameters();
  allParameters.addParameters(rDist->getParameters());
	ParameterList parametersToIgnore;
  string paramListDesc = ApplicationTools::getStringParameter("optimization.ignore_parameter", bppdist.getParams(), "", "", true, false);
	bool ignoreBrLen = false;
  StringTokenizer st(paramListDesc, ",");
	while (st.hasMoreToken())
  {
		try
    {
      string param = st.nextToken();
      if (param == "BrLen")
        ignoreBrLen = true;
      else
      {
        if (allParameters.hasParameter(param))
        {
          Parameter* p = &allParameters.getParameter(param);
          parametersToIgnore.addParameter(*p);
        }
        else ApplicationTools::displayWarning("Parameter '" + param + "' not found."); 
      }
		} 
    catch (ParameterNotFoundException& pnfe)
    {
			ApplicationTools::displayError("Parameter '" + pnfe.getParameter() + "' not found, and so can't be ignored!");
		}
	}
	
	unsigned int nbEvalMax = ApplicationTools::getParameter<unsigned int>("optimization.max_number_f_eval", bppdist.getParams(), 1000000);
	ApplicationTools::displayResult("Max # ML evaluations", TextTools::toString(nbEvalMax));
	
	double tolerance = ApplicationTools::getDoubleParameter("optimization.tolerance", bppdist.getParams(), .000001);
	ApplicationTools::displayResult("Tolerance", TextTools::toString(tolerance));
开发者ID:matsen,项目名称:bppsuite,代码行数:67,代码来源:bppDist.cpp


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