def random_pdkb(depth, numAg, fluents, numRMLs, output=True): agents = list(range(1, numAg + 1)) kb = PDKB(depth, agents, fluents) count = 0 new_rmls = set() while count < numRMLs: rml = random_rml(depth, agents, fluents) if rml not in kb.rmls and neg(rml) not in kb.rmls: # Take advantage of the fact that we know the closure # is just the union of the closure of each RML test_rmls = list(kd_closure(rml)) + [rml] cons = True for trml in test_rmls: if neg(trml) in kb.rmls: cons = False if cons: if output: print "Added %s" % rml for trml in test_rmls: kb.add_rml(trml) new_rmls.add(rml) count += 1 kb.rmls = new_rmls return kb
def preprocess(self): # Project the initial state new_init = PDKB(self.init.depth, self.init.agents, self.init.props) rmls = self.init.rmls for ag in self.agent_projection: rmls = project(rmls, ag) new_init.rmls = rmls self.init = new_init self.orig_cond_count = 0 self.comp_cond_count = 0 # Expand and project the action's effects with derived conditional effects for act in self.domain.actions: self.orig_cond_count += sum([ len(act.effs[i][0]) + len(act.effs[i][1]) for i in range(len(act.effs)) ]) act.expand() self.comp_cond_count += sum([ len(act.effs[i][0]) + len(act.effs[i][1]) for i in range(len(act.effs)) ]) for ag in self.agent_projection: act.project_effects(ag) if self.agent_projection: # We project the precondition separately since we are in the # perspective of the final agent act.project_pre(self.agent_projection[-1])
def preprocess(self): # Project the initial state new_init = PDKB(self.init.depth, self.init.agents, self.init.props) rmls = self.init.rmls for ag in self.agent_projection: rmls = project(rmls, ag) new_init.rmls = rmls self.init = new_init # Expand and project the action's effects with derived conditional effects for act in self.domain.actions: act.expand() for ag in self.agent_projection: act.project_effects(ag) if self.agent_projection: # We project the precondition separately since we are in the # perspective of the final agent act.project_pre(self.agent_projection[-1])