Skip to content

Commit

Permalink
Fix some code style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Jan 6, 2025
1 parent 3c27784 commit e47cc93
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/matsim/prepare/FilterRelevantAgents.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@
import java.util.concurrent.ConcurrentHashMap;


/**
* Use {@link org.matsim.application.prepare.scenario.CreateScenarioCutOut} instead.
*/
@CommandLine.Command(
name = "filter-relevant-agents",
description = "Filter agents that have any activities or routes within the shp file."
)
@Deprecated
@Deprecated(forRemoval = true, since = "6.4")
public class FilterRelevantAgents implements MATSimAppCommand, PersonAlgorithm {

private static final Logger log = LogManager.getLogger(FilterRelevantAgents.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public class ComputePlanChoices implements MATSimAppCommand, PersonAlgorithm {
@CommandLine.Option(names = "--calc-scores", description = "Perform pseudo scoring for each plan", defaultValue = "false")
private boolean calcScores;

@CommandLine.Option(names = "--plan-candidates", description = "Method to generate plan candidates", defaultValue = "bestK")
private PlanCandidates planCandidates = PlanCandidates.bestK;
@CommandLine.Option(names = "--plan-candidates", description = "Method to generate plan candidates", defaultValue = "subtour")
private PlanCandidates planCandidates = PlanCandidates.subtour;

@CommandLine.Option(names = "--max-plan-length", description = "Maximum plan length", defaultValue = "7")
private int maxPlanLength;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public List<PlanCandidate> generate(Plan plan, PlanModel planModel, @Nullable Se
PlanCandidate existing = gen.generatePredefined(planModel, chosen).get(0);

// This changes the internal state to randomize the estimates
// TODO random selection is biased because of mass conservation
// random selection is biased because of mass conservation
// due to that, this class should not be used
for (Map.Entry<String, List<ModeEstimate>> entry : planModel.getEstimates().entrySet()) {
for (ModeEstimate est : entry.getValue()) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/matsim/prepare/pt/CorrectRouteTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
@SuppressWarnings("unused")
public class CorrectRouteTypes implements Consumer<Route> {

private static final Pattern ICE = Pattern.compile("ICE [0-9]+");
private static final Pattern IC = Pattern.compile("(IC|EC) [0-9]+");
private static final Pattern RE = Pattern.compile("((RE|RB[0-9]+)|FEX|^RE)");
private static final Pattern ICE = Pattern.compile("ICE \\d+");
private static final Pattern IC = Pattern.compile("(IC|EC) \\d+");
private static final Pattern RE = Pattern.compile("((RE|RB\\d+)|FEX|^RE)");

private static final Pattern S_BAHN = Pattern.compile("S[0-9]+");
private static final Pattern U_BAHN = Pattern.compile("U[0-9]+");
private static final Pattern S_BAHN = Pattern.compile("S\\d+");
private static final Pattern U_BAHN = Pattern.compile("U\\d+");

@Override
public void accept(Route route) {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/matsim/run/OpenBerlinDrtScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ private static void tagTransitStopsInServiceArea(TransitSchedule transitSchedule

for (TransitStopFacility stop : transitSchedule.getFacilities().values()) {
if (stop.getAttributes().getAttribute(oldFilterAttribute) != null) {
if (stop.getAttributes().getAttribute(oldFilterAttribute).equals(oldFilterValue)) {
if (serviceAreas.stream().anyMatch(geom -> geom.contains(MGC.coord2Point(stop.getCoord())))) {
stop.getAttributes().putAttribute(newAttributeName, newAttributeValue);
}
if (stop.getAttributes().getAttribute(oldFilterAttribute).equals(oldFilterValue) &&
serviceAreas.stream().anyMatch(geom -> geom.contains(MGC.coord2Point(stop.getCoord())))) {
stop.getAttributes().putAttribute(newAttributeName, newAttributeValue);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ public IndividualPersonScoringParameters(Scenario scenario) {
this.cache = new IdMap<>(Person.class, scenario.getPopulation().getPersons().size());

// Create uncorrelated seed from the global seed
SplittableRandom rnd = new SplittableRandom(scenario.getConfig().global().getRandomSeed());
for (int i = 0; i < rnd.nextInt(); i++) {
rnd.nextLong();
SplittableRandom rng = new SplittableRandom(scenario.getConfig().global().getRandomSeed());
for (int i = 0; i < rng.nextInt(); i++) {
rng.nextLong();
}

byte[] seed = Longs.toByteArray(rnd.nextLong());
byte[] seed = Longs.toByteArray(rng.nextLong());
this.rnd = ThreadLocal.withInitial(() -> new Context(seed));
}

Expand Down

0 comments on commit e47cc93

Please sign in to comment.