@@ -78,11 +78,6 @@ function build_sdpmodel_from_spmodel(model::SPModel)
7878
7979 if isa (model,PiecewiseLinearCostSPmodel)|| isa (model,LinearDynamicLinearCostSPmodel)
8080 function cons_fun (t,x,u,w)
81- for i in 1 : model. dimStates
82- if (x[i]< model. xlim[i][1 ]) || (x[i]> model. xlim[i][2 ])
83- return false
84- end
85- end
8681 return true
8782 end
8883 if in (:finalCostFunction ,fieldnames (model))
@@ -418,7 +413,7 @@ function get_control(model::SPModel,param::SDPparameters,V, t::Int64, x::Array)
418413
419414 next_state = SDPmodel. dynamics (t, x, u, w_sample)
420415
421- if SDPmodel. constraints (t, next_state , u, w_sample)
416+ if SDPmodel. constraints (t, x , u, w_sample) && SDPutils . is_next_state_feasible (next_state, model . dimStates, model . xlim )
422417 ind_next_state = SDPutils. real_index_from_variable (next_state, x_bounds, x_steps)
423418 next_V = Vitp[ind_next_state... ]
424419 current_V += proba * (SDPmodel. costFunctions (t, x, u, w_sample) + next_V)
@@ -481,7 +476,7 @@ function get_control(model::SPModel,param::SDPparameters,V, t::Int64, x::Array,
481476
482477 next_state = SDPmodel. dynamics (t, x, u, w)
483478
484- if SDPmodel. constraints (t, next_state , u, w)
479+ if SDPmodel. constraints (t, x , u, w) && SDPutils . is_next_state_feasible (next_state, model . dimStates, model . xlim )
485480 ind_next_state = SDPutils. real_index_from_variable (next_state, x_bounds, x_steps)
486481 next_V = Vitp[ind_next_state... ]
487482 current_V = SDPmodel. costFunctions (t, x, u, w) + next_V
@@ -586,7 +581,7 @@ function sdp_forward_single_simulation(model::StochDynProgModel,
586581
587582 next_state = model. dynamics (t, x, u, w_sample)
588583
589- if model. constraints (t, next_state , u, w_sample)
584+ if model. constraints (t, x , u, w_sample) && SDPutils . is_next_state_feasible (next_state, model . dimStates, model . xlim )
590585 ind_next_state = SDPutils. real_index_from_variable (next_state, x_bounds, x_steps)
591586 next_V = Vitp[ind_next_state... ]
592587 current_V += proba * (model. costFunctions (t, x, u, w_sample) + next_V)
@@ -629,7 +624,7 @@ function sdp_forward_single_simulation(model::StochDynProgModel,
629624
630625 next_state = model. dynamics (t, x, u, scenario[t,1 ,:])
631626
632- if model. constraints (t, next_state , u, scenario[t])
627+ if model. constraints (t, x , u, scenario[t]) && SDPutils . is_next_state_feasible (next_state, model . dimStates, model . xlim )
633628 ind_next_state = SDPutils. real_index_from_variable (next_state, x_bounds, x_steps)
634629 next_V = Vitp[ind_next_state... ]
635630 current_V = model. costFunctions (t, x, u, scenario[t,1 ,:]) + next_V
0 commit comments