SUMO - Simulation of Urban MObility
AGActivity.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Parent object for all activities. Derived classes generate trips for each
10 // household.
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
14 // activitygen module
15 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
37 #include "AGActivity.h"
38 #include "../city/AGTime.h"
39 
40 
41 // ===========================================================================
42 // method definitions
43 // ===========================================================================
44 bool
46  return genDone;
47 }
48 
49 bool
51  return true;
52 }
53 
54 int
56  int FOOT = 1;
57  int BUS = 2;
58  int CAR = 4;
59 
60  int transp = 0;
61 
63  transp = FOOT;
64  if (myHousehold->getCarNbr() != 0) {
65  transp += CAR;
66  }
69  transp += BUS;
70  }
71  } else if (myHousehold->getCarNbr() == 0) {
72  SUMOReal d1 = destination.distanceTo(myHousehold->getPosition());
74 
75  if (d1 > d2) {
76  transp = BUS;
77  } else {
78  transp = FOOT;
79  }
80  } else if (myHousehold->getCarNbr() != 0) { //all other cases
83  transp = CAR;
84  } else {
85  transp = CAR + BUS;
86  }
87  }
88  return transp;
89 }
90 
91 int
93  int FOOT = 1;
94  int BUS = 2;
95 
96  int available = 0;
97 
98  if (from.distanceTo(to) <= myStatData->maxFootDistance) {
99  available += FOOT;
100  }
103  available += BUS;
104  }
105  return available;
106 }
107 
108 int
110  SUMOReal dist = from.distanceTo(to);
111  return (int)(timePerKm * dist / 1000.0);
112 }
113 
114 int
115 AGActivity::depHour(AGPosition from, AGPosition to, int arrival) {
116  // ?? departure.addDays(1); // in case of negative time: arrival < timeToDrive
117  //departure.setDay(0); // days are set to 0 because we want the time in the current day
118  return (arrival - timeToDrive(from, to));
119 }
120 
121 int
122 AGActivity::arrHour(AGPosition from, AGPosition to, int departure) {
123  return (departure + timeToDrive(from, to));
124 }
125 
126 int
127 AGActivity::randomTimeBetween(int begin, int end) {
128  if (0 > begin || begin > end) {
129  return -1;
130  }
131  if (begin == end) {
132  return begin;
133  }
134  int tAlea = RandHelper::rand(end - begin);
135  return (begin + tAlea);
136 }
137 
138 std::list<AGTrip>&
140  return myPartialActivityTrips;
141 }
142 
143 /****************************************************************************/
int depHour(AGPosition from, AGPosition to, int arrival)
Definition: AGActivity.cpp:115
int timeToDrive(AGPosition from, AGPosition to)
Definition: AGActivity.cpp:109
virtual bool generateTrips()=0
Definition: AGActivity.cpp:50
bool isGenerated()
Definition: AGActivity.cpp:45
A location in the 2D plane freely positioned on a street.
Definition: AGPosition.h:63
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
AGDataAndStatistics * myStatData
Definition: AGActivity.h:112
int getCarNbr()
Definition: AGHousehold.cpp:89
SUMOReal minDistanceTo(const std::list< AGPosition > &positions) const
Computes the distance to the closest position in a list.
Definition: AGPosition.cpp:76
std::list< AGTrip > & getPartialActivityTrips()
Definition: AGActivity.cpp:139
int availableTranspMeans(AGPosition from, AGPosition to)
Definition: AGActivity.cpp:92
int randomTimeBetween(int begin, int end)
Definition: AGActivity.cpp:127
AGHousehold * myHousehold
Definition: AGActivity.h:110
AGPosition getPosition()
int arrHour(AGPosition from, AGPosition to, int departure)
Definition: AGActivity.cpp:122
int possibleTranspMean(AGPosition destination)
Definition: AGActivity.cpp:55
std::list< AGTrip > myPartialActivityTrips
Definition: AGActivity.h:115
SUMOReal distanceTo(const AGPosition &otherPos) const
Computes the distance between two AGPosition objects.
Definition: AGPosition.cpp:70
#define SUMOReal
Definition: config.h:213
SUMOReal timePerKm
Definition: AGActivity.h:118
std::map< int, AGPosition > busStations
bool genDone
Definition: AGActivity.h:117