SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
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-2013 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
36
#include <
utils/common/RandHelper.h
>
37
#include "
AGActivity.h
"
38
#include "../city/AGTime.h"
39
40
41
// ===========================================================================
42
// method definitions
43
// ===========================================================================
44
bool
45
AGActivity::isGenerated
() {
46
return
genDone
;
47
}
48
49
bool
50
AGActivity::generateTrips
() {
51
return
true
;
52
}
53
54
int
55
AGActivity::possibleTranspMean
(
AGPosition
destination) {
56
int
FOOT = 1;
57
int
BUS = 2;
58
int
CAR = 4;
59
60
int
transp = 0;
61
62
if
(destination.
distanceTo
(
myHousehold
->
getPosition
()) <=
myStatData
->
maxFootDistance
) {
63
transp = FOOT;
64
if
(
myHousehold
->
getCarNbr
() != 0) {
65
transp += CAR;
66
}
67
if
(destination.
minDistanceTo
(
myStatData
->
busStations
) <=
myStatData
->
maxFootDistance
68
&&
myHousehold
->
getPosition
().
minDistanceTo
(
myStatData
->
busStations
) <=
myStatData
->
maxFootDistance
) {
69
transp += BUS;
70
}
71
}
else
if
(
myHousehold
->
getCarNbr
() == 0) {
72
SUMOReal
d1 = destination.
distanceTo
(
myHousehold
->
getPosition
());
73
SUMOReal
d2 = destination.
minDistanceTo
(
myStatData
->
busStations
) +
myHousehold
->
getPosition
().
minDistanceTo
(
myStatData
->
busStations
);
74
75
if
(d1 > d2) {
76
transp = BUS;
77
}
else
{
78
transp = FOOT;
79
}
80
}
else
if
(
myHousehold
->
getCarNbr
() != 0) {
//all other cases
81
if
(destination.
minDistanceTo
(
myStatData
->
busStations
) >
myStatData
->
maxFootDistance
82
||
myHousehold
->
getPosition
().
minDistanceTo
(
myStatData
->
busStations
) >
myStatData
->
maxFootDistance
) {
83
transp = CAR;
84
}
else
{
85
transp = CAR + BUS;
86
}
87
}
88
return
transp;
89
}
90
91
int
92
AGActivity::availableTranspMeans
(
AGPosition
from,
AGPosition
to) {
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
}
101
if
(from.
minDistanceTo
(
myStatData
->
busStations
) <=
myStatData
->
maxFootDistance
102
&& to.
minDistanceTo
(
myStatData
->
busStations
) <=
myStatData
->
maxFootDistance
) {
103
available += BUS;
104
}
105
return
available;
106
}
107
108
int
109
AGActivity::timeToDrive
(
AGPosition
from,
AGPosition
to) {
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>&
139
AGActivity::getPartialActivityTrips
() {
140
return
myPartialActivityTrips
;
141
}
142
143
/****************************************************************************/
home
gladk
tmp
05
sumo-0.17.1~dfsg
src
activitygen
activities
AGActivity.cpp
Generated on Sun Jun 16 2013 07:06:57 for SUMO - Simulation of Urban MObility by
1.8.1.2