|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Sets and checks options for routing 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 00020 00021 // =========================================================================== 00022 // included modules 00023 // =========================================================================== 00024 #ifdef _MSC_VER 00025 #include <windows_config.h> 00026 #else 00027 #include <config.h> 00028 #endif 00029 00030 #include <iostream> 00031 #include <ctime> 00032 #include <utils/options/OptionsCont.h> 00033 #include <utils/options/Option.h> 00034 #include <utils/common/MsgHandler.h> 00035 #include <utils/common/UtilExceptions.h> 00036 #include <utils/common/RandHelper.h> 00037 #include <utils/common/ToString.h> 00038 #include <utils/common/SUMOTime.h> 00039 #include "ROFrame.h" 00040 00041 #ifdef CHECK_MEMORY_LEAKS 00042 #include <foreign/nvwa/debug_new.h> 00043 #endif // CHECK_MEMORY_LEAKS 00044 00045 00046 // =========================================================================== 00047 // method definitions 00048 // =========================================================================== 00049 void 00050 ROFrame::fillOptions(OptionsCont& oc, bool forDuarouter) { 00051 // register options 00052 // register I/O options 00053 oc.doRegister("output-file", 'o', new Option_FileName()); 00054 oc.addSynonyme("output-file", "output"); 00055 oc.addDescription("output-file", "Output", "Write generated routes to FILE"); 00056 00057 oc.doRegister("net-file", 'n', new Option_FileName()); 00058 oc.addSynonyme("net-file", "net"); 00059 oc.addDescription("net-file", "Input", "Use FILE as SUMO-network to route on"); 00060 00061 oc.doRegister("taz-files", 'd', new Option_FileName()); 00062 oc.addSynonyme("taz-files", "districts", true); 00063 oc.addDescription("taz-files", "Input", "Read (additional) districts from FILE"); 00064 00065 oc.doRegister("alternative-files", 'a', new Option_FileName()); 00066 oc.addSynonyme("alternative-files", "alternatives-files"); 00067 oc.addSynonyme("alternative-files", "alternatives", true); 00068 oc.addDescription("alternative-files", "Input", "Read alternatives from FILE"); 00069 00070 oc.doRegister("flow-files", 'f', new Option_FileName()); 00071 oc.addSynonyme("flow-files", "flows"); 00072 oc.addSynonyme("flow-files", "flow-definition", true); 00073 oc.addDescription("flow-files", "Input", "Read flow-definitions from FILE(s)"); 00074 00075 if (forDuarouter) { 00076 oc.doRegister("weight-files", 'w', new Option_FileName()); 00077 oc.addSynonyme("weight-files", "weights"); 00078 oc.addDescription("weight-files", "Input", "Read network weights from FILE(s)"); 00079 00080 oc.doRegister("lane-weight-files", new Option_FileName()); 00081 oc.addDescription("lane-weight-files", "Input", "Read lane-based network weights from FILE(s)"); 00082 00083 oc.doRegister("weight-attribute", 'x', new Option_String("traveltime")); 00084 oc.addSynonyme("weight-attribute", "measure", true); 00085 oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight"); 00086 } 00087 00088 // register the time settings 00089 oc.doRegister("begin", 'b', new Option_String("0", "TIME")); 00090 oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded"); 00091 00092 oc.doRegister("end", 'e', new Option_String(SUMOTIME_MAXSTRING, "TIME")); 00093 oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent"); 00094 00095 00096 // register the processing options 00097 oc.doRegister("ignore-errors", new Option_Bool(false)); 00098 oc.addSynonyme("ignore-errors", "continue-on-unbuild", true); 00099 oc.addDescription("ignore-errors", "Processing", "Continue if a route could not be build"); 00100 00101 oc.doRegister("unsorted-input", new Option_Bool(false)); 00102 oc.addSynonyme("unsorted-input", "unsorted"); 00103 oc.addDescription("unsorted-input", "Processing", "Assume input is unsorted"); 00104 00105 oc.doRegister("randomize-flows", new Option_Bool(false)); 00106 oc.addDescription("randomize-flows", "Processing", "generate random departure times for flow input"); 00107 00108 oc.doRegister("max-alternatives", new Option_Integer(5)); 00109 oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT"); 00110 00111 oc.doRegister("remove-loops", new Option_Bool(false)); 00112 oc.addDescription("remove-loops", "Processing", "Remove loops within the route; Remove turnarounds at start and end of the route"); 00113 00114 oc.doRegister("repair", new Option_Bool(false)); 00115 oc.addDescription("repair", "Processing", "Tries to correct a false route"); 00116 00117 oc.doRegister("weights.interpolate", new Option_Bool(false)); 00118 oc.addSynonyme("weights.interpolate", "interpolate", true); 00119 oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries"); 00120 00121 oc.doRegister("with-taz", new Option_Bool(false)); 00122 oc.addDescription("with-taz", "Processing", "Use origin and destination zones (districts) for in- and output"); 00123 00124 00125 // register defaults options 00126 oc.doRegister("departlane", new Option_String()); 00127 oc.addDescription("departlane", "Defaults", "Assigns a default depart lane"); 00128 00129 oc.doRegister("departpos", new Option_String()); 00130 oc.addDescription("departpos", "Defaults", "Assigns a default depart position"); 00131 00132 oc.doRegister("departspeed", new Option_String()); 00133 oc.addDescription("departspeed", "Defaults", "Assigns a default depart speed"); 00134 00135 oc.doRegister("arrivallane", new Option_String()); 00136 oc.addDescription("arrivallane", "Defaults", "Assigns a default arrival lane"); 00137 00138 oc.doRegister("arrivalpos", new Option_String()); 00139 oc.addDescription("arrivalpos", "Defaults", "Assigns a default arrival position"); 00140 00141 oc.doRegister("arrivalspeed", new Option_String()); 00142 oc.addDescription("arrivalspeed", "Defaults", "Assigns a default arrival speed"); 00143 00144 oc.doRegister("defaults-override", new Option_Bool(false)); 00145 oc.addDescription("defaults-override", "Defaults", "Defaults will override given values"); 00146 00147 00148 // register report options 00149 oc.doRegister("stats-period", new Option_Integer(-1)); 00150 oc.addDescription("stats-period", "Report", "Defines how often statistics shall be printed"); 00151 } 00152 00153 00154 bool 00155 ROFrame::checkOptions(OptionsCont& oc) { 00156 // check whether the output is valid and can be build 00157 if (!oc.isSet("output-file")) { 00158 WRITE_ERROR("No output specified."); 00159 return false; 00160 } 00161 // 00162 if (oc.getInt("max-alternatives")<2) { 00163 WRITE_ERROR("At least two alternatives should be enabled"); 00164 return false; 00165 } 00166 // check departure/arrival options 00167 return true; 00168 } 00169 00170 00171 00172 /****************************************************************************/ 00173