Ejemplo n.º 1
0
def call_planner_ex():
    """Example for changing specs and calling the planner """

    # initialize default inputs
    specs = MyInputs()

    # load graph, either by number (int), iGraph object or .p file name (str)
    specs.set_graph(8)
    # solver parameter: central x distributed
    specs.set_solver_type('distributed')
    # target motion
    specs.set_target_motion('static')
    # searchers' detection: capture range and false negatives
    m = 3
    specs.set_capture_range(0)
    specs.set_size_team(m)

    # time-step stuff: deadline mission (tau), planning horizon (h), re-plan frequency (theta)
    h = 10
    specs.set_all_times(h)
    specs.set_theta(1)
    # solver timeout (in sec)
    specs.set_timeout(100)

    # belief
    n = len(specs.graph.vs)
    v_maybe = [8, 10, 12, 14, 17, 15]
    b_0 = [0.0 for i in range(n + 1)]
    for v in v_maybe:
        b_0[v] = 1 / 6
    specs.set_b0(b_0)
    # searchers initial vertices
    specs.set_start_searchers([2, 2, 2])

    output_solver_data = True
    my_path, solver_data = pln.run_planner(specs, output_solver_data)

    # to retrieve belief computed by the solver
    # we want b(t+1) - next time step
    t_next = 1
    my_belief_vec = solver_data.retrieve_solver_belief(0, t_next)

    return my_path, my_belief_vec
Ejemplo n.º 2
0
def call_sim_ex():
    """Example for changing specs and calling the planner """

    # initialize default inputs
    specs = MyInputs()

    # load graph, either by number (int), iGraph object or .p file name (str)
    specs.set_graph(8)
    # solver parameter: central x distributed
    specs.set_solver_type('distributed')
    # target motion
    specs.set_target_motion('static')
    # searchers' detection: capture range and false negatives
    m = 3
    specs.set_capture_range(0)
    specs.set_size_team(m)

    # time-step stuff: deadline mission (tau), planning horizon (h), re-plan frequency (theta)
    h = 10
    specs.set_all_times(h)
    specs.set_deadline(50)
    specs.set_theta(1)
    # solver timeout (in sec)
    specs.set_timeout(120)

    # belief
    n = len(specs.graph.vs)
    v_maybe = [8, 10, 12, 14, 15, 17]
    b_0 = [0.0 for i in range(n + 1)]
    for v in v_maybe:
        b_0[v] = 1 / 6
    specs.set_b0(b_0)
    specs.set_start_target_vertex(5)
    # searchers initial vertices
    specs.set_start_searchers([1, 1, 1])

    # run simulator
    belief, target, searchers, sim_data = sf.run_simulator(specs)
Ejemplo n.º 3
0
def test_inputs():
    horizon, theta, deadline, solver_type = get_solver_param()
    g, v0_target, v0_searchers, target_motion, belief_distribution = parameters_sim()

    specs = MyInputs()

    specs.set_theta(theta)
    specs.set_deadline(deadline)
    specs.set_solver_type(solver_type)
    specs.set_horizon(horizon)
    specs.set_graph(0)
    specs.set_start_target(v0_target)
    specs.set_start_searchers(v0_searchers)
    specs.set_target_motion(target_motion)
    specs.set_belief_distribution(belief_distribution)

    assert g["name"] == specs.graph["name"]
    assert specs.horizon == horizon
    assert specs.theta == theta
    assert specs.start_target_random is False
    assert specs.start_target_true == v0_target[0]
    assert specs.start_searcher_random is False
    assert specs.start_searcher_v == v0_searchers
    assert specs.target_motion == target_motion
    assert specs.belief_distribution == belief_distribution
Ejemplo n.º 4
0
def my_specs():
    horizon, theta, deadline, solver_type = get_solver_param()
    g, v0_target, v0_searchers, target_motion, belief_distribution = parameters_sim()

    specs = MyInputs()

    specs.set_graph(0)
    specs.set_theta(theta)
    specs.set_deadline(deadline)
    specs.set_solver_type(solver_type)
    specs.set_horizon(horizon)
    specs.set_start_target(v0_target)
    specs.set_start_searchers(v0_searchers)
    specs.set_target_motion(target_motion)
    specs.set_belief_distribution(belief_distribution)

    return specs
Ejemplo n.º 5
0
"""Example for changing specs and calling the planner """

# ---------------------------------------------------------------------------------------------------------------------
# start of header
# import relevant modules
from core import plan_fun as pln
from core import plot_fun as pf
from classes.inputs import MyInputs

# end of header
# ---------------------------------------------------------------------------------------------------------------------

# initialize default inputs
specs = MyInputs()

# load graph, either by number (int), iGraph object or .p file name (str)
specs.set_graph(8)
# solver parameter: central x distributed
specs.set_solver_type('distributed')
# target motion
specs.set_target_motion('static')
# searchers' detection: capture range and false negatives
m = 3
specs.set_capture_range(0)
specs.set_size_team(m)

# time-step stuff: deadline mission (tau), planning horizon (h), re-plan frequency (theta)
h = 5
specs.set_all_times(h)
specs.set_theta(1)
# solver timeout (in sec)
Ejemplo n.º 6
0
def my_specs():
    theta = 2
    deadline = 6
    horizon = 3
    solver_type = 'central'

    graph_file = 'G7V_test.p'
    g = ext.get_graph(graph_file)
    target_motion = 'random'
    belief_distribution = 'uniform'

    v0_target = [7]
    v0_searchers = [1, 2]

    specs = MyInputs()

    specs.set_graph(0)
    specs.set_theta(theta)
    specs.set_deadline(deadline)
    specs.set_solver_type(solver_type)
    specs.set_horizon(horizon)
    specs.set_start_target(v0_target)
    specs.set_start_searchers(v0_searchers)
    specs.set_target_motion(target_motion)
    specs.set_belief_distribution(belief_distribution)

    return specs
Ejemplo n.º 7
0
"""Example for numerical simulation (multiple runs and change in configuration)"""

# ---------------------------------------------------------------------------------------------------------------------
# start of header
# import relevant modules
from core import sim_fun as sf
from core import plot_fun as pf
from classes.inputs import MyInputs

# end of header
# ---------------------------------------------------------------------------------------------------------------------

# initialize default inputs
exp_inputs = MyInputs()
# graph number -- MUSEUM (1), GRID 10x10 (2), 3
exp_inputs.set_graph(2)
# solver parameter: central x distributed
exp_inputs.set_solver_type('distributed')
# searchers' detection: capture range and false negatives
exp_inputs.set_capture_range(1)
exp_inputs.set_zeta(0.3)
# time stuff: deadline mission (tau), planning horizon (h), re-plan frequency (theta)
exp_inputs.set_all_times(10)
exp_inputs.set_theta(1)
exp_inputs.set_timeout(5)

# repetitions for each configuration
exp_inputs.set_number_of_runs(100)
# set random seeds
exp_inputs.set_start_seeds(2000, 6000)