// deprecated bool checkNeighborCandidates(int x, int y) { for (int i = 0; i < dim; i++) { if (!preassigned[x][i]) { if (!checkCandidates(x, i, true)) { //printf("checkNeighborCandidates returning false at: %i, %i\n", x, i); //std::cout << initCandidates[x][i]->toString() << " "; return false; } } if (!preassigned[i][y]) { if (!checkCandidates(i, y, true)) { //printf("checkNeighborCandidates returning false at: %i, %i\n", i, y); //std::cout << initCandidates[i][y]->toString() << " "; return false; } } } int startBlockRow = startOfCurrentBlockRow(x); int startBlockCol = startOfCurrentBlockCol(y); int endBlockRow = startBlockRow + blockSize; int endBlockCol = startBlockCol + blockSize; for (int j = startBlockRow; j < endBlockRow; j++) { for (int k = startBlockCol; k < endBlockCol; k++) { if (j != x && k != y) { if (!checkCandidates(j, k, true)) { //printf("checkNeighborCandidates returning false at: %i, %i\n", j, k); //std::cout << initCandidates[j][k]->toString() << " "; return false; } } } } // printf("checkNeighbor return true; }
void MSInsertionControl::determineCandidates(SUMOTime time) { MSVehicleControl& vehControl = MSNet::getInstance()->getVehicleControl(); for (std::vector<Flow>::iterator i = myFlows.begin(); i != myFlows.end();) { SUMOVehicleParameter* pars = i->pars; if (!i->isVolatile && i->vehicle != 0 && pars->repetitionProbability < 0) { ++i; //std::cout << SIMTIME << " volatile=" << i->isVolatile << " veh=" << i->vehicle << "\n"; continue; } bool tryEmitByProb = pars->repetitionProbability > 0; while ((pars->repetitionProbability < 0 && pars->repetitionsDone < pars->repetitionNumber && pars->depart + pars->repetitionsDone * pars->repetitionOffset < time + DELTA_T) || (tryEmitByProb && pars->depart < time + DELTA_T && pars->repetitionEnd > time // only call rand if all other conditions are met && RandHelper::rand() < (pars->repetitionProbability * TS)) ) { tryEmitByProb = false; // only emit one per step SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars); newPars->id = pars->id + "." + toString(i->index); newPars->depart = pars->repetitionProbability > 0 ? time : (SUMOTime)(pars->depart + pars->repetitionsDone * pars->repetitionOffset); pars->repetitionsDone++; // try to build the vehicle if (vehControl.getVehicle(newPars->id) == 0) { const MSRoute* route = MSRoute::dictionary(pars->routeid); const MSVehicleType* vtype = vehControl.getVType(pars->vtypeid, MSRouteHandler::getParsingRNG()); i->vehicle = vehControl.buildVehicle(newPars, route, vtype, false); unsigned int quota = vehControl.getQuota(); if (quota > 0) { vehControl.addVehicle(newPars->id, i->vehicle); add(i->vehicle); i->index++; while (--quota > 0) { SUMOVehicleParameter* quotaPars = new SUMOVehicleParameter(*pars); quotaPars->id = pars->id + "." + toString(i->index); quotaPars->depart = pars->repetitionProbability > 0 ? time : (SUMOTime)(pars->depart + pars->repetitionsDone * pars->repetitionOffset); i->vehicle = vehControl.buildVehicle(quotaPars, route, vtype, false); vehControl.addVehicle(quotaPars->id, i->vehicle); add(i->vehicle); i->index++; } } else { vehControl.deleteVehicle(i->vehicle, true); i->vehicle = 0; } } else { // strange: another vehicle with the same id already exists if (MSGlobals::gStateLoaded) { vehControl.discountStateLoaded(); break; } throw ProcessError("Another vehicle with the id '" + newPars->id + "' exists."); } } if (pars->repetitionsDone == pars->repetitionNumber || (pars->repetitionProbability > 0 && pars->repetitionEnd <= time)) { i = myFlows.erase(i); MSRoute::checkDist(pars->routeid); delete pars; } else { ++i; } } checkCandidates(time, MSDevice_Routing::isEnabled()); }