Skip to content

Commit

Permalink
{amitran} fixing remarks from the code review, removing emission-mode…
Browse files Browse the repository at this point in the history
…l and a lot of refactoring, refs #12

git-svn-id: file:///home/behr_mi/git/sumo_synched/branches/amitran@16165 afbd958f-9f77-42d5-a016-97a22340ccf4
  • Loading branch information
behrisch committed Apr 11, 2014
1 parent d67b147 commit b967a69
Show file tree
Hide file tree
Showing 51 changed files with 275 additions and 163 deletions.
3 changes: 0 additions & 3 deletions sumo/src/activitygen/AGFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ void AGFrame::fillOptions() {
oc.addDescription("duration-d", "Time", "Sets the duration of the simulation in days");

// Options needed by the router
oc.doRegister("emission-model", new Option_String("HBEFA2"));
oc.addDescription("emission-model", "Processing", "Use the model given as default for emission calculations");

oc.doRegister("weights.interpolate", new Option_Bool(false));
oc.addSynonyme("weights.interpolate", "interpolate", true);
oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
Expand Down
4 changes: 4 additions & 0 deletions sumo/src/activitygen/activitygen_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ loadNet(RONet& toFill, ROAbstractEdgeBuilder& eb) {
} else {
PROGRESS_DONE_MESSAGE();
}
if (!deprecatedVehicleClassesSeen.empty()) {
WRITE_WARNING("Deprecated vehicle classes '" + toString(deprecatedVehicleClassesSeen) + "' in input network.");
deprecatedVehicleClassesSeen.clear();
}
}


