Skip to content

Commit

Permalink
consolidate actions, create tp attr before network change eval
Browse files Browse the repository at this point in the history
  • Loading branch information
yueshuaing committed Sep 17, 2024
1 parent e6f5d08 commit f84399e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/settings/log_to_net.csv
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ USECLASS_AM,useclass_AM
USECLASS_MD,useclass_MD
USECLASS_PM,useclass_PM
USECLASS_EV,useclass_EV
LANES,lanes
45 changes: 39 additions & 6 deletions lasso/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,10 @@ def split_log(x):
.rename("operation_history")
.reset_index()
)
action_history_df["operation_final"] = action_history_df.apply(lambda x: Project._final_op(x), axis=1)


link_df = pd.merge(link_df, action_history_df, on=['A', 'B'], how="left")
link_df.drop_duplicates(subset=['A', 'B'], keep="last", inplace=True)
link_df["operation_final"] = link_df.apply(lambda x: Project._final_op(x), axis=1)

if len(node_df) > 0:
action_history_df = (
Expand All @@ -506,9 +507,10 @@ def split_log(x):
.rename("operation_history")
.reset_index()
)
action_history_df["operation_final"] = action_history_df.apply(lambda x: Project._final_op(x), axis=1)

node_df = pd.merge(node_df, action_history_df, on='N', how="left")

node_df = pd.merge(node_df, action_history_df, on=['N'], how="left")
node_df.drop_duplicates(subset=['N'], keep="last", inplace=True)
node_df["operation_final"] = node_df.apply(lambda x: Project._final_op(x), axis=1)

WranglerLogger.info(
"Processed {} Node lines and {} Link lines".format(
Expand Down Expand Up @@ -1080,8 +1082,39 @@ def _process_link_additions(

for x in add_col:
cube_add_df[x] = cube_add_df[x].astype(self.base_roadway_network.links_df[x].dtype)

add_col_final = add_col.copy()
# properties that are split by time period and category
for c in add_col:
if "_" not in c:
continue
# WranglerLogger.debug("Processing Column: {}".format(c))
(
p_base_name,
p_time_period,
p_category,
managed_lane,
) = column_name_to_parts(c, self.parameters)

if p_base_name not in self.parameters.properties_to_split.keys():
continue

if (p_base_name in cube_add_df.columns):
if cube_add_df[p_base_name].equals(cube_add_df[c]):
add_col_final.remove(c)
continue
else:
msg = "Detected different changes for split-property variables on regular roadway links: "
msg += "conflicting \"{}\" values \"{}\", \"{}\"".format(p_base_name, cube_add_df[p_base_name], cube_add_df[c])
WranglerLogger.error(msg)
raise ValueError(msg)

else:
cube_add_df[p_base_name] = cube_add_df[c]
add_col_final.remove(c)
add_col_final.append(p_base_name)

add_link_properties = cube_add_df[add_col].to_dict("records")
add_link_properties = cube_add_df[add_col_final].to_dict("records")

# WranglerLogger.debug("Add Link Properties: {}".format(add_link_properties))
WranglerLogger.debug("{} Links Added".format(len(add_link_properties)))
Expand Down

0 comments on commit f84399e

Please sign in to comment.