Esempio n. 1
0
def define_settings(ha, plot):
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_IMAGE if plot else PlotSettings.PLOT_NONE

    max_time = 20.0
    step_size = 0.005
    settings = HylaaSettings(step=step_size, max_time=max_time, plot_settings=plot_settings)

    settings.time_elapse.method = TimeElapseSettings.SCIPY_SIM
    settings.print_output = plot

    plot_settings.xdim_dir = None
    plot_settings.ydim_dir = ha.modes.values()[0].output_space_csr[0].toarray()

    plot_settings.filename = "hylaa_iss_constant.png"
    plot_settings.max_shown_polys = None
    plot_settings.label.y_label = '$y_{3}$'
    plot_settings.label.x_label = 'Time'
    plot_settings.label.title = '' #'Space Station (Constant Inputs)'
    plot_settings.plot_size = (10, 10)
    plot_settings.label.big(size=36)
    plot_settings.label.tick_label_size = 24

    plot_settings.extra_lines = [[(0.0, -0.00017), (20.0, -0.00017)], [(0.0, 0.00017), (20.0, 0.00017)]]

    plot_settings.label.axes_limits = (0, 20, -0.0002, 0.0002)

    return settings
Esempio n. 2
0
def define_settings(plot):
    'get the hylaa settings object'

    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_IMAGE if plot else PlotSettings.PLOT_NONE
    #plot_settings.plot_mode = PlotSettings.PLOT_NONE

    plot_settings.max_shown_polys = None
    plot_settings.xdim = 0
    plot_settings.ydim = 1
    
    plot_settings.label.title = "Spacecraft Rendezvous"
    plot_settings.filename = "rendezvous4.png"
    plot_settings.plot_size = (10, 10)
    plot_settings.label.big(size=32)
    plot_settings.label.x_label = '$x$'
    plot_settings.label.y_label = '$y$'

    y = 57.735
    plot_settings.extra_lines = [[(-100, y), (-100, -y), (0, 0), (-100, y)]]

    settings = HylaaSettings(step=0.1, max_time=200.0, plot_settings=plot_settings)

    settings.aggregation = False
    settings.deaggregation = False

    settings.simulation.threads = 1

    return settings
Esempio n. 3
0
def define_settings():
    'get the hylaa settings object'

    plot_settings = PlotSettings()

    # save to a video file
    plot_settings.make_video("deaggregation.mp4", frames=150, fps=5)
    #plot_settings.plot_mode = PlotSettings.PLOT_IMAGE

    plot_settings.xdim = 0
    plot_settings.ydim = 1
    plot_settings.extra_lines = [[(-0.5, -4), (-0.5, -0), (0.5, -0),
                                  (0.5, -4)]]

    settings = HylaaSettings(step=0.25,
                             max_time=6.0,
                             plot_settings=plot_settings)
    settings.process_urgent_guards = True
    #settings.deaggregation = False
    #settings.aggregation = False
    settings.skip_step_times = True

    settings.simulation.threads = 1

    return settings
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_IMAGE
    plot_settings.xdim = 0
    plot_settings.ydim = 3

    s = HylaaSettings(step=0.1, max_time=2.0, plot_settings=plot_settings)
    s.stop_when_error_reachable = False
    return s
Esempio n. 5
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_IMAGE
    plot_settings.xdim = 1  # 3
    plot_settings.ydim = 2  # 4

    settings = HylaaSettings(step=0.02, max_time=3.0, disc_dyn=False, plot_settings=plot_settings)
    settings.stop_when_error_reachable = False

    return settings
Esempio n. 6
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_IMAGE
    plot_settings.xdim = 0
    plot_settings.ydim = 1

    s = HylaaSettings(step=step_size, max_time=max_time, disc_dyn=True, plot_settings=plot_settings)
    s.stop_when_error_reachable = False
    
    return s
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_IMAGE
    plot_settings.xdim = 0
    plot_settings.ydim = 1
    # plot_settings.make_video("acc-controllerII.mp4", frames=80, fps=2)

    s = HylaaSettings(step=0.2, max_time=20.0, plot_settings=plot_settings, disc_dyn=False)
    s.stop_when_error_reachable = False
    
    return s
Esempio n. 8
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_NONE
    plot_settings.xdim = 0
    plot_settings.ydim = 4

    settings = HylaaSettings(step=0.001, max_time=0.001, plot_settings=plot_settings)
    settings.print_output = False
    settings.counter_example_filename = None

    return settings
