本文整理汇总了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;
}
}
示例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);
}
}
示例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;
}
示例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());
}
示例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);
}
}
示例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;
}
示例7: while
Queue::~Queue()
{
if (!first) return;
QNode *ce = first;
while (ce->has_next()) {
QNode *tmp = ce;
ce = ce->next();
delete tmp;
}
delete ce;
}
示例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();
}
示例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;
}
示例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 ++;
}
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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;
}