Capacity expansion of power generation#
Description: Models the extensive form of a deterministic multi-stage capacity expansion problem. In this model we can have multiple resources of the same type which have identical properties. The model can be further developed into a stochastic one.
Tags: ampl-only, energy, planning, mip, power-generation
Notebook author: Gyorgy Matyasfalvi <gyorgy@ampl.com>
Model author: Ahmed et al., Gyorgy Matyasfalvi
References:
Ahmed, S., King, A. J. and Parija G. (2003). “A Multi-Stage Stochastich Integer Programming Approach for Capacity Expansion Under Uncertainty”. In: J. of Global Optimization 26.1 (May 2003), pp. 3-24. URL: https://doi.org/10.1023/A:1023062915106
# Install dependencies
%pip install -q amplpy
# Google Colab & Kaggle integration
from amplpy import AMPL, ampl_notebook
ampl = ampl_notebook(
modules=["coin"], # modules to install
license_uuid="default", # license to use
) # instantiate AMPL object and register magics
Use %%ampl_eval
to evaluate AMPL commands#
%%ampl_eval
option version;
option version 'AMPL Version 20230301 (Linux-5.15.0-1037-azure, 64-bit)\
Demo license with maintenance expiring 20240131.\
Using license file "/home/gomfy/miniconda3/envs/tutorial/lib/python3.11/site-packages/ampl_module_base/bin/ampl.lic".\
';
Use %%writeifile to create files#
%%writefile cap_ef.mod
# Declare index sets
set STAGES ordered;
set RESOURCES ordered;
# Decision variables
var cap_exp {STAGES, RESOURCES} >= 0; # Variable cost associated with increase in capacity
var cap_dec {STAGES, RESOURCES} integer; # Fixed cost associated with decision to involve a new resource
# Parameters
param var_cost {STAGES, RESOURCES} > 0;
param fix_cost {STAGES, RESOURCES} > 0;
param cap_ub {STAGES, RESOURCES} > 0;
param demand {STAGES};
# Objective function
minimize total_cost:
sum{t in STAGES, i in RESOURCES} (var_cost[t,i]*cap_exp[t,i] + fix_cost[t,i]*cap_dec[t,i]);
# Constraints
subject to cap_acqu_bound {t in STAGES, i in RESOURCES}:
cap_exp[t,i] <= cap_ub[t,i]*cap_dec[t,i]; # Upper bounds on total capacity
subject to statisfy_demand {T in STAGES}:
sum {t in STAGES, i in RESOURCES: ord(t) <= ord(T)} cap_exp[t,i] >= demand[T]; # Demand needs to be satisfied at all times
subject to one_resource:
sum {t in STAGES} cap_dec[t,first(RESOURCES)] <= 1;
Writing cap_ef.mod
%%writefile cap_ef.dat
# Index sets
set STAGES := 2030 2040 2050;
set RESOURCES := hydro nuclear coal;
# Billions of USD
param var_cost: hydro nuclear coal :=
2030 0.01 0.01 0.8
2040 0.011 0.013 1.9
2050 0.012 0.014 2.7 ;
# Billions of USD
param fix_cost: hydro nuclear coal :=
2030 25 10 1
2040 28 11 2.3
2050 25 11.5 3.8 ;
# In GWH
param cap_ub: hydro nuclear coal :=
2030 300 12 20
2040 290 15 21
2050 280 18 20 ;
# In GWH
param demand :=
2030 500
2040 1000
2050 1105 ;
Writing cap_ef.dat
%%writefile cap_ef.run
# ---------------------------------------------------------------
# Solve capcity expansion problem then display decison variables
# ---------------------------------------------------------------
option solver cbc;
option solution_round 6;
model cap_ef.mod;
data cap_ef.dat;
solve;
for {t in STAGES} {
printf "\n\n\t\t**%s**\n", t;
printf {i in RESOURCES}: "%s: %d\t", i, cap_dec[t,i];
printf "\n";
}
printf "\n";
Writing cap_ef.run
Use %%ampl_eval
to run the script cap_ef.run#
%%ampl_eval
commands cap_ef.run;
cbc 2.10.7: cbc 2.10.7: optimal solution; objective 640.67
212 simplex iterations
212 barrier iterations
4 branching nodes
**2030**
hydro: 1 nuclear: 14 coal: 2
**2040**
hydro: 0 nuclear: 34 coal: 0
**2050**
hydro: 0 nuclear: 5 coal: 0