Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2026 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 Distribution_Parameterized.h
15 : /// @author Daniel Krajzewicz
16 : /// @author Michael Behrisch
17 : /// @date Sept 2002
18 : ///
19 : // A distribution described by parameters such as the mean value and std-dev
20 : /****************************************************************************/
21 : #pragma once
22 : #include <config.h>
23 :
24 : #include <vector>
25 :
26 : #include "Distribution.h"
27 :
28 :
29 : // ===========================================================================
30 : // class definitions
31 : // ===========================================================================
32 : /**
33 : * @class Distribution_Parameterized
34 : * A description of distribution by the distribution's mean value and a
35 : * standard deviation.
36 : * Incomplete and unused yet. This class should be overridden by derived
37 : * classes
38 : */
39 348656 : class Distribution_Parameterized : public Distribution {
40 :
41 : public:
42 : /// @brief Constructor for any temporary distribution parsed directly from the description
43 : Distribution_Parameterized(const std::string& description);
44 :
45 : /// @brief Constructor for standard normal distribution
46 : Distribution_Parameterized(const std::string& id, double mean, double deviation);
47 :
48 : /// @brief Constructor for normal distribution with cutoff
49 : Distribution_Parameterized(const std::string& id, double mean, double deviation, double min, double max);
50 :
51 : /// @brief Destructor
52 : virtual ~Distribution_Parameterized();
53 :
54 : /// @brief Overwrite by parsable distribution description
55 : void parse(const std::string& description, const bool hardFail);
56 :
57 : /** @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 passed
62 : * @return the drawn member
63 : */
64 : double sample(SumoRNG* which = nullptr) const;
65 :
66 : /// @brief Returns the maximum value of this distribution
67 : double getMax() const;
68 :
69 : /// @brief Returns the minimum value of this distribution
70 : double getMin() const;
71 :
72 : /// @brief Returns the nth parameter of this distribution
73 : inline double getParameter(const int index) const {
74 13353154 : return myParameter[index];
75 : }
76 :
77 : /// @brief Set a parameter of this distribution
78 : void setParameter(const int index, const double value);
79 :
80 : /// @brief check whether the distribution is valid
81 : const std::string isValid() const;
82 :
83 : /// @brief Returns the string representation of this distribution
84 : std::string toStr(std::streamsize accuracy) const;
85 :
86 : /// @brief validate input description
87 : static bool isValidDescription(const std::string& description);
88 :
89 : private:
90 : /// @brief The distribution's parameters
91 : std::vector<double> myParameter;
92 : };
|