Eclipse SUMO - Simulation of Urban MObility
FirstOrderLagModel.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-2019 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 /****************************************************************************/
15 // An engine model using a first order lag
16 /****************************************************************************/
17 
18 #include "FirstOrderLagModel.h"
20 #include "utils/common/StdDefs.h"
21 #include <algorithm>
22 
24  tau_s(0.5), dt_s(0.01) {
25  className = "FirstOrderLagModel";
27 }
29 
31  alpha = dt_s / (tau_s + dt_s);
32  oneMinusAlpha = 1 - alpha;
33 }
34 
35 double FirstOrderLagModel::getRealAcceleration(double speed_mps, double accel_mps2, double reqAccel_mps2, SUMOTime timeStep) {
36  UNUSED_PARAMETER(speed_mps);
37  UNUSED_PARAMETER(timeStep);
38  return std::min(
40  std::max(
42  alpha * reqAccel_mps2 + oneMinusAlpha * accel_mps2
43  )
44  );
45 }
46 
47 void FirstOrderLagModel::loadParameters(const ParMap& parameters) {
48  parseParameter(parameters, std::string(FOLM_PAR_TAU), tau_s);
49  parseParameter(parameters, std::string(FOLM_PAR_DT), dt_s);
51 }
52 
53 void FirstOrderLagModel::setParameter(const std::string parameter, const std::string& value) {
54  UNUSED_PARAMETER(parameter);
55  UNUSED_PARAMETER(value);
56 }
57 void FirstOrderLagModel::setParameter(const std::string parameter, double value) {
58  if (parameter == FOLM_PAR_TAU) {
59  tau_s = value;
60  }
61  if (parameter == FOLM_PAR_DT) {
62  dt_s = value;
63  }
65 }
66 void FirstOrderLagModel::setParameter(const std::string parameter, int value) {
67  UNUSED_PARAMETER(parameter);
68  UNUSED_PARAMETER(value);
69 }
virtual void loadParameters(const ParMap &parameters)
void parseParameter(const ParMap &parameters, std::string parameter, double &value)
#define FOLM_PAR_DT
Definition: CC_Const.h:81
virtual void setParameter(const std::string parameter, const std::string &value)
long long int SUMOTime
Definition: SUMOTime.h:35
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:32
virtual double getRealAcceleration(double speed_mps, double accel_mps2, double reqAccel_mps2, SUMOTime timeStep=0)
std::map< std::string, std::string > ParMap
#define FOLM_PAR_TAU
Definition: CC_Const.h:80