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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // The description of a distribution by a curve
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <cassert>
32 #include <sstream>
33 #include <iomanip>
34 #include <utils/common/StdDefs.h>
35 #include "Distribution_Points.h"
36 
37 
38 // ===========================================================================
39 // method definitions
40 // ===========================================================================
42  : Distribution(id) {}
43 
44 
46 
47 
48 double
50  assert(getVals().size() > 0);
51  return getVals().back();
52 }
53 
54 
55 std::string
56 Distribution_Points::toStr(std::streamsize accuracy) const {
57  std::stringstream oss;
58  oss << std::setprecision(accuracy);
59  const std::vector<double> vals = getVals();
60  for (int i = 0; i < (int)vals.size(); i++) {
61  if (i > 0) {
62  oss << ",";
63  }
64  oss << vals[i] << ":" << getProbs()[i];
65  }
66  return "points(" + oss.str() + ")";
67 }
68 
69 
70 /****************************************************************************/
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.