Quick ExampleTo give a feel of what can be done using the toolbox a quick example of how a discrete equivalent can be found for an affine system on a simplex. Finding a discrete equivalent
%First define the state space simplex s.dim=2; s.vertices={[2;1],[1;2],[1,1]}; s=makesimplex(s); %Then the system s.dynamics.A=[0 1; 0 -0.3]; s.dynamics.B=[0;1]; s.dynamics.C=[0;0]; %Now the input polytope (in this case it is a simplex) s.input.dim=1; s.input.vertices={1,-1}; s.input=makesimplex(s.input); %Prepare the simplex for computations s=preparesimplex(s); %Find a discrete equivalent de=finddiscreteeq(s); %Plot the result plotdisceq(s,de); The example above is a model of a block sliding on a 1-D surface with viscous friction. The input is the force applied on the block by e.g. a rod. The following example shows how controllers for a PAHS can generated. Computing a control strategy for a PAHS
%First define the pahs. %This PAHS is included in the toolbox. pahs=demopahs2(); %Compute the discrete abstraction dgabs=finddiscgame(pahs); %Define the control requirements req=demoreq2(); %Convert the requirements to a specification on the discrete abstraction spec=req2spec(pahs,req) %Find a winning strategy [win,sol]=finddgsol(dgabs,spec); %Is there a winning strategy if(win) disp('Winning strategy found!'); %Compute control laws based on the strategy ctcat=sol2ctrl(pahs,dgabs,sol); %Parameters for the simulation: %Initial location and mode l0=req.init{1}.loc; m0=req.init{1}.modes(1); %Initial state x0=mean(horzcat(pahs.mode{m0}.loc{l0}.s.vertices{:}),2); %Set up the occurrence of events events{1}.time=3; events{1}.mode=2; %Simulation time simtime=1000; %Timestep step=.5; %Simulate the controlled pahs [x,t,m,l]=simpahs(pahs,ctcat,x0,l0,m0,simtime,events,step); %Plot the results plotpahs(pahs,spec,x,t,events,m0); else disp('No winning strategy found!') end The above example can be found as example2.m in the demo directory of the toolbox |