示例#1
0
def run_hylaa(settings, init_r, *args):

    'Runs hylaa with the given settings, returning the HylaaResult object.'
    assert len(args) > 0

    ha, usafe_set_constraint_list = define_ha(settings, args)
    init = define_init_states(ha, init_r)

    engine = HylaaEngine(ha, settings)
    reach_tree = engine.run(init)

    return PVObject(len(ha.variables), usafe_set_constraint_list, reach_tree)
示例#2
0
def run_hylaa(plot, limit):
    'Runs hylaa with the given settings, returning the HylaaResult object.'

    #print "!!! in iss.py run_hylaa(). Check if early break in arnoldi loop actually helps performance on this example"

    ha = define_ha(limit)
    settings = define_settings(ha, plot)
    init = make_init_star(ha, settings)

    engine = HylaaEngine(ha, settings)
    engine.run(init)

    return engine.result
示例#3
0
    def test_sync_motor(self):
        '''test sync motor with input system'''

        model = sync_motor
        ha = model.define_ha()

        init_list = model.define_init_states(ha)
        settings = model.define_settings()

        engine = HylaaEngine(ha, settings)
        engine.run(init_list)

        self.assertTrue(engine.reached_error)
示例#4
0
    def test_drivetrain(self):
        'test running a single step on the drivetrain model (zonotope initialization)'

        ha = drivetrain.define_ha()
        init_list = drivetrain.define_init_states(ha)

        self.assertEquals(len(init_list), 1)

        settings = drivetrain.define_settings()
        plot_settings = settings.plot

        settings.print_output = False
        plot_settings.skip_frames = 10  # run 10 frames
        plot_settings.skip_show_gui = True

        engine = HylaaEngine(ha, settings)
        engine.run(init_list)
示例#5
0
def run_hylaa(spec='S01', uncertain_inputs=True):
    'Runs hylaa with the given settings, returning the HylaaResult object.'

    if spec == 'S01':
        limit = 0.0051
    elif spec == 'U01':
        limit = 0.004
    else:
        raise RuntimeError("Unsupported spec {}".format(spec))

    ha = define_ha(spec, limit, uncertain_inputs)
    settings = define_settings(ha, limit)
    init = make_init_star(ha, settings)

    engine = HylaaEngine(ha, settings)
    engine.run(init)

    return engine.result
示例#6
0
    def test_violation_extends_axis(self):
        '''invariant limits should also extend axis draw limits'''

        ha = ball_string.define_ha()
        init_list = ball_string.define_init_states(ha)
        settings = ball_string.define_settings()
        plot_settings = settings.plot

        plot_settings.plot_mode = PlotSettings.PLOT_INTERACTIVE
        plot_settings.skip_frames = 21
        plot_settings.skip_show_gui = True
        plot_settings.num_angles = 256
        settings.print_output = False

        engine = HylaaEngine(ha, settings)
        engine.run(init_list)

        self.assertTrue(engine.plotman.drawn_limits.xmax > 0)
示例#7
0
def hylaa_v1_single(r, stepsize):
    'Runs hylaa with the given settings, returning the seconds elapsed'

    settings = define_settings(stepsize)

    ha = define_ha(r)
    init = define_init_states(ha)

    print "Running hylaa with r={} stepsize={}...".format(r, stepsize),

    engine = HylaaEngine(ha, settings)
    engine.run(init)

    rv = engine.result.time
    Timers.reset()

    print rv

    return rv
示例#8
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)]))
示例#9
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))