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-2018 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
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 // SPDX-License-Identifier: EPL-2.0
11 /****************************************************************************/
19 // Parent object for all activities. Derived classes generate trips for each
20 // household.
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
30 #include "AGActivity.h"
31 #include "../city/AGTime.h"
32 
33 
34 // ===========================================================================
35 // method definitions
36 // ===========================================================================
37 bool
39  return genDone;
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 int
103  double dist = from.distanceTo(to);
104  return (int)(timePerKm * dist / 1000.0);
105 }
106 
107 int
108 AGActivity::depHour(AGPosition from, AGPosition to, int arrival) {
109  // ?? departure.addDays(1); // in case of negative time: arrival < timeToDrive
110  //departure.setDay(0); // days are set to 0 because we want the time in the current day
111  return (arrival - timeToDrive(from, to));
112 }
113 
114 int
115 AGActivity::arrHour(AGPosition from, AGPosition to, int departure) {
116  return (departure + timeToDrive(from, to));
117 }
118 
119 int
120 AGActivity::randomTimeBetween(int begin, int end) {
121  if (0 > begin || begin > end) {
122  return -1;
123  }
124  if (begin == end) {
125  return begin;
126  }
127  int tAlea = RandHelper::rand(end - begin);
128  return (begin + tAlea);
129 }
130 
131 std::list<AGTrip>&
133  return myPartialActivityTrips;
134 }
135 
136 /****************************************************************************/
int depHour(AGPosition from, AGPosition to, int arrival)
Definition: AGActivity.cpp:108
int timeToDrive(AGPosition from, AGPosition to)
Definition: AGActivity.cpp:102
virtual bool generateTrips()=0
Definition: AGActivity.cpp:43
bool isGenerated()
Definition: AGActivity.cpp:38
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:61
A location in the 2D plane freely positioned on a street.
Definition: AGPosition.h:56
AGDataAndStatistics * myStatData
Definition: AGActivity.h:105
double timePerKm
Definition: AGActivity.h:111
int getCarNbr()
Definition: AGHousehold.cpp:82
double minDistanceTo(const std::list< AGPosition > &positions) const
Computes the distance to the closest position in a list.
Definition: AGPosition.cpp:69
std::list< AGTrip > & getPartialActivityTrips()
Definition: AGActivity.cpp:132
int availableTranspMeans(AGPosition from, AGPosition to)
Definition: AGActivity.cpp:85
double distanceTo(const AGPosition &otherPos) const
Computes the distance between two AGPosition objects.
Definition: AGPosition.cpp:63
int randomTimeBetween(int begin, int end)
Definition: AGActivity.cpp:120
AGHousehold * myHousehold
Definition: AGActivity.h:103
AGPosition getPosition()
int arrHour(AGPosition from, AGPosition to, int departure)
Definition: AGActivity.cpp:115
int possibleTranspMean(AGPosition destination)
Definition: AGActivity.cpp:48
std::list< AGTrip > myPartialActivityTrips
Definition: AGActivity.h:108
std::map< int, AGPosition > busStations
bool genDone
Definition: AGActivity.h:110