Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1c988af
import_tg_results translate
yzhou-cmap Mar 26, 2026
137cc36
File and script updates to support the Python version of trip generat…
tinleycraig Mar 27, 2026
3e94ade
Merge pull request #43 from CMAP-REPOS/42-integrate-python-version-of…
nrferguson Mar 27, 2026
5dfc2e6
run_transit_assignment.bat revised for c26q2
tinleycraig Apr 8, 2026
b37f80d
Merge pull request #45 from CMAP-REPOS/44-update-run_transit_assignme…
nrferguson Apr 9, 2026
62fbe9d
Install cmap_modedest package from GitHub
nrferguson Mar 25, 2026
213c2b7
Merge pull request #46 from CMAP-REPOS:30-update-cmap-trip2-environme…
nrferguson Apr 14, 2026
677efce
fix(tg): include new tg input data files
nrferguson Apr 15, 2026
c398906
fix(cmap_modedest): remove obsolete sourceCode config setting
nrferguson Apr 15, 2026
83508d5
chore: ignore new tg output files
nrferguson Apr 15, 2026
1f7276a
feat(env): add R environment activation and rename CMAP-TRIP2
nrferguson Apr 16, 2026
3396303
feat(env): use conda R env to execute create_distr_m01_files.R
nrferguson Apr 16, 2026
5250c6c
Merge pull request #49 from CMAP-REPOS:20-automate-r-environment-crea…
nrferguson Apr 16, 2026
f99b7f5
feat(env): use miniconda and uv to install environments
nrferguson Apr 23, 2026
3d6a351
Merge pull request #50 from CMAP-REPOS/nrferguson/issue47
nrferguson Apr 29, 2026
87f1917
fix(export): handle multiple TG results files to prevent errors
nrferguson Apr 29, 2026
6117dd4
Merge pull request #51 from CMAP-REPOS/22-multiple-tg-results-files-c…
nrferguson Apr 29, 2026
8466a2a
fix(summarize): replace append with concat for trip dataframes
nrferguson Apr 29, 2026
e52b318
Merge pull request #52 from CMAP-REPOS/develop
nrferguson Apr 30, 2026
1eaf8d0
Merge remote-tracking branch 'origin/main' into translate_import_tg
kcazzatoCMAP Jun 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Ignore compiled Python.
**/__pycache__

# Ignore files generated by installing Python eggs.
src/Mode-Dest-TOD/cmap_modedest.egg-info
src/Mode-Dest-TOD/sharrow/sharrow.egg-info

# Ignore large Emme project files.
Database/emmemat
Database/emmebank
Expand All @@ -15,7 +11,6 @@ Database/tg/fortran/HH_IN.TXT
Database/tg/fortran/POPSYN_HH.CSV
Database/tg/fortran/GQ_IN.TXT
Database/tg/fortran/ATTR_IN.TXT
Database/tg/fortran/airport_sz.csv
Database/tg/fortran/SCHOOL_IN.CSV
Database/tg/fortran/wfhmodule/indusmix.csv

Expand All @@ -39,6 +34,10 @@ Database/tg/fortran/wfhmodule/synthetic_*.zip
Database/TG_HHENUM_OUTPUT.TXT
Database/tg/fortran/HH_WFH_STATUS.CSV
Database/tg/fortran/SIMULATED_HHVEH.TXT
Database/tg/fortran/households_selected_noWFH_enumeration_count.csv
Database/tg/fortran/households_selected_WFH_enumeration_count.csv
Database/tg/fortran/missing_hhtype.csv
Database/tg/fortran/trip_generation_model_log.txt

