@@ -73,27 +73,28 @@ function forward_simulations(model::SPModel,
7373 state_t = extract_vector_from_3Dmatrix (stocks, t, k)
7474 alea_t = extract_vector_from_3Dmatrix (xi, t, k)
7575
76- status, nextstep = solve_one_step_one_alea (
76+ if ~ init
77+ status, nextstep = solve_one_step_one_alea (
7778 model,
7879 param,
7980 solverProblems[t],
8081 t,
8182 state_t,
82- alea_t,
83- init)
84-
85- if status
86- stocks[t+ 1 , k, :] = nextstep. next_state
87- opt_control = nextstep. optimal_control
88- controls[t, k, :] = opt_control
89- costs[k] += nextstep. cost - nextstep. cost_to_go
90- if t== T- 1
91- costs[k] += nextstep. cost_to_go
83+ alea_t)
84+ if status
85+ stocks[t+ 1 , k, :] = nextstep. next_state
86+ opt_control = nextstep. optimal_control
87+ controls[t, k, :] = opt_control
88+ costs[k] += nextstep. cost - nextstep. cost_to_go
89+ if t== T- 1
90+ costs[k] += nextstep. cost_to_go
91+ end
92+ else
93+ stocks[t+ 1 , k, :] = state_t
9294 end
9395 else
94- stocks[t+ 1 , k, :] = state_t
96+ stocks[t+ 1 , k, :] = [model . xlim[i][ 1 ] + rand () * (model . xlim[i][ 2 ] - model . xlim[i][ 1 ]) for i in 1 : model . dimStates]
9597 end
96-
9798 end
9899 end
99100 return costs, stocks, controls
0 commit comments