def test_sir_pca_strat(): #Compute Sapo's version.3 sir_pca = SIR_UnitBox(delta=0.5) sir = SIR(delta=0.5) sir_reach = ReachSet(sir) sir_flow = sir_reach.computeReachSet(NUM_STEPS) sir_plot = Plot() sir_plot.add(sir_flow, "SIR SAPO") for i in range(ITER_SPREAD, ITER_SPREAD + 1): print( colored("Generating PCA with Iterative Step Size: {}".format(i), "white", attrs=['reverse', 'blink'])) sir_pca_reach = ReachSet(sir_pca) sir_flow_pca = sir_pca_reach.computeReachSet( NUM_STEPS, tempstrat=PCAStrat(sir_pca, iter_steps=i), transmode=BundleMode.AFO) sir_plot.add(sir_flow_pca, "SIR_PCA_{}".format(i)) sir_plot.plot2DPhase(0, 1, separate=False, plotvertices=True) #sir_plot.plot(0,1,2) Timer.generate_stats() """
def test_VDP(): model = VanDerPol() mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(200) FlowPipePlotter(mod_flow).plot2DPhase(0,1)
def test_sir_lin_pca_strat(): NUM_STEPS = 70 SIR_PCA_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. 'PCA Strategy Parameters' SIR_PCA_TRAJ_STEPS = 1 #Number of steps our sample trajectories should run. SIR_PCA_NUM_TRAJ = 100 #Number of sample trajectories we should use for the PCA routine. SIR_LIN_ITER_STEPS = 1 # SIR_PCA_LIFE_SPAN = 3 sir_pca = SIR_UnitBox(delta=0.5) sir_plot = Plot() points = [[0.79,0.19,0], [0.79, 0.2,0], [0.8,0.19,0], [0.8,0.2,0], [0.79,0.195,0], [0.8,0.195,0], [0.795,0.19,0], [0.795,0.2,0]] trajs = [Traj(sir_pca, point, NUM_STEPS) for point in points] pca_strat = MultiStrategy(LinStrat(sir_pca, iter_steps=SIR_LIN_ITER_STEPS), \ DelayedPCAStrat(sir_pca, traj_steps=SIR_PCA_TRAJ_STEPS, num_trajs=SIR_PCA_NUM_TRAJ, life_span=SIR_PCA_LIFE_SPAN)) sir_pca_reach = ReachSet(sir_pca) sir_flow_pca = sir_pca_reach.computeReachSet(NUM_STEPS, tempstrat=pca_strat) sir_plot.add(sir_flow_pca, "SIR_LinApp&PCA") 'Add trajectories' for traj in trajs: sir_plot.add(traj) # sir_plot.plot2DPhase(0,1,separate=False, plotvertices=True) sir_plot.plot2DPhase(1,2,separate=False, plotvertices=True) sir_plot.plot2DPhase(0,2,separate=False, plotvertices=True) Timer.generate_stats()
def test_phase_sir(): sir_mod = SIR() sir_reach = ReachSet(sir_mod) flowpipe = sir_reach.computeReachSet(300) FlowPipePlotter(flowpipe).plot2DPhase(0, 1)
def test_pca_lin_Phos(): NUM_STEPS = 30 PHOS_LIN_ITER_STEPS = 1 #Number of steps between each recomputation of LinApp Templates. PHOS_PCA_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. 'PCA Strategy Parameters' PHOS_PCA_TRAJ_STEPS = 5 #Number of steps our sample trajectories should run. PHOS_PCA_NUM_TRAJ = 200 #Number of sample trajectories we should use for the PCA routine. PHOS_LIFE_SPAN = 3 unit_model = Phosphorelay_UnitBox() unit_mod_reach = ReachSet(unit_model) #points = [[1,1,1], [1.005, 1,1], [1.01,1.01,1.01], [1.005,1.01,1.01], [1,1.005,1], [1.01,1,1.05]] #trajs = [Traj(unit_model , point, NUM_STEPS) for point in points] multi_strat = MultiStrategy(LinStrat(unit_model, iter_steps=PHOS_LIN_ITER_STEPS), \ DelayedPCAStrat(unit_model, traj_steps=PHOS_PCA_TRAJ_STEPS, num_trajs=PHOS_PCA_NUM_TRAJ, life_span=PHOS_LIFE_SPAN)) #PCAStrat(unit_model, traj_steps=PHOS_PCA_TRAJ_STEPS, num_trajs=PHOS_PCA_NUM_TRAJ, iter_steps=PHOS_PCA_ITER_STEPS+PHOS_PCA_DELAY)) #PCAStrat(unit_model, traj_steps=PHOS_PCA_TRAJ_STEPS, num_trajs=PHOS_PCA_NUM_TRAJ, iter_steps=PHOS_PCA_ITER_STEPS+2*PHOS_PCA_DELAY)) mod_lin_flow = unit_mod_reach.computeReachSet(NUM_STEPS, tempstrat=multi_strat) # points = [[0,1.97], [0.01, 1.97], [0.01,2], [0,2], [0.005,1.97], [0.005,2], [0,1.97], [0,1.985], [0.01,1.985]] #trajs = [Traj(unit_model, point, NUM_STEPS) for point in points] phos_plot = Plot() phos_plot.add(mod_lin_flow) 'Add trajectories' for traj in trajs: phos_plot.add(traj) phos_plot.plot2DPhase(0, 1, separate=False, plotvertices=True)
def test_sir_lin_strat(): #Compute Sapo's version. sir_lin = SIR_UnitBox(delta=0.5) sir = SIR() #sir_reach = ReachSet(sir) #sir_flow = sir_reach.computeReachSet(NUM_STEPS) sir_plot = Plot() #sir_plot.add(sir_flow) for i in range(10, 11): print( colored( "Generating Lin_Approx with Iterative Step Size: {}".format(i), "white", attrs=['reverse', 'blink'])) sir_lin_reach = ReachSet(sir_lin) sir_flow_lin = sir_lin_reach.computeReachSet( NUM_STEPS, LinStrat(sir_lin, iter_steps=i)) sir_plot.add(sir_flow_lin, "SIR_LIN_{}".format(i)) #sir_plot.plot(0,1,2) sir_plot.plot2DPhase(0, 1, separate=True) Timer.generate_stats() """
def test_phase_rossler(): basic_mod = Rossler() basic_reach = ReachSet(basic_mod) flowpipe = basic_reach.computeReachSet(100) FlowPipePlotter(flowpipe).plot2DPhase(0, 1)
def test_pca_lin_Rossler(): NUM_STEPS = 5 ROSS_PCA_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. 'PCA Strategy Parameters' ROSS_PCA_TRAJ_STEPS = 1 #Number of steps our sample trajectories should run. ROSS_PCA_NUM_TRAJ = 200 #Number of sample trajectories we should use for the PCA routine. rossler_pca = Rossler_UnitBox(delta=0.5) rossler_plot = Plot() points = [[0.05,4.95,0.05], [0.1,4.95,0.05], [0.05,5,0.05], [0.1,5,0.05], [0.05,4.95,0.05], [0.05,4.95,0.1], [0.1,4.95,0.1], [0.1,5,0.1]] trajs = [Traj(rossler_pca, point, NUM_STEPS) for point in points] pca_strat = PCALinStrat(rossler_pca, traj_steps=ROSS_PCA_TRAJ_STEPS, num_trajs=ROSS_PCA_NUM_TRAJ, iter_steps=ROSS_PCA_ITER_STEPS) ross_pca_reach = ReachSet(rossler_pca) ross_flow_pca = ross_pca_reach.computeReachSet(NUM_STEPS, tempstrat=pca_strat) rossler_plot.add(ross_flow_pca, "SIR_LinApp&PCA") 'Add trajectories' for traj in trajs: rossler_plot.add(traj) rossler_plot.plot2DPhase(0,1,separate=True, plotvertices=True) Timer.generate_stats()
def test_lin_HarOsc(): NUM_STEPS = 5 model = HarOsc() #trajs = generate_traj(model, 10, 200) mod_reach = ReachSet(model) #mod_flow = mod_reach.computeReachSet() sir_plot = Plot() #mod_flow = mod_reach.computeReachSet(NUM_STEPS) SIR_LIN_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. lin_strat = LinStrat(model, iter_steps=SIR_LIN_ITER_STEPS) mod_lin_flow = mod_reach.computeReachSet(NUM_STEPS, tempstrat=lin_strat, transmode=BundleMode.AFO) trajs = [Traj(model, point, steps=NUM_STEPS) for point in product([-5,-4],[0,1])] 'Generaste the trajectories and add them to the plot.' sir_plot.add(mod_lin_flow, "HarOsc LINAPP") for t in trajs: sir_plot.add(t) sir_plot.plot2DPhase(0,1, separate=True, plotvertices=True) Timer.generate_stats()
def test_pca_HarOsc(): NUM_STEPS = 4 model = HarOsc() #trajs = generate_traj(model, 10, 200) mod_reach = ReachSet(model) #mod_flow = mod_reach.computeReachSet() sir_plot = Plot() SIR_PCA_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. 'PCA Strategy Parameters' SIR_PCA_TRAJ_STEPS = 2 #Number of steps our sample trajectories should run. SIR_PCA_NUM_TRAJ = 100 #Number of sample trajectories we should use for the PCA routine. pca_strat = PCAStrat(model, traj_steps=SIR_PCA_TRAJ_STEPS, num_trajs=SIR_PCA_NUM_TRAJ, iter_steps=SIR_PCA_ITER_STEPS) mod_pca_flow = mod_reach.computeReachSet(NUM_STEPS, tempstrat=[pca_strat], transmode=BundleMode.AFO) #trajs = generate_traj(model, 10, 200) 'Generaste the trajectories and add them to the plot.' sir_plot.add(mod_pca_flow, "HarOsc PCA") sir_plot.plot2DPhase(0,1, separate=True, plotvertices=True) Timer.generate_stats()
def test_pca_Quad(): NUM_STEPS = 5 QUAD_PCA_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. 'PCA Strategy Parameters' QUAD_PCA_TRAJ_STEPS = 1 #Number of steps our sample trajectories should run. QUAD_PCA_NUM_TRAJ = 200 #Number of sample trajectories we should use for the PCA routine. quad_pca = Quadcopter_UnitBox() quad_plot = Plot() #trajs = [Traj(rossler_pca, point, NUM_STEPS) for point in points] pca_strat = PCAStrat(quad_pca, traj_steps=QUAD_PCA_TRAJ_STEPS, num_trajs=QUAD_PCA_NUM_TRAJ, iter_steps=QUAD_PCA_ITER_STEPS) quad_pca_reach = ReachSet(quad_pca) quad_flow_pca = quad_pca_reach.computeReachSet(NUM_STEPS, tempstrat=pca_strat) 'Add trajectories' #for traj in trajs: # rossler_plot.add(traj) quad_plot.add(quad_flow_pca, "Quad_PCA") quad_plot.plot2DPhase(2, 5, separate=True, plotvertices=True)
def test_LL(): model = LL() mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(150) FlowPipePlotter(mod_flow).plot2DProj(3) Timer.generate_stats()
def test_plot_basic(): basic_mod = Basic() basic_reach = ReachSet(basic_mod) flowpipe = basic_reach.computeReachSet(10) FlowPipePlotter(flowpipe).plot2DProj(0) Benchmark.generate_stats()
def pca_lin_comp(): sir = SIR_UnitBox() sir_reach = ReachSet(sir) sir_flow = sir_reach.computeReachSet(NUM_STEPS) sir_plot = Plot() sir_plot.add(sir_flow) sir_lin_flow = sir_reach.computeReachSet(NUM_STEPS, LinStrat(sir, iter_steps=150)) #sir_pca_flow = sir_reach.computeReachSet(NUM_STEPS, PCAStrat(sir, iter_steps=50)) sir_plot.add(sir_lin_flow, "SIR_LIN") #sir_plot.add(sir_pca_flow, "SIR_PCA") sir_plot.plot(0, 1, 2) Timer.generate_stats()
def test_phase_sir(): sir_mod = SIR_UnitBox(delta=0.5) sir_reach = ReachSet(sir_mod) flowpipe = sir_reach.computeReachSet(50) plot = Plot() plot.add(flowpipe) plot.plot2DPhase(1, 2)
def test_basic(): basic_mod = Basic() basic_reach = ReachSet(basic_mod) flowpipe = basic_reach.computeReachSet(300) basic_plot = Plot() basic_plot.add_flowpipe(flowpipe) basic_plot.plot(0)
def execute(self): model = experi_input['model'] strat = experi_input['strat'] label = experi_input['label'] num_steps = experi_input['num_steps'] mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(num_steps, tempstrat=strat) self.animation = TempAnimation(mod_flow)
def test_Rossler(): model = Rossler() mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(300) FlowPipePlotter(mod_flow).plot2DProj(0) FlowPipePlotter(mod_flow).plot2DProj(1) FlowPipePlotter(mod_flow).plot2DProj(2)
def test_Quad(): model = Quadcopter() mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(10) FlowPipePlotter(mod_flow).plot2DProj(2) FlowPipePlotter(mod_flow).plot2DProj(5) FlowPipePlotter(mod_flow).plot2DProj(13) Timer.generate_stats()
def test_rossler_phase(): model = Rossler() mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(200) rossler_plot = Plot() rossler_plot.add(mod_flow) rossler_plot.plot2DPhase(0,1) Timer.generate_stats()
def test_Quad(): model = Quadcopter() mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(3) quad_plot = Plot() quad_plot.add(mod_flow) quad_plot.plot(2, 5, 13) Timer.generate_stats()
def test_Rossler(): model = Rossler() mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(300) rossler_plot = Plot() rossler_plot.add(mod_flow) rossler_plot.plot(0,1,2) Timer.generate_stats()
def test_basic2(): basic_mod = Basic2() basic_reach = ReachSet(basic_mod) flowpipe = basic_reach.computeReachSet(300) basic_plot = Plot() basic_plot.add(flowpipe) basic_plot.plot(0) Timer.generate_stats()
def test_LV(): model = LotkaVolterra() mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(100) plot = Plot() plot.add(mod_flow) plot.plot(0,1,2) Timer.generate_stats()
def test_LL(): model = LL() mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(150) ll_plot = Plot() ll_plot.add(mod_flow) ll_plot.plot(0) Timer.generate_stats()
def test_SIR(): model = SIR() mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(200) FlowPipePlotter(mod_flow).plot2DProj(0) FlowPipePlotter(mod_flow).plot2DProj(1) FlowPipePlotter(mod_flow).plot2DProj(2) Timer.generate_stats()
def test_sir_cut_strat(): #Compute Sapo's version. sir_cut = SIR() sir = SIR_UnitBox() sir_reach = ReachSet(sir) sir_flow = sir_reach.computeReachSet(NUM_STEPS) sir_plot = Plot() sir_plot.add(sir_flow) sir_cut_reach = ReachSet(sir_cut) sir_cut_flow = sir_cut_reach.computeReachSet(NUM_STEPS, CutStrat(sir_cut)) sir_sapo_flow = sir_cut_reach.computeReachSet(NUM_STEPS) sir_plot.add(sir_cut_flow, "SIR_CUT_150") sir_plot.add(sir_sapo_flow, "SIR_SAPO") sir_plot.plot(0, 1, 2) Timer.generate_stats()
def execute(self): self.output_flowpipes = [] for experi_input in self.inputs: model = experi_input['model'] strat = experi_input['strat'] label = experi_input['label'] num_steps = experi_input['num_steps'] mod_reach = ReachSet(model) mod_flow = mod_reach.computeReachSet(num_steps, tempstrat=strat) self.plot.add(mod_flow, label=label) self.output_flowpipes.append(mod_flow) self.max_num_steps = max(self.max_num_steps, num_steps)
def test_Phos(): model = Phosphorelay() #unit_model = Phosphorelay_UnitBox() mod_reach = ReachSet(model) #mod_unit_reach = ReachSet(unit_model) #unit_flow = mod_unit_reach.computeReachSet(200) mod_flow = mod_reach.computeReachSet(30) phos_plot = Plot() phos_plot.add(mod_flow) phos_plot.plot2DPhase(0, 1, separate=False, plotvertices=True) Timer.generate_stats()
def test_rossler_lin_strat(): #Compute Sapo's version. rossler_lin = Rossler_UnitBox() rossler = Rossler() rossler_reach = ReachSet(rossler) rossler_flow = rossler_reach.computeReachSet(NUM_STEPS) rossler_plot = Plot() rossler_plot.add(rossler_flow) for i in range(10, 11): print( colored("Generating LIN with Iterative Step Size: {}".format(i), "white", attrs=['reverse', 'blink'])) rossler_lin_reach = ReachSet(rossler_lin) rossler_flow_lin = rossler_lin_reach.computeReachSet( NUM_STEPS, LinStrat(rossler_lin, iter_steps=i)) rossler_plot.add(rossler_flow_lin, "Rossler_LIN_{}".format(i)) rossler_plot.plot(0, 1, 2) Timer.generate_stats()