Skip to content

Commit

Permalink
add optional id filter
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Jul 7, 2024
1 parent 87f43d2 commit f7c518d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/org/matsim/prepare/choices/ComputePlanChoices.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.regex.Pattern;


@CommandLine.Command(
Expand All @@ -57,6 +58,10 @@ public class ComputePlanChoices implements MATSimAppCommand, PersonAlgorithm {
private int topK;
@CommandLine.Option(names = "--modes", description = "Modes to include in estimation", split = ",")
private Set<String> modes;

@CommandLine.Option(names = "--id-filter", description = "Filter for person ids")
private Pattern idFilter;

@CommandLine.Option(names = "--time-util-only", description = "Reset scoring for estimation and only use time utility", defaultValue = "false")
private boolean timeUtil;
@CommandLine.Option(names = "--calc-scores", description = "Perform pseudo scoring for each plan", defaultValue = "false")
Expand Down Expand Up @@ -112,6 +117,10 @@ public Integer call() throws Exception {
topK = 2;
}

if (idFilter != null) {
log.info("Using person id filter: {}", idFilter);
}

Controler controler = this.scenario.createControler();

controler.addOverridingModule(InformedModeChoiceModule.newBuilder()
Expand Down Expand Up @@ -209,6 +218,11 @@ public void run(Person person) {
return;
}

if (idFilter != null && !idFilter.matcher(person.getId().toString()).matches()) {
pb.step();
return;
}

Plan plan = person.getSelectedPlan();
PlanModel model = PlanModel.newInstance(plan);

Expand Down

0 comments on commit f7c518d

Please sign in to comment.