SUMO - Simulation of Urban MObility
AGActivity.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 // activitygen module
5 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
6 /****************************************************************************/
7 //
8 // This program and the accompanying materials
9 // are made available under the terms of the Eclipse Public License v2.0
10 // which accompanies this distribution, and is available at
11 // http://www.eclipse.org/legal/epl-v20.html
12 //
13 /****************************************************************************/
21 // Parent object for all activities. Derived classes generate trips for each
22 // household.
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
36 #include "AGActivity.h"
37 #include "../city/AGTime.h"
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
43 bool
45  return genDone;
46 }
47 
48 bool
50  return true;
51 }
52 
53 int
55  int FOOT = 1;
56  int BUS = 2;
57  int CAR = 4;
58 
59  int transp = 0;
60 
62  transp = FOOT;
63  if (myHousehold->getCarNbr() != 0) {
64  transp += CAR;
65  }
68  transp += BUS;
69  }
70  } else if (myHousehold->getCarNbr() == 0) {
71  double d1 = destination.distanceTo(myHousehold->getPosition());
73 
74  if (d1 > d2) {
75  transp = BUS;
76  } else {
77  transp = FOOT;
78  }
79  } else if (myHousehold->getCarNbr() != 0) { //all other cases
82  transp = CAR;
83  } else {
84  transp = CAR + BUS;
85  }
86  }
87  return transp;
88 }
89 
90 int
92  int FOOT = 1;
93  int BUS = 2;
94 
95  int available = 0;
96 
97  if (from.distanceTo(to) <= myStatData->maxFootDistance) {
98  available += FOOT;
99  }
102  available += BUS;
103  }
104  return available;
105 }
106 
107 int
109  double dist = from.distanceTo(to);
110  return (int)(timePerKm * dist / 1000.0);
111 }
112 
113 int
114 AGActivity::depHour(AGPosition from, AGPosition to, int arrival) {
115  // ?? departure.addDays(1); // in case of negative time: arrival < timeToDrive
116  //departure.setDay(0); // days are set to 0 because we want the time in the current day
117  return (arrival - timeToDrive(from, to));
118 }
119 
120 int
121 AGActivity::arrHour(AGPosition from, AGPosition to, int departure) {
122  return (departure + timeToDrive(from, to));
123 }
124 
125 int
126 AGActivity::randomTimeBetween(int begin, int end) {
127  if (0 > begin || begin > end) {
128  return -1;
129  }
130  if (begin == end) {
131  return begin;
132  }
133  int tAlea = RandHelper::rand(end - begin);
134  return (begin + tAlea);
135 }
136 
137 std::list<AGTrip>&
139  return myPartialActivityTrips;
140 }
141 
142 /****************************************************************************/
int depHour(AGPosition from, AGPosition to, int arrival)
Definition: AGActivity.cpp:114
int timeToDrive(AGPosition from, AGPosition to)
Definition: AGActivity.cpp:108
virtual bool generateTrips()=0
Definition: AGActivity.cpp:49
bool isGenerated()
Definition: AGActivity.cpp:44
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:64
A location in the 2D plane freely positioned on a street.
Definition: AGPosition.h:62
AGDataAndStatistics * myStatData
Definition: AGActivity.h:111
double timePerKm
Definition: AGActivity.h:117
int getCarNbr()
Definition: AGHousehold.cpp:88
double minDistanceTo(const std::list< AGPosition > &positions) const
Computes the distance to the closest position in a list.
Definition: AGPosition.cpp:75
std::list< AGTrip > & getPartialActivityTrips()
Definition: AGActivity.cpp:138
int availableTranspMeans(AGPosition from, AGPosition to)
Definition: AGActivity.cpp:91
double distanceTo(const AGPosition &otherPos) const
Computes the distance between two AGPosition objects.
Definition: AGPosition.cpp:69
int randomTimeBetween(int begin, int end)
Definition: AGActivity.cpp:126
AGHousehold * myHousehold
Definition: AGActivity.h:109
AGPosition getPosition()
int arrHour(AGPosition from, AGPosition to, int departure)
Definition: AGActivity.cpp:121
int possibleTranspMean(AGPosition destination)
Definition: AGActivity.cpp:54
std::list< AGTrip > myPartialActivityTrips
Definition: AGActivity.h:114
std::map< int, AGPosition > busStations
bool genDone
Definition: AGActivity.h:116