⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 states_sd2.m

📁 一个matlab的将军模型
💻 M
字号:
function states_sd2
% Function  	: PlotPoly                          
% Credate   	: 07/20/99		                  
% CURDATE		: 07/24/99   
% Description	: This function draw the polytope related with 
%                each  location  reachable  from  the initial 
%                locations, using GLOBAL_TRANSITIONS structure


% clear figure and make initial arrangements to plot

global_var;

time = cputime
clf;
hold on;

GT = GLOBAL_TRANSITION;

iloc = unique(GLOBAL_PIHA.InitialLocations);
omniloc = iloc;
omni_end = 0;

while ~omni_end
   newloc = [];
   for i=1:length(iloc)
      lfs = GLOBAL_XSYS2AUTO_MAP{iloc(i)}(1);
      test_lfs = strcmp(lfs,'null_event')|strcmp(lfs,'terminal')|...
            	strcmp(lfs,'indeterminate')|strcmp(lfs,'out_of_bound')|...
               strcmp(lfs,'time_limit');
      if test_lfs
         newloc = unique([newloc iloc(i)]);
      else
	   	sf_val = GLOBAL_PIHA.Locations{lfs}.q([1 2]);
   		END=0;
   		while ~END
	      	cv = GT{iloc(i)};
	      	aux=[];
	      	END=1;
            if (length(cv) ~=1)|(iloc(i)~=cv(1))
               change = 0;
               for j= 1:length(cv)
                 lfst=GLOBAL_XSYS2AUTO_MAP{cv(j)}(1);
                 if strcmp(lfst,'null_event')|strcmp(lfst,'terminal')|...
            		  strcmp(lfst,'indeterminate')|strcmp(lfst,'out_of_bound')|...
            		  strcmp(lfs,'time_limit')
                 	  aux = [aux cv(j)];
   				  else              
                    sf_val_test = GLOBAL_PIHA.Locations{GLOBAL_XSYS2AUTO_MAP{cv(j)}(1)}.q([1 2]);
                    if sf_val_test(2)~=sf_val(2)
                       change=1;
                    end
                    if (sf_val_test(1)~=sf_val(1))& change
                       aux = [aux cv(j)];
                       change=0;
	     				  else
                       aux = [aux GT{cv(j)}];
                       if (length(cv)~=1)  
                          END=0;                         
                       end
                    end
                 end
	      		end
	         else
	           if (iloc(i)==cv(1))
	              aux = [aux cv(j)];
	           end
	        	end
	      	GT{iloc(i)}=unique(aux);
	      end
         newloc = unique([newloc aux]);
      end
	end
	last_omniloc = omniloc;
	iloc =unique(setdiff(newloc,omniloc));
	omniloc = unique([iloc omniloc])
	if length(last_omniloc)==length(omniloc)
   	if last_omniloc == omniloc
      	omni_end = 1;
   	end
	end
end
%save test GT omniloc;

initloc = unique(GLOBAL_PIHA.InitialLocations);
omniloc =unique(setdiff(omniloc,initloc));

for i=1:length(initloc)
   plot(GLOBAL_AUTOMATON{i}.initstate{length(GLOBAL_AUTOMATON{i}.initstate)}.polytope)
   hold on ;
end

for i=1:length(omniloc)
   var_location 	= GLOBAL_XSYS2AUTO_MAP{omniloc(i)}(1);
   if ~(strcmp(var_location,'terminal'))& ~(strcmp(var_location,'out_of_bound'))&...
      ~(strcmp(var_location,'indeterminate'))&~(strcmp(var_location,'time_limit'))&...
      ~(strcmp(var_location,'out_of_bound'))   
   	var_face			= GLOBAL_XSYS2AUTO_MAP{omniloc(i)}(2);
      var_state		= GLOBAL_XSYS2AUTO_MAP{omniloc(i)}(3);
      hold on;
      plot(GLOBAL_AUTOMATON{var_location}.face{var_face}.state{var_state}.polytope,[1 1 1]);%[sqrt(i)/i (length(actloc) - i)/length(actloc) log(i+1)/(i+1)]);
  	end
end

return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -