|
17 | 17 | from predicators.planning import PlanningFailure, PlanningTimeout, \ |
18 | 18 | run_task_plan_once, sesame_plan |
19 | 19 | from predicators.settings import CFG |
20 | | -from predicators.structs import NSRT, Action, GroundAtom, Metrics, \ |
21 | | - ParameterizedOption, Predicate, State, Task, Type, _GroundNSRT, _Option,\ |
22 | | - ConceptPredicate |
| 20 | +from predicators.structs import NSRT, Action, ConceptPredicate, GroundAtom, \ |
| 21 | + Metrics, ParameterizedOption, Predicate, State, Task, Type, _GroundNSRT, \ |
| 22 | + _Option |
23 | 23 |
|
24 | 24 |
|
25 | 25 | class BilevelPlanningApproach(BaseApproach): |
26 | 26 | """Bilevel planning approach.""" |
27 | 27 |
|
28 | | - def __init__(self, |
29 | | - initial_predicates: Set[Predicate], |
30 | | - initial_options: Set[ParameterizedOption], |
31 | | - types: Set[Type], |
32 | | - action_space: Box, |
33 | | - train_tasks: List[Task], |
34 | | - task_planning_heuristic: str = "default", |
35 | | - max_skeletons_optimized: int = -1, |
36 | | - bilevel_plan_without_sim: Optional[bool] = None, |
37 | | - option_model: Optional[_OptionModelBase] = None, |
38 | | - initial_concept_predicates: Set[ConceptPredicate] = set(), |
39 | | - ) -> None: |
40 | | - super().__init__(initial_predicates, |
41 | | - initial_options, types, |
42 | | - action_space, train_tasks, |
43 | | - initial_concept_predicates=initial_concept_predicates) |
| 28 | + def __init__( |
| 29 | + self, |
| 30 | + initial_predicates: Set[Predicate], |
| 31 | + initial_options: Set[ParameterizedOption], |
| 32 | + types: Set[Type], |
| 33 | + action_space: Box, |
| 34 | + train_tasks: List[Task], |
| 35 | + task_planning_heuristic: str = "default", |
| 36 | + max_skeletons_optimized: int = -1, |
| 37 | + bilevel_plan_without_sim: Optional[bool] = None, |
| 38 | + option_model: Optional[_OptionModelBase] = None, |
| 39 | + initial_concept_predicates: Set[ConceptPredicate] = set(), |
| 40 | + ) -> None: |
| 41 | + super().__init__(initial_predicates, |
| 42 | + initial_options, |
| 43 | + types, |
| 44 | + action_space, |
| 45 | + train_tasks, |
| 46 | + initial_concept_predicates=initial_concept_predicates) |
44 | 47 | if task_planning_heuristic == "default": |
45 | 48 | task_planning_heuristic = CFG.sesame_task_planning_heuristic |
46 | 49 | if max_skeletons_optimized == -1: |
@@ -191,12 +194,13 @@ def _get_current_predicates(self) -> Set[Predicate]: |
191 | 194 | Defaults to initial predicates. |
192 | 195 | """ |
193 | 196 | return self._initial_predicates | self._initial_concept_predicates |
194 | | - |
| 197 | + |
195 | 198 | def _get_current_concept_predicates(self) -> Set[ConceptPredicate]: |
196 | | - """Get the current set of concept predicates. |
197 | | - """ |
198 | | - cnpt_preds = set([pred for pred in self._get_current_predicates() if |
199 | | - isinstance(pred, ConceptPredicate)]) |
| 199 | + """Get the current set of concept predicates.""" |
| 200 | + cnpt_preds = set([ |
| 201 | + pred for pred in self._get_current_predicates() |
| 202 | + if isinstance(pred, ConceptPredicate) |
| 203 | + ]) |
200 | 204 | return cnpt_preds |
201 | 205 |
|
202 | 206 | def get_option_model(self) -> _OptionModelBase: |
|
0 commit comments