Update app.py
Browse files
app.py
CHANGED
|
@@ -2,10 +2,8 @@ import streamlit as st
|
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
import pulp
|
| 5 |
-
import plotly.graph_objs as go
|
| 6 |
import plotly.express as px
|
| 7 |
import numpy as np
|
| 8 |
-
import matplotlib.pyplot as plt
|
| 9 |
|
| 10 |
# Renewable energy data fetch function
|
| 11 |
def get_renewable_energy_data(city_code):
|
|
@@ -205,13 +203,6 @@ if st.button("Run MGA Optimization"):
|
|
| 205 |
alternative_solutions = optimize_energy_system(city_code, solar_cost, onshore_wind_cost, offshore_wind_cost, river_cost, battery_cost, yearly_demand, solar_range, wind_range, river_range, offshore_wind_range, [t / 100 for t in thresholds], selected_technologies)
|
| 206 |
|
| 207 |
if alternative_solutions:
|
| 208 |
-
# Cost breakdown visualization
|
| 209 |
-
cost_data = [{'threshold': sol['threshold'] * 100, 'type': sol['type'], 'technology': sol['technology'], 'total_cost': sol['total_cost']} for sol in alternative_solutions]
|
| 210 |
-
cost_df = pd.DataFrame(cost_data)
|
| 211 |
-
fig_cost = px.bar(cost_df, x='threshold', y='total_cost', color='technology', title="Cost Breakdown by Technology and Threshold")
|
| 212 |
-
fig_cost.update_layout(xaxis_title='Threshold (%)', yaxis_title='Total Cost (¥)')
|
| 213 |
-
st.plotly_chart(fig_cost, use_container_width=True)
|
| 214 |
-
|
| 215 |
# Display capacity distribution using violin plots
|
| 216 |
fig_violin = plot_capacity_distribution(alternative_solutions, selected_technologies)
|
| 217 |
st.plotly_chart(fig_violin, use_container_width=True)
|
|
|
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
import pulp
|
|
|
|
| 5 |
import plotly.express as px
|
| 6 |
import numpy as np
|
|
|
|
| 7 |
|
| 8 |
# Renewable energy data fetch function
|
| 9 |
def get_renewable_energy_data(city_code):
|
|
|
|
| 203 |
alternative_solutions = optimize_energy_system(city_code, solar_cost, onshore_wind_cost, offshore_wind_cost, river_cost, battery_cost, yearly_demand, solar_range, wind_range, river_range, offshore_wind_range, [t / 100 for t in thresholds], selected_technologies)
|
| 204 |
|
| 205 |
if alternative_solutions:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
# Display capacity distribution using violin plots
|
| 207 |
fig_violin = plot_capacity_distribution(alternative_solutions, selected_technologies)
|
| 208 |
st.plotly_chart(fig_violin, use_container_width=True)
|