int possibleInteraction(ClusterDesc *clusterInfo, int nClusters) { int i, j; for (i=0; i<nClusters; i++) { /* flag any non-periodic pattern */ if (clusterInfo[i].osc.period<1) return 1; /* otherwise consider pairs: at least one pattern must be a spaceship (assume it's the first) */ if (clusterInfo[i].osc.T.translateBy != 0) { /* pair with any higher-indexed spaceship or stationary oscillator */ for (j=0; j<nClusters; j++) { if (j>i || clusterInfo[j].osc.T.translateBy == 0) { if (approaching(clusterInfo[i], clusterInfo[j])) { return 1; } } } } } return 0; }
SUMOReal MSCFModel_Wiedemann::_v(const MSVehicle* veh, SUMOReal predSpeed, SUMOReal gap) const { const VehicleVariables* vars = (VehicleVariables*)veh->getCarFollowVariables(); const SUMOReal dx = gap + myType->getLength(); // wiedemann uses brutto gap const SUMOReal v = veh->getSpeed(); const SUMOReal vpref = veh->getMaxSpeed(); const SUMOReal dv = v - predSpeed; const SUMOReal bx = myAX + (1 + 7 * mySecurity) * sqrt(v); // Harding propose a factor of *.8 here const SUMOReal ex = 2 - myEstimation; // + RandHelper::randNorm(0.5, 0.15) const SUMOReal sdx = myAX + ex * (bx - myAX); /// the distance at which we drift out of following const SUMOReal sdv_root = (dx - myAX) / myCX; const SUMOReal sdv = sdv_root * sdv_root; const SUMOReal cldv = sdv * ex * ex; const SUMOReal opdv = cldv * (-1 - 2 * RandHelper::randNorm(0.5, 0.15)); // select the regime, get new acceleration, compute new speed based SUMOReal accel; if (dx <= bx) { accel = emergency(dv, dx); } else if (dx < sdx) { if (dv > cldv) { accel = approaching(dv, dx, bx); } else if (dv > opdv) { accel = following(vars->accelSign); } else { accel = fullspeed(v, vpref, dx, bx); } } else { if (dv > sdv && dx < D_MAX) { //@note other versions have an disjunction instead of conjunction accel = approaching(dv, dx, bx); } else { accel = fullspeed(v, vpref, dx, bx); } } // since we have hard constrainst on accel we may as well use them here accel = MAX2(MIN2(accel, myAccel), -myDecel); const SUMOReal vNew = MAX2(SUMOReal(0), v + ACCEL2SPEED(accel)); // don't allow negative speeds return vNew; }