Esempio n. 9
0
def define_settings(ha, limit):
    'get the hylaa settings object'
    plot_settings = PlotSettings()

    max_time = 20.0  # 20.0
    step_size = 0.005  # 0.005
    settings = HylaaSettings(step=step_size,
                             max_time=max_time,
                             plot_settings=plot_settings)
    settings.print_output = False

    return settings
Esempio n. 10
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_MATLAB
    plot_settings.xdim = 0
    plot_settings.ydim = 1

    s = HylaaSettings(step=0.2,
                      max_time=2.6,
                      disc_dyn=False,
                      plot_settings=plot_settings)
    s.stop_when_error_reachable = False

    return s
Esempio n. 11
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_NONE
    plot_settings.xdim = 0
    plot_settings.ydim = 8

    settings = HylaaSettings(step=0.1,
                             max_time=30.0,
                             plot_settings=plot_settings)
    #settings.sim_tol = 1000.0
    settings.use_presimulation = True
    #settings.aggregation = False
    #settings.solver = 'cvxopt-glpk'

    return settings
Esempio n. 12
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_INTERACTIVE
    plot_settings.xdim = 0
    plot_settings.ydim = 1

    return HylaaSettings(step=5.0E-4,
                         max_time=2.0,
                         plot_settings=plot_settings)
Esempio n. 13
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_IMAGE
    plot_settings.xdim = 0
    plot_settings.ydim = 1

    settings = HylaaSettings(step=0.1, max_time=3.2, plot_settings=plot_settings)

    return settings
Esempio n. 14
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_MATLAB
    plot_settings.xdim = 0
    plot_settings.ydim = 1

    s = HylaaSettings(step=0.2, max_time=20.0, plot_settings=plot_settings)
    
    return s
Esempio n. 15
0
def define_settings(ha, plot):
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_IMAGE if plot else PlotSettings.PLOT_NONE
    #plot_settings.plot_mode = PlotSettings.PLOT_NONE

    max_time = 20.0
    step_size = 0.02 if plot else 0.005  # plotting with small timesteps has lots of overhead
    settings = HylaaSettings(step=step_size,
                             max_time=max_time,
                             plot_settings=plot_settings)

    settings.time_elapse.method = TimeElapseSettings.SCIPY_SIM
    settings.time_elapse.check_answer = False
    settings.print_output = plot

    #settings.interval_guard_optimization = False
    #settings.time_elapse.scipy_sim.max_step = 0.001

    #settings.time_elapse.scipy_sim.rtol = 1e-9
    #settings.time_elapse.scipy_sim.atol = 1e-12

    #settings.skip_step_times = False

    plot_settings.xdim_dir = None
    plot_settings.ydim_dir = ha.modes.values()[0].output_space_csr[0]

    plot_settings.filename = "hylaa_iss_uncertain.png"
    plot_settings.max_shown_polys = None
    plot_settings.label.y_label = '$y_{3}$'
    plot_settings.label.x_label = 'Time'
    plot_settings.label.title = ''  #'Space Station (Uncertain Inputs)'
    #plot_settings.label.axes_limits = (0.4, 0.6, -0.0002, -0.0001)
    plot_settings.plot_size = (10, 10)
    plot_settings.label.big(size=36)
    plot_settings.label.tick_label_size = 24

    plot_settings.extra_lines = [[(0.0, -0.0005), (20.0, -0.0005)],
                                 [(0.0, 0.0005), (20.0, 0.0005)]]

    plot_settings.label.axes_limits = (0, 20, -0.0007, 0.0007)

    return settings
Esempio n. 16
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_NONE
    plot_settings.xdim = 0
    plot_settings.ydim = 2

    settings = HylaaSettings(step=5.0E-4, max_time=2.0, plot_settings=plot_settings)

    return settings
Esempio n. 17
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_NONE

    settings = HylaaSettings(step=0.005, max_time=20.0, plot_settings=plot_settings)

    settings.simulation.sim_mode = SimulationSettings.MATRIX_EXP
    settings.simulation.threads=1

    return settings
Esempio n. 18
0
def define_settings():
    'get the hylaa settings object'
    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_IMAGE
    plot_settings.xdim = 0
    plot_settings.ydim = 1
    #plot_settings.label.axes_limits = (0.9, 1.1, 2.0, 6.0)

    settings = HylaaSettings(step=0.01,
                             max_time=2.0,
                             plot_settings=plot_settings)

    return settings
