Path: blob/main/src/utils/distribution/Distribution_Points.cpp
169678 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file Distribution_Points.cpp14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @date Sept 200217///18// The description of a distribution by a curve19/****************************************************************************/20#include <config.h>2122#include <cassert>23#include <sstream>24#include <iomanip>25#include <utils/common/StdDefs.h>26#include "Distribution_Points.h"272829// ===========================================================================30// method definitions31// ===========================================================================32Distribution_Points::Distribution_Points(const std::string& id)33: Distribution(id) {}343536Distribution_Points::~Distribution_Points() {}373839double40Distribution_Points::getMax() const {41assert(getVals().size() > 0);42return getVals().back();43}444546std::string47Distribution_Points::toStr(std::streamsize accuracy) const {48std::stringstream oss;49oss << std::setprecision(accuracy);50const std::vector<double> vals = getVals();51for (int i = 0; i < (int)vals.size(); i++) {52if (i > 0) {53oss << ",";54}55oss << vals[i] << ":" << getProbs()[i];56}57return "points(" + oss.str() + ")";58}596061/****************************************************************************/626364