MSTriggeredRerouter Class Reference

#include <MSTriggeredRerouter.h>

Inheritance diagram for MSTriggeredRerouter:

MSTrigger SUMOSAXHandler Named GenericSAXHandler GUITriggeredRerouter

Detailed Description

Reroutes vehicles passing an edge.

A rerouter can be positioned on a list of edges and gives vehicles which arrive one of these edges a new route.

The new route may be either chosen from a set of routes where each is chosen with a certain probability, or newly computed, either by keeping the old destination or by choosing a new one from a set of existing ones.

Definition at line 63 of file MSTriggeredRerouter.h.


Public Member Functions

void characters (const XMLCh *const chars, const XERCES3_SIZE_t length)
 The inherited method called when characters occured.
void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
 The inherited method called when a tag is being closed.
const RerouteIntervalgetCurrentReroute (SUMOTime time) const
 Returns the rerouting definition valid for the given time and vehicle.
const RerouteIntervalgetCurrentReroute (SUMOTime time, SUMOVehicle &veh) const
 Returns the rerouting definition valid for the given time and vehicle.
const std::string & getFileName () const throw ()
 returns the current file name
const std::string & getID () const throw ()
 Returns the id.
SUMOReal getProbability () const
 Returns the rerouting probability.
SUMOReal getUserProbability () const
 Returns the rerouting probability given by the user.
bool hasCurrentReroute (SUMOTime time) const
 Returns whether a rerouting definition is valid for the given time.
bool hasCurrentReroute (SUMOTime time, SUMOVehicle &veh) const
 Returns whether a rerouting definition is valid for the given time and vehicle.
bool inUserMode () const
 Returns whether the user is setting the rerouting probability.
 MSTriggeredRerouter (const std::string &id, const std::vector< MSEdge * > &edges, SUMOReal prob, const std::string &file, bool off)
 Constructor.
void registerParent (const SumoXMLTag tag, GenericSAXHandler *handler)
 Assigning a parent handler which is enabled when the specified tag is closed.
void reroute (SUMOVehicle &veh, const MSEdge &src)
 Reroutes a vehicle.
void setFileName (const std::string &name) throw ()
 Sets the current file name.
void setUserMode (bool val)
 Sets whether the process is currently steered by the user.
void setUserUsageProbability (SUMOReal prob)
 Sets the probability with which a vehicle is rerouted given by the user.
void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
 The inherited method called when a new tag opens.
virtual ~MSTriggeredRerouter () throw ()
 Destructor.
SAX ErrorHandler callbacks
void error (const SAXParseException &exception) throw (ProcessError)
 Handler for XML-errors.
void fatalError (const SAXParseException &exception) throw (ProcessError)
 Handler for XML-errors.
void warning (const SAXParseException &exception) throw ()
 Handler for XML-warnings.

Protected Member Functions

std::string buildErrorMessage (const SAXParseException &exception) throw ()
 Builds an error message.
virtual void myCharacters (SumoXMLTag element, const std::string &chars) throw (ProcessError)
 Callback method for characters to implement by derived classes.
inherited from GenericSAXHandler
void myEndElement (SumoXMLTag element) throw (ProcessError)
 Called when a closing tag occurs.
virtual void myStartElement (SumoXMLTag element, const SUMOSAXAttributes &attrs) throw (ProcessError)
 Called on the opening of a tag;.

Protected Attributes

bool myAmInUserMode
 Information whether the current rerouting probability is the user-given.
std::string myID
 The name of the object.
std::vector< RerouteIntervalmyIntervals
 List of rerouting definition intervals.
SUMOReal myProbability
 The probability and the user-given probability.
std::vector< Setter * > mySetter
 List of lane-based vehicle informing children.
SUMOReal myUserProbability
members used during loading
std::vector< MSEdge * > myCurrentClosed
 List of closed edges.
RandomDistributor< MSEdge * > myCurrentEdgeProb
 new destinations with probabilities
SUMOTime myCurrentIntervalBegin
 The first and the last time steps of the interval.
SUMOTime myCurrentIntervalEnd
RandomDistributor< const
MSRoute * > 
myCurrentRouteProb
 new routes with probabilities

Private Member Functions

 MSTriggeredRerouter (const MSTriggeredRerouter &)
 Invalidated copy constructor.
MSTriggeredRerouteroperator= (const MSTriggeredRerouter &)
 Invalidated assignment operator.

