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