@@ -60,17 +60,17 @@ Cw=[]
6060
6161function generate_random_dynamic ()
6262 for i= 1 : N_STAGES
63- push! (Ax, rand (DIM_STATES,DIM_STATES))
64- push! (Au, rand (DIM_STATES,DIM_CONTROLS))
65- push! (Aw, rand (DIM_STATES,DIM_ALEAS))
63+ push! (Ax, rand (DIM_STATES,DIM_STATES))
64+ push! (Au, rand (DIM_STATES,DIM_CONTROLS))
65+ push! (Aw, rand (DIM_STATES,DIM_ALEAS))
6666 end
6767end
6868
6969function generate_random_costs ()
7070 for i= 1 : N_STAGES
71- push! (Cx, rand (1 ,DIM_STATES))
72- push! (Cu, - 1 * rand (1 ,DIM_CONTROLS))
73- push! (Cw, rand (1 ,DIM_ALEAS))
71+ push! (Cx, rand (1 ,DIM_STATES))
72+ push! (Cu, - 1 * rand (1 ,DIM_CONTROLS))
73+ push! (Cw, rand (1 ,DIM_ALEAS))
7474 end
7575end
7676
8484
8585# Define cost corresponding to each timestep:
8686function cost_t (t, x, u, w)
87- # if you want to compare the value, take the cost with only control
88- return (Cu[t]* u)[1 ,1 ]
89- # return (Cx[t]*x)[1,1]+(Cu[t]*u)[1,1]+(Cw[t]*w)[1,1]
87+ return (Cx[t]* x)[1 ,1 ]+ (Cu[t]* u)[1 ,1 ]+ (Cw[t]* w)[1 ,1 ]
9088end
9189
9290
@@ -170,15 +168,13 @@ function init_problem()
170168end
171169
172170model, params = init_problem ()
173- modelbis = model
174- paramsbis = params
171+ modelbis = deepcopy ( model)
172+ paramsbis = deepcopy ( params)
175173
176174
177175""" Solve the problem."""
178176function solve_dams (model,params,display= false )
179177
180- # model, params = init_problem()
181-
182178 V, pbs = solve_SDDP (model, params, display)
183179
184180 aleas = simulate_scenarios (model. noises,
@@ -222,6 +218,6 @@ if (unsolve)
222218 println (" Change your parameters" )
223219else
224220 a,b = solve_dams (modelbis,paramsbis)
225- println (" solution =" ,sol)
221+ println (" solution =" ,sol)
226222end
227223
0 commit comments