/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2002-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 ODDistrict.h14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @date Sept 200217///18// A district (origin/destination)19/****************************************************************************/20#pragma once21#include <config.h>2223#include <vector>24#include <string>25#include <utility>26#include <utils/common/Named.h>27#include <utils/common/UtilExceptions.h>28#include <utils/distribution/RandomDistributor.h>293031// ===========================================================================32// class definitions33// ===========================================================================34/**35* @class ODDistrict36* @brief A district (origin/destination)37*38* Class representing a district which has some ingoing and outgoing connections39* to the road network which may be weighted.40*/41class ODDistrict : public Named {42public:43/** @brief Constructor44*45* @param[in] id The id of the district46*/47ODDistrict(const std::string& id);484950/// @brief Destructor51~ODDistrict();525354/** @brief Adds a source connection55*56* A source is an edge where vehicles leave the district from to reach57* the network. The weight is used when a random source shall be58* chosen.59*60* BTW, it is possible to add a source twice. In this case it will occure61* twice within the distribution so that the behaviour is as adding62* both given probabilities.63*64* @param[in] id The id of the source65* @param[in] weight The weight (probability to be chosen) of the source66*/67void addSource(const std::string& id, double weight);686970/** @brief Adds a sink connection71*72* A sink connection is an edge which is used by vehicles to leave the73* network and reach the district. The weight is used when a random74* sink shall be chosen.75*76* BTW, it is possible to add a sink twice. In this case it will occure77* twice within the distribution so that the behaviour is as adding78* both given probabilities.79*80* @param[in] id The id of the sink81* @param[in] weight The weight (probability to be chosen) of the sink82*/83void addSink(const std::string& id, double weight);848586/** @brief Returns the id of a source to use87*88* If the list of this district's sources is empty, an OutOfBoundsException89* -exception is thrown.90*91* @return One of this district's sources chosen randomly regarding their weights92* @exception OutOfBoundsException If this district has no sources93*/94std::string getRandomSource() const;959697/** @brief Returns the id of a sink to use98*99* If the list of this district's sinks is empty, an OutOfBoundsException100* -exception is thrown.101*102* @return One of this district's sinks chosen randomly regarding their weights103* @exception OutOfBoundsException If this district has no sinks104*/105std::string getRandomSink() const;106107108/** @brief Returns the number of sinks109*110* @return The number of known sinks111*/112int sinkNumber() const;113114115/** @brief Returns the number of sources116*117* @return The number of known sources118*/119int sourceNumber() const;120121122private:123/// @brief Container of weighted sources124RandomDistributor<std::string> mySources;125126/// @brief Container of weighted sinks127RandomDistributor<std::string> mySinks;128129130private:131/// @brief invalidated copy constructor132ODDistrict(const ODDistrict& s);133134/// @brief invalidated assignment operator135ODDistrict& operator=(const ODDistrict& s);136137138};139140141