Skip to content

Commit 720fadc

Browse files
committed
[FIX] Fix a bug in sdp HD, solve the stock-example issue
1 parent a765d33 commit 720fadc

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

examples/stock-example.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ println("Lower bound obtained by SDDP: "*string(lb_sddp))
7676

7777
######### Solving the problem via Dynamic Programming
7878

79-
stateSteps = [0.1]
80-
controlSteps = [0.1]
79+
stateSteps = [0.01]
80+
controlSteps = [0.01]
8181
infoStruct = "HD" # noise at time t is known before taking the decision at time t
8282

8383
paramSDP = SDPparameters(spmodel, stateSteps, controlSteps, infoStruct)

src/SDPoptimize.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ function sdp_optimize(model::SPModel,
141141
param::SDPparameters,
142142
display=true::Bool)
143143

144-
function true_fun(x...)
144+
function true_fun(t,x,u,w)
145145
return true
146146
end
147-
function zero_fun(x...)
147+
function zero_fun(x)
148148
return 0
149149
end
150150

@@ -390,7 +390,7 @@ function sdp_solve_HD(model::StochDynProgModel,
390390
#Compute expectation
391391
for w in 1:sampling_size
392392
admissible_u_w_count = 0
393-
best_V_x_w = 0.
393+
best_V_x_w = Inf
394394
next_V_x_w = Inf
395395
w_sample = samples[:, w]
396396
proba = probas[w]
@@ -417,7 +417,6 @@ function sdp_solve_HD(model::StochDynProgModel,
417417
expected_V += proba*best_V_x_w
418418
count_admissible_w += (admissible_u_w_count>0)*proba
419419
end
420-
421420
if (count_admissible_w>0.)
422421
expected_V = expected_V / count_admissible_w
423422
end

0 commit comments

Comments
 (0)