Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2010-2024 German Aerospace Center (DLR) and others. 4 : // activitygen module 5 : // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/) 6 : // This program and the accompanying materials are made available under the 7 : // terms of the Eclipse Public License 2.0 which is available at 8 : // https://www.eclipse.org/legal/epl-2.0/ 9 : // This Source Code may also be made available under the following Secondary 10 : // Licenses when the conditions for such availability set forth in the Eclipse 11 : // Public License 2.0 are satisfied: GNU General Public License, version 2 12 : // or later which is available at 13 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 14 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 15 : /****************************************************************************/ 16 : /// @file AGActivity.h 17 : /// @author Piotr Woznica 18 : /// @author Daniel Krajzewicz 19 : /// @author Walter Bamberger 20 : /// @author Michael Behrisch 21 : /// @date July 2010 22 : /// 23 : // Parent object for all activities. Derived classes generate trips for each 24 : // household. 25 : /****************************************************************************/ 26 : #pragma once 27 : #include <config.h> 28 : 29 : #include "AGTrip.h" 30 : #include <activitygen/city/AGDataAndStatistics.h> 31 : 32 : 33 : // =========================================================================== 34 : // class declarations 35 : // =========================================================================== 36 : class AGHousehold; 37 : 38 : 39 : // =========================================================================== 40 : // class definitions 41 : // =========================================================================== 42 : class AGActivity { 43 : public: 44 3012 : AGActivity(AGHousehold* hh, AGDataAndStatistics* das, std::list<AGTrip>* prevTrips, int prio) : 45 3012 : myHousehold(hh), 46 3012 : myStatData(das), 47 3012 : myPreviousTrips(prevTrips), 48 3012 : activityPriority(prio), 49 3012 : genDone(false), 50 3012 : timePerKm(das->speedTimePerKm), 51 3012 : carPreference(das->carPreference) {}; 52 : 53 : /// @brief empty destructor 54 1506 : virtual ~AGActivity() {} 55 : 56 : /** 57 : * returns whether the generation could have been well done 58 : */ 59 : bool isGenerated(); 60 : 61 : /** 62 : * main function called for trip generation 63 : * this function is overwritten in every child-class (every activity) 64 : */ 65 : virtual bool generateTrips() = 0; 66 : 67 : /** 68 : * determine the possible transportation means, what would be chosen: 69 : * 1 = foot 70 : * 2 = bus 71 : * 4 = car 72 : * any combination is possible by simply addition of these values 73 : * (ex. 7 means: 4+2+1 <=> foot, bus and car possible / 5 means: 4+1 <=> only foot and car are possible) 74 : */ 75 : int possibleTranspMean(AGPosition destination); 76 : 77 : /** 78 : * determine the possible means for a trip from one position to a destination. 79 : * whether CAR is necessary or not, BUS available or not... 80 : * 1 = by foot possible. 81 : * 2 = by bus possible. 82 : * 0 = by bus or foot NOT possible => only by car. 83 : * @NOTE: 4 is useless because it is always possible 84 : * @NOTE: 3 = 2 + 1 = means bus and foot possible. 85 : */ 86 : int availableTranspMeans(AGPosition from, AGPosition to); 87 : 88 : /** 89 : * evaluation of the needed time for going from one point to an other using the car 90 : */ 91 : int timeToDrive(AGPosition from, AGPosition to); 92 : 93 : /** 94 : * estimates the departure/arrival time given the departure location 95 : * the arrival location and the wished arrival/departure time 96 : */ 97 : int depHour(AGPosition from, AGPosition to, int arrival); 98 : int arrHour(AGPosition from, AGPosition to, int departure); 99 : 100 : /** 101 : * evaluates a random time between the given two time instants 102 : */ 103 : int randomTimeBetween(int begin, int end); 104 : 105 : std::list<AGTrip>& getPartialActivityTrips(); 106 : 107 : protected: 108 : AGHousehold* myHousehold; 109 : 110 : AGDataAndStatistics* myStatData; 111 : 112 : std::list<AGTrip>* myPreviousTrips; 113 : std::list<AGTrip> myPartialActivityTrips; 114 : int activityPriority; 115 : bool genDone; 116 : double timePerKm; 117 : /** 118 : * rate of taking the car instead of the bus because of personal preference 119 : */ 120 : double carPreference; 121 : 122 : };