% This function is part of the NMSM Pipeline, see file for full license.
%
% This function parses and loads the initial guesses for states (if
% specified), controls (if specified), and parameters (if specified)
%
% (struct) -> (struct)
%
function initialGuess = getGpopsInitialGuess(tree)
import org.opensim.modeling.Storage
initialGuess = [];
statesFileName = getTextFromField(getFieldByNameOrAlternate(tree, ...
'initial_states_file', ''));
if ~isempty(statesFileName)
initialGuess.time = parseTimeColumn({statesFileName})';
initialGuess.stateLabels = getStorageColumnNames(Storage({statesFileName}));
initialGuess.state = parseTreatmentOptimizationStandard({statesFileName});
end
controlsFileName = getTextFromField(getFieldByNameOrAlternate(tree, ...
'initial_controls_file', ''));
if ~isempty(controlsFileName)
initialGuess.controlLabels = getStorageColumnNames(Storage({controlsFileName}));
initialGuess.control = parseTreatmentOptimizationStandard({controlsFileName});
end
parametersFileName = getTextFromField(getFieldByNameOrAlternate(tree, ...
'initial_parameters_file', ''));
if ~isempty(parametersFileName)
initialGuess.parameterLabels = getStorageColumnNames(Storage({parametersFileName}));
initialGuess.parameter = parseTreatmentOptimizationStandard({parametersFileName});
end
end