diff --git a/src/main/java/org/matsim/prepare/population/AssignReferencePopulation.java b/src/main/java/org/matsim/prepare/population/AssignReferencePopulation.java index a468698d..cc0b6fff 100644 --- a/src/main/java/org/matsim/prepare/population/AssignReferencePopulation.java +++ b/src/main/java/org/matsim/prepare/population/AssignReferencePopulation.java @@ -11,6 +11,7 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; import org.matsim.application.MATSimAppCommand; +import org.matsim.application.analysis.population.TripAnalysis; import org.matsim.application.options.ShpOptions; import org.matsim.core.population.PopulationUtils; import org.matsim.core.router.TripStructureUtils; @@ -131,13 +132,14 @@ public Integer call() throws Exception { if (success) { sampling.copyAttributes(p, person); - person.getAttributes().putAttribute(Attributes.REF_WEIGHT, p.get("p_weight")); + person.getAttributes().putAttribute(TripAnalysis.ATTR_REF_WEIGHT, p.get("p_weight")); person.removePlan(person.getSelectedPlan()); person.addPlan(plan); person.setSelectedPlan(plan); String refModes = TripStructureUtils.getLegs(plan).stream().map(Leg::getMode).collect(Collectors.joining("-")); - person.getAttributes().putAttribute(Attributes.REF_MODES, refModes); + person.getAttributes().putAttribute(TripAnalysis.ATTR_REF_MODES, refModes); + person.getAttributes().putAttribute(TripAnalysis.ATTR_REF_ID, e.getKey()); // remove person that have been used as reference refPersons.remove(person); diff --git a/src/main/java/org/matsim/prepare/population/Attributes.java b/src/main/java/org/matsim/prepare/population/Attributes.java index b2d6bb8e..bbeaf3a9 100644 --- a/src/main/java/org/matsim/prepare/population/Attributes.java +++ b/src/main/java/org/matsim/prepare/population/Attributes.java @@ -4,6 +4,7 @@ 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.application.analysis.population.TripAnalysis; import java.util.Objects; @@ -36,8 +37,7 @@ public final class Attributes { public static final String RESTRICTED_MOBILITY = "restricted_mobility"; public static final String ECONOMIC_STATUS = "economic_status"; public static final String HOUSEHOLD_SIZE = "household_size"; - public static final String REF_WEIGHT = "ref_weight"; - public static final String REF_MODES = "ref_modes"; + public static final String REF_MODES = TripAnalysis.ATTR_REF_MODES; public static final String ATTRACTION_WORK = "attraction_work"; public static final String ATTRACTION_OTHER = "attraction_other"; diff --git a/src/main/java/org/matsim/prepare/population/PlanBuilder.java b/src/main/java/org/matsim/prepare/population/PlanBuilder.java index 5265750e..b4cb0b17 100644 --- a/src/main/java/org/matsim/prepare/population/PlanBuilder.java +++ b/src/main/java/org/matsim/prepare/population/PlanBuilder.java @@ -39,11 +39,6 @@ public class PlanBuilder { private static final Logger log = LogManager.getLogger(PlanBuilder.class); private static final CsvOptions csv = new CsvOptions(CSVFormat.Predefined.Default); - /** - * Stores of warning for a zone was generated. - */ - private final Set warnings = new HashSet<>(); - /** * Maps zone ids to contained facilities. */ @@ -60,10 +55,6 @@ public class PlanBuilder { private final SplittableRandom rnd = new SplittableRandom(); - /** - * Drop plans with more than this number of trips. - */ - private int maxTripNumber = 0; public PlanBuilder(ShpOptions zones, FacilityIndex facilities, Path activityPath) throws IOException { // Collect all zones @@ -86,24 +77,6 @@ public PlanBuilder(ShpOptions zones, FacilityIndex facilities, Path activityPath } } - /** - * Add necesarry vehicles to the scenario. - */ - public static void addVehiclesToScenario(Scenario scenario) { - Id car = Id.createVehicleId("car"); - Vehicle vehicle = scenario.getVehicles().getFactory().createVehicle( - car, scenario.getVehicles().getVehicleTypes().get(Id.create("car", VehicleType.class)) - ); - scenario.getVehicles().addVehicle(vehicle); - - Id ride = Id.createVehicleId("ride"); - vehicle = scenario.getVehicles().getFactory().createVehicle( - ride, scenario.getVehicles().getVehicleTypes().get(Id.create("ride", VehicleType.class)) - ); - scenario.getVehicles().addVehicle(vehicle); - - } - private void readActivities(CSVParser csv, String idColumn) { String currentId = null;