LCOV - code coverage report
Current view: top level - src/router - ROFrame.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 98.6 % 141 139
Test Date: 2025-12-06 15:35:27 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2025 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    ROFrame.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Michael Behrisch
      18              : /// @date    Sept 2002
      19              : ///
      20              : // Sets and checks options for routing
      21              : /****************************************************************************/
      22              : #include <config.h>
      23              : 
      24              : #include <iostream>
      25              : #include <ctime>
      26              : #include <stdlib.h>
      27              : #include <utils/options/OptionsCont.h>
      28              : #include <utils/options/Option.h>
      29              : #include <utils/common/MsgHandler.h>
      30              : #include <utils/common/UtilExceptions.h>
      31              : #include <utils/common/RandHelper.h>
      32              : #include <utils/common/ToString.h>
      33              : #include <utils/common/SUMOTime.h>
      34              : #include <utils/common/SystemFrame.h>
      35              : #include "ROFrame.h"
      36              : 
      37              : 
      38              : // ===========================================================================
      39              : // method definitions
      40              : // ===========================================================================
      41              : void
      42         4131 : ROFrame::fillOptions(OptionsCont& oc, const bool isDUA, const bool isMA) {
      43              :     // register options
      44              :     // register I/O options
      45         4131 :     oc.doRegister("output-file", 'o', new Option_FileName());
      46         8262 :     oc.addSynonyme("output-file", "output");
      47         8262 :     oc.addDescription("output-file", "Output", TL("Write generated routes to FILE"));
      48              : 
      49         4131 :     oc.doRegister("vtype-output", new Option_FileName());
      50         4131 :     if (!isMA) {
      51         8046 :         oc.addSynonyme("vtype-output", "vtype");
      52              :     }
      53         8262 :     oc.addDescription("vtype-output", "Output", TL("Write used vehicle types into separate FILE"));
      54              : 
      55         4131 :     oc.doRegister("keep-vtype-distributions", new Option_Bool(false));
      56         8262 :     oc.addDescription("keep-vtype-distributions", "Output", TL("Keep vTypeDistribution ids when writing vehicles and their types"));
      57              : 
      58         4131 :     oc.doRegister("emissions.volumetric-fuel", new Option_Bool(false));
      59         8262 :     oc.addDescription("emissions.volumetric-fuel", "Output", TL("Return fuel consumption values in (legacy) unit l instead of mg"));
      60              : 
      61         4131 :     oc.doRegister("net-file", 'n', new Option_FileName());
      62         8262 :     oc.addSynonyme("net-file", "net");
      63         8262 :     oc.addDescription("net-file", "Input", TL("Use FILE as SUMO-network to route on"));
      64              : 
      65         4131 :     oc.doRegister("named-routes", new Option_Bool(false));
      66         8262 :     oc.addDescription("named-routes", "Output", TL("Write vehicles that reference routes by their id"));
      67              : 
      68         4131 :     oc.doRegister("additional-files", 'a', new Option_FileName());
      69         8262 :     oc.addSynonyme("additional-files", "d", true);
      70         8262 :     oc.addSynonyme("additional-files", "additional");
      71         8262 :     oc.addSynonyme("additional-files", "taz-files");
      72         8262 :     oc.addSynonyme("additional-files", "districts", true);
      73         8262 :     oc.addDescription("additional-files", "Input", TL("Read additional network data (districts, bus stops) from FILE(s)"));
      74              : 
      75         4131 :     oc.doRegister("route-files", 'r', new Option_FileName());
      76         8262 :     oc.addSynonyme("route-files", "flow-files", true);
      77         8262 :     oc.addSynonyme("route-files", "flows", true);
      78         8262 :     oc.addSynonyme("route-files", "f", true);
      79         8262 :     oc.addSynonyme("route-files", "alternative-files", true);
      80         8262 :     oc.addSynonyme("route-files", "alternatives-files", true);
      81         8262 :     oc.addSynonyme("route-files", "trip-files", true);
      82         8262 :     oc.addSynonyme("route-files", "trips", true);
      83         4131 :     if (isDUA) {
      84              :         // to make the transition from --trip-files easier, but has a conflict with jtrrouter
      85         7298 :         oc.addSynonyme("route-files", "t", true);
      86              :     }
      87         8262 :     oc.addDescription("route-files", "Input", TL("Read sumo routes, alternatives, flows, and trips from FILE(s)"));
      88              : 
      89        16524 :     oc.doRegister("phemlight-path", new Option_FileName(StringVector({ "./PHEMlight/" })));
      90         8262 :     oc.addDescription("phemlight-path", "Input", TL("Determines where to load PHEMlight definitions from"));
      91              : 
      92         4131 :     oc.doRegister("phemlight-year", new Option_Integer(0));
      93         8262 :     oc.addDescription("phemlight-year", "Input", TL("Enable fleet age modelling with the given reference year in PHEMlight5"));
      94              : 
      95         4131 :     oc.doRegister("phemlight-temperature", new Option_Float(INVALID_DOUBLE));
      96         8262 :     oc.addDescription("phemlight-temperature", "Input", TL("Set ambient temperature to correct NOx emissions in PHEMlight5"));
      97              : 
      98         4131 :     if (isDUA || isMA) {
      99         3757 :         oc.doRegister("weight-files", 'w', new Option_FileName());
     100         7514 :         oc.addSynonyme("weight-files", "weights");
     101         7514 :         oc.addDescription("weight-files", "Input", TL("Read network weights from FILE(s)"));
     102              : 
     103         3757 :         oc.doRegister("lane-weight-files", new Option_FileName());
     104         7514 :         oc.addDescription("lane-weight-files", "Input", TL("Read lane-based network weights from FILE(s)"));
     105              : 
     106         7514 :         oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
     107         7514 :         oc.addSynonyme("weight-attribute", "measure", true);
     108         7514 :         oc.addDescription("weight-attribute", "Input", TL("Name of the xml attribute which gives the edge weight"));
     109              :     }
     110              : 
     111              :     // need to do this here to be able to check for network and route input options
     112         4131 :     SystemFrame::addReportOptions(oc);
     113              : 
     114              :     // register the time settings
     115         8262 :     oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
     116         8262 :     oc.addDescription("begin", "Time", TL("Defines the begin time; Previous trips will be discarded"));
     117              : 
     118         8262 :     oc.doRegister("end", 'e', new Option_String("-1", "TIME"));
     119         8262 :     oc.addDescription("end", "Time", TL("Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent"));
     120              : 
     121              :     // register the processing options
     122         4131 :     oc.doRegister("ignore-errors", new Option_Bool(false));
     123         8262 :     oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
     124         8262 :     oc.addSynonyme("ignore-errors", "dismiss-loading-errors", true);
     125         8262 :     oc.addDescription("ignore-errors", "Report", TL("Continue if a route could not be build"));
     126              : 
     127         4131 :     oc.doRegister("max-alternatives", new Option_Integer(5));
     128         8262 :     oc.addDescription("max-alternatives", "Processing", TL("Prune the number of alternatives to INT"));
     129              : 
     130         4131 :     oc.doRegister("with-taz", new Option_Bool(false));
     131         8262 :     oc.addDescription("with-taz", "Processing", TL("Use origin and destination zones (districts) for in- and output"));
     132              : 
     133         4131 :     oc.doRegister("junction-taz", new Option_Bool(false));
     134         8262 :     oc.addDescription("junction-taz", "Input", TL("Initialize a TAZ for every junction to use attributes toJunction and fromJunction"));
     135              : 
     136         4131 :     if (!isMA) {
     137         4023 :         oc.doRegister("unsorted-input", new Option_Bool(false));
     138         8046 :         oc.addSynonyme("unsorted-input", "unsorted");
     139         8046 :         oc.addDescription("unsorted-input", "Processing", TL("Assume input is unsorted"));
     140              : 
     141         8046 :         oc.doRegister("route-steps", 's', new Option_String("200", "TIME"));
     142         8046 :         oc.addDescription("route-steps", "Processing", TL("Load routes for the next number of seconds ahead"));
     143              : 
     144         4023 :         oc.doRegister("no-internal-links", new Option_Bool(false));
     145         8046 :         oc.addDescription("no-internal-links", "Processing", TL("Disable (junction) internal links"));
     146              : 
     147         4023 :         oc.doRegister("randomize-flows", new Option_Bool(false));
     148         8046 :         oc.addDescription("randomize-flows", "Processing", TL("generate random departure times for flow input"));
     149              : 
     150         4023 :         oc.doRegister("remove-loops", new Option_Bool(false));
     151         8046 :         oc.addDescription("remove-loops", "Processing", TL("Remove loops within the route; Remove turnarounds at start and end of the route"));
     152              : 
     153         4023 :         oc.doRegister("repair", new Option_Bool(false));
     154         8046 :         oc.addDescription("repair", "Processing", TL("Tries to correct a false route"));
     155              : 
     156         4023 :         oc.doRegister("repair.from", new Option_Bool(false));
     157         8046 :         oc.addDescription("repair.from", "Processing", TL("Tries to correct an invalid starting edge by using the first usable edge instead"));
     158              : 
     159         4023 :         oc.doRegister("repair.to", new Option_Bool(false));
     160         8046 :         oc.addDescription("repair.to", "Processing", TL("Tries to correct an invalid destination edge by using the last usable edge instead"));
     161              : 
     162         4023 :         oc.doRegister("repair.max-detour-factor", new Option_Float(10));
     163         8046 :         oc.addDescription("repair.max-detour-factor", "Processing", TL("Backtrack on route if the detour is longer than the gap by FACTOR"));
     164              : 
     165         4023 :         oc.doRegister("mapmatch.distance", new Option_Float(100));
     166         8046 :         oc.addDescription("mapmatch.distance", "Processing", TL("Maximum distance when mapping input coordinates (fromXY etc.) to the road network"));
     167              : 
     168         4023 :         oc.doRegister("mapmatch.junctions", new Option_Bool(false));
     169         8046 :         oc.addDescription("mapmatch.junctions", "Processing", TL("Match positions to junctions instead of edges"));
     170              : 
     171         4023 :         oc.doRegister("mapmatch.taz", new Option_Bool(false));
     172         8046 :         oc.addDescription("mapmatch.taz", "Processing", TL("Match positions to taz instead of edges"));
     173              : 
     174         4023 :         oc.doRegister("bulk-routing", new Option_Bool(false));
     175         8046 :         oc.addDescription("bulk-routing", "Processing", TL("Aggregate routing queries with the same origin"));
     176              :     }
     177              : 
     178         4131 :     oc.doRegister("routing-threads", new Option_Integer(0));
     179         8262 :     oc.addDescription("routing-threads", "Processing", TL("The number of parallel execution threads used for routing"));
     180              : 
     181         4131 :     if (isDUA || isMA) {
     182         7514 :         oc.doRegister("routing-algorithm", new Option_String("dijkstra"));
     183         7514 :         oc.addDescription("routing-algorithm", "Processing", TL("Select among routing algorithms ['dijkstra', 'astar', 'CH', 'CHWrapper']"));
     184              :     }
     185              : 
     186         4131 :     oc.doRegister("restriction-params", new Option_StringVector());
     187         8262 :     oc.addDescription("restriction-params", "Processing", TL("Comma separated list of param keys to compare for additional restrictions"));
     188              : 
     189         4131 :     if (isDUA || isMA) {
     190         3757 :         oc.doRegister("weights.interpolate", new Option_Bool(false));
     191         7514 :         oc.addSynonyme("weights.interpolate", "interpolate", true);
     192         7514 :         oc.addDescription("weights.interpolate", "Processing", TL("Interpolate edge weights at interval boundaries"));
     193              : 
     194         3757 :         oc.doRegister("weights.expand", new Option_Bool(false));
     195         7514 :         oc.addSynonyme("weights.expand", "expand-weights", true);
     196         7514 :         oc.addDescription("weights.expand", "Processing", TL("Expand the end of the last loaded weight interval to infinity"));
     197              :     }
     198              : 
     199         4131 :     oc.doRegister("weights.minor-penalty", new Option_Float(1.5));
     200         8262 :     oc.addDescription("weights.minor-penalty", "Processing", TL("Apply the given time penalty when computing routing costs for minor-link internal lanes"));
     201              : 
     202         4131 :     oc.doRegister("weights.tls-penalty", new Option_Float(0));
     203         8262 :     oc.addDescription("weights.tls-penalty", "Processing", TL("Apply the given time penalty when computing routing costs across a traffic light"));
     204              : 
     205         4131 :     oc.doRegister("weights.turnaround-penalty", new Option_Float(5.0));
     206         8262 :     oc.addDescription("weights.turnaround-penalty", "Processing", TL("Apply the given time penalty when computing routing costs for turnaround internal lanes"));
     207              : 
     208         4131 :     oc.doRegister("weights.reversal-penalty", new Option_Float(60));
     209         8262 :     oc.addDescription("weights.reversal-penalty", "Processing", TL("Apply the given time penalty when computing routing costs for train reversal. Negative values disable reversal"));
     210              : 
     211         4131 :     if (!isMA) {
     212              :         // register defaults options
     213         4023 :         oc.doRegister("departlane", new Option_String());
     214         8046 :         oc.addDescription("departlane", "Defaults", TL("Assigns a default depart lane"));
     215              : 
     216         4023 :         oc.doRegister("departpos", new Option_String());
     217         8046 :         oc.addDescription("departpos", "Defaults", TL("Assigns a default depart position"));
     218              : 
     219         4023 :         oc.doRegister("departspeed", new Option_String());
     220         8046 :         oc.addDescription("departspeed", "Defaults", TL("Assigns a default depart speed"));
     221              : 
     222         4023 :         oc.doRegister("arrivallane", new Option_String());
     223         8046 :         oc.addDescription("arrivallane", "Defaults", TL("Assigns a default arrival lane"));
     224              : 
     225         4023 :         oc.doRegister("arrivalpos", new Option_String());
     226         8046 :         oc.addDescription("arrivalpos", "Defaults", TL("Assigns a default arrival position"));
     227              : 
     228         4023 :         oc.doRegister("arrivalspeed", new Option_String());
     229         8046 :         oc.addDescription("arrivalspeed", "Defaults", TL("Assigns a default arrival speed"));
     230              : 
     231              :     }
     232         4131 :     oc.doRegister("defaults-override", new Option_Bool(false));
     233         8262 :     oc.addDescription("defaults-override", "Defaults", TL("Defaults will override given values"));
     234              : 
     235              :     // register report options
     236         4131 :     oc.doRegister("stats-period", new Option_Integer(-1));
     237         8262 :     oc.addDescription("stats-period", "Report", TL("Defines how often statistics shall be printed"));
     238              : 
     239         4131 :     oc.doRegister("no-step-log", new Option_Bool(false));
     240         8262 :     oc.addDescription("no-step-log", "Report", TL("Disable console output of route parsing step"));
     241        12393 : }
     242              : 
     243              : 
     244              : bool
     245         3757 : ROFrame::checkOptions(OptionsCont& oc) {
     246              :     // check whether the output is valid and can be build
     247         7514 :     if (!oc.isSet("output-file")) {
     248           10 :         WRITE_ERROR(TL("No output specified."));
     249           10 :         return false;
     250              :     }
     251              :     //
     252         7494 :     if (oc.getInt("max-alternatives") < 1) {
     253            0 :         WRITE_ERROR(TL("A positive number of alternatives must be enabled."));
     254            0 :         return false;
     255              :     }
     256              : #ifndef HAVE_FOX
     257              :     if (oc.getInt("routing-threads") > 1) {
     258              :         WRITE_ERROR(TL("Parallel routing is only possible when compiled with Fox."));
     259              :         return false;
     260              :     }
     261              : #endif
     262              :     return true;
     263              : }
     264              : 
     265              : 
     266              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1