Skip to content

Commit

Permalink
Copying a few updates from master to v1.5.2.2 branch for the record s…
Browse files Browse the repository at this point in the history
…ince they were used in Draft Blueprint runs
  • Loading branch information
lmz committed Aug 14, 2020
1 parent fc1060f commit 2b9bad9
Show file tree
Hide file tree
Showing 14 changed files with 2,463 additions and 13 deletions.
10 changes: 4 additions & 6 deletions model-files/RunModel.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
::
::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


:: ------------------------------------------------------------------------------------------------------
::
:: Step 1: Set the necessary path variables
Expand Down Expand Up @@ -158,12 +159,6 @@ copy INPUT\logsums logsums\
python CTRAMP\scripts\preprocess\RuntimeConfiguration.py
if ERRORLEVEL 1 goto done

:: For the "Per-Mile Tolling on Congested Freeways" in the Draft Blueprint
if NOT %PROJECT%==DBP (set UseTollDist=No)
if %PROJECT%==DBP (
if %UseTollDist%==Yes (python CTRAMP\scripts\preprocess\updateUECsToUseTollDist.py)
)

:: Set the prices in the roadway network (convert csv to dbf first)
python CTRAMP\scripts\preprocess\csvToDbf.py hwy\tolls.csv hwy\tolls.dbf
IF ERRORLEVEL 1 goto done
Expand Down Expand Up @@ -385,6 +380,9 @@ del *.prn
del *.script.*
del *.script

:: run QA/QC for PBA50
call Run_QAQC

:: Success target and message
:success
ECHO FINISHED SUCCESSFULLY!
Expand Down
243 changes: 243 additions & 0 deletions model-files/SetUpModel_PBA50.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
:: ------------------------------------------------------------------------------------------------------
::
:: Step 1: Specify file locations
::
:: ------------------------------------------------------------------------------------------------------

:: set the location of the model run folder on M; this is where the input and output directories will be copied to
set M_DIR=M:\Application\Model One\RTP2021\Blueprint\2050_TM152_DBP_PlusCrossing_07

:: Should strategies be included? AddStrategies=Yes for Project runs; AddStrategies=No for NoProject runs.
set AddStrategies=Yes

:: set the location of the Travel Model Release
set GITHUB_DIR=\\tsclient\X\travel-model-one-1.5.2.1

:: set the location of the networks (make sure the network version, year and variant are correct)
set INPUT_NETWORK=M:\Application\Model One\RTP2021\Blueprint\INPUT_DEVELOPMENT\Networks\BlueprintNetworks_15\net_2050_Blueprint Plus Crossing

:: set the location of the populationsim and land use inputs (make sure the land use version and year are correct)
set INPUT_POPLU=M:\Application\Model One\RTP2021\Blueprint\INPUT_DEVELOPMENT\PopSyn_n_LandUse\POPLU_v170_01\2050
set UrbanSimScenario=s23

:: set the location of the "input development" directory where other inputs are stored
set INPUT_DEVELOPMENT_DIR=M:\Application\Model One\RTP2021\Blueprint\INPUT_DEVELOPMENT

:: set the location of the previous run (where warmstart inputs will be copied)
:: the INPUT folder of the previous run will also be used as the base for the compareinputs log
set PREV_RUN_DIR=M:\Application\Model One\RTP2021\Blueprint\2050_TM152_DBP_PlusCrossing_06

:: set the name and location of the properties file
:: often the properties file is on master during the active application phase
set PARAMS=\\tsclient\X\travel-model-one-master\config\params_PBA50_Blueprint2050.properties

:: set the location of the overrides directory (for Blueprint strategies)
set BP_OVERRIDE_DIR=\\tsclient\M\Application\Model One\RTP2021\Blueprint\travel-model-overrides

:: ------------------------------------------------------------------------------------------------------
::
:: Step 2: Set up folder structure and copy CTRAMP
::
:: ------------------------------------------------------------------------------------------------------

SET computer_prefix=%computername:~0,4%

:: copy over CTRAMP
mkdir CTRAMP\model
mkdir CTRAMP\runtime
mkdir CTRAMP\scripts
mkdir CTRAMP\scripts\metrics
c:\windows\system32\Robocopy.exe /E "%GITHUB_DIR%\model-files\model" CTRAMP\model
c:\windows\system32\Robocopy.exe /E "%GITHUB_DIR%\model-files\runtime" CTRAMP\runtime
c:\windows\system32\Robocopy.exe /E "%GITHUB_DIR%\model-files\scripts" CTRAMP\scripts
c:\windows\system32\Robocopy.exe /E "%GITHUB_DIR%\utilities\RTP\metrics" CTRAMP\scripts\metrics
copy /Y "%GITHUB_DIR%\utilities\monitoring\notify_slack.py" CTRAMP\scripts
copy /Y "%GITHUB_DIR%\model-files\RunIteration.bat" CTRAMP
copy /Y "%GITHUB_DIR%\model-files\RunModel.bat" .
copy /Y "%GITHUB_DIR%\model-files\RunLogsums.bat" .
copy /Y "%GITHUB_DIR%\model-files\RunCoreSummaries.bat" .
copy /Y "%GITHUB_DIR%\utilities\RTP\RunMetrics.bat" .
copy /Y "%GITHUB_DIR%\utilities\RTP\RunScenarioMetrics.bat" .
copy /Y "%GITHUB_DIR%\utilities\RTP\ExtractKeyFiles.bat" .
::copy /Y "%GITHUB_DIR%\utilities\check-setupmodel\Check_SetupModelLog.py" .

if "%COMPUTER_PREFIX%" == "WIN-" (copy "%GITHUB_DIR%\utilities\monitoring\notify_slack.py" "CTRAMP\scripts\notify_slack.py")
if "%COMPUTER_PREFIX%" == "WIN-" set HOST_IP_ADDRESS=10.0.0.59

:: ------------------------------------------------------------------------------------------------------
::
:: Step 3: copy over input from INPUT_DEVELOPMENT or the previous run
:: (or sometimes a special location for the properties file)
::
:: ------------------------------------------------------------------------------------------------------

:: networks
c:\windows\system32\Robocopy.exe /E "%INPUT_NETWORK%\hwy" INPUT\hwy
c:\windows\system32\Robocopy.exe /E "%INPUT_NETWORK%\trn" INPUT\trn

:: popsyn and land use
c:\windows\system32\Robocopy.exe /E "%INPUT_POPLU%\popsyn" INPUT\popsyn
c:\windows\system32\Robocopy.exe /E "%INPUT_POPLU%\landuse" INPUT\landuse

:: nonres
c:\windows\system32\Robocopy.exe /E "%INPUT_DEVELOPMENT_DIR%\nonres\nonres_00" INPUT\nonres

:: logsums and metrics
c:\windows\system32\Robocopy.exe /E "%INPUT_DEVELOPMENT_DIR%\logsums_dummies" INPUT\logsums
c:\windows\system32\Robocopy.exe /E "%INPUT_DEVELOPMENT_DIR%\metrics" INPUT\metrics

:: warmstart (copy from the previous run)
mkdir INPUT\warmstart\main
mkdir INPUT\warmstart\nonres
copy /Y "%PREV_RUN_DIR%\OUTPUT\main\*.tpp" INPUT\warmstart\main
copy /Y "%PREV_RUN_DIR%\OUTPUT\nonres\*.tpp" INPUT\warmstart\nonres
del INPUT\warmstart\nonres\ixDaily2015.tpp
del INPUT\warmstart\nonres\ixDailyx4.tpp

:: the properties file
copy /Y "%PARAMS%" INPUT\params.properties

:: ------------------------------------------------------------------------------------------------------
::
:: Step 4: Overrides for Blueprint Strategies
::
:: ------------------------------------------------------------------------------------------------------
if %AddStrategies%==No goto DoneAddingStrategies
:: ------
:: Blueprint Regional Transit Fare Policy
:: ------
:: Same as PPA project 6100_TransitFare_Integration
copy /Y "%BP_OVERRIDE_DIR%\Regional_Transit_Fare_Policy\TransitSkims.job" CTRAMP\scripts\skims

:: means-based fare discount -- 50% off for Q1 -- are config in the parmas.properties file (see step 1)

:: ------
:: Blueprint Vision Zero
:: ------
:: Start year (freeways): 2030
:: Start year (local streets): 2025

