diff --git a/planetarium/oracle.py b/planetarium/oracle.py index 81e4489..7a08a9b 100644 --- a/planetarium/oracle.py +++ b/planetarium/oracle.py @@ -17,7 +17,6 @@ _fully_specify_gripper, _plan_gripper, ) -from .oracles.rover import _reduce_rover, _inflate_rover, _fully_specify_rover from .oracles.rover_single import _reduce_rover_single, _inflate_rover_single, _fully_specify_rover_single @@ -53,8 +52,6 @@ def reduce( return _reduce_blocksworld(graph) case "gripper": return _reduce_gripper(graph) - case "rover": - return _reduce_rover(graph) case "rover-single": return _reduce_rover_single(graph) case _: @@ -81,8 +78,6 @@ def inflate( return _inflate_blocksworld(scene) case "gripper": return _inflate_gripper(scene) - case "rover": - return _inflate_rover(scene) case "rover-single": return _inflate_rover_single(scene) case _: @@ -119,10 +114,6 @@ def fully_specify( reduced_init, reduced_goal, ) - case "rover": - reduced_init, fully_specified_goal = _fully_specify_rover( - *problem.decompose() - ) case "rover-single": reduced_init, fully_specified_goal = _fully_specify_rover_single( *problem.decompose() diff --git a/planetarium/oracles/rover.py b/planetarium/oracles/rover.py deleted file mode 100644 index 06a6545..0000000 --- a/planetarium/oracles/rover.py +++ /dev/null @@ -1,645 +0,0 @@ -from typing import Any - -from collections import defaultdict -import copy - -import rustworkx as rx - -from planetarium import graph -from ..reduced_graph import ( - ReducedProblemGraph, - ReducedSceneGraph, - ReducedNode, - ReducedNodes, -) - - -# Add enums for the rover domain -ReducedNode.register( - { - "SOIL_ANALYSIS": "equipped_for_soil_analysis", - "ROCK_ANALYSIS": "equipped_for_rock_analysis", - "IMAGING": "equipped_for_imaging", - "EMPTY": "empty", - "FULL": "full", - "AVAILABLE": "available", - "COMMUNICATED_SOIL_DATA": "communicated_soil_data", - "COMMUNICATED_ROCK_DATA": "communicated_rock_data", - "AT_SOIL_SAMPLE": "at_soil_sample", - "AT_ROCK_SAMPLE": "at_rock_sample", - "CHANNEL_FREE": "channel_free", - }, - "rover", -) - - -def _reduced_rover_add_predicate( - reduced: graph.SceneGraph | graph.ProblemGraph, - predicate: dict[str, Any], -): - """Add a predicate to a reduced rover scene graph. - - Args: - reduced (graph.SceneGraph | graph.ProblemGraph): The scene graph to add - the predicate to. - predicate (dict[str, Any]): The predicate to add. - """ - params = predicate["parameters"] - reduced_edge = graph.PlanGraphEdge( - predicate=predicate["typing"], - scene=predicate.get("scene"), - ) - - match (predicate["typing"], len(params)): - case ("at", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("at_lander", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("can_traverse", 3): - predicate_node = graph.PlanGraphNode( - f"{params[0]}-{params[1]}-{params[2]}", - name="can_traverse", - label=graph.Label.PREDICATE, - typing="can_traverse", - scene=predicate.get("scene"), - ) - reduced.add_node(predicate_node) - for i, param in enumerate(params): - pos_edge = copy.deepcopy(reduced_edge) - pos_edge.position = i - reduced.add_edge(predicate_node, param, pos_edge) - - case ("equipped_for_soil_analysis", 1): - reduced.add_edge(ReducedNode.SOIL_ANALYSIS, params[0], reduced_edge) - case ("equipped_for_rock_analysis", 1): - reduced.add_edge(ReducedNode.ROCK_ANALYSIS, params[0], reduced_edge) - case ("equipped_for_imaging", 1): - reduced.add_edge(ReducedNode.IMAGING, params[0], reduced_edge) - case ("empty", 1): - reduced.add_edge(ReducedNode.EMPTY, params[0], reduced_edge) - case ("full", 1): - reduced.add_edge(ReducedNode.FULL, params[0], reduced_edge) - case ("have_rock_analysis", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("have_soil_analysis", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("calibrated", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("supports", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("available", 1): - reduced.add_edge(ReducedNode.AVAILABLE, params[0], reduced_edge) - case ("visible", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("have_image", 3): - predicate_node = graph.PlanGraphNode( - f"{params[0]}-{params[1]}-{params[2]}", - name="have_image", - label=graph.Label.PREDICATE, - typing="have_image", - scene=predicate.get("scene"), - ) - reduced.add_node(predicate_node) - for i, param in enumerate(params): - pos_edge = copy.deepcopy(reduced_edge) - pos_edge.position = i - reduced.add_edge(predicate_node, param, pos_edge) - case ("communicated_soil_data", 1): - reduced.add_edge( - ReducedNode.COMMUNICATED_SOIL_DATA, params[0], reduced_edge - ) - case ("communicated_rock_data", 1): - reduced.add_edge( - ReducedNode.COMMUNICATED_ROCK_DATA, params[0], reduced_edge - ) - case ("communicated_image_data", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("at_soil_sample", 1): - reduced.add_edge(ReducedNode.AT_SOIL_SAMPLE, params[0], reduced_edge) - case ("at_rock_sample", 1): - reduced.add_edge(ReducedNode.AT_ROCK_SAMPLE, params[0], reduced_edge) - case ("visible_from", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("store_of", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("calibration_target", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("on_board", 2): - reduced.add_edge(params[0], params[1], reduced_edge) - case ("channel_free", 1): - reduced.add_edge(ReducedNode.CHANNEL_FREE, params[0], reduced_edge) - - -def _reduce_rover( - scene: graph.SceneGraph | graph.ProblemGraph, -) -> ReducedSceneGraph | ReducedProblemGraph: - """Reduces a rover scene graph to a Directed Acyclic Graph. - - Args: - scene (graph.SceneGraph | graph.ProblemGraph): The scene graph to reduce. - - Raises: - ValueError: If the scene graph is not a Directed Acyclic Graph. - - Returns: - ReducedSceneGraph | ReducedProblemGraph: The reduced problem graph. - """ - match scene: - case graph.ProblemGraph( - _constants=constants, - _predicates=predicates, - _domain=domain, - _requirements=requirements, - ): - reduced = ReducedProblemGraph( - constants=constants, - domain=domain, - requirements=requirements, - ) - case graph.SceneGraph( - constants=constants, - _predicates=predicates, - scene=scene, - _domain=domain, - _requirements=requirements, - ): - reduced = ReducedSceneGraph( - constants=constants, - domain=domain, - scene=scene, - requirements=requirements, - ) - case _: - raise ValueError("Scene must be a SceneGraph or ProblemGraph.") - - for predicate in predicates: - _reduced_rover_add_predicate(reduced, predicate) - - return reduced - - -def _inflate_rover( - scene: ReducedSceneGraph | ReducedProblemGraph, -) -> graph.SceneGraph | graph.ProblemGraph: - """Respecify a rover scene graph. - - Args: - scene (ReducedGraph): The reduced SceneGraph of a scene. - - Returns: - graph.SceneGraph: The respecified scene graph. - """ - constants = [] - predicates = [] - - for node in scene.nodes: - if ( - not isinstance(node.node, ReducedNode) - and node.label == graph.Label.CONSTANT - ): - # add constants - constants.append({"name": node.node, "typing": node.typing}) - elif node.label == graph.Label.PREDICATE and node.typing in ( - "can_traverse", - "have_image", - ): - # add multi-arity predicates - params = scene.out_edges(node) - params.sort(key=lambda x: x[1].position) - - predicates.append( - { - "typing": node.typing, - "parameters": [param.node for param, _ in params], - "scene": node.scene, - } - ) - - for u, v, edge in scene.edges: - match (u, v): - case (predicate, _) if predicate.node in ReducedNodes["rover"]: - predicates.append( - { - "typing": predicate.node.value, - "parameters": [v.node], - "scene": edge.scene, - } - ) - case ( - predicate, - _, - ) if predicate.label == graph.Label.PREDICATE and predicate.typing in ( - "can_traverse", - "have_image", - ): - # add separately to handle multi-arity predicates - pass - case (_, _): - predicates.append( - { - "typing": edge.predicate, - "parameters": [u.node, v.node], - "scene": edge.scene, - } - ) - - if isinstance(scene, ReducedProblemGraph): - return graph.ProblemGraph( - constants, - [pred for pred in predicates if pred["scene"] == graph.Scene.INIT], - [pred for pred in predicates if pred["scene"] == graph.Scene.GOAL], - domain="rover", - requirements=scene._requirements, - ) - else: - return graph.SceneGraph( - constants, - predicates, - domain="rover", - scene=scene.scene, - requirements=scene._requirements, - ) - - -def _rover_get_unchangeable_predicates( - scene: ReducedSceneGraph, -) -> list[dict[str, Any]]: - """Get the unchangeable predicates in a rover scene graph. - - Args: - scene (ReducedGraph): The reduced SceneGraph of a scene. - - Returns: - list[dict[str, Any]]: The unchangeable predicates in the scene graph. - """ - predicates = [] - - for node in scene.nodes: - # ternary unchangeable predicates - if node.label == graph.Label.PREDICATE and node.typing in ( - "can_traverse", - "have_image", - ): - params = scene.out_edges(node) - params.sort(key=lambda x: x[1].position) - predicates.append( - { - "typing": node.node, - "parameters": [param.node for param, _ in params], - } - ) - - for u, v, edge in scene.edges: - match edge: - # unary unchangeable predicates - case pred if pred.predicate in ( - "equipped_for_soil_analysis", - "equipped_for_rock_analysis", - "equipped_for_imaging", - "available", # changes but always changes back - "channel_free", # changes but always changes back - "communicated_soil_data", - "communicated_rock_data", - ): - predicates.append( - { - "typing": pred.predicate, - "parameters": [v.node], - } - ) - # binary unchangeable predicates - case pred if pred.predicate in ( - "supports", - "communicated_image_data", - "visible_from", - "store_of", - "calibration_target", - "on_board", - "at_lander", - ): - predicates.append( - { - "typing": pred.predicate, - "parameters": [u.node, v.node], - } - ) - - return predicates - - -def _rover_get_typed_objects( - scene: ReducedSceneGraph, -) -> dict[ - ReducedNode, - set[graph.PlanGraphNode] - | dict[ - graph.PlanGraphNode, - set[graph.PlanGraphNode], - ], -]: - """Get the typed objects in a rover scene graph. - - Args: - scene (ReducedGraph): The reduced SceneGraph of a scene. - - Returns: - dict[ReducedNode, set[graph.PlanGraphNode] | dict[graph.PlanGraphNode, - set[graph.PlanGraphNode]]]: The typed objects in the scene graph. - """ - rover: set[graph.PlanGraphNode] = set() - equipped_for_soil: set[graph.PlanGraphNode] = set() - equipped_for_rock: set[graph.PlanGraphNode] = set() - equipped_for_imaging: set[graph.PlanGraphNode] = set() - has_cameras = defaultdict(set) - has_stores = defaultdict(set) - - waypoints: set[graph.PlanGraphNode] = set() - stores: set[graph.PlanGraphNode] = set() - cameras: set[graph.PlanGraphNode] = set() - modes: set[graph.PlanGraphNode] = set() - landers: set[graph.PlanGraphNode] = set() - objectives: set[graph.PlanGraphNode] = set() - - objects: dict[ - str, - set[graph.PlanGraphNode] | dict[graph.PlanGraphNode, set[graph.PlanGraphNode]], - ] = { - "rover": rover, - "equipped_for_soil_analysis": equipped_for_soil, - "equipped_for_rock_analysis": equipped_for_rock, - "equipped_for_imaging": equipped_for_imaging, - "has_cameras": has_cameras, - "has_stores": has_stores, - "waypoint": waypoints, - "store": stores, - "camera": cameras, - "mode": modes, - "lander": landers, - "objective": objectives, - } - - for node in scene.nodes: - if node.label == graph.Label.CONSTANT: - for typing in node.typing: - objects[typing].add(node) - if node.typing == {"rover"}: - if scene.has_edge(ReducedNode.SOIL_ANALYSIS, node.node): - equipped_for_soil.add(node) - if scene.has_edge(ReducedNode.ROCK_ANALYSIS, node.node): - equipped_for_rock.add(node) - if scene.has_edge(ReducedNode.IMAGING, node.node): - equipped_for_imaging.add(node) - elif node.typing == {"camera"}: - rover = [ - r - for r, edge in scene.out_edges(node.node) - if edge.predicate == "on_board" - ] - for r in rover: - has_cameras[r].add(node) - elif node.typing == {"store"}: - rover = [ - r - for r, edge in scene.out_edges(node) - if edge.predicate == "store_of" - ] - for r in rover: - has_stores[r].add(node) - - return objects - - -def _rover_subgraph( - scene: ReducedSceneGraph, - rover: graph.PlanGraphNode, -) -> ReducedSceneGraph: - """Get the subgraph of a specific rover in a rover scene graph. - - Args: - scene (ReducedGraph): The reduced SceneGraph of a scene. - rover (graph.PlanGraphNode): The rover to get the subgraph of. - - Returns: - ReducedSceneGraph: The subgraph for the rover, where each waypoint is - traversable by the rover. - """ - objects = _rover_get_typed_objects(scene) - subgraph = ReducedSceneGraph( - constants=[], - domain="ROVER_SUBGRAPH", - scene=scene.scene, - requirements=(*scene._requirements, "ROVER_SUBGRAPH"), - ) - - for node in [ - rover, - *objects["waypoint"], - *objects["objective"], - *objects["lander"], - ]: - subgraph.add_node(copy.deepcopy(node)) - - # take all edges related to the above and copy it over - for u, v, edge in scene.edges: - if u in subgraph.nodes and v in subgraph.nodes: - if edge.predicate == "at_lander": - subgraph.add_edge(v.node, u.node, edge) - elif edge.predicate == "at": - subgraph.add_edge(u.node, v.node, edge) - elif edge.predicate == "visible_from": - if u in objects["objective"] and v in objects["waypoint"]: - subgraph.add_edge(v.node, u.node, edge) - - # can_traverse is encoded in predicate nodes - for node in scene.nodes: - if node.label == graph.Label.PREDICATE and node.typing == "can_traverse": - params = sorted(scene.out_edges(node), key=lambda x: x[1].position) - params = [p for p, _ in params] - if params[0] == rover: - reduced_edge = graph.PlanGraphEdge( - predicate=node.typing, - scene=scene.scene, - ) - # if visible edge exists, add can_traverse edge - edges = [ - edge for u, v, edge in scene.edges if edge.predicate == "visible" - ] - if edges: - subgraph.add_edge(params[1], params[2], reduced_edge) - - return subgraph - - -def _fully_specify_rover( - inflated_init: graph.SceneGraph, - inflated_goal: graph.SceneGraph, -) -> tuple[ReducedSceneGraph, ReducedSceneGraph]: - """Fully specifies a rover scene graph. - - Args: - init (graph.SceneGraph): The reduced SceneGraph of the initial scene. - goal (graph.SceneGraph): The reduced SceneGraph of the goal scene. - - Returns: - ReducedSceneGraph: The fully specified scene graph. - """ - # NOTE: we assume bidirectional traversal and visibility - # Removing this assumption would require bfs planning for this domain. - init = _reduce_rover(inflated_init) - - # bring unchangeable predicates from init to goal - unchangeable_predicates = _rover_get_unchangeable_predicates(init) - for pred in unchangeable_predicates: - if pred not in inflated_goal.predicates: - inflated_goal._add_predicate(pred, scene=graph.Scene.GOAL) - - objects = _rover_get_typed_objects(init) - # if there is only one waypoint, everyone must be at it in the goal (if they are at it in the init) - if len(objects["waypoint"]) == 1: - (waypoint,) = objects["waypoint"] - for rover in objects["rover"]: - pred = { - "typing": "at", - "parameters": [rover.name, waypoint.name], - } - init_pred = dict(**pred, scene=graph.Scene.INIT) - goal_pred = dict(**pred, scene=graph.Scene.GOAL) - if ( - goal_pred not in inflated_goal.predicates - and init_pred in inflated_init.predicates - ): - inflated_goal._add_predicate(goal_pred, scene=graph.Scene.GOAL) - for lander in objects["lander"]: - pred = { - "typing": "at_lander", - "parameters": [lander.name, waypoint.name], - } - init_pred = dict(**pred, scene=graph.Scene.INIT) - goal_pred = dict(**pred, scene=graph.Scene.GOAL) - if ( - goal_pred not in inflated_goal.predicates - and init_pred in inflated_init.predicates - ): - inflated_goal._add_predicate(goal_pred, scene=graph.Scene.GOAL) - - # Handle rock, soil, and image data: - # - if data has been communicated, and there is only rover that - # could have communicated it, then we need to add this to the fully specified goal - # - if data has been communicated, and there is more than one rover that - # could have communicated it, then we can't decide who communicated it, and - # we don't have anything to add to the fully specified goal - - rover_maps = {r: _rover_subgraph(init, r) for r in objects["rover"]} - - # for every soil sample that needs collecting/communicating: - # check if we can attach to a specific rover - def rover_can_reach_and_communicate(rover, waypoint): - # can this rover reach the sample - reachable, communicable = False, False - - G = rover_maps[rover] - rover, _ = G._node_lookup[rover.node] - waypoint, _ = G._node_lookup[waypoint.node] - - if reachable := rx.has_path(G.graph, rover, waypoint): - # can this rover, from the waypoint, communicate to a lander? - for lander in objects["lander"]: - lander, _ = G._node_lookup[lander.node] - if communicable := rx.has_path(G.graph, rover, lander): - break - - return reachable and communicable - - def rover_can_image_and_communicate(rover, objective): - # can this rover reach the sample - reachable, communicable = False, False - - G = rover_maps[rover] - rover, _ = G._node_lookup[rover.node] - objective, _ = G._node_lookup[objective.node] - - if reachable := rx.has_path(G.graph, rover, objective): - paths = rx.all_simple_paths(G.graph, rover, objective) - # can this rover, from the waypoint, communicate to a lander? - for lander in objects["lander"]: - lander, _ = G._node_lookup[lander.node] - for path in paths: - if communicable := rx.has_path(G.graph, path[-2], lander): - break - - return reachable and communicable - - # DO NOT ADD PREDICATES TO INFLATED_GOAL DIRECTLY AFTER HERE - goal = _reduce_rover(inflated_goal) - # soil and rock - for analysis_type, have, reduced_node in ( - ("soil_analysis", "soil_sample", ReducedNode.COMMUNICATED_SOIL_DATA), - ("rock_analysis", "rock_sample", ReducedNode.COMMUNICATED_ROCK_DATA), - ): - for waypoint in goal.successors(reduced_node): - if waypoint in init.successors(reduced_node): - continue - equipped_rover = objects[f"equipped_for_{analysis_type}"] - # only equipped rover with storage can communicate - equipped_rover = [ - rover for rover in equipped_rover if objects["has_stores"][rover] - ] - # If a store is not specified as full or empty in the init, we can't - # use it to communicate data (it might be full or empty). - equipped_rover = [ - rover - for rover in equipped_rover - if any( - store - for store in objects["has_stores"][rover] - if init.has_edge(ReducedNode.EMPTY, store) - or init.has_edge(ReducedNode.FULL, store) - ) - ] - valid_rover: list[graph.PlanGraphNode] = [] - for rover in equipped_rover: - if rover_can_reach_and_communicate(rover, waypoint): - valid_rover.append(rover) - if len(valid_rover) > 1: - break - - if len(valid_rover) == 1: - _reduced_rover_add_predicate( - goal, - { - "typing": f"have_{have}", - "parameters": [valid_rover[0].node], - "scene": graph.Scene.GOAL, - }, - ) - - # images (adding fully_specified have_image propositions) - image_edges = [E for E in goal.edges if E[2].predicate == "communicated_image_data"] - for objective, mode, _ in image_edges: - # if init also has this edge, we don't need to worry about processing have_image for this edge - if [ - edge - for _v, edge in init.out_edges(objective.node) - if edge.predicate == "communicated_image_data" and mode.node == _v.node - ]: - continue - valid_rover: list[graph.PlanGraphNode] = [] - for rover in objects[f"equipped_for_imaging"]: - cameras = objects["has_cameras"][rover] - if not any(goal.has_edge(camera.node, mode.node) for camera in cameras): - continue - if rover_can_image_and_communicate(rover, objective): - valid_rover.append(rover) - if len(valid_rover) > 1: - break - - if len(valid_rover) == 1: - _reduced_rover_add_predicate( - goal, - { - "typing": "have_image", - "parameters": [valid_rover[0].node, objective.node, mode.node], - }, - ) - - return init, goal diff --git a/planetarium/oracles/rover_single.py b/planetarium/oracles/rover_single.py index 5e6df91..68759da 100644 --- a/planetarium/oracles/rover_single.py +++ b/planetarium/oracles/rover_single.py @@ -491,7 +491,7 @@ def _init_waypoint() -> list[int]: endpoints = {rover_map.graph.nodes()[e] for e in endpoints} - if not final_destination(): + if not final_pos: # rover doesn't need to be at a particular location, # check how many locations he can be at if len(endpoints) == 1: diff --git a/tests/problem_fixtures.py b/tests/problem_fixtures.py index 98afb6a..8c8fae3 100644 --- a/tests/problem_fixtures.py +++ b/tests/problem_fixtures.py @@ -1731,3 +1731,66 @@ def rover_single_line_fully_specified_2(): ) ) )""" + + +@pytest.fixture +def rover_single_line_fully_specified_3(): + return """ + (define (problem rover) + (:domain rover-single) + (:objects + site1 site2 site3 site4 site5 site6 - waypoint + store1 store2 - store + rgb - mode + camera1 camera2 camera3 - camera + objective1 objective2 objective3 - objective + ) + (:init + (can_traverse site1 site2) + (can_traverse site2 site3) + (can_traverse site3 site4) + (can_traverse site4 site5) + (can_traverse site5 site6) + (visible site1 site2) + (visible site2 site3) + (visible site3 site4) + (visible site4 site5) + (visible site5 site6) + (at_rover site1) + (available) + (at_lander site6) + (empty store1) + (full store2) + (supports camera1 rgb) + (supports camera2 rgb) + (supports camera3 rgb) + (visible_from objective1 site5) + (channel_free) + ) + (:goal + (and + (can_traverse site1 site2) + (can_traverse site2 site3) + (can_traverse site3 site4) + (can_traverse site4 site5) + (can_traverse site5 site6) + (visible site1 site2) + (visible site2 site3) + (visible site3 site4) + (visible site4 site5) + (visible site5 site6) + (available) + (at_rover site6) + (at_lander site6) + (empty store1) + (full store2) + (supports camera1 rgb) + (supports camera2 rgb) + (supports camera3 rgb) + (visible_from objective1 site5) + (channel_free) + (have_image objective1 rgb) + (communicated_image_data objective1 rgb) + ) + ) + )""" \ No newline at end of file diff --git a/tests/test_evaluate.py b/tests/test_evaluate.py index 0f2295f..1bb3f57 100644 --- a/tests/test_evaluate.py +++ b/tests/test_evaluate.py @@ -9,8 +9,6 @@ blocksworld_missing_ontables, blocksworld_fully_specified, blocksworld_invalid_1, - rover_line_fully_specified_1, - rover_line_fully_specified_2, ) @@ -283,23 +281,6 @@ def test_evaluate_inequivalent( False, ) - def test_unsolveable_rovers( - self, - rover_line_fully_specified_1, - rover_line_fully_specified_2, - ): - """ - Test if the evaluation of PDDL problem descriptions is correct. - """ - assert planetarium.evaluate( - rover_line_fully_specified_1, - rover_line_fully_specified_1, - ) == (True, True, True) - assert planetarium.evaluate( - rover_line_fully_specified_2, - rover_line_fully_specified_2, - ) == (True, False, False) - class TestUnsupportedDomain: """ diff --git a/tests/test_metric.py b/tests/test_metric.py index a6094c2..d82fce5 100644 --- a/tests/test_metric.py +++ b/tests/test_metric.py @@ -22,8 +22,6 @@ blocksworld_fully_specified, gripper_fully_specified, gripper_no_robby, - rover_line_fully_specified, - rover_line_fully_specified_1, ) @@ -290,14 +288,3 @@ def test_blocksworld_equivalence( assert not metric.equals(p2, p1, is_placeholder=True) assert not metric.equals(p2, p1, is_placeholder=False) - def test_rover_equivalence(self, rover_line_fully_specified_1): - """Test the equivalence of rover problems.""" - p1 = builder.build(rover_line_fully_specified_1) - p2 = oracle.fully_specify(p1) - - assert metric.equals(p1.init(), p2.init(), is_placeholder=True) - assert metric.equals(p1.init(), p2.init(), is_placeholder=False) - assert metric.equals(p1.goal(), p2.goal(), is_placeholder=True) - assert metric.equals(p1.goal(), p2.goal(), is_placeholder=False) - assert metric.equals(p1, p2, is_placeholder=True) - assert metric.equals(p1, p2, is_placeholder=False) diff --git a/tests/test_oracle.py b/tests/test_oracle.py index 02d4fb7..3d68c8d 100644 --- a/tests/test_oracle.py +++ b/tests/test_oracle.py @@ -17,17 +17,10 @@ gripper_underspecified_2, gripper_underspecified_3, gripper_no_robby_init, - rover_line, - rover_line_fully_specified, - rover_line_fully_specified_1, - rover_line_fully_specified_2, - rover_line_missing_visible, - rover_line_1, - rover_line_2, - rover_line_underspecified_1, rover_single_line_fully_specified, rover_single_line_fully_specified_1, rover_single_line_fully_specified_2, + rover_single_line_fully_specified_3, ) @@ -190,62 +183,6 @@ def test_underspecified( assert oracle.fully_specify(full) == full -class TestRoverOracle: - """ - Test suite for the rover oracle. - """ - - def test_fully_specified( - self, - subtests, - rover_line_fully_specified, - rover_line_fully_specified_1, - rover_line_fully_specified_2, - ): - """ - Test the fully specified rover problem. - """ - descs = [ - ("rover_line_fully_specified", rover_line_fully_specified), - ("rover_line_fully_specified_1", rover_line_fully_specified_1), - ("rover_line_fully_specified_2", rover_line_fully_specified_2), - ] - for name, desc in descs: - with subtests.test(name): - problem = builder.build(desc) - full = oracle.fully_specify(problem) - assert oracle.fully_specify(full) == problem - - def test_under_specified( - self, - subtests, - rover_line, - rover_line_missing_visible, - rover_line_1, - rover_line_2, - rover_line_underspecified_1, - ): - """ - Test the under specified rover problem. - """ - descs = [ - ("rover_line", rover_line), - ("rover_line_missing_visible", rover_line_missing_visible), - ("rover_line_1", rover_line_1), - ("rover_line_2", rover_line_2), - ("rover_line_underspecified_1", rover_line_underspecified_1), - ] - for name, desc in descs: - with subtests.test(name): - problem = builder.build(desc) - full = oracle.fully_specify(problem) - assert full != problem - assert oracle.fully_specify(full) == full - - def test_inflate(self): - pass - - class TestRoverSingleOracle: """ Test suite for the rover oracle. @@ -257,6 +194,7 @@ def test_fully_specified( rover_single_line_fully_specified, rover_single_line_fully_specified_1, rover_single_line_fully_specified_2, + rover_single_line_fully_specified_3, ): """ Test the fully specified rover problem. @@ -265,6 +203,7 @@ def test_fully_specified( ("rover_single_line_fully_specified", rover_single_line_fully_specified), ("rover_single_line_fully_specified_1", rover_single_line_fully_specified_1), ("rover_single_line_fully_specified_2", rover_single_line_fully_specified_2), + ("rover_single_line_fully_specified_3", rover_single_line_fully_specified_3), ] for name, desc in descs: with subtests.test(name):