Skip to content

Commit

Permalink
Merge pull request #2 from wsp-sag/bart-feat-mode-choice
Browse files Browse the repository at this point in the history
Link21: Update Tour and Trip Mode Choice UECs
  • Loading branch information
i-am-sijia committed May 17, 2022
2 parents 49e1e2f + ccc6439 commit bcb6757
Show file tree
Hide file tree
Showing 27 changed files with 5,750 additions and 13 deletions.
Binary file modified core/projects/mtc/release/mtc.jar
Binary file not shown.
26 changes: 13 additions & 13 deletions core/projects/mtc/src/java/com/pb/mtc/ctramp/MtcModelStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,23 @@ public class MtcModelStructure extends ModelStructure {
// TODO: set these values from project specific code.
public static final int ESCORT_INDEX = 3;

public static final int[] SOV_ALTS = { 1, 2 };
public static final int[] HOV_ALTS = { 3, 4, 5, 6 };
public static final int[] WALK_ALTS = { 7 };
public static final int[] BIKE_ALTS = { 8 };
public static final int[] NON_MOTORIZED_ALTS = { 7, 8 };
public static final int[] TRANSIT_ALTS = { 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };
public static final int[] WALK_LOCAL_ALTS = { 9 };
public static final int[] WALK_PREMIUM_ALTS = { 10, 11, 12, 13 };
public static final int[] DRIVE_TRANSIT_ALTS = { 14, 15, 16, 17, 18 };
public static final int[] SOV_ALTS = { 1 };
public static final int[] HOV_ALTS = { 2, 3 };
public static final int[] WALK_ALTS = { 4 };
public static final int[] BIKE_ALTS = { 5 };
public static final int[] NON_MOTORIZED_ALTS = { 4, 5 };
public static final int[] TRANSIT_ALTS = { 6, 7, 8 };
public static final int[] WALK_LOCAL_ALTS = { 6 };
public static final int[] WALK_PREMIUM_ALTS = { 6 };
public static final int[] DRIVE_TRANSIT_ALTS = { 7, 8 };
public static final int[] SCHOOL_BUS_ALTS = {};
public static final int[] RIDE_HAIL_ALTS = {19, 20, 21};
public static final int MAXIMUM_TOUR_MODE_ALT_INDEX = 21;
public static final int[] RIDE_HAIL_ALTS = { 9 };
public static final int MAXIMUM_TOUR_MODE_ALT_INDEX = 9;

public static final int NUM_INCOME_CATEGORIES = 4;

public static final int[] TRIP_SOV_ALTS = { 1, 2 };
public static final int[] TRIP_HOV_ALTS = { 3, 4, 5, 6 };
public static final int[] TRIP_SOV_ALTS = { 1 };
public static final int[] TRIP_HOV_ALTS = { 2, 3 };


public static final String[] JTF_ALTERNATIVE_LABELS = { "0_tours", "1_Shop", "1_Main", "1_Eat", "1_Visit", "1_Disc", "2_SS", "2_SM", "2_SE", "2_SV", "2_SD", "2_MM", "2_ME", "2_MV", "2_MD", "2_EE", "2_EV", "2_ED", "2_VV", "2_VD", "2_DD" };
Expand Down
Binary file added model-files/model/ModeChoice-for-script.xlsx
Binary file not shown.
Binary file modified model-files/model/ModeChoice.xls
Binary file not shown.
Binary file added model-files/model/TripModeChoice-for-script.xlsx
Binary file not shown.
Binary file modified model-files/model/TripModeChoice.xls
Binary file not shown.
Binary file modified model-files/runtime/mtc.jar
Binary file not shown.
153 changes: 153 additions & 0 deletions utilities/make-mode-choice/find-uec-differences.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
---
title: "Find UEC Differences"
output: html_notebook
---

# Overhead
```{r overhead, include = FALSE}
packages_vector <- c("tidyverse",
"readxl")
need_to_install <- packages_vector[!(packages_vector %in% installed.packages()[,"Package"])]
if (length(need_to_install)) install.packages(need_to_install)
for (package in packages_vector) {
library(package, character.only = TRUE)
}
```

# Remote I/O
```{r remote-io}
uec_dir <- "../../model-files/model/"
uec_filename <- paste0(uec_dir, "ModeChoice-for-script.xlsx")
output_file_name <- paste0("uec-differences.csv")
```

# Parameters
```{r parameters}
```


# Data Reads
```{r read}
excel_df <- tibble()
sheets <- c("Work",
"Shopping",
"Work-deprecated",
"University-deprecated",
"School-deprecated",
"Escort-deprecated",
"Shopping-deprecated",
"EatOut-deprecated",
"OthMaint-deprecated",
"Social-deprecated",
"OthDiscr-deprecated",
"WorkBased-deprecated")
for (sheet in sheets) {
number_alts <- if_else(str_detect(sheet, "deprecated"), 21L, 9L)
skip_lines <- if_else(str_detect(sheet, "deprecated"), 10L, 8L)
df <- read_excel(uec_filename,
sheet = sheet,
skip = skip_lines,
col_names = c("row_number", "token", "description", "filter", "formula", "index", sprintf("Alt%0d", seq(1,number_alts)))) %>%
mutate(sheet_name = sheet)
excel_df <- bind_rows(excel_df, df)
}
remove(sheets, df, number_alts, skip_lines)
```

# Methods
```{r methods}
make_uec <- function(input_df, template_name, subject_name, start_with_name) {
input_df <- excel_df
template_name <- "Shopping-deprecated"
subject_name <- "WorkBased-deprecated"
start_with_name <- "Shopping"
join_ref_df <- filter(input_df, sheet_name == template_name) %>%
select(ref_row = row_number, token, description, filter, formula)
join_df <- filter(input_df, sheet_name == subject_name) %>%
select(subject_row = row_number, token, description, filter, formula)
working_df <- left_join(join_df, join_ref_df, by = c("token", "filter", "description", "formula")) %>%
mutate(matched = !is.na(ref_row))
different_df <- working_df %>%
filter(!matched)
constants_df <- different_df %>%
select(subject_row, token, filter, description, update_formula = formula) %>%
left_join(., join_ref_df, by = c("token", "filter", "description")) %>%
select(token, description, filter, formula, update_formula)
out_df <- filter(excel_df, sheet_name == start_with_name) %>%
select(row_number, token, description, filter, formula, index) %>%
left_join(., constants_df, by = c("token", "filter", "description", "formula")) %>%
mutate(formula = if_else(is.na(update_formula), formula, update_formula)) %>%
select(-update_formula) %>%
replace(is.na(.), "")
return(list("differences" = different_df, "uec" = out_df))
}
```

# Reductions
```{r reductions}
univ_list <- make_uec(excel_df, "Work-deprecated", "University-deprecated", "Work")
check_univ_df <- univ_list$differences
school_list <- make_uec(excel_df, "Work-deprecated", "School-deprecated", "Work")
check_school_df <- school_list$differences
escort_list <- make_uec(excel_df, "Work-deprecated", "Escort-deprecated", "Work")
check_escort_df <- escort_list$differences
shopping_list <- make_uec(excel_df, "Work-deprecated", "Shopping-deprecated", "Work")
check_shopping_df <- shopping_list$differences
eatout_list <- make_uec(excel_df, "Shopping-deprecated", "EatOut-deprecated", "Shopping")
check_eatout_df <- eatout_list$differences
othmaint_list <- make_uec(excel_df, "Shopping-deprecated", "OthMaint-deprecated", "Shopping")
check_othmaint_df <- othmaint_list$differences
social_list <- make_uec(excel_df, "Shopping-deprecated", "Social-deprecated", "Shopping")
check_social_df <- social_list$differences
othdiscr_list <- make_uec(excel_df, "Shopping-deprecated", "OthDiscr-deprecated", "Shopping")
check_othdiscr_df <- othdiscr_list$differences
workbased_list <- make_uec(excel_df, "Shopping-deprecated", "WorkBased-deprecated", "Shopping")
check_workbased_df <- workbased_list$differences
df <- workbased_list$uec
```

# Write to disk
```{r write}
write_csv(univ_list$uec, file = "update-university.csv")
write_csv(school_list$uec, file = "update-school.csv")
write_csv(escort_list$uec, file = "update-escort.csv")
write_csv(shopping_list$uec, file = "update-shopping.csv")
write_csv(eatout_list$uec, file = "update-eatout.csv")
write_csv(othmaint_list$uec, file = "update-othmaint.csv")
write_csv(social_list$uec, file = "update-social.csv")
write_csv(othdiscr_list$uec, file = "update-othdiscr.csv")
write_csv(workbased_list$uec, file = "update-workbased.csv")
```

13 changes: 13 additions & 0 deletions utilities/make-mode-choice/make-mode-choice.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
Loading

0 comments on commit bcb6757

Please sign in to comment.