Exemple #1
0
def _get_simple_task_always_true():
    """
    Simple test task with one operator needed.
    """
    op1 = Operator("op1", {}, {"var2"}, set())
    op2 = Operator("op2", {"var1"}, set(), set())
    op3 = Operator("op3", {"var2"}, {"var1"}, set())
    init = frozenset(["var1"])
    goals = frozenset(["var1", "var2"])
    task1 = Task("task1", {"var1", "var2", "var3"}, init, goals, [op1, op2, op3])
    return task1
Exemple #2
0
def _get_simple_task_at_goal():
    """
    Goal is already reached in the initial state.
    """
    op1 = Operator("op1", {"var1"}, {"var2"}, set())
    op2 = Operator("op2", {"var1"}, set(), set())
    op3 = Operator("op3", {"var2"}, {"var1"}, set())
    init = frozenset(["var1"])
    goals = frozenset(["var1"])
    task1 = Task("task1", {"var1", "var2", "var3"}, init, goals, [op1, op2, op3])
    return task1
Exemple #3
0
def _get_simple_task_unsolvable():
    """
    Unsolvable task.
    """
    op1 = Operator("op1", {"var1"}, {"var2"}, set())
    op2 = Operator("op2", {"var1"}, set(), set())
    op3 = Operator("op3", {"var2"}, {"var1"}, set())
    init = frozenset(["var1"])
    goals = frozenset(["var1", "var3"])
    task1 = Task("task1", {"var1", "var2", "var3"}, init, goals, [op1, op2, op3])
    return task1
Exemple #4
0
def _get_simple_task():
    """
    Task with a goal with two facts and an operator with no effect.
    """
    op1 = Operator("op1", {"var1"}, {"var2"}, set())
    op2 = Operator("op2", {"var1"}, set(), set())
    op3 = Operator("op3", {"var2"}, {"var1"}, set())
    init = frozenset(["var1"])
    goals = frozenset(["var1", "var2"])
    task1 = Task("task1", {"var1", "var2", "var3"}, init, goals, [op1, op2, op3])
    return task1
Exemple #5
0
def _get_intermediate_task_two_paths():
    """
    Intermediate task with two possible paths.
    """
    op1 = Operator("op1", {"v1"}, {"v2"}, set())
    op2 = Operator("op2", {"v2"}, {"v3"}, set())
    op3 = Operator("op3", {"v3"}, {"v4", "v5"}, set())
    op4 = Operator("op4", {"v7", "v5"}, {"g"}, set())
    op7 = Operator("op7", {"v4"}, {"v7"}, set())
    op5 = Operator("op5", {"v2"}, {"v4", "v5"}, set())
    init = frozenset(["v1"])
    goals = frozenset(["g"])
    task1 = Task(
        "task1",
        {"v1", "v2", "v3", "v4", "v5", "v6", "v7", "g"},
        init,
        goals,
        [op1, op2, op3, op4, op5, op7],
    )
    return task1
Exemple #6
0
def _get_intermediate_task_two_initial_facts():
    """
    Intermediate task with two initial facts
    """
    op2 = Operator("op2", {"v1", "v2"}, {"v3"}, set())
    op3 = Operator("op3", {"v3"}, {"v4", "v5"}, set())
    op4 = Operator("op4", {"v7", "v5"}, {"g"}, set())
    op7 = Operator("op7", {"v4"}, {"v7"}, set())
    op5 = Operator("op5", {"v2"}, {"v6"}, set())
    op6 = Operator("op6", {"v6"}, {"v5"}, set())
    init = frozenset(["v1", "v2"])
    goals = frozenset(["g"])
    task1 = Task(
        "task1",
        {"v1", "v2", "v3", "v4", "v5", "v6", "v7", "g"},
        init,
        goals,
        [op2, op3, op4, op5, op6, op7],
    )
    return task1
Exemple #7
0
import pytest

s1 = frozenset(["var1"])
s2 = frozenset(["var2"])
s3 = frozenset(["var1", "var2"])
op1 = Operator("op1", {"var1"}, {"var2"}, set())
op2 = Operator("op1", {"var1"}, set(), set())
op3 = Operator("op1", {"var2"}, {"var1"}, set())

# Operator that makes var2 true and false
op4 = Operator("op1", {"var1"}, {"var2"}, {"var2"})

init = frozenset(["var1"])
goals = frozenset(["var1", "var2"])
task1 = Task("task1", {"var1", "var2", "var3"}, init, goals, [op1, op2, op3])


def test_op_applicable1():
    assert op1.applicable(s1)


def test_op_applicable2():
    assert not op1.applicable(s2)


def test_op_applicable3():
    assert op1.applicable(s3)


def test_op_application1():