Fermer X

# A decomposition-coordination method for the cascade interconnected dams problem

Sowg
(last modiﬁcation date: October 10, 2017)
Version pdf de ce document
Version sans bandeaux

Hydroelectricity is the main renewable energy which is produced in France (over 10% of the country annual production). It provides a clean (no greenhouse gases emissions) and fast-usable energy that is cheap and substitutable for the thermal one. We address the question of the production management of cascade-interconnected dams by means of a ﬁnite-horizon Markov decision process. Solving such a problem is not straightforward since it displays a large size, so is likely to suﬀer from the curse of dimensionality. We handle it with a decomposition-coordination algorithm that we adapt by approximation to the stochastic case.

### Introduction

This pratical work will follow the lecture entitled Decomposition-coordination methods in stochastic optimal control (P. Carpentier). The computations will be performed using nsp and only nsp. In order to launch nsp write nsp & in a terminal. Type pwd to see the current repertory and then download the practical work material from the Internet to this repertory. Since we will use a three dimension dynamic programming algorithm, a part of the programming functions had to be written in C. Moreover, we have to load some scenarios datas. Thus, we will need a speciﬁc nsp toolbox called COURSES/stochdec. In order to load it, go to the stochdec repertory and type exec('loader.sce');.

### 1 Description of the problem

#### 1.1 Dynamics of a single dam and dams cascade

Let time t vary in {0,...,T}. The following real valued random variables are deﬁned on a probability space :

• Xti is the storage level at the beginning of period [t,t + 1); (state)
• Uti is the hydroturbine outﬂow during [t,t + 1); (production control)
• Zti is the inﬂow from dam i 1 into dam i during [t,t + 1); (coordination control)
• Wti is the exogeneous inﬂow into dam i during [t,t + 1).; (noise)

The dynamics of the dam reads:

 (1)

When Xti + W ti + Z ti U ti is greater than xi, the diﬀerence is spilled from dam i to dam i + 1 so that the upper bound constraint on dam i is directly handled by the dynamics. Therefore the total outﬂow from dam i to dam i + 1 is given by:

The bounds constraints are:

 (2)

Each dam i ∈{2,,N} receives from the dam i 1 outﬂows gti1 as inﬂows Zti and sends its own outﬂows into the dam i + 1 reservoir, at every t ∈{0,,T}. With the notation Zt1 0, this leads to the following coupling constraints:

 (3)

#### 1.2 The optimization problem

We assume that the noise random variable Wt = (Wt1,W t2,W t3) are independent over time. The hydroelectric production obeys the following valorization mechanism for every dam:

• the production at time t, Uti, is p t linearly retributed and a quadratic cost to produce 𝜀 × Uti2 has to be considered,

• a ﬁnal storage level appreciation function Ki(X T i) prevents the reservoir from being lower than a target storage level i at the end of the study period,

We consider the expected value of the sum of every dam total gain as the problem criterion:

 (4)

Note that this criterion is both time and space separable. The control U = (U0i,,U T1i) i must satisfy the non anticipativity constraint in the hazard-decision framework. So, Uti has to be measurable with respect to the noises up to time t:

 (5)

The problem consists in minimizing the criterion (4) under the dynamics (1), the coupling (3), the bounds (2) and the measurability (5) constraints.

#### 1.3 Numerical instance

We will test algorithms on a valley composed of three cascade-interconnected dams over a T = 12 time steps period. The problem is of a discrete type and the dams share the following common characteristics:

• the volume Xti of every dam i at t belongs to the forty one integers set ;
• the space in which every control Uti takes its values is discretized over the six integers set ;
• the noise random variables Wti are considered as being interstage independent and uniformely distributed over a ﬁnite set of ten integers.

The simulation part is based on 500 intakes scenarios.

Question 1 Execute the script answer-question1.sce which is stored in the directory COURSES/stochdec. This script will draw N simulation scenarios for the dam number 1. Take a look at the script and change it to draw the scenarios of the other dams.

The contents of the script answer-question1.sce is reproduced here:

// You should be in COURSES/stochdec to run this script
SIMSCEN=dp_get_simulation_scenarios();