Data Structures

struct  RerouteInterval
class  Setter
 Responsible for setting a new route to a vehicle which arrives at a single lane. More...

Constructor & Destructor Documentation

MSTriggeredRerouter::MSTriggeredRerouter ( const std::string &  id,
const std::vector< MSEdge * > &  edges,
SUMOReal  prob,
const std::string &  file,
bool  off 
)

Constructor.

Parameters:
[in] id The id of the rerouter
[in] edges The edges the rerouter is placed at
[in] prob The probability the rerouter reoutes vehicles with
[in] file The file to read the reroute definitions from

Definition at line 88 of file MSTriggeredRerouter.cpp.

References mySetter, XMLSubSys::runParser(), setUserMode(), and setUserUsageProbability().

00091         : MSTrigger(id), SUMOSAXHandler(file),
00092         myProbability(prob), myUserProbability(prob), myAmInUserMode(false) {
00093     // read in the trigger description
00094     if (!XMLSubSys::runParser(*this, file)) {
00095         throw ProcessError();
00096     }
00097     // build actors
00098 #ifdef HAVE_MESOSIM
00099     if (MSGlobals::gUseMesoSim) {
00100         for (std::vector<MSEdge*>::const_iterator j=edges.begin(); j!=edges.end(); ++j) {
00101             MESegment *s = MSGlobals::gMesoNet->getSegmentForEdge(**j);
00102             s->addRerouter(this);
00103         }
00104     } else {
00105 #endif
00106         for (std::vector<MSEdge*>::const_iterator j=edges.begin(); j!=edges.end(); ++j) {
00107             const std::vector<MSLane*> &destLanes = (*j)->getLanes();
00108             for (std::vector<MSLane*>::const_iterator i=destLanes.begin(); i!=destLanes.end(); ++i) {
00109                 mySetter.push_back(new Setter(this, (*i)));
00110             }
00111         }
00112 #ifdef HAVE_MESOSIM
00113     }
00114 #endif
00115     if (off) {
00116         setUserMode(true);
00117         setUserUsageProbability(0);
00118     }
00119 }

MSTriggeredRerouter::~MSTriggeredRerouter (  )  throw () [virtual]

Destructor.

Definition at line 122 of file MSTriggeredRerouter.cpp.

References mySetter.

00122                                                   {
00123     {
00124         std::vector<Setter*>::iterator i;
00125         for (i=mySetter.begin(); i!=mySetter.end(); ++i) {
00126             delete *i;
00127         }
00128     }
00129 }

MSTriggeredRerouter::MSTriggeredRerouter ( const MSTriggeredRerouter  )  [private]

Invalidated copy constructor.


Member Function Documentation

std::string SUMOSAXHandler::buildErrorMessage ( const SAXParseException &  exception  )  throw () [protected, inherited]

Builds an error message.

The error message includes the file name and the line/column information as supported by the given SAXParseException

Parameters:
[in] exception The name of the currently processed file
Returns:
A string describing the given exception

Definition at line 55 of file SUMOSAXHandler.cpp.

References GenericSAXHandler::getFileName().

Referenced by SUMOSAXHandler::error(), SUMOSAXHandler::fatalError(), and SUMOSAXHandler::warning().

00055                                                                             {
00056     std::ostringstream buf;
00057     char *pMsg = XMLString::transcode(exception.getMessage());
00058     buf << pMsg << std::endl;
00059     buf << " In file '" << getFileName() << "'" << std::endl;
00060     buf << " At line/column " << exception.getLineNumber()+1
00061     << '/' << exception.getColumnNumber() << "." << std::endl;
00062     XMLString::release(&pMsg);
00063     return buf.str();
00064 }

void GenericSAXHandler::characters ( const XMLCh *const   chars,
const XERCES3_SIZE_t  length 
) [inherited]

The inherited method called when characters occured.

The retrieved characters are converted into a string and appended into a private buffer. They are reported as soon as the element ends.

Todo:
recheck/describe what happens with characters when a new element is opened
Todo:
describe characters processing in the class' head

Definition at line 168 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myCharactersVector.

00169                                                            {
00170     myCharactersVector.push_back(TplConvert<XMLCh>::_2str(chars, length));
00171 }

void GenericSAXHandler::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const   qname 
) [inherited]

The inherited method called when a tag is being closed.

This method calls the user-implemented methods myCharacters with the previously collected and converted characters.

