代码拉取完成,页面将自动刷新
同步操作将从 NUDTexplorer/OptimTraj 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
function problem = inputValidation(problem)
%
% This function runs through the problem struct and sets any missing fields
% to the default value. If a mandatory field is missing, then it throws an
% error.
%
% INPUTS:
% problem = a partially completed problem struct
%
% OUTPUTS:
% problem = a complete problem struct, with validated fields
%
%%%% Check the function handles:
if ~isfield(problem,'func')
error('Field ''func'' cannot be ommitted from ''problem''');
else
if ~isfield(problem.func,'dynamics')
error('Field ''dynamics'' cannot be ommitted from ''problem.func'''); end
if ~isfield(problem.func,'pathObj'), problem.func.pathObj = []; end
if ~isfield(problem.func,'bndObj'), problem.func.bndObj = []; end
if ~isfield(problem.func,'pathCst'), problem.func.pathCst = []; end
if ~isfield(problem.func,'bndCst'), problem.func.bndCst = []; end
end
%%%% Check the initial guess (also compute nState and nControl):
if ~isfield(problem, 'guess')
error('Field ''guess'' cannot be ommitted from ''problem''');
else
if ~isfield(problem.guess,'time')
error('Field ''time'' cannot be ommitted from ''problem.guess'''); end
if ~isfield(problem.guess, 'state')
error('Field ''state'' cannot be ommitted from ''problem.guess'''); end
if ~isfield(problem.guess, 'control')
error('Field ''control'' cannot be ommitted from ''problem.guess'''); end
% Compute the size of the time, state, and control based on guess
[checkOne, nTime] = size(problem.guess.time);
[nState, checkTimeState] = size(problem.guess.state);
[nControl, checkTimeControl] = size(problem.guess.control);
if nTime < 2 || checkOne ~= 1
error('guess.time must have dimensions of [1, nTime], where nTime > 1');
end
if checkTimeState ~= nTime
error('guess.state must have dimensions of [nState, nTime]');
end
if checkTimeControl ~= nTime
error('guess.control must have dimensions of [nControl, nTime]');
end
end
%%%% Check the problem bounds:
if ~isfield(problem,'bounds')
problem.bounds.initialTime = [];
problem.bounds.finalTime = [];
problem.bounds.state = [];
problem.bounds.initialState = [];
problem.bounds.finalState = [];
problem.bounds.control = [];
else
if ~isfield(problem.bounds,'initialTime')
problem.bounds.initialTime = []; end
problem.bounds.initialTime = ...
checkLowUpp(problem.bounds.initialTime,1,1,'initialTime');
if ~isfield(problem.bounds,'finalTime')
problem.bounds.finalTime = []; end
problem.bounds.finalTime = ...
checkLowUpp(problem.bounds.finalTime,1,1,'finalTime');
if ~isfield(problem.bounds,'state')
problem.bounds.state = []; end
problem.bounds.state = ...
checkLowUpp(problem.bounds.state,nState,1,'state');
if ~isfield(problem.bounds,'initialState')
problem.bounds.initialState = []; end
problem.bounds.initialState = ...
checkLowUpp(problem.bounds.initialState,nState,1,'initialState');
if ~isfield(problem.bounds,'finalState')
problem.bounds.finalState = []; end
problem.bounds.finalState = ...
checkLowUpp(problem.bounds.finalState,nState,1,'finalState');
if ~isfield(problem.bounds,'control')
problem.bounds.control = []; end
problem.bounds.control = ...
checkLowUpp(problem.bounds.control,nControl,1,'control');
end
end
function input = checkLowUpp(input,nRow,nCol,name)
%
% This function checks that input has the following is true:
% size(input.low) == [nRow, nCol]
% size(input.upp) == [nRow, nCol]
if ~isfield(input,'low')
input.low = -inf(nRow,nCol);
end
if ~isfield(input,'upp')
input.upp = inf(nRow,nCol);
end
[lowRow, lowCol] = size(input.low);
if lowRow ~= nRow || lowCol ~= nCol
error(['problem.bounds.' name ...
'.low must have size = [' num2str(nRow) ', ' num2str(nCol) ']']);
end
[uppRow, uppCol] = size(input.upp);
if uppRow ~= nRow || uppCol ~= nCol
error(['problem.bounds.' name ...
'.upp must have size = [' num2str(nRow) ', ' num2str(nCol) ']']);
end
if sum(sum(input.upp-input.low < 0))
error(...
['problem.bounds.' name '.upp must be >= problem.bounds.' name '.low!']);
end
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。