Skip to content

nimazzi/Stand_and_Adapt_Bend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Benders with Adaptive Oracles

Brief Description

This code solves a power system investment planning problem with a time horizon of 15 years. The deterministic version of the problem has 3 decision nodes: one refers to decisions to be taken at present time, one to decisions in 5 years time, and one to decision in 10 years time. The stochastic version is obtained by modeling different possible scenarios for the future of the system in 5 and 10 years. At each node we also compute the cost of operating the system for the following 5 years for given installed capacity. We consider a construction time of 5 years, so new assets installed at present time will only be available in 5 and 10 years, and new capacity installed in 5 years will only be available in 10 years. We model a set img1 of technologies: six thermal units, three storage units, and three renewable generation units.

The stochastic investment planning problem is formulated as

eq1

where eq2 is the set of decision nodes, each associated with a probability eq3. The function

eq4

gives the cost of operating the system over 5 years. The vector of right-hand side coefficients img2 is given by

eq5

here img3 is the accumulated capacity of technology img4 at node img5. Parameters img6 and img7 are the relative level of energy demand and the yearly CO2 emission limit, respectively. The vector of cost coefficients img8 is

eq6

where img9 is the uranium fuel price and img10 the CO2 emission price. Finally, the function img11 yields the expected total investment and fixed cost, and it is computed as

eq7

where the variable img12 is the newly installed capacity of technology img13 at node img14. Parameters img14 and img15 are the unitary investment and fixed cost of technology img16 at node img14. Parameters img17. The accumulated capacity img18 at node img19 is computed as the sum of the historical capacity and the newly installed capacity img21 in all nodes img22 ancestors to img23.

We consider three possible sources of uncertainty, i.e., img23, img24, and img25. Each uncertain parameters has 3 possible outcomes in 5 years, each of which is linked to 3 additional possible outcomes in 10 years. The result is 9 possible trajectories for each uncertainty, all with the same probability. We consider 4 different cases of the investment problem. Case 0 is the deterministic version, where img26, img27, and img28 are deterministic parameters (weighted average of the scenarios). Then, case 1 has 1 uncertain parameter, case 2 has 2 uncertain parameters, and case 3 has 3 uncertain parameters. The number of decision nodes for the 4 versions of the problem is

case uncertain parameters decision nodes
0 - 3
1 a1 13
2 a2 91
3 a3 757

