def test_voi():
    from cops_and_robots.robo_tools.robber import Robber
    from cops_and_robots.map_tools.map import Map
    from cops_and_robots.fusion.human import Human
    from cops_and_robots.fusion.gaussian_mixture import GaussianMixture
    import matplotlib.pyplot as plt
    from matplotlib.colors import cnames

    m = Map()
    pris = Robber('Pris')
    pris.map_obj.color = cnames['cornflowerblue']
    m.add_robber(pris.map_obj)
    zhora = Robber('Zhora')
    zhora.map_obj.color = cnames['cornflowerblue']
    m.add_robber(zhora.map_obj)
    roy = Robber('Roy')
    m.add_robber(roy.map_obj)
    h = Human(map_=m)
    m.add_human_sensor(h)

    prior = GaussianMixture(
        [0.1, 0.7, 0.2], [[3, -2], [-6, -2], [0, 0]],
        [[[1.5, 1.0], [1.0, 1.5]], [[2.5, -0.3], [-0.3, 2.5]],
         [[0.5, -0.3], [-0.3, 0.5]]])
    prior._discretize(bounds=m.bounds, grid_spacing=0.1)
    q = Questioner(human_sensor=h,
                   target_order=['Pris', 'Roy'],
                   target_weights=[11., 10.])

    m.setup_plot(show_human_interface=False)
    m.update()
    ax = m.axes['combined']

    # prior.plot(bounds=m.bounds, alpha=0.5, ax=ax)
    # m.update()
    # plt.show()
    q.weigh_questions({'Roy': prior})
    for qu in q.weighted_questions:
        print qu
Exemple #2
0
def test_voi():
    from cops_and_robots.robo_tools.robber import Robber
    from cops_and_robots.map_tools.map import Map
    from cops_and_robots.fusion.human import Human
    from cops_and_robots.fusion.gaussian_mixture import GaussianMixture
    import matplotlib.pyplot as plt
    from matplotlib.colors import cnames

    m = Map()
    pris = Robber("Pris")
    pris.map_obj.color = cnames["cornflowerblue"]
    m.add_robber(pris.map_obj)
    zhora = Robber("Zhora")
    zhora.map_obj.color = cnames["cornflowerblue"]
    m.add_robber(zhora.map_obj)
    roy = Robber("Roy")
    m.add_robber(roy.map_obj)
    h = Human(map_=m)
    m.add_human_sensor(h)

    prior = GaussianMixture(
        [0.1, 0.7, 0.2],
        [[3, -2], [-6, -2], [0, 0]],
        [[[1.5, 1.0], [1.0, 1.5]], [[2.5, -0.3], [-0.3, 2.5]], [[0.5, -0.3], [-0.3, 0.5]]],
    )
    prior._discretize(bounds=m.bounds, grid_spacing=0.1)
    q = Questioner(human_sensor=h, target_order=["Pris", "Roy"], target_weights=[11.0, 10.0])

    m.setup_plot(show_human_interface=False)
    m.update()
    ax = m.axes["combined"]

    # prior.plot(bounds=m.bounds, alpha=0.5, ax=ax)
    # m.update()
    # plt.show()
    q.weigh_questions({"Roy": prior})
    for qu in q.weighted_questions:
        print qu