Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions Database/Submit_Full_Regional_Model_SOLA.bat
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,25 @@ for /f "eol=# skip=1 tokens=2 delims=:" %%z in (batch_file.yaml) do (set ver=%%z
:break0
for /f "eol=# skip=2 tokens=2 delims=:" %%a in (batch_file.yaml) do (set val=%%a & goto break1)
:break1
for /f "eol=# skip=4 tokens=2 delims=:" %%b in (batch_file.yaml) do (set wfhFile=%%b & goto break2)
for /f "eol=# skip=5 tokens=2 delims=:" %%e in (batch_file.yaml) do (set selLinkFile=%%e & goto break2)
:break2
for /f "eol=# skip=5 tokens=2 delims=:" %%c in (batch_file.yaml) do (set wfh=%%c & goto break3)
for /f "eol=# skip=8 tokens=2* delims=:" %%g in (batch_file.yaml) do (set transactFilePath1=%%g & set transactFilePath2=%%h & goto break3)
:break3
for /f "eol=# skip=6 tokens=2 delims=:" %%d in (batch_file.yaml) do (set tc14=%%d & goto break4)
for /f "eol=# skip=10 tokens=2 delims=:" %%f in (batch_file.yaml) do (set transitAsmt=%%f & goto break4)
:break4
for /f "eol=# skip=9 tokens=2 delims=:" %%e in (batch_file.yaml) do (set selLinkFile=%%e & goto break5)
for /f "eol=# skip=12 tokens=2 delims=:" %%i in (batch_file.yaml) do (set selLineFile=%%i & goto break5)
:break5
for /f "eol=# skip=12 tokens=2* delims=:" %%g in (batch_file.yaml) do (set transactFilePath1=%%g & set transactFilePath2=%%h & goto break6)
for /f "eol=# skip=14 tokens=2 delims=:" %%j in (batch_file.yaml) do (set utilFile=%%j & goto break6)
:break6
for /f "eol=# skip=14 tokens=2 delims=:" %%f in (batch_file.yaml) do (set transitAsmt=%%f & goto break7)
for /f "eol=# skip=16 tokens=2 delims=:" %%k in (batch_file.yaml) do (set UrbansimFile=%%k & goto break7)
:break7
for /f "eol=# skip=16 tokens=2 delims=:" %%i in (batch_file.yaml) do (set selLineFile=%%i & goto break8)
for /f "eol=# skip=18 tokens=2 delims=:" %%l in (batch_file.yaml) do (set RSPrun=%%l & goto break8)
:break8
for /f "eol=# skip=18 tokens=2 delims=:" %%j in (batch_file.yaml) do (set utilFile=%%j & goto break9)
for /f "eol=# skip=21 tokens=2 delims=:" %%m in (batch_file.yaml) do (set srcCode=%%m & goto break9)
:break9
for /f "eol=# skip=20 tokens=2 delims=:" %%k in (batch_file.yaml) do (set UrbansimFile=%%k & goto break10)
:break10
for /f "eol=# skip=22 tokens=2 delims=:" %%l in (batch_file.yaml) do (set RSPrun=%%l & goto break11)
:break11
for /f "eol=# skip=25 tokens=2 delims=:" %%m in (batch_file.yaml) do (set srcCode=%%m & goto break12)
:break12

set ver=%ver:~1,5%
set val=%val:~1,3%
set wfhFile=%wfhFile:~1%
set wfh=%wfh:~1%
set tc14=%tc14:~1%
set selLinkFile=%selLinkFile:~1%
set transitAsmt=%transitAsmt:~1,1%
rem Construct complete transit file path
Expand Down Expand Up @@ -96,9 +87,6 @@ cd Database
@echo --- Model Run Settings ---
@echo Conformity version = %ver%
@echo Scenario = %val%
@echo Create WFH validation file = %wfhFile%
@echo Usual WFH share = %wfh%
@echo WFH 1-4 days share = %tc14%
@echo Highway assignment select link files = %selLinkFile%
@echo Location of network transaction files = %transactFilePath%
@echo Run transit assignment = %transitAsmt%
Expand Down
34 changes: 33 additions & 1 deletion Database/Telework.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# ---------------- Work from home module inputs (trip generation) starting year 2025
# ---------------- Work from home module inputs (trip generation)
validationfiles: N
usualwfhpct: 0.0510
tc14pct: 0.1031
# ---------------- New Work from home module inputs (trip generation)
wfhpctlow: 0.143
wfhpctmedium: 0.232
wfhpcthigh: 0.552
declinerate: 0.1
# ---------------- Education portion of WFH workers
# ---------------- Group by high/medium/low WFH rates
# ---------------- 1 for Lower edu level
# ---------------- 2 for Higher edu level
edu:
high:
1: 0.202
2: 0.798
medium:
1: 0.268
2: 0.732
low:
1: 0.305
2: 0.695
# ---------------- Income portion of WFH workers
# ---------------- Group by high/medium/low WFH rates
# ---------------- 1 for Lower income level
# ---------------- 2 for Higher income level
inc:
high:
1: 0.231
2: 0.769
medium:
1: 0.418
2: 0.582
low:
1: 0.353
2: 0.647
15 changes: 10 additions & 5 deletions Database/batch_file.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Project details
model_version: c26q2
scenario_code: 100
# ---------------- Work from home module inputs (trip generation)
validationfiles: N
usualwfhpct: 0.0510
tc14pct: 0.1031
# ---------------- Select link analysis files: provide file name (ex: RSP32_links.txt [stored in Database\Select_Link\]) or use None
# ---------------- Can submit up to 5, comma-separated, any order, no spaces, (ex: None,test4.txt,test1.txt,None,None)
selectLinkFile: None,None,None,None,None
Expand All @@ -25,4 +21,13 @@ RSP: False
# ---------------- 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
pumaVersion: 2010
# ---------------- Scenario number to year
100: 2019
200: 2026
300: 2030
400: 2032
500: 2035
600: 2040
700: 2045
800: 2050
2 changes: 1 addition & 1 deletion Database/build_scenario_networks.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for /f "eol=# skip=1 tokens=2 delims=:" %%z in (batch_file.yaml) do (set ver=%%z
:break0
for /f "eol=# skip=2 tokens=2 delims=:" %%a in (batch_file.yaml) do (set val=%%a & goto break1)
:break1
for /f "eol=# skip=12 tokens=2* delims=:" %%g in (batch_file.yaml) do (set transactFilePath1=%%g & set transactFilePath2=%%h & goto break6)
for /f "eol=# skip=8 tokens=2* delims=:" %%g in (batch_file.yaml) do (set transactFilePath1=%%g & set transactFilePath2=%%h & goto break6)
:break6

set ver=%ver:~1,5%
Expand Down
24 changes: 7 additions & 17 deletions Database/prep_macros/initialize_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
config = yaml.safe_load(lines_without_backslashes)
scen_yr = config['scenario_code'] # e.g., '200'
batchin_path = config['transactionFilePath'] # e.g., M:/catslib/modelprod/c24q2
real_yr = config[scen_yr]

hwy_batchin_dir = os.path.join(batchin_path, 'highway')
trn_batchin_dir = os.path.join(batchin_path, 'transit')
Expand Down Expand Up @@ -392,23 +393,12 @@
## BUILD TRANSIT ASSIGNMENT SCENARIO NETWORKS
#######################

scen_yr = str(scen_yr) #just to ensure it works here - convert to string
scen3_yr4 = {
'100': 2019,
'200': 2025,
'300': 2030,
'400': 2035,
'500': 2040,
'600': 2045,
'700': 2050
}

network_batchin_list = [
#[{transit asmt scenario number}, {transaction file time-of-day suffix}, {name of scenario}]
[int(scen_yr)+21, 1, f'{scen3_yr4[scen_yr]} Night (6pm-6am)'],
[int(scen_yr)+23, 2, f'{scen3_yr4[scen_yr]} AM (6am-9am)'],
[int(scen_yr)+25, 3, f'{scen3_yr4[scen_yr]} Midday (9am-4pm)'],
[int(scen_yr)+27, 4, f'{scen3_yr4[scen_yr]} PM (4pm-6pm)']
[int(scen_yr)+21, 1, f'{real_yr} Night (6pm-6am)'],
[int(scen_yr)+23, 2, f'{real_yr} AM (6am-9am)'],
[int(scen_yr)+25, 3, f'{real_yr} Midday (9am-4pm)'],
[int(scen_yr)+27, 4, f'{real_yr} PM (4pm-6pm)']
]

for asmt_scen in network_batchin_list:
Expand Down Expand Up @@ -799,14 +789,14 @@
copy_scenario(
from_scenario = emmebank.scenario(int(scen_yr)+23),
scenario_id = int(scen_yr)+3,
scenario_title = f'{scen3_yr4[scen_yr]} am (6am-9am) transit skim network - {today}',
scenario_title = f'{real_yr} am (6am-9am) transit skim network - {today}',
copy_linkshapes=True,
overwrite=True
)
copy_scenario(
from_scenario = emmebank.scenario(int(scen_yr)+25),
scenario_id = int(scen_yr)+5,
scenario_title = f'{scen3_yr4[scen_yr]} midday (9am-4pm) transit skim network - {today}',
scenario_title = f'{real_yr} midday (9am-4pm) transit skim network - {today}',
copy_linkshapes=True,
overwrite=True
)
Expand Down
16 changes: 9 additions & 7 deletions Database/tg/fortran/wfhmodule/incdist.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
wfhgroup,hhinc2,pct
high,1,0.231
high,2,0.769
medium,1,0.418
medium,2,0.582
low,1,0.353
low,2,0.647
incdist,hhinc4,pct
high,1,0.038985164
high,2,0.080435697
high,3,0.156394004
high,4,0.724185136
low,1,0.09287371
low,2,0.134953622
low,3,0.238871815
low,4,0.533300852
9 changes: 0 additions & 9 deletions Database/tg/fortran/wfhmodule/incdist_base.csv

This file was deleted.

60 changes: 25 additions & 35 deletions Database/tg/fortran/wfhmodule/wfhflag.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
# this flags tbm people as usualwfh or tc14
import pandas as pd
import numpy as np
from pathlib import Path
import yaml
import sys
import os

# Current trip_gen.bat
# python wfhflag.py %filedir% %savedir% %wfhFile% %wfh% %tc14%

# Adj trip_gen.bat
# python wfhflag.py %filedir% %savedir% %wfhFile% %wfhl% %wfhm% %wfhh%

# pathways
savedir = sys.argv[2]
assert os.path.exists(savedir) == True, "savedir not valid"
Expand All @@ -22,24 +18,39 @@
indpxwalkpath = "indp_naics.csv"
geoinpath = savedir + "/GEOG_IN.TXT"

#telework worker distribution by income, edu level and children
incdistpath = "incdist.csv"
edudistpath = "edudist.csv"
db = Path(__file__).resolve().parents[3] # database folder
with open(os.path.join(db, 'Telework.yaml')) as f:
lines_without_backslashes = ''.join([line.replace('\\','/') for line in f])
wfh_data = yaml.safe_load(lines_without_backslashes)

with open(os.path.join(db, 'batch_file.yaml')) as f:
lines_without_backslashes = ''.join([line.replace('\\','/') for line in f])
batch_data = yaml.safe_load(lines_without_backslashes)

# save additional output files?
savefiles = sys.argv[3]

# major parameters - source: mdt + nirpc survey (which is higher than PUMS data...)
# percent of all workers
scen_yr = batch_data['scenario_code']
real_yr = batch_data[scen_yr]

''' This data will be separated from batch_file.yaml to Telework.yaml including Tuesday-Thursday telework rates'''
# Assume decline_rate from 2026 to 2050,
decline_rate = wfh_data['declinerate']

wfhl = float(sys.argv[4])
wfhm = float(sys.argv[5])
wfhh = float(sys.argv[6])
# Based on year gap calculate the adjust rate from 2026 to scenaior year
scen_yr_adj_rate = 1 - (real_yr-2026)/(2050-2026) * decline_rate
print('Telework decline rate applied: {0:.4f}'.format(scen_yr_adj_rate))
wfhl = wfh_data['wfhpctlow'] * scen_yr_adj_rate
wfhm = wfh_data['wfhpctmedium'] * scen_yr_adj_rate
wfhh = wfh_data['wfhpcthigh'] * scen_yr_adj_rate

# Combine to list for easy loop process
wfhpctlist = [wfhl, wfhm, wfhh]

# Read income and eduction portion for different WFH rate group from YAML file
incdist_dict = wfh_data['inc']
edudist_dict = wfh_data['edu']

# set seedvalue
seedvalue = 2
np.random.seed(seed=seedvalue)
Expand All @@ -49,10 +60,6 @@
dfhh = pd.read_csv(synhhpath, dtype={'MV': object})
indpxwalk = pd.read_csv(indpxwalkpath)

# Need to change if plan to get data from Telework.yaml
incdist = pd.read_csv(incdistpath)
edudist = pd.read_csv(edudistpath)

# merge income2, edu2, trc get workers
dfpop = dfpop.merge(indpxwalk, on='INDP', how='left')
dfpop = dfpop.merge(dfhh[['household_id', 'HINCP19']], on='household_id', how='left')
Expand All @@ -69,23 +76,6 @@
workers.loc[:, 'selected'] = 0
workers = workers[workers['ESR'] != '4']

# telework distribution
inc_values = incdist.iloc[:, 2].astype(float).tolist()
edu_values = edudist.iloc[:, 2].astype(float).tolist()

# organize into dicts for easier access
incdist_dict = {
"high": {1: inc_values[0], 2: inc_values[1]},
"medium": {1: inc_values[2], 2: inc_values[3]},
"low": {1: inc_values[4], 2: inc_values[5]},
}

edudist_dict = {
"high": {1: edu_values[0], 2: edu_values[1]},
"medium": {1: edu_values[2], 2: edu_values[3]},
"low": {1: edu_values[4], 2: edu_values[5]},
}

def samplingworkers(df, wfhpctlist):
df = df.copy()

Expand Down
15 changes: 10 additions & 5 deletions Database/tg/fortran/wfhmodule/wfhflag_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# this flags tbm people as usualwfh or tc14
import pandas as pd
import numpy as np
from pathlib import Path
import yaml
import sys
import os

Expand All @@ -13,17 +15,20 @@
synpoppath = "synthetic_persons.zip"
synhhpath = "synthetic_households.zip"
popsynhhpath = savedir + "/POPSYN_HH.csv"
incdistpath = "incdist_base.csv"
incdistpath = "incdist.csv"
indmixpath = "indusmix.csv"
indpxwalkpath = "indp_naics.csv"

db = Path(__file__).resolve().parents[3] # database folder
with open(os.path.join(db, 'Telework.yaml')) as f:
lines_without_backslashes = ''.join([line.replace('\\','/') for line in f])
wfh_data = yaml.safe_load(lines_without_backslashes)
# save additional output files?
savefiles = sys.argv[3]

# major parameters - source: mdt + nirpc survey (which is higher than PUMS data...)
# percent of all workers
usualwfhpct = float(sys.argv[4])
tc14pct = float(sys.argv[5])
# Read WFH data from YAML file
usualwfhpct = wfh_data['usualwfhpct']
tc14pct = wfh_data['tc14pct']

# set seedvalue
seedvalue = 2
Expand Down
6 changes: 3 additions & 3 deletions Database/transit_asmt_macros/create_transit_demand.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ cd ..
rem -- Read model run settings from batch_file.yaml --
for /f "eol=# skip=2 tokens=2 delims=:" %%a in (batch_file.yaml) do (set val=%%a & goto break1)
:break1
for /f "eol=# skip=14 tokens=2 delims=:" %%f in (batch_file.yaml) do (set transitAsmt=%%f & goto break2)
for /f "eol=# skip=10 tokens=2 delims=:" %%f in (batch_file.yaml) do (set transitAsmt=%%f & goto break2)
:break2
for /f "eol=# skip=16 tokens=2 delims=:" %%h in (batch_file.yaml) do (set selLineFile=%%h & goto break4)
for /f "eol=# skip=12 tokens=2 delims=:" %%h in (batch_file.yaml) do (set selLineFile=%%h & goto break4)
:break4
for /f "eol=# skip=22 tokens=2 delims=:" %%k in (batch_file.yaml) do (set RSPrun=%%k & goto break5)
for /f "eol=# skip=18 tokens=2 delims=:" %%k in (batch_file.yaml) do (set RSPrun=%%k & goto break5)
:break5

set val=%val:~1,3%
Expand Down
Loading