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("net-file", 'n', new Option_FileName());
00061     oc.addSynonyme("net-file", "net");
00062     oc.addDescription("net-file", "Input", "Use FILE as SUMO-network to route on");
00063 
00064     oc.doRegister("taz-files", 'd', new Option_FileName());
00065     oc.addSynonyme("taz-files", "districts", true);
00066     oc.addDescription("taz-files", "Input", "Read (additional) districts from FILE");
00067 
00068     oc.doRegister("alternative-files", 'a', new Option_FileName());
00069     oc.addSynonyme("alternative-files", "alternatives-files");
00070     oc.addSynonyme("alternative-files", "alternatives", true);
00071     oc.addDescription("alternative-files", "Input", "Read alternatives from FILE");
00072 
00073     oc.doRegister("flow-files", 'f', new Option_FileName());
00074     oc.addSynonyme("flow-files", "flows");
00075     oc.addSynonyme("flow-files", "flow-definition", true);
00076     oc.addDescription("flow-files", "Input", "Read flow-definitions from FILE(s)");
00077 
00078     if (forDuarouter) {
00079         oc.doRegister("weight-files", 'w', new Option_FileName());
00080         oc.addSynonyme("weight-files", "weights");
00081         oc.addDescription("weight-files", "Input", "Read network weights from FILE(s)");
00082 
00083         oc.doRegister("lane-weight-files", new Option_FileName());
00084         oc.addDescription("lane-weight-files", "Input", "Read lane-based network weights from FILE(s)");
00085 
00086         oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
00087         oc.addSynonyme("weight-attribute", "measure", true);
00088         oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight");
00089     }
00090 
00091     // register the time settings
00092     oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
00093     oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
00094 
00095     oc.doRegister("end", 'e', new Option_String(SUMOTIME_MAXSTRING, "TIME"));
00096     oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
00097 
00098 
00099     // register the processing options
00100     oc.doRegister("ignore-errors", new Option_Bool(false));
00101     oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
00102     oc.addDescription("ignore-errors", "Processing", "Continue if a route could not be build");
00103 
00104     oc.doRegister("unsorted-input", new Option_Bool(false));
00105     oc.addSynonyme("unsorted-input", "unsorted");
00106     oc.addDescription("unsorted-input", "Processing", "Assume input is unsorted");
00107 
00108     oc.doRegister("randomize-flows", new Option_Bool(false));
00109     oc.addDescription("randomize-flows", "Processing", "generate random departure times for flow input");
00110 
00111     oc.doRegister("max-alternatives", new Option_Integer(5));
00112     oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
00113 
00114     oc.doRegister("remove-loops", new Option_Bool(false));
00115     oc.addDescription("remove-loops", "Processing", "Remove loops within the route; Remove turnarounds at start and end of the route");
00116 
00117     oc.doRegister("repair", new Option_Bool(false));
00118     oc.addDescription("repair", "Processing", "Tries to correct a false route");
00119 
00120     oc.doRegister("weights.interpolate", new Option_Bool(false));
00121     oc.addSynonyme("weights.interpolate", "interpolate", true);
00122     oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
00123 
00124     oc.doRegister("with-taz", new Option_Bool(false));
00125     oc.addDescription("with-taz", "Processing", "Use origin and destination zones (districts) for in- and output");
00126 
00127 
00128     // register defaults options
00129     oc.doRegister("departlane", new Option_String());
00130     oc.addDescription("departlane", "Defaults", "Assigns a default depart lane");
00131 
00132     oc.doRegister("departpos", new Option_String());
00133     oc.addDescription("departpos", "Defaults", "Assigns a default depart position");
00134 
00135     oc.doRegister("departspeed", new Option_String());
00136     oc.addDescription("departspeed", "Defaults", "Assigns a default depart speed");
00137 
00138     oc.doRegister("arrivallane", new Option_String());
00139     oc.addDescription("arrivallane", "Defaults", "Assigns a default arrival lane");
00140 
00141     oc.doRegister("arrivalpos", new Option_String());
00142     oc.addDescription("arrivalpos", "Defaults", "Assigns a default arrival position");
00143 
00144     oc.doRegister("arrivalspeed", new Option_String());
00145     oc.addDescription("arrivalspeed", "Defaults", "Assigns a default arrival speed");
00146 
00147     oc.doRegister("defaults-override", new Option_Bool(false));
00148     oc.addDescription("defaults-override", "Defaults", "Defaults will override given values");
00149 
00150 
00151     // register report options
00152     oc.doRegister("stats-period", new Option_Integer(-1));
00153     oc.addDescription("stats-period", "Report", "Defines how often statistics shall be printed");
00154 }
00155 
00156 
00157 bool
00158 ROFrame::checkOptions(OptionsCont& oc) {
00159     // check whether the output is valid and can be build
00160     if (!oc.isSet("output-file")) {
00161         WRITE_ERROR("No output specified.");
00162         return false;
00163     }
00164     //
00165     if (oc.getInt("max-alternatives") < 2) {
00166         WRITE_ERROR("At least two alternatives should be enabled");
00167         return false;
00168     }
00169     // check departure/arrival options
00170     return true;
00171 }
00172 
00173 
00174 
00175 /****************************************************************************/
00176 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines