bool ScaffoldLayoutVisitor::visit(ScaffoldGraph* pGraph, ScaffoldVertex* pVertex) { // Never re-classify repeats if(pVertex->getClassification() == SVC_REPEAT) return false; for(size_t idx = 0; idx < ED_COUNT; idx++) { EdgeDir dir = EDGE_DIRECTIONS[idx]; ScaffoldEdgePtrVector edgeVec = pVertex->getEdges(dir); if(edgeVec.size() <= 1) continue; ScaffoldGroup group(pVertex, 100); for(size_t i = 0; i < edgeVec.size(); ++i) group.addLink(edgeVec[i]->getLink(), edgeVec[i]->getEnd()); group.computeBestOrdering(); int longestOverlap = group.calculateLongestOverlap(); if(longestOverlap > 150) { std::cout << "cannot scaffold from " << pVertex->getID() << " OL: " << longestOverlap << "\n"; continue; } // Calculate the ordered set of links that would make up this scaffold std::cout << "Computing layout for " << pVertex->getID() << "\n"; LinkVector linearLinks; group.getLinearLinks(linearLinks); std::cout << "Linearized links:\n"; // Iterate through the linearized links and see if they are sane bool allResolved = true; ScaffoldVertex* pCurrStartVertex = pVertex; for(size_t i = 0; i < linearLinks.size(); ++i) { std::cout << "\t" << linearLinks[i] << "\n"; // Does a real link exist between the two vertices that are predicted to be linked? ScaffoldEdge* pRealEdge = pCurrStartVertex->findEdgeTo(linearLinks[i].endpointID, linearLinks[i].getDir(), linearLinks[i].getComp()); if(pRealEdge != NULL) { std::cout << "\t\tresolved:" << pRealEdge->getLink() << "\n"; } else { pCurrStartVertex->setClassification(SVC_REPEAT); allResolved = false; std::cout << "\t\tnotfound\n"; } ScaffoldVertex* pCurrEndVertex = pGraph->getVertex(linearLinks[i].endpointID); assert(pCurrEndVertex != NULL); pCurrStartVertex = pCurrEndVertex; } group.getSecondaryLinks(); if(allResolved) { // Removed all the edges for current vertex except for the first std::string firstID = linearLinks[0].endpointID; for(size_t i = 0; i < edgeVec.size(); ++i) { if(edgeVec[i]->getEndID() == firstID) { edgeVec[i]->setColor(GC_BLACK); edgeVec[i]->getTwin()->setColor(GC_BLACK); } } } } return false; }
void MSSOTLTrafficLightLogic::init(NLDetectorBuilder& nb) throw(ProcessError) { MSTrafficLightLogic::init(nb); if (isDecayThresholdActivated()) { decayThreshold = 1; } if (sensorsSelfBuilt) { //Building SOTLSensors switch (SENSORS_TYPE) { case SENSORS_TYPE_E1: assert(0); // Throw exception because TLS can only handle E2 sensors case SENSORS_TYPE_E2: //Adding Sensors to the ingoing Lanes LaneVectorVector lvv = getLaneVectors(); DBG( WRITE_MESSAGE("Listing lanes for TLS " + getID()); for (unsigned int i = 0; i < lvv.size(); i++) { LaneVector lv = lvv[i]; for (unsigned int j = 0; j < lv.size(); j++) { MSLane* lane = lv[j]; WRITE_MESSAGE(lane ->getID()); } } ) mySensors = new MSSOTLE2Sensors(myID, &(getPhases())); ((MSSOTLE2Sensors*)mySensors)->buildSensors(myLanes, nb, getInputSensorsLength()); mySensors->stepChanged(getCurrentPhaseIndex()); if (getParameter("USE_VEHICLE_TYPES_WEIGHTS", "0") == "1") { ((MSSOTLE2Sensors*) mySensors)->setVehicleWeigths(getParameter("VEHICLE_TYPES_WEIGHTS", "")); } //threshold speed param for tuning with irace ((MSSOTLE2Sensors*)mySensors)->setSpeedThresholdParam(getSpeedThreshold()); myCountSensors = new MSSOTLE2Sensors(myID + "Count", &(getPhases())); myCountSensors->buildCountSensors(myLanes, nb); myCountSensors->stepChanged(getCurrentPhaseIndex()); //Adding Sensors to the outgoing Lanes LinkVectorVector myLinks = getLinks(); DBG( WRITE_MESSAGE("Listing output lanes"); for (unsigned int i = 0; i < myLinks.size(); i++) { LinkVector oneLink = getLinksAt(i); for (unsigned int j = 0; j < oneLink.size(); j++) { MSLane* lane = oneLink[j]->getLane(); WRITE_MESSAGE(lane ->getID()); } } ) LaneVectorVector myLaneVector; LaneVector outLanes; LinkVectorVector myoutLinks = getLinks(); for (unsigned int i = 0; i < myLinks.size(); i++) { LinkVector oneLink = getLinksAt(i); for (unsigned int j = 0; j < oneLink.size(); j++) { MSLane* lane = oneLink[j]->getLane(); outLanes.push_back(lane); } } if (outLanes.size() > 0) { myLaneVector.push_back(outLanes); } if (myLaneVector.size() > 0) { ((MSSOTLE2Sensors*)mySensors)->buildOutSensors(myLaneVector, nb, getOutputSensorsLength()); myCountSensors->buildCountOutSensors(myLaneVector, nb); } }