Exemplo n.º 1
0
def test_ground_differential_constraints_for_hybrid_problem():
    prob = create_particles_world()
    index = ProblemGrounding(prob)
    index.process_symbols(prob)
    index.state_variables = IndexDictionary()
    grounder = DifferentialConstraintGrounder(prob, index)
    grounder.calculate_constraints()
    assert len(prob.ground_differential_constraints) == 8
Exemplo n.º 2
0
def test_ground_reactions_for_hybrid_problem():
    prob = create_billiards_world()
    index = ProblemGrounding(prob)
    index.process_symbols(prob)
    index.state_variables = IndexDictionary()
    grounder = ReactionGrounder(prob, index)
    grounder.calculate_reactions()
    assert len(prob.ground_reactions) == 4
Exemplo n.º 3
0
def test_create_state_variables_for_hybrid_problem_with_reactions():
    prob = create_billiards_world()
    index = ProblemGrounding(prob)
    index.process_symbols(prob)
    index.state_variables = IndexDictionary()
    for var in create_all_possible_state_variables(index.fluent_terms):
        index.state_variables.add(var)
    assert len(index.state_variables) == 4
Exemplo n.º 4
0
def test_enumeration_of_action_parameters_for_small_bw():
    prob, index = create_small_bw_with_index()
    index.ground_actions = IndexDictionary()
    actions = list(prob.actions.values())
    card, syms, substs = instantiation.enumerate_groundings(prob.language, actions[0].parameters)
    assert card == 6
    assert len(syms) == 1
    assert len(substs) == 1
Exemplo n.º 5
0
def test_ground_sensors_for_small_contingent_problem():
    prob = localize.create_small_task()
    index = ProblemGrounding(prob)
    index.process_symbols(prob)
    index.state_variables = IndexDictionary()

    grounder = SensorGrounder(prob, index)
    grounder.calculate_sensors()
    assert len(prob.ground_sensors) == 4
def test_task_index_create_state_variables_parcprinter():
    prob = parcprinter.create_small_task()
    index = fs.TaskIndex(prob.language, prob.name)
    index.process_symbols(prob)
    index.state_variables = IndexDictionary()
    for var in sv.create_all_possible_state_variables(index.fluent_symbols):
        index.state_variables.add(var)

    assert len(index.state_variables) == 7
Exemplo n.º 7
0
def create_small_bw_with_index():
    problem = create_4blocks_task()
    grounding = ProblemGrounding(problem)
    grounding.process_symbols(problem)
    grounding.state_variables = IndexDictionary()

    for var in create_all_possible_state_variables(grounding.fluent_terms):
        grounding.state_variables.add(var)

    return problem, grounding
def test_task_index_create_state_variables_blocksworld():
    prob = create_small_bw_task()
    index = fs.TaskIndex(prob.language.name, prob.name)
    index.process_symbols(prob)
    index.state_variables = IndexDictionary()
    for var in sv.create_all_possible_state_variables(index.fluent_symbols):
        index.state_variables.add(var)

    # print(','.join([str(var) for var in index.state_variables]))
    assert len(index.state_variables) == 8
def test_all_state_variables_can_be_evaluated_in_init_parcprinter():
    prob = parcprinter.create_small_task()
    index = fs.TaskIndex(prob.language, prob.name)
    index.process_symbols(prob)
    index.state_variables = IndexDictionary()
    for var in sv.create_all_possible_state_variables(index.fluent_symbols):
        index.state_variables.add(var)
    for var in index.state_variables:
        # print("type: {} expr: {} value: {}".format(type(var.ground), str(var.ground), prob.init[var.ground]))
        assert prob.init[var.ground] is True or prob.init[var.ground] is False
Exemplo n.º 10
0
def test_task_index_create_state_variables_blocksworld():
    prob = create_4blocks_task()
    index = ProblemGrounding(prob)
    index.process_symbols(prob)
    index.state_variables = IndexDictionary()
    for var in create_all_possible_state_variables(index.fluent_terms):
        index.state_variables.add(var)

    # print(','.join([str(var) for var in index.state_variables]))
    assert len(index.state_variables) == 12
def create_small_bw_with_index():
    prob = create_small_bw_task()
    index = fs.TaskIndex(prob.language.name, prob.name)
    index.process_symbols(prob)
    index.state_variables = IndexDictionary()

    for var in sv.create_all_possible_state_variables(index.fluent_symbols):
        index.state_variables.add(var)

    return prob, index
Exemplo n.º 12
0
def test_generate_substitutions_for_small_bw():
    import itertools

    prob, index = create_small_bw_with_index()
    index.ground_actions = IndexDictionary()
    actions = list(prob.actions.values())
    card, syms, substs = instantiation.enumerate_groundings(prob.language, actions[0].parameters)
    for values in itertools.product(*substs):
        assert (len(syms) == len(values))
        subst = create_substitution(syms, values)
        assert len(subst) == 1
Exemplo n.º 13
0
def test_all_state_variables_can_be_evaluated_in_init_parcprinter():
    prob = parcprinter.create_small_task()
    index = ProblemGrounding(prob)
    index.process_symbols(prob)
    index.state_variables = IndexDictionary()
    for var in create_all_possible_state_variables(index.fluent_terms):
        index.state_variables.add(var)
    for var in index.state_variables:
        # print("type: {} expr: {} value: {}".format(type(var.ground), str(var.ground), prob.init[var.ground]))
        assert (prob.init[var.ground] is True or
                prob.init[var.ground] is False or
                prob.init[var.ground] == 0.0)