LCOV - code coverage report
Current view: top level - src/marouter - ROMAFrame.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 97.1 % 138 134
Test Date: 2024-12-21 15:45:41 Functions: 100.0 % 4 4

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    ROMAFrame.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Laura Bieker
      18              : /// @author  Michael Behrisch
      19              : /// @date    Sept 2002
      20              : ///
      21              : // Sets and checks options for ma-routing
      22              : /****************************************************************************/
      23              : #include <config.h>
      24              : 
      25              : #include <iostream>
      26              : #include <fstream>
      27              : #include <ctime>
      28              : #include <utils/options/OptionsCont.h>
      29              : #include <utils/options/Option.h>
      30              : #include <utils/common/MsgHandler.h>
      31              : #include <utils/common/UtilExceptions.h>
      32              : #include <utils/common/ToString.h>
      33              : #include "ROMAFrame.h"
      34              : #include <router/ROFrame.h>
      35              : #include <utils/common/RandHelper.h>
      36              : #include <utils/common/SystemFrame.h>
      37              : #include <utils/vehicle/SUMOVehicleParameter.h>
      38              : 
      39              : 
      40              : // ===========================================================================
      41              : // method definitions
      42              : // ===========================================================================
      43              : void
      44          102 : ROMAFrame::fillOptions() {
      45          102 :     OptionsCont& oc = OptionsCont::getOptions();
      46          204 :     oc.addCallExample("-c <CONFIGURATION>", "run routing with options from file");
      47              : 
      48              :     // insert options sub-topics
      49          102 :     SystemFrame::addConfigurationOptions(oc); // fill this subtopic, too
      50          102 :     oc.addOptionSubTopic("Input");
      51          102 :     oc.addOptionSubTopic("Output");
      52          102 :     oc.addOptionSubTopic("Processing");
      53          102 :     oc.addOptionSubTopic("Defaults");
      54          102 :     oc.addOptionSubTopic("Time");
      55              : 
      56              :     // insert options
      57          102 :     ROFrame::fillOptions(oc, false, true);
      58          102 :     addImportOptions();
      59          102 :     addAssignmentOptions();
      60              :     // add rand options
      61          102 :     RandHelper::insertRandOptions(oc);
      62          102 : }
      63              : 
      64              : 
      65              : void
      66          102 : ROMAFrame::addImportOptions() {
      67          102 :     OptionsCont& oc = OptionsCont::getOptions();
      68              :     // register import options
      69          102 :     oc.doRegister("ignore-vehicle-type", new Option_Bool(false));
      70          204 :     oc.addSynonyme("ignore-vehicle-type", "no-vtype", true);
      71          204 :     oc.addDescription("ignore-vehicle-type", "Output", TL("Does not save vtype information"));
      72              : 
      73          102 :     oc.doRegister("netload-output", new Option_FileName());
      74          204 :     oc.addDescription("netload-output", "Output", TL("Writes edge loads and final costs into FILE"));
      75              : 
      76          102 :     oc.doRegister("all-pairs-output", new Option_FileName());
      77          204 :     oc.addDescription("all-pairs-output", "Output", TL("Writes complete distance matrix into FILE"));
      78              : 
      79          102 :     oc.doRegister("od-matrix-files", 'm', new Option_FileName());
      80          204 :     oc.addSynonyme("od-matrix-files", "od-files");
      81          204 :     oc.addDescription("od-matrix-files", "Input", TL("Loads O/D-files from FILE(s)"));
      82              : 
      83          102 :     oc.doRegister("od-amitran-files", new Option_FileName());
      84          204 :     oc.addSynonyme("od-amitran-files", "amitran-files");
      85          204 :     oc.addSynonyme("od-amitran-files", "amitran");
      86          204 :     oc.addDescription("od-amitran-files", "Input", TL("Loads O/D-matrix in Amitran format from FILE(s)"));
      87              : 
      88          102 :     oc.doRegister("tazrelation-files", 'z', new Option_FileName());
      89          204 :     oc.addDescription("tazrelation-files", "Input", TL("Loads O/D-matrix in tazRelation format from FILE(s)"));
      90              : 
      91          204 :     oc.doRegister("tazrelation-attribute", new Option_String("count"));
      92          204 :     oc.addSynonyme("tazrelation-attribute", "attribute");
      93          204 :     oc.addDescription("tazrelation-attribute", "Input", TL("Define data attribute for loading counts (default 'count')"));
      94              : 
      95          102 :     oc.doRegister("weight-adaption", new Option_Float(0.));
      96          204 :     oc.addDescription("weight-adaption", "Input", TL("The travel time influence of prior intervals"));
      97              : 
      98          102 :     oc.doRegister("taz-param", new Option_StringVector());
      99          204 :     oc.addDescription("taz-param", "Input", TL("Parameter key(s) defining source (and sink) taz"));
     100              : 
     101          102 :     oc.doRegister("ignore-taz", new Option_Bool(false));
     102          204 :     oc.addDescription("ignore-taz", "Input", TL("Ignore attributes 'fromTaz' and 'toTaz'"));
     103              : 
     104              :     // register the processing options
     105          204 :     oc.doRegister("aggregation-interval", new Option_String("3600", "TIME"));
     106          204 :     oc.addDescription("aggregation-interval", "Processing", TL("Defines the time interval when aggregating single vehicle input; Defaults to one hour"));
     107              : 
     108          102 :     oc.doRegister("capacities.default", new Option_Bool(false));
     109          204 :     oc.addDescription("capacities.default", "Processing", TL("Ignore edge priorities when calculating capacities and restraints"));
     110              : 
     111          102 :     oc.doRegister("weights.priority-factor", new Option_Float(0));
     112          204 :     oc.addDescription("weights.priority-factor", "Processing", TL("Consider edge priorities in addition to travel times, weighted by factor"));
     113              : 
     114          102 :     oc.doRegister("bulk-routing.vtypes", new Option_Bool(false));
     115          204 :     oc.addDescription("bulk-routing.vtypes", "Processing", TL("Aggregate routing queries with the same origin for different vehicle types"));
     116              : 
     117          204 :     oc.doRegister("weight-period", new Option_String("3600", "TIME"));
     118          204 :     oc.addDescription("weight-period", "Processing", TL("Aggregation period for the given weight files; triggers rebuilding of Contraction Hierarchy"));
     119              : 
     120              :     // register defaults options
     121          204 :     oc.doRegister("flow-output.departlane", new Option_String("free"));
     122          204 :     oc.addSynonyme("flow-output.departlane", "departlane");
     123          204 :     oc.addDescription("flow-output.departlane", "Defaults", TL("Assigns a default depart lane"));
     124              : 
     125          102 :     oc.doRegister("flow-output.departpos", new Option_String());
     126          204 :     oc.addSynonyme("flow-output.departpos", "departpos");
     127          204 :     oc.addDescription("flow-output.departpos", "Defaults", TL("Assigns a default depart position"));
     128              : 
     129          204 :     oc.doRegister("flow-output.departspeed", new Option_String("max"));
     130          204 :     oc.addSynonyme("flow-output.departspeed", "departspeed");
     131          204 :     oc.addDescription("flow-output.departspeed", "Defaults", TL("Assigns a default depart speed"));
     132              : 
     133          102 :     oc.doRegister("flow-output.arrivallane", new Option_String());
     134          204 :     oc.addSynonyme("flow-output.arrivallane", "arrivallane");
     135          204 :     oc.addDescription("flow-output.arrivallane", "Defaults", TL("Assigns a default arrival lane"));
     136              : 
     137          102 :     oc.doRegister("flow-output.arrivalpos", new Option_String());
     138          204 :     oc.addSynonyme("flow-output.arrivalpos", "arrivalpos");
     139          204 :     oc.addDescription("flow-output.arrivalpos", "Defaults", TL("Assigns a default arrival position"));
     140              : 
     141          102 :     oc.doRegister("flow-output.arrivalspeed", new Option_String());
     142          204 :     oc.addSynonyme("flow-output.arrivalspeed", "arrivalspeed");
     143          204 :     oc.addDescription("flow-output.arrivalspeed", "Defaults", TL("Assigns a default arrival speed"));
     144              : 
     145          102 : }
     146              : 
     147              : 
     148              : void
     149          102 : ROMAFrame::addAssignmentOptions() {
     150          102 :     OptionsCont& oc = OptionsCont::getOptions();
     151              :     // register the data processing options
     152          102 :     oc.doRegister("scale", 's', new Option_Float(1));
     153          204 :     oc.addDescription("scale", "Processing", TL("Scales the loaded flows by FLOAT"));
     154              : 
     155          204 :     oc.doRegister("vtype", new Option_String(""));
     156          204 :     oc.addDescription("vtype", "Processing", TL("Defines the name of the vehicle type to use"));
     157              : 
     158          204 :     oc.doRegister("prefix", new Option_String(""));
     159          204 :     oc.addDescription("prefix", "Processing", TL("Defines the prefix for vehicle flow names"));
     160              : 
     161          102 :     oc.doRegister("timeline", new Option_StringVector());
     162          204 :     oc.addDescription("timeline", "Processing", TL("Uses STR[] as a timeline definition"));
     163              : 
     164          102 :     oc.doRegister("timeline.day-in-hours", new Option_Bool(false));
     165          204 :     oc.addDescription("timeline.day-in-hours", "Processing", TL("Uses STR as a 24h-timeline definition"));
     166              : 
     167          102 :     oc.doRegister("additive-traffic", new Option_Bool(false));
     168          204 :     oc.addDescription("additive-traffic", "Processing", TL("Keep traffic flows of all time slots in the net"));
     169              : 
     170              :     // register macroscopic SUE-settings
     171          204 :     oc.doRegister("assignment-method", new Option_String("incremental"));
     172          204 :     oc.addDescription("assignment-method", "Processing", TL("Choose a assignment method: incremental, UE or SUE"));
     173              : 
     174          102 :     oc.doRegister("tolerance", new Option_Float(double(0.001)));
     175          204 :     oc.addDescription("tolerance", "Processing", TL("Use FLOAT as tolerance when checking for SUE stability"));
     176              : 
     177          102 :     oc.doRegister("left-turn-penalty", new Option_Float(0.));
     178          204 :     oc.addDescription("left-turn-penalty", "Processing", TL("Use left-turn penalty FLOAT to calculate link travel time when searching routes"));
     179              : 
     180          102 :     oc.doRegister("paths",  new Option_Integer(1));
     181          204 :     oc.addDescription("paths", "Processing", TL("Use INTEGER as the number of paths needed to be searched for each OD pair at each iteration"));
     182              : 
     183          102 :     oc.doRegister("paths.penalty", new Option_Float(double(1)));
     184          204 :     oc.addDescription("paths.penalty", "Processing", TL("Penalize existing routes with FLOAT to find secondary routes"));
     185              : 
     186          102 :     oc.doRegister("upperbound", new Option_Float(double(0.5)));
     187          204 :     oc.addSynonyme("upperbound", "upper", true);
     188          204 :     oc.addDescription("upperbound", "Processing", TL("Use FLOAT as the upper bound to determine auxiliary link cost"));
     189              : 
     190          102 :     oc.doRegister("lowerbound", new Option_Float(double(0.15)));
     191          204 :     oc.addSynonyme("lowerbound", "lower", true);
     192          204 :     oc.addDescription("lowerbound", "Processing", TL("Use FLOAT as the lower bound to determine auxiliary link cost"));
     193              : 
     194          102 :     oc.doRegister("max-iterations", 'i', new Option_Integer(20));
     195          204 :     oc.addDescription("max-iterations", "Processing", TL("maximal number of iterations for new route searching in incremental and stochastic user assignment"));
     196              : 
     197          102 :     oc.doRegister("max-inner-iterations", new Option_Integer(1000));
     198          204 :     oc.addDescription("max-inner-iterations", "Processing", TL("maximal number of inner iterations for user equilibrium calculation in the stochastic user assignment"));
     199              : 
     200              :     // register route choice settings
     201          204 :     oc.doRegister("route-choice-method", new Option_String("logit"));
     202          204 :     oc.addDescription("route-choice-method", "Processing", TL("Choose a route choice method: gawron, logit, or lohse"));
     203              : 
     204          102 :     oc.doRegister("gawron.beta", new Option_Float(double(0.3)));
     205          204 :     oc.addSynonyme("gawron.beta", "gBeta", true);
     206          204 :     oc.addDescription("gawron.beta", "Processing", TL("Use FLOAT as Gawron's beta"));
     207              : 
     208          102 :     oc.doRegister("gawron.a", new Option_Float(double(0.05)));
     209          204 :     oc.addSynonyme("gawron.a", "gA", true);
     210          204 :     oc.addDescription("gawron.a", "Processing", TL("Use FLOAT as Gawron's a"));
     211              : 
     212          102 :     oc.doRegister("exit-times", new Option_Bool(false));
     213          204 :     oc.addDescription("exit-times", "Output", TL("Write exit times (weights) for each edge"));
     214              : 
     215          102 :     oc.doRegister("keep-all-routes", new Option_Bool(false));
     216          204 :     oc.addDescription("keep-all-routes", "Processing", TL("Save routes with near zero probability"));
     217              : 
     218          102 :     oc.doRegister("skip-new-routes", new Option_Bool(false));
     219          204 :     oc.addDescription("skip-new-routes", "Processing", TL("Only reuse routes from input, do not calculate new ones"));
     220              : 
     221          102 :     oc.doRegister("logit.beta", new Option_Float(double(0.15)));  // check: remove the default?
     222          204 :     oc.addSynonyme("logit.beta", "lBeta", true);
     223          204 :     oc.addDescription("logit.beta", "Processing", TL("Use FLOAT as (c-)logit's beta for the commonality factor"));
     224              : 
     225          102 :     oc.doRegister("logit.gamma", new Option_Float(double(1)));
     226          204 :     oc.addSynonyme("logit.gamma", "lGamma", true);
     227          204 :     oc.addDescription("logit.gamma", "Processing", TL("Use FLOAT as (c-)logit's gamma for the commonality factor"));
     228              : 
     229          102 :     oc.doRegister("logit.theta", new Option_Float(double(0.01)));
     230          204 :     oc.addSynonyme("logit.theta", "lTheta", true);
     231          204 :     oc.addDescription("logit.theta", "Processing", TL("Use FLOAT as (c-)logit's theta"));
     232          102 : }
     233              : 
     234              : 
     235              : bool
     236           96 : ROMAFrame::checkOptions() {
     237           96 :     OptionsCont& oc = OptionsCont::getOptions();
     238          305 :     if (oc.isSet("assignment-method") && oc.getString("assignment-method") != "incremental" && oc.getString("assignment-method") != "UE" && oc.getString("assignment-method") != "SUE") {
     239            0 :         WRITE_ERRORF(TL("Invalid assignment method '%'."), oc.getString("assignment-method"));
     240            0 :         return false;
     241              :     }
     242          288 :     if (oc.getString("route-choice-method") != "gawron" && oc.getString("route-choice-method") != "logit" && oc.getString("route-choice-method") != "lohse") {
     243            0 :         WRITE_ERRORF(TL("Invalid route choice method '%'."), oc.getString("route-choice-method"));
     244            0 :         return false;
     245              :     }
     246          106 :     if (oc.getInt("paths") > 1 && (oc.getString("routing-algorithm") == "CH" || oc.getString("routing-algorithm") == "CHWrapper")) {
     247            2 :         WRITE_WARNING(TL("Contraction hierarchies do not work with k shortest path search (please use a different routing algorithm)!"));
     248              :     }
     249              :     return true;
     250              : }
     251              : 
     252              : 
     253              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1