Jacob,
Thanks for the reply. I've changed the from.get call to from.getCFParam as
you have suggested.
case SUMO_TAG_CF_GM:
vtype->myCarFollowModel = new MSCFModel_GM(vtype,
from.getCFParam(SUMO_ATTR_GM_Alpha,1.),
from.getCFParam(SUMO_ATTR_GM_M, 1.),
from.getCFParam(SUMO_ATTR_GM_L, 1.));
break;
But I am still having rouble with the second error "no overloaded function
takes 4 arguments". at MSVehicleType.cpp
Even though I've declared my parameters in both .h and .cpp file, I am
still getting the same error.
In cpp file, I have wrote the following
MSCFModel_GM::MSCFModel_GM(const MSVehicleType* vtype) :
MSCFModel(vtype),
myalpha(vtype->getParameter().getCFParam(SUMO_ATTR_GM_Alpha, 1.0)), //
This is the sensitivity parameter, default value is set to 1
myM(vtype->getParameter().getCFParam(SUMO_ATTR_GM_M, -2.0)), // This is
the speed exponent, takes values between -2 to +2
myL(vtype->getParameter().getCFParam(SUMO_ATTR_GM_L, 4.0)) { // This is
the distance headway exponent, takes values between +4 to -1
}
MSCFModel_GM::~MSCFModel_GM() {}
and in .h file, I have declared the myalpha , myM and myL as the following
private:
/// @name model parameter
/// @{
/// @brief General Motors sensitivity
double myalpha;
/// @brief General Motors speed exponent
double myM;
/// @brief General Motors Distance Headway Exponent
double myL;
/// @}
I would really appreciate the help.
Best Regards,
Sadullah.
On Sat, Oct 23, 2021 at 11:56 AM Jakob Erdmann <[email protected]>
wrote:
> Hello,
>
> - the call from.get is obsolete and from.getCFParam is correct
> (documentation has been updated).
> - the make the constructor call 'new MSCFModel_GM( ... )' with 4
> parameters work, you have to define a corresponding constructor in
> MSCFModel_GM.h and .cpp
>
> regards,
> Jakob
>
>
> Am Sa., 23. Okt. 2021 um 02:25 Uhr schrieb S G <[email protected]>:
>
>> Greetings,
>>
>> I am trying to implement a car-following model (General Motors model) to
>> SUMO. I've successfully downloaded the developer version and compiled
>> (built) the code on windows.
>>
>> However, I am having some trouble with the implementation of a
>> car-following model. I've followed and completed every step in the guide at
>> the documentation (
>> https://sumo.dlr.de/docs/Developer/How_To/Car-Following_Model.html). My
>> main issue occurs at the "MSVehicleType.cpp" when I try to compile again.
>> According to the documentation, I need to add the following to the
>> "MSVehicleType.cpp" ;
>>
>> case SUMO_TAG_CF_GM:
>> model = new MSCFModel_GM(vtype,
>> from.get(SUMO_ATTR_GM_Alpha,1.),
>> from.get(SUMO_ATTR_GM_M, 1.),
>> from.get(SUMO_ATTR_GM_L, 1.));
>> break ;
>>
>> However, when I try to compile the code again, the "from.get" command
>> does not work and build fails around step 390-400 with the following errors;
>>
>> - 'get': is not a member of 'SUMOVTypeParameter'7
>> - model : undeclared identifier
>>
>> I have tried the following as well, which is the current format for the
>> car-following models already existing inside the MSVehicleType.cpp
>>
>> case SUMO_TAG_CF_GM:
>> vtype->myCarFollowModel = new MSCFModel_GM(vtype,
>> from.getCFParam(SUMO_ATTR_GM_Alpha,1.),
>> from.getCFParam(SUMO_ATTR_GM_M, 1.),
>> from.getCFParam(SUMO_ATTR_GM_L, 1.));
>> break ;
>>
>> When I compile this I get the error that "no overloaded function takes 4
>> arguments.
>>
>> Another version I've tried
>>
>> case SUMO_TAG_CF_GM:
>> vtype->myCarFollowModel = new MSCFModel_GM(vtype)
>> break ;
>>
>> At this version, compile procedure successfully runs to the step 740 but
>> fails with an error message as follows :
>>
>> [740/1025]
>> C:\PROGRA~2\MICROS~3\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe
>> /nologo /TP -DFLOAT_MATH_FUNCTIONS
>> -IC:\SUMOLibraries\googletest-1.10.0\include -Isrc -I..\..\..\src
>> -IC:\SUMOLibraries\xerces-c-3.2.3\include
>> -IC:\SUMOLibraries\proj-7.2.0\include -IC:\SUMOLibraries\fox-1.6.57\include
>> -IC:\SUMOLibraries\freetype-2.10.4\include\freetype2
>> -IC:\SUMOLibraries\3rdPartyLibs\zlib-1.2.11\include
>> -IC:\SUMOLibraries\gdal-3.2.1\include
>> -IC:\SUMOLibraries\FFMPEG-4.2.0\include
>> -IC:\SUMOLibraries\OSG-3.6.5\include -IC:\SUMOLibraries\gl2ps-1.4.0\include
>> -IC:\SUMOLibraries\eigen-3.3.9 /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MP /bigobj
>> /MD /O2 /Ob2 /DNDEBUG /showIncludes
>> /Fosrc\utils\gui\images\CMakeFiles\utils_gui_images.dir\GUIIconSubSys.cpp.obj
>> /Fdsrc\utils\gui\images\CMakeFiles\utils_gui_images.dir\utils_gui_images.pdb
>> /FS -c ..\..\..\src\utils\gui\images\GUIIconSubSys.cpp
>> [741/1025] cmd.exe /C "cd /D
>> C:\Users\l\source\repos\sumo\out\build\x64-Release\src\libsumo &&
>> "C:\Program Files (x86)\Microsoft Visual
>> Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
>> -E make_directory C:/Users/source/repos/sumo/tools/libsumo
>> C:/Users//source/repos/sumo/out/build/x64-Release/src/libsumo &&
>> "C:\Program Files (x86)\Microsoft Visual
>> Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
>> -E env SWIG_LIB=C:/SUMOLibraries/swigwin-4.0.2/Lib
>> C:/SUMOLibraries/swigwin-4.0.2/swig.exe -python -keyword -outdir
>> C:/Users/source/repos/sumo/tools/libsumo -c++ -interface _libsumo
>> -IC:/SUMOLibraries/googletest-1.10.0/include
>> -IC:/SUMOLibraries/xerces-c-3.2.3/include
>> -IC:/SUMOLibraries/proj-7.2.0/include -IC:/SUMOLibraries/fox-1.6.57/include
>> -IC:/SUMOLibraries/freetype-2.10.4/include/freetype2
>> -IC:/SUMOLibraries/3rdPartyLibs/zlib-1.2.11/include
>> -IC:/SUMOLibraries/gdal-3.2.1/include
>> -IC:/SUMOLibraries/FFMPEG-4.2.0/include
>> -IC:/SUMOLibraries/OSG-3.6.5/include -IC:/SUMOLibraries/gl2ps-1.4.0/include
>> -IC:/SUMOLibraries/eigen-3.3.9
>> -IC:/Users/source/repos/sumo/out/build/x64-Release/src
>> -IC:/Users/source/repos/sumo/src -IC:/Users/anaconda3/include -o
>> C:/Users/source/repos/sumo/out/build/x64-Release/src/libsumo/libsumoPYTHON_wrap.cxx
>> C:/Users/source/repos/sumo/src/libsumo/libsumo.i"
>> ninja: build stopped: subcommand failed.
>>
>>
>> Another common error I get at is the following:
>>
>> Severity Code Description Project File Line Suppression State Detail
>> Description
>> Error (active) E0289 no instance of constructor
>> "MSCFModel_GM::MSCFModel_GM" matches the argument list microsim.lib
>> (src\microsim\microsim.lib) - x64-Release
>> C:\Users\sadul\source\repos\sumo\src\microsim\MSVehicleType.cpp 356
>> argument types are: (MSVehicleType *, double, double, double)
>>
>>
>> Sorry for the long e-mail but I would really appreciate any help. You can
>> find the code files in the attachment as well.
>>
>> Best Regards,
>> Sadullah.
>> _______________________________________________
>> sumo-user mailing list
>> [email protected]
>> To unsubscribe from this list, visit
>> https://www.eclipse.org/mailman/listinfo/sumo-user
>>
> _______________________________________________
> sumo-user mailing list
> [email protected]
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/sumo-user
>
/****************************************************************************/
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
// Copyright (C) 2001-2021 German Aerospace Center (DLR) and others.
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0/
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License 2.0 are satisfied: GNU General Public License, version 2
// or later which is available at
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
/****************************************************************************/
/// @file MSCFModel_GM.h
/// @author Sadullah Göncü
///
///
///
/// @date Friday, 22 October 2021
///
// The original General Motors (1958) car-following model and parameter
/****************************************************************************/
#pragma once
#include <config.h>
#include "MSCFModel.h"
#include <utils/xml/SUMOXMLDefinitions.h>
// ===========================================================================
// class definitions
// ===========================================================================
/** @class MSCFModel_GM
* @brief The General Motors (1958) car-following model and parameter
* @see MSCFModel
*/
class MSCFModel_GM : public MSCFModel {
public:
/** @brief Constructor
* @param[in] vtype the type for which this model is built and also the
parameter object to configure this model
*/
MSCFModel_GM(const MSVehicleType* vtype);
/// @brief Destructor
~MSCFModel_GM();
/// @name Implementations of the MSCFModel interface
/// @{
/// @brief apply dawdling
double finalizeSpeed(MSVehicle* const veh, double vPos) const;
/** @brief Computes the vehicle's safe speed (no dawdling)
* @param[in] veh The vehicle (EGO)
* @param[in] speed The vehicle's speed
* @param[in] gap2pred The (netto) distance to the LEADER
* @param[in] predSpeed The speed of LEADER
* @return EGO's safe speed
* @see MSCFModel::ffeV
*/
double followSpeed(const MSVehicle* const veh, double speed, double
gap2pred, double predSpeed, double predMaxDecel, const MSVehicle* const pred =
0) const;
/** @brief Computes the vehicle's safe speed for approaching a non-moving
obstacle (no dawdling)
* @param[in] veh The vehicle (EGO)
* @param[in] gap2pred The (netto) distance to the the obstacle
* @return EGO's safe speed for approaching a non-moving obstacle
* @see MSCFModel::ffeS
* @todo generic Interface, models can call for the values they need
*/
virtual double stopSpeed(const MSVehicle* const veh, const double speed,
double gap2pred, double decel) const;
/** @brief Returns the model's name
* @return The model's name
* @see MSCFModel::getModelName
*/
virtual int getModelID() const {
return SUMO_TAG_CF_GM ;
}
private:
class VehicleVariables : public MSCFModel::VehicleVariables {
public:
double rand;
};
/** @brief Returns the "safe" velocity
* @param[in] gap2pred The (netto) distance to the LEADER
* @param[in] predSpeed The LEADER's speed
* @return the safe velocity
*/
double _v(const MSVehicle* const veh, double speed, double vfree, double
gap, double predSpeed) const;
private:
/// @name model parameter
/// @{
/// @brief General Motors sensitivity
double myalpha;
/// @brief General Motors speed exponent
double myM;
/// @brief General Motors Distance Headway Exponent
double myL;
/// @}
/// @name Setter methods
/// @{
/** @brief Sets a new value for maximum deceleration [m/s^2]
* @param[in] accel The new deceleration in m/s^2
*/
void setMaxDecel(double decel) {
myDecel = decel;
myTauDecel = myDecel * myHeadwayTime;
}
/** @brief Sets a new value for desired headway [s]
* @param[in] headwayTime The new desired headway (in s)
*/
void setHeadwayTime(double headwayTime) {
myHeadwayTime = headwayTime;
myTauDecel = myDecel * headwayTime;
}
/// @}
/** @brief Duplicates the car-following model
* @param[in] vtype The vehicle type this model belongs to (1:1)
* @return A duplicate of this car-following model
*/
virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
MSCFModel::VehicleVariables* createVehicleVariables() const;
protected:
/// @brief The precomputed value for myDecel*myTau
double myTauDecel;
};
/****************************************************************************/
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
// Copyright (C) 2001-2021 German Aerospace Center (DLR) and others.
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0/
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License 2.0 are satisfied: GNU General Public License, version 2
// or later which is available at
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
/****************************************************************************/
/// @file MSCFModel_GM.cpp
/// @author Sadullah Göncü
/// @author
/// @author
/// @author
/// @author
/// @date Friday, 22 October 2021
///
// The original General Motors (1958) car-following model and parameter
/****************************************************************************/
#include <config.h>
#include <microsim/MSVehicle.h>
#include <microsim/MSLane.h>
#include "MSCFModel_GM.h"
#include <microsim/lcmodels/MSAbstractLaneChangeModel.h>
#include <utils/common/RandHelper.h>
#include <microsim/MSGlobals.h>
// ===========================================================================
// DEBUG constants
// ===========================================================================
//#define DEBUG_COND (veh->getID()=="disabled")
// ===========================================================================
// method definitions
// ===========================================================================
MSCFModel_GM::MSCFModel_GM(const MSVehicleType* vtype) :
MSCFModel(vtype),
myalpha(vtype->getParameter().getCFParam(SUMO_ATTR_GM_Alpha, 1.0)), // This
is the sensitivity parameter, default value is set to 1
myM(vtype->getParameter().getCFParam(SUMO_ATTR_GM_M, -2.0)), // This is the
speed exponent, takes values between -2 to +2
myL(vtype->getParameter().getCFParam(SUMO_ATTR_GM_L, 4.0)) { // This is the
distance headway exponent, takes values between +4 to -1
}
MSCFModel_GM::~MSCFModel_GM() {}
double
MSCFModel_GM::finalizeSpeed(MSVehicle* const veh, double vPos) const {
const double vNext = MSCFModel::finalizeSpeed(veh, vPos);
VehicleVariables* vars = (VehicleVariables*)veh->getCarFollowVariables();
vars->rand = RandHelper::rand(veh->getRNG());
return vNext;
}
double
MSCFModel_GM::followSpeed(const MSVehicle* const veh, double speed, double gap,
double predSpeed, double /*predMaxDecel*/, const MSVehicle* const /*pred*/)
const {
return MIN2(_v(veh, speed, maxNextSpeed(speed, veh), gap, predSpeed),
maxNextSpeed(speed, veh));
}
double
MSCFModel_GM::stopSpeed(const MSVehicle* const veh, const double speed, double
gap, double /*decel*/) const {
return MIN2(_v(veh, speed, maxNextSpeed(speed, veh), gap, 0),
maxNextSpeed(speed, veh));
}
MSCFModel::VehicleVariables*
MSCFModel_GM::createVehicleVariables() const {
VehicleVariables* ret = new VehicleVariables();
/// XXX should use egoVehicle->getRNG()
ret->rand = RandHelper::rand();
return ret;
}
double
MSCFModel_GM::_v(const MSVehicle* const veh, double speed, double vfree, double
gap, double predSpeed) const {
if (predSpeed == 0 && gap < 0.01) {
return 0;
}
// !!! in the following, the prior step is not considered!!!
double GM_acc = MAX2((double)(myalpha * pow(predSpeed, myM) / pow(gap,
myL)) * (speed - predSpeed), (double)0);
double vsafe = (double)(speed + ACCEL2SPEED(GM_acc));
double v = MAX2((double)0, MIN2(vfree, vsafe));
return v;
}
MSCFModel*
MSCFModel_GM::duplicate(const MSVehicleType* vtype) const {
return new MSCFModel_GM(vtype);
}
/****************************************************************************/
_______________________________________________
sumo-user mailing list
[email protected]
To unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user