:: Figure out the model year
set MODEL_DIR=%CD%
set PROJECT_DIR=%~p0
set PROJECT_DIR2=%PROJECT_DIR:~0,-1%
:: get the base dir only
for %%f in (%PROJECT_DIR2%) do set myfolder=%%~nxf
:: the first four characters are model year
set MODEL_YEAR=%myfolder:~0,4%

set /a MODEL_YEAR_NUM=%MODEL_YEAR% 2>nul

if %MODEL_YEAR_NUM%==2025 (copy /Y "%BP_OVERRIDE_DIR%\Vision_Zero\SpeedCapacity_1hour_2025.block" "CTRAMP\scripts\block\SpeedCapacity_1hour.block")
if %MODEL_YEAR_NUM% GEQ 2030 (copy /Y "%BP_OVERRIDE_DIR%\Vision_Zero\SpeedCapacity_1hour_2030to2050.block" "CTRAMP\scripts\block\SpeedCapacity_1hour.block")

:: ------
:: Blueprint Per-Mile Tolling on Congested Freeways
:: ------
:: no override needed, as we confirmed that all ODs have free paths
:: see asana task: https://app.asana.com/0/572982923864207/1174201042245385

:: toll rate discount -- 50% discount for Q1 and Q2 -- are specified in the properties file (see step 1)

:: ------
:: Complete Streets
:: ------
:: https://app.asana.com/0/403262763383022/1160600926245407
:: implemented as an UEC override for now; pass the bike constant via params when there is time
copy /Y "%BP_OVERRIDE_DIR%\Complete_Streets_Network\ModeChoice_%MODEL_YEAR_NUM%.xls" CTRAMP\model\ModeChoice.xls
copy /Y "%BP_OVERRIDE_DIR%\Complete_Streets_Network\TripModeChoice_%MODEL_YEAR_NUM%.xls" CTRAMP\model\TripModeChoice.xls

:DoneAddingStrategies

:: ------------------------------------------------------------------------------------------------------
::
:: Step 5: Patches to Travel Model Release
::
:: ------------------------------------------------------------------------------------------------------
:: in case the TM release is behind, this is where we copy the most up-to-date scripts from master
set GITHUB_MASTER=\\tsclient\X\travel-model-one-master

:: runmodel is behind
:: because I took out the lines related to UseTollDist
copy /Y "%GITHUB_MASTER%\model-files\RunModel.bat" .

:: some minor updates to trips.rdata for the tnc electrification calculator
copy /y "%GITHUB_MASTER%\model-files\scripts\core_summaries\CoreSummaries.R" CTRAMP\scripts\core_summaries\

:: some minor updates to ExtractKeyFiles
copy /Y "%GITHUB_MASTER%\utilities\RTP\ExtractKeyFiles.bat" .

:: added AV share =30% to auto_ownership UECs
copy /y "%GITHUB_MASTER%\model-files\model\AutoOwnership.xls" CTRAMP\model\AutoOwnership.xls

:: add run_qaqc.bat
copy /Y "%GITHUB_MASTER%\utilities\RTP\QAQC\Run_QAQC.bat" .

:: add a process to check setupmodel
copy /Y "%GITHUB_MASTER%\utilities\check-setupmodel\Check_SetupModelLog.py" .

:: ------------------------------------------------------------------------------------------------------
::
:: Step 6: copy information back to the M drive for run management
::
:: ------------------------------------------------------------------------------------------------------

:: copy the INPUT folder back to M for record keeping

echo %date%
SET mm=%date:~4,2%
SET dd=%date:~7,2%
SET yy=%date:~12,2%
echo %time%
SET hh=%time:~0,2%
SET min=%time:~3,2%
SET ss=%time:~6,2%

if exist "%M_DIR%\INPUT" (
:: do not overwrite existing INPUT folders on M
c:\windows\system32\Robocopy.exe /E "INPUT" "%M_DIR%\INPUT_%mm%%dd%%yy%_%hh%%min%%ss%"
) else (
c:\windows\system32\Robocopy.exe /E "INPUT" "%M_DIR%\INPUT"
)

Set dir1="%M_DIR%\INPUT"
Set dir2="%PREV_RUN_DIR%\INPUT"
robocopy.exe %dir1% %dir2% /e /l /ns /njs /ndl /fp /log:"%M_DIR%\CompareInputs.txt"

