@@ -40,67 +40,35 @@ namespace abm
4040 * @brief A trip describes a change of Location from one Location to another Location.
4141 */
4242struct Trip {
43- // TODO: Origin is currently not used for the trips. Should we delete it then?
4443 PersonId person_id; /* *< Person that makes the trip and corresponds to the index into the structure m_persons from
4544 Model, where all Person%s are saved.*/
46- TimePoint time ; // /< Daytime at which a Person changes the Location.
45+ TimePoint trip_time ; // /< Daytime at which a Person changes the Location.
4746 LocationId destination; // /< Location where the Person changes to.
4847 int destination_model_id; // /< Model id of destination Location.
49- LocationId origin; // /< Location where the Person starts the Trip.
50- int origin_model_id; // /< Model id of origin Location.
48+ TransportMode trip_mode; // /< Mode of transportation. See TransportMode for all possible modes of transportation.
5149 std::vector<uint32_t > cells; /* *< If destination consists of different Cell%s, this gives the index of the
5250 Cell%s the Person changes to.*/
53- TransportMode
54- trip_mode; // /< Mode of transportation. 1:Bike, 2:Car (Driver), 3:Car (Co-Driver)), 4:Public Transport, 5:Walking, 6:Other/Unknown
55- LocationType destination_type; // /< Type of destination Location.
5651
5752 /* *
5853 * @brief Construct a new Trip.
5954 * @param[in] id ID of the Person that makes the Trip.
60- * @param[in] time_new Time at which a Person changes the Location this currently cant be set for s specific day just a timepoint in a day.
55+ * @param[in] time Time at which a Person changes the Location this currently cant be set for s specific day just a timepoint in a day.
6156 * @param[in] destination Location where the Person changes to.
6257 * @param[in] destination_model_id Model the Person changes to.
6358 * @param[in] origin Location where the person starts the Trip.
6459 * @param[in] origin_model_id Model the Person starts the Trip.
6560 * @param[in] input_cells The index of the Cell%s the Person changes to.
6661 */
67- Trip (PersonId id, TimePoint time_new, LocationId dest, int dest_model_id, LocationId orig, int orig_model_id,
68- TransportMode mode_of_transport, LocationType type_of_activity, const std::vector<uint32_t >& input_cells = {})
62+ Trip (PersonId id, const TimePoint time, const LocationId dest, const int dest_model_id = 0 ,
63+ const TransportMode mode_of_transport = mio::abm::TransportMode::Unknown,
64+ const std::vector<uint32_t >& input_cells = {})
6965 : person_id(id)
70- , time (mio::abm::TimePoint(time_new .time_since_midnight().seconds()))
66+ , trip_time (mio::abm::TimePoint(time .time_since_midnight().seconds()))
7167 , destination(dest)
7268 , destination_model_id(dest_model_id)
73- , origin(orig)
74- , origin_model_id(orig_model_id)
75- , cells(input_cells)
7669 , trip_mode(mode_of_transport)
77- , destination_type(type_of_activity)
78- {
79- }
80-
81- Trip (PersonId id, TimePoint time_new, LocationId dest, LocationId orig, TransportMode mode_of_transport,
82- LocationType type_of_activity, const std::vector<uint32_t >& input_cells = {})
83- : person_id(id)
84- , time(mio::abm::TimePoint(time_new.time_since_midnight().seconds()))
85- , destination(dest)
86- , destination_model_id(0 )
87- , origin(orig)
88- , origin_model_id(0 )
8970 , cells(input_cells)
90- , trip_mode(mode_of_transport)
91- , destination_type(type_of_activity)
92- {
93- }
9471
95- Trip (PersonId id, TimePoint time_new, LocationId dest, LocationId orig, LocationType type_of_activity,
96- const std::vector<uint32_t >& input_cells = {})
97- : Trip(id, time_new, dest, orig, mio::abm::TransportMode::Unknown, type_of_activity, input_cells)
98- {
99- }
100-
101- Trip (PersonId id, TimePoint time_new, LocationId dest, LocationType type_of_activity,
102- const std::vector<uint32_t >& input_cells = {})
103- : Trip(id, time_new, dest, dest, mio::abm::TransportMode::Unknown, type_of_activity, input_cells)
10472 {
10573 }
10674
@@ -109,17 +77,18 @@ struct Trip {
10977 */
11078 bool operator ==(const Trip& other) const
11179 {
112- return (person_id == other.person_id ) && (time == other.time ) && (destination == other.destination ) &&
113- (origin == other.origin );
80+ return (person_id == other.person_id ) && (trip_time == other.trip_time ) && (destination == other.destination ) &&
81+ (destination_model_id == other.destination_model_id ) && (trip_mode == other. trip_mode );
11482 }
11583
11684 auto default_serialize ()
11785 {
11886 return Members (" Trip" )
11987 .add (" person_id" , person_id)
120- .add (" time " , time )
88+ .add (" trip_time " , trip_time )
12189 .add (" destination" , destination)
122- .add (" origin" , origin);
90+ .add (" model_id" , destination_model_id)
91+ .add (" trip_mode" , trip_mode);
12392 }
12493};
12594
@@ -132,31 +101,26 @@ class TripList
132101 /* *
133102 * @brief Construct empty TripList.
134103 */
135- TripList ();
104+ TripList () = default ;
136105
137106 /* *
138107 * @brief Get the next Trip.
139108 * @param weekend Whether the Trip%s during the week or on the weekend are used.
140109 */
141- const Trip& get_next_trip (bool weekend ) const ;
110+ const Trip& get_next_trip () const ;
142111
143112 /* *
144- * @brief Get the time at which the next Trip will happen.
113+ * @brief Get the trip_time at which the next Trip will happen.
145114 * @param weekend Whether the Trip%s during the week or on the weekend are used.
146115 */
147- TimePoint get_next_trip_time (bool weekend ) const ;
116+ TimePoint get_next_trip_time () const ;
148117
149118 /* *
150- * @brief Add a Trip to the trip list.
151- * @param[in] trip The Trip to be added.
119+ * @brief Adds Trips to the trip list.
120+ * @param[in] trips The Trips to be added.
152121 * @param[in] weekend If the Trip is made on a weekend day.
153122 */
154- void add_trip (Trip trip, bool weekend = false );
155-
156- /* *
157- * @brief Use the same TripList for weekend and weekday.
158- */
159- void use_weekday_trips_on_weekend ();
123+ void add_trips (std::vector<Trip> trip);
160124
161125 /* *
162126 * @brief Increment the current index to select the next Trip.
@@ -178,9 +142,9 @@ class TripList
178142 * @brief Get the length of the TripList.
179143 * @param weekend Whether the Trip%s during the week or on the weekend are used.
180144 */
181- size_t num_trips (bool weekend = false ) const
145+ size_t num_trips () const
182146 {
183- return weekend ? m_trips_weekend. size () : m_trips_weekday .size ();
147+ return m_trips .size ();
184148 }
185149
186150 /* *
@@ -194,16 +158,12 @@ class TripList
194158 // / This method is used by the default serialization feature.
195159 auto default_serialize ()
196160 {
197- return Members (" TestingScheme" )
198- .add (" trips_weekday" , m_trips_weekday)
199- .add (" trips_weekend" , m_trips_weekend)
200- .add (" index" , m_current_index);
161+ return Members (" TestingScheme" ).add (" trips" , m_trips).add (" index" , m_current_index);
201162 }
202163
203164private:
204- std::vector<Trip> m_trips_weekday; // /< The list of Trip%s a Person makes on a weekday.
205- std::vector<Trip> m_trips_weekend; // /< The list of Trip%s a Person makes on a weekend day.
206- uint32_t m_current_index; // /< The index of the Trip a Person makes next.
165+ std::vector<Trip> m_trips; // /< The list of Trip%s a Person makes on a weekday.
166+ uint32_t m_current_index = 0 ; // /< The index of the Trip a Person makes next.
207167};
208168
209169} // namespace abm
@@ -213,7 +173,7 @@ template <>
213173struct DefaultFactory <abm::Trip> {
214174 static abm::Trip create ()
215175 {
216- return abm::Trip{abm::PersonId{}, abm::TimePoint{}, abm::LocationId{}, abm::LocationType{} };
176+ return abm::Trip{abm::PersonId{}, abm::TimePoint{}, abm::LocationId{}};
217177 }
218178};
219179
0 commit comments