@@ -400,7 +400,7 @@ def parse_syswide_variables(
400400 return cur_syswide_vars
401401
402402
403- def parse_lmp (lmp : dict [str , float ], sim_horizon : int , step_k : int ) -> pd .DataFrame :
403+ def parse_lmp (lmp : dict [str , float ], sim_horizon : int , step_k : int = None ) -> pd .DataFrame :
404404 """Parse the LMP dictionary and return a DataFrame.
405405
406406 Args:
@@ -415,12 +415,27 @@ def parse_lmp(lmp: dict[str, float], sim_horizon: int, step_k: int) -> pd.DataFr
415415 lmp_df = lmp_df .reset_index ().rename (columns = {"index" : "name" })
416416 lmp_df [["node" , "timestep" ]] = lmp_df ["name" ].str .extract (r"flowBal\[(.*),(\d+)\]" )
417417 lmp_df ["timestep" ] = lmp_df ["timestep" ].astype (int )
418- lmp_df ["hour" ] = lmp_df ["timestep" ] + sim_horizon * (step_k - 1 )
418+
419+ if step_k is not None :
420+ lmp_df ["hour" ] = lmp_df ["timestep" ] + sim_horizon * (step_k - 1 )
421+
422+ # TODO: Block vs. Rolling horizon
419423 # Keep only the first 24-hours of the simulation
420424 lmp_df = lmp_df [lmp_df ["timestep" ] <= 24 ]
421425 lmp_df = lmp_df .drop (["name" ], axis = 1 )
422426 return lmp_df
423427
428+ def parse_lmp_dict (lmp : dict [str , float ]) -> dict [tuple [str , int ], float ]:
429+ lmp_df = pd .DataFrame .from_dict (lmp , orient = "index" , columns = ["value" ])
430+ lmp_df = lmp_df .reset_index ().rename (columns = {"index" : "name" })
431+ lmp_df [["node" , "timestep" ]] = lmp_df ["name" ].str .extract (r"flowBal\[(.*),(\d+)\]" )
432+ # Create a dict of tuples (node, timestep) as keys and LMP values as values
433+ lmp_dict = {
434+ (row ["node" ], int (row ["timestep" ])): row ["value" ]
435+ for _ , row in lmp_df .iterrows ()
436+ }
437+ return lmp_dict
438+
424439
425440def get_fuel_mix_order () -> list [str ]:
426441 """Return the order of fuel mix for plotting.
0 commit comments