Esempio n. 19
0
    def test_rectangular(self):
        '''test integration of x' = 1, y' = 2'''

        ha = LinearHybridAutomaton('Harmonic Oscillator')
        ha.variables = ["x", "y"]

        # x' = x
        loc1 = ha.new_mode('loc')
        loc1.a_matrix = np.array([[0, 0], [0, 0]])
        loc1.c_vector = np.array([1, 2])

        # x(0) = 1, y(0) = 2
        init_list = [(ha.modes['loc'],
                      HyperRectangle([(0.99, 1.01), (1.99, 2.01)]))]

        plot_settings = PlotSettings()
        plot_settings.plot_mode = PlotSettings.PLOT_NONE
        settings = HylaaSettings(step=0.1,
                                 max_time=1.1,
                                 plot_settings=plot_settings)
        settings.print_output = False

        engine = HylaaEngine(ha, settings)

        engine.load_waiting_list(init_list)
        # x(t) = 1 + t; y(t) = 2 + 2*t

        # pop from waiting_list (doesn't advance state)
        engine.do_step()

        for i in xrange(10):
            engine.do_step()

            t = 0.1 * (i + 1)
            star = engine.cur_state
            point = [1 + t, 2 + 2 * t]

            self.assertTrue(star.contains_point(point))
Esempio n. 20
0
    def test_exp(self):
        '''test integration of x' = x'''

        ha = LinearHybridAutomaton('Harmonic Oscillator')
        ha.variables = ["x"]

        # x' = x
        a_matrix = np.array([[1]], dtype=float)
        c_vector = np.array([0], dtype=float)

        loc1 = ha.new_mode('loc')
        loc1.set_dynamics(a_matrix, c_vector)

        # x(0) = 1
        init_list = [(ha.modes['loc'], HyperRectangle([(0.99, 1.01)]))]

        plot_settings = PlotSettings()
        plot_settings.plot_mode = PlotSettings.PLOT_NONE
        settings = HylaaSettings(step=0.1,
                                 max_time=1.1,
                                 plot_settings=plot_settings)
        settings.print_output = False

        engine = HylaaEngine(ha, settings)

        engine.load_waiting_list(init_list)

        # pop from waiting_list (doesn't advance state)
        engine.do_step()

        # x(t) should be e^t
        for i in xrange(10):
            engine.do_step()

            t = 0.1 * (i + 1)
            star = engine.cur_state

            self.assertTrue(star.contains_point([math.exp(t)]))
Esempio n. 21
0
def define_settings():
    'get the hylaa settings object'

    plot_settings = PlotSettings()
    plot_settings.plot_mode = PlotSettings.PLOT_IMAGE
    #plot_settings.plot_mode = PlotSettings.PLOT_VIDEO
    #plot_settings.video_frames = 220
    #plot_settings.video_filename = "out.wma"
    #plot_settings.video_codec = None

    plot_settings.xdim = 0
    plot_settings.ydim = 1

    settings = HylaaSettings(step=0.1,
                             max_time=10.0,
                             plot_settings=plot_settings)

    return settings
Esempio n. 22
0
def define_settings(stepsize):
    'get the hylaa settings object'

    plot_settings = PlotSettings()
    #plot_settings.plot_mode = PlotSettings.PLOT_IMAGE if plot else PlotSettings.PLOT_NONE
    plot_settings.plot_mode = PlotSettings.PLOT_NONE

    plot_settings.max_shown_polys = None
    plot_settings.xdim = 0
    plot_settings.ydim = 1
    plot_settings.label.title = "Spacecraft Rendezvous (Abort)"
    plot_settings.filename = "rendezvous4_abort.png"
    plot_settings.plot_size = (10, 10)
    plot_settings.label.big(size=32)
    plot_settings.label.x_label = '$x$'
    plot_settings.label.y_label = '$y$'

    plot_settings.label.axes_limits = [-50, 50, -50, 50]
    #plot_settings.label.axes_limits = [-200, 200, -100, 100]

    y = 57.735
    lines1 = [(-100, y), (-100, -y), (0, 0), (-100, y)]
    lines2 = [(-5, -5), (5, -5), (5, 5), (-5, 5), (-5, -5)]
    plot_settings.extra_lines = [lines1, lines2]

    #plot_settings.label.axes_limits = (-100, 100, -50, 0)

    settings = HylaaSettings(step=stepsize,
                             max_time=250.0,
                             plot_settings=plot_settings)

    settings.aggregation = False
    settings.deaggregation = False

    settings.skip_step_times = True
    settings.print_output = False

    settings.simulation.threads = 1

    return settings