Skip to content

Commit

Permalink
fix sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
rewertvsp committed May 21, 2024
1 parent 8a3e138 commit 3a62d9d
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ else if (Math.abs(parcelDeliveryRoundingError.get()) >= 1.) {
}
}
// is the number of sampled tours for this carrier reached, we ignore the rest. If the carrier is not for waste collections or parcel delivery, we use all tours
else if (sampledToursForThisCarrier.get() == integratedToursForThisCarrier.get())
if (sampledToursForThisCarrier.get() == integratedToursForThisCarrier.get())
return;

integratedToursForThisCarrier.getAndIncrement();
if ((int) carrier.getAttributes().getAttribute("goodsType") == 140) {
if (goodsType == 140) {
integratedToursForWasteCollections.getAndIncrement();
}
if ((int) carrier.getAttributes().getAttribute("goodsType") == 150) {
if (goodsType == 150) {
integratedToursForParcelDelivery.getAndIncrement();
}
Plan plan = PopulationUtils.createPlan();
Expand Down Expand Up @@ -208,7 +208,7 @@ else if (sampledToursForThisCarrier.get() == integratedToursForThisCarrier.get()

newPerson.addPlan(plan);
PopulationUtils.putSubpopulation(newPerson, subpopulation);
newPerson.getAttributes().putAttribute("goodsType", carrier.getAttributes().getAttribute("goodsType"));
newPerson.getAttributes().putAttribute("goodsType", goodsType);

Id<Vehicle> vehicleId = scheduledTour.getVehicle().getId();

Expand All @@ -220,9 +220,10 @@ else if (sampledToursForThisCarrier.get() == integratedToursForThisCarrier.get()

});
});
if (sampledToursForWasteCollections != integratedToursForWasteCollections.get())
// because of rounding errors of each carrier, the number of integrated tours for waste collections and parcel delivery should differ at maximum by 1
if (Math.abs(sampledToursForWasteCollections - integratedToursForWasteCollections.get()) > 1)
throw new RuntimeException("The number of integrated tours for waste collections does not match the sampled tours");
if (sampledToursForParcelDelivery != integratedToursForParcelDelivery.get())
if (Math.abs(sampledToursForParcelDelivery - integratedToursForParcelDelivery.get()) > 1)
throw new RuntimeException("The number of integrated tours for parcel delivery does not match the sampled tours");
}

Expand Down

0 comments on commit 3a62d9d

Please sign in to comment.