SUMO - Simulation of Urban MObility
Distribution_Points.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // The description of a distribution by a curve
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <cassert>
33 #include <sstream>
34 #include <iomanip>
35 #include <utils/common/StdDefs.h>
36 #include "Distribution_Points.h"
37 
38 
39 // ===========================================================================
40 // method definitions
41 // ===========================================================================
43  : Distribution(id) {}
44 
45 
47 
48 
49 double
51  assert(getVals().size() > 0);
52  return getVals().back();
53 }
54 
55 
56 std::string
57 Distribution_Points::toStr(std::streamsize accuracy) const {
58  std::stringstream oss;
59  oss << std::setprecision(accuracy);
60  const std::vector<double> vals = getVals();
61  for (int i = 0; i < (int)vals.size(); i++) {
62  if (i > 0) {
63  oss << ",";
64  }
65  oss << vals[i] << ":" << getProbs()[i];
66  }
67  return "points(" + oss.str() + ")";
68 }
69 
70 
71 /****************************************************************************/
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.