// ---------------------------------------------------------- // Hybrid System Example: Bouncing Ball // ---------------------------------------------------------- // This version produces a plot of position over time. // A clock is added to the system to model time explicitly. // This gives us a another choice of partitioning: along // the time-axis. It's fast, but doesn't work with convex // hull. // // The complexity of this example requires us to put limits // on the bits used in polyhedral computations. // Otherwise, it may take very long or not terminate at all. REACH_CONSTRAINT_LIMIT = 48; REACH_CONSTRAINT_TRIGGER = 96; CONSTRAINT_BITSIZE = 24; REACH_BITSIZE_TRIGGER = 200; // ---------------------------------------------------------- // Constants // ---------------------------------------------------------- g:=1; // constant for gravity // ---------------------------------------------------------- // System Description // ---------------------------------------------------------- automaton bouncing_ball contr_var: t, x, v; synclabs: jump; loc state: while x>=0 & x<=10 & v<=10 & v>=-10 & t<=5 & t>=0 wait {x'==v & v'==-g & t'==1} when x==0 & v<0 sync jump do {v'==-v*0.5 & x'==x & t'==t} goto state; initially: state & x==2 & v==0 & t==0; end // ---------------------------------------------------------- // Define Partitioning // ---------------------------------------------------------- // Add a new label for the transitions that are introduced // between partitions bouncing_ball.add_label(tau); // Define the directions of the partitions // here: in both axes with a min. threshold of partition size 0.2 bouncing_ball.set_refine_constraints((x, 0.2),(v,0.2),tau); // With this partitioning we can use convex hull overapproximations, // resulting in fewer polyhedra (one per partition) //REACH_USE_CONVEX_HULL=true; // ---------------------------------------------------------- // Define Partitioning (alternative 1) // ---------------------------------------------------------- // We can also just partition in the v-direction, but then // we must turn off convex hull (try it...) // bouncing_ball.set_refine_constraints((v,0.2),tau); // REACH_USE_CONVEX_HULL=false; // ---------------------------------------------------------- // Define Partitioning (alternative 2) // ---------------------------------------------------------- // We can also just partition in the t-direction, but then // we must turn off convex hull // and refine the time-elapse operator at least twice // at every step (try it...) //TIME_POST_ITER=2; //bouncing_ball.set_refine_constraints((t, 0.1),tau); //REACH_USE_CONVEX_HULL=false; // ---------------------------------------------------------- // Analysis Commands // ---------------------------------------------------------- reg=bouncing_ball.reachable; // ---------------------------------------------------------- // Saving Data for Graphical Output // ---------------------------------------------------------- reg.project_to(t, x); // remove v to get a 2-dim output reg.print("out_reach",2); // output as a list of vertices // for display with graph use, e.g.: // graph -T X -C -B -q0.5 out_reach // for display with matlab use, e.g.: // plot_2d_vertices('out_m_reach')