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
activitygen_main.cpp
Go to the documentation of this file.
1
/****************************************************************************/
11
// Main object of the ActivityGen application
12
/****************************************************************************/
13
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14
// Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
15
// activitygen module
16
// Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
17
/****************************************************************************/
18
//
19
// This file is part of SUMO.
20
// SUMO is free software: you can redistribute it and/or modify
21
// it under the terms of the GNU General Public License as published by
22
// the Free Software Foundation, either version 3 of the License, or
23
// (at your option) any later version.
24
//
25
/****************************************************************************/
26
27
28
// ===========================================================================
29
// included modules
30
// ===========================================================================
31
#ifdef _MSC_VER
32
#include <
windows_config.h
>
33
#else
34
#include <
config.h
>
35
#endif
36
37
#ifdef HAVE_VERSION_H
38
#include <version.h>
39
#endif
40
41
#include <iostream>
42
#include <exception>
43
#include <typeinfo>
44
#include <
router/RONet.h
>
45
#include <
router/ROLoader.h
>
46
#include <
router/RONetHandler.h
>
47
#include <
duarouter/RODUAEdgeBuilder.h
>
48
#include <
utils/options/OptionsIO.h
>
49
#include <
utils/common/MsgHandler.h
>
50
#include <
utils/common/ToString.h
>
51
#include <
utils/xml/XMLSubSys.h
>
52
#include <
utils/common/FileHelpers.h
>
53
#include <
utils/common/RandHelper.h
>
54
#include <
utils/common/SystemFrame.h
>
55
#include <
utils/options/OptionsCont.h
>
56
#include <
utils/iodevices/OutputDevice.h
>
57
#include <
utils/iodevices/OutputDevice.h
>
58
//ActivityGen
59
#include "
AGFrame.h
"
60
#include "
AGActivityGen.h
"
61
#include "
city/AGTime.h
"
62
63
#ifdef CHECK_MEMORY_LEAKS
64
#include <
foreign/nvwa/debug_new.h
>
65
#endif // CHECK_MEMORY_LEAKS
66
67
68
// ===========================================================================
69
// method definitions
70
// ===========================================================================
71
73
void
74
loadNet
(
RONet
& toFill,
ROAbstractEdgeBuilder
& eb) {
75
OptionsCont
& oc =
OptionsCont::getOptions
();
76
std::string file = oc.
getString
(
"net-file"
);
77
if
(file ==
""
) {
78
throw
ProcessError
(
"Missing definition of network to load!"
);
79
}
80
if
(!
FileHelpers::isReadable
(file)) {
81
throw
ProcessError
(
"The network file '"
+ file +
"' could not be accessed."
);
82
}
83
PROGRESS_BEGIN_MESSAGE
(
"Loading net"
);
84
RONetHandler
handler(toFill, eb);
85
handler.
setFileName
(file);
86
if
(!
XMLSubSys::runParser
(handler, file,
true
)) {
87
PROGRESS_FAILED_MESSAGE
();
88
throw
ProcessError
();
89
}
else
{
90
PROGRESS_DONE_MESSAGE
();
91
}
92
if
(!
deprecatedVehicleClassesSeen
.empty()) {
93
WRITE_WARNING
(
"Deprecated vehicle classes '"
+
toString
(
deprecatedVehicleClassesSeen
) +
"' in input network."
);
94
deprecatedVehicleClassesSeen
.clear();
95
}
96
}
97
98
99
int
100
main
(
int
argc,
char
* argv[]) {
101
int
ret = 0;
102
OptionsCont
& oc =
OptionsCont::getOptions
();
103
RONet
* net = 0;
104
try
{
105
// Initialise subsystems and process options
106
XMLSubSys::init
();
107
AGFrame::fillOptions
();
108
OptionsIO::getOptions
(
true
, argc, argv);
109
if
(oc.
processMetaOptions
(argc < 2)) {
110
SystemFrame::close
();
111
return
0;
112
}
113
XMLSubSys::setValidation
(oc.
getString
(
"xml-validation"
), oc.
getString
(
"xml-validation.net"
));
114
MsgHandler::initOutputOptions
();
115
RandHelper::initRandGlobal
();
116
117
// Load network
118
net =
new
RONet
();
119
RODUAEdgeBuilder
builder(oc.
getBool
(
"weights.expand"
), oc.
getBool
(
"weights.interpolate"
));
120
loadNet
(*net, builder);
121
WRITE_MESSAGE
(
"Loaded "
+
toString
(net->
getEdgeNoWithoutInternal
()) +
" edges."
);
122
if
(oc.
getBool
(
"debug"
)) {
123
WRITE_MESSAGE
(
"\n\t ---- begin AcitivtyGen ----\n"
);
124
}
125
126
std::string statFile = oc.
getString
(
"stat-file"
);
127
OutputDevice::createDeviceByOption
(
"output-file"
,
"routes"
,
"routes_file.xsd"
);
128
AGTime
duration(1, 0, 0);
129
AGTime
begin(0);
130
AGTime
end(0);
131
if
(oc.
isSet
(
"duration-d"
)) {
132
duration.
setDay
(oc.
getInt
(
"duration-d"
));
133
}
134
if
(oc.
isSet
(
"begin"
)) {
135
begin.
addSeconds
(oc.
getInt
(
"begin"
) % 86400);
136
}
137
if
(oc.
isSet
(
"end"
)) {
138
end.
addSeconds
(oc.
getInt
(
"end"
) % 86400);
139
}
140
AGActivityGen
actiGen(statFile,
OutputDevice::getDevice
(oc.
getString
(
"output-file"
)), net);
141
actiGen.
importInfoCity
();
142
actiGen.
makeActivityTrips
(duration.
getDay
(), begin.
getTime
(), end.
getTime
());
143
144
if
(oc.
getBool
(
"debug"
)) {
145
WRITE_MESSAGE
(
"\n\t ---- end of ActivityGen ----\n"
);
146
}
147
ret = 0;
148
}
catch
(
const
ProcessError
& e) {
149
if
(std::string(e.what()) != std::string(
"Process Error"
) && std::string(e.what()) != std::string(
""
)) {
150
WRITE_ERROR
(e.what());
151
}
152
MsgHandler::getErrorInstance
()->
inform
(
"Quitting (on error)."
,
false
);
153
ret = 1;
154
#ifndef _DEBUG
155
}
catch
(
const
std::exception& e) {
156
if
(std::string(e.what()) != std::string(
""
)) {
157
WRITE_ERROR
(e.what());
158
}
159
MsgHandler::getErrorInstance
()->
inform
(
"Quitting (on error)."
,
false
);
160
ret = 1;
161
}
catch
(...) {
162
MsgHandler::getErrorInstance
()->
inform
(
"Quitting (on unknown error)."
,
false
);
163
ret = 1;
164
#endif
165
}
166
SystemFrame::close
();
167
if
(ret == 0) {
168
std::cout <<
"Success."
<< std::endl;
169
}
170
return
ret;
171
}
172
173
/****************************************************************************/
174
tmp
buildd
sumo-0.21.0+dfsg
src
activitygen
activitygen_main.cpp
Generated on Thu Nov 20 2014 19:49:52 for SUMO - Simulation of Urban MObility by
1.8.1.2