// get the inflows law on dam 1
M=fscanfMat('Datas/Generated_datas/generated_intakes_0.txt');

// QUESTION 1:
xclear();
[nss,v]=size(SIMSCEN)
N=10
// Draw N scenarions of intakes of dam 1
Sim=SIMSCEN(1:N,:)+1;// take care to add one
T=dp_horizon();
res=Sim;

for t=1:T-1 do
res(:,t)=M(Sim(:,t),t);
end;

xset('colormap',jetcolormap(N));
plot2d([],res');
xtitle(sprintf('first %d simulation scenarios',N));

### 2 Exact solution by dynamic programming

The noises Wti are independent over time, so that the problem can be theoretically solved by stochastic dynamic programming (DP). Although, DP is prone to face the curse of dimensionality (the method is not numerically tractable as soon as the number of dams is larger than 5 ) you will ﬁrst solve the three cascade interconnected dams problem by DP since it is numerically possible (as N = 3). Note that the discretization of the problem avoids us to use an interpolation scheme to implement the method.

Question 2 Running DP on the cascade of three connected dams is obtained using the function dp_run(). Then call the function dp_simu() as follows [cost, stocks, controls]=dp_simu() to obtain the expected cost and the stocks and the controls trajectories. Plot the stocks trajectories and show the optimal expected cost. Note that, for example, you will obtain the stocks evolution of dam 1 by using S1=stocks{1}.

Question 3 For the most sceptical of you, just try to beat the DP-computed strategy by building your own strategy ! ;) For example, you may want to multiply the optimal control mapping by a scalar γ [0,1] to get a new control U (you can use dp_getu(U) and dp_setu(U) to obtain or set the current used control table). Simulate the strategies obtained with your control strategy by using dadp_simu() and compare to what you had obtained before.

Question 4 You can also design your own strategy using function dp_f2u and simulate your strategy as seen in question3. How far is your solution expected cost from the optimal one?

The next script gives some hints on how to use dp_f2u:

function u=myfeedback(t,w,x)
// scalar t, vector w of size 4 (three inflows and a price)
//, vector x of size 3 (water levels of the dams)
u=sin(t)*x(1)*w(4)*[0;1;0]+x(3);
endfunction
// dp_f2u(fn): use a feedback function given as
// argument to fill a control array U.

U=dp_f2u(myfeedback)
...

### 3 Approximate solution by dual approximate dynamic programming

In a few words, we decompose the three dimension dynamic state problem into three one dimension dynamic state problems. This is done by:

1. dualizing the coupling constraints;
2. coordinating the local optimal solutions to got the global optimal one using an Uzawa algorithm.

#### 3.1 Dualization of the coupling constraint and DADP

We aim at dualizing (3) and at solving the problem by using an Uzawa algorithm: at iteration k, the associated multiplier is a ﬁxed t-measurable random variable λti+1(k), and the term (under the expectation) induced by duality in the cost function is

It can be decomposed as

• λti+1(k).Z ti+1: term pertaining to dam i + 1.
• λti+1(k).g tiX ti,U ti,W ti,Z ti: term pertaining to dam i.

Finally, the following term is added to the cost of dam i

The main idea of the price decomposition of the problem is to see Zti as an independent control variable as shown in ﬁgures 3. As Uti does, Z ti has to observe the (3) constraint.

Then, we would like to solve the resulting N independent one-dam subproblems by DP1 ,

 (6)

But, the presence of the random variables λti t=0,,T1(k) prevents to use dynamic programming in a straightforward manner since the random variables λti are not independent over time. The idea of DADP is to replace the multipliers λti(k) by their conditional expectations w.r.t. chosen information variable Yti, namely

Note that this is equivalent to replace the (3) constraint by 𝔼Zti gti1()  Yti = 0. In practice, Yti is a short-memory process that will enter the state variables of the subproblems. In the sequel we will consider that Yti const, so that ti(k) := 𝔼λ ti(k).

1. initialization: choose initial values for the multipliers ti(0) for all i and t,
2. minimization: solve N independent one dimensional subproblems by dynamic programming,

3. coordination: update the multipliers by a gradient step as follows:
• simulation: apply the current strategy on a sample of n noise trajectories ωl, to get n realizations of the random variables (gti())(k+1)(ω l) by time step, compute all discrepancies (δti)(ω l) in the coupling constraints given by:

