Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
Distribution_Parameterized.h
Go to the documentation of this file.
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/****************************************************************************/
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// ===========================================================================
40
41public:
44
46 Distribution_Parameterized(const std::string& description);
47
49 Distribution_Parameterized(const std::string& id, double mean, double deviation);
50
52 Distribution_Parameterized(const std::string& id, double mean, double deviation, double min, double max);
53
56
58 void parse(const std::string& description, const bool hardFail);
59
67 double sample(SumoRNG* which = nullptr) const;
68
70 double getMax() const;
71
73 double getMin() const;
74
76 inline double getParameter(const int index) const {
77 return myParameter[index];
78 }
79
81 void setParameter(const int index, const double value);
82
84 const std::string isValid() const;
85
86 bool isDummy() const {
87 return myParameter.empty();
88 }
89
90 bool isVariable() const {
91 return !myParameter.empty() && getMin() != getMax();
92 }
93
95 std::string toStr(std::streamsize accuracy) const;
96
98 static bool isValidDescription(const std::string& description, std::string& error);
99
100private:
102 std::vector<double> myParameter;
103};
void parse(const std::string &description, const bool hardFail)
Overwrite by parsable distribution description.
virtual ~Distribution_Parameterized()
Destructor.
double getMax() const
Returns the maximum value of this distribution.
double getMin() const
Returns the minimum value of this distribution.
Distribution_Parameterized()
Dummy Constructor for a default distribution.
double getParameter(const int index) const
Returns the nth parameter of this distribution.
void setParameter(const int index, const double value)
Set a parameter of this distribution.
std::string toStr(std::streamsize accuracy) const
Returns the string representation of this distribution.
static bool isValidDescription(const std::string &description, std::string &error)
validate input description
const std::string isValid() const
check whether the distribution is valid
std::vector< double > myParameter
The distribution's parameters.
double sample(SumoRNG *which=nullptr) const
Draw a sample of the distribution using the given RNG.