Skip to content

Commit

Permalink
activity analysis
Browse files Browse the repository at this point in the history
sebhoerl committed Jan 26, 2025
1 parent 6aac1a6 commit 8b5c351
Showing 4 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.eqasim.core.analysis.activities;

import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.population.Person;
import org.matsim.facilities.ActivityFacility;

public class ActivityItem {
public Id<Person> personId;
@@ -11,15 +13,19 @@ public class ActivityItem {
public double endTime;
public double x;
public double y;
public Id<ActivityFacility> facilityId;
public Id<Link> linkId;

public ActivityItem(Id<Person> personId, int activityIndex, String purpose, double startTime, double endTime,
double x, double y) {
double x, double y, Id<ActivityFacility> facilityId, Id<Link> linkId) {
this.personId = personId;
this.activityIndex = activityIndex;
this.purpose = purpose;
this.startTime = startTime;
this.endTime = endTime;
this.x = x;
this.y = y;
this.facilityId = facilityId;
this.linkId = linkId;
}
}
Original file line number Diff line number Diff line change
@@ -48,7 +48,8 @@ public void handleEvent(ActivityStartEvent event) {

// this is not the first one
ActivityItem activity = new ActivityItem(event.getPersonId(), personActivityIndex, event.getActType(),
event.getTime(), Double.POSITIVE_INFINITY, event.getCoord().getX(), event.getCoord().getY());
event.getTime(), Double.POSITIVE_INFINITY, event.getCoord().getX(), event.getCoord().getY(),
event.getFacilityId(), event.getLinkId());

activities.add(activity);
ongoing.put(event.getPersonId(), activity);
@@ -67,10 +68,11 @@ public void handleEvent(ActivityEndEvent event) {
// can happen for BeforeVrpSchedule activities of DRT vehicles
return;
}

// this is the first one
activity = new ActivityItem(event.getPersonId(), 0, event.getActType(), Double.NEGATIVE_INFINITY,
event.getTime(), event.getCoord().getX(), event.getCoord().getY());
event.getTime(), event.getCoord().getX(), event.getCoord().getY(), event.getFacilityId(),
event.getLinkId());

Verify.verify(activityIndex.put(event.getPersonId(), 0) == null);

Original file line number Diff line number Diff line change
@@ -104,7 +104,8 @@ public Collection<ActivityItem> readActivities(Population population) {
}

activityItems.add(new ActivityItem(person.getId(), personActivityIndex, activity.getType(),
startTime, endTime, location.getX(), location.getY()));
startTime, endTime, location.getX(), location.getY(), activity.getFacilityId(),
activity.getLinkId()));

personActivityIndex++;
}
Original file line number Diff line number Diff line change
@@ -43,6 +43,8 @@ private String formatHeader() {
"end_time", //
"x", //
"y", //
"facility_id", //
"link_id", //
});
}

@@ -55,6 +57,8 @@ private String formatActivity(ActivityItem activity) {
String.valueOf(activity.endTime), //
String.valueOf(activity.x), //
String.valueOf(activity.y), //
activity.facilityId.toString(), //
activity.linkId.toString(), //
});
}
}

0 comments on commit 8b5c351

Please sign in to comment.