Then, myEndElement is called, supplying it the qname converted to its enum- and string-representations.

Todo:
recheck/describe encoding of the string-representation
Todo:
do not generate and report the string-representation

Definition at line 118 of file GenericSAXHandler.cpp.

References TplConvert< E >::_2str(), GenericSAXHandler::convertTag(), GenericSAXHandler::myCharacters(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myEndElement(), GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, XMLSubSys::setHandler(), SUMO_TAG_INCLUDE, and SUMO_TAG_NOTHING.

00120                                                         {
00121     std::string name = TplConvert<XMLCh>::_2str(qname);
00122     SumoXMLTag element = convertTag(name);
00123     // collect characters
00124     if (myCharactersVector.size()!=0) {
00125         size_t len = 0;
00126         unsigned i;
00127         for (i=0; i<myCharactersVector.size(); ++i) {
00128             len += myCharactersVector[i].length();
00129         }
00130         char *buf = new char[len+1];
00131         size_t pos = 0;
00132         for (i=0; i<myCharactersVector.size(); ++i) {
00133             memcpy((unsigned char*) buf+pos, (unsigned char*) myCharactersVector[i].c_str(),
00134                    sizeof(char)*myCharactersVector[i].length());
00135             pos += myCharactersVector[i].length();
00136         }
00137         buf[pos] = 0;
00138 
00139         // call user handler
00140         try {
00141             myCharacters(element, buf);
00142         } catch (std::runtime_error &) {
00143             delete[] buf;
00144             throw;
00145         }
00146         delete[] buf;
00147     }
00148     if (element != SUMO_TAG_INCLUDE) {
00149         myEndElement(element);
00150         if (myParentHandler && myParentIndicator == element) {
00151             XMLSubSys::setHandler(*myParentHandler);
00152             myParentIndicator = SUMO_TAG_NOTHING;
00153             myParentHandler = 0;
00154         }
00155     }
00156 }

void SUMOSAXHandler::error ( const SAXParseException &  exception  )  throw (ProcessError) [inherited]

Handler for XML-errors.

The message is built using buildErrorMessage and thrown within a ProcessError.

Parameters:
[in] exception The occured exception to process
Exceptions:
ProcessError On any call

Definition at line 74 of file SUMOSAXHandler.cpp.

References SUMOSAXHandler::buildErrorMessage().

00074                                                                             {
00075     throw ProcessError(buildErrorMessage(exception));
00076 }

void SUMOSAXHandler::fatalError ( const SAXParseException &  exception  )  throw (ProcessError) [inherited]

Handler for XML-errors.

The message is built using buildErrorMessage and thrown within a ProcessError.

Exceptions:
ProcessError On any call
Parameters:
[in] exception The occured exception to process

Definition at line 80 of file SUMOSAXHandler.cpp.

References SUMOSAXHandler::buildErrorMessage().

00080                                                                                  {
00081     throw ProcessError(buildErrorMessage(exception));
00082 }

const MSTriggeredRerouter::RerouteInterval & MSTriggeredRerouter::getCurrentReroute ( SUMOTime  time  )  const

Returns the rerouting definition valid for the given time and vehicle.

Definition at line 273 of file MSTriggeredRerouter.cpp.

References myIntervals.

00273                                                      {
00274     std::vector<RerouteInterval>::const_iterator i = myIntervals.begin();
00275     while (i!=myIntervals.end()) {
00276         if ((*i).edgeProbs.getOverallProb()!=0||(*i).routeProbs.getOverallProb()!=0||(*i).closed.size()!=0) {
00277             return *i;
00278         }
00279         i++;
00280     }
00281     throw 1;
00282 }

const MSTriggeredRerouter::RerouteInterval & MSTriggeredRerouter::getCurrentReroute ( SUMOTime  time,
SUMOVehicle veh 
) const

Returns the rerouting definition valid for the given time and vehicle.

Definition at line 257 of file MSTriggeredRerouter.cpp.

References MSRoute::containsAnyOf(), SUMOVehicle::getRoute(), and myIntervals.

Referenced by GUITriggeredRerouter::drawGL(), and reroute().

00257                                                                             {
00258     std::vector<RerouteInterval>::const_iterator i = myIntervals.begin();
00259     const MSRoute &route = veh.getRoute();
00260     while (i!=myIntervals.end()) {
00261         if ((*i).begin<=time && (*i).end>=time) {
00262             if ((*i).edgeProbs.getOverallProb()!=0||(*i).routeProbs.getOverallProb()!=0||route.containsAnyOf((*i).closed)) {
00263                 return *i;
00264             }
00265         }
00266         i++;
00267     }
00268     throw 1;
00269 }

const std::string & GenericSAXHandler::getFileName (  )  const throw () [inherited]

const std::string& Named::getID (  )  const throw () [inline, inherited]

Returns the id.

Returns:
The stored id

Definition at line 59 of file Named.h.

References Named::myID.

Referenced by RORouteDef_Alternatives::addAlternative(), MSRouteProbe::addRoute(), MSEmitter::MSEmitter_FileTriggeredChild::buildAndScheduleFlowVehicle(), MSCalibrator::MSCalibrator_FileTriggeredChild::buildAndScheduleFlowVehicle(), RORouteDef_Complete::buildCurrentRoute(), ODDistrictHandler::closeDistrict(), NBTrafficLightDefinition::collectLinks(), NBTrafficLightDefinition::compute(), GUIPointOfInterest::drawGL(), MSInductLoop::enterDetectorByMove(), MSVTypeProbe::execute(), MSNet::getBusStopID(), GUITriggeredRerouter::getMicrosimID(), GUIPointOfInterest::getMicrosimID(), GUILaneSpeedTrigger::getMicrosimID(), GUIInductLoop::MyWrapper::getMicrosimID(), GUIEmitter::getMicrosimID(), GUIBusStop::getMicrosimID(), GUI_E2_ZS_Collector::MyWrapper::getMicrosimID(), traci::TraCIServer::handlePoiDomain(), RORDLoader_SUMOBase::myCharacters(), NBOwnTLDef::myCompute(), NBLoadedTLDef::myCompute(), myStartElement(), MSLaneSpeedTrigger::myStartElement(), MSEmitter::MSEmitter_FileTriggeredChild::myStartElement(), MSCalibrator::MSCalibrator_FileTriggeredChild::myStartElement(), NBLoadedTLDef::SignalGroup::patchTYellow(), TraCIServerAPI_Vehicle::processGet(), MSVehicle::replaceRoute(), MSVehicle::saveState(), NBOwnTLDef::setTLControllingInformation(), NBLoadedTLDef::setTLControllingInformation(), RORDLoader_SUMOBase::startRoute(), GUIEmitter::GUIEmitterChild_UserTriggeredChild::wrappedExecute(), NBTrafficLightLogic::writeXML(), MSRouteProbe::writeXMLOutput(), MSInductLoop::writeXMLOutput(), MSE2Collector::writeXMLOutput(), and MSVehicle::~MSVehicle().

00059                                            {
00060         return myID;
00061     }

SUMOReal MSTriggeredRerouter::getProbability (  )  const

Returns the rerouting probability.

Definition at line 346 of file MSTriggeredRerouter.cpp.

References myAmInUserMode, myProbability, and myUserProbability.

Referenced by GUITriggeredRerouter::drawGL().

00346                                           {
00347     return myAmInUserMode ? myUserProbability : myProbability;
00348 }

SUMOReal MSTriggeredRerouter::getUserProbability (  )  const

Returns the rerouting probability given by the user.

Definition at line 352 of file MSTriggeredRerouter.cpp.

References myUserProbability.

00352                                               {
00353     return myUserProbability;
00354 }

bool MSTriggeredRerouter::hasCurrentReroute ( SUMOTime  time  )  const

Returns whether a rerouting definition is valid for the given time.

Definition at line 242 of file MSTriggeredRerouter.cpp.

References myIntervals.

00242                                                           {
00243     std::vector<RerouteInterval>::const_iterator i = myIntervals.begin();
00244     while (i!=myIntervals.end()) {
00245         if ((*i).begin<=time && (*i).end>=time) {
00246             if ((*i).edgeProbs.getOverallProb()!=0||(*i).routeProbs.getOverallProb()!=0||(*i).closed.size()!=0) {
00247                 return true;
00248             }
00249         }
00250         i++;
00251     }
00252     return false;
00253 }

bool MSTriggeredRerouter::hasCurrentReroute ( SUMOTime  time,
SUMOVehicle veh 
) const

Returns whether a rerouting definition is valid for the given time and vehicle.

Definition at line 226 of file MSTriggeredRerouter.cpp.

References MSRoute::containsAnyOf(), SUMOVehicle::getRoute(), and myIntervals.

Referenced by GUITriggeredRerouter::drawGL(), and reroute().

00226                                                                             {
00227     std::vector<RerouteInterval>::const_iterator i = myIntervals.begin();
00228     const MSRoute &route = veh.getRoute();
00229     while (i!=myIntervals.end()) {
00230         if ((*i).begin<=time && (*i).end>=time) {
00231             if ((*i).edgeProbs.getOverallProb()!=0||(*i).routeProbs.getOverallProb()!=0||route.containsAnyOf((*i).closed)) {
00232                 return true;
00233             }
00234         }
00235         i++;
00236     }
00237     return false;
00238 }

bool MSTriggeredRerouter::inUserMode (  )  const

Returns whether the user is setting the rerouting probability.

Definition at line 340 of file MSTriggeredRerouter.cpp.

References myAmInUserMode.

00340                                       {
00341     return myAmInUserMode;
00342 }

void GenericSAXHandler::myCharacters ( SumoXMLTag  element,
const std::string &  chars 
) throw (ProcessError) [protected, virtual, inherited]

Callback method for characters to implement by derived classes.

Called by "endElement" (see there).

Parameters:
[in] element The opened element, given as a SumoXMLTag
[in] chars The complete embedded character string ProcessError These method may throw a ProcessError if something fails

Reimplemented in ROJTRTurnDefLoader, MSRouteHandler, NIImporter_OpenDrive, NIImporter_SUMO, NLHandler, PCLoaderXML, PCNetProjectionLoader, and RORDLoader_SUMOBase.

Definition at line 189 of file GenericSAXHandler.cpp.

Referenced by GenericSAXHandler::endElement().

00189 {}

void MSTriggeredRerouter::myEndElement ( SumoXMLTag  element  )  throw (ProcessError) [protected, virtual]

Called when a closing tag occurs.

Parameters:
[in] element ID of the currently opened element
Exceptions:
ProcessError If something fails
See also:
GenericSAXHandler::myEndElement

Reimplemented from GenericSAXHandler.

Definition at line 206 of file MSTriggeredRerouter.cpp.

References MSTriggeredRerouter::RerouteInterval::begin, RandomDistributor< T >::clear(), MSTriggeredRerouter::RerouteInterval::closed, MSTriggeredRerouter::RerouteInterval::edgeProbs, MSTriggeredRerouter::RerouteInterval::end, myCurrentClosed, myCurrentEdgeProb, myCurrentIntervalBegin, myCurrentIntervalEnd, myCurrentRouteProb, myIntervals, MSTriggeredRerouter::RerouteInterval::routeProbs, and SUMO_TAG_INTERVAL.

00206                                                                         {
00207     if (element==SUMO_TAG_INTERVAL) {
00208         RerouteInterval ri;
00209         ri.begin = myCurrentIntervalBegin;
00210         ri.end = myCurrentIntervalEnd;
00211         ri.closed = myCurrentClosed;
00212         ri.edgeProbs = myCurrentEdgeProb;
00213         ri.routeProbs = myCurrentRouteProb;
00214         myCurrentClosed.clear();
00215         myCurrentEdgeProb.clear();
00216         myCurrentRouteProb.clear();
00217         myIntervals.push_back(ri);
00218     }
00219 }

void MSTriggeredRerouter::myStartElement ( SumoXMLTag  element,
const SUMOSAXAttributes attrs 
) throw (ProcessError) [protected, virtual]

Called on the opening of a tag;.

Parameters:
[in] element ID of the currently opened element
[in] attrs Attributes within the currently opened element
Exceptions:
ProcessError If something fails
See also:
GenericSAXHandler::myStartElement

Reimplemented from GenericSAXHandler.

Definition at line 133 of file MSTriggeredRerouter.cpp.

References RandomDistributor< T >::add(), MSRoute::dictionary(), MSEdge::dictionary(), Named::getID(), myCurrentClosed, myCurrentEdgeProb, myCurrentIntervalBegin, myCurrentIntervalEnd, myCurrentRouteProb, SUMO_ATTR_BEGIN, SUMO_ATTR_END, SUMO_ATTR_ID, SUMO_ATTR_PROB, SUMO_TAG_CLOSING_REROUTE, SUMO_TAG_DEST_PROB_REROUTE, SUMO_TAG_INTERVAL, SUMO_TAG_ROUTE_PROB_REROUTE, and SUMOReal.

00134                                                                                         {
00135     if (element==SUMO_TAG_INTERVAL) {
00136         bool ok = true;
00137         myCurrentIntervalBegin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, "interval", 0, ok, -1);
00138         myCurrentIntervalEnd = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, "interval", 0, ok, -1);
00139     }
00140 
00141     if (element==SUMO_TAG_DEST_PROB_REROUTE) {
00142         // by giving probabilities of new destinations
00143         // get the destination edge
00144         std::string dest = attrs.getStringSecure(SUMO_ATTR_ID, "");
00145         if (dest=="") {
00146             throw ProcessError("MSTriggeredRerouter " + getID() + ": No destination edge id given.");
00147         }
00148         MSEdge *to = MSEdge::dictionary(dest);
00149         if (to==0) {
00150             throw ProcessError("MSTriggeredRerouter " + getID() + ": Destination edge '" + dest + "' is not known.");
00151         }
00152         // get the probability to reroute
00153         bool ok = true;
00154         SUMOReal prob = attrs.getOptSUMORealReporting(SUMO_ATTR_PROB, "rerouter/dest_prob_reroute", getID().c_str(), ok, 1.);
00155         if (!ok) {
00156             throw ProcessError();
00157         }
00158         if (prob<0) {
00159             throw ProcessError("MSTriggeredRerouter " + getID() + ": Attribute 'probability' for destination '" + dest + "' is negative (must not).");
00160         }
00161         // add
00162         myCurrentEdgeProb.add(prob, to);
00163     }
00164 
00165     if (element==SUMO_TAG_CLOSING_REROUTE) {
00166         // by closing
00167         std::string closed_id = attrs.getStringSecure(SUMO_ATTR_ID, "");
00168         if (closed_id=="") {
00169             throw ProcessError("MSTriggeredRerouter " + getID() + ": closed edge id given.");
00170         }
00171         MSEdge *closed = MSEdge::dictionary(closed_id);
00172         if (closed==0) {
00173             throw ProcessError("MSTriggeredRerouter " + getID() + ": Edge '" + closed_id + "' to close is not known.");
00174         }
00175         myCurrentClosed.push_back(closed);
00176     }
00177 
00178     if (element==SUMO_TAG_ROUTE_PROB_REROUTE) {
00179         // by explicite rerouting using routes
00180         // check if route exists
00181         std::string routeStr = attrs.getStringSecure(SUMO_ATTR_ID, "");
00182         if (routeStr=="") {
00183             throw ProcessError("MSTriggeredRerouter " + getID() + ": No route id given.");
00184         }
00185         const MSRoute* route = MSRoute::dictionary(routeStr);
00186         if (route == 0) {
00187             throw ProcessError("MSTriggeredRerouter " + getID() + ": Route '" + routeStr + "' does not exist.");
00188         }
00189 
00190         // get the probability to reroute
00191         bool ok = true;
00192         SUMOReal prob = attrs.getOptSUMORealReporting(SUMO_ATTR_PROB, "rerouter/dest_prob_reroute", getID().c_str(), ok, 1.);
00193         if (!ok) {
00194             throw ProcessError();
00195         }
00196         if (prob<0) {
00197             throw ProcessError("MSTriggeredRerouter " + getID() + ": Attribute 'probability' for route '" + routeStr + "' is negative (must not).");
00198         }
00199         // add
00200         myCurrentRouteProb.add(prob, route);
00201     }
00202 }