• gradient step: update the multipliers by taking the average of the discrepancies (δti)(ω l)

4. stopping condition: go to step (2) until convergence of the algorithm.

Question 5 Run the script job.sce to see iterations of the DADP algorithm solving the three cascade interconnected dams problem. You should observe the multipliers expected values and the dual costs converging in about three thousand iterations. At the end of iterations you can obtain the optimal multipliers expected values using the function dadp_get_lambda(). Use this function to store this values in matrix OPT_LAMBDA by calling OPT_LAMBDA=dadp_get_lambda().

Question 6 Have a look at the Uzawa algorithm ﬁgure Figure 4. Implement your own gradient step process and make the gradient step size values vary to see how it aﬀects the convergence of the algorithm. You can use the following program skeleton.

l1=[];l2=[];cost=[],costa=[],costaa=[],costab=[];
for i=1:200
dadp_minimization_step(); // DP for each dam given lambdas
// now you should update the lambdas using the following functions
// you can get or set the current values of lambda with
// or
end

Question 7 Write your own dadp_coordination() function using the following code skeleton and then compare your code to the reference one.

// dc: used to store the dual cost
// dl: used to accumulate the average gradients it should be of size
// zeros(2,T-1);
for ksimul=0:Nu-1
//  dadp_x0(); // gives the initial stocks
for t=0:T-2
// dadp_get_noise(ksimul,t); // get the intakes and price
...
end
// dadp_final_cost(x); // returns the final cost for each dam
end
dc =- dc /Nu; // average
dl = dl/Nu; // average
endfunction

Question 8 You can change the previous function dadp_coordination1 in order to get the deviations from the coupling constraints trajectories at the optimal multipliers expected values. Compute these values when at the optimal multipliers expected values that you have stored before.

The approximation Yti const is a relaxation of the problem (as the constraint is loosened). Thus, the strategies that we derive may not be feasible, even if the algorithm converges: we have to design a method to go back to a feasible strategy.

#### 3.2 A heuristic to construct an admissible solution

Once the algorithm has converged we have feedbacks laws that verify the constraint

But, this means that the physical constraint Zti = g ti1a.s. is not veriﬁed. Consequently one has to deﬁne an heuristic to turn this strategies into an admissible one.

We ﬁrst note that the optimal control to apply along a given noise trajectory may be computed using the Bellman function. The way to do this is the following: suppose that you have the three dimension DP-computed Bellman function

For every scenario
For t=0:1:T-1
get the current state and the inflow value for every dam;
set a variable opt_cost to infinity;
For u_i=0:4:40 (a loop a dam, three loops here thus)
set the corresponding instant cost to a variable cost;
apply the dynamic to get the reached states;
add the reached states t+1 Bellman function value to cost;
If cost < opt_cost then
opt_cost=cost and set the u_i values to a vector opt_u;
apply the dynamics with u=opt_u and collect the new current states;

Question 9 Use the simulation part of the previous coordination function to implement the simulation using the Bellman function you get by DP and compare it to the dp_simu() results.

We don’t have the three dimension Bellman function but we can construct an approximate Bellman’s value function for the global problem as the sum of the Bellman’s value function of each subproblem. Consequently we obtain a global admissible strategy by doing a one time step optimization of the global problem. More precisely if we write V ti(x ti) the Bellman’s function obtained for subproblem i when the DADP algorithm has converged, we deﬁne (xt) = i=1NV ti(x ti1,x ti,x ti+1), with the convention that¡ x 0t = 0. Then the control we choose at time t when the cascade of dams is in the state xt and the wt is observed is the optimum of

This problem is global on the cascade but only done on one time-step, so numerically tractable.

Question 10 Apply the heuristic to the optimal strategy we computed using dadp_admissible() and simulate with [cost, stocks, controls]=dadp_simv(). Use the function which checked for the feasibility of the DADP computed strategy to see that the strategy is now feasible. Compare the results with those we get by the application of the exact optimal strategy.

 L'École des Ponts ParisTech est membre fondateur de L'École des Ponts ParisTech est certifiée