LCOV - code coverage report
Current view: top level - src/microsim/cfmodels - MSCFModel_KraussX.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 84.2 % 19 16
Test Date: 2024-12-21 15:45:41 Functions: 83.3 % 6 5

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    MSCFModel_KraussX.cpp
      15              : /// @author  Tobias Mayer
      16              : /// @author  Daniel Krajzewicz
      17              : /// @author  Jakob Erdmann
      18              : /// @author  Michael Behrisch
      19              : /// @author  Laura Bieker
      20              : /// @date    Mon, 04 Aug 2009
      21              : ///
      22              : // Krauss car-following model, changing accel and speed by slope
      23              : /****************************************************************************/
      24              : #include <config.h>
      25              : 
      26              : #include <microsim/lcmodels/MSAbstractLaneChangeModel.h>
      27              : #include <microsim/MSVehicle.h>
      28              : #include <microsim/MSNet.h>
      29              : #include "MSCFModel_KraussX.h"
      30              : 
      31              : 
      32              : #define OVERBRAKING_THRESHOLD -3
      33              : 
      34              : // ===========================================================================
      35              : // method definitions
      36              : // ===========================================================================
      37           12 : MSCFModel_KraussX::MSCFModel_KraussX(const MSVehicleType* vtype):
      38              :     MSCFModel_Krauss(vtype),
      39           12 :     myTmp1(vtype->getParameter().getCFParam(SUMO_ATTR_TMP1, 0.0)),
      40           12 :     myTmp2(vtype->getParameter().getCFParam(SUMO_ATTR_TMP2, 0.0)) {
      41           12 : }
      42              : 
      43              : 
      44           24 : MSCFModel_KraussX::~MSCFModel_KraussX() {}
      45              : 
      46              : 
      47              : MSCFModel*
      48            0 : MSCFModel_KraussX::duplicate(const MSVehicleType* vtype) const {
      49            0 :     return new MSCFModel_KraussX(vtype);
      50              : }
      51              : 
      52              : 
      53              : double
      54      3708488 : MSCFModel_KraussX::patchSpeedBeforeLC(const MSVehicle* veh, double vMin, double vMax) const {
      55      3708488 :     return dawdleX(veh->getSpeed(), vMin, vMax, veh->getRNG());
      56              : }
      57              : 
      58              : 
      59              : double
      60      3708488 : MSCFModel_KraussX::dawdleX(double vOld, double vMin, double vMax, SumoRNG* rng) const {
      61              :     double speed = vMax;
      62      3708488 :     if (!MSGlobals::gSemiImplicitEulerUpdate) {
      63              :         // in case of the ballistic update, negative speeds indicate
      64              :         // a desired stop before the completion of the next timestep.
      65              :         // We do not allow dawdling to overwrite this indication
      66            0 :         if (speed < 0) {
      67              :             return speed;
      68              :         }
      69              :     }
      70              :     // extra slow to start
      71      3708488 :     if (vOld < myAccel) {
      72       162560 :         speed -= ACCEL2SPEED(myTmp1 * myAccel);
      73              :     }
      74      3708488 :     const double random = RandHelper::rand(rng);
      75      3708488 :     speed -= ACCEL2SPEED(myDawdle * myAccel * random);
      76              :     // overbraking
      77      3708488 :     if (vOld > vMax) {
      78       296528 :         speed -= ACCEL2SPEED(myTmp2 * myAccel * random);
      79              :         //std::cout << " vMin=" << vMin << " vMax=" << vMax << "speed=" << speed << " d1=" << ACCEL2SPEED(myDawdle * myAccel * random) << " d2=" << ACCEL2SPEED(myTmp2 * myAccel * random) << " unexpectedDecel=" << (speed < vMin) << "\n";
      80       296528 :         if (MSGlobals::gSemiImplicitEulerUpdate) {
      81              :             speed = MAX2(0.0, speed);
      82              :         }
      83              :     }
      84              :     speed = MAX2(vMin, speed);
      85              :     return speed;
      86              : }
      87              : 
      88              : 
      89              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1