MSTriggeredRerouter& MSTriggeredRerouter::operator= ( const MSTriggeredRerouter  )  [private]

Invalidated assignment operator.

void GenericSAXHandler::registerParent ( const SumoXMLTag  tag,
GenericSAXHandler handler 
) [inherited]

Assigning a parent handler which is enabled when the specified tag is closed.

Definition at line 160 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, and XMLSubSys::setHandler().

Referenced by NLTriggerBuilder::parseAndBuildLaneSpeedTrigger().

00160                                                                                   {
00161     myParentHandler = handler;
00162     myParentIndicator = tag;
00163     XMLSubSys::setHandler(*this);
00164 }

void MSTriggeredRerouter::reroute ( SUMOVehicle veh,
const MSEdge src 
)

Reroutes a vehicle.

Definition at line 287 of file MSTriggeredRerouter.cpp.

References MSTriggeredRerouter::RerouteInterval::closed, DijkstraRouterTTBase< E, V, PF >::compute(), MSEdge::dictSize(), MSTriggeredRerouter::RerouteInterval::edgeProbs, RandomDistributor< T >::get(), getCurrentReroute(), MSNet::getCurrentTimeStep(), MSRoute::getEdges(), MSNet::getInstance(), MSRoute::getLastEdge(), RandomDistributor< T >::getOverallProb(), SUMOVehicle::getRoute(), MSNet::EdgeWeightsProxi::getTravelTime(), hasCurrentReroute(), myAmInUserMode, myProbability, myUserProbability, RandHelper::rand(), SUMOVehicle::replaceRoute(), MSTriggeredRerouter::RerouteInterval::routeProbs, and SUMOReal.

