void TLFrame::setUseProperties( TLFrame *in_frame ) { Q_CHECK_PTR( in_frame ); setUsed( in_frame -> isUsed() ); setKey( in_frame -> isKey() ); setLast( in_frame -> isLast() ); setUnknownMotion( in_frame -> isUnknownMotion() ); setMotion( in_frame -> isMotion() ); setHasDrawing( in_frame -> hasDrawing() ); }
returnValue SCPmethod::printIteration( ) { double KKTmultiplierRegularisation; get( KKT_TOLERANCE_SAFEGUARD,KKTmultiplierRegularisation ); setLast( LOG_NUM_SQP_ITERATIONS, numberOfSteps ); setLast( LOG_KKT_TOLERANCE, eval->getKKTtolerance( iter,bandedCP,KKTmultiplierRegularisation ) ); setLast( LOG_OBJECTIVE_VALUE, eval->getObjectiveValue() ); int printLevel; get( PRINTLEVEL,printLevel ); if ( (PrintLevel)printLevel >= MEDIUM ) printLogRecord( outputLoggingIdx,PRINT_LAST_ITER ); replot( PLOT_AT_EACH_ITERATION ); return SUCCESSFUL_RETURN; }
void nsFrameIterator::Next() { // recursive-oid method to get next frame nsIFrame *result = nsnull; nsIFrame *parent = getCurrent(); if (!parent) parent = getLast(); if (mType == eLeaf) { // Drill down to first leaf while ((result = GetFirstChild(parent))) { parent = result; } } else if (mType == ePreOrder) { result = GetFirstChild(parent); if (result) parent = result; } if (parent != getCurrent()) { result = parent; } else { while (parent) { result = GetNextSibling(parent); if (result) { if (mType != ePreOrder) { parent = result; while ((result = GetFirstChild(parent))) { parent = result; } result = parent; } break; } else { result = GetParentFrameNotPopup(parent); if (!result || IsRootFrame(result) || (mLockScroll && result->GetType() == nsGkAtoms::scrollFrame)) { result = nsnull; break; } if (mType == ePostOrder) break; parent = result; } } } setCurrent(result); if (!result) { setOffEdge(1); setLast(parent); } }
void TLFrame::setUsed( bool in_is_used ) { is_used = in_is_used; if ( !is_used ) { setKey( false ); setLast( false ); setHasDrawing( false ); } update(); }
returnValue SCPmethod::stopClockAndPrintRuntimeProfile( ) { clockTotalTime.stop( ); setLast( LOG_TIME_SQP_ITERATION,clockTotalTime.getTime() ); int printProfile; get( PRINT_SCP_METHOD_PROFILE, printProfile ); if( (BooleanType) printProfile == BT_TRUE ) printRuntimeProfile(); return SUCCESSFUL_RETURN; }
Node<T> List<T>::popLast() { if (hasLast()) { Node<T> oldLast = *getLast(); if (getFirst() == getLast()) { setFirst(NULL); } delete getLast(); if (oldLast.hasPrev()) { oldLast.getPrev()->setNext(NULL); setLast(oldLast.getPrev()); } else { setLast(NULL); } return oldLast; } return NULL; }
size_t TileNode::hashSingle(const SpatialDimension* hashing, Data& data, response_container& response, ulong zoom) { size_t count = 0; if (zoom < hashing->maxZoom() && _pivot.size() > hashing->min_per_node()) { std::map <std::pair<uint32_t, uint32_t>, uint32_t> used; zoom += 1; for (auto i = _pivot.front(); i < _pivot.back(); ++i) { ulong y = util::lat2tiley(data.getFloatProperty(i, 0), zoom); ulong x = util::lon2tilex(data.getFloatProperty(i, 1), zoom); used[std::make_pair(x, y)]++; data.setHash(i, getIndex(x, y)); } // sorting data.sortHash(_pivot.front(), _pivot.back()); int accum = _pivot.front(); int first, second; for (auto& pair : used) { if (pair.second == 0) continue; first = accum; accum += pair.second; second = accum; ulong x = pair.first.first; ulong y = pair.first.second; ulong index = getIndex(x, y); count++; _container[index] = (std::make_unique<TileNode>(TileNode(TilePivot(first, second, tile_t(x, y, zoom))))); count += _container[index]->hashSingle(hashing, data, response, zoom); } } else { response.emplace_back(&_pivot); setLast(); } return count; }
nsFrameIterator::nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart, nsIteratorType aType, PRBool aLockInScrollView, PRBool aFollowOOFs) { mOffEdge = 0; mPresContext = aPresContext; if (aFollowOOFs && aStart) aStart = nsPlaceholderFrame::GetRealFrameFor(aStart); setStart(aStart); setCurrent(aStart); setLast(aStart); mType = aType; SetLockInScrollView(aLockInScrollView); mFollowOOFs = aFollowOOFs; }
void Family::adopt(LmerVector *v, uint L){ v->setFamily(this); //cout << L << endl; if (vectors.size() > 0){ uint off = v->front() - vectors.back()->front(); addToOffset(off - 1); setRepeatLength(getRepeatLength() + off); } else{ setRepeatLength(L); setOffset(0); } vectors.push_back(v); setLast(v); setExpectedEnd(v->back() + L); }
QtlRange& QtlRange::clip(const QtlRange& range) { const qint64 rangeLast = range.last(); if (_first > rangeLast) { _first = rangeLast + 1; // never overflow since rangeLast < _first, so rangeLast is not qint64'last. _count = 0; } else { const qint64 thisLast = this->last(); if (_first < range._first) { _first = range._first; } setLast(qMin(thisLast, rangeLast)); } return *this; }
/** * @brief Allocate a contiguous range of blocks * @brief heap_state Pointer to the heap state related to the heap to use. * @brief block The starting block from where to originate the allocation. * @brief blocks The number of blocks to allocate. * @return A pointer to the first byte of the allocated blocks, or NULL. */ static void* allocate(heap_state_t* heap_state, register int32_t block, register int32_t blocks) { void* pointer=NULL; if ( valid(heap_state,block) ) { for(register int32_t n=0; n < blocks; n++) /* flag blocks in use... */ { set(heap_state,block+n); resetLast(heap_state,block+n); ++heap_state->heap_blocks_allocated; } setLast(heap_state,(block+blocks)-1); pointer = to_pointer(heap_state,block); /* fetch the base pointer */ notify_heap_alloc(blocks); } return pointer; }
returnValue QPsolver_qpOASES::solve( double* H, double* A, double* g, double* lb, double* ub, double* lbA, double* ubA, uint maxIter ) { if ( qp == 0 ) return ACADOERROR( RET_INITIALIZE_FIRST ); /* call to qpOASES, using hotstart if possible and desired */ numberOfSteps = maxIter; qpOASES::returnValue returnvalue; qpStatus = QPS_SOLVING; //printf( "nV: %d, nC: %d \n",qp->getNV(),qp->getNC() ); if ( (bool)qp->isInitialised( ) == false ) { returnvalue = qp->init( H,g,A,lb,ub,lbA,ubA,numberOfSteps,0 ); } else { int performHotstart = 0; get( HOTSTART_QP,performHotstart ); if ( (bool)performHotstart == true ) { returnvalue = qp->hotstart( H,g,A,lb,ub,lbA,ubA,numberOfSteps,0 ); } else { /* if no hotstart is desired, reset QP and use cold start */ qp->reset( ); returnvalue = qp->init( H,g,A,lb,ub,lbA,ubA,numberOfSteps,0 ); } } setLast( LOG_NUM_QP_ITERATIONS, numberOfSteps ); /* update QP status and determine return value */ return updateQPstatus( returnvalue ); }
Student::Student( const int age, const char *last_name, const char *first_name, const char *email, const char social[]) : mAge(0), mLastName(0), mFirstName(0), mEmail(0) { mSocial[0] = 0; setAge(age); setLast(last_name); setFirst(first_name); setEmail(email); setSsn(social); }
/** * @brief Extend a sequence of blocks starting at this block be extended by blocks amount. * @param heap_state Pointer to the heap state related to the heap to use. * @param block The block index from which to begin extending * @param used The number of blocks currently allocated or earmarked for allocation. * @param blocks The number of bocks by which to contiguously extend the allocation. * @return Boolean true if the extension was performed, else false */ static bool extend(heap_state_t* heap_state, int32_t block, int32_t used, int32_t blocks) { int32_t n; bool rc=false; if ( can_extend(heap_state,block,used,blocks) ) { uint32_t total = used+blocks; for(n=0; n < total; n++) { if (n == total-1) setLast(heap_state,block+n); else resetLast(heap_state,block+n); set(heap_state,block+n); ++heap_state->heap_blocks_allocated; } rc=true; } return rc; }
void List<T>::pushLast(const T& data) { Node<T>* newLast = new Node<T>(data); if (debug) { std::cout << "DEBUG: " << "Pushing " << newLast << " to last" << std::endl; } if (hasLast()) { getLast()->setNext(newLast); newLast->setPrev(getLast()); } if (!hasFirst()) { setFirst(newLast); } setLast(newLast); }
void SyncSourceConfig::assign(const SyncSourceConfig& sc) { if (&sc == this) { return; } setName (sc.getName ()); setURI (sc.getURI ()); setSyncModes (sc.getSyncModes ()); setType (sc.getType ()); setSync (sc.getSync ()); setLast (sc.getLast ()); setEncoding (sc.getEncoding ()); setVersion (sc.getVersion ()); setSupportedTypes(sc.getSupportedTypes()); setSyncMode (sc.getSyncMode ()); setIsAllowed (sc.isAllowed ()); // setCtCap (sc.getCtCap ()); setEncryption (sc.getEncryption ()); setLastSourceError(sc.getLastSourceError()); setLastSyncServerTime(sc.AbstractSyncSourceConfig::getLastSyncServerTime()); extraProps = sc.getExtraProps(); }
returnValue ShootingMethod::logTrajectory( const OCPiterate &iter ){ if( integrator == 0 ) return SUCCESSFUL_RETURN; int i, j; double T,t1,t2,h; BooleanType needToRescale = BT_FALSE; VariablesGrid logX, logXA, logP, logU, logW, logI, tmp,tmp2; Matrix intervalPoints(N+1,1); intervalPoints(0,0) = 0.0; j = 0; for( i = 0; i < N; i++ ){ if( (int) breakPoints(j,0) <= i ) j++; int i1 = (int) breakPoints(j,1); int i2 = (int) breakPoints(j,2); if( i1 >= 0 ) t1 = iter.p->operator()(0,i1); else t1 = breakPoints(j,3); if( i2 >= 0 ) t2 = iter.p->operator()(0,i2); else t2 = breakPoints(j,4); if( i == 0 ) T = t1; integrator[i]->getX( tmp ); intervalPoints(i+1,0) = intervalPoints(i,0) + tmp.getNumPoints(); if ( ( i1 >= 0 ) || ( i2 >= 0 ) ) { if ( iter.isInSimulationMode() == BT_FALSE ) { h = t2-t1; needToRescale = BT_TRUE; } } else { h = 1.0; needToRescale = BT_FALSE; } if( nx > 0 ){ if ( needToRescale == BT_TRUE ) rescale( &tmp, T, h ); logX .appendTimes( tmp ); } if( na > 0 ){ integrator[i]->getXA( tmp ); if ( needToRescale == BT_TRUE ) rescale( &tmp, T, h ); logXA.appendTimes( tmp ); } if( np > 0 ){ tmp2.init( np, tmp.getFirstTime(),tmp.getLastTime(),2 ); if ( iter.isInSimulationMode( ) == BT_FALSE ) tmp2.setAllVectors( iter.p->getVector(0) ); else tmp2.setAllVectors( iter.p->getVector(i) ); logP .appendTimes( tmp2 ); } if( nu > 0 ){ tmp2.init( nu, tmp.getFirstTime(),tmp.getLastTime(),2 ); tmp2.setAllVectors(iter.u->getVector(i)); logU .appendTimes( tmp2 ); } if( nw > 0 ){ tmp.init( nw, tmp ); tmp.setAllVectors(iter.w->getVector(i)); logW .appendTimes( tmp ); } integrator[i]->getI( tmp ); if ( needToRescale == BT_TRUE ) rescale( &tmp, T, h ); logI .appendTimes( tmp ); T = tmp.getLastTime(); } // WRITE DATA TO THE LOG COLLECTION: // --------------------------------- if( nx > 0 ) setLast( LOG_DIFFERENTIAL_STATES, logX ); if( na > 0 ) setLast( LOG_ALGEBRAIC_STATES , logXA ); if( np > 0 ) setLast( LOG_PARAMETERS , logP ); if( nu > 0 ) setLast( LOG_CONTROLS , logU ); if( nw > 0 ) setLast( LOG_DISTURBANCES , logW ); setLast( LOG_INTERMEDIATE_STATES , logI ); setLast( LOG_DISCRETIZATION_INTERVALS, intervalPoints ); return SUCCESSFUL_RETURN; }
List<T>::List() { setDebug(false); setFirst(NULL); setLast(NULL); }
returnValue SCPmethod::prepareNextStep( ) { returnValue returnvalue; RealClock clockLG; BlockMatrix oldLagrangeGradient; BlockMatrix newLagrangeGradient; // acadoPrintf("bandedCP.dynResiduum (possibly shifted) = \n"); // bandedCP.dynResiduum.print(); // acadoPrintf("bandedCP.lambdaDynamic (possibly shifted) = \n"); // bandedCP.lambdaDynamic.print(); // Coumpute the "old" Lagrange Gradient with the latest multipliers: // ----------------------------------------------------------------- clockLG.reset( ); clockLG.start( ); returnvalue = eval->evaluateLagrangeGradient( getNumPoints(),oldIter,bandedCP, oldLagrangeGradient ); if( returnvalue != SUCCESSFUL_RETURN ) ACADOERROR( RET_NLP_STEP_FAILED ); clockLG.stop( ); // Linearize the NLP system at the new point: // ------------------------------------------ int printLevel; get( PRINTLEVEL,printLevel ); #ifdef SIM_DEBUG /* printf("preparation step \n"); (iter.x->getVector(0)).print("iter.x(0)"); (iter.u->getVector(0)).print("iter.u(0)"); (iter.x->getVector(1)).print("iter.x(1)"); (iter.u->getVector(1)).print("iter.u(1)");*/ #endif if ( (PrintLevel)printLevel >= HIGH ) acadoPrintf( "--> Computing new linearization of NLP system ...\n" ); clock.reset( ); clock.start( ); if ( needToReevaluate == BT_TRUE ) { // needs to re-evaluate due to eval->evaluate call within merit function evaluation! eval->clearDynamicDiscretization( ); if ( eval->evaluate( iter,bandedCP ) != SUCCESSFUL_RETURN ) return ACADOERROR( RET_NLP_STEP_FAILED ); needToReevaluate = BT_FALSE; } returnvalue = eval->evaluateSensitivities( iter,bandedCP ); if( returnvalue != SUCCESSFUL_RETURN ) ACADOERROR( RET_NLP_STEP_FAILED ); clock.stop( ); setLast( LOG_TIME_SENSITIVITIES,clock.getTime() ); if ( (PrintLevel)printLevel >= HIGH ) acadoPrintf( "<-- Computing new linearization of NLP system done.\n" ); //bandedCP.objectiveGradient.print(); // Coumpute the "new" Lagrange Gradient with the latest multipliers: // ----------------------------------------------------------------- clockLG.start( ); returnvalue = eval->evaluateLagrangeGradient( getNumPoints(),iter,bandedCP, newLagrangeGradient ); if( returnvalue != SUCCESSFUL_RETURN ) ACADOERROR( RET_NLP_STEP_FAILED ); clockLG.stop( ); setLast( LOG_TIME_LAGRANGE_GRADIENT,clockLG.getTime() ); // Compute the next Hessian: // ------------------------- if ( (PrintLevel)printLevel >= HIGH ) acadoPrintf( "--> Computing or approximating Hessian matrix ...\n" ); clock.reset( ); clock.start( ); returnvalue = computeHessianMatrix( oldLagrangeGradient,newLagrangeGradient ); if( returnvalue != SUCCESSFUL_RETURN ) ACADOERROR( RET_NLP_STEP_FAILED ); clock.stop( ); setLast( LOG_TIME_HESSIAN_COMPUTATION,clock.getTime() ); if ( (PrintLevel)printLevel >= HIGH ) acadoPrintf( "<-- Computing or approximating Hessian matrix done.\n" ); // CONDENSE THE KKT-SYSTEM: // ------------------------ if ( isInRealTimeMode == BT_TRUE ) { if ( bandedCPsolver->prepareSolve( bandedCP ) != SUCCESSFUL_RETURN ) return ACADOERROR( RET_NLP_STEP_FAILED ); } stopClockAndPrintRuntimeProfile( ); return CONVERGENCE_NOT_YET_ACHIEVED; }
returnValue SCPmethod::performCurrentStep( ) { returnValue returnvalue; if ( isInRealTimeMode == BT_TRUE ) { if ( bandedCPsolver->finalizeSolve( bandedCP ) != SUCCESSFUL_RETURN ) return ACADOERROR( RET_NLP_STEP_FAILED ); // bandedCP.deltaX.print(); } // acadoPrintf("bandedCP.dynResiduum = \n"); // bandedCP.dynResiduum.print(); // acadoPrintf("bandedCP.lambdaDynamic = \n"); // bandedCP.lambdaDynamic.print(); oldIter = iter; // Perform a globalized step: // -------------------------- int printLevel; get( PRINTLEVEL,printLevel ); if ( (PrintLevel)printLevel >= HIGH ) acadoPrintf( "--> Perform globalized SQP step ...\n" ); clock.reset( ); clock.start( ); #ifdef SIM_DEBUG /* printf("performing the current step...: old iterate \n"); (iter.x->getVector(0)).print("iter.x(0)"); (iter.u->getVector(0)).print("iter.u(0)"); (iter.x->getVector(1)).print("iter.x(1)"); (iter.u->getVector(1)).print("iter.u(1)");*/ #endif returnvalue = scpStep->performStep( iter,bandedCP,eval ); if( returnvalue != SUCCESSFUL_RETURN ) ACADOERROR( RET_NLP_STEP_FAILED ); hasPerformedStep = BT_TRUE; clock.stop( ); setLast( LOG_TIME_GLOBALIZATION,clock.getTime() ); if ( (PrintLevel)printLevel >= HIGH ) acadoPrintf( "<-- Perform globalized SQP step done.\n" ); printIteration( ); // Check convergence criterion if no real-time iterations are performed int terminateAtConvergence = 0; get( TERMINATE_AT_CONVERGENCE,terminateAtConvergence ); if ( (BooleanType)terminateAtConvergence == BT_TRUE ) { if ( checkForConvergence( ) == CONVERGENCE_ACHIEVED ) { stopClockAndPrintRuntimeProfile( ); return CONVERGENCE_ACHIEVED; } } if ( numberOfSteps >= 0 ) set( KKT_TOLERANCE_SAFEGUARD,0.0 ); return CONVERGENCE_NOT_YET_ACHIEVED; }
void Family::adopt(LmerVector *v) { v->setFamily(this); vectors.push_back(v); setLast(v); setExpectedEnd(v->back() + 1); }
// Queries the use to find out what actions they want to perform. // Runs continuously until the user selects 'Quit'. Contains basic // operations for manipulating a doubly linked list, except adding // a new node. int query(ring *r) { printf("What would you like to do?\n"); printf("1 - View previous website\n"); printf("2 - View next website\n"); printf("3 - View latest website\n"); printf("4 - View first website\n"); printf("5 - Open current website\n"); printf("6 - Remove from history\n"); printf("7 - Print number of links stored\n"); printf("8 - Print all links (from last to first)\n"); printf("9 - Quit\n"); char option, nl; char link[120] = "open "; scanf("%c%c", &option, &nl); switch(option) { case '1': shiftForward(r); printf("Previous:\n%s\n", getCurrent(r)); return 1; break; case '2': shiftBackward(r); printf("Next:\n%s\n", getCurrent(r)); return 1; break; case '3': setFirst(r); printf("Latest:\n%s\n", getCurrent(r)); return 1; break; case '4': setLast(r); printf("First:\n%s\n", getCurrent(r)); return 1; break; case '5': printf("Opening:\n%s\n", getCurrent(r)); strcat(link, getCurrent(r)); system(link); return 1; break; case '6': deleteCurrent(r); printf("Previous:\n%s\n", getCurrent(r)); return 1; break; case '7': printf("There are %d links stored.\n", getLength(r)); printf("Current: \n%s\n", getCurrent(r)); return 1; break; case '8': printAll(r); printf("\nCurrent: \n%s\n", getCurrent(r)); return 1; break; case '9': return 0; break; default: printf("Please enter a valid option!\n"); return 1; } }
void BinaryHeap::removeLast(){ delete last; last = NULL; setLast(); }
size_t TileNode::hashMultiple(const SpatialDimension* hashing, Data& data, response_container& response, std::vector<zoom_level> zoom, ulong level) { ulong d = (level + 1) % hashing->key().size(); size_t count = 0; if (level < hashing->maxZoom() && _pivot.size() > hashing->min_per_node()) { std::map <std::pair<uint32_t, uint32_t>, uint32_t> used; for (auto i = _pivot.front(); i < _pivot.back(); ++i) { ulong y = util::lat2tiley(data.getFloatProperty(i, d), zoom[d].z); ulong x = util::lon2tilex(data.getFloatProperty(i, d + (ulong)hashing->key().size()), zoom[d].z); used[std::make_pair(x, y)]++; data.setHash(i, getIndex(x, y)); } // sorting data.sortHash(_pivot.front(), _pivot.back()); int accum = _pivot.front(); int first, second; ulong curr_zoom = zoom[d].z; zoom[d].z += 1; for (auto& pair : used) { if (pair.second == 0) continue; first = accum; accum += pair.second; second = accum; ulong index = getIndex(pair.first.first, pair.first.second); count++; _container[index] = (std::make_unique<TileNode>(TileNode(TilePivot(first, second, tile_t(pair.first.first, pair.first.second, curr_zoom))))); zoom[d].first = pair.first.first; zoom[d].second = pair.first.second; count += _container[index]->hashMultiple(hashing, data, response, zoom, level + 1); } } else { response.emplace_back(&_pivot); setLast(); TileNode* ptr = this; ulong k = level % hashing->key().size(); while (d != k) { count++; ptr->_container[0] = (std::make_unique<TileNode>(TileNode(TilePivot(ptr->_pivot.front(), ptr->_pivot.back(), tile_t(zoom[d].first, zoom[d].second, zoom[d].z - 1))))); ptr->_container[0]->setLast(); ptr = ptr->_container[0].get(); d = (d + 1) % hashing->key().size(); } } return count; }