13
13
14
14
import itertools
15
15
16
+ from ..asp import strips_problem
16
17
from ..exceptions import UnimplementedFeature
17
18
from ..asp .utilities import ProblemException , default_type_name , cond_prefix ,\
18
19
inequality_prefix , grounding_error_code , lower_var_alphabet , NOT_CONDITION ,\
@@ -75,6 +76,8 @@ def __str__(self):
75
76
"""
76
77
return self .name
77
78
79
+ __repr__ = __str__
80
+
78
81
def add_object (self , obj ):
79
82
""" Add the object to the type and to all of its ancestors.
80
83
(Type, str) -> None
@@ -143,9 +146,9 @@ def __str__(self):
143
146
""" Return a short string representation of the predicate
144
147
(Predicate) -> str
145
148
"""
146
- return "( " + self .name + " " + " " .join ([x + " - " + str (y )\
147
- for x , y in zip (self .variables , self .types )]) + " )"
149
+ return "( " + self .name + " " + " " .join (x + " - " + str (y ) for x , y in zip (self .variables , self .types )) + " )"
148
150
151
+ __repr__ = __str__
149
152
150
153
class Condition (object ):
151
154
""" A formula used as a precondition or head of an axiom or conditional effect. """
@@ -155,6 +158,7 @@ def __init__(self):
155
158
(Condition) -> None
156
159
"""
157
160
self .groundings = []
161
+ self .bindings = []
158
162
self .desc = None
159
163
160
164
def substitute_derived_predicates (self , derived_predicates , seen_preds ):
@@ -298,12 +302,9 @@ def detect_statics(self, candidates, neg_candidates):
298
302
""" Remove entries from candidates which are deleted somewhere in this effect.
299
303
(PredicateCondition, set([(Predicate, [str])], set([(Predicate, [str])) -> None
300
304
"""
301
- if self .sign :
302
- for grounding in self .groundings :
303
- neg_candidates .discard ((self .pred , grounding ))
304
- else :
305
- for grounding in self .groundings :
306
- candidates .discard ((self .pred , grounding ))
305
+ cand_list = candidates if not self .sign else neg_candidates
306
+ for binding in self .bindings :
307
+ cand_list .discard ((self .pred , binding ))
307
308
308
309
def link_groundings (self , static_preds , neg_static_preds ):
309
310
""" Link the groundings in this condition to the groundings in its
@@ -1484,6 +1485,7 @@ def __init__(self, name, parameters, types, precondition, effect, is_derived):
1484
1485
self .is_noop = False
1485
1486
1486
1487
self .groundings = []
1488
+ self .bindings = [] # Same as groundings, but maps variable name to actual value
1487
1489
self .ground_preconditions = {}
1488
1490
self .ground_effects = {}
1489
1491
0 commit comments