@@ -342,6 +342,7 @@ type MPCSettings
342
342
printLevel:: Int64
343
343
expandGoal:: Bool # bool to indicate if the goal needs to be expanded
344
344
enlargeGoalTolFactor:: Int64 # scaling factor to enlare the goal
345
+ onlyOptimal:: Bool
345
346
end
346
347
347
348
function MPCSettings ()
@@ -357,7 +358,8 @@ function MPCSettings()
357
358
true ,
358
359
2 ,
359
360
true ,
360
- 2
361
+ 2 ,
362
+ false
361
363
)
362
364
end
363
365
@@ -855,7 +857,7 @@ function postProcess!(n;kwargs...)
855
857
n. r. ocp. tst = n. r. ocp. tctr
856
858
end
857
859
858
- if n. r. ocp. status== :Optimal || (n. s. mpc. on && isequal (n. mpc. v. evalNum,1 ))
860
+ if n. r. ocp. status== :Optimal || (! n . s . mpc . onlyOptimal && n. s. mpc. on && isequal (n. mpc. v. evalNum,1 ))
859
861
if (! isequal (n. r. ocp. status,:Optimal ) && n. s. mpc. on && isequal (n. mpc. v. evalNum,1 ))
860
862
warn (" There is no previous :Optimal solution to use since isequal(n.mpc.v.evalNum,1). \n
861
863
Attemting to extract: " ,n. r. ocp. status," solution. \n
@@ -871,7 +873,7 @@ function postProcess!(n;kwargs...)
871
873
n. r. ocp. U[:,ctr] = getvalue (n. r. ocp. u[:,ctr])
872
874
end
873
875
874
- elseif n. s. mpc. on && n. s. mpc. lastOptimal
876
+ elseif n. s. mpc. on && n. s. mpc. lastOptimal && ! n . s . mpc . onlyOptimal
875
877
if ! n. s. ocp. save
876
878
error (" This functionality currently needs to have n.s.save==true" )
877
879
end
@@ -910,6 +912,10 @@ function postProcess!(n;kwargs...)
910
912
n. r. ocp. U[:,ctr] = n. r. ocp. dfs[optIdx][n. ocp. control. name[ctr]][timeIdx: end - 1 ]
911
913
end
912
914
end
915
+ else
916
+ warn (" The solution is not Optimal \n
917
+ Setting: n.f.mpc.simFailed = [true, n.r.ocp.status] " )
918
+ n. f. mpc. simFailed = [true , n. r. ocp. status]
913
919
end
914
920
if n. s. ocp. evalConstraints && n. r. ocp. status!= :Error # note may want to remove the && arg
915
921
evalConstraints! (n)
0 commit comments