Referenced by MSTriggeredRerouter::Setter::isStillActive(), and MSTriggeredRerouter::Setter::notifyEnter().

00287                                                                 {
00288     // check whether the vehicle shall be rerouted
00289     SUMOTime time = MSNet::getInstance()->getCurrentTimeStep();
00290     if (!hasCurrentReroute(time, veh)) {
00291         return;
00292     }
00293 
00294     SUMOReal prob = myAmInUserMode ? myUserProbability : myProbability;
00295     if (RandHelper::rand() > prob) {
00296         return;
00297     }
00298 
00299     // get vehicle params
00300     const MSRoute &route = veh.getRoute();
00301     const MSEdge *lastEdge = route.getLastEdge();
00302     // get rerouting params
00303     const MSTriggeredRerouter::RerouteInterval &rerouteDef = getCurrentReroute(time, veh);
00304     const MSRoute *newRoute = rerouteDef.routeProbs.getOverallProb()>0 ? rerouteDef.routeProbs.get() : 0;
00305     // we will use the route if given rather than calling our own dijsktra...
00306     if (newRoute!=0) {
00307         veh.replaceRoute(newRoute->getEdges(), time);
00308         return;
00309     }
00310     // ok, try using a new destination
00311     const MSEdge *newEdge = rerouteDef.edgeProbs.getOverallProb()>0 ? rerouteDef.edgeProbs.get() : route.getLastEdge();
00312     if (newEdge==0) {
00313         newEdge = lastEdge;
00314     }
00315 
00316     // we have a new destination, let's replace the vehicle route
00317     MSEdgeWeightsStorage empty;
00318     MSNet::EdgeWeightsProxi proxi(empty, MSNet::getInstance()->getWeightsStorage());
00319     DijkstraRouterTT_ByProxi<MSEdge, SUMOVehicle, prohibited_withRestrictions<MSEdge, SUMOVehicle>, MSNet::EdgeWeightsProxi> router(MSEdge::dictSize(), true, &proxi, &MSNet::EdgeWeightsProxi::getTravelTime);
00320     router.prohibit(rerouteDef.closed);
00321     std::vector<const MSEdge*> edges;
00322     router.compute(&src, newEdge, &veh, MSNet::getInstance()->getCurrentTimeStep(), edges);
00323     veh.replaceRoute(edges, MSNet::getInstance()->getCurrentTimeStep());
00324 }

