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


C++ QNode类代码示例

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


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

示例1: Update

void DESPOT::Update(VNode* vnode) {
	if (vnode->IsLeaf()) {
		return;
	}

	double lower = vnode->default_move().value;
	double upper = vnode->default_move().value;
	double utility_upper = Globals::NEG_INFTY;

	for (int action = 0; action < vnode->children().size(); action++) {
		QNode* qnode = vnode->Child(action);

		lower = max(lower, qnode->lower_bound());
		upper = max(upper, qnode->upper_bound());
		utility_upper = max(utility_upper, qnode->utility_upper_bound);
	}

	if (lower > vnode->lower_bound()) {
		vnode->lower_bound(lower);
	}
	if (upper < vnode->upper_bound()) {
		vnode->upper_bound(upper);
	}
	if (utility_upper < vnode->utility_upper_bound) {
		vnode->utility_upper_bound = utility_upper;
	}
}
开发者ID:karkuspeter,项目名称:CS6244,代码行数:27,代码来源:despot.cpp

示例2: Q_Q

void QNodePrivate::propertyChanged(int propertyIndex)
{
    // Bail out early if we can to avoid the cost below
    if (m_blockNotifications)
        return;

    Q_Q(QNode);

    const QMetaProperty property = q->metaObject()->property(propertyIndex);

    const QVariant data = property.read(q);
    if (data.canConvert<QNode*>()) {
        QNode *node = data.value<QNode*>();

        // Ensure the node has issued a node creation change. We can end
        // up here if a newly created node with a parent is immediately set
        // as a property on another node. In this case the deferred call to
        // _q_postConstructorInit() will not have happened yet as the event
        // loop will still be blocked. So force it here and we catch this
        // eventuality in the _q_postConstructorInit() function so that we
        // do not repeat the creation and new child scene change events.
        if (node)
            QNodePrivate::get(node)->_q_postConstructorInit();

        const QNodeId id = node ? node->id() : QNodeId();
        notifyPropertyChange(property.name(), QVariant::fromValue(id));
    } else {
        notifyPropertyChange(property.name(), data);
    }
}
开发者ID:RSATom,项目名称:Qt,代码行数:30,代码来源:qnode.cpp

示例3: main

int main(int argc, char *argv[]){
    
    int numThreads = atoi(argv[1]);
    threshold = atoi(argv[2]);
    int levels = atoi(argv[3]);
    int * participantsAtLevel = (int * ) malloc(levels);
    for (int i = 0; i < levels; i++) {
        participantsAtLevel[i] = atoi(argv[4 + i]);
    }
    
    omp_set_num_threads(numThreads);
    
    int numIter = 144 * (0x4ffff) / numThreads;

        //int levels = 4;
        //int participantsAtLevel[] = {2, 4, 8, 16};
        //omp_set_num_threads(16);
        //int levels = 2;
        //int participantsAtLevel[] = {12, 36};
        //omp_set_num_threads(36);
    
    //int levels = 2;
    //int participantsAtLevel[] = {2, 4};
    //omp_set_num_threads(4);
    
    struct timeval start;
    struct timeval end;
    uint64_t elapsed;
    
#pragma omp parallel
    {
        int tid = omp_get_thread_num();
        int size = omp_get_num_threads();
        HMCS * hmcs = LockInit(tid, size, levels, participantsAtLevel);
        
        if(tid == 0)
            gettimeofday(&start, 0);
        
        QNode me;
        for(int i = 0; i < numIter; i++) {
            me.Reuse();
            Acquire(hmcs, &me);
            //printf("Acquired %d!\n", tid);
//#define VALIDATE
#ifdef VALIDATE
            int lvar = var;
            var ++;
            assert(var == lvar + 1);
#endif
            Release(hmcs, &me);
            
        }
    }
    gettimeofday(&end, 0);
    elapsed = TIME_SPENT(start, end);
    double throughPut = (numIter * numThreads * 144 * 0x4ffffL) * 100000.0 / elapsed;
    std::cout<<"\n Throughput = " << throughPut;
    return 0;
}
开发者ID:chabbimilind,项目名称:nwchem,代码行数:59,代码来源:hmcs.ibm.cpp

示例4: while

