1717# The decision variable is the quantity U_t of energy stored (or discharged) in
1818# the battery, is decided knowing the uncertainty W_0,...,W_t.
1919# We want to minimize the money spent on buying electricity (cost are deterministic) :
20- # min E[\sum_{t=0}^T c_t * G_{t}]
20+ # min E[\sum_{t=0}^T c_t * G_{t}]
2121# d_t + U_t <= W_t + G_t (a)
2222# S_{t+1} = S_t + r (U_t)^+ + 1/r (U_t)^- (b)
2323# Smin <= S_t <= Smax (c)
@@ -68,22 +68,12 @@ println("library loaded")
6868
6969 # Define dynamic of the stock:
7070 function dynamic (t, x, u, xi)
71- if u[1 ]>= 0
72- return [ x[1 ] + rho_c * min (max (u[1 ], xi[1 ]),STATE_MAX- x[1 ])]
73- else
74- return [ x[1 ] + 1 / rho_dc * max (u[1 ],- max (0 ,DEMAND[t])) ]
75- end
71+ return [ x[1 ] + 1 / rho_dc * min (u[1 ],0 ) + rho_c * max (u[1 ],0 ) ]
7672 end
7773
7874 # Define cost corresponding to each timestep:
7975 function cost_t (t, x, u, xi)
80- U = 0
81- if u[1 ]>= 0
82- U = rho_c * min (max (u[1 ], xi[1 ]),STATE_MAX- x[1 ])
83- else
84- U = 1 / rho_dc * max (u[1 ],- max (0 ,DEMAND[t]))
85- end
86- return COSTS[t] * max (0 , DEMAND[t] + U - xi[1 ])
76+ return COSTS[t] * max (0 , DEMAND[t] + u[1 ] - xi[1 ])
8777 end
8878
8979 function constraint (t, x, u, xi)
@@ -110,7 +100,7 @@ println("library loaded")
110100
111101 stateSteps = [0.01 ]
112102 controlSteps = [0.001 ]
113- infoStruct = " DH " # noise at time t is not known before taking the decision at time t
103+ infoStruct = " HD " # noise at time t is not known before taking the decision at time t
114104
115105 paramSDP = StochDynamicProgramming. SDPparameters (spmodel, stateSteps,
116106 controlSteps, infoStruct)
0 commit comments