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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -1
app.py CHANGED
@@ -160,6 +160,85 @@ def optimize_energy_system(city_code, solar_cost, onshore_wind_cost, offshore_wi
160
  st.set_page_config(page_title='Renewable Energy System Optimization with MGA', layout='wide')
161
  st.title('Renewable Energy System Optimization with MGA')
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  # Sidebar Inputs
164
  with st.sidebar:
165
  st.header('Input Parameters')
@@ -174,7 +253,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 (%)", 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'])
 
160
  st.set_page_config(page_title='Renewable Energy System Optimization with MGA', layout='wide')
161
  st.title('Renewable Energy System Optimization with MGA')
162
 
163
+ # MGA Explanation Section
164
+ st.markdown("""
165
+ # Modeling to Generate Alternatives (MGA) in Renewable Energy System Optimization
166
+
167
+ This application uses **Modeling to Generate Alternatives (MGA)** to explore near-optimal solutions in a renewable energy system model. MGA helps to identify alternative configurations that are close to the optimal solution but vary in their specific technological composition, providing flexibility for policy makers and stakeholders who might prioritize factors beyond cost minimization, such as social acceptance or regional preferences.
168
+
169
+ ## Objective Function and Cost Minimization
170
+
171
+ In our renewable energy model, the **objective function** is to minimize the total annual cost of the system, which includes the costs of installing renewable generation capacities (such as solar, wind, and hydroelectric) and storage (batteries). The objective function is defined as:
172
+
173
+ \\[
174
+ \\text{Minimize } \\quad \\sum_{r, g} \\text{Cost}_{g} \\times \\text{Capacity}_{r, g} + \\text{Battery Cost} \\times \\text{Battery Capacity}
175
+ \\]
176
+
177
+ where:
178
+ - \\( r \\) represents the region (in this case, a single region),
179
+ - \\( g \\) represents the generation technology (solar, onshore wind, offshore wind, river),
180
+ - \\( \\text{Cost}_{g} \\) is the per-MW cost of technology \\( g \\),
181
+ - \\( \\text{Capacity}_{r, g} \\) is the installed capacity of technology \\( g \\) in region \\( r \\),
182
+ - \\( \\text{Battery Cost} \\) represents the cost per MWh of battery storage,
183
+ - \\( \\text{Battery Capacity} \\) is the total installed battery capacity.
184
+
185
+ The goal is to find the configuration that minimizes the total cost while meeting the energy demand over time.
186
+
187
+ ## What is MGA and Why is it Important?
188
+
189
+ Typically, optimization models produce a **single optimal solution** that minimizes the cost under a given set of constraints. However, in many real-world applications, there are **multiple near-optimal solutions** that achieve similar costs but vary in other characteristics. This diversity is valuable because:
190
+ - **Flexibility**: Different solutions might be preferable depending on policy objectives, geographic constraints, or social preferences.
191
+ - **Robustness**: Exploring near-optimal solutions reveals which elements (e.g., specific technologies or infrastructure investments) are consistently essential, regardless of slight variations in cost.
192
+
193
+ MGA addresses this need by generating **alternative solutions** that are close to the optimal cost but differ in technological composition.
194
+
195
+ ## How MGA Works: Adding a Cost Constraint
196
+
197
+ To generate alternatives, MGA introduces a **cost tolerance** parameter \\( \\epsilon \\), which represents the acceptable increase in total cost relative to the optimal solution. The cost constraint for alternative solutions is expressed as:
198
+
199
+ \\[
200
+ \\text{Total Cost} \\leq (1 + \\epsilon) \\times \\text{Optimal Cost}
201
+ \\]
202
+
203
+ where:
204
+ - \\( \\epsilon \\) is the cost deviation percentage (e.g., if \\( \\epsilon = 0.05 \\), then the solution can be up to 5% more expensive than the optimal cost),
205
+ - \\( \\text{Optimal Cost} \\) is the minimum cost obtained from the initial optimization.
206
+
207
+ This constraint allows for flexibility in cost, enabling the exploration of solutions that are **near-optimal** but differ in terms of installed capacities for each technology.
208
+
209
+ ### MGA Process in This Application
210
+
211
+ 1. **Initial Optimization**: First, we solve for the optimal solution to obtain the minimal total cost, referred to as \\( \\text{Optimal Cost} \\).
212
+ 2. **Setting the Cost Threshold**: We introduce a range of \\( \\epsilon \\) values (0%, 5%, 10%, etc.) to explore how alternative solutions differ as we allow for higher costs.
213
+ 3. **Minimizing and Maximizing Capacities**: For each selected technology (e.g., solar, wind, hydro), we attempt to:
214
+ - **Minimize the installed capacity** within the allowed cost threshold, identifying configurations with the lowest feasible capacity for that technology.
215
+ - **Maximize the installed capacity** under the same conditions, exploring configurations with higher reliance on that technology.
216
+
217
+ These steps generate a set of **alternative solutions** that are close in cost but vary significantly in their reliance on each technology, revealing **flexibility** and **trade-offs** in the renewable energy system configuration.
218
+
219
+ ## Interpreting the Cost Threshold (\\( \\epsilon \\))
220
+
221
+ The cost threshold parameter \\( \\epsilon \\) is crucial in MGA, as it determines the range within which we consider solutions to be "near-optimal." For example:
222
+ - **\\( \\epsilon = 0 \\%**: Only the exact optimal solution is considered.
223
+ - **\\( \\epsilon = 5 \\%**: Solutions within 5% of the optimal cost are considered acceptable, allowing for slightly more flexibility in technology choice.
224
+ - **\\( \\epsilon = 10 \\%**: Solutions within 10% of the optimal cost are allowed, providing even greater flexibility.
225
+
226
+ By exploring a range of \\( \\epsilon \\) values, we can see how the system configuration changes as we relax the cost constraint, offering a broader view of feasible solutions.
227
+
228
+ ## Visualization of Results
229
+
230
+ - **Cost Breakdown**: The total cost of each solution, broken down by technology, helps us see the contribution of each technology to the total cost.
231
+ - **Capacity Ranges**: For each technology, we plot the minimum and maximum capacities across different \\( \\epsilon \\) values, showing the flexibility in system design as cost thresholds change.
232
+
233
+ This visualization provides insights into:
234
+ - Which technologies are essential (appear consistently in solutions across all \\( \\epsilon \\) values),
235
+ - Which technologies offer flexibility (capacities vary widely as \\( \\epsilon \\) increases),
236
+ - The cost impact of relying more or less on specific technologies.
237
+
238
+ Through MGA, we can make more **informed decisions** about the renewable energy mix and identify robust, flexible strategies that align with broader goals beyond cost minimization.
239
+ """)
240
+
241
+
242
  # Sidebar Inputs
243
  with st.sidebar:
244
  st.header('Input Parameters')
 
253
  wind_range = st.slider("Onshore Wind Capacity Range (MW)", 0, 10000, (0, 10000))
254
  offshore_wind_range = st.slider("Offshore Wind Capacity Range (MW)", 0, 10000, (0, 10000))
255
  river_range = st.slider("River Capacity Range (MW)", 0, 10000, (0, 10000))
256
+ thresholds = st.multiselect("Select MGA Cost Deviation Thresholds (%)", list(range(0, 1.01, 0.1)), default=[0, 0.5, 1])
257
 
258
  # 技術の選択オプション
259
  selected_technologies = st.multiselect("Select Technologies to Optimize", ['solar', 'onshore_wind', 'offshore_wind', 'river'], default=['solar', 'onshore_wind', 'offshore_wind', 'river'])