Expand Down
3 changes: 0 additions & 3 deletions sumo/src/dfrouter/RODFFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ RODFFrame::fillOptions() {
oc.doRegister("arrivalspeed", new Option_String());
oc.addDescription("arrivalspeed", "Defaults", "Assigns a default arrival speed");

oc.doRegister("emission-model", new Option_String("HBEFA2"));
oc.addDescription("emission-model", "Defaults", "Use the model given as default for emission calculations");


// register the simulation settings
oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
Expand Down
4 changes: 2 additions & 2 deletions sumo/src/guisim/GUILane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ GUILane::getParameterWindow(GUIMainWindow& app,
ret->mkItem("length [m]", false, myLength);
ret->mkItem("street name", false, myEdge->getStreetName());
ret->mkItem("stored traveltime [s]", true, new FunctionBinding<GUILane, SUMOReal>(this, &GUILane::getStoredEdgeTravelTime));
ret->mkItem("allowed vehicle class", false, getAllowedVehicleClassNames(myPermissions));
ret->mkItem("disallowed vehicle class", false, getAllowedVehicleClassNames(~myPermissions));
ret->mkItem("allowed vehicle class", false, getVehicleClassNames(myPermissions));
ret->mkItem("disallowed vehicle class", false, getVehicleClassNames(~myPermissions));
// close building
ret->closeBuilding();
return ret;
Expand Down
2 changes: 2 additions & 0 deletions sumo/src/guisim/GUIVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ GUIVehicle::drawAction_drawVehicleAsPoly(const GUIVisualizationSettings& s) cons
drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
break;
case SVS_BUS:
case SVS_BUS_COACH:
case SVS_BUS_TROLLEY: {
SUMOReal ml = length;
glScaled(1. / (length), 1, 1.);
Expand Down Expand Up @@ -737,6 +738,7 @@ GUIVehicle::drawAction_drawVehicleAsPoly(const GUIVisualizationSettings& s) cons
glPopMatrix();
break;
case SVS_BUS:
case SVS_BUS_COACH:
case SVS_BUS_FLEXIBLE:
case SVS_RAIL:
case SVS_RAIL_CAR:
Expand Down
4 changes: 2 additions & 2 deletions sumo/src/microsim/MSEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ MSEdge::initialize(std::vector<MSLane*>* lanes) {
myLaneChanger = new MSLaneChanger(myLanes, OptionsCont::getOptions().getBool("lanechange.allow-swap"));
}
if (myFunction == EDGEFUNCTION_DISTRICT) {
myCombinedPermissions = SVCFreeForAll;
myCombinedPermissions = SVCAll;
}
}

Expand Down Expand Up @@ -172,7 +172,7 @@ MSEdge::rebuildAllowedLanes() {
}
myClassedAllowed.clear();
// rebuild myMinimumPermissions and myCombinedPermissions
myMinimumPermissions = SVCFreeForAll;
myMinimumPermissions = SVCAll;
myCombinedPermissions = 0;
for (std::vector<MSLane*>::iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
myMinimumPermissions &= (*i)->getPermissions();
Expand Down
2 changes: 0 additions & 2 deletions sumo/src/microsim/MSFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ MSFrame::fillOptions() {
std::string plp = getenv("PHEMLIGHT_PATH")==0 ? "./PHEMlight/" : std::string(getenv("PHEMLIGHT_PATH"));
oc.doRegister("phemlight-path", new Option_FileName(plp));
oc.addDescription("phemlight-path", "Emissions", "Determines where to load PHEMlight definitions from.");
oc.doRegister("emission-model", new Option_String("HBEFA2"));
oc.addDescription("emission-model", "Emissions", "Use the model given as default for emission calculations");

oc.addOptionSubTopic("Communication");
MSDevice::insertOptions(oc);
Expand Down
8 changes: 7 additions & 1 deletion sumo/src/microsim/MSVehicleType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,17 @@
#endif // CHECK_MEMORY_LEAKS


// ===========================================================================
// static members
// ===========================================================================
int MSVehicleType::myNextIndex = 0;


// ===========================================================================
// method definitions
// ===========================================================================
MSVehicleType::MSVehicleType(const SUMOVTypeParameter& parameter)
: myParameter(parameter), myOriginalType(0) {
: myParameter(parameter), myIndex(myNextIndex++), myOriginalType(0) {
assert(getLength() > 0);
assert(getMaxSpeed() > 0);
}
Expand Down
14 changes: 14 additions & 0 deletions sumo/src/microsim/MSVehicleType.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ class MSVehicleType {
}


/** @brief Returns the running index of the vehicle type
* @return This type's numerical id
*/
const int getNumericalID() const {
return myIndex;
}


/** @brief Get vehicle's length [m]
* @return The length vehicles of this type have in m
*/
Expand Down Expand Up @@ -408,12 +416,18 @@ class MSVehicleType {
/// @brief the parameter container
SUMOVTypeParameter myParameter;

/// @brief the running index
const int myIndex;

/// @brief ID of the car following model.
MSCFModel* myCarFollowModel;

/// @brief The original type
const MSVehicleType* myOriginalType;

/// @brief next value for the running index
static int myNextIndex;


private:
/// @brief Invalidated copy constructor
Expand Down
30 changes: 18 additions & 12 deletions sumo/src/microsim/output/MSMeanData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
// ---------------------------------------------------------------------------
MSMeanData::MeanDataValues::MeanDataValues(
MSLane* const lane, const SUMOReal length, const bool doAdd,
const std::map<std::string, unsigned>* const vTypes) :
const std::set<std::string>* const vTypes) :
MSMoveReminder("meandata_" + (lane == 0 ? "NULL" : lane->getID()), lane, doAdd),
myLaneLength(length),
sampleSeconds(0),
Expand Down Expand Up @@ -144,7 +144,7 @@ MSMeanData::MeanDataValues::getSamples() const {
// ---------------------------------------------------------------------------
MSMeanData::MeanDataValueTracker::MeanDataValueTracker(MSLane* const lane,
const SUMOReal length,
const std::map<std::string, unsigned>* const vTypes,
const std::set<std::string>* const vTypes,
const MSMeanData* const parent)
: MSMeanData::MeanDataValues(lane, length, true, vTypes), myParent(parent) {
myCurrentData.push_back(new TrackerEntry(parent->createValues(lane, length, false)));
Expand Down Expand Up @@ -252,7 +252,7 @@ MSMeanData::MSMeanData(const std::string& id,
const bool printDefaults, const bool withInternal, const bool trackVehicles,
const SUMOReal maxTravelTime,
const SUMOReal minSamples,
const std::map<std::string, unsigned> vTypes) :
const std::set<std::string> vTypes) :
MSDetectorFileOutput(id),
myMinSamples(minSamples),
myMaxTravelTime(maxTravelTime),
Expand Down Expand Up @@ -349,6 +349,12 @@ MSMeanData::resetOnly(SUMOTime stopTime) {
}


std::string
MSMeanData::getEdgeID(const MSEdge* const edge) {
return edge->getID();
}


void
MSMeanData::writeEdge(OutputDevice& dev,
const std::vector<MeanDataValues*>& edgeValues,
Expand Down Expand Up @@ -408,8 +414,7 @@ MSMeanData::writeEdge(OutputDevice& dev,
meanData.addTo(*sumData);
meanData.reset();
}
const std::string id = dynamic_cast<MSMeanData_Amitran*>(this) == 0 ? edge->getID() : toString(edge->getNumericalID());
if (writePrefix(dev, *sumData, SUMO_TAG_EDGE, id)) {
if (writePrefix(dev, *sumData, SUMO_TAG_EDGE, getEdgeID(edge))) {
sumData->write(dev, stopTime - startTime, (SUMOReal)edge->getLanes().size(), myPrintDefaults ? edge->getLength() / edge->getSpeedLimit() : -1.);
}
delete sumData;
Expand All @@ -418,6 +423,13 @@ MSMeanData::writeEdge(OutputDevice& dev,
}


void
MSMeanData::openInterval(OutputDevice& dev, const SUMOTime startTime, const SUMOTime stopTime) {
dev.openTag(SUMO_TAG_INTERVAL).writeAttr(SUMO_ATTR_BEGIN, STEPS2TIME(startTime)).writeAttr(SUMO_ATTR_END, STEPS2TIME(stopTime));
dev.writeAttr(SUMO_ATTR_ID, myID);
}


bool
MSMeanData::writePrefix(OutputDevice& dev, const MeanDataValues& values, const SumoXMLTag tag, const std::string id) const {
if (myDumpEmpty || !values.isEmpty()) {
Expand Down Expand Up @@ -457,13 +469,7 @@ MSMeanData::writeXMLOutput(OutputDevice& dev,
stopTime = myPendingIntervals.front().second;
myPendingIntervals.pop_front();
}
if (dynamic_cast<MSMeanData_Amitran*>(this) == 0) {
dev.openTag(SUMO_TAG_INTERVAL).writeAttr(SUMO_ATTR_BEGIN, STEPS2TIME(startTime)).writeAttr(SUMO_ATTR_END, STEPS2TIME(stopTime));
dev.writeAttr(SUMO_ATTR_ID, myID);
} else {
int duration = int(1000 * STEPS2TIME(stopTime - startTime) + 0.5);
dev.openTag("timeSlice").writeAttr("startTime", int(1000 * STEPS2TIME(startTime) + 0.5)).writeAttr("duration", duration);
}
openInterval(dev, startTime, stopTime);
std::vector<MSEdge*>::iterator edge = myEdges.begin();
for (std::vector<std::vector<MeanDataValues*> >::const_iterator i = myMeasures.begin(); i != myMeasures.end(); ++i, ++edge) {
writeEdge(dev, (*i), *edge, startTime, stopTime);
Expand Down
26 changes: 20 additions & 6 deletions sumo/src/microsim/output/MSMeanData.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class MSMeanData : public MSDetectorFileOutput {
class MeanDataValues : public MSMoveReminder {
public:
/** @brief Constructor */
MeanDataValues(MSLane* const lane, const SUMOReal length, const bool doAdd, const std::map<std::string, unsigned>* const vTypes = 0);
MeanDataValues(MSLane* const lane, const SUMOReal length, const bool doAdd, const std::set<std::string>* const vTypes = 0);

/** @brief Destructor */
virtual ~MeanDataValues();
Expand Down Expand Up @@ -182,7 +182,7 @@ class MSMeanData : public MSDetectorFileOutput {

protected:
/// @brief The vehicle types to look for (0 or empty means all)
const std::map<std::string, unsigned>* const myVehicleTypes;
const std::set<std::string>* const myVehicleTypes;

};

Expand All @@ -195,7 +195,7 @@ class MSMeanData : public MSDetectorFileOutput {
public:
/** @brief Constructor */
MeanDataValueTracker(MSLane* const lane, const SUMOReal length,
const std::map<std::string, unsigned>* const vTypes = 0,
const std::set<std::string>* const vTypes = 0,
const MSMeanData* const parent = 0);

/** @brief Destructor */
Expand Down Expand Up @@ -322,7 +322,7 @@ class MSMeanData : public MSDetectorFileOutput {
const bool printDefaults, const bool withInternal,
const bool trackVehicles, const SUMOReal minSamples,
const SUMOReal maxTravelTime,
const std::map<std::string, unsigned> vTypes);
const std::set<std::string> vTypes);


/// @brief Destructor
Expand Down Expand Up @@ -376,10 +376,16 @@ class MSMeanData : public MSDetectorFileOutput {
/** @brief Resets network value in order to allow processing of the next interval
*
* Goes through the lists of edges and starts "resetOnly" for each edge.
* @param [in] edge The last time step that is reported
* @param[in] edge The last time step that is reported
*/
void resetOnly(SUMOTime stopTime);

/** @brief Return the relevant edge id
*
* @param[in] edge The edge to retrieve the id for
*/
virtual std::string getEdgeID(const MSEdge* const edge);

/** @brief Writes edge values into the given stream
*
* microsim: It is checked whether the dump shall be generated edge-
Expand All @@ -397,6 +403,14 @@ class MSMeanData : public MSDetectorFileOutput {
void writeEdge(OutputDevice& dev, const std::vector<MeanDataValues*>& edgeValues,
MSEdge* edge, SUMOTime startTime, SUMOTime stopTime);

/** @brief Writes the interval opener
*
* @param[in] dev The output device to write the data into
* @param[in] startTime First time step the data were gathered
* @param[in] stopTime Last time step the data were gathered
*/
virtual void openInterval(OutputDevice& dev, const SUMOTime startTime, const SUMOTime stopTime);

/** @brief Checks for emptiness and writes prefix into the given stream
*
* @param[in] dev The output device to write the data into
Expand All @@ -417,7 +431,7 @@ class MSMeanData : public MSDetectorFileOutput {
const SUMOReal myMaxTravelTime;

/// @brief The vehicle types to look for (empty means all)
const std::map<std::string, unsigned> myVehicleTypes;
const std::set<std::string> myVehicleTypes;

/// @brief Value collectors; sorted by edge, then by lane
std::vector<std::vector<MeanDataValues*> > myMeasures;
Expand Down
19 changes: 16 additions & 3 deletions sumo/src/microsim/output/MSMeanData_Amitran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
MSMeanData_Amitran::MSLaneMeanDataValues::MSLaneMeanDataValues(MSLane* const lane,
const SUMOReal length,
const bool doAdd,
const std::map<std::string, unsigned>* const vTypes,
const std::set<std::string>* const vTypes,
const MSMeanData_Amitran* parent)
: MSMeanData::MeanDataValues(lane, length, doAdd, vTypes), amount(0) {}

Expand Down Expand Up @@ -137,7 +137,7 @@ MSMeanData_Amitran::MSLaneMeanDataValues::write(OutputDevice& dev, const SUMOTim
}
if (myVehicleTypes != 0 && !myVehicleTypes->empty()) {
for (std::map<const MSVehicleType*, unsigned>::const_iterator it = typedAmount.begin(); it != typedAmount.end(); ++it) {
dev.openTag("actorConfig").writeAttr(SUMO_ATTR_ID, myVehicleTypes->find(it->first->getID())->second);
dev.openTag("actorConfig").writeAttr(SUMO_ATTR_ID, it->first->getNumericalID());
dev.writeAttr("amount", it->second).writeAttr("averageSpeed", int(100 * typedTravelDistance.find(it->first)->second / typedSamples.find(it->first)->second));
dev.closeTag();
}
Expand All @@ -157,7 +157,7 @@ MSMeanData_Amitran::MSMeanData_Amitran(const std::string& id,
const SUMOReal maxTravelTime,
const SUMOReal minSamples,
const SUMOReal haltSpeed,
const std::map<std::string, unsigned> vTypes)
const std::set<std::string> vTypes)
: MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
withInternal, trackVehicles, maxTravelTime, minSamples, vTypes),
myHaltSpeed(haltSpeed) {
Expand All @@ -173,6 +173,19 @@ MSMeanData_Amitran::writeXMLDetectorProlog(OutputDevice& dev) const {
}


std::string
MSMeanData_Amitran::getEdgeID(const MSEdge* const edge) {
return toString(edge->getNumericalID());
}


void
MSMeanData_Amitran::openInterval(OutputDevice& dev, const SUMOTime startTime, const SUMOTime stopTime) {
const int duration = int(1000 * STEPS2TIME(stopTime - startTime) + 0.5);
dev.openTag(SUMO_TAG_TIMESLICE).writeAttr(SUMO_ATTR_STARTTIME, int(1000 * STEPS2TIME(startTime) + 0.5)).writeAttr(SUMO_ATTR_DURATION, duration);
}


bool
MSMeanData_Amitran::writePrefix(OutputDevice& dev, const MeanDataValues& values, const SumoXMLTag tag, const std::string id) const {
if (myDumpEmpty || !values.isEmpty()) {
Expand Down
18 changes: 16 additions & 2 deletions sumo/src/microsim/output/MSMeanData_Amitran.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MSMeanData_Amitran : public MSMeanData {
* @param[in] length The length of the object for which the data gets collected
*/
MSLaneMeanDataValues(MSLane* const lane, const SUMOReal length, const bool doAdd,
const std::map<std::string, unsigned>* const vTypes = 0,
const std::set<std::string>* const vTypes = 0,
const MSMeanData_Amitran* parent = 0);

/** @brief Destructor */
Expand Down Expand Up @@ -178,7 +178,7 @@ class MSMeanData_Amitran : public MSMeanData {
const bool useLanes, const bool withEmpty, const bool printDefaults,
const bool withInternal, const bool trackVehicles,
const SUMOReal maxTravelTime, const SUMOReal minSamples,
const SUMOReal haltSpeed, const std::map<std::string, unsigned> vTypes);
const SUMOReal haltSpeed, const std::set<std::string> vTypes);


/// @brief Destructor
Expand All @@ -196,6 +196,20 @@ class MSMeanData_Amitran : public MSMeanData {
virtual void writeXMLDetectorProlog(OutputDevice& dev) const;
/// @}

/** @brief Return the relevant edge id
*
* @param[in] edge The edge to retrieve the id for
*/
virtual std::string getEdgeID(const MSEdge* const edge);

/** @brief Writes the interval opener
*
* @param[in] dev The output device to write the data into
* @param[in] startTime First time step the data were gathered
* @param[in] stopTime Last time step the data were gathered
*/
virtual void openInterval(OutputDevice& dev, const SUMOTime startTime, const SUMOTime stopTime);

/** @brief Checks for emptiness and writes prefix into the given stream
*
* @param[in] dev The output device to write the data into
Expand Down
Loading

0 comments on commit b967a69

Please sign in to comment.