@@ -17,25 +17,21 @@ const SOLVER = ClpSolver()
1717# const SOLVER = CplexSolver(CPX_PARAM_SIMDISPLAY=0)
1818
1919const N_STAGES = 5
20- const N_SCENARIOS = 3
20+ const N_SCENARIOS = 1
2121
22- const DIM_STATES = 2
23- const DIM_CONTROLS = 2
22+ const DIM_STATES = 1
23+ const DIM_CONTROLS = 1
2424const DIM_ALEAS = 1
2525
2626
2727
2828# Constants that the user does not have to define
2929const T0 = 1
3030
31- # Constants:
32- const VOLUME_MAX = 100
33- const VOLUME_MIN = 0
34-
35- const CONTROL_MAX = round (Int, .4 / 7. * VOLUME_MAX) + 1
31+ const CONTROL_MAX = round (Int, .4 / 7. * 100 ) + 1
3632const CONTROL_MIN = 0
3733
38- const W_MAX = round (Int, .5 / 7. * VOLUME_MAX )
34+ const W_MAX = round (Int, .5 / 7. * 100 )
3935const W_MIN = 0
4036const DW = 1
4137
@@ -46,9 +42,7 @@ const ALEAS = linspace(W_MIN, W_MAX, N_ALEAS)
4642const EPSILON = .05
4743const MAX_ITER = 20
4844
49- alea_year = Array ([7.0 7.0 8.0 3.0 1.0 1.0 3.0 4.0 3.0 2.0 6.0 5.0 2.0 6.0 4.0 7.0 3.0 4.0 1.0 1.0 6.0 2.0 2.0 8.0 3.0 7.0 3.0 1.0 4.0 2.0 4.0 1.0 3.0 2.0 8.0 1.0 5.0 5.0 2.0 1.0 6.0 7.0 5.0 1.0 7.0 7.0 7.0 4.0 3.0 2.0 8.0 7.0 ])
50-
51- const X0 = [50 , 50 ]
45+ const X0 = 50 * ones (DIM_STATES)
5246
5347Ax= []
5448Au= []
@@ -146,23 +140,17 @@ function init_problem()
146140 x0 = X0
147141 aleas = generate_probability_laws ()
148142
149- x_bounds = [(VOLUME_MIN, VOLUME_MAX), (VOLUME_MIN, VOLUME_MAX)]
150- u_bounds = []
151- for u = 1 : DIM_CONTROLS
152- u_bounds = push! (u_bounds, (CONTROL_MIN, CONTROL_MAX))
153- end
154-
143+ # Define bounds for the control
144+ u_bounds = [(CONTROL_MIN, CONTROL_MAX) for i in 1 : DIM_CONTROLS]
145+
155146 model = LinearDynamicLinearCostSPmodel (N_STAGES,
156147 u_bounds,
157148 x0,
158149 cost_t,
159150 dynamic,
160151 aleas)
161152
162- # set_state_bounds(model, x_bounds)
163-
164- solver = SOLVER
165- params = SDDPparameters (solver, N_SCENARIOS, EPSILON, MAX_ITER)
153+ params = SDDPparameters (SOLVER, N_SCENARIOS, EPSILON, MAX_ITER)
166154
167155 return model, params
168156end
@@ -177,10 +165,7 @@ function solve_dams(model,params,display=false)
177165
178166 V, pbs = solve_SDDP (model, params, display)
179167
180- aleas = simulate_scenarios (model. noises,
181- (model. stageNumber,
182- params. forwardPassNumber,
183- model. dimNoises))
168+ aleas = simulate_scenarios (model. noises,params. forwardPassNumber)
184169
185170 params. forwardPassNumber = 1
186171
@@ -189,7 +174,7 @@ function solve_dams(model,params,display=false)
189174 return stocks, V
190175end
191176
192- # Solve the problem and try nb_iter times to generate radom data in case of infeasibility
177+ # Solve the problem and try nb_iter times to generate random data in case of infeasibility
193178unsolve = true
194179sol = 0
195180i = 0
@@ -219,5 +204,6 @@ if (unsolve)
219204else
220205 a,b = solve_dams (modelbis,paramsbis)
221206 println (" solution =" ,sol)
207+ println (" V0 = " , b[1 ]. lambdas[1 ,:]* X0+ b[1 ]. betas[1 ])
222208end
223209
0 commit comments