A Mathematical Approach
Energy supply diversification is a critical challenge in modern energy planning. Today, we’ll explore how to mathematically optimize the mix of different energy sources to meet demand while minimizing costs and environmental impact. Let’s dive into a concrete example using Python optimization techniques.
Problem Setup
Imagine a utility company that needs to meet a daily energy demand of 1000 MWh. They have access to five different energy sources:
- Coal Power Plant: Low cost but high emissions
- Natural Gas: Medium cost and emissions
- Nuclear: High upfront cost but low emissions
- Solar: Variable cost, zero emissions, limited by capacity
- Wind: Variable cost, zero emissions, weather dependent
Our objective is to minimize the total cost while satisfying environmental constraints and capacity limitations.
Mathematical Formulation
The optimization problem can be formulated as:
$$\min \sum_{i=1}^{n} c_i x_i$$
Subject to:
- $\sum_{i=1}^{n} x_i = D$ (demand constraint)
- $\sum_{i=1}^{n} e_i x_i \leq E_{max}$ (emission constraint)
- $0 \leq x_i \leq Cap_i$ (capacity constraints)
Where:
- $x_i$ = energy output from source $i$ (MWh)
- $c_i$ = cost per MWh for source $i$
- $e_i$ = emissions per MWh for source $i$
- $D$ = total demand (MWh)
- $E_{max}$ = maximum allowed emissions
- $Cap_i$ = capacity limit for source $i$
1 | import numpy as np |
Code Walkthrough and Technical Deep Dive
Let me break down the key components of this optimization solution:
1. Problem Formulation
The code begins by defining our energy sources with their respective characteristics. Each source has three critical parameters:
- Cost coefficient ($c_i$): The price per MWh generated
- Emission factor ($e_i$): Environmental impact per MWh
- Capacity limit ($Cap_i$): Maximum generation capacity
2. Linear Programming Setup
We use scipy.optimize.linprog to solve this as a linear programming problem. The mathematical formulation translates to:
1 | # Objective: minimize total cost |
3. Constraint Handling
The optimization respects three types of constraints:
- Equality constraint: $\sum x_i = 1000$ (must meet exact demand)
- Inequality constraint: $\sum e_i x_i \leq 400$ (emission limit)
- Box constraints: $0 \leq x_i \leq Cap_i$ (capacity bounds)
4. Sensitivity Analysis
The code performs a comprehensive sensitivity analysis by varying the emission limit from 200 to 600 tons CO2. This reveals the trade-off frontier between cost and environmental impact:
$$\text{Trade-off}: \frac{\partial \text{Cost}}{\partial \text{Emission Limit}} = \text{Shadow Price}$$
5. Risk Assessment
The risk analysis simulates failure scenarios by setting each source’s capacity to zero sequentially. This helps identify:
- Critical sources: Those whose failure causes largest cost increases
- System resilience: Whether demand can still be met
- Diversification benefits: How spreading risk across sources helps
Key Results and Insights
============================================================
ENERGY SUPPLY DIVERSIFICATION OPTIMIZATION
============================================================
Total Demand: 1000 MWh
Maximum Emissions Allowed: 400 tons CO2
Energy Source Details:
--------------------------------------------------
Source Cost ($/MWh) Emissions (tons CO2/MWh) Capacity (MWh)
Coal 30 0.90 400
Natural Gas 45 0.50 350
Nuclear 60 0.02 300
Solar 80 0.00 200
Wind 70 0.00 250
Solving optimization problem...
Minimize: 30*x_1 + 45*x_2 + 60*x_3 + 80*x_4 + 70*x_5
Subject to:
Demand: x_1 + x_2 + x_3 + x_4 + x_5 = 1000
Emissions: 0.90*x_1 + 0.50*x_2 + 0.02*x_3 + 0.00*x_4 + 0.00*x_5 ≤ 400
Capacity: 0 ≤ x_i ≤ Cap_i for all i
Optimization successful!
Minimum total cost: $48,516.67
Total emissions: 400.00 tons CO2
Emission constraint utilization: 100.0%
Optimal Energy Mix:
----------------------------------------
Source Optimal Output (MWh) Percentage (%) Cost ($) Emissions (tons CO2)
Coal 243.33 24.33 7300.00 219.0
Natural Gas 350.00 35.00 15750.00 175.0
Nuclear 300.00 30.00 18000.00 6.0
Solar 0.00 0.00 0.00 0.0
Wind 106.67 10.67 7466.67 0.0
============================================================
SENSITIVITY ANALYSIS
============================================================

============================================================
MARGINAL COST ANALYSIS
============================================================
Shadow Prices (Marginal Values):
• Demand constraint: $70.00/MWh
• Emission constraint: $44.44/ton CO2
Economic Interpretation:
• An additional 1 MWh of demand would increase costs by $70.00
• Relaxing emission limit by 1 ton would save $44.44
Sustainability Metrics:
• Renewable energy share: 10.7%
• Clean energy share: 40.7%
• Average cost per MWh: $48.52
• Emissions intensity: 0.400 tons CO2/MWh
============================================================
RISK ANALYSIS: SOURCE FAILURE SCENARIOS
============================================================
Failed Source Cost Increase ($) Cost Increase (%) Feasible
Coal 10733.333333 22.122982 Yes
Natural Gas 2983.333333 6.149090 Yes
Nuclear 4233.333333 8.725524 Yes
Wind 1066.666667 2.198557 Yes

============================================================ SUMMARY AND RECOMMENDATIONS ============================================================ Key Findings: 1. Optimal mix achieves $48,517 total cost 2. 40.7% of energy comes from clean sources 3. Emission constraint is 100.0% utilized 4. Most vulnerable to Coal failure Strategic Recommendations: • Diversification reduces risk - no single source dominates • Emission constraints drive toward cleaner sources • Consider backup capacity for critical sources • Monitor fuel price volatility for cost-sensitive sources
Optimal Solution Characteristics
The optimization typically produces a solution that:
- Maximizes clean energy within emission constraints
- Balances cost and sustainability through the Lagrangian multipliers
- Achieves portfolio diversification to minimize risk
- Utilizes capacity efficiently based on marginal costs
Economic Interpretation
The shadow prices from the optimization provide valuable economic insights:
- Demand shadow price: Marginal cost of serving additional demand
- Emission shadow price: Economic value of relaxing environmental constraints
This represents the classic environmental economics trade-off:
$$\text{Marginal Abatement Cost} = \frac{\partial \text{Total Cost}}{\partial \text{Emission Reduction}}$$
Strategic Implications
- Diversification Strategy: The optimal solution naturally diversifies across multiple sources, reducing dependency risks
- Clean Energy Transition: Emission constraints drive investment toward renewable and nuclear sources
- Capacity Planning: Utilization analysis identifies where additional capacity would be most valuable
- Risk Management: Failure analysis quantifies the cost of inadequate redundancy
This mathematical framework provides energy planners with a robust tool for making data-driven decisions about energy portfolio optimization, balancing economic efficiency with environmental responsibility and system reliability.