Update app.py
Browse files
app.py
CHANGED
|
@@ -174,9 +174,32 @@ with st.sidebar:
|
|
| 174 |
thresholds = st.multiselect("Select MGA Cost Deviation Thresholds (%)", [0.5, 1, 2, 3, 5, 7.5, 10], default=[0.5, 1, 5])
|
| 175 |
|
| 176 |
if st.button("Run MGA Optimization"):
|
|
|
|
| 177 |
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])
|
|
|
|
| 178 |
if alternative_solutions:
|
| 179 |
-
|
| 180 |
-
for sol in alternative_solutions
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
thresholds = st.multiselect("Select MGA Cost Deviation Thresholds (%)", [0.5, 1, 2, 3, 5, 7.5, 10], default=[0.5, 1, 5])
|
| 175 |
|
| 176 |
if st.button("Run MGA Optimization"):
|
| 177 |
+
# 実行して alternative_solutions を取得
|
| 178 |
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])
|
| 179 |
+
|
| 180 |
if alternative_solutions:
|
| 181 |
+
# 各しきい値ごとの最小と最大のバッテリー容量を収集
|
| 182 |
+
epsilon_values = sorted(list(set(sol['threshold'] * 100 for sol in alternative_solutions)))
|
| 183 |
+
storage_min = []
|
| 184 |
+
storage_max = []
|
| 185 |
+
|
| 186 |
+
for epsilon in epsilon_values:
|
| 187 |
+
capacities = [sol['battery_capacity'] for sol in alternative_solutions if sol['threshold'] * 100 == epsilon]
|
| 188 |
+
storage_min.append(min(capacities))
|
| 189 |
+
storage_max.append(max(capacities))
|
| 190 |
+
|
| 191 |
+
# 可視化
|
| 192 |
+
fig, ax = plt.subplots()
|
| 193 |
+
ax.fill_between(epsilon_values, storage_min, storage_max, color='orange', alpha=0.3) # オレンジ色の塗りつぶし
|
| 194 |
+
ax.plot(epsilon_values, storage_min, marker='o', color='orange', linestyle='-', linewidth=1.5, label='Min Storage') # 最小値ライン
|
| 195 |
+
ax.plot(epsilon_values, storage_max, marker='o', color='orange', linestyle='-', linewidth=1.5, label='Max Storage') # 最大値ライン
|
| 196 |
+
|
| 197 |
+
# ラベルとタイトル
|
| 198 |
+
ax.set_xlabel(r'$\epsilon$ [%]')
|
| 199 |
+
ax.set_ylabel('Storage [GW]')
|
| 200 |
+
ax.set_title('GHG -100%')
|
| 201 |
+
ax.legend()
|
| 202 |
+
ax.grid(True, linestyle='--', alpha=0.7)
|
| 203 |
+
|
| 204 |
+
# Streamlitにプロットを表示
|
| 205 |
+
st.pyplot(fig)
|