naohiro701 commited on
Commit
64ab041
·
verified ·
1 Parent(s): ebece77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -18
app.py CHANGED
@@ -174,7 +174,7 @@ with st.sidebar:
174
  wind_range = st.slider("Onshore Wind Capacity Range (MW)", 0, 10000, (0, 10000))
175
  offshore_wind_range = st.slider("Offshore Wind Capacity Range (MW)", 0, 10000, (0, 10000))
176
  river_range = st.slider("River Capacity Range (MW)", 0, 10000, (0, 10000))
177
- thresholds = st.multiselect("Select MGA Cost Deviation Thresholds (%)", [0.5, 1, 2, 3, 5, 7.5, 10], default=[0.5, 1, 5])
178
 
179
  # 技術の選択オプション
180
  selected_technologies = st.multiselect("Select Technologies to Optimize", ['solar', 'onshore_wind', 'offshore_wind', 'river'], default=['solar', 'onshore_wind', 'offshore_wind', 'river'])
@@ -202,9 +202,16 @@ if st.button("Run MGA Optimization"):
202
  # Streamlitでコスト積み上げグラフを表示
203
  st.plotly_chart(fig_cost, use_container_width=True)
204
 
205
- # 各しきい値ごとの技術ごとの容量の範囲を表示
 
 
 
 
 
 
 
 
206
  epsilon_values = sorted(list(set(sol['threshold'] * 100 for sol in alternative_solutions)))
207
- fig, ax = plt.subplots()
208
 
209
  for tech in selected_technologies:
210
  storage_min = []
@@ -213,18 +220,19 @@ if st.button("Run MGA Optimization"):
213
  capacities = [sol['solution'][tech] for sol in alternative_solutions if sol['technology'] == tech and sol['threshold'] * 100 == epsilon]
214
  storage_min.append(min(capacities))
215
  storage_max.append(max(capacities))
216
-
217
- # 塗りつぶし範囲とラインプロット
218
- ax.fill_between(epsilon_values, storage_min, storage_max, alpha=0.3, label=f"{tech} range")
219
- ax.plot(epsilon_values, storage_min, marker='o', linestyle='-', label=f"{tech} Min")
220
- ax.plot(epsilon_values, storage_max, marker='o', linestyle='-', label=f"{tech} Max")
221
-
222
- # ラベルとタイトル
223
- ax.set_xlabel(r'$\epsilon$ [%]')
224
- ax.set_ylabel('Capacity [GW]')
225
- ax.set_title('Capacity Ranges for Each Technology')
226
- ax.legend()
227
- ax.grid(True, linestyle='--', alpha=0.7)
228
-
229
- # Streamlitにプロットを表示
230
- st.pyplot(fig)
 
 
174
  wind_range = st.slider("Onshore Wind Capacity Range (MW)", 0, 10000, (0, 10000))
175
  offshore_wind_range = st.slider("Offshore Wind Capacity Range (MW)", 0, 10000, (0, 10000))
176
  river_range = st.slider("River Capacity Range (MW)", 0, 10000, (0, 10000))
177
+ thresholds = st.multiselect("Select MGA Cost Deviation Thresholds (%)", list(range(0, 101, 10)), default=[0, 50, 100])
178
 
179
  # 技術の選択オプション
180
  selected_technologies = st.multiselect("Select Technologies to Optimize", ['solar', 'onshore_wind', 'offshore_wind', 'river'], default=['solar', 'onshore_wind', 'offshore_wind', 'river'])
 
202
  # Streamlitでコスト積み上げグラフを表示
203
  st.plotly_chart(fig_cost, use_container_width=True)
204
 
205
+ # 各技術ごとに異なる色を指定
206
+ colors = {
207
+ 'solar': 'gold',
208
+ 'onshore_wind': 'skyblue',
209
+ 'offshore_wind': 'lightgreen',
210
+ 'river': 'salmon'
211
+ }
212
+
213
+ # 各技術の容量範囲を個別のグラフで表示
214
  epsilon_values = sorted(list(set(sol['threshold'] * 100 for sol in alternative_solutions)))
 
215
 
216
  for tech in selected_technologies:
217
  storage_min = []
 
220
  capacities = [sol['solution'][tech] for sol in alternative_solutions if sol['technology'] == tech and sol['threshold'] * 100 == epsilon]
221
  storage_min.append(min(capacities))
222
  storage_max.append(max(capacities))
223
+
224
+ # 各技術ごとにグラフ作成
225
+ fig, ax = plt.subplots()
226
+ ax.fill_between(epsilon_values, storage_min, storage_max, color=colors[tech], alpha=0.3, label=f"{tech} range")
227
+ ax.plot(epsilon_values, storage_min, marker='o', color=colors[tech], linestyle='-', linewidth=1.5, label=f"{tech} Min")
228
+ ax.plot(epsilon_values, storage_max, marker='o', color=colors[tech], linestyle='-', linewidth=1.5, label=f"{tech} Max")
229
+
230
+ # ラベルとタイトル
231
+ ax.set_xlabel(r'$\epsilon$ [%]')
232
+ ax.set_ylabel(f'{tech.capitalize()} Capacity [GW]')
233
+ ax.set_title(f'Capacity Range for {tech.capitalize()}')
234
+ ax.legend()
235
+ ax.grid(True, linestyle='--', alpha=0.7)
236
+
237
+ # Streamlitに各技術のプロットを表示
238
+ st.pyplot(fig)