Simulate a Controlled PAHS

The simulator included in the toolbox uses a 2nd order trapezoid integration method especially taylored to detect when a guard has been crossed. In order to perform a simulation the user needs to specify initial mode,location and state as well as the timing of external events.

The output of a simulation is:

  • x: A vector of state values

  • t: A timevector

  • l: A vector of locations

  • m: A vector of modes

Simulating a Control Strategy
%Compute a controller catalogue
pahs=demopahs2();
dgabs=finddiscgame(pahs);
req=demoreq2();
spec=req2spec(pahs,req);
[win,sol]=finddgsol(dgabs,spec);
if(win)
   disp('Winning')
   ctcat=sol2ctrl(pahs,dgabs,sol);

   %Setup 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);

end