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


C++ Cost类代码示例

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


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

示例1: Cost

void Car::addNewCost(QDate date, unsigned int distance, QString description, double price)
{
    Cost *cost = new Cost(date,distance,description,price,CREATE_NEW_EVENT,this);
    _costlist.append(cost);
    qSort(_costlist.begin(), _costlist.end(), sortCostByDistance);
    cost->save();
    emit costsChanged();
}
开发者ID:loisspitz,项目名称:carbudget,代码行数:8,代码来源:car.cpp

示例2: informedVector

        void PathLengthDirectInfSampler::sampleUniform(State* statePtr, const Cost& maxCost)
        {
            //Check if a solution path has been found
            if (std::isfinite(maxCost.value()) == false)
            {
                //We don't have a solution yet, we sample from our basic sampler instead...
                baseSampler_->sampleUniform(statePtr);
            }
            else //We have a solution
            {
                //Set the new transverse diameter
                phsPtr_->setTransverseDiameter(maxCost.value());

                //Check whether the problem domain (i.e., StateSpace) or PHS has the smaller measure. Sample the smaller directly and reject from the larger.
                if (informedSubSpace_->getMeasure() <= phsPtr_->getPhsMeasure())
                {
                    //The PHS is larger than the subspace, just sample from the subspace directly.
                    //Variables
                    //The informed subset of the sample as a vector
                    std::vector<double> informedVector(informedSubSpace_->getDimension());

                    //Sample from the state space until the sample is in the PHS
                    do
                    {
                        //Generate a random sample
                        baseSampler_->sampleUniform(statePtr);

                        //Is there an extra "uninformed" subspace to trim off before comparing to the PHS?
                        if ( StateSampler::space_->isCompound() == false )
                        {
                            //No, space_ == informedSubSpace_
                            informedSubSpace_->copyToReals(informedVector, statePtr);
                        }
                        else
                        {
                            //Yes, we need to do some work to extract the subspace
                            informedSubSpace_->copyToReals(informedVector, statePtr->as<CompoundState>()->components[informedIdx_]);
                        }
                    }
                    //Check if the informed state is in the PHS
                    while ( phsPtr_->isInPhs(informedSubSpace_->getDimension(), &informedVector[0]) == false );
                }
                else
                {
                    //The PHS has a smaller volume than the subspace.
                    //Sample from within the PHS until the sample is in the state space
                    do
                    {
                        this->sampleUniformIgnoreBounds(statePtr, maxCost);
                    }
                    while ( StateSampler::space_->satisfiesBounds(statePtr) == false );
                }
            }
        }
开发者ID:OspreyX,项目名称:ompl-informed,代码行数:54,代码来源:PathLengthDirectInfSampler.cpp

示例3: cost

Cost IntersectQP::cost(OperationContext &context, QueryExecutionContext &qec) const
{
	Cost result;
	Vector::const_iterator it = args_.begin();
	if(it != args_.end()) {
		result = (*it)->cost(context, qec);
		for(++it; it != args_.end(); ++it) {
			result.intersectOp((*it)->cost(context, qec));
		}
	}
	return result;
}
开发者ID:kanbang,项目名称:Colt,代码行数:12,代码来源:IntersectQP.cpp

示例4: identityCost

ompl::base::Cost ompl::base::MultiOptimizationObjective::stateCost(const State *s) const
{
    Cost c = identityCost();
    for (std::vector<Component>::const_iterator comp = components_.begin();
         comp != components_.end();
         ++comp)
    {
        c = Cost(c.value() + comp->weight * (comp->objective->stateCost(s).value()));
    }

    return c;
}
开发者ID:HRZaheri,项目名称:batch-informed-trees,代码行数:12,代码来源:OptimizationObjective.cpp

示例5: Cost_optimizeA

static void* Cost_optimizeA(void* object){
    pthread_setname_np(pthread_self(), "Athread");
    Cost* cost = (Cost*)object;
    set_affinity(3);
    cost->running_a = true;
    while(cost->running_a) {
        cost->optimizeA();

        if(allDie) {
            return 0;
        }
    }
}
开发者ID:caomw,项目名称:XTAM,代码行数:13,代码来源:optimizer.part.cpp

示例6: Cost_optimizeQD

static void* Cost_optimizeQD(void* object){
    pthread_setname_np(pthread_self(), "QDthread");
    Cost* cost = (Cost*)object;
    set_affinity(2);
    cost->running_qd = true;

    while(cost->running_a) { // A is not done
        cost->optimizeQD();

        if(allDie) {
            return 0;
        }
    }
    cost->running_qd = false;
}
开发者ID:caomw,项目名称:XTAM,代码行数:15,代码来源:optimizer.part.cpp

示例7: ticksToAvgPrice

inline double ticksToAvgPrice(Lots lots, Cost cost, const Contr& contr) noexcept
{
  double ticks = 0;
  if (lots != 0_lts) {
    ticks = fractToReal(cost.count(), lots.count());
  }
  return ticks * contr.priceInc();
}
开发者ID:swirlycloud,项目名称:swirly,代码行数:8,代码来源:Contr.hpp

示例8: cost

