LCOV - code coverage report
Current view: top level - src/utils/distribution - Distribution_Parameterized.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 1 100.0 %
Date: 2024-05-05 15:31:14 Functions: 0 0 -

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2001-2024 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             : #include <random>
      26             : 
      27             : #include "Distribution.h"
      28             : 
      29             : 
      30             : // ===========================================================================
      31             : // class definitions
      32             : // ===========================================================================
      33             : /**
      34             :  * @class Distribution_Parameterized
      35             :  * A description of distribution by the distribution's mean value and a
      36             :  *  standard deviation.
      37             :  * Incomplete and unused yet. This class should be overridden by derived
      38             :  *  classes
      39             :  */
      40      303639 : class Distribution_Parameterized : public Distribution {
      41             : 
      42             : public:
      43             :     /// @brief Constructor for any temporary distribution parsed directly from the description
      44             :     Distribution_Parameterized(const std::string& description);
      45             : 
      46             :     /// @brief Constructor for standard normal distribution
      47             :     Distribution_Parameterized(const std::string& id, double mean, double deviation);
      48             : 
      49             :     /// @brief Constructor for normal distribution with cutoff
      50             :     Distribution_Parameterized(const std::string& id, double mean, double deviation, double min, double max);
      51             : 
      52             :     /// @brief Destructor
      53             :     virtual ~Distribution_Parameterized();
      54             : 
      55             :     /// @brief Overwrite by parsable distribution description
      56             :     void parse(const std::string& description, const bool hardFail);
      57             : 
      58             :     /** @brief Draw a sample of the distribution.
      59             :     *
      60             :     * A random sample is drawn according to the assigned probabilities.
      61             :     *
      62             :     * @param[in] which The random number generator to use; the static one will be used if 0 is passed
      63             :     * @return the drawn member
      64             :     */
      65             :     double sample(SumoRNG* which = 0) const;
      66             : 
      67             :     /// @brief Returns the maximum value of this distribution
      68             :     double getMax() const;
      69             : 
      70             :     /// @brief Returns the parameters of this distribution
      71             :     std::vector<double>& getParameter();
      72             : 
      73             :     /// @brief Returns the unmodifiable parameters of this distribution
      74             :     const std::vector<double>& getParameter() const;
      75             : 
      76             :     /// @brief check whether the distribution is valid
      77             :     bool isValid(std::string& error);
      78             : 
      79             :     /// @brief Returns the string representation of this distribution
      80             :     std::string toStr(std::streamsize accuracy) const;
      81             : 
      82             :     /// @brief validate input description
      83             :     static bool isValidDescription(const std::string& description);
      84             : 
      85             : private:
      86             :     /// @brief The distribution's parameters
      87             :     std::vector<double> myParameter;
      88             : };

Generated by: LCOV version 1.14