Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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// ===========================================================================
36bool
40
41
42bool
44 return true;
45}
46
47int
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
84int
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
102int
104 double dist = from.distanceTo(to);
105 return (int)(timePerKm * dist / 1000.0);
106}
107
108
109int
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
117int
118AGActivity::arrHour(AGPosition from, AGPosition to, int departure) {
119 return (departure + timeToDrive(from, to));
120}
121
122
123int
124AGActivity::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
136std::list<AGTrip>&
140
141
142/****************************************************************************/
@ BUS
render as a bus
std::list< AGTrip > & getPartialActivityTrips()
bool isGenerated()
virtual bool generateTrips()=0
AGHousehold * myHousehold
Definition AGActivity.h:108
std::list< AGTrip > myPartialActivityTrips
Definition AGActivity.h:113
int availableTranspMeans(AGPosition from, AGPosition to)
AGDataAndStatistics * myStatData
Definition AGActivity.h:110
int possibleTranspMean(AGPosition destination)
int depHour(AGPosition from, AGPosition to, int arrival)
double timePerKm
Definition AGActivity.h:116
int arrHour(AGPosition from, AGPosition to, int departure)
int randomTimeBetween(int begin, int end)
int timeToDrive(AGPosition from, AGPosition to)
std::map< int, AGPosition > busStations
AGPosition getPosition()
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.
double minDistanceTo(const std::list< AGPosition > &positions) const
Computes the distance to the closest position in a list.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)