Skip to content

Commit

Permalink
fix test and add setter
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhoerl committed Dec 5, 2024
1 parent 6c975cc commit ff48382
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ private void preparePopulation(Scenario scenario) {
Plan plan = factory.createPlan();
Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1));
start.setEndTime(5000);
start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 1800.);
start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 5000.);
AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 1800.0);
AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 5000.0);
plan.addActivity(start);
plan.addLeg(factory.createLeg("drt"));
plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2)));
Expand All @@ -295,8 +295,8 @@ private void preparePopulation(Scenario scenario) {
Plan plan = factory.createPlan();
Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1));
start.setEndTime(5000);
start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 900.);
start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 5005.);
AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 900.0);
AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 5005.0);
plan.addActivity(start);
plan.addLeg(factory.createLeg("drt"));
plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2)));
Expand All @@ -310,8 +310,8 @@ private void preparePopulation(Scenario scenario) {
Plan plan = factory.createPlan();
Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1));
start.setEndTime(5000);
start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 4000.);
start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 5000.);
AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 4000.0);
AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 5000.0);
plan.addActivity(start);
plan.addLeg(factory.createLeg("drt"));
plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2)));
Expand All @@ -325,8 +325,8 @@ private void preparePopulation(Scenario scenario) {
Plan plan = factory.createPlan();
Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1));
start.setEndTime(8000);
start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 4000.);
start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 11000.);
AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 4000.0);
AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 11000.0);
plan.addActivity(start);
plan.addLeg(factory.createLeg("drt"));
plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2)));
Expand All @@ -340,8 +340,8 @@ private void preparePopulation(Scenario scenario) {
Plan plan = factory.createPlan();
Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1));
start.setEndTime(6000.);
start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 4000.);
start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 6000.);
AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 4000.0);
AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 6000.0);
plan.addActivity(start);
plan.addLeg(factory.createLeg("drt"));
plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2)));
Expand All @@ -355,8 +355,8 @@ private void preparePopulation(Scenario scenario) {
Plan plan = factory.createPlan();
Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1));
start.setEndTime(6500.);
start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 4000.);
start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 6500.);
AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 4000.0);
AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 6500.0);
plan.addActivity(start);
plan.addLeg(factory.createLeg("drt"));
plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Optional;

import org.matsim.api.core.v01.population.Activity;
import org.matsim.api.core.v01.population.Leg;
import org.matsim.api.core.v01.population.PlanElement;
import org.matsim.contrib.drt.prebooking.logic.helpers.PopulationIterator;
Expand Down Expand Up @@ -63,6 +64,14 @@ static public void setPlannedDepartureTime(String mode, Trip trip, double planne
trip.getTripAttributes().putAttribute(getPlannedDepartureTimeAttribute(mode), plannedDepartureTime);
}

static public void setSubmissionTime(String mode, Activity originActivity, double submissionTime) {
originActivity.getAttributes().putAttribute(getSubmissionTimeAttribute(mode), submissionTime);
}

static public void setPlannedDepartureTime(String mode, Activity originActivity, double plannedDepartureTime) {
originActivity.getAttributes().putAttribute(getPlannedDepartureTimeAttribute(mode), plannedDepartureTime);
}

private final PrebookingQueue prebookingQueue;
private final PopulationIteratorFactory populationIteratorFactory;
private final TimeInterpretation timeInterpretation;
Expand Down

0 comments on commit ff48382

Please sign in to comment.