SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.sourceforge.net/
13 // Copyright (C) 2001-2012 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 /****************************************************************************/