@@ -527,14 +527,19 @@ function sdp_forward_single_simulation(model::StochDynProgModel,
527527 V,
528528 display= true :: Bool )
529529
530+ if VERSION . minor < 5
531+ scenario = reshape (scenario, size (scenario, 1 ), size (scenario, 3 ))
532+ end
530533 TF = model. stageNumber
531534 law = model. noises
532535 u_bounds = model. ulim
533536 x_bounds = model. xlim
534537 x_steps = param. stateSteps
535538
536539 # Compute cartesian product spaces
537- product_states, product_controls = generate_grid (model, param)
540+ p_states, p_controls = generate_grid (model, param)
541+ product_states = collect (p_states)
542+ product_controls = collect (p_controls)
538543
539544 controls = Inf * ones (TF- 1 , 1 , model. dimControls)
540545 states = Inf * ones (TF, 1 , model. dimStates)
@@ -591,7 +596,7 @@ function sdp_forward_single_simulation(model::StochDynProgModel,
591596 current_V = current_V/ count_admissible_w
592597 if (current_V < best_V)& (count_admissible_w> 0 )
593598 best_control = u
594- best_state = model. dynamics (t, x, u, scenario[t,1 , :])
599+ best_state = model. dynamics (t, x, u, scenario[t,:])
595600 best_V = current_V
596601 end
597602 end
@@ -607,7 +612,7 @@ function sdp_forward_single_simulation(model::StochDynProgModel,
607612 index_state = index_state + 1
608613 states[t+ 1 ,1 ,index_state] = xj
609614 end
610- J += model. costFunctions (t, x, best_control, scenario[t,1 , :])
615+ J += model. costFunctions (t, x, best_control, scenario[t,:])
611616 end
612617
613618 else
@@ -622,15 +627,15 @@ function sdp_forward_single_simulation(model::StochDynProgModel,
622627
623628 for u = product_controls
624629
625- next_state = model. dynamics (t, x, u, scenario[t,1 , :])
630+ next_state = model. dynamics (t, x, u, scenario[t,:])
626631
627632 if model. constraints (t, x, u, scenario[t])&& SDPutils. is_next_state_feasible (next_state, model. dimStates, model. xlim)
628633 ind_next_state = SDPutils. real_index_from_variable (next_state, x_bounds, x_steps)
629634 next_V = Vitp[ind_next_state... ]
630- current_V = model. costFunctions (t, x, u, scenario[t,1 , :]) + next_V
635+ current_V = model. costFunctions (t, x, u, scenario[t,:]) + next_V
631636 if (current_V < best_V)
632637 best_control = u
633- best_state = model. dynamics (t, x, u, scenario[t,1 , :])
638+ best_state = model. dynamics (t, x, u, scenario[t,:])
634639 best_V = current_V
635640 end
636641 end
@@ -647,7 +652,7 @@ function sdp_forward_single_simulation(model::StochDynProgModel,
647652 index_state = index_state + 1
648653 states[t+ 1 ,1 ,index_state] = xj
649654 end
650- J += model. costFunctions (t, x, best_control, scenario[t,1 , :])
655+ J += model. costFunctions (t, x, best_control, scenario[t,:])
651656 end
652657 end
653658
0 commit comments