# Ignore files generated by prep macros.
Database/*_DISTR.TXT
Expand Down
126 changes: 39 additions & 87 deletions Database/Submit_Full_Regional_Model_SOLA.bat
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ for /f "eol=# skip=16 tokens=2 delims=:" %%k in (batch_file.yaml) do (set Urbans
:break7
for /f "eol=# skip=18 tokens=2 delims=:" %%l in (batch_file.yaml) do (set RSPrun=%%l & goto break8)
:break8
for /f "eol=# skip=21 tokens=2 delims=:" %%m in (batch_file.yaml) do (set srcCode=%%m & goto break9)
:break9

set ver=%ver:~1,5%
set val=%val:~1,3%
Expand All @@ -63,7 +61,6 @@ set selLineFile=%selLineFile:~1%
set utilFile=%utilFile:~1,1%
set UrbansimFile=%UrbansimFile:~1,1%
set RSPrun=%RSPrun:~1,1%
set srcCode=%srcCode:~1,1%
REM -- Count number of select link files --
set tempCnt=0
for %%a in (%selLinkFile:None=%) do set /a tempCnt+=1
Expand Down Expand Up @@ -94,7 +91,6 @@ if "%transitAsmt%" EQU "T" (@echo Transit assignment select line file = %selLin
@echo Save utility files = %utilFile%
@echo Create UrbanSim travel time file = %UrbansimFile%
@echo RSP evaluation run = %RSPrun%
@echo Have CMAP-TRIP2 use destination-mode choice code in this model setup = %srcCode%
@echo ==================================================================================
@echo.

Expand All @@ -107,14 +103,11 @@ set transactFilePath=%transactFilePath:~0,-1%
if "%check2%" NEQ "None" (
if not exist Select_Line\%selLineFile% (goto no_select_line_file)
)

rem Activate Emme Python env
call %~dp0..\Scripts\manage\env\activate_env.cmd emme

@echo -- Verifying select link files --
call python macros\verify_select_link.py %file1% %selLinkFile% %RSPrun% %trnAsmt%
uv run macros\verify_select_link.py %file1% %selLinkFile% %RSPrun% %trnAsmt%
if %ERRORLEVEL% GTR 0 (goto end)


REM Clean up prior to run
if exist cache\choice_simulator_trips_out (rmdir /S /Q cache\choice_simulator_trips_out)
if exist cache\choice_simulator_trips_out.001 (rmdir /S /Q cache\choice_simulator_trips_out.001)
Expand All @@ -127,7 +120,6 @@ echo.
echo Select Destination Choice-Mode Choice model run mode:
echo 1) Minimize run time (default) - resources allocated to support a single model run.
echo 2) Balanced - resources allocated to support two simultaneous model runs.
echo [If this is the second of two simultaneous runs: only proceed if srcCode is False (currently set to %srcCode%)]
echo.
set /a jobs=38
set /a zones=10
Expand Down Expand Up @@ -196,19 +188,6 @@ REM PREP WORK
CD %~dp0
CD prep_macros

REM Now find R executable
set infile=path.txt
if exist %infile% (del %infile% /Q)
dir "C:\Program Files\R\*R.exe" /s /b >> %infile% 2>nul
set /p path2=<%infile%
set paren="
set rpath=%paren%%path2%%paren%
echo rpath = %rpath%
call :CheckEmpty2 %infile%
:Rpass
if exist %infile% (del %infile% /Q)
set rfile=create_distr_m01_files

REM -- Start DISTR & M01 Data Processing --
@ECHO.
@ECHO Start Time: %date% %time%
Expand All @@ -222,14 +201,18 @@ if not exist tg\data\m01tg.txt (goto filemiss2)
if not exist tg\data\m01type.csv (goto filemiss2)
@ECHO.
@ECHO -- OBTAINING TRANSIT NETWORK DATA FROM EMME --
call python prep_macros/distr_m01_data.py %file1% %val% >> prep_macros\report.txt
uv run prep_macros/distr_m01_data.py %file1% %val% >> prep_macros\report.txt
if %ERRORLEVEL% GTR 0 (goto issue)
cd prep_macros
@ECHO.
@ECHO -- CREATING FILES FOR SPATIAL ANALYSIS --
@ECHO.
%rpath% CMD BATCH %rfile%.R
rem Activate R env
call %LOCALAPPDATA%\miniconda3\condabin\conda_hook.bat
call conda activate tbm-r
Rscript create_distr_m01_files.R
if %ERRORLEVEL% GTR 0 (goto issue)
call conda deactivate

@ECHO.
@ECHO -- DISTR AND M01 FILES CREATED --
Expand All @@ -240,32 +223,21 @@ if exist temp\nul (rmdir temp /S /Q)
if exist report.txt (del report.txt /Q)
CD ..

rem Activate Python env to build it if necessary
call %~dp0..\Scripts\manage\env\activate_env.cmd
if "%srcCode%" EQU "T" (
@ECHO -- Ensure CMAP-TRIP2 uses the destination choice-mode choice source code in this model setup --
python -m pip install -e %~dp0..\src\Mode-Dest-TOD
python -m pip install -e %~dp0..\src\Mode-Dest-TOD\sharrow
)

rem Activate Emme Python env
call %~dp0..\Scripts\manage\env\activate_env.cmd emme

@ECHO *** Cleaning up databank. ***
if exist cleanup.rpt (del cleanup.rpt)
call python useful_macros\cleanup_for_rerun.py %val%>> cleanup.rpt
uv run useful_macros\cleanup_for_rerun.py %val%>> cleanup.rpt
if exist reports (del reports)

REM RUN FREESKIM TO CREATE TIME, DISTANCE AND TOLL MATRICES
@ECHO.
@ECHO *** Skimming highway network. ***
call python prep_macros\free.skim.mac.py %file1% %val%
uv run prep_macros\free.skim.mac.py %file1% %val%
if %ERRORLEVEL% neq 0 (goto issue)
@ECHO.

REM IF PRELOAD=1, REPLACE UNCONGESTED TIME AND DISTANCE MATRICES
if %preload% EQU 1 (@echo *** Preloading congested times and distances. ***)
if %preload% EQU 1 (call python prep_macros\preload_congested_times_mac.py %file1% %val%)
if %preload% EQU 1 (uv run prep_macros\preload_congested_times_mac.py %file1% %val%)

@ECHO ==================================================================
REM - LOOP TO RUN MODEL
Expand All @@ -277,47 +249,43 @@ if %counter% GTR 2 (goto loopend)
@ECHO BEGINNING TRANSIT SKIM - FULL MODEL ITERATION %counter%
@ECHO - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM AM Peak Skim
call python macros/skim_transit.py %val% %counter% AM
uv run macros/skim_transit.py %val% %counter% AM
if %ERRORLEVEL% neq 0 (goto issue)
call python macros/transit_triple_indexing.py %val% AM
uv run macros/transit_triple_indexing.py %val% AM
if %ERRORLEVEL% neq 0 (goto issue)
call python macros/transit_skim_final_matrices.py AM
uv run macros/transit_skim_final_matrices.py AM
if %ERRORLEVEL% neq 0 (goto issue)
call python macros/transit_skim_wrapup.py AM
uv run macros/transit_skim_wrapup.py AM
if %ERRORLEVEL% neq 0 (goto issue)
REM Midday Skim
call python macros/skim_transit.py %val% %counter% MD
uv run macros/skim_transit.py %val% %counter% MD
if %ERRORLEVEL% neq 0 (goto issue)
call python macros/transit_triple_indexing.py %val% MD
uv run macros/transit_triple_indexing.py %val% MD
if %ERRORLEVEL% neq 0 (goto issue)
call python macros/transit_skim_final_matrices.py MD
uv run macros/transit_skim_final_matrices.py MD
if %ERRORLEVEL% neq 0 (goto issue)
call python macros/transit_skim_wrapup.py MD
uv run macros/transit_skim_wrapup.py MD
if %ERRORLEVEL% neq 0 (goto issue)
@ECHO -- End of Transit Skim Procedures: %date% %time% >> model_run_timestamp.txt

@ECHO Begin Global Iteration %counter%: %date% %time% >> model_run_timestamp.txt
@ECHO PREPARING EMMEBANK - FULL MODEL ITERATION %counter%
@ECHO - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
rem @ECHO on
call python macros\init_HOVsim_databk_mac.py %val% %counter% %file1%
uv run macros\init_HOVsim_databk_mac.py %val% %counter% %file1%
if %ERRORLEVEL% neq 0 (goto issue)

rem Activate Python env
call %~dp0..\Scripts\manage\env\activate_env.cmd

@ECHO -- Begin Mode-Destination Choice Procedures: %date% %time% >> model_run_timestamp.txt
@ECHO.
@ECHO RUN CMAP MODE-DESTINATION CHOICE MODEL - FULL MODEL ITERATION %counter%
@ECHO - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
call cmap_modedest . --njobs %jobs% --max_zone_chunk %zones%
call conda activate cmap-modedest
cmap_modedest . --njobs %jobs% --max_zone_chunk %zones%
if %ERRORLEVEL% NEQ 0 (goto issue)
call conda deactivate
@ECHO -- End Mode-Destination Choice Procedures: %date% %time% >> model_run_timestamp.txt
@ECHO.

rem Activate Emme Python env
call %~dp0..\Scripts\manage\env\activate_env.cmd emme

@ECHO -- Begin Time-of-Day Procedures: %date% %time% >> model_run_timestamp.txt
@ECHO.
@ECHO BEGINNING TOD HIGHWAY ASSIGNMENT - FULL MODEL ITERATION %counter%
Expand All @@ -330,12 +298,12 @@ REM
call emme -ng 000 -m macros\ttables.mac %val% %tod_cntr% 92 93 >> blog.txt
@ECHO --- End ttables.mac Period %tod_cntr%: %date% %time% >> model_run_timestamp.txt
@ECHO --- Begin TOD_network_prep.py Period %tod_cntr%: %date% %time% >> model_run_timestamp.txt
call python macros\TOD_network_prep.py %val% %tod_cntr% %counter% >> blog.txt
uv run macros\TOD_network_prep.py %val% %tod_cntr% %counter% >> blog.txt
@ECHO --- End TOD_network_prep.py Period %tod_cntr%: %date% %time% >> model_run_timestamp.txt
@ECHO --- Begin assignment Period %tod_cntr%: %date% %time% >> model_run_timestamp.txt
@ECHO --- Begin assignment Period %tod_cntr%: %date% %time% ---
@ECHO -- Run TOD assignment --
call python macros/SOLA_assignment.py %tod_cntr% %sola_threads% %counter% %RSPrun% %tempCnt% %selLinkFile% %trnAsmt%
uv run macros/SOLA_assignment.py %tod_cntr% %sola_threads% %counter% %RSPrun% %tempCnt% %selLinkFile% %trnAsmt%
if %ERRORLEVEL% NEQ 0 (goto issue)
@ECHO --- End assignment Period %tod_cntr%: %date% %time% >> model_run_timestamp.txt
@ECHO --- End assignment Period %tod_cntr%: %date% %time% ---
Expand All @@ -345,7 +313,7 @@ call emme -ng 000 -m macros\balance5I_7c.mac %val% >> blog.txt
@ECHO --- End balance5I_7c.mac Period %tod_cntr%: %date% %time% >> model_run_timestamp.txt
@ECHO --- Begin time-of-day skim Period %tod_cntr%: %date% %time% >> model_run_timestamp.txt
@ECHO --- Complete time of day skims ---
call python macros/TOD_skim.py %tod_cntr% %val%%counter%%tod_cntr% %sola_threads%
uv run macros/TOD_skim.py %tod_cntr% %val%%counter%%tod_cntr% %sola_threads%
if %ERRORLEVEL% NEQ 0 (goto issue)
@ECHO -- End Time-of-Day Procedures Period %tod_cntr%: %date% %time% >> model_run_timestamp.txt
@ECHO -- End Time-of-Day Procedures for Period %tod_cntr%: %date% %time% --
Expand All @@ -355,9 +323,9 @@ if %tod_cntr% LSS 9 (goto tod_loop)
REM -- End time-of-day loop --
@ECHO --- Begin Global Iteration MSA skims: %date% %time% >> model_run_timestamp.txt
@ECHO --- Begin Global Iteration MSA skims: %date% %time% ---
call python macros/MSA_iteration_skims.py %file1% 3 %val%%counter%3 %counter% %sola_threads%
uv run macros/MSA_iteration_skims.py %file1% 3 %val%%counter%3 %counter% %sola_threads%
if %ERRORLEVEL% NEQ 0 (goto issue)
call python macros/MSA_iteration_skims.py %file1% 5 %val%%counter%5 %counter% %sola_threads%
uv run macros/MSA_iteration_skims.py %file1% 5 %val%%counter%5 %counter% %sola_threads%
if %ERRORLEVEL% NEQ 0 (goto issue)
@ECHO --- End Global Iteration MSA skims: %date% %time% >> model_run_timestamp.txt
@ECHO --- End Global Iteration MSA skims: %date% %time%
Expand All @@ -380,17 +348,17 @@ REM Run script to complete select link analysis, if necessary
set /A counter=counter-1
if %tempCnt% EQU 0 (goto skip_sel_link)
if %trnAsmt% EQU 1 (goto skip_sel_link)
call python macros/complete_select_link.py %file1% %val%%counter%9 %val%%counter%0 %tempCnt% %RSPrun%
uv run macros/complete_select_link.py %file1% %val%%counter%9 %val%%counter%0 %tempCnt% %RSPrun%
if %ERRORLEVEL% NEQ 0 (goto issue)
:skip_sel_link
@ECHO End Daily Accumulation Procedures: %date% %time% >> model_run_timestamp.txt

REM Run script to write link data for MOVES emissions analysis.
call python post_macros\punchmovesdata.py
uv run post_macros\punchmovesdata.py
@ECHO Link Data Written for MOVES Emissions Analysis: %date% %time% >> model_run_timestamp.txt
call python post_macros\final_run_statistics.py
uv run post_macros\final_run_statistics.py
rem Run script to create input files for MOVES.
call python post_macros\createMOVESinputfile.py
uv run post_macros\createMOVESinputfile.py
if %ERRORLEVEL% NEQ 0 (goto issue)
@echo %DATE% %TIME% - INFO - MOVES files created >> model_run_timestamp.txt

Expand All @@ -403,39 +371,35 @@ if "%utilFile%"=="F" (del cache\choice_simulator_trips_out\choice_simulator_util
:USskim
if "%UrbansimFile%"=="F" (goto skip_UrbanSim)
@ECHO Creating skim file for UrbanSim ...
call python tg\scripts\urbansim_skims.py
uv run tg\scripts\urbansim_skims.py
:skip_UrbanSim

REM The following lines run transit assignment.
if "%transitAsmt%" EQU "T" (
@ECHO Begin Transit Assignment setup: %date% %time% >> model_run_timestamp.txt
REM -- Create matrices to hold TOD transit demand
if "%RSPrun%" EQU "T" (@ECHO -- Creating HBW transit demand matrices >> model_run_timestamp.txt)
call python transit_asmt_macros/setup_transit_asmt_2_initialize_matrices.py %file1% %RSPrun%
uv run transit_asmt_macros/setup_transit_asmt_2_initialize_matrices.py %file1% %RSPrun%
if %ERRORLEVEL% NEQ 0 (goto issue)
REM -- Fill matrices with demand (point to conda environment)
rem Activate Python env
call %~dp0..\Scripts\manage\env\activate_env.cmd
call python transit_asmt_macros\setup_transit_asmt_3_TOD_transit_demand.py %RSPrun%
uv run transit_asmt_macros\setup_transit_asmt_3_TOD_transit_demand.py %RSPrun%
if %ERRORLEVEL% NEQ 0 (goto issue)
@ECHO End Transit Assignment setup >> model_run_timestamp.txt
rem Activate Emme Python env
call %~dp0..\Scripts\manage\env\activate_env.cmd emme
@ECHO Submit Transit Assignment >> model_run_timestamp.txt
cd transit_asmt_macros
call python cmap_transit_assignment_runner.py %file1% 1 %val%
uv run cmap_transit_assignment_runner.py %file1% 1 %val%
if %ERRORLEVEL% GTR 0 (goto issue)
cd ..
REM -- Delete transit assignment matrices
call python transit_asmt_macros\delete_transit_skims.py %file1%
uv run transit_asmt_macros\delete_transit_skims.py %file1%
if %ERRORLEVEL% GTR 0 (goto issue)
if "%check2%" NEQ "None" (
REM -- Run select line analysis
call python transit_asmt_macros\transit_select_line.py %file1% %val% %selLineFile%
uv run transit_asmt_macros\transit_select_line.py %file1% %val% %selLineFile%
if %ERRORLEVEL% GTR 0 (goto issue)
@ECHO -- Completed Select Line Analysis >> model_run_timestamp.txt
REM -- Summarize select line boardings
call python transit_asmt_macros\select_line_boardings.py %file1% %val% %RSPrun% %selLineFile%
uv run transit_asmt_macros\select_line_boardings.py %file1% %val% %RSPrun% %selLineFile%
if %ERRORLEVEL% GTR 0 (goto issue)
@ECHO -- Completed Select Line Boarding Analysis >> model_run_timestamp.txt
)
Expand All @@ -459,18 +423,6 @@ goto end
pause
goto end

:CheckEmpty2
if %~z1 == 0 (goto badR)
goto Rpass

:badR
@ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ECHO COULD NOT FIND R INSTALLATION.
@ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ECHO.
pause
goto end

:mcmiss
@ECHO
@ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 0 additions & 3 deletions Database/batch_file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ util_files: False
UrbanSim_file: False
# ---------------- Is this an RSP evaluation run? Default is False.
RSP: False
# ---------------- sourceCode will force CMAP-TRIP2 to use the source code in this model setup if set to True. Default is True.
# ---------------- Set to False if this is the second of two simultaneous runs being submitted.
sourceCode: False
# ---------------- PUMA version used in Trip Generation. 2010 is the current option.
pumaVersion: 2010

9 changes: 3 additions & 6 deletions Database/build_scenario_networks.bat
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,14 @@ set ok=%ok:y=Y%
if not "%ok%"=="Y" (goto end)
@echo ==================================================================

rem Activate Emme Python env
call %~dp0..\Scripts\manage\env\activate_env.cmd emme

@ECHO --- Cleaning up databank ---
if exist cleanup.rpt (del cleanup.rpt)
call python useful_macros\cleanup_for_rerun.py %val%>> cleanup.rpt
uv run useful_macros\cleanup_for_rerun.py %val%>> cleanup.rpt
if exist reports (del reports)
@ECHO Cleanup complete.

@ECHO --- Creating time-of-day highway and transit networks ---
call python prep_macros\initialize_scenarios.py
uv run prep_macros\initialize_scenarios.py
if %ERRORLEVEL% GTR 0 (goto end)

@ECHO -- Checking for transit network input errors --
Expand All @@ -59,7 +56,7 @@ if exist report\build_transit.error (del report\build_transit.error /Q)

:while
if %trnscen% GTR %maxscen% (goto loopend)
python prep_macros\build_transit_error_check.py %trnscen%
uv run prep_macros\build_transit_error_check.py %trnscen%
if exist report\build_transit.error (goto badnet)
set /A trnscen=%trnscen%+2
goto while
Expand Down
1 change: 0 additions & 1 deletion Database/choice_model_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ HBWL:
intrazonal : 0.02173059479852062
log_attraction : 1.0
metra_longtrip : 5.625
ovtt_dist : -0.076
ovtt_dist : -0.07639147912439262
samp_af : 1.0
totaltime : -0.014712168298471244
Expand Down
Loading