Skip to content

Commit 5d5b9e0

Browse files
committed
[FIX] Integrated remarks for PR
1 parent f3f8460 commit 5d5b9e0

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

examples/dynamic_example.jl

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ Cw=[]
6060

6161
function 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
6767
end
6868

6969
function 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
7575
end
7676

@@ -84,9 +84,7 @@ end
8484

8585
# Define cost corresponding to each timestep:
8686
function 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]
9088
end
9189

9290

@@ -170,15 +168,13 @@ function init_problem()
170168
end
171169

172170
model, params = init_problem()
173-
modelbis = model
174-
paramsbis = params
171+
modelbis = deepcopy(model)
172+
paramsbis = deepcopy(params)
175173

176174

177175
"""Solve the problem."""
178176
function 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")
223219
else
224220
a,b = solve_dams(modelbis,paramsbis)
225-
println("solution =",sol)
221+
println("solution =",sol)
226222
end
227223

0 commit comments

Comments
 (0)