Path: blob/main/src/utils/distribution/Distribution_Parameterized.h
169678 views
/****************************************************************************/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 Distribution_Parameterized.h14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @date Sept 200217///18// A distribution described by parameters such as the mean value and std-dev19/****************************************************************************/20#pragma once21#include <config.h>2223#include <vector>24#include <random>2526#include "Distribution.h"272829// ===========================================================================30// class definitions31// ===========================================================================32/**33* @class Distribution_Parameterized34* A description of distribution by the distribution's mean value and a35* standard deviation.36* Incomplete and unused yet. This class should be overridden by derived37* classes38*/39class Distribution_Parameterized : public Distribution {4041public:42/// @brief Constructor for any temporary distribution parsed directly from the description43Distribution_Parameterized(const std::string& description);4445/// @brief Constructor for standard normal distribution46Distribution_Parameterized(const std::string& id, double mean, double deviation);4748/// @brief Constructor for normal distribution with cutoff49Distribution_Parameterized(const std::string& id, double mean, double deviation, double min, double max);5051/// @brief Destructor52virtual ~Distribution_Parameterized();5354/// @brief Overwrite by parsable distribution description55void parse(const std::string& description, const bool hardFail);5657/** @brief Draw a sample of the distribution using the given RNG.58*59* A random sample is drawn according to the assigned probabilities.60*61* @param[in] which The random number generator to use; the static one will be used if nullptr is passed62* @return the drawn member63*/64double sample(SumoRNG* which = nullptr) const;6566/// @brief Returns the maximum value of this distribution67double getMax() const;6869/// @brief Returns the minimum value of this distribution70double getMin() const;7172/// @brief Returns the nth parameter of this distribution73inline double getParameter(const int index) const {74return myParameter[index];75}7677/// @brief Set a parameter of this distribution78void setParameter(const int index, const double value);7980/// @brief check whether the distribution is valid81const std::string isValid() const;8283/// @brief Returns the string representation of this distribution84std::string toStr(std::streamsize accuracy) const;8586/// @brief validate input description87static bool isValidDescription(const std::string& description);8889private:90/// @brief The distribution's parameters91std::vector<double> myParameter;92};939495