Eclipse SUMO - Simulation of Urban MObility
ROJTRFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // Sets and checks options for jtr-routing
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <iostream>
26 #include <fstream>
27 #include <ctime>
29 #include <utils/options/Option.h>
32 #include <utils/common/ToString.h>
33 #include "ROJTRFrame.h"
34 #include <router/ROFrame.h>
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
43 void
46  oc.addCallExample("-c <CONFIGURATION>", "run with routing options defined in file");
47 
48  // insert options sub-topics
50  oc.addOptionSubTopic("Input");
51  oc.addOptionSubTopic("Output");
52  oc.addOptionSubTopic("Processing");
53  oc.addOptionSubTopic("Defaults");
54  oc.addOptionSubTopic("Time");
55  SystemFrame::addReportOptions(oc); // fill this subtopic, too
56 
58 
59  oc.doRegister("turn-ratio-files", 't', new Option_FileName());
60  oc.addSynonyme("turn-ratio-files", "turns");
61  oc.addDescription("turn-ratio-files", "Input", "Read turning ratios from FILE(s)");
62 
63  oc.doRegister("exit-times", new Option_Bool(false));
64  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
65 
66  oc.doRegister("max-edges-factor", new Option_Float(2.0));
67  oc.addDescription("max-edges-factor", "Processing",
68  "Routes are cut off when the route edges to net edges ratio is larger than FLOAT");
69 
70  oc.doRegister("turn-defaults", 'T', new Option_StringVector(StringVector({ "30", "50", "20" })));
71  oc.addDescription("turn-defaults", "Processing", "Use STR[] as default turn definition");
72 
73  oc.doRegister("sink-edges", new Option_StringVector());
74  oc.addSynonyme("sink-edges", "sinks");
75  oc.addDescription("sink-edges", "Processing", "Use STR[] as list of sink edges");
76 
77  oc.doRegister("accept-all-destinations", 'A', new Option_Bool(false));
78  oc.addDescription("accept-all-destinations", "Processing", "Whether all edges are allowed as sink edges");
79 
80  oc.doRegister("ignore-vclasses", 'i', new Option_Bool(false));
81  oc.addDescription("ignore-vclasses", "Processing", "Ignore road restrictions based on vehicle class");
82 
83  oc.doRegister("allow-loops", new Option_Bool(false));
84  oc.addDescription("allow-loops", "Processing", "Allow to re-use a road");
85 
86  // add rand options
88 }
89 
90 
91 bool
94  bool ok = ROFrame::checkOptions(oc);
95  if (oc.isDefault("no-internal-links")) {
96  oc.set("no-internal-links", "true");
97  }
98 
100  std::string error;
101  if (oc.isSet("departlane") && !SUMOVehicleParameter::parseDepartLane(oc.getString("departlane"), "option", "departlane", p.departLane, p.departLaneProcedure, error)) {
102  WRITE_ERROR(error);
103  ok = false;
104  }
105  if (oc.isSet("departpos") && !SUMOVehicleParameter::parseDepartPos(oc.getString("departpos"), "option", "departpos", p.departPos, p.departPosProcedure, error)) {
106  WRITE_ERROR(error);
107  ok = false;
108  }
109  if (oc.isSet("departspeed") && !SUMOVehicleParameter::parseDepartSpeed(oc.getString("departspeed"), "option", "departspeed", p.departSpeed, p.departSpeedProcedure, error)) {
110  WRITE_ERROR(error);
111  ok = false;
112  }
113  if (oc.isSet("arrivallane") && !SUMOVehicleParameter::parseArrivalLane(oc.getString("arrivallane"), "option", "arrivallane", p.arrivalLane, p.arrivalLaneProcedure, error)) {
114  WRITE_ERROR(error);
115  ok = false;
116  }
117  if (oc.isSet("arrivalpos") && !SUMOVehicleParameter::parseArrivalPos(oc.getString("arrivalpos"), "option", "arrivalpos", p.arrivalPos, p.arrivalPosProcedure, error)) {
118  WRITE_ERROR(error);
119  ok = false;
120  }
121  if (oc.isSet("arrivalspeed") && !SUMOVehicleParameter::parseArrivalSpeed(oc.getString("arrivalspeed"), "option", "arrivalspeed", p.arrivalSpeed, p.arrivalSpeedProcedure, error)) {
122  WRITE_ERROR(error);
123  ok = false;
124  }
125  return ok;
126 }
127 
128 
129 /****************************************************************************/
OptionsCont::isSet
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Definition: OptionsCont.cpp:135
ToString.h
SystemFrame::addConfigurationOptions
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:39
SUMOVehicleParameter::arrivalSpeedProcedure
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
Definition: SUMOVehicleParameter.h:537
Option_Bool
Definition: Option.h:538
OptionsCont.h
OptionsCont::set
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
Definition: OptionsCont.cpp:241
SUMOVehicleParameter::departSpeed
double departSpeed
(optional) The initial speed of the vehicle
Definition: SUMOVehicleParameter.h:506
SUMOVehicleParameter::departPosProcedure
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
Definition: SUMOVehicleParameter.h:497
MsgHandler.h
SUMOVehicleParameter::parseDepartSpeed
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
Definition: SUMOVehicleParameter.cpp:384
OptionsCont::getString
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
Definition: OptionsCont.cpp:201
SUMOVehicleParameter::parseDepartLane
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.
Definition: SUMOVehicleParameter.cpp:275
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
ROFrame.h
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:297
SUMOVehicleParameter::parseArrivalPos
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
Definition: SUMOVehicleParameter.cpp:448
SUMOVehicleParameter.h
SystemFrame::addReportOptions
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:64
OptionsCont::addDescription
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
Definition: OptionsCont.cpp:469
StringVector
std::vector< std::string > StringVector
Definition of a vector of strings.
Definition: Option.h:45
SUMOVehicleParameter::arrivalLaneProcedure
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
Definition: SUMOVehicleParameter.h:519
SystemFrame.h
OptionsCont::addSynonyme
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
Definition: OptionsCont.cpp:95
SUMOVehicleParameter::parseArrivalLane
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.
Definition: SUMOVehicleParameter.cpp:419
ROJTRFrame::checkOptions
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within jtrrouter.
Definition: ROJTRFrame.cpp:92
SUMOVehicleParameter::arrivalPos
double arrivalPos
(optional) The position the vehicle shall arrive on
Definition: SUMOVehicleParameter.h:522
OptionsCont::doRegister
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:74
SUMOVehicleParameter::arrivalPosProcedure
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
Definition: SUMOVehicleParameter.h:525
UtilExceptions.h
SUMOVehicleParameter::parseArrivalSpeed
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
Definition: SUMOVehicleParameter.cpp:508
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
SUMOVehicleParameter::arrivalLane
int arrivalLane
Definition: SUMOVehicleParameter.h:516
OptionsCont::isDefault
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
Definition: OptionsCont.cpp:163
OptionsCont::addOptionSubTopic
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
Definition: OptionsCont.cpp:519
ROFrame::checkOptions
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:172
SUMOVehicleParameter::departLane
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
Definition: SUMOVehicleParameter.h:488
SUMOVehicleParameter::departLaneProcedure
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
Definition: SUMOVehicleParameter.h:491
Option_StringVector
Definition: Option.h:720
Option.h
Option_Float
Definition: Option.h:470
OptionsCont::addCallExample
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
Definition: OptionsCont.cpp:495
ROJTRFrame::fillOptions
static void fillOptions()
Inserts options used by jtrrouter into the OptionsCont-singleton.
Definition: ROJTRFrame.cpp:44
ROFrame::fillOptions
static void fillOptions(OptionsCont &oc)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:42
ROJTRFrame.h
config.h
Option_FileName
Definition: Option.h:783
RandHelper::insertRandOptions
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:45
RandHelper.h
SUMOVehicleParameter::parseDepartPos
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
Definition: SUMOVehicleParameter.cpp:312
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283
SUMOVehicleParameter::departPos
double departPos
(optional) The position the vehicle shall depart from
Definition: SUMOVehicleParameter.h:494
SUMOVehicleParameter::departSpeedProcedure
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
Definition: SUMOVehicleParameter.h:509
SUMOVehicleParameter::arrivalSpeed
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
Definition: SUMOVehicleParameter.h:534