% This function is part of the NMSM Pipeline, see file for full license.
%
% This function parses and scales the design variables common to all
% treatment optimization modules (tracking, verification, and design
% optimization). Time, states, and controls are parsed and scaled back to
% their original values.
%
% (struct, struct) -> (struct)
% Design variables common to all treatment optimization modules are parsed
function values = getTreatmentOptimizationValueStruct(inputs, params)
values.time = scaleToOriginal(inputs.time, params.maxTime, ...
params.minTime);
state = scaleToOriginal(inputs.state, ones(size(inputs.state, 1), 1) .* ...
params.maxState, ones(size(inputs.state, 1), 1) .* params.minState);
control = scaleToOriginal(inputs.control, ones(size(inputs.control, 1), 1) .* ...
params.maxControl, ones(size(inputs.control, 1), 1) .* params.minControl);
values.statePositions = getCorrectStates(state, 1, params.numCoordinates);
values.stateVelocities = getCorrectStates(state, 2, params.numCoordinates);
values.stateAccelerations = getCorrectStates(state, 3, params.numCoordinates);
values.controlJerks = control(:, 1 : params.numCoordinates);
if ~strcmp(params.controllerType, 'synergy_driven')
values.controlTorques = control(:, params.numCoordinates + 1 : ...
params.numCoordinates + params.numTorqueControls);
else
values.controlSynergyActivations = control(:, ...
params.numCoordinates + 1 : params.numCoordinates + params.numSynergies);
end
end