MCPcopy Create free account
hub / github.com/caelan/pddlstream / SkeletonQueue

Class SkeletonQueue

pddlstream/algorithms/skeleton.py:261–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259STANDBY = None
260
261class SkeletonQueue(Sized):
262 def __init__(self, store, domain, disable=True):
263 # TODO: multi-threaded
264 self.store = store
265 self.domain = domain
266 self.skeletons = []
267 self.queue = [] # TODO: deque version
268 self.disable = disable
269 self.standby = []
270
271 @property
272 def evaluations(self):
273 return self.store.evaluations
274
275 def __len__(self):
276 return len(self.queue)
277
278 def is_active(self):
279 return self.queue and (not self.store.is_terminated())
280
281 def push_binding(self, binding):
282 # TODO: add to standby if not active
283 priority = binding.get_priority()
284 element = HeapElement(priority, binding)
285 heappush(self.queue, element)
286
287 def pop_binding(self):
288 priority, binding = heappop(self.queue)
289 #return binding
290 return priority, binding
291
292 def peak_binding(self):
293 if not self.queue:
294 return None
295 priority, binding = self.queue[0]
296 return priority, binding
297
298 def new_skeleton(self, stream_plan, action_plan, cost):
299 skeleton = Skeleton(self, stream_plan, action_plan, cost)
300 self.skeletons.append(skeleton)
301 self.push_binding(skeleton.root)
302 #self.greedily_process()
303 return skeleton
304
305 def readd_standby(self):
306 for binding in self.standby:
307 self.push_binding(binding)
308 self.standby = []
309
310 #########################
311
312 def _process_binding(self, binding):
313 assert binding.calls <= binding.visits # TODO: global DEBUG mode
314 readd = is_new = False
315 if binding.is_dominated():
316 return readd, is_new
317 if binding.is_fully_bound:
318 action_plan = binding.skeleton.bind_action_plan(binding.mapping)

Callers 2

solve_abstractFunction · 0.90
constraint_satisfactionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected