Skip to content
Merged
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
7 changes: 3 additions & 4 deletions uam_system_model/Pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,11 @@ def optimize(
cost_level_of_service = quicksum(
di_bar_selected_x[i_non_zero]
/ p_i_bar[i_non_zero]
* m._x_inverse_vars[self.edges[i]]
* m._x_inverse_vars[self.edges[idx]]
* m._theta_uam[i_non_zero]
* self.time_resolution
/ 2
for i_non_zero, i in zip(
range(len(di_bar_selected_x)), non_zero_indices
)
for i_non_zero, idx in enumerate(non_zero_indices)
)
theta_terms = quicksum(
di_bar_selected_x[i_non_zero]
Expand Down
21 changes: 15 additions & 6 deletions uam_system_model/financial_analysis/cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ def analyze(self, df):
round(self.revenue - self.total_opex, 2),
)

def projection(self, years=15, discount_rate=0.08):
def projection(self, years=15, discount_rate=0.08, ax=None):
if ax is None:
fig, ax = plt.subplots(figsize=(8, 5), dpi=300)
else:
fig = ax.figure


rev_by_year = np.full(years, self.revenue)
opex_by_year = np.full(years, self.total_opex)
net_cash_flow = np.concatenate(
Expand All @@ -113,6 +119,8 @@ def projection(self, years=15, discount_rate=0.08):
discounted_cash_flows,
np.cumsum(net_cash_flow),
cum_disc,
fig,
ax,
)

print(f"ROI (undiscounted) ............ : {ROI:.2f}")
Expand All @@ -134,6 +142,8 @@ def _plot_projection(
discounted_cashflow,
cumulative_cash_flow,
cumulative_discounted_cashflow,
fig,
ax,
):
df = pd.DataFrame(
{
Expand All @@ -145,8 +155,6 @@ def _plot_projection(
}
)

fig, ax = plt.subplots(figsize=(8, 5), dpi=300)

ax.bar(
df["Year"],
df["Cash Flow"] / 1e6,
Expand Down Expand Up @@ -277,8 +285,8 @@ def _compute_revenue(self, df):
revenue = df["total_revenue"].sum()
return revenue * self.multiplier

def plot(self):
fig, ax = plt.subplots(ncols=2, figsize=(14, 4), dpi=300)
def plot(self, dpi=300):
fig, ax = plt.subplots(ncols=2, figsize=(14, 4), dpi=dpi)
sns.barplot(
x=["Fleet Aquisition Cost", "Construction Cost", "Land Acquisition Cost"],
y=[
Expand Down Expand Up @@ -314,10 +322,11 @@ def plot(self):
palette=custom_colors,
)
ax[1].set_title("Yearly OPEX", fontsize=24)
ax[1].set(yticks=np.arange(0, 11, 1))
ax[1].set(yticks=np.arange(0, 18, 2))

for i in range(2):
ax[i].set_ylabel("Million ($)")
ax[i].tick_params(axis="x", rotation=45)
ax[i].grid(True, alpha=0.25, linestyle="--", which="both")

return fig, ax
34 changes: 23 additions & 11 deletions uam_system_model/utils/PricingOpSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def get_summary_statistics(self):

return summary_stats

def plot_average_rasm(self, ax=None, dpi=300):
def plot_average_rasm(self, ax=None, ylim=(0, 12), dpi=300):
if ax is None:
fig, ax = plt.subplots(figsize=(6, 4), dpi=dpi)
fig, ax = plt.subplots(figsize=(4, 2.5), dpi=dpi)
else:
fig = ax.figure

Expand All @@ -79,15 +79,19 @@ def plot_average_rasm(self, ax=None, dpi=300):
xlabel="",
ylabel="RASM ($)",
xlim=(0, 48),
title="Average RASM over ODs",
ylim=ylim,
title="Average RASM over Passengers",
)
ax.xaxis.set_major_locator(MultipleLocator(2))
ax.grid(True, linestyle="--", alpha=0.5)

return fig, ax

def plot_rasm_by_od(self, dpi=300):
fig, ax = plt.subplots(figsize=(6, 4), dpi=dpi)
def plot_rasm_by_od(self, ax=None, dpi=300, ylim=(0, 12)):
if ax is None:
fig, ax = plt.subplots(figsize=(6, 4), dpi=dpi)
else:
fig = ax.figure
sns.lineplot(
data=self.policy,
x="passenger_arrival_time_slot",
Expand All @@ -106,15 +110,19 @@ def plot_rasm_by_od(self, dpi=300):
ylabel="RASM ($)",
xlim=(0, 48),
title="Average RASM by ODs",
ylim=ylim,
)
ax.xaxis.set_major_locator(MultipleLocator(2))
ax.grid(True, linestyle="--", alpha=0.5)
ax.legend(bbox_to_anchor=(1.02, 0.85), loc="upper left", borderaxespad=0.0)

return fig, ax

def plot_fare_by_od(self, dpi=300):
fig, ax = plt.subplots(figsize=(6, 4), dpi=dpi)
def plot_fare_by_od(self, ax=None, dpi=300):
if ax is None:
fig, ax = plt.subplots(figsize=(6, 4), dpi=dpi)
else:
fig = ax.figure
sns.lineplot(
data=self.policy,
x="passenger_arrival_time_slot",
Expand All @@ -141,8 +149,11 @@ def plot_fare_by_od(self, dpi=300):

return fig, ax

def plot_revenue_by_od(self, dpi=300):
fig, ax = plt.subplots(figsize=(6, 4), dpi=dpi)
def plot_revenue_by_od(self, ax=None, dpi=300, ylim=(0, 2000)):
if ax is None:
fig, ax = plt.subplots(figsize=(6, 4), dpi=dpi)
else:
fig = ax.figure
sns.lineplot(
data=self.policy,
x="passenger_arrival_time_slot",
Expand All @@ -161,11 +172,12 @@ def plot_revenue_by_od(self, dpi=300):
xlabel="",
ylabel="Revenue ($)",
xlim=(0, 48),
ylim=ylim,
title="Total Revenue by ODs",
)
ax.xaxis.set_major_locator(MultipleLocator(2))
ax.grid(True, linestyle="--", alpha=0.5)
ax.legend(bbox_to_anchor=(1.02, 0.85), loc="upper left", borderaxespad=0.0)
ax.legend(bbox_to_anchor=(1.02, 1), loc="upper left", borderaxespad=0.0)

return fig, ax

Expand Down Expand Up @@ -196,6 +208,6 @@ def plot_uam_share_by_od(self, ax=None, dpi=300):
)
ax.xaxis.set_major_locator(MultipleLocator(2))
ax.grid(True, linestyle="--", alpha=0.5)
ax.legend(bbox_to_anchor=(1.02, 0.85), loc="upper left", borderaxespad=0.0)
ax.legend(bbox_to_anchor=(1.02, 0.95), loc="upper left", borderaxespad=0.0)

return fig, ax
8 changes: 6 additions & 2 deletions uam_system_model/utils/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@


def plot_travel_time(
travel_time_avg, vertiports, ylim=(0, 100), ylabel="TNC Trip Time (min)"
travel_time_avg, vertiports, ax=None, dpi=300, ylim=(0, 100), ylabel="TNC Trip Time (min)"
):
fig, ax = plt.subplots(figsize=(12, 4), ncols=2, dpi=300)
if ax is None:
fig, ax = plt.subplots(figsize=(12, 4), ncols=2, dpi=dpi)
else:
fig = ax.figure

for i in range(1, len(vertiports)):
ax[0].plot(
np.arange(24),
Expand Down
Loading