Eclipse 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.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // activitygen module
5 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
6 // This program and the accompanying materials are made available under the
7 // terms of the Eclipse Public License 2.0 which is available at
8 // https://www.eclipse.org/legal/epl-2.0/
9 // This Source Code may also be made available under the following Secondary
10 // Licenses when the conditions for such availability set forth in the Eclipse
11 // Public License 2.0 are satisfied: GNU General Public License, version 2
12 // or later which is available at
13 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
14 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
15 /****************************************************************************/
22 // Parent object for all activities. Derived classes generate trips for each
23 // household.
24 /****************************************************************************/
25 #include <config.h>
26 
30 #include "AGActivity.h"
31 
32 
33 // ===========================================================================
34 // method definitions
35 // ===========================================================================
36 bool
38  return genDone;
39 }
40 
41 
42 bool
44  return true;
45 }
46 
47 int
49  int FOOT = 1;
50  int BUS = 2;
51  int CAR = 4;
52 
53  int transp = 0;
54 
56  transp = FOOT;
57  if (myHousehold->getCarNbr() != 0) {
58  transp += CAR;
59  }
62  transp += BUS;
63  }
64  } else if (myHousehold->getCarNbr() == 0) {
65  double d1 = destination.distanceTo(myHousehold->getPosition());
67 
68  if (d1 > d2) {
69  transp = BUS;
70  } else {
71  transp = FOOT;
72  }
73  } else if (myHousehold->getCarNbr() != 0) { //all other cases
76  transp = CAR;
77  } else {
78  transp = CAR + BUS;
79  }
80  }
81  return transp;
82 }
83 
84 int
86  int FOOT = 1;
87  int BUS = 2;
88 
89  int available = 0;
90 
91  if (from.distanceTo(to) <= myStatData->maxFootDistance) {
92  available += FOOT;
93  }
96  available += BUS;
97  }
98  return available;
99 }
100 
101 
102 int
104  double dist = from.distanceTo(to);
105  return (int)(timePerKm * dist / 1000.0);
106 }
107 
108 
109 int
110 AGActivity::depHour(AGPosition from, AGPosition to, int arrival) {
111  // ?? departure.addDays(1); // in case of negative time: arrival < timeToDrive
112  //departure.setDay(0); // days are set to 0 because we want the time in the current day
113  return (arrival - timeToDrive(from, to));
114 }
115 
116 
117 int
118 AGActivity::arrHour(AGPosition from, AGPosition to, int departure) {
119  return (departure + timeToDrive(from, to));
120 }
121 
122 
123 int
124 AGActivity::randomTimeBetween(int begin, int end) {
125  if (0 > begin || begin > end) {
126  return -1;
127  }
128  if (begin == end) {
129  return begin;
130  }
131  int tAlea = RandHelper::rand(end - begin);
132  return (begin + tAlea);
133 }
134 
135 
136 std::list<AGTrip>&
138  return myPartialActivityTrips;
139 }
140 
141 
142 /****************************************************************************/
@ BUS
render as a bus
std::list< AGTrip > & getPartialActivityTrips()
Definition: AGActivity.cpp:137
bool isGenerated()
Definition: AGActivity.cpp:37
virtual bool generateTrips()=0
Definition: AGActivity.cpp:43
bool genDone
Definition: AGActivity.h:115
AGHousehold * myHousehold
Definition: AGActivity.h:108
std::list< AGTrip > myPartialActivityTrips
Definition: AGActivity.h:113
int availableTranspMeans(AGPosition from, AGPosition to)
Definition: AGActivity.cpp:85
AGDataAndStatistics * myStatData
Definition: AGActivity.h:110
int possibleTranspMean(AGPosition destination)
Definition: AGActivity.cpp:48
int depHour(AGPosition from, AGPosition to, int arrival)
Definition: AGActivity.cpp:110
double timePerKm
Definition: AGActivity.h:116
int arrHour(AGPosition from, AGPosition to, int departure)
Definition: AGActivity.cpp:118
int randomTimeBetween(int begin, int end)
Definition: AGActivity.cpp:124
int timeToDrive(AGPosition from, AGPosition to)
Definition: AGActivity.cpp:103
std::map< int, AGPosition > busStations
AGPosition getPosition()
int getCarNbr()
Definition: AGHousehold.cpp:83
A location in the 2D plane freely positioned on a street.
Definition: AGPosition.h:53
double distanceTo(const AGPosition &otherPos) const
Computes the distance between two AGPosition objects.
Definition: AGPosition.cpp:61
double minDistanceTo(const std::list< AGPosition > &positions) const
Computes the distance to the closest position in a list.
Definition: AGPosition.cpp:67
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.cpp:94