Skip to content

Commit

Permalink
update attraction models
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Oct 26, 2024
1 parent 4a21578 commit c609ce9
Show file tree
Hide file tree
Showing 4 changed files with 5,360 additions and 4,275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,11 @@ public Integer call() throws Exception {
}

// Upper bounds for attraction
double workIQR = work.getPercentile(75) - work.getPercentile(25);
double otherIQR = other.getPercentile(75) - other.getPercentile(25);
double workUpper = work.getPercentile(99.99);
double otherUpper = other.getPercentile(99.99);

double workUpper = work.getPercentile(75) + 1.5 * workIQR;
double otherUpper = other.getPercentile(75) + 1.5 * otherIQR;

double workLower = Math.max(Math.max(work.getPercentile(1), 0.1), work.getPercentile(25) - 1.5 * workIQR);
double otherLower = Math.max(Math.max(other.getPercentile(1), 0.1), other.getPercentile(25) - 1.5 * otherIQR);

log.info("Work IQR: {} Upper: {} Lower: {}", workIQR, workUpper, workLower);
log.info("Other IQR: {} Upper: {} Lower: {}", otherIQR, otherUpper, otherLower);
log.info("Work upper bound: {}", workUpper);
log.info("Other upper bound: {}", otherUpper);

ActivityFacilities facilities = FacilitiesUtils.createActivityFacilities();

Expand All @@ -167,10 +161,10 @@ public Integer call() throws Exception {

// Filter outliers from the attraction
facility.getAttributes().putAttribute(Attributes.ATTRACTION_WORK,
round(Math.min(Math.max(h.attractionWork, workLower), workUpper))
round(Math.min(Math.max(h.attractionWork, 5), workUpper))
);
facility.getAttributes().putAttribute(Attributes.ATTRACTION_OTHER,
round(Math.min(Math.max(h.attractionOther, otherLower), otherUpper))
round(Math.min(Math.max(h.attractionOther, 5), otherUpper))
);

if (zones != null) {
Expand Down Expand Up @@ -220,17 +214,15 @@ private Holder processFeature(SimpleFeature ft, Network network) {
}
}

double area = (double) ft.getAttribute("area");

List<Map.Entry<Id<Link>, Long>> counts = map.entrySet().stream().sorted(Map.Entry.comparingByValue())
.toList();

// The "main" link of the facility
Id<Link> link = counts.get(counts.size() - 1).getKey();

Holder holder = new Holder(link, activities, new ArrayList<>(),
area * FacilityAttractionModelWork.INSTANCE.predict(features, null),
area * FacilityAttractionModelOther.INSTANCE.predict(features, null)
FacilityAttractionModelWork.INSTANCE.predict(features, null),
FacilityAttractionModelOther.INSTANCE.predict(features, null)
);

// Search for the original drawn coordinate of the associated link
Expand Down
Loading

0 comments on commit c609ce9

Please sign in to comment.