Skip to content

Commit 181ac9e

Browse files
committed
[UPD] update stock-example
1 parent d2083e2 commit 181ac9e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

examples/stock-example.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ if run_ef
8888
value_ef = extensive_formulation(spmodel, paramSDDP)[1]
8989
println("Value obtained by Extensive Formulation: "*string(round(value_ef,4)))
9090
println("Relative error of SDP value: "*string(100*round(value_sdp/value_ef-1,4))*"%")
91-
println("Relative error of SDDP value: "*string(100*round(lb_sddp/value_ef-1,4))*"%")
91+
println("Relative error of SDDP lower bound: "*string(100*round(lb_sddp/value_ef-1,4))*"%")
9292
end
9393

9494
######### Comparing the solutions on simulated scenarios.
@@ -101,5 +101,5 @@ if run_sdp
101101
end
102102
if run_sddp && run_sdp
103103
println("Simulated relative difference between sddp and sdp: "
104-
*string(200*round(mean(costsddp-costsdp)/mean(costsddp+costsdp),4))*"%")
104+
*string(round(200*mean(costsddp-costsdp)/mean(costsddp+costsdp),3))*"%")
105105
end

src/SDDPoptimize.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ fulfilled.
3939
function solve_SDDP(model::SPModel, param::SDDPparameters, display=0::Int64)
4040
# initialize value functions:
4141
V, problems = initialize_value_functions(model, param)
42+
println("initial value function intialized")
4243
# Run SDDP upon example:
4344
sddp_stats = run_SDDP!(model, param, V, problems, display)
4445
return V, problems, sddp_stats
@@ -128,10 +129,16 @@ function run_SDDP!(model::SPModel,
128129
push!(stats.upper_bounds, upb)
129130

130131
if (display > 0) && (iteration_count%display==0)
131-
println("Pass number ", iteration_count,
132+
if upb < Inf
133+
println("Pass number ", iteration_count,
132134
"\tUpper-bound: ", upb,
133135
"\tLower-bound: ", round(stats.lower_bounds[end], 4),
134136
"\tTime: ", round(stats.exectime[end], 2),"s")
137+
else
138+
println("Pass number ", iteration_count,
139+
"\tLower-bound: ", round(stats.lower_bounds[end], 4),
140+
"\tTime: ", round(stats.exectime[end], 2),"s")
141+
end
135142
end
136143

137144
end
@@ -313,7 +320,7 @@ function initialize_value_functions(model::SPModel,
313320
param::SDDPparameters)
314321

315322
solverProblems = build_models(model, param)
316-
323+
println("model builded")
317324
V = PolyhedralFunction[
318325
PolyhedralFunction([], Array{Float64}(0, model.dimStates), 0) for i in 1:model.stageNumber]
319326

0 commit comments

Comments
 (0)