📄 find_children.m
字号:
function [out_of_bound,terminal,children] = find_children(srcloc,mapping)
% Find children (destination) `face` states for the given `mapping set`
% and the source location.
%
% Syntax:
% "[out_of_bound,terminal,children] = find_children(srcloc,mapping)"
%
% Description:
% The inputs to this function are
%
% * "srcloc": the source location
%
% * "mapping": the `mapping set`, which is a cell array of "linearcon"
% objects. A `mapping set` is the set of states on the boundary faces of
% the location `invariant` that can be reached under the given continuous
% dynamics from the initial continuous set.
%
% The outputs from this function are
%
% * "children": a matrix whose rows are the `face` state indices of the
% form "[loc face state]" indicating the destination states for the
% given "mapping" and "srcloc"
%
% * "out_of_bound": the `out-of-bound` flag, which is set to 1 if part
% of "mapping" is on the analysis region boundary and 0 otherwise
%
% * "terminal": if the mapping reaches the invariant faces that make
% transitions to `terminal` FSM states, the FSM state vectors for those
% `terminal` FSM states are stored in the elements of the cell array
% "terminal".
%
% See Also:
% piha,iauto_part,iauto_build,compute_mapping
% Global variables (used as reference only in this function)
global GLOBAL_PIHA GLOBAL_AUTOMATON
if isempty(mapping)
error('Empty mapping given.')
else
% set default out-of-bound flag to be 0
out_of_bound = 0;
terminal = {};
children = [];
% identify the destination location on each face to find intersection
for i = 1:length(mapping)
if ~isempty(mapping{i})
% find destination location(s) for transition through ith inv. face
transitions_i = GLOBAL_PIHA.Locations{srcloc}.transitions{i};
for j = 1:length(transitions_i)
switch transitions_i(j).type
case 'out_of_bound'
out_of_bound = 1;
case 'terminal'
%Test to see if any out of bound transitions are 'covered' by mapping
term_cell=transitions_i(j).terminal_cell;
current_cell=GLOBAL_PIHA.Locations{srcloc}.p;
hyp=GLOBAL_PIHA.Cells{current_cell}.boundary(i);
term_face=get_cell_face(term_cell,hyp);
for q=1:length(mapping{i})
if isfeasible(term_face,mapping{i}{q})
terminal{length(terminal)+1} = transitions_i(j).destination;
break;
end
end
case 'regular'
dstloc = transitions_i(j).destination;
% find hyperplane for the ith invariant face
srccell = GLOBAL_PIHA.Locations{srcloc}.p;
srchp = GLOBAL_PIHA.Cells{srccell}.boundary(i);
dstcell = GLOBAL_PIHA.Locations{dstloc}.p;
% find destination face in destination location for the ith
% invariant face in the source location
for m = 1:length(GLOBAL_PIHA.Cells{dstcell}.boundary)
if (srchp == GLOBAL_PIHA.Cells{dstcell}.boundary(m))
dstface = m;
break;
end
end
% now find intersection between states on the destination face
for m = 1:length(GLOBAL_AUTOMATON{dstloc}.face{dstface}.state)
for n = 1:length(mapping{i})
polytope = get_auto_state('current',...
[dstloc dstface m],'polytope');
non_reachable = get_auto_state('current',...
[dstloc dstface m],'non_reachable');
if isfeasible(polytope,mapping{i}{n})& ~non_reachable
children = [children; dstloc dstface m];
break;
end
end
end
end % switch
end % for j = 1:length(transitions_i)
end % if ~empty(mapping{i})
end % for
end
%--------------------------------------------------------------------------
function face=get_cell_face(cell,hyperplane)
global GLOBAL_PIHA
%This function takes a GLOBAL_PIHA cell and a hyperplane and returns the polytope that represents
%the face of the cell that is described by the hyperplane.
boundary = GLOBAL_PIHA.Cells{cell}.boundary;
hpflags = GLOBAL_PIHA.Cells{cell}.hpflags;
C = []; d = [];
for l = 1:length(boundary)
if hpflags(l)
C(l,:) = GLOBAL_PIHA.Hyperplanes{boundary(l)}.c;
d(l,:) = GLOBAL_PIHA.Hyperplanes{boundary(l)}.d;
else
C(l,:) = -GLOBAL_PIHA.Hyperplanes{boundary(l)}.c;
d(l,:) = -GLOBAL_PIHA.Hyperplanes{boundary(l)}.d;
end
end
Ci=C;
Di=d;
ce=GLOBAL_PIHA.Hyperplanes{hyperplane}.c;
de=GLOBAL_PIHA.Hyperplanes{hyperplane}.d;
face=linearcon(ce,de,C,d);
face=clean_up(face);
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -