/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file ROMAAssignments.h14/// @author Yun-Pang Floetteroed15/// @author Laura Bieker16/// @author Michael Behrisch17/// @date Feb 201318///19// Assignment methods20/****************************************************************************/21#pragma once22#include <config.h>2324#include <utils/router/SUMOAbstractRouter.h>25#include <utils/common/SUMOTime.h>2627// ===========================================================================28// class declarations29// ===========================================================================30class RONet;31class ODMatrix;32class Distribution_Points;33class ROEdge;34class ROMAEdge;35class ROVehicle;36373839// ===========================================================================40// class definitions41// ===========================================================================42/**43* @class ROMAAssignments44* @brief assignment methods45*46*/47class ROMAAssignments {48public:49/// Constructor50ROMAAssignments(const SUMOTime begin, const SUMOTime end, const bool additiveTraffic,51const double adaptionFactor, const int maxAlternatives, const bool defaultCapacities,52RONet& net, ODMatrix& matrix, SUMOAbstractRouter<ROEdge, ROVehicle>& router,53OutputDevice* netloadOutput);5455/// Destructor56~ROMAAssignments();5758ROVehicle* getDefaultVehicle() const {59return myDefaultVehicle;60}6162// @brief calculate edge capacity for the given edge63double getCapacity(const ROEdge* edge) const;6465// @brief calculate edge travel time for the given edge and number of vehicles per hour66double capacityConstraintFunction(const ROEdge* edge, const double flow) const;6768// @brief clear effort storage69void resetFlows();7071// @brief Writes the travel times for a single interval72void writeInterval(const SUMOTime begin, const SUMOTime end);7374// @brief incremental method75void incremental(const int numIter, const bool verbose);7677// @brief UE method78void ue();7980// @brief SUE method81void sue(const int maxOuterIteration, const int maxInnerIteration, const int kPaths, const double penalty, const double tolerance, const std::string routeChoiceMethod);8283/** @brief Returns the effort to pass an edge including penalties84*85* This method is given to the used router in order to obtain the efforts86* to pass an edge from the internal edge weights container.87*88* @param[in] e The edge for which the effort to be passed shall be returned89* @param[in] v The (default) vehicle that is routed90* @param[in] t The time for which the effort shall be returned91* @return The effort (time to pass in this case) for an edge92* @see DijkstraRouter_ByProxi93*/94static double getPenalizedEffort(const ROEdge* const e, const ROVehicle* const v, double t);9596/** @brief Returns the traveltime on an edge including penalties97*98* This method is given to the used router in order to obtain the efforts99* to pass an edge from the internal edge weights container.100*101* @param[in] e The edge for which the effort to be passed shall be returned102* @param[in] v The (default) vehicle that is routed103* @param[in] t The time for which the effort shall be returned104* @return The effort (time to pass in this case) for an edge105* @see DijkstraRouter_ByProxi106*/107static double getPenalizedTT(const ROEdge* const e, const ROVehicle* const v, double t);108109/** @brief Returns the traveltime on an edge without penalties110*111* This method is given to the used router in order to obtain the efforts112* to pass an edge from the internal edge weights container.113*114* @param[in] e The edge for which the effort to be passed shall be returned115* @param[in] v The (default) vehicle that is routed116* @param[in] t The time for which the effort shall be returned117* @return The effort (time to pass in this case) for an edge118* @see DijkstraRouter_ByProxi119*/120static double getTravelTime(const ROEdge* const e, const ROVehicle* const v, double t);121122private:123/// @brief add a route and check for duplicates124bool addRoute(const ConstROEdgeVector& edges, std::vector<RORoute*>& paths, std::string routeId, double prob);125126const ConstROEdgeVector computePath(ODCell* cell, const SUMOTime time = 0, const double probability = 0., SUMOAbstractRouter<ROEdge, ROVehicle>* router = nullptr, bool setBulkMode = false);127128/// @brief get the k shortest paths129void getKPaths(const int kPaths, const double penalty);130131private:132const SUMOTime myBegin;133const SUMOTime myEnd;134const bool myAdditiveTraffic;135const double myAdaptionFactor;136const int myMaxAlternatives;137const bool myUseDefaultCapacities;138RONet& myNet;139ODMatrix& myMatrix;140SUMOAbstractRouter<ROEdge, ROVehicle>& myRouter;141static std::map<const ROEdge* const, double> myPenalties;142ROVehicle* myDefaultVehicle;143OutputDevice* const myNetloadOutput;144145#ifdef HAVE_FOX146private:147class RoutingTask : public MFXWorkerThread::Task {148public:149RoutingTask(ROMAAssignments& assign, ODCell* c, const SUMOTime begin, const double linkFlow, const bool setBulkMode = false)150: myAssign(assign), myCell(c), myBegin(begin), myLinkFlow(linkFlow), mySetBulkMode(setBulkMode) {}151void run(MFXWorkerThread* context);152private:153ROMAAssignments& myAssign;154ODCell* const myCell;155const SUMOTime myBegin;156const double myLinkFlow;157const bool mySetBulkMode;158private:159/// @brief Invalidated assignment operator.160RoutingTask& operator=(const RoutingTask&) = delete;161};162#endif163164165private:166/// @brief Invalidated assignment operator167ROMAAssignments& operator=(const ROMAAssignments& src) = delete;168169};170171172