SUMO - Simulation of Urban MObility
ROJTRFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Sets and checks options for jtr-routing
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <iostream>
34 #include <fstream>
35 #include <ctime>
37 #include <utils/options/Option.h>
40 #include <utils/common/ToString.h>
41 #include "ROJTRFrame.h"
42 #include <router/ROFrame.h>
46 
47 #ifdef CHECK_MEMORY_LEAKS
48 #include <foreign/nvwa/debug_new.h>
49 #endif // CHECK_MEMORY_LEAKS
50 
51 
52 // ===========================================================================
53 // method definitions
54 // ===========================================================================
55 void
58  oc.addCallExample("-c <CONFIGURATION>", "run with routing options defined in file");
59 
60  // insert options sub-topics
62  oc.addOptionSubTopic("Input");
63  oc.addOptionSubTopic("Output");
64  oc.addOptionSubTopic("Processing");
65  oc.addOptionSubTopic("Defaults");
66  oc.addOptionSubTopic("Time");
67  SystemFrame::addReportOptions(oc); // fill this subtopic, too
68 
69  ROFrame::fillOptions(oc, false);
70 
71  oc.doRegister("turn-ratio-files", 't', new Option_FileName());
72  oc.addSynonyme("turn-ratio-files", "turns");
73  oc.addDescription("turn-ratio-files", "Input", "Read turning ratios from FILE(s)");
74 
75  oc.doRegister("exit-times", new Option_Bool(false));
76  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
77 
78  oc.doRegister("max-edges-factor", new Option_Float(2.0));
79  oc.addDescription("max-edges-factor", "Processing", "Routes are cut off when the route edges to net edges ratio is larger than FLOAT");
80 
81  oc.doRegister("turn-defaults", 'T', new Option_String("30,50,20"));
82  oc.addDescription("turn-defaults", "Processing", "Use STR as default turn definition");
83 
84  oc.doRegister("sink-edges", new Option_String());
85  oc.addSynonyme("sink-edges", "sinks");
86  oc.addDescription("sink-edges", "Processing", "Use STR as list of sink edges");
87 
88  oc.doRegister("accept-all-destinations", 'A', new Option_Bool(false));
89  oc.addDescription("accept-all-destinations", "Processing", "Whether all edges are allowed as sink edges");
90 
91  oc.doRegister("ignore-vclasses", 'i', new Option_Bool(false));
92  oc.addDescription("ignore-vclasses", "Processing", "Ignore road restrictions based on vehicle class");
93 
94  oc.doRegister("allow-loops", new Option_Bool(false));
95  oc.addDescription("allow-loops", "Processing", "Allow to re-use a road");
96 
97  // add rand options
99 }
100 
101 
102 bool
105  bool ok = ROFrame::checkOptions(oc);
106 
108  std::string error;
109  if (oc.isSet("departlane") && !SUMOVehicleParameter::parseDepartLane(oc.getString("departlane"), "option", "departlane", p.departLane, p.departLaneProcedure, error)) {
110  WRITE_ERROR(error);
111  ok = false;
112  }
113  if (oc.isSet("departpos") && !SUMOVehicleParameter::parseDepartPos(oc.getString("departpos"), "option", "departpos", p.departPos, p.departPosProcedure, error)) {
114  WRITE_ERROR(error);
115  ok = false;
116  }
117  if (oc.isSet("departspeed") && !SUMOVehicleParameter::parseDepartSpeed(oc.getString("departspeed"), "option", "departspeed", p.departSpeed, p.departSpeedProcedure, error)) {
118  WRITE_ERROR(error);
119  ok = false;
120  }
121  if (oc.isSet("arrivallane") && !SUMOVehicleParameter::parseArrivalLane(oc.getString("arrivallane"), "option", "arrivallane", p.arrivalLane, p.arrivalLaneProcedure, error)) {
122  WRITE_ERROR(error);
123  ok = false;
124  }
125  if (oc.isSet("arrivalpos") && !SUMOVehicleParameter::parseArrivalPos(oc.getString("arrivalpos"), "option", "arrivalpos", p.arrivalPos, p.arrivalPosProcedure, error)) {
126  WRITE_ERROR(error);
127  ok = false;
128  }
129  if (oc.isSet("arrivalspeed") && !SUMOVehicleParameter::parseArrivalSpeed(oc.getString("arrivalspeed"), "option", "arrivalspeed", p.arrivalSpeed, p.arrivalSpeedProcedure, error)) {
130  WRITE_ERROR(error);
131  ok = false;
132  }
133  return ok;
134 }
135 
136 
137 /****************************************************************************/
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:84
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:53
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, SUMOReal &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:74
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, SUMOReal &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
SUMOReal departSpeed
(optional) The initial speed of the vehicle
SUMOReal arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
SUMOReal arrivalPos
(optional) The position the vehicle shall arrive on
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:50
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
static void fillOptions(OptionsCont &oc, bool forDuarouter)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:54
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:185
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, SUMOReal &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, SUMOReal &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
Structure representing possible vehicle parameter.
static void fillOptions()
Inserts options used by jtrrouter into the OptionsCont-singleton.
Definition: ROJTRFrame.cpp:56
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within jtrrouter...
Definition: ROJTRFrame.cpp:103
A storage for options typed value containers)
Definition: OptionsCont.h:108
SUMOReal departPos
(optional) The position the vehicle shall depart from
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.