The investment problem can be solved with two algorithms: Algorithm 1 (Stand_Bend) and Algorithm 2 (Adapt_Bend). Both Algorithm Stand_Bend and Adapt_Bend are presented in ''Benders Decomposition with Adaptive Oracles for Large Scale Optimization'' (http://www.optimization-online.org/DB_HTML/2019/08/7327.html).

Prerequisites

Install Julia 1.4 (with packages JuMP.jl 0.21, Gurobi.jl, Suppressor.jl, CSV.jl, JLD.jl, Printf.jl, Clustering.jl, ParallelDataTransfer.jl) and Gurobi 9.0.

Running the serial code

Open the terminal and change directory to the project folder.

bash$ cd ~/path_to_folder/Stand_and_Adapt_Bend/serial

Start Julia and include "main.jl"

bash$ julia
               _ 
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.0 (2020-03-21)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> include("main.jl")

You will be asked to select the case study (0, 1, 2, or 3),

 case 0 -> 0 uncertain parameters
 case 1 -> 1 uncertain parameters
 case 2 -> 2 uncertain parameters
 case 3 -> 3 uncertain parameters
 select case study:
1 

and the algorithm (0, 1, 2, or 3) used to solve the problem

 algorithm 0 -> deterministic equivalent
 algorithm 1 -> Stand_Bend (Standard Benders)
 algorithm 2 -> Adapt_Bend (Benders with Adaptive Oracles)
 algorithm 3 -> Zaker_Bend (Benders, Zakeri et al.)
 select Benders-type algorithm:
2 

if algorithm Adapt_Bend is selected, input the number w of subproblems to solve at each iteration

 number of subproblems to solve each iter j:
 input w (0 < w < 12)
1 

if algorithm Zaker_Bend is selected, input the coefficient q to update the optimality tolerance (10 suggested)

 select parameter σ:
 input σ (1 < σ <= 100)
10 

The algorithm starts and stops once reached the predifined tolerance, e.g.,

 */--------------------------------/*
 algorithm          : adapt_bend
 case               : 1
 subs per iter      : 1
 investment  nodes  : 4
 operational nodes  : 12
 */--------------------------------/*
 k =   1, δ = 99.791 %, t =    2.31 s 
 k =   2, δ = 99.542 %, t =    0.93 s 
 ...
 k =  69, δ =  0.010 %, t =    2.65 s 
 k =  70, δ =  0.009 %, t =    4.24 s 
 */--------------------------------/*

 */--------------------------------------------------------------------/*
  
 co2 emission limit : uncertain
 co2 emission cost  : known
 uranium cost       : known
 investment nodes   : 4
 operational nodes  : 12
 optimal objective  : 1.381 x 10^11 £

 */--------------------------------------------------------------------/*

 optimal investments (GW) @ 0 years
 ----------------
 tech.         i1
 ----------------
 coal         0.0 
 coalccs      0.0
 OCGT         0.0
 CCGT        13.3
 diesel       1.8
 nuclear      0.0
 pumpL        0.0
 pumpH        0.0
 lithium      0.0
 onwind      19.0
 offwind      0.0
 solar        0.0
 ----------------

 optimal investments (GW) @ 5 years
 ------------------------------
 tech.         i1     i2     i3
 ------------------------------
 coal         0.0    0.0    0.0 
 coalccs      0.0    0.0    2.3
 OCGT         0.0    0.0    0.0
 CCGT         4.4    0.9    0.0
 diesel       2.5    2.5    0.1
 nuclear      5.4    8.6   10.0
 pumpL        0.0    0.0    0.0
 pumpH        0.0    0.0    0.0
 lithium      0.0    0.0    0.0
 onwind       0.0    0.0    0.0
 offwind      0.0    0.0    0.0
 solar        0.0    0.0    0.0
 ------------------------------

 */--------------------------------------------------------------------/*

 computational results:
 -------------------------------------------------------------------
 ϵ-target (%) | iters     time (s)   RMP (%)   SP (%)   Oracles (%)
 -------------------------------------------------------------------
 1.00         | 44        87          0.10      99.46    0.11
 0.10         | 51        106         0.09      99.52    0.12
 0.01         | 70        155         0.07      99.58    0.13
 -------------------------------------------------------------------

 */--------------------------------------------------------------------/*

Running the parallel code

Open the terminal and change directory to the project folder.

bash$ cd ~/path_to_folder/Stand_and_Adapt_Bend/parallel

Modify file /functions/load_cluster.jl if loading workers on multiple machines, specify the ip address of the machine, the path to the gurobi license, and the path to the julia executable.

machine_1   = Dict("hostip" => "000.000.000.000",
                   "grblcs" => "path_to_gurobi_license",
                   "jlpath" => "path_to_julia_exec")

Start Julia and include "main.jl"

bash$ julia
               _ 
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.0 (2020-03-21)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> include("main.jl")

You will be asked to select the case study (0, 1, 2, or 3),

 case 0 -> 0 uncertain parameters
 case 1 -> 1 uncertain parameters
 case 2 -> 2 uncertain parameters
 case 3 -> 3 uncertain parameters
 select case study:
2 

select the algorithm (1 or 2) used to solve the problem

 algorithm 1 -> Stand_Bend (Standard Benders)
 algorithm 2 -> Adapt_Bend (Benders with Adaptive Oracles)
 select Benders-type algorithm:
2 

and the number of workers to start up on every computer

 select number of workers on machine0 (local_machine)
 select 0 <= w <= 11 :
2 

 select number of workers on machine1 (000.000.000.000)
 select 0 <= w <= 9 :
0 

The algorithm starts and stops once reached the predifined tolerance, e.g.,

 */--------------------------------/*
 algorithm          : adapt_bend
 case               : 2
 investment  nodes  : 10
 operational nodes  : 90
 workers            : 2
 */--------------------------------/*
 k =   1, δ = 99.759 %, t =    3.27 s 
 k =   2, δ = 99.116 %, t =    2.23 s 
 ...
 k = 144, δ =  0.013 %, t =    3.76 s 
 k = 145, δ =  0.009 %, t =     3.0 s 
 */--------------------------------/*

 */--------------------------------------------------------------------/*
  
 co2 emission limit : uncertain
 co2 emission cost  : known
 uranium cost       : known
 investment nodes   : 10
 operational nodes  : 90
 optimal objective  : 1.374 x 10^11 £

 */--------------------------------------------------------------------/*

 optimal investments (GW) @ 0 years
 ----------------
 tech.         i1
 ----------------
 coal         0.0 
 coalccs      1.0
 OCGT         0.0
 CCGT        11.5
 diesel       2.0
 nuclear      0.0
 pumpL        0.0
 pumpH        0.0
 lithium      0.0
 onwind      19.0
 offwind      0.0
 solar        0.0
 ----------------

 optimal investments (GW) @ 5 years
 ------------------------------------------------------------------------
 tech.         i1     i2     i3     i4     i5     i6     i7     i8     i9
 ------------------------------------------------------------------------
 coal         0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0 
 coalccs      6.5    6.5    6.5    0.0    0.0    1.4    0.0    0.0    1.4
 OCGT         0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
 CCGT         0.0    0.0    0.0    6.0    2.9    0.0    5.6    2.7    0.0
 diesel       0.0    0.0    0.0    2.1    2.1    1.3    2.6    2.4    1.4
 nuclear     10.0   10.0   10.0    4.8    7.9   10.0    4.7    7.8   10.0
 pumpL        0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
 pumpH        0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
 lithium      0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
 onwind       0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
 offwind      0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
 solar        0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
 ------------------------------------------------------------------------

 */--------------------------------------------------------------------/*

 computational results:
 -------------------------------------------------------------------
 ϵ-target (%) | iters     time (s)   RMP (%)   SP (%)   Oracles (%)
 -------------------------------------------------------------------
 1.00         | 38        112         3.17      95.89    0.65
 0.10         | 83        263         3.87      94.99    0.96
 0.01         | 145       490         4.77      93.76    1.33
 -------------------------------------------------------------------

 */--------------------------------------------------------------------/*