def test_task_index_process_symbols_fluents_bw():
    problem = blocksworld.create_4blocks_task()
    index = ProblemGrounding(problem)
    index.process_symbols(problem)

    assert len(index.fluent_terms) == 6
    assert len(index.static_terms) == 11
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 = SymbolIndex()
    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 = SymbolIndex()
    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_ground_differential_constraints_for_hybrid_problem():
    prob = create_particles_world()
    index = ProblemGrounding(prob)
    index.process_symbols(prob)
    index.state_variables = SymbolIndex()
    grounder = DifferentialConstraintGrounder(prob, index)
    grounder.calculate_constraints()
    assert len(prob.ground_differential_constraints) == 8
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 = SymbolIndex()

    grounder = SensorGrounder(prob, index)
    grounder.calculate_sensors()
    assert len(prob.ground_sensors) == 4
Exemplo n.º 6
0
def test_task_index_create_state_variables_blocksworld():
    prob = create_4blocks_task()
    index = ProblemGrounding(prob)
    index.process_symbols(prob)
    index.state_variables = SymbolIndex()
    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
Exemplo n.º 7
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 = SymbolIndex()
    for var in create_all_possible_state_variables(index.fluent_terms):
        index.state_variables.add(var)
    for var in index.state_variables:
        val = prob.init[var.ground]
        assert val in (True, False, 0.0)
Exemplo n.º 8
0
def create_small_bw_with_index():
    problem = create_4blocks_task()
    grounding = ProblemGrounding(problem)
    grounding.process_symbols(problem)
    grounding.state_variables = SymbolIndex()

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

    return problem, grounding
Exemplo n.º 9
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)