void GenericSAXHandler::setFileName ( const std::string &  name  )  throw () [inherited]

Sets the current file name.

Parameters:
[in] name The name of the currently processed file
Todo:
Hmmm - this is as unsafe as having a direct access to the variable; recheck

Definition at line 72 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myFileName.

Referenced by PCNetProjectionLoader::loadIfSet(), ROLoader::loadNet(), NIImporter_OpenStreetMap::loadNetwork(), NILoader::loadXMLType(), and traci::TraCIServer::TraCIServer().

00072                                                             {
00073     myFileName = name;
00074 }

void MSTriggeredRerouter::setUserMode ( bool  val  ) 

Sets whether the process is currently steered by the user.

Definition at line 328 of file MSTriggeredRerouter.cpp.

References myAmInUserMode.

Referenced by MSTriggeredRerouter(), GUITriggeredRerouter::GUIManip_TriggeredRerouter::onCmdChangeOption(), and GUITriggeredRerouter::GUIManip_TriggeredRerouter::onCmdUserDef().

00328                                          {
00329     myAmInUserMode = val;
00330 }

void MSTriggeredRerouter::setUserUsageProbability ( SUMOReal  prob  ) 

Sets the probability with which a vehicle is rerouted given by the user.

Definition at line 334 of file MSTriggeredRerouter.cpp.

