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