NonAddShortestPath* ObjectManager::getNonAddShPath(){ assert(getIfAdditive() == false); if (nonAddShPath_ == NULL) { std::cout << "Creating non-additive shortest path" << std::endl; std::string algo = params_->getParamWoSpaces("ShPathAlgo"); if (algo == "LazyNonAdd") { nonAddShPath_ = new NonAddShortestPathWithLazyBSP(getNonAdditivePC(), getNet()->getNbNodes(), getOneSourceBSP(), getODMatrix()); } else if (algo == "NonAdd") { nonAddShPath_ = new NonAddShortestPath(getNonAdditivePC(), getNet()->getNbNodes(), getOneSourceBSP(), getPoint2PointBSP(), getODMatrix()); } else { throw Error("Unexpected value of parameter <ShPathAlgo>"); } if (shPath_ == NULL && (algo == "NonAdd" || algo == "LazyNonAdd" || algo == "NonAddWithAstar")) { shPath_ = nonAddShPath_; } if (! params_->getParamWoSpaces("UseP2PShPathWithRandomReturn").empty()) { std::cout << "******************************************" << std::endl; if (! params_->getParamWoSpaces("FIXED_PROBABILITY").empty()) { FPType probability = getFloatValue("FIXED_PROBABILITY"); if (probability <= 0 || probability > 1) throw Error("Unexpected value of parameter <FIXED_PROBABILITY>"); shPath_ = new ShortestPathWithRandomReturnWithFixedProbability(shPath_, probability); } else { shPath_ = new ShortestPathWithRandomReturn(shPath_); } std::cout << "******************************************: " << (shPath_ == nonAddShPath_) << std::endl; } std::cout << "Non-additive shortest path created" << std::endl; } return nonAddShPath_; };
TEST_F(ReporterTest, ShutdownImmediatelyAfterTriggerWhileKeepAliveTimeoutIsScheduledShouldSucceed) { processNetworkResponse(BSON("ok" << 1)); auto keepAliveTimeoutWhen = getExecutor().now() + reporter->getKeepAliveInterval(); ASSERT_EQUALS(keepAliveTimeoutWhen, reporter->getKeepAliveTimeoutWhen_forTest()); ASSERT_TRUE(reporter->isActive()); auto until = keepAliveTimeoutWhen - reporter->getKeepAliveInterval() / 2; runUntil(until); ASSERT_OK(reporter->trigger()); // '_keepAliveTimeoutWhen' is reset by trigger() not by the canceled callback. ASSERT_EQUALS(Date_t(), reporter->getKeepAliveTimeoutWhen_forTest()); ASSERT_TRUE(reporter->isActive()); auto net = getNet(); net->enterNetwork(); ASSERT_TRUE(net->hasReadyRequests()); net->exitNetwork(); reporter->shutdown(); net->enterNetwork(); ASSERT_FALSE(net->hasReadyRequests()); // Executor should invoke reporter callback with a ErrorCodes::CallbackCanceled status. net->runReadyNetworkOperations(); net->exitNetwork(); ASSERT_EQUALS(ErrorCodes::CallbackCanceled, reporter->join()); assertReporterDone(); }
void irect::calcTR (nr_double_t t) { nr_double_t i = getPropertyDouble ("I"); nr_double_t th = getPropertyDouble ("TH"); nr_double_t tl = getPropertyDouble ("TL"); nr_double_t tr = getPropertyDouble ("Tr"); nr_double_t tf = getPropertyDouble ("Tf"); nr_double_t td = getPropertyDouble ("Td"); nr_double_t it = 0; nr_double_t s = getNet()->getSrcFactor (); if (tr > th) tr = th; if (tf > tl) tf = tl; if (t > td) { // after delay t = t - td; t = t - (th + tl) * floor (t / (th + tl)); if (t < tr) { // rising edge it = + i / tr * t; } else if (t < th) { // high pulse it = i; } else if (t < th + tf) { // falling edge it = - i / tf * (t - (th + tf)); } } setI (NODE_1, +it * s); setI (NODE_2, -it * s); }
LineSearch* ObjectManager::getLineSearch(){ if (lineSearch_ == NULL) { if (getIfAdditive() == false) { throw Error("Line search is not implemented for the non-additive case"); } // line search, possible values: BISEC, ARMIJO, QUAD_APP std::cout << "Creating line search" << std::endl; std::string tmp = params_->getParamWoSpaces("LINE_SEARCH"); if (tmp == "BISEC") { FPType pr = getFloatValue("LS_PRECISION"); if (pr <= 0.0) throw Error("Line search precision must be positive"); lineSearch_ = new Bisection(pr, getDerivative()); } else if (tmp == "ARMIJO") { FPType dec = getFloatValue("ARMIJO_DEC"); if (dec <= 0.0) throw Error("Decrement for Armijo search must be positive"); lineSearch_ = new Armijo(dec, getDerivative()); } else if (tmp == "QUAD_APP") { lineSearch_ = new QuadApp(getDerivative(), getNet()); } else { throw Error("Unexpected value of parameter <LINE_SEARCH>"); } std::cout << "Line search created" << std::endl; } return lineSearch_; };
IndiffCurveContainer* ObjectManager::getIndiffCurveContainer(){ assert(getIfAdditive() == false); if (indiffCurveCont_ == NULL) { std::cout << "Creating indiffCurveCont" << std::endl; std::string curves = params_->getParam("INDIFF_CURVE"); std::string curveType = params_->getParamWoSpaces("INDIFF_CURVE_TYPE"); indiffCurveCont_ = createProperIndiffCurveContainer(curveType, getODMatrix()->getNbODPairs()); if (curves == "RND_GEN") { indiffCurveCont_->generateRandomCurvesWithBSP(static_cast<int>( getFloatValue("MAX_NB_POINTS_PER_CURVE")), *getOneSourceBSP(), *getODMatrix() ); indiffCurveCont_->writeToFile(getNet()->getNetName() + ".curves", *getODMatrix() ); } else { if (curveType == "PiecewiseLinear") { ParseIndiffCurves curvesParser; curvesParser.parse(curves, *indiffCurveCont_); } else if (curveType == "Linear" || curveType == "Convex" || curveType == "Concave") { ParseSpecificIndiffCurves curvesParser; curvesParser.parse(curves, *indiffCurveCont_); } else { throw Error("Unexpected value of parameter <INDIFF_CURVE_TYPE>"); } } std::cout << "IndiffCurveCont created" << std::endl; } return indiffCurveCont_; };
void BaseClonerTest::scheduleNetworkResponse(NetworkOperationIterator noi, ErrorCodes::Error code, const std::string& reason) { auto net = getNet(); ReplicationExecutor::ResponseStatus responseStatus(code, reason); net->scheduleResponse(noi, net->now(), responseStatus); }
boolean CClientRegister::doUnregister(CSyncEngine& oSync) { String session = m_unregisterSession; if ( session.length() == 0 ) { m_unregisterSession = ""; m_unregisterClientID = ""; LOG(INFO)+"Session is empty, don't need to unregister"; return true; } m_nPollInterval = POLL_INTERVAL_SECONDS; String client_id = m_unregisterClientID; if ( client_id.length() == 0 ) { m_unregisterSession = ""; m_unregisterClientID = ""; LOG(WARNING)+"Sync client_id is empty, don't need to unregister"; return true; } String strBody = getUnregisterBody(client_id); LOG(INFO)+"Unregistered client with body = " + strBody; class UnregisterSession : public net::IRhoSession { String m_session; String m_contentType; public: UnregisterSession(const String& session, const String& contentType) : m_session(session), m_contentType(contentType) {} virtual void logout() {} virtual const String& getSession() { return m_session; } virtual const String& getContentType() { return m_contentType; } }; UnregisterSession unregSession(session, oSync.getProtocol().getContentType() ); NetResponse resp = getNet().pushData( oSync.getProtocol().getClientRegisterUrl(client_id), strBody, &unregSession ); if( resp.isOK() ) { m_unregisterSession = ""; m_unregisterClientID = ""; CDBAdapter::getUserDB().executeSQL("UPDATE client_info SET token_sent=?", 0 ); LOG(INFO)+"Unregistered client sucessfully..."; return true; } LOG(WARNING)+"Network error: "+ resp.getRespCode(); return false; }
LinkFncContainer* ObjectManager::getLinkFncCont(){ if (linkFnc_ == NULL) { std::cout << "Creating linkFncContainer" << std::endl; linkFnc_ = new LinkFncContainer(getNet()); std::cout << "linkFncContainer created" << std::endl; } return linkFnc_; };
void BaseClonerTest::scheduleNetworkResponse(NetworkOperationIterator noi, const BSONObj& obj) { auto net = getNet(); Milliseconds millis(0); RemoteCommandResponse response(obj, millis); ReplicationExecutor::ResponseStatus responseStatus(response); net->scheduleResponse(noi, net->now(), responseStatus); }
void CLogSocketSink::processCommand(IQueueCommand* pCmd) { LogCommand *cmd = (LogCommand *)pCmd; if (!cmd) return; getNet().doRequest( "POST", cmd->m_url, cmd->m_body, 0, 0 ); }
bool Pathfinder::connect(int net, int n1, int n2){ //cout << n1 << ", " << getNet(n1) << endl; //cout << n2 << ", " << getNet(n2) << endl; if(!getNet(n1)){ //cout << "(" << n1 << ", "; graph[n1].net=net; graph[n1].nrNets++; netlist[net].netTree.push_front(n1); } if(!getNet(n2)){ //cout << n2 << ")" << endl; graph[n2].net=net; graph[n2].nrNets++; netlist[net].netTree.push_front(n2); } return true; //TODO: TEST TO RETURN FALSE }
OneSourceBiObjShPath* ObjectManager::getOneSourceBSP() { assert(getIfAdditive() == false); if (oneSourceBSP_ == NULL) { std::cout << "Creating OneSourceBSP" << std::endl; oneSourceBSP_ = new LabelSettingOneSourceBSP(*getNet(), *getTolls()); std::cout << "OneSourceBSP created" << std::endl; } return oneSourceBSP_; };
TollContainerType* ObjectManager::getTolls(){ assert(getIfAdditive() == false); if (tolls_ == NULL) { std::cout << "Creating tolls" << std::endl; getNet(); std::cout << "Tolls created" << std::endl; } return tolls_; };
void ElacticMapAnalyzer::printResults(QTableWidget * table) { table->setObjectName(tr(" Таксоны")); table->setEditTriggers(QTableWidget::NoEditTriggers); table->setColumnCount(AMatrix[0].size()); table->setRowCount(AMatrix.size()); for (int i=0;i<table->columnCount();i++) table->setHorizontalHeaderItem(i,new QTableWidgetItem(QString::number(i))); for (int i=0;i<AMatrix.size();i++) for (int j=0;j<AMatrix[i].size();j++) table->setItem(i,j,new QTableWidgetItem(QString::number(AMatrix[i][j]))); int startRow = table->rowCount(); table->setRowCount(table->rowCount()+prevTaxonsCountHistory[0].size()); for(int i=0;i<prevTaxonsCountHistory[0].size();i++) { table->setItem(startRow+i,0,new QTableWidgetItem(QString::number(prevTaxonsCountHistory[0][i]))); } startRow = table->rowCount(); table->setRowCount(table->rowCount()+taxons.size()); for(int i=0;i<taxons.size();i++) { table->setItem(startRow+i,0,new QTableWidgetItem(QString::number(taxons[i].x))); table->setItem(startRow+i,1,new QTableWidgetItem(QString::number(taxons[i].y))); table->setItem(startRow+i,2,new QTableWidgetItem(QString::number(taxons[i].z))); } startRow = table->rowCount(); table->setRowCount(table->rowCount()+BMatrixOld.size()); for(int i=0;i<BMatrixOld.size();i++) { table->setItem(startRow+i,0,new QTableWidgetItem(QString::number(BMatrixOld[i].x))); table->setItem(startRow+i,1,new QTableWidgetItem(QString::number(BMatrixOld[i].y))); table->setItem(startRow+i,2,new QTableWidgetItem(QString::number(BMatrixOld[i].z))); } Point3D coords; coords.x = 5.0f; coords.y = 5.0f; coords.z = 5.0f; QList<QString> coordLables; coordLables.append("PC1"); coordLables.append("PC2"); coordLables.append("PC3"); QWidget * tab1 = AdditionalWidgets.at(0); tab1->setObjectName(tr("График")); Graphic3d * g1 = new Graphic3d(tab1); //g1->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); coordLables.append(headerList.at(parametersList->at(0).toInt())); coordLables.append(headerList.at(parametersList->at(1).toInt())); coordLables.append(headerList.at(parametersList->at(2).toInt())); g1->SetCoordsData(coords, coordLables); g1->SetPoints(getTmatrix()); g1->SetNet(getNet()); tab1->setLayout(new QGridLayout()); tab1->layout()->addWidget(g1); }
ODMatrix* ObjectManager::getODMatrix(){ if (odMatrix_ == NULL) { std::cout << "Creating OD matrix" << std::endl; std::string file = params_->getParam("OD_MATRIX"); DefaultODMatrixParser parser(file); odMatrix_ = parser.parseODMatrix(getNet()); std::cout << "OD matrix created" << std::endl; } return odMatrix_; };
FXint GUIRunThread::run() { long beg = 0; long end = -1; // perform an endless loop while (!myQuit) { // if the simulation shall be perfomed, do it if (!myHalting && myNet != 0 && myOk) { if (getNet().logSimulationDuration()) { beg = SysUtils::getCurrentMillis(); if (end != -1) { getNet().setIdleDuration((int)(beg - end)); } } // check whether we shall stop at this step myBreakpointLock.lock(); const bool haltAfter = find(myBreakpoints.begin(), myBreakpoints.end(), myNet->getCurrentTimeStep()) != myBreakpoints.end(); myBreakpointLock.unlock(); // do the step makeStep(); // stop if wished if (haltAfter) { stop(); } // wait if wanted long wait = (long) mySimDelay.getValue(); if (getNet().logSimulationDuration()) { end = SysUtils::getCurrentMillis(); getNet().setSimDuration((int)(end - beg)); wait -= (end - beg); } if (wait > 0) { sleep(wait); } } else { // sleep if the simulation is not running sleep(50); } } // delete a maybe existing simulation at the end deleteSim(); return 0; }
BoundsCalculatorForBackwardNet* ObjectManager::getBackwardBound() { if (backwardBounds_ == NULL) { std::cout << "creating backward bounds *********************" << std::endl; backwardBounds_ = new BoundsCalculatorForBackwardNet(*getNet(), *getTolls()); backwardBounds_->initializeBounds(); } return backwardBounds_; };
PASManager* ObjectManager::getPASManager(){ assert(getIfAdditive() == true); if (pasManager_ == NULL) { std::cout << "Creating PASManager" << std::endl; std::string tmp = params_->getParamWoSpaces("ALGORITHM"); if (tmp == "TAPAS") { pasManager_ = new PASManager(*getShPath(), getFloatValue("DIR_TOLERANCE"), getNet()->getNbLinks(), getFloatValue("MU"), getFloatValue("V"), getFloatValue("ZERO_FLOW")); } else if (tmp == "TAPASstep") { pasManager_ = new PASManagerWithStep(*getShPath(), getFloatValue("DIR_TOLERANCE"), getNet()->getNbLinks(), getFloatValue("MU"), getFloatValue("V"), getNet()->getNbLinks(), getLineSearch(), getFloatValue("ZERO_FLOW")); } else { throw Error("Unexpected algorithm type. Possible values are TAPAS or TAPASwithStep"); } std::cout << "PASManager created" << std::endl; } return pasManager_; };
DescDirectionPath* ObjectManager::getDescDirectionPath(){ if (descDirPath_ == NULL) { std::cout << "Creating Desc direction" << std::endl; descDirPath_ = allocateDescDirectionPath(getPathAlgoType(), getPathAlgoApp(), getNet()->getNbLinks(), getFloatValue("DIR_TOLERANCE"), getFloatValue("SLOPE"), getFloatValue("ISP_SCALE")); std::cout << "descDirection created" << std::endl; } return descDirPath_; };
boolean CClientRegister::doRegister(CSyncEngine& oSync) { String session = oSync.loadSession(); if ( session.length() == 0 ) { m_nPollInterval = POLL_INTERVAL_INFINITE; LOG(INFO)+"Session is empty, do register later"; return false; } if ( m_strDevicePin.length() == 0 ) { notifyLoggedIn("","",session); m_nPollInterval = POLL_INTERVAL_INFINITE; LOG(INFO)+"Device PUSH pin is empty, do register later"; return false; } m_nPollInterval = POLL_INTERVAL_SECONDS; String client_id = oSync.loadClientID(); if ( client_id.length() == 0 ) { LOG(WARNING)+"Sync client_id is empty, do register later"; return false; } IDBResult res = CDBAdapter::getUserDB().executeSQL("SELECT token,token_sent from client_info"); if ( !res.isEnd() ) { String token = res.getStringByIdx(0); int token_sent = res.getIntByIdx(1) && !RHOCONF().getBool("register_push_at_startup"); if ( m_strDevicePin.compare(token) == 0 && token_sent > 0 ) { //token in db same as new one and it was already send to the server //so we do nothing return true; } } String strBody = getRegisterBody(client_id); NetResponse resp = getNet().pushData( oSync.getProtocol().getClientRegisterUrl(client_id), strBody, &oSync ); if( resp.isOK() ) { CDBAdapter::getUserDB().executeSQL("UPDATE client_info SET token_sent=?, token=?", 1, m_strDevicePin ); LOG(INFO)+"Registered client sucessfully..."; return true; } LOG(WARNING)+"Network error: "+ resp.getRespCode(); return false; }
void vac::calcTR (nr_double_t t) { nr_double_t f = getPropertyDouble ("f"); nr_double_t p = getPropertyDouble ("Phase"); nr_double_t d = getPropertyDouble ("Theta"); nr_double_t a = getPropertyDouble ("U"); nr_double_t s = getNet()->getSrcFactor (); nr_double_t o = 2 * M_PI * f; nr_double_t T = p / f / 360; nr_double_t u = s * a * exp (-(t + T) * d * f) * sin (o * t + rad (p)); setE (VSRC_1, u); }
BoundsCalculatorForBSPBase* ObjectManager::getBoundsCaclulator() { assert(getIfAdditive() == false); if (boundsCalculator_ == NULL) { std::cout << "Creating BoundsCalculatorForBSP" << std::endl; std::string bsp = params_->getParamWoSpaces("BLS_BOUNDS"); if (bsp.empty()) { boundsCalculator_ = new BoundsCalculatorForBSPBase; } else if (bsp == "zeroFlow") { boundsCalculator_ = new BoundsCalculatorForBSP(*getNet(), *getTolls()); } else if (bsp == "currentFlow") { boundsWithTimeUpdate_ = new BoundsCalculatorWithTimeUpdate(*getNet(), *getTolls()); boundsCalculator_ = boundsWithTimeUpdate_; } else { throw Error("Unexpected value of parameter <BIOBJ_SHPATH_P2P>."); } std::cout << "BoundsCalculatorForBSP created" << std::endl; boundsCalculator_->initializeBounds(); } return boundsCalculator_; };
Point2PointBiObjShPath* ObjectManager::getPoint2PointBSP(){ assert(getIfAdditive() == false); if (point2pointBSP_ == NULL) { std::cout << "Creating p2pBSP" << std::endl; std::string bsp = params_->getParamWoSpaces("BIOBJ_SHPATH_P2P"); if (bsp == "BiLabelSetting") { point2pointBSP_ = new LabelSettingPoint2PointBSP(*getNet(), *getTolls(), *getBoundsCaclulator(), *getPathsAdder(), *getDominationByPathCost()); } else if (bsp == "BiLabelSetting_bidirectional"){ point2pointBSP_ = new BiDirectionalPoint2PointBSP(*getNet(), *getTolls(), *getBoundsCaclulator(), *getPathsAdder(), *getBackwardBound(), *getDominationByPathCost()); } else { throw Error("Unexpected value of parameter <BIOBJ_SHPATH_P2P>."); } std::cout << "P2PBSP created" << std::endl; } return point2pointBSP_; };
LabelCorrectingAl* ObjectManager::getLabelCorrectingAlgo(){ assert(getIfAdditive() == true); if (LCShortestPath_ == NULL) { std::string algo = params_->getParamWoSpaces("ShPathAlgo"); LCShortestPath_ = new LabelCorrectingAl(getNet()); if (shPath_ == NULL && algo == "LC") { shPath_ = LCShortestPath_; } } return LCShortestPath_; };
void iac::calcTR (nr_double_t t) { nr_double_t f = getPropertyDouble ("f"); nr_double_t p = getPropertyDouble ("Phase"); nr_double_t d = getPropertyDouble ("Theta"); nr_double_t a = getPropertyDouble ("I"); nr_double_t s = getNet()->getSrcFactor (); nr_double_t o = 2 * M_PI * f; nr_double_t T = p / f / 360; nr_double_t i = s * a * exp (-(t + T) * d * f) * sin (o * t + rad (p)); setI (NODE_1, +i); setI (NODE_2, -i); }
void GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) { switch (key) { case SUMO_ATTR_FROM: case SUMO_ATTR_TO: case SUMO_ATTR_FROM_LANE: case SUMO_ATTR_TO_LANE: case SUMO_ATTR_PASS: case SUMO_ATTR_KEEP_CLEAR: case SUMO_ATTR_CONTPOS: case SUMO_ATTR_UNCONTROLLED: case SUMO_ATTR_VISIBILITY_DISTANCE: case SUMO_ATTR_SPEED: case SUMO_ATTR_CUSTOMSHAPE: case GNE_ATTR_SELECTED: case GNE_ATTR_GENERIC: // no special handling undoList->p_add(new GNEChange_Attribute(this, myNet, key, value)); break; case SUMO_ATTR_TLLINKINDEX: if (value != getAttribute(key)) { // trigger GNEChange_TLS undoList->p_begin("change tls linkIndex for connection"); // make a copy std::set<NBTrafficLightDefinition*> defs = getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS(); for (NBTrafficLightDefinition* tlDef : defs) { NBLoadedSUMOTLDef* sumoDef = dynamic_cast<NBLoadedSUMOTLDef*>(tlDef); NBTrafficLightLogic* tllogic = sumoDef ? sumoDef->getLogic() : tlDef->compute(OptionsCont::getOptions()); if (tllogic != nullptr) { NBLoadedSUMOTLDef* newDef = new NBLoadedSUMOTLDef(tlDef, tllogic); newDef->addConnection(getEdgeFrom()->getNBEdge(), getEdgeTo()->getNBEdge(), getLaneFrom()->getIndex(), getLaneTo()->getIndex(), parse<int>(value), false); std::vector<NBNode*> nodes = tlDef->getNodes(); for (NBNode* node : nodes) { GNEJunction* junction = getNet()->retrieveJunction(node->getID()); undoList->add(new GNEChange_TLS(junction, tlDef, false), true); undoList->add(new GNEChange_TLS(junction, newDef, true), true); } } else { WRITE_ERROR("Could not set attribute '" + toString(key) + "' (tls is broken)"); } } undoList->p_end(); } break; case SUMO_ATTR_DIR: throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified"); case SUMO_ATTR_STATE: throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified"); default: throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'"); } }
PathSet* ObjectManager::getPathSet(){ if (pathSet_ == NULL) { std::cout << "Creating path set" << std::endl; PathApp app = getPathAlgoApp(); AONAssignment* aon = NULL; if (getIfAdditive()) { aon = new AONUsual(*getODMatrix(), getLabelCorrectingAlgo()); } else { aon = new AONNonAdditive(*getODMatrix(), new NonAddShortestPathForAON(getNonAdditivePC(), getNet()->getNbNodes(), getOneSourceBSP(), getODMatrix())); } if (app == APP3) { PathAlgoType algo = getPathAlgoType(); if (algo == PE ) { pathSet_ = PathSet::createSetPEAPP3(getNet(), getODMatrix(), getShPath(), getPathCost(), getFloatValue("ZERO_FLOW"), getPathBasedFlowMove(), aon); } else if (algo == GP) { pathSet_ = PathSet::createSetGPAPP3(getNet(), getODMatrix(), getShPath(), getPathCost(), getFloatValue("ZERO_FLOW"), getPathBasedFlowMoveGP(), aon); } else { throw Error("Approach 3 is not implemented for this algorithm"); } } else { pathSet_ = PathSet::createSetWithStep(getNet(), getODMatrix(), getShPath(), getPathCost(), getFloatValue("ZERO_FLOW"), getPathBasedFlowMoveWithStep(), aon); } std::cout << "Path set created" << std::endl; } return pathSet_; };
bool GoogleGeoCoding::fetchData(String const &url, void **data, size_t *datasize) { RHO_MAP_TRACE1("GoogleGeoCoding: fetchData: url=%s", url.c_str()); NetResponse resp = getNet().doRequest("GET", url, "", 0, 0); if (!resp.isOK()) return false; *datasize = resp.getDataSize(); *data = malloc(*datasize); if (!*data) return false; memcpy(*data, resp.getCharData(), *datasize); return true; }
ShortestPath* ObjectManager::getShPath(){ if (shPath_ == NULL) { std::cout << "Creating shortest path" << std::endl; std::string algo = params_->getParamWoSpaces("ShPathAlgo"); if( algo == "LC"){ assert(getIfAdditive() == true); LCShortestPath_ = new LabelCorrectingAl(getNet()); shPath_ = LCShortestPath_; } else if( algo == "Astar"){ assert(getIfAdditive() == true); aStar_ = new Astar(getNet(), getODMatrix()); aStar_->initializeBounds(getODMatrix()); shPath_ = aStar_; } else if (algo == "NonAdd" || algo == "LazyNonAdd" || algo == "NonAddWithAstar") { assert(getIfAdditive() == false); nonAddShPath_ = getNonAddShPath(); } else if (algo == "LazySP") { assert(getIfAdditive() == true); shPath_ = new LazyShortestPath(new LabelCorrectingAl(getNet())); } else { throw Error("Unexpected parameter for <ShPathAlgo>. Possible values are LC, Astar."); } if (nonAddShPath_ == NULL && ! params_->getParamWoSpaces("UseP2PShPathWithRandomReturn").empty()) { std::cout << " params_->getParamWoSpaces(UseP2PShPathWithRandomReturn) = " << params_->getParamWoSpaces("UseP2PShPathWithRandomReturn") << std::endl; if (! params_->getParamWoSpaces("FIXED_PROBABILITY").empty()) { FPType probability = getFloatValue("FIXED_PROBABILITY"); if (probability <= 0 || probability > 1) throw Error("Unexpected value of parameter <FIXED_PROBABILITY>"); shPath_ = new ShortestPathWithRandomReturnWithFixedProbability(shPath_, probability); } else { shPath_ = new ShortestPathWithRandomReturn(shPath_); } } std::cout << "Shortest path created" << std::endl; } return shPath_; };
OriginSet* ObjectManager::getOriginSet(){ assert(getIfAdditive() == true); if (originSet_ == NULL) { std::cout << "Creating origin set" << std::endl; std::string tmp = params_->getParamWoSpaces("ALGORITHM"); if (tmp == "B") { std::string steps = params_->getParamWoSpaces("NEWTON_STEPS"); bool useMulti = true; if (steps == "SINGLE") { useMulti = false; } else if (steps == "MULTI") { useMulti = true; } else { throw Error("Unexpected value of parameter <NEWTON_STEPS>"); } originSet_ = OriginSet::createOriginSetB(getODMatrix(), getNet(), getFloatValue("ZERO_FLOW"), getFloatValue("DIR_TOLERANCE"), useMulti, getLabelCorrectingAlgo()); } else if (tmp == "Bstep"){ originSet_ = OriginSet::createOriginSetBWithStep(getODMatrix(), getNet(), getFloatValue("ZERO_FLOW"), getFloatValue("DIR_TOLERANCE"), getLineSearch(), getLabelCorrectingAlgo()); } else if (tmp == "LUCE") { originSet_ = OriginSet::createOriginSetLUCE(getODMatrix(), getNet(), getFloatValue("ZERO_FLOW"), getFloatValue("DIR_TOLERANCE"), getLineSearch(), getLabelCorrectingAlgo()); } else if (tmp == "TAPAS" || tmp == "TAPASstep") { originSet_ = OriginSet::createOriginSetTAPAS(getODMatrix(), getNet(), getFloatValue("ZERO_FLOW"), getFloatValue("DIR_TOLERANCE"), getPASManager(), getLabelCorrectingAlgo()); } else { throw Error("Unexpected algorithm value"); } std::cout << "origin set created" << std::endl; } return originSet_; };