def test_lm_cut_mark_single_goal(): task = _get_intermediate_task() heuristic = LmCutHeuristic(task) heuristic.compute_hmax(task.initial_state) heuristic.compute_goal_plateau(heuristic.explicit_goal) assert {f.name for f in heuristic.goal_plateau} == {heuristic.explicit_goal, 'g'}
def test_lm_cut_compute_single_cut(): task1 = _get_intermediate_task_two_paths() heuristic = LmCutHeuristic(task1) heuristic.compute_hmax(task1.initial_state) heuristic.goal_plateau.clear() heuristic.compute_goal_plateau(heuristic.explicit_goal) cut = heuristic.find_cut(task1.initial_state) assert [op.name for op in cut] == ["op4"]
def test_lm_cut_compute_single_cut(): task1 = _get_intermediate_task_two_paths() heuristic = LmCutHeuristic(task1) heuristic.compute_hmax(task1.initial_state) heuristic.goal_plateau.clear() heuristic.compute_goal_plateau(heuristic.explicit_goal) cut = heuristic.find_cut(task1.initial_state) assert [op.name for op in cut] == ['op4']
def test_lm_cut_hmax_simple(): # define a simple test task task1 = _get_simple_task() heuristic = LmCutHeuristic(task1) heuristic.compute_hmax(task1.initial_state) assert heuristic.relaxed_facts["var1"].hmax_value == 0.0 assert heuristic.relaxed_facts["var2"].hmax_value == 1.0 assert heuristic.relaxed_facts["var3"].hmax_value == float("inf") assert heuristic.relaxed_facts["GOAL"].hmax_value == 1.0
def test_lm_cut_hmax_simple(): # define a simple test task task1 = _get_simple_task() heuristic = LmCutHeuristic(task1) heuristic.compute_hmax(task1.initial_state) assert heuristic.relaxed_facts['var1'].hmax_value == 0. assert heuristic.relaxed_facts['var2'].hmax_value == 1. assert heuristic.relaxed_facts['var3'].hmax_value == float('inf') assert heuristic.relaxed_facts['GOAL'].hmax_value == 1.
def test_lm_cut_mark_multiple_goal(): task = _get_intermediate_task() heuristic = LmCutHeuristic(task) heuristic.compute_hmax(task.initial_state) # artificially alter operator costs to get a larger goal plateau heuristic.relaxed_ops['op4'].cost = 0. heuristic.compute_goal_plateau(heuristic.explicit_goal) assert ({f.name for f in heuristic.goal_plateau} in [{heuristic.explicit_goal, 'v4', 'g'}, {heuristic.explicit_goal, 'v5', 'g'}])
def test_two_times_hmax_same_result(): task = _get_intermediate_task() heuristic = LmCutHeuristic(task) heuristic.compute_hmax(task.initial_state) heuristic.compute_hmax(task.initial_state) # artificially alter operator costs to get a larger goal plateau heuristic.relaxed_ops["op4"].cost = 0.0 heuristic.compute_goal_plateau(heuristic.explicit_goal) assert {f.name for f in heuristic.goal_plateau} in [ {heuristic.explicit_goal, "v4", "g"}, {heuristic.explicit_goal, "v5", "g"}, ]
def test_lm_cut_hmax_intermediate(): task1 = _get_intermediate_task() heuristic = LmCutHeuristic(task1) heuristic.compute_hmax(task1.initial_state) assert heuristic.relaxed_facts["v1"].hmax_value == 0.0 assert heuristic.relaxed_facts["v2"].hmax_value == 1.0 assert heuristic.relaxed_facts["v3"].hmax_value == 2.0 assert heuristic.relaxed_facts["v6"].hmax_value == 2.0 assert heuristic.relaxed_facts["v4"].hmax_value == 3.0 assert heuristic.relaxed_facts["v5"].hmax_value == 3.0 assert heuristic.relaxed_facts["g"].hmax_value == 4.0 assert heuristic.relaxed_ops["op1"].hmax_supporter.name == "v1" assert heuristic.relaxed_ops["op2"].hmax_supporter.name == "v2" assert heuristic.relaxed_ops["op3"].hmax_supporter.name == "v3" assert heuristic.relaxed_ops["op4"].hmax_supporter.name in {"v4", "v5"} assert heuristic.relaxed_ops["op5"].hmax_supporter.name == "v2" assert heuristic.relaxed_ops["op6"].hmax_supporter.name == "v6"
def test_lm_cut_hmax_intermediate(): task1 = _get_intermediate_task() heuristic = LmCutHeuristic(task1) heuristic.compute_hmax(task1.initial_state) assert heuristic.relaxed_facts['v1'].hmax_value == 0. assert heuristic.relaxed_facts['v2'].hmax_value == 1. assert heuristic.relaxed_facts['v3'].hmax_value == 2. assert heuristic.relaxed_facts['v6'].hmax_value == 2. assert heuristic.relaxed_facts['v4'].hmax_value == 3. assert heuristic.relaxed_facts['v5'].hmax_value == 3. assert heuristic.relaxed_facts['g'].hmax_value == 4. assert heuristic.relaxed_ops['op1'].hmax_supporter.name == 'v1' assert heuristic.relaxed_ops['op2'].hmax_supporter.name == 'v2' assert heuristic.relaxed_ops['op3'].hmax_supporter.name == 'v3' assert heuristic.relaxed_ops['op4'].hmax_supporter.name in {'v4', 'v5'} assert heuristic.relaxed_ops['op5'].hmax_supporter.name == 'v2' assert heuristic.relaxed_ops['op6'].hmax_supporter.name == 'v6'
def test_lm_cut_hmax_intermediate_two_paths(): task1 = _get_intermediate_task_two_paths() heuristic = LmCutHeuristic(task1) heuristic.compute_hmax(task1.initial_state) assert heuristic.relaxed_facts["v1"].hmax_value == 0.0 assert heuristic.relaxed_facts["v2"].hmax_value == 1.0 assert heuristic.relaxed_facts["v3"].hmax_value == 2.0 assert heuristic.relaxed_facts["v6"].hmax_value == float("inf") assert not heuristic.relaxed_facts["v6"] in heuristic.reachable assert heuristic.relaxed_facts["v4"].hmax_value == 2.0 assert heuristic.relaxed_facts["v5"].hmax_value == 2.0 assert heuristic.relaxed_facts["v7"].hmax_value == 3.0 assert heuristic.relaxed_facts["g"].hmax_value == 4.0 assert heuristic.relaxed_ops["op1"].hmax_supporter.name == "v1" assert heuristic.relaxed_ops["op2"].hmax_supporter.name == "v2" assert heuristic.relaxed_ops["op3"].hmax_supporter.name == "v3" assert heuristic.relaxed_ops["op4"].hmax_supporter.name == "v7" assert heuristic.relaxed_ops["op5"].hmax_supporter.name == "v2"
def test_lm_cut_hmax_intermediate_two_paths(): task1 = _get_intermediate_task_two_paths() heuristic = LmCutHeuristic(task1) heuristic.compute_hmax(task1.initial_state) assert heuristic.relaxed_facts['v1'].hmax_value == 0. assert heuristic.relaxed_facts['v2'].hmax_value == 1. assert heuristic.relaxed_facts['v3'].hmax_value == 2. assert heuristic.relaxed_facts['v6'].hmax_value == float('inf') assert not heuristic.relaxed_facts['v6'] in heuristic.reachable assert heuristic.relaxed_facts['v4'].hmax_value == 2. assert heuristic.relaxed_facts['v5'].hmax_value == 2. assert heuristic.relaxed_facts['v7'].hmax_value == 3. assert heuristic.relaxed_facts['g'].hmax_value == 4. assert heuristic.relaxed_ops['op1'].hmax_supporter.name == 'v1' assert heuristic.relaxed_ops['op2'].hmax_supporter.name == 'v2' assert heuristic.relaxed_ops['op3'].hmax_supporter.name == 'v3' assert heuristic.relaxed_ops['op4'].hmax_supporter.name == 'v7' assert heuristic.relaxed_ops['op5'].hmax_supporter.name == 'v2'