% This function is part of the NMSM Pipeline, see file for full license.
%
% This function sets up the common bounds for an optimal control problem
% and is used by Tracking Optimization, Verification Optimization, and
% Design Optimization
%
% () => ()
% return a set of setup values common to all optimal control problems
function bounds = setupCommonOptimalControlBounds(inputs, params)
% setup time bounds
bounds.phase.initialtime.lower = -0.5;
bounds.phase.initialtime.upper = -0.5;
bounds.phase.finaltime.lower = 0.5;
bounds.phase.finaltime.upper = 0.5;
% setup state bounds
bounds.phase.initialstate.lower = -0.5 * ones(1, length(inputs.minState));
bounds.phase.initialstate.upper = 0.5 * ones(1, length(inputs.minState));
bounds.phase.finalstate.lower = -0.5 * ones(1, length(inputs.minState));
bounds.phase.finalstate.upper = 0.5 * ones(1, length(inputs.minState));
bounds.phase.state.lower = -0.5 * ones(1, length(inputs.minState));
bounds.phase.state.upper = 0.5 * ones(1, length(inputs.minState));
% setup path constraint bounds
bounds.phase.path.lower = -0.5 * ones(1, length(inputs.minPath));
bounds.phase.path.upper = 0.5 * ones(1, length(inputs.minPath));
% setup control bounds
bounds.phase.control.lower = -0.5 * ones(1, length(inputs.minControl));
bounds.phase.control.upper = 0.5 * ones(1, length(inputs.minControl));
% setup integral bounds
bounds.phase.integral.lower = zeros(1, length(inputs.minIntegral));
bounds.phase.integral.upper = params.solverSettings.integralBound * ones(1, length(inputs.minIntegral));
% setup terminal constraint bounds
if ~isempty(inputs.minTerminal)
bounds.eventgroup.lower = inputs.minTerminal;
end
if ~isempty(inputs.maxTerminal)
bounds.eventgroup.upper = inputs.maxTerminal;
end
end