ROFrame.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Sets and checks options for routing
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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 "ROFrame.h"
00039 
00040 #ifdef CHECK_MEMORY_LEAKS
00041 #include <foreign/nvwa/debug_new.h>
00042 #endif // CHECK_MEMORY_LEAKS
00043 
00044 
00045 // ===========================================================================
00046 // method definitions
00047 // ===========================================================================
00048 void
00049 ROFrame::fillOptions(OptionsCont &oc) {
00050     // register options
00051     // register I/O options
00052     oc.doRegister("output", 'o', new Option_FileName());
00053     oc.addSynonyme("output-file", "output");
00054     oc.addDescription("output-file", "Output", "Write generated routes to FILE");
00055 
00056     oc.doRegister("net-file", 'n', new Option_FileName());
00057     oc.addSynonyme("net-file", "net");
00058     oc.addDescription("net-file", "Input", "Use FILE as SUMO-network to route on");
00059 
00060     oc.doRegister("districts", 'd', new Option_FileName());
00061     oc.addDescription("districts", "Input", "Read (additional) districts from FILE");
00062 
00063     oc.doRegister("alternatives", 'a', new Option_FileName());
00064     oc.addDescription("alternatives", "Input", "Read alternatives from FILE");
00065 
00066     oc.doRegister("weights", 'w', new Option_FileName());
00067     oc.addSynonyme("weights", "weight-files");
00068     oc.addDescription("weights", "Input", "Read network weights from FILE(s)");
00069 
00070     oc.doRegister("lane-weights", new Option_FileName());
00071     oc.addDescription("lane-weights", "Input", "Read lane-weights from FILE(s)");
00072 
00073     oc.doRegister("measure", 'x', new Option_String("traveltime"));
00074     oc.addDescription("measure", "Input", "Name of the xml attribute which gives the edge weight");
00075 
00076     // register the time settings
00077     oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
00078     oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
00079 
00080     oc.doRegister("end", 'e', new Option_String("86400", "TIME"));
00081     oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded");
00082 
00083 
00084     // register the processing options
00085     oc.doRegister("continue-on-unbuild", new Option_Bool(false));
00086     oc.addDescription("continue-on-unbuild", "Processing", "Continue if a route could not be build");
00087 
00088     oc.doRegister("unsorted", new Option_Bool(false));
00089     oc.addDescription("unsorted", "Processing", "Assume input is unsorted");
00090 
00091     oc.doRegister("randomize-flows", new Option_Bool(false)); // !!! undescibed
00092     oc.addDescription("randomize-flows", "Processing", "");
00093 
00094     oc.doRegister("max-alternatives", new Option_Integer(5));
00095     oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
00096 
00097     oc.doRegister("remove-loops", new Option_Bool(false));
00098     oc.addDescription("remove-loops", "Processing", "Remove loops at start and end of the route");
00099 
00100     oc.doRegister("repair", new Option_Bool(false));
00101     oc.addDescription("repair", "Processing", "Tries to correct a false route");
00102 
00103     oc.doRegister("interpolate", new Option_Bool(false));
00104     oc.addDescription("interpolate", "Processing", "Interpolate edge weights at interval boundaries");
00105 
00106     oc.doRegister("with-taz", new Option_Bool(false));
00107     oc.addDescription("with-taz", "Processing", "Use origin and destination zones (districts) for in- and output");
00108 
00109 
00110     // register defaults options
00111     oc.doRegister("departlane", new Option_String());
00112     oc.addDescription("departlane", "Defaults", "Assigns a default depart lane");
00113 
00114     oc.doRegister("departpos", new Option_String());
00115     oc.addDescription("departpos", "Defaults", "Assigns a default depart position");
00116 
00117     oc.doRegister("departspeed", new Option_String());
00118     oc.addDescription("departspeed", "Defaults", "Assigns a default depart speed");
00119 
00120     oc.doRegister("arrivallane", new Option_String());
00121     oc.addDescription("arrivallane", "Defaults", "Assigns a default arrival lane");
00122 
00123     oc.doRegister("arrivalpos", new Option_String());
00124     oc.addDescription("arrivalpos", "Defaults", "Assigns a default arrival position");
00125 
00126     oc.doRegister("arrivalspeed", new Option_String());
00127     oc.addDescription("arrivalspeed", "Defaults", "Assigns a default arrival speed");
00128 
00129     oc.doRegister("defaults-override", new Option_Bool(false));
00130     oc.addDescription("defaults-override", "Defaults", "Defaults will override given values");
00131 
00132 
00133     // register report options
00134     oc.doRegister("stats-period", new Option_Integer(-1));
00135     oc.addDescription("stats-period", "Report", "Defines how often statistics shall be printed");
00136 }
00137 
00138 
00139 bool
00140 ROFrame::checkOptions(OptionsCont &oc) {
00141     // check whether the output is valid and can be build
00142     if (!oc.isSet("output")) {
00143         MsgHandler::getErrorInstance()->inform("No output specified.");
00144         return false;
00145     }
00146     //
00147     if (oc.getInt("max-alternatives")<2) {
00148         MsgHandler::getErrorInstance()->inform("At least two alternatives should be enabled");
00149         return false;
00150     }
00151     // check departure/arrival options
00152     return true;
00153 }
00154 
00155 
00156 
00157 /****************************************************************************/
00158 

Generated on Wed May 5 00:06:36 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6