Cost NegativeNodePredicateFilterQP::cost(OperationContext &context, QueryExecutionContext &qec) const
{
	Cost cost = arg_->cost(context, qec);
	Cost predCost = pred_->cost(context, qec);

	// The predicate expression is run once for every argument key
// 	cost.pages += ceil(cost.keys * predCost.pages);
	cost.pagesForKeys += cost.keys * predCost.totalPages();

	// Take a token key away from the result, because it is likely to
	// return less nodes than the argument - we just don't know how many less.
	if(cost.keys > 1) cost.keys -= 1;

	// Add a token page to the result, because having a predicate takes more
	// time than not
	cost.pagesOverhead += 1;

	return cost;
}
开发者ID:cajus,项目名称:dbxml-debian,代码行数:19,代码来源:NodePredicateFilterQP.cpp

示例9: PToLie

Track::Track(Cost cost){
    rows=cost.rows;
    cols=cost.cols;
    baseImage=lastFrame=thisFrame=cost.baseImage;
    cameraMatrix=Mat(cost.cameraMatrix);
    depth=cost.depthMap();
    PToLie(Mat(cost.basePose),basePose);
    pose=basePose.clone();

}
开发者ID:caomw,项目名称:XTAM,代码行数:10,代码来源:Track.cpp

示例10: solve_nonlinear

    void solve_nonlinear () {
      for (size_t i = 0; i < signals.rows(); ++i) {
        const Math::Vector<cost_value_type> signal (signals.row(i));
        Math::Vector<cost_value_type> values (tensors.row(i));

        cost.set_voxel (&signal, &values);

        Math::Vector<cost_value_type> x (cost.size());
        cost.init (x);
        //Math::check_function_gradient (cost, x, 1e-10, true);

        Math::GradientDescent<Cost> optim (cost);
        try { optim.run (10000, 1e-8); }
        catch (Exception& E) {
          E.display();
        }

        //x = optim.state();
        //Math::check_function_gradient (cost, x, 1e-10, true);

        cost.get_values (values, optim.state());
      }
    }
开发者ID:szho42,项目名称:mrtrix3,代码行数:23,代码来源:dwi2tensor.cpp

示例11: Cost

ompl::base::Cost ompl::base::StateCostIntegralObjective::motionCost(const State *s1, const State *s2) const
{
    if (interpolateMotionCost_)
    {
        Cost totalCost = this->identityCost();

        int nd = si_->getStateSpace()->validSegmentCount(s1, s2);

        State *test1 = si_->cloneState(s1);
        Cost prevStateCost = this->stateCost(test1);
        if (nd > 1)
        {
            State *test2 = si_->allocState();
            for (int j = 1; j < nd; ++j)
            {
                si_->getStateSpace()->interpolate(s1, s2, (double)j / (double)nd, test2);
                Cost nextStateCost = this->stateCost(test2);
                totalCost = Cost(totalCost.value() +
                                 this->trapezoid(prevStateCost, nextStateCost, si_->distance(test1, test2)).value());
                std::swap(test1, test2);
                prevStateCost = nextStateCost;
            }
            si_->freeState(test2);
        }

        // Lastly, add s2
        totalCost = Cost(totalCost.value() +
                         this->trapezoid(prevStateCost, this->stateCost(s2), si_->distance(test1, s2)).value());

        si_->freeState(test1);

        return totalCost;
    }

        return this->trapezoid(this->stateCost(s1), this->stateCost(s2), si_->distance(s1, s2));
}
开发者ID:ompl,项目名称:ompl,代码行数:36,代码来源:StateCostIntegralObjective.cpp

示例12: getInformedMeasure

        double PathLengthDirectInfSampler::getInformedMeasure(const Cost& currentCost) const
        {
            //Variable
            //The measure of the informed set
            double informedMeasure;

            //The informed measure is then the measure of the PHS for the given cost:
            informedMeasure = phsPtr_->getPhsMeasure(currentCost.value());

            //And if the space is compound, further multiplied by the measure of the uniformed subspace
            if ( StateSampler::space_->isCompound() == true )
            {
                informedMeasure = informedMeasure*uninformedSubSpace_->getMeasure();
            }

            //Return the smaller of the two measures
            return std::min(StateSampler::space_->getMeasure(), informedMeasure);
        }
开发者ID:OspreyX,项目名称:ompl-informed,代码行数:18,代码来源:PathLengthDirectInfSampler.cpp

示例13: Cost

ompl::base::Cost ompl::base::OptimizationObjective::combineCosts(Cost c1, Cost c2) const
{
    return Cost(c1.value() + c2.value());
}
开发者ID:HRZaheri,项目名称:batch-informed-trees,代码行数:4,代码来源:OptimizationObjective.cpp

示例14: in

std::vector<std::pair<std::vector<uint>, std::vector<SentenceInfo>  aStar::Suchalgorithmus(char* eingabe, PTree<PTree <Cost> >* blacktree, Lexicon* eLex, Lexicon* fLex){
     igzstream in(eingabe);
     aStar::flex=fLex;
     elex=eLex;
     schwarz=blacktree;


     string token,line;

	  unsigned int lineNumber = 0;
	
     while(getline(in,line)){
	  istringstream ist(line); //Einlesen des Satzes
	  
	  vector<unsigned int> sentence_id;

	  vector<HypothesisNode> Knoten;
	  Knoten.push_back(HypothesisNode());//initialisiert den ersten Knoten
	  Cost startkosten(0);
	  Knoten[0].setBestcost(startkosten);
	  //cout << "start kosten " << Knoten[0].getBestcost().cost() << endl;
	  
	  int aktPos=0; //merkt sich, wieviele Wörter schon eingelesen wurden

	  while ( ist >> token){
	       Word word_id_french=flex->getWord_or_add(token); // das word zum Wort (mit 2 Bits Sprache)
	       unsigned int id_french= word_id_french.wordId(); //die id ohne sprachbits

	       sentence_id.push_back(id_french);
	       aktPos++;
	       
	       HypothesisNode knoten_next= HypothesisNode();//initialisiert den nächsten Knoten mit den bisherigen Kosten
	       
	       for (int laengePhrase=1; laengePhrase<5; laengePhrase++){
		    int posPhraseStart=aktPos-laengePhrase; //gibt die Pos. für den Knoten, auf dem die Phrase beginnt
		    if (posPhraseStart < 0)	break; //wir befinden uns am Satzanfang und es gibt keine Phrasen

		    vector<unsigned int> fphrase;
		    for (int i=posPhraseStart; i<aktPos; i++){
			 fphrase.push_back(sentence_id[i]);
		    }
			PTree<PTree <Cost> >* schwarzRest=schwarz->traverse(fphrase);
			if (!schwarzRest)	continue; //wenn es die französische Phrase nicht gibt, nächste überprüfen
			PTree <Cost>* blauBaum=&schwarzRest->c;
			

		    
		    if (blauBaum){
			 int counter=0; //nur fürs Programmieren, damit alle Fehler ausgemerzt werden 
			 for (PTree<Cost>::iterator it=blauBaum->begin(); it!=blauBaum->end(); it++){
			      //if (counter++==10)	continue;
			      vector<unsigned int> ephrase=it->phrase();
			      
			      Cost relfreq = it->c;
				
			      if (relfreq.cost() == 1./0. )	continue;
			      
			      double cost_till_aktPos=Knoten[posPhraseStart].getBestcost().cost();
			      
			      if (cost_till_aktPos+prune > knoten_next.getBestcost().cost())	continue; //pruning ergibt, das ist eine schlecht Übersetzung
			      
			      if(cost_till_aktPos+relfreq.cost() < knoten_next.getBestcost().cost())	knoten_next.setBestcost(Knoten[posPhraseStart].getBestcost()+relfreq.cost());
			      
			      PartialTranslation* Kante= new PartialTranslation(relfreq,ephrase,&knoten_next,posPhraseStart);
			      Knoten[posPhraseStart].add_PartialTranslation_to_Inbound(Kante);
			      knoten_next.add_PartialTranslation_to_Outbound(Kante);   
			 }
		    }
		
	       }
		if (knoten_next.getOutbound().size() == 0){
			//zuerst in das englische Lexicon einfügen
			string word_string = flex->getString(sentence_id[aktPos-1]);
			unsigned int id_english=elex->getWord_or_add(word_string);

			//dann die Kante anlegen, dabei sollen die Kosten niedrig sein, da sie sowieso genutzt werden muss, kann sie auch direkt exploriert werden
			PartialTranslation* Kante= new PartialTranslation(Cost(0),vector<unsigned int>{id_english},&Knoten[aktPos],aktPos-1);
			knoten_next.setBestcost(Knoten.back().getBestcost());
			knoten_next.add_PartialTranslation_to_Outbound(Kante);
			Knoten.back().add_PartialTranslation_to_Inbound(Kante);
		}
	       Knoten.push_back(knoten_next); //letzter Knoten (node_next) hat keine eingehenden Kanten
	       
	  }
	  
	  //dotGraph(Knoten, elex);
	  aStar astar(Knoten);
	  astar.lineNumber = lineNumber;

	  std::vector<SentenceInfo> sentenceInfos = astar.print(astar.search(), sentence_id, schwarz);
	  
	  for(unsigned int i = 0; i < Knoten.size(); i++){
		 HypothesisNode& hnode = Knoten[i];
		 for(unsigned int j = 0; j < hnode.getOutbound().size(); j++)
		 	delete hnode.getOutbound()[j];
	  }
	  
	  std::pair<std::vector<uint>, std::vector<SentenceInfo> > pair_tmp;
	  pair_tmp.first = sentence_id;
	  pair_tmp.second = sentenceInfos;
//.........这里部分代码省略.........
开发者ID:niklasfi,项目名称:mu,代码行数:101,代码来源:opt_aStar.cpp

示例15:

bool ompl::base::OptimizationObjective::isCostBetterThan(Cost c1, Cost c2) const
{
    return c1.value() < c2.value();
}
开发者ID:HRZaheri,项目名称:batch-informed-trees,代码行数:4,代码来源:OptimizationObjective.cpp


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