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
Distribution_Points.cpp
Go to the documentation of this file.
1
/****************************************************************************/
8
// The description of a distribution by a curve
9
/****************************************************************************/
10
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
12
/****************************************************************************/
13
//
14
// This file is part of SUMO.
15
// SUMO is free software: you can redistribute it and/or modify
16
// it under the terms of the GNU General Public License as published by
17
// the Free Software Foundation, either version 3 of the License, or
18
// (at your option) any later version.
19
//
20
/****************************************************************************/
21
22
23
// ===========================================================================
24
// included modules
25
// ===========================================================================
26
#ifdef _MSC_VER
27
#include <
windows_config.h
>
28
#else
29
#include <
config.h
>
30
#endif
31
32
#include <cassert>
33
#include "
Distribution.h
"
34
#include <
utils/geom/PositionVector.h
>
35
#include "
Distribution_Points.h
"
36
#include <
utils/common/StdDefs.h
>
37
38
#ifdef CHECK_MEMORY_LEAKS
39
#include <
foreign/nvwa/debug_new.h
>
40
#endif // CHECK_MEMORY_LEAKS
41
42
43
// ===========================================================================
44
// method definitions
45
// ===========================================================================
46
Distribution_Points::Distribution_Points
(
const
std::string&
id
,
47
const
PositionVector
& points,
48
bool
interpolating)
49
:
Distribution
(id), myPoints(points), myProbabilitiesAreComputed(false),
50
myInterpolateDist(interpolating) {}
51
52
53
Distribution_Points::~Distribution_Points
() {}
54
55
56
SUMOReal
57
Distribution_Points::getMax
()
const
{
58
assert(
myPoints
.
size
() > 0);
59
const
Position
& p =
myPoints
[-1];
60
return
p.x();
61
}
62
63
64
size_t
65
Distribution_Points::getAreaNo
()
const
{
66
return
myPoints
.
size
() - 1;
67
}
68
69
70
SUMOReal
71
Distribution_Points::getAreaBegin
(
size_t
index)
const
{
72
return
myPoints
[(
int
) index].x();
73
}
74
75
76
SUMOReal
77
Distribution_Points::getAreaEnd
(
size_t
index)
const
{
78
return
myPoints
[(
int
) index + 1].x();
79
}
80
81
82
SUMOReal
83
Distribution_Points::getAreaPerc
(
size_t
index)
const
{
84
if
(!
myProbabilitiesAreComputed
) {
85
SUMOReal
sum = 0;
86
size_t
i;
87
if
(
myInterpolateDist
) {
88
for
(i = 0; i <
myPoints
.
size
() - 1; i++) {
89
SUMOReal
width =
getAreaEnd
(i) -
getAreaBegin
(i);
90
SUMOReal
minval =
MIN2
(
myPoints
[(
int
) i].y(),
myPoints
[(
int
) i].y());
91
SUMOReal
maxval =
MAX2
(
myPoints
[(
int
) i].y(),
myPoints
[(
int
) i].y());
92
SUMOReal
amount = minval * width + (maxval - minval) * width / (
SUMOReal
) 2.;
93
myProbabilities
.push_back(amount);
94
sum += amount;
95
}
96
}
else
{
97
for
(i = 0; i <
myPoints
.
size
() - 1; i++) {
98
myProbabilities
.push_back(
myPoints
[(
int
) i].y());
99
sum +=
myPoints
[(
int
) i].y();
100
}
101
}
102
// normalize
103
if
(
myInterpolateDist
) {
104
for
(i = 0; i <
myPoints
.
size
() - 1; i++) {
105
myProbabilities
[i] =
myProbabilities
[i] / sum;
106
}
107
}
else
{
108
for
(i = 0; i <
myPoints
.
size
() - 1; i++) {
109
myProbabilities
[i] =
myProbabilities
[i] / sum;
110
}
111
}
112
myProbabilitiesAreComputed
=
true
;
113
}
114
return
myProbabilities
[index];
115
}
116
117
118
119
/****************************************************************************/
120
var
build
temp
tmp.znCyBrHNjL
4.0-0-0
sumo
sumo-0.15.0~dfsg
src
utils
distribution
Distribution_Points.cpp
Generated on Mon Mar 24 2014 09:53:08 for SUMO - Simulation of Urban MObility by
1.8.1.2