SUMO - Simulation of Urban MObility
Distribution_Points.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // The description of a distribution by a curve
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <cassert>
26 #include <sstream>
27 #include <iomanip>
28 #include <utils/common/StdDefs.h>
29 #include "Distribution_Points.h"
30 
31 
32 // ===========================================================================
33 // method definitions
34 // ===========================================================================
36  : Distribution(id) {}
37 
38 
40 
41 
42 double
44  assert(getVals().size() > 0);
45  return getVals().back();
46 }
47 
48 
49 std::string
50 Distribution_Points::toStr(std::streamsize accuracy) const {
51  std::stringstream oss;
52  oss << std::setprecision(accuracy);
53  const std::vector<double> vals = getVals();
54  for (int i = 0; i < (int)vals.size(); i++) {
55  if (i > 0) {
56  oss << ",";
57  }
58  oss << vals[i] << ":" << getProbs()[i];
59  }
60  return "points(" + oss.str() + ")";
61 }
62 
63 
64 /****************************************************************************/
const std::vector< double > & getVals() const
Returns the members of the distribution.
std::string toStr(std::streamsize accuracy) const
Returns the string representation of this distribution.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
virtual ~Distribution_Points()
Destructor.
Distribution_Points(const std::string &id)
Constructor.
double getMax() const
Returns the maximum value of this distribution.