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_pca_VDP(): NUM_STEPS = 3 model = VanDerPol(delta=0.08) unit_model = VanDerPol_UnitBox(delta=0.08) VDP_PCA_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. 'PCA Strategy Parameters' VDP_PCA_TRAJ_STEPS = 5 #Number of steps our sample trajectories should run. VDP_PCA_NUM_TRAJ = 50 #Number of sample trajectories we should use for the PCA routine. VDP_PCA_DELAY = 5 pca_dirs = GeneratedPCADirs(model, VDP_PCA_NUM_TRAJ, NUM_STEPS) pca_strat = MultiStrategy(PCAStrat(unit_model, traj_steps=VDP_PCA_TRAJ_STEPS, num_trajs=VDP_PCA_NUM_TRAJ, iter_steps=VDP_PCA_ITER_STEPS, pca_dirs=pca_dirs), \ PCAStrat(unit_model, traj_steps=VDP_PCA_TRAJ_STEPS, num_trajs=VDP_PCA_NUM_TRAJ, iter_steps=VDP_PCA_ITER_STEPS+VDP_PCA_DELAY, pca_dirs=pca_dirs), \ PCAStrat(unit_model, traj_steps=VDP_PCA_TRAJ_STEPS, num_trajs=VDP_PCA_NUM_TRAJ, iter_steps=VDP_PCA_ITER_STEPS+2*VDP_PCA_DELAY, pca_dirs=pca_dirs)) inputs = [ ExperimentInput(model, label="VDP Sapo"), ExperimentInput(unit_model, strat=pca_strat, label="VDP Kaa PCA") ] vdp_pca = PhasePlotExperiment(inputs) vdp_pca.execute(NUM_STEPS) vdp_pca.plot_results(0, 1) Timer.generate_stats()
def test_pca_lin_VDP(): NUM_STEPS = 70 VDP_LIN_ITER_STEPS = 1 #Number of steps between each recomputation of LinApp Templates. VDP_PCA_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. 'PCA Strategy Parameters' VDP_PCA_TRAJ_STEPS = 2 #Number of steps our sample trajectories should run. VDP_PCA_NUM_TRAJ = 200 #Number of sample trajectories we should use for the PCA routine. VDP_LIN_DELAY = 2 VDP_PCA_DELAY = 5 model = VanDerPol(delta=0.08) unit_model = VanDerPol_UnitBox(delta=0.08) lin_strat = MultiStrategy(LinStrat(unit_model, iter_steps=VDP_LIN_ITER_STEPS), \ LinStrat(unit_model, iter_steps=VDP_LIN_ITER_STEPS+VDP_LIN_DELAY), \ PCAStrat(unit_model, traj_steps=VDP_PCA_TRAJ_STEPS, num_trajs=VDP_PCA_NUM_TRAJ, iter_steps=VDP_PCA_ITER_STEPS), \ PCAStrat(unit_model, traj_steps=VDP_PCA_TRAJ_STEPS, num_trajs=VDP_PCA_NUM_TRAJ, iter_steps=VDP_PCA_ITER_STEPS+VDP_PCA_DELAY)) inputs = [ ExperimentInput(model, label="VDP Sapo"), ExperimentInput(unit_model, strat=lin_strat, label="VDP Kaa") ] vdp_pca = PhasePlotExperiment(inputs) vdp_pca.execute(NUM_STEPS) vdp_pca.plot_results(0, 1) Timer.generate_stats()
def test_ani_pca_lin_VDP(): NUM_STEPS = 70 VDP_LIN_ITER_STEPS = 1 #Number of steps between each recomputation of LinApp Templates. VDP_PCA_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. 'PCA Strategy Parameters' VDP_PCA_TRAJ_STEPS = 2 #Number of steps our sample trajectories should run. VDP_PCA_NUM_TRAJ = 200 #Number of sample trajectories we should use for the PCA routine. VDP_LIN_DELAY = 2 VDP_PCA_DELAY = 5 model = VanDerPol(delta=0.08) unit_model = VanDerPol_UnitBox(delta=0.08) lin_1 = LinStrat(unit_model, iter_steps=VDP_LIN_ITER_STEPS) lin_2 = LinStrat(unit_model, iter_steps=VDP_LIN_ITER_STEPS + VDP_LIN_DELAY) pca_1 = PCAStrat(unit_model, traj_steps=VDP_PCA_TRAJ_STEPS, num_trajs=VDP_PCA_NUM_TRAJ, iter_steps=VDP_PCA_ITER_STEPS) pca_2 = PCAStrat(unit_model, traj_steps=VDP_PCA_TRAJ_STEPS, num_trajs=VDP_PCA_NUM_TRAJ, iter_steps=VDP_PCA_ITER_STEPS + VDP_PCA_DELAY) lin_strat = MultiStrategy(lin_1, lin_2, pca_1, pca_2) inputs = ExperimentInput(unit_model, strat=lin_strat, label="VDP Kaa") vdp_pca = Animation(inputs) vdp_pca.execute(NUM_STEPS) vdp_pca.animate(0, 1, lin_1, lin_2) #vdp_pca.animate(0,1, lin_2) #vdp_pca.animate(0,1, pca_2) Timer.generate_stats()
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_ani_pca_VDP(): NUM_STEPS = 70 #model = VanDerPol(delta=0.08) unit_model = VanDerPol_UnitBox(delta=0.08) VDP_PCA_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. 'PCA Strategy Parameters' VDP_PCA_TRAJ_STEPS = 5 #Number of steps our sample trajectories should run. VDP_PCA_NUM_TRAJ = 100 #Number of sample trajectories we should use for the PCA routine. VDP_PCA_DELAY = 5 pca_1 = PCAStrat(unit_model, traj_steps=VDP_PCA_TRAJ_STEPS, num_trajs=VDP_PCA_NUM_TRAJ, iter_steps=VDP_PCA_ITER_STEPS) pca_2 = PCAStrat(unit_model, traj_steps=VDP_PCA_TRAJ_STEPS, num_trajs=VDP_PCA_NUM_TRAJ, iter_steps=VDP_PCA_ITER_STEPS + VDP_PCA_DELAY) pca_3 = PCAStrat(unit_model, traj_steps=VDP_PCA_TRAJ_STEPS, num_trajs=VDP_PCA_NUM_TRAJ, iter_steps=VDP_PCA_ITER_STEPS + 2 * VDP_PCA_DELAY) pca_strat = MultiStrategy(pca_1, pca_2, pca_3) experi_input = ExperimentInput(unit_model, strat=pca_strat, label="VDP Kaa PCA") vdp_pca = Animation(experi_input) vdp_pca.execute(NUM_STEPS) vdp_pca.animate(0, 1, pca_1) vdp_pca.animate(0, 1, pca_2) vdp_pca.animate(0, 1, pca_3) Timer.generate_stats()
def test_lin_VDP(): NUM_STEPS = 70 VDP_LIN_ITER_STEPS = 1 #Number of steps between each recomputation of LinApp Templates. VDP_LIN_DELAY = 1 model = VanDerPol(delta=0.08) unit_model = VanDerPol_UnitBox(delta=0.08) lin_strat = MultiStrategy(LinStrat(unit_model, iter_steps=VDP_LIN_ITER_STEPS), \ LinStrat(unit_model, iter_steps=VDP_LIN_ITER_STEPS+VDP_LIN_DELAY), \ LinStrat(unit_model, iter_steps=VDP_LIN_ITER_STEPS+2*VDP_LIN_DELAY)) inputs = [ ExperimentInput(model, label="VDP Sapo"), ExperimentInput(unit_model, strat=lin_strat, label="VDP Kaa Lin") ] vdp_pca = PhasePlotExperiment(inputs) vdp_pca.execute(NUM_STEPS) vdp_pca.plot_results(0, 1) Timer.generate_stats()
def test_pca_lin_HarOsc(): NUM_STEPS = 4 model = HarOsc() #trajs = generate_traj(model, 10, 200) mod_reach = ReachSet(model) #mod_flow = mod_reach.computeReachSet() sir_plot = Plot()dd SIR_LIN_ITER_STEPS = 1 #Number of steps between each recomputation of PCA Templates. 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. tandem_strat = MultiStrategy(LinStrat(model, iter_steps=SIR_LIN_ITER_STEPS), 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=tandem_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)dd