References myUserProbability.

Referenced by MSTriggeredRerouter(), GUITriggeredRerouter::GUIManip_TriggeredRerouter::onCmdChangeOption(), and GUITriggeredRerouter::GUIManip_TriggeredRerouter::onCmdUserDef().

00334                                                           {
00335     myUserProbability = prob;
00336 }

void GenericSAXHandler::startElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const   qname,
const Attributes &  attrs 
) [inherited]

The inherited method called when a new tag opens.

The method parses the supplied XMLCh*-qname using the internal name/enum-map to obtain the enum representation of the attribute name.

Then, "myStartElement" is called supplying the enumeration value, the string-representation of the name and the attributes.

Todo:
recheck/describe encoding of the string-representation
Todo:
do not generate and report the string-representation

Definition at line 97 of file GenericSAXHandler.cpp.

References TplConvert< E >::_2str(), GenericSAXHandler::convertTag(), FileHelpers::getConfigurationRelative(), GenericSAXHandler::getFileName(), SUMOSAXAttributesImpl_Xerces::getString(), FileHelpers::isAbsolute(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myPredefinedTags, GenericSAXHandler::myPredefinedTagsMML, GenericSAXHandler::myStartElement(), XMLSubSys::runParser(), SUMO_ATTR_HREF, and SUMO_TAG_INCLUDE.

00100                                                          {
00101     std::string name = TplConvert<XMLCh>::_2str(qname);
00102     SumoXMLTag element = convertTag(name);
00103     myCharactersVector.clear();
00104     SUMOSAXAttributesImpl_Xerces na(attrs, myPredefinedTags, myPredefinedTagsMML);
00105     if (element == SUMO_TAG_INCLUDE) {
00106         std::string file = na.getString(SUMO_ATTR_HREF);
00107         if (!FileHelpers::isAbsolute(file)) {
00108             file = FileHelpers::getConfigurationRelative(getFileName(), file);
00109         }
00110         XMLSubSys::runParser(*this, file);
00111     } else {
00112         myStartElement(element, na);
00113     }
00114 }

void SUMOSAXHandler::warning ( const SAXParseException &  exception  )  throw () [inherited]

Handler for XML-warnings.

The message is built using buildErrorMessage and reported to the warning-instance of the MsgHandler.

Parameters:
[in] exception The occured exception to process

Definition at line 68 of file SUMOSAXHandler.cpp.

References SUMOSAXHandler::buildErrorMessage(), MsgHandler::getWarningInstance(), and MsgHandler::inform().


Field Documentation

Information whether the current rerouting probability is the user-given.

Definition at line 234 of file MSTriggeredRerouter.h.

Referenced by GUITriggeredRerouter::drawGL(), getProbability(), inUserMode(), reroute(), and setUserMode().

std::vector<MSEdge*> MSTriggeredRerouter::myCurrentClosed [protected]

List of closed edges.

Definition at line 242 of file MSTriggeredRerouter.h.

Referenced by myEndElement(), and myStartElement().

new destinations with probabilities

Definition at line 244 of file MSTriggeredRerouter.h.

Referenced by myEndElement(), and myStartElement().

The first and the last time steps of the interval.

Definition at line 240 of file MSTriggeredRerouter.h.

Referenced by myEndElement(), and myStartElement().

Definition at line 240 of file MSTriggeredRerouter.h.

Referenced by myEndElement(), and myStartElement().

new routes with probabilities

Definition at line 246 of file MSTriggeredRerouter.h.

Referenced by myEndElement(), and myStartElement().

std::string Named::myID [protected, inherited]

List of rerouting definition intervals.

Definition at line 228 of file MSTriggeredRerouter.h.

Referenced by getCurrentReroute(), hasCurrentReroute(), and myEndElement().

SUMOReal MSTriggeredRerouter::myProbability [protected]

The probability and the user-given probability.

Definition at line 231 of file MSTriggeredRerouter.h.

Referenced by GUITriggeredRerouter::drawGL(), getProbability(), and reroute().

std::vector<Setter*> MSTriggeredRerouter::mySetter [protected]

List of lane-based vehicle informing children.

Definition at line 225 of file MSTriggeredRerouter.h.

Referenced by MSTriggeredRerouter(), and ~MSTriggeredRerouter().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:50 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6