ValuedAction DESPOT::Evaluate(VNode* root, vector<State*>& particles,
	RandomStreams& streams, POMCPPrior* prior, const DSPOMDP* model) {
	double value = 0;

	for (int i = 0; i < particles.size(); i++) {
		particles[i]->scenario_id = i;
	}

	for (int i = 0; i < particles.size(); i++) {
		State* particle = particles[i];
		VNode* cur = root;
		State* copy = model->Copy(particle);
		double discount = 1.0;
		double val = 0;
		int steps = 0;

		while (!streams.Exhausted()) {
			int action =
				(cur != NULL) ?
					OptimalAction(cur).action : prior->GetAction(*copy);

			assert(action != -1);

			double reward;
			OBS_TYPE obs;
			bool terminal = model->Step(*copy, streams.Entry(copy->scenario_id),
				action, reward, obs);

			val += discount * reward;
			discount *= Discount();

			if (!terminal) {
				prior->Add(action, obs);
				streams.Advance();
				steps++;

				if (cur != NULL && !cur->IsLeaf()) {
					QNode* qnode = cur->Child(action);
					map<OBS_TYPE, VNode*>& vnodes = qnode->children();
					cur = vnodes.find(obs) != vnodes.end() ? vnodes[obs] : NULL;
				}
			} else {
				break;
			}
		}

		for (int i = 0; i < steps; i++) {
			streams.Back();
			prior->PopLast();
		}

		model->Free(copy);

		value += val;
	}

	return ValuedAction(OptimalAction(root).action, value / particles.size());
}
开发者ID:karkuspeter,项目名称:CS6244,代码行数:58,代码来源:despot.cpp

示例5: Q_D

// Main Thread
void QPostman::notifyFrontendNode(const QSceneChangePtr &e)
{
    Q_D(QPostman);
    if (!e.isNull() && d->m_scene != nullptr) {
        QNode *n = d->m_scene->lookupNode(e->subjectId());
        if (n != nullptr)
            n->sceneChangeEvent(e);
    }
}
开发者ID:RSATom,项目名称:Qt,代码行数:10,代码来源:qpostman.cpp

示例6:

double AEMS::AEMS2Likelihood(QNode* qnode) {
	VNode* vnode = qnode->parent();
	QNode* qstar = NULL;
	for (int action = 0; action < vnode->children().size(); action++) {
		QNode* child = vnode->Child(action);

		if (qstar == NULL || child->upper_bound() > qstar->upper_bound())
			qstar = child;
	}

	return qstar == qnode;
}
开发者ID:karkuspeter,项目名称:CS6244,代码行数:12,代码来源:aems.cpp

示例7: while

Queue::~Queue()
{
  if (!first) return;

  QNode *ce = first;
  while (ce->has_next()) {
    QNode *tmp = ce;
    ce = ce->next();
    delete tmp;
  }
  delete ce;
}
开发者ID:BackupTheBerlios,项目名称:linjap,代码行数:12,代码来源:Queue.cpp

示例8: PolicyTreeSize

int VNode::PolicyTreeSize() const {
	if (children_.size() == 0)
		return 0;

	QNode* best = NULL;
	for (int a = 0; a < children_.size(); a++) {
		QNode* child = children_[a];
		if (best == NULL || child->lower_bound() > best->lower_bound())
			best = child;
	}
	return best->PolicyTreeSize();
}
开发者ID:karkuspeter,项目名称:CS6244,代码行数:12,代码来源:node.cpp

示例9: parentNode

/*!
    Returns a pointer to the parent.
 */
QFrameGraphNode *QFrameGraphNode::parentFrameGraphNode() const
{
    QFrameGraphNode *parentFGNode = nullptr;
    QNode *parentN = parentNode();

    while (parentN) {
        if ((parentFGNode = qobject_cast<QFrameGraphNode *>(parentN)) != nullptr)
            break;
        parentN = parentN->parentNode();
    }
    return parentFGNode;
}
开发者ID:RSATom,项目名称:Qt,代码行数:15,代码来源:qframegraphnode.cpp

示例10: while

void QuadTreeObject::upDateQuadTree(RECT screen)
{
	//this->upDateQNode(this->root);

	//duyet listObjectInMap. Nhung Object nao ko ton tai thi xoa di
	std::hash_map< int, ObjectGame*>::iterator it = this->mapObject.listObjectInMap.begin();
	ObjectGame* obj = NULL;
	while (it != this->mapObject.listObjectInMap.end())
	{
		obj = it->second;
		if (!obj->_isALive)
		{
			//xoa object ra khoi quadtree
			this->eraseObject(it->first);

			//xoa khoi listObj
			it = this->mapObject.listObjectInMap.erase(it);
			//xoa IDHashMap cua Object ra khoi Quadtree
			//it++;
		
		}else
		{
			//neu van thuoc trong man hinh ma la enemy thi kiem tra no con va cham voi node chua no ko
			if (obj->className() == TagClassName::getInstance()->tagEnemy)
			{
				//tim nhung node co chua no
				QNode* node = NULL;
				//duyet tat ca node. 
				for (std::hash_map< int, QNode*>::iterator itNode = this->listQNode.begin(); itNode != listQNode.end();)
				{
					node = itNode->second;
					int ID_HashMapOfObj = it->first;
					if (node->findIDObj(it->first))
					{
						//neu node co chua enemy thi kiem tra enemy co con nam trong do ko? neu ko thi xoa va add vao lai
						if (!QNode::isBound(node->rect, obj->getRect()))
						{
							//neu node ko con chua obj nua
							this->eraseObject(it->first);
							
							//sau do add vao lai node root
							this->addObjectToNode(this->root, obj, it->first);
						}
					}
					itNode++;
				}
			}

			it ++;
		}

	}
}
开发者ID:doanhtdpl,项目名称:game-cashtle-vania,代码行数:53,代码来源:QuadTreeObject.cpp

