00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <iostream>
00031 #include <iomanip>
00032 #include <fstream>
00033 #include <ctime>
00034 #include <utils/options/OptionsCont.h>
00035 #include <utils/options/Option.h>
00036 #include <utils/common/MsgHandler.h>
00037 #include <utils/common/UtilExceptions.h>
00038 #include <utils/common/ToString.h>
00039 #include <utils/iodevices/OutputDevice.h>
00040 #include <microsim/MSJunction.h>
00041 #include <microsim/MSNet.h>
00042 #include <microsim/MSGlobals.h>
00043 #include <microsim/devices/MSDevice_Routing.h>
00044 #include <microsim/devices/MSDevice_HBEFA.h>
00045 #include <utils/common/RandHelper.h>
00046 #include "MSFrame.h"
00047 #include <utils/common/SystemFrame.h>
00048
00049 #ifdef CHECK_MEMORY_LEAKS
00050 #include <foreign/nvwa/debug_new.h>
00051 #endif // CHECK_MEMORY_LEAKS
00052
00053
00054
00055
00056
00057 void
00058 MSFrame::fillOptions() {
00059 OptionsCont &oc = OptionsCont::getOptions();
00060 oc.addCallExample("-b 0 -e 1000 -n net.xml -r routes.xml");
00061 oc.addCallExample("-c munich_config.cfg");
00062 oc.addCallExample("--help");
00063
00064
00065 SystemFrame::addConfigurationOptions(oc);
00066 oc.addOptionSubTopic("Input");
00067 oc.addOptionSubTopic("Output");
00068 oc.addOptionSubTopic("Time");
00069 oc.addOptionSubTopic("Processing");
00070 oc.addOptionSubTopic("TLS Defaults");
00071 SystemFrame::addReportOptions(oc);
00072
00073
00074
00075
00076 oc.doRegister("net-file", 'n', new Option_FileName());
00077 oc.addSynonyme("net-file", "net");
00078 oc.addDescription("net-file", "Input", "Load road network description from FILE");
00079
00080 oc.doRegister("route-files", 'r', new Option_FileName());
00081 oc.addSynonyme("route-files", "routes");
00082 oc.addDescription("route-files", "Input", "Load routes descriptions from FILE(s)");
00083
00084 oc.doRegister("additional-files", 'a', new Option_FileName());
00085 oc.addSynonyme("additional-files", "additional");
00086 oc.addDescription("additional-files", "Input", "Load further descriptions from FILE(s)");
00087
00088 oc.doRegister("weight-files", 'w', new Option_FileName());
00089 oc.addSynonyme("weight-files", "weights");
00090 oc.addDescription("weight-files", "Input", "Load weights from FILE");
00091 oc.doRegister("measure", 'm', new Option_String());
00092 oc.addDescription("measure", "Input", "Load <measure> from weights");
00093
00094 #ifdef HAVE_MESOSIM
00095 oc.doRegister("load-state", new Option_FileName());
00096 oc.addDescription("load-state", "Input", "Loads a network state from FILE");
00097 oc.doRegister("load-state.offset", new Option_String("0", "TIME"));
00098 oc.addDescription("load-state.offset", "Input", "Sets the time offset for vehicle segment exit times.");
00099 #endif
00100
00101
00102 oc.doRegister("netstate-dump", new Option_FileName());
00103 oc.addSynonyme("netstate-dump", "ndump");
00104 oc.addSynonyme("netstate-dump", "netstate");
00105 oc.addDescription("netstate-dump", "Output", "Save complete network states into FILE");
00106 oc.doRegister("dump-empty-edges", new Option_Bool(false));
00107 oc.addDescription("dump-empty-edges", "Output", "Write also empty edges completely when dumping");
00108
00109 oc.doRegister("emissions-output", new Option_FileName());
00110 oc.addSynonyme("emissions-output", "emissions");
00111 oc.addDescription("emissions-output", "Output", "Save aggregated vehicle emission inf. into FILE");
00112
00113 oc.doRegister("tripinfo-output", new Option_FileName());
00114 oc.addSynonyme("tripinfo-output", "tripinfo");
00115 oc.addDescription("tripinfo-output", "Output", "Save single vehicle trip inf. into FILE");
00116
00117 oc.doRegister("vehroute-output", new Option_FileName());
00118 oc.addSynonyme("vehroute-output", "vehroutes");
00119 oc.addDescription("vehroute-output", "Output", "Save single vehicle route inf. into FILE");
00120
00121 oc.doRegister("vehroute-output.exit-times", new Option_Bool(false));
00122 oc.addSynonyme("vehroute-output.exit-times", "vehroutes.exit-times");
00123 oc.addDescription("vehroute-output.exit-times", "Output", "Write the exit times for all edges");
00124
00125 oc.doRegister("vehroute-output.last-route", new Option_Bool(false));
00126 oc.addSynonyme("vehroute-output.last-route", "vehroutes.last-route");
00127 oc.addDescription("vehroute-output.last-route", "Output", "Write the last route only");
00128
00129 #ifdef HAVE_MESOSIM
00130 oc.doRegister("save-state.times", new Option_IntVector(IntVector()));
00131 oc.addDescription("save-state.times", "Output", "Use INT[] as times at which a network state written");
00132 oc.doRegister("save-state.prefix", new Option_FileName());
00133 oc.addDescription("save-state.prefix", "Output", "Prefix for network states");
00134 oc.doRegister("save-state.files", new Option_FileName());
00135 oc.addDescription("save-state.files", "Output", "Files for network states");
00136 #endif
00137
00138
00139 oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
00140 oc.addDescription("begin", "Time", "Defines the begin time; The simulation starts at this time");
00141
00142 oc.doRegister("end", 'e', new Option_String("-1", "TIME"));
00143 oc.addDescription("end", "Time", "Defines the end time; The simulation ends at this time");
00144
00145 #ifdef HAVE_SUBSECOND_TIMESTEPS
00146 oc.doRegister("step-length", new Option_String("1", "TIME"));
00147 oc.addDescription("step-length", "Time", "Defines the step duration");
00148 #endif
00149
00150
00151
00152 oc.doRegister("route-steps", 's', new Option_Integer(200));
00153 oc.addDescription("route-steps", "Processing", "Load routes for the next INT steps ahead");
00154
00155 #ifdef HAVE_INTERNAL_LANES
00156 oc.doRegister("no-internal-links", new Option_Bool(false));
00157 oc.addDescription("no-internal-links", "Processing", "Disable (junction) internal links");
00158 #endif
00159
00160 oc.doRegister("ignore-accidents", new Option_Bool(false));
00161 oc.addDescription("ignore-accidents", "Processing", "Do not check whether accidents occure more deeply");
00162
00163 oc.doRegister("too-many-vehicles", new Option_Integer(-1));
00164 oc.addDescription("too-many-vehicles", "Processing", "Quit simulation if this number of vehicles is exceeded");
00165
00166 oc.doRegister("incremental-dua-step", new Option_Integer(-1));
00167 oc.addDescription("incremental-dua-step", "Processing", "Perform the simulation as a step in incremental DUA");
00168 oc.doRegister("incremental-dua-base", new Option_Integer(10));
00169 oc.addDescription("incremental-dua-base", "Processing", "Base value for incremental DUA");
00170
00171 oc.doRegister("time-to-teleport", new Option_String("300", "TIME"));
00172 oc.addDescription("time-to-teleport", "Processing", "Specify how long a vehicle may wait until being teleported");
00173
00174 oc.doRegister("max-depart-delay", new Option_Integer(-1));
00175 oc.addDescription("max-depart-delay", "Processing", "How long vehicles wait for departure before being skipped");
00176
00177 oc.doRegister("sloppy-emit", new Option_Bool(false));
00178 oc.addDescription("sloppy-emit", "Processing", "Whether emission on an edge shall not be repeated in same step once failed.");
00179
00180
00181 MSDevice_Routing::insertOptions();
00182 MSDevice_HBEFA::insertOptions();
00183
00184
00185
00186 oc.doRegister("agent-tl.detector-len", new Option_Float(75));
00187 oc.addDescription("agent-tl.detector-len", "TLS Defaults", "");
00188
00189 oc.doRegister("agent-tl.learn-horizon", new Option_Integer(3));
00190 oc.addDescription("agent-tl.learn-horizon", "TLS Defaults", "");
00191
00192 oc.doRegister("agent-tl.decision-horizon", new Option_Integer(1));
00193 oc.addDescription("agent-tl.decision-horizon", "TLS Defaults", "");
00194
00195 oc.doRegister("agent-tl.min-diff", new Option_Float((SUMOReal) .1));
00196 oc.addDescription("agent-tl.min-diff", "TLS Defaults", "");
00197
00198 oc.doRegister("agent-tl.tcycle", new Option_Integer(90));
00199 oc.addDescription("agent-tl.tcycle", "TLS Defaults", "");
00200
00201 oc.doRegister("actuated-tl.detector-pos", new Option_Float(100));
00202 oc.addDescription("actuated-tl.detector-pos", "TLS Defaults", "");
00203
00204 oc.doRegister("actuated-tl.max-gap", new Option_Float(3.1f));
00205 oc.addDescription("actuated-tl.max-gap", "TLS Defaults", "");
00206
00207 oc.doRegister("actuated-tl.detector-gap", new Option_Float(3.0f));
00208 oc.addDescription("actuated-tl.detector-gap", "TLS Defaults", "");
00209
00210 oc.doRegister("actuated-tl.passing-time", new Option_Float(1.9f));
00211 oc.addDescription("actuated-tl.passing-time", "TLS Defaults", "");
00212
00213
00214
00215 oc.doRegister("no-duration-log", new Option_Bool(false));
00216 oc.addDescription("no-duration-log", "Report", "Disable performance reports for individual simulation steps");
00217
00218 oc.doRegister("no-step-log", new Option_Bool(false));
00219 oc.addDescription("no-step-log", "Report", "Disable console output of current simulation step");
00220
00221 oc.doRegister("message-log", new Option_FileName());
00222 oc.addDescription("message-log", "Report", "Writes all non-error messages to FILE");
00223
00224 oc.doRegister("error-log", new Option_FileName());
00225 oc.addDescription("error-log", "Report", "Writes all warnings and errors to FILE");
00226
00227
00228 #ifndef NO_TRACI
00229
00230 oc.addOptionSubTopic("TraCI Server");
00231 oc.doRegister("remote-port", new Option_Integer(0));
00232 oc.addDescription("remote-port", "TraCI Server", "Enables TraCI Server if set");
00233 oc.doRegister("penetration", new Option_Float(1.0f));
00234 oc.addDescription("penetration", "TraCI Server", "Value in 0..1 [default: 1]");
00235 #endif
00236
00237 #ifdef HAVE_MESOSIM
00238 oc.addOptionSubTopic("Mesoscopic");
00239 oc.doRegister("mesosim", new Option_Bool(false));
00240 oc.addDescription("mesosim", "Mesoscopic", "Enables mesoscopic simulation");
00241 oc.doRegister("meso-edgelength", new Option_Float(98.0f));
00242 oc.addDescription("meso-edgelength", "Mesoscopic", "Length of an edge segment in mesoscopic simulation");
00243 oc.doRegister("meso-tauff", new Option_String("1.4", "TIME"));
00244 oc.addDescription("meso-tauff", "Mesoscopic", "Factor for calculating the free-free headway time");
00245 oc.doRegister("meso-taufj", new Option_String("1.4", "TIME"));
00246 oc.addDescription("meso-taufj", "Mesoscopic", "Factor for calculating the free-jam headway time");
00247 oc.doRegister("meso-taujf", new Option_String("2", "TIME"));
00248 oc.addDescription("meso-taujf", "Mesoscopic", "Factor for calculating the jam-free headway time");
00249 oc.doRegister("meso-taujj", new Option_String("2", "TIME"));
00250 oc.addDescription("meso-taujj", "Mesoscopic", "Factor for calculating the jam-jam headway time");
00251 oc.doRegister("meso-jam-threshold", new Option_Float(0.29f));
00252 oc.addDescription("meso-jam-threshold", "Mesoscopic", "Minimum percentage of occupied space to consider a segment jammed");
00253 oc.doRegister("meso-multi-queue", new Option_Bool(false));
00254 oc.addDescription("meso-multi-queue", "Mesoscopic", "Enable multiple queues at edge ends");
00255 oc.doRegister("meso-junction-control", new Option_Bool(false));
00256 oc.addDescription("meso-junction-control", "Mesoscopic", "Enable mesoscopic traffic light and priority junction handling");
00257 #endif
00258
00259
00260 RandHelper::insertRandOptions();
00261
00262 oc.addOptionSubTopic("GUI Only");
00263 oc.doRegister("gui-settings-file", new Option_FileName(""));
00264 oc.addDescription("gui-settings-file", "GUI Only", "Load visualisation settings from FILE");
00265
00266 }
00267
00268
00269 void
00270 MSFrame::buildStreams() throw(IOError) {
00271
00272 OutputDevice::createDeviceByOption("netstate-dump", "sumo-netstate");
00273 OutputDevice::createDeviceByOption("emissions-output", "emissions");
00274 OutputDevice::createDeviceByOption("tripinfo-output", "tripinfos");
00275 OutputDevice::createDeviceByOption("vehroute-output", "routes");
00276 }
00277
00278
00279 bool
00280 MSFrame::checkOptions() {
00281 OptionsCont &oc = OptionsCont::getOptions();
00282 bool ok = true;
00283
00284 if (!oc.isSet("n")) {
00285 MsgHandler::getErrorInstance()->inform("No network file (-n) specified.");
00286 ok = false;
00287 }
00288
00289 if (!oc.isSet("b")) {
00290 MsgHandler::getErrorInstance()->inform("The begin of the simulation (-b) is not specified.");
00291 ok = false;
00292 }
00293 if (!oc.isSet("e")) {
00294 MsgHandler::getErrorInstance()->inform("The end of the simulation (-e) is not specified.");
00295 ok = false;
00296 }
00297 if (oc.isSet("incremental-dua-step") && oc.isSet("incremental-dua-base")) {
00298 if (oc.getInt("incremental-dua-step") > oc.getInt("incremental-dua-base")) {
00299 MsgHandler::getErrorInstance()->inform("Invalid dua step");
00300 ok = false;
00301 }
00302 }
00303 if (oc.getBool("vehroutes.exit-times") && !oc.isSet("vehroutes")) {
00304 MsgHandler::getErrorInstance()->inform("A vehroute-output file is needed for exit times.");
00305 ok = false;
00306 }
00307 return ok;
00308 }
00309
00310
00311 void
00312 MSFrame::setMSGlobals(OptionsCont &oc) {
00313
00314
00315 MSGlobals::gOmitEmptyEdgesOnDump = !oc.getBool("dump-empty-edges");
00316 #ifdef HAVE_INTERNAL_LANES
00317
00318 MSGlobals::gUsingInternalLanes = !oc.getBool("no-internal-links");
00319 #else
00320 MSGlobals::gUsingInternalLanes = false;
00321 #endif
00322
00323 MSGlobals::gTimeToGridlock = string2time(oc.getString("time-to-teleport"))<0 ? 0 : string2time(oc.getString("time-to-teleport"));
00324
00325 MSGlobals::gCheck4Accidents = !oc.getBool("ignore-accidents");
00326 #ifdef HAVE_MESOSIM
00327 MSGlobals::gStateLoaded = oc.isSet("load-state");
00328 #endif
00329
00330 #ifdef HAVE_SUBSECOND_TIMESTEPS
00331 DELTA_T = string2time(oc.getString("step-length"));
00332 #endif
00333
00334 #ifdef HAVE_MESOSIM
00335 MSGlobals::gUseMesoSim = oc.getBool("mesosim");
00336 #endif
00337 }
00338
00339
00340
00341
00342