-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First tests in org.eqasim.core (#181)
* Feat: RemovePersonsWithActivityTypes * fix: properly reading PublicTransitEvent objects from events file during analysis Now adding a CustomEventMapper to the event readers that converts GenericEvent objects to PublicTransitEvent ones. This is done by the new convert method in the latter class. * test: TestSimulationPipeline for various functionalities Scope of the test: - Simulation of a small scenario (added in this commit) with default Eqasim behaviour - Shapefile export tools for transit schedules, transit stops and networks - Run scripts in eqasim.core.analysis.run using output events * fix: throwing exception instead of return null in PublicTransitEvent.convert * fix: Renamed runCorsicaSimulation method to runMelunSimulation ---------
- Loading branch information
Showing
12 changed files
with
1,065 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
core/src/main/java/org/eqasim/core/tools/RemovePersonsWithActivityTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.eqasim.core.tools; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.matsim.api.core.v01.Identifiable; | ||
import org.matsim.api.core.v01.Scenario; | ||
import org.matsim.api.core.v01.population.Activity; | ||
import org.matsim.api.core.v01.population.PopulationWriter; | ||
import org.matsim.core.config.CommandLine; | ||
import org.matsim.core.config.ConfigUtils; | ||
import org.matsim.core.population.io.PopulationReader; | ||
import org.matsim.core.scenario.ScenarioUtils; | ||
|
||
import java.util.Arrays; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class RemovePersonsWithActivityTypes { | ||
|
||
private static final Logger logger = Logger.getLogger(RemovePersonsWithActivityTypes.class); | ||
|
||
public static void main(String[] args) throws CommandLine.ConfigurationException { | ||
CommandLine commandLine = new CommandLine.Builder(args).requireOptions("input-path", "output-path", "activity-types").build(); | ||
|
||
Set<String> activityTypes = Arrays.stream(commandLine.getOptionStrict("activity-types").split(",")).map(String::trim).collect(Collectors.toSet()); | ||
|
||
Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); | ||
new PopulationReader(scenario).readFile(commandLine.getOptionStrict("input-path")); | ||
|
||
logger.info("Old population size: " + scenario.getPopulation().getPersons().size()); | ||
scenario.getPopulation().getPersons().values().stream() | ||
.filter(p -> p.getSelectedPlan().getPlanElements().stream() | ||
.filter(e -> e instanceof Activity) | ||
.map(e -> ((Activity) e).getType()) | ||
.anyMatch(activityTypes::contains)) | ||
.map(Identifiable::getId) | ||
.collect(Collectors.toSet()) | ||
.forEach(scenario.getPopulation()::removePerson); | ||
logger.info("new population size: " + scenario.getPopulation().getPersons().size()); | ||
new PopulationWriter(scenario.getPopulation()).write(commandLine.getOptionStrict("output-path")); | ||
} | ||
} |
Oops, something went wrong.