示例11: ExploitBlockers

VNode* DESPOT::Trial(VNode* root, RandomStreams& streams,
	ScenarioLowerBound* lower_bound, ScenarioUpperBound* upper_bound,
	const DSPOMDP* model, History& history, SearchStatistics* statistics) {
	VNode* cur = root;

	int hist_size = history.Size();

	do {
		if (statistics != NULL
			&& cur->depth() > statistics->longest_trial_length) {
			statistics->longest_trial_length = cur->depth();
		}

		ExploitBlockers(cur);

		if (Gap(cur) == 0) {
			break;
		}

		if (cur->IsLeaf()) {
			double start = clock();
			Expand(cur, lower_bound, upper_bound, model, streams, history);

			if (statistics != NULL) {
				statistics->time_node_expansion += (double) (clock() - start)
					/ CLOCKS_PER_SEC;
				statistics->num_expanded_nodes++;
				statistics->num_tree_particles += cur->particles().size();
			}
		}

		double start = clock();
		QNode* qstar = SelectBestUpperBoundNode(cur);
		VNode* next = SelectBestWEUNode(qstar);

		if (statistics != NULL) {
			statistics->time_path += (clock() - start) / CLOCKS_PER_SEC;
		}

		if (next == NULL) {
			break;
		}

		cur = next;
		history.Add(qstar->edge(), cur->edge());
	} while (cur->depth() < Globals::config.search_depth && WEU(cur) > 0);

	history.Truncate(hist_size);

	return cur;
}
开发者ID:karkuspeter,项目名称:CS6244,代码行数:51,代码来源:despot.cpp

示例12: Child

void VNode::Free(const DSPOMDP& model) {
	for (int i = 0; i < particles_.size(); i++) {
		model.Free(particles_[i]);
	}

	for (int a = 0; a < children().size(); a++) {
		QNode* qnode = Child(a);
		map<OBS_TYPE, VNode*>& children = qnode->children();
		for (map<OBS_TYPE, VNode*>::iterator it = children.begin();
			it != children.end(); it++) {
			it->second->Free(model);
		}
	}
}
开发者ID:karkuspeter,项目名称:CS6244,代码行数:14,代码来源:node.cpp

示例13: SelectBestUpperBoundNode

QNode* DESPOT::SelectBestUpperBoundNode(VNode* vnode) {
	int astar = -1;
	double upperstar = Globals::NEG_INFTY;
	for (int action = 0; action < vnode->children().size(); action++) {
		QNode* qnode = vnode->Child(action);

		if (qnode->upper_bound() > upperstar) {
			upperstar = qnode->upper_bound();
			astar = action;
		}
	}
	assert(astar >= 0);
	return vnode->Child(astar);
}
开发者ID:karkuspeter,项目名称:CS6244,代码行数:14,代码来源:despot.cpp

示例14: astar

ValuedAction DESPOT::OptimalAction(VNode* vnode) {
	ValuedAction astar(-1, Globals::NEG_INFTY);
	for (int action = 0; action < vnode->children().size(); action++) {
		QNode* qnode = vnode->Child(action);
		if (qnode->lower_bound() > astar.value) {
			astar = ValuedAction(action, qnode->lower_bound());
		}
	}

	if (vnode->default_move().value > astar.value) {
		astar = vnode->default_move();
	}

	return astar;
}
开发者ID:karkuspeter,项目名称:CS6244,代码行数:15,代码来源:despot.cpp

示例15:

const char *QTextContainer::getText(QAbstractPlayer *ctx) {
	// Need to deal with locales
	if (!subnodes) return NULL;

	for (int i=0;i<subnodeCount;i++) {
		QNode *n = subnodes[i];
		if (n->getType() == NODETYPE_TEXT) {
			QText *t = (QText*)n;
			const char *str = t->getText();
			return ctx ? ctx->replaceVariables(str) : str;
		}
	}
	
	return NULL;
}
开发者ID:jeowen,项目名称:ptsdFamilyCoachSupport,代码行数:15,代码来源:QTextContainer.cpp


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