::----------------------------------------------
:: add folder name to the command prompt window
::----------------------------------------------
set MODEL_DIR=%CD%
set PROJECT_DIR=%~p0
set PROJECT_DIR2=%PROJECT_DIR:~0,-1%
:: get the base dir only
for %%f in (%PROJECT_DIR2%) do set myfolder=%%~nxf

title %myfolder%


:: copy this batch file itself to M
set CopyOfSetupModel="SetUpModel_" %myfolder%".txt"
copy SetUpModel.bat "%M_DIR%\%CopyOfSetupModel%"

::-----------------------------------------------------------------------
:: create a shortcut of the project directory using a temporary VBScript
::-----------------------------------------------------------------------

set TEMP_SCRIPT="%CD%\temp_script_to_create_shortcut.vbs"
set PROJECT_DIR=%~p0
set ALPHABET=%computername:~7,1%

echo Set oWS = WScript.CreateObject("WScript.Shell") >> %TEMP_SCRIPT%
echo sLinkFile = "%M_DIR%/model_run_on_%computername%.lnk" >> %TEMP_SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %TEMP_SCRIPT%
echo oLink.TargetPath = "M:" >> %TEMP_SCRIPT%
echo oLink.TargetPath = "\\%computername%\%PROJECT_DIR%" >> %TEMP_SCRIPT%

echo oLink.Save >> %TEMP_SCRIPT%

::C:\Windows\SysWOW64\cscript.exe /nologo %TEMP_SCRIPT%
C:\Windows\SysWOW64\cscript.exe %TEMP_SCRIPT%
del %TEMP_SCRIPT%

:end
Binary file modified model-files/model/AutoOwnership.xls
Binary file not shown.
8 changes: 4 additions & 4 deletions model-files/scripts/core_summaries/CoreSummaries.R
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ add_distance <- function(this_timeperiod, input_trips_or_tours) {
(distance_mode == 6) * s3Toll +
(distance_mode == 7) * walk +
(distance_mode == 8) * bike +
(distance_mode >= 9) * da )
(distance_mode >= 9) * pmin(da, daToll))


relevant <- relevant %>%
Expand Down Expand Up @@ -595,7 +595,7 @@ add_active <- function(this_timeperiod, input_trips_or_tours) {

indiv_trips <- read.table(file=file.path(MAIN_DIR, paste0("indivTripData_",ITER,".csv")), header=TRUE, sep=",")
indiv_trips <- select(indiv_trips, hh_id, person_id, tour_id, orig_taz, dest_taz,
trip_mode, tour_purpose, orig_purpose, dest_purpose, depart_hour, stop_id, tour_category) %>%
trip_mode, tour_purpose, orig_purpose, dest_purpose, depart_hour, stop_id, tour_category, avAvailable, sampleRate) %>%
mutate(tour_id = paste0("i",substr(tour_category,1,2),tour_id))

## Data Reads: Joint Trips and recode a few variables
Expand All @@ -604,7 +604,7 @@ indiv_trips <- select(indiv_trips, hh_id, person_id, tour_id, orig_taz, dest
joint_trips <- tbl_df(read.table(file=file.path(MAIN_DIR, paste0("jointTripData_",ITER,".csv")),
header=TRUE, sep=","))
joint_trips <- select(joint_trips, hh_id, tour_id, orig_taz, dest_taz, trip_mode,
num_participants, tour_purpose, orig_purpose, dest_purpose, depart_hour, stop_id, tour_category) %>%
num_participants, tour_purpose, orig_purpose, dest_purpose, depart_hour, stop_id, tour_category, avAvailable, sampleRate) %>%
mutate(tour_id = paste0("j",substr(tour_category,1,2),tour_id))

print(paste("Read",prettyNum(nrow(joint_trips),big.mark=","),
Expand Down Expand Up @@ -715,7 +715,7 @@ if (JUST_MES=="1") {
joint_person_trips <- inner_join(joint_trips, joint_tour_persons, by=c("hh_id", "tour_id"))
# select out person_num and the person table columns
joint_person_trips <- select(joint_person_trips, hh_id, person_id, tour_id, orig_taz, dest_taz, trip_mode,
num_participants, tour_purpose, orig_purpose, dest_purpose, depart_hour, stop_id)
num_participants, tour_purpose, orig_purpose, dest_purpose, depart_hour, stop_id, avAvailable, sampleRate)
# cleanup
remove(joint_tours,joint_trips,joint_tour_persons)

Expand Down
13 changes: 10 additions & 3 deletions utilities/RTP/ExtractKeyFiles.bat
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ copy main\tripsEV.tpp extractor\main
copy main\ShadowPricing_7.csv extractor\main

mkdir extractor\nonres
copy nonres\ixDaily2015.tpp extractor\nonres
copy nonres\ixDailyx4.tpp extractor\nonres
copy nonres\ixDaily2015.tpp extractor\nonres
copy nonres\ixDailyx4.tpp extractor\nonres
copy nonres\tripsIX*.tpp extractor\nonres
copy nonres\tripsTrk*.tpp extractor\nonres

:: copy skims\hwyskmEA.tpp extractor\emfac\hwyskmEA.tpp
:: copy skims\hwyskmAM.tpp extractor\emfac\hwyskmAM.tpp
Expand Down Expand Up @@ -105,6 +107,11 @@ copy logsums\person_workDCLogsum.csv extractor\logsums
copy logsums\mandatoryAccessibilities.csv extractor\logsums
copy logsums\nonMandatoryAccessibilities.csv extractor\logsums

mkdir extractor\logsums\ForUrbanSim
copy logsums\mandatoryAccessibilities.csv extractor\logsums\ForUrbanSim\mandatoryAccessibilities_%model_year%_%UrbanSimScenario%.csv
copy logsums\nonMandatoryAccessibilities.csv extractor\logsums\ForUrbanSim\nonMandatoryAccessibilities_%model_year%_%UrbanSimScenario%.csv
copy core_summaries\AccessibilityMarkets.csv extractor\logsums\ForUrbanSim\AccessibilityMarkets_%model_year%_%UrbanSimScenario%.csv

:: Core summaries
mkdir extractor\core_summaries
copy core_summaries\*.* extractor\core_summaries
Expand All @@ -123,4 +130,4 @@ if exist metrics\ITHIM (
echo ExtractKeyFiles into extractor for PBAU Complete
echo ENDED EXTRACTOR RUN %DATE% %TIME% >> logs\feedback.rpt

:done
:done
42 changes: 42 additions & 0 deletions utilities/RTP/QAQC/Car_ownership_AVHV.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
########################################################################################
# AVs vs HVs ownership summary
########################################################################################
library(dplyr)

# Remove all files from the workspace
rm(list = ls())

# Read the household data file
Hhld_df <-read.csv(file="householdData_3.csv", header=TRUE, sep=",")

M_DIR <- Sys.getenv("M_DIR")
M_DIR <- gsub("\\\\","/",M_DIR) # switch slashes around


Out_file <-file.path(M_DIR, "OUTPUT", "QAQC", "carown_summary.csv")

Hhld_df$carown <- paste(Hhld_df$humanVehicles, "HV-", Hhld_df$autonomousVehicles, "AV", sep="")


Hhld_df <- Hhld_df %>%
mutate(carown_labels = recode(carown,
"0HV-0AV" = "Alt01 0 car",
"1HV-0AV" = "Alt02 1 car - 1HV",
"0HV-1AV" = "Alt03 1 car - 1AV",
"2HV-0AV" = "Alt04 2 cars - 2HVs",
"0HV-2AV" = "Alt05 2 cars - 2AVs",
"1HV-1AV" = "Alt06 2 cars - 1HV1AV",
"3HV-0AV" = "Alt07 3 cars - 3HVs",
"0HV-3AV" = "Alt08 3 cars - 3AVs",
"2HV-1AV" = "Alt09 3 cars - 2HVs1AV",
"1HV-2AV" = "Alt10 3 cars - 1HV2AVs",
"4HV-0AV" = "Alt11 4 cars - 4HVs"))


carown_summary <- Hhld_df %>%
group_by(carown_labels) %>%
summarise(nhhld = n())


# write out the results
write.table(carown_summary, file=(Out_file), sep = ",", row.names=FALSE, col.names=TRUE)
Binary file added utilities/RTP/QAQC/Car_ownership_summary.xlsx
Binary file not shown.
Loading

0 comments on commit 2b9bad9

Please sign in to comment.