Skip to content

Commit 1fab604

Browse files
committed
Merge pull request #57 from leclere/sdp_speedup
[UPD] Add control iterators speedup to sdp_optimize + adapt benchmark…
2 parents 78e61ea + b9fadd1 commit 1fab604

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

examples/benchmark.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,7 @@ function benchmark_sdp()
306306

307307
x0 = [20., 22.]
308308

309-
modelSDP = StochDynProgModel(N_STAGES-1, N_CONTROLS,
310-
N_STATES, N_NOISES,
309+
modelSDP = StochDynProgModel(N_STAGES-1,
311310
x_bounds, u_bounds,
312311
x0, cost_t,
313312
finalCostFunction, dynamic,
@@ -319,8 +318,8 @@ function benchmark_sdp()
319318

320319
paramsSDP = StochDynamicProgramming.SDPparameters(modelSDP, stateSteps,
321320
controlSteps,
322-
monteCarloSize,
323-
infoStruct);
321+
infoStruct,
322+
"Exact");
324323

325324
print("Problem size (T*X*U*W): ")
326325
println(paramsSDP.totalStateSpaceSize*paramsSDP.totalControlSpaceSize)

examples/stock-example.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const S0 = 0.5
4242
proba = 1/N_XI*ones(N_XI) # uniform probabilities
4343
xi_support = collect(linspace(XI_MIN,XI_MAX,N_XI))
4444
xi_law = NoiseLaw(xi_support, proba)
45-
xi_laws = NoiseLaw[xi_law for t in 1:N_STAGES-1]
45+
xi_laws = NoiseLaw[xi_law for t in 1:N_STAGES-1]
4646

4747
# Define dynamic of the stock:
4848
function dynamic(t, x, u, xi)
@@ -59,7 +59,7 @@ end
5959
u_bounds = [(CONTROL_MIN, CONTROL_MAX)]
6060
spmodel = LinearDynamicLinearCostSPmodel(N_STAGES,u_bounds,[S0],cost_t,dynamic,xi_laws)
6161
set_state_bounds(spmodel, s_bounds)
62-
62+
6363

6464
######### Solving the problem via SDDP
6565
if run_sddp

src/SDPoptimize.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ function sdp_solve_DH(model::StochDynProgModel,
237237
#Compute cartesian product spaces
238238
product_states, product_controls = generate_grid(model, param)
239239

240+
product_controls = collect(product_controls)
241+
240242
V = zeros(Float64, param.stateVariablesSizes..., TF)
241243

242244
#Compute final value functions
@@ -359,6 +361,8 @@ function sdp_solve_HD(model::StochDynProgModel,
359361
#Compute cartesian product spaces
360362
product_states, product_controls = generate_grid(model, param)
361363

364+
product_controls = collect(product_controls)
365+
362366
V = zeros(Float64, param.stateVariablesSizes..., TF)
363367

364368
#Compute final value functions

0 commit comments

Comments
 (0)