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 /****************************************************************************/
17 // Sets and checks options for jtr-routing
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <iostream>
27 #include <fstream>
28 #include <ctime>
30 #include <utils/options/Option.h>
33 #include <utils/common/ToString.h>
34 #include "ROJTRFrame.h"
35 #include <router/ROFrame.h>
39 
40 
41 // ===========================================================================
42 // method definitions
43 // ===========================================================================
44 void
47  oc.addCallExample("-c <CONFIGURATION>", "run with routing options defined in file");
48 
49  // insert options sub-topics
51  oc.addOptionSubTopic("Input");
52  oc.addOptionSubTopic("Output");
53  oc.addOptionSubTopic("Processing");
54  oc.addOptionSubTopic("Defaults");
55  oc.addOptionSubTopic("Time");
56  SystemFrame::addReportOptions(oc); // fill this subtopic, too
57 
59 
60  oc.doRegister("turn-ratio-files", 't', new Option_FileName());
61  oc.addSynonyme("turn-ratio-files", "turns");
62  oc.addDescription("turn-ratio-files", "Input", "Read turning ratios from FILE(s)");
63 
64  oc.doRegister("exit-times", new Option_Bool(false));
65  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
66 
67  oc.doRegister("max-edges-factor", new Option_Float(2.0));
68  oc.addDescription("max-edges-factor", "Processing", "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_String("30,50,20"));
71  oc.addDescription("turn-defaults", "Processing", "Use STR as default turn definition");
72 
73  oc.doRegister("sink-edges", new Option_String());
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:136
ToString.h
SystemFrame::addConfigurationOptions
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:40
SUMOVehicleParameter::arrivalSpeedProcedure
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
Definition: SUMOVehicleParameter.h:531
Option_Bool
Definition: Option.h:540
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:244
SUMOVehicleParameter::departSpeed
double departSpeed
(optional) The initial speed of the vehicle
Definition: SUMOVehicleParameter.h:500
SUMOVehicleParameter::departPosProcedure
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
Definition: SUMOVehicleParameter.h:491
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:357
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:202
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:250
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
ROFrame.h
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:291
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:421
SUMOVehicleParameter.h
SystemFrame::addReportOptions
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:65
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:473
SUMOVehicleParameter::arrivalLaneProcedure
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
Definition: SUMOVehicleParameter.h:513
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:96
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:392
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:516
OptionsCont::doRegister
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:75
SUMOVehicleParameter::arrivalPosProcedure
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
Definition: SUMOVehicleParameter.h:519
Option_String
Definition: Option.h:401
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:481
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
SUMOVehicleParameter::arrivalLane
int arrivalLane
Definition: SUMOVehicleParameter.h:510
OptionsCont::isDefault
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
Definition: OptionsCont.cpp:164
OptionsCont::addOptionSubTopic
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
Definition: OptionsCont.cpp:523
ROFrame::checkOptions
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:170
SUMOVehicleParameter::departLane
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
Definition: SUMOVehicleParameter.h:482
SUMOVehicleParameter::departLaneProcedure
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
Definition: SUMOVehicleParameter.h:485
Option.h
Option_Float
Definition: Option.h:472
OptionsCont::addCallExample
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
Definition: OptionsCont.cpp:499
ROJTRFrame::fillOptions
static void fillOptions()
Inserts options used by jtrrouter into the OptionsCont-singleton.
Definition: ROJTRFrame.cpp:45
ROFrame::fillOptions
static void fillOptions(OptionsCont &oc)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:43
ROJTRFrame.h
config.h
Option_FileName
Definition: Option.h:651
RandHelper::insertRandOptions
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:43
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:287
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:245
SUMOVehicleParameter::departPos
double departPos
(optional) The position the vehicle shall depart from
Definition: SUMOVehicleParameter.h:488
SUMOVehicleParameter::departSpeedProcedure
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
Definition: SUMOVehicleParameter.h:503
SUMOVehicleParameter::arrivalSpeed
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
Definition